]> git.ipfire.org Git - thirdparty/grsecurity-scrape.git/blob - test/grsecurity-3.0-3.12.7-201401120824.patch
Auto commit, 1 new patch{es}.
[thirdparty/grsecurity-scrape.git] / test / grsecurity-3.0-3.12.7-201401120824.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 4f7c57c..a2dc685 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 @@ -2001,6 +2005,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 @@ -2268,6 +2276,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 c2f0b79..2e5e090 100644
285 --- a/Makefile
286 +++ b/Makefile
287 @@ -241,8 +241,9 @@ CONFIG_SHELL := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
288
289 HOSTCC = gcc
290 HOSTCXX = g++
291 -HOSTCFLAGS = -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer
292 -HOSTCXXFLAGS = -O2
293 +HOSTCFLAGS = -Wall -W -Wmissing-prototypes -Wstrict-prototypes -Wno-unused-parameter -Wno-missing-field-initializers -O2 -fomit-frame-pointer -fno-delete-null-pointer-checks
294 +HOSTCFLAGS += $(call cc-option, -Wno-empty-body)
295 +HOSTCXXFLAGS = -O2 -Wall -W -fno-delete-null-pointer-checks
296
297 # Decide whether to build built-in, modular, or both.
298 # Normally, just do built-in.
299 @@ -414,8 +415,8 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn \
300 # Rules shared between *config targets and build targets
301
302 # Basic helpers built in scripts/
303 -PHONY += scripts_basic
304 -scripts_basic:
305 +PHONY += scripts_basic gcc-plugins
306 +scripts_basic: gcc-plugins
307 $(Q)$(MAKE) $(build)=scripts/basic
308 $(Q)rm -f .tmp_quiet_recordmcount
309
310 @@ -576,6 +577,65 @@ else
311 KBUILD_CFLAGS += -O2
312 endif
313
314 +ifndef DISABLE_PAX_PLUGINS
315 +ifeq ($(call cc-ifversion, -ge, 0408, y), y)
316 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCXX)" "$(HOSTCXX)" "$(CC)")
317 +else
318 +PLUGINCC := $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-plugin.sh "$(HOSTCC)" "$(HOSTCXX)" "$(CC)")
319 +endif
320 +ifneq ($(PLUGINCC),)
321 +ifdef CONFIG_PAX_CONSTIFY_PLUGIN
322 +CONSTIFY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/constify_plugin.so -DCONSTIFY_PLUGIN
323 +endif
324 +ifdef CONFIG_PAX_MEMORY_STACKLEAK
325 +STACKLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/stackleak_plugin.so -DSTACKLEAK_PLUGIN
326 +STACKLEAK_PLUGIN_CFLAGS += -fplugin-arg-stackleak_plugin-track-lowest-sp=100
327 +endif
328 +ifdef CONFIG_KALLOCSTAT_PLUGIN
329 +KALLOCSTAT_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kallocstat_plugin.so
330 +endif
331 +ifdef CONFIG_PAX_KERNEXEC_PLUGIN
332 +KERNEXEC_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/kernexec_plugin.so
333 +KERNEXEC_PLUGIN_CFLAGS += -fplugin-arg-kernexec_plugin-method=$(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD) -DKERNEXEC_PLUGIN
334 +KERNEXEC_PLUGIN_AFLAGS := -DKERNEXEC_PLUGIN
335 +endif
336 +ifdef CONFIG_CHECKER_PLUGIN
337 +ifeq ($(call cc-ifversion, -ge, 0406, y), y)
338 +CHECKER_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/checker_plugin.so -DCHECKER_PLUGIN
339 +endif
340 +endif
341 +COLORIZE_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/colorize_plugin.so
342 +ifdef CONFIG_PAX_SIZE_OVERFLOW
343 +SIZE_OVERFLOW_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/size_overflow_plugin.so -DSIZE_OVERFLOW_PLUGIN
344 +endif
345 +ifdef CONFIG_PAX_LATENT_ENTROPY
346 +LATENT_ENTROPY_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/latent_entropy_plugin.so -DLATENT_ENTROPY_PLUGIN
347 +endif
348 +ifdef CONFIG_PAX_MEMORY_STRUCTLEAK
349 +STRUCTLEAK_PLUGIN_CFLAGS := -fplugin=$(objtree)/tools/gcc/structleak_plugin.so -DSTRUCTLEAK_PLUGIN
350 +endif
351 +GCC_PLUGINS_CFLAGS := $(CONSTIFY_PLUGIN_CFLAGS) $(STACKLEAK_PLUGIN_CFLAGS) $(KALLOCSTAT_PLUGIN_CFLAGS)
352 +GCC_PLUGINS_CFLAGS += $(KERNEXEC_PLUGIN_CFLAGS) $(CHECKER_PLUGIN_CFLAGS) $(COLORIZE_PLUGIN_CFLAGS)
353 +GCC_PLUGINS_CFLAGS += $(SIZE_OVERFLOW_PLUGIN_CFLAGS) $(LATENT_ENTROPY_PLUGIN_CFLAGS) $(STRUCTLEAK_PLUGIN_CFLAGS)
354 +GCC_PLUGINS_AFLAGS := $(KERNEXEC_PLUGIN_AFLAGS)
355 +export PLUGINCC GCC_PLUGINS_CFLAGS GCC_PLUGINS_AFLAGS CONSTIFY_PLUGIN
356 +ifeq ($(KBUILD_EXTMOD),)
357 +gcc-plugins:
358 + $(Q)$(MAKE) $(build)=tools/gcc
359 +else
360 +gcc-plugins: ;
361 +endif
362 +else
363 +gcc-plugins:
364 +ifeq ($(call cc-ifversion, -ge, 0405, y), y)
365 + $(error Your gcc installation does not support plugins. If the necessary headers for plugin support are missing, they should be installed. On Debian, apt-get install gcc-<ver>-plugin-dev. If you choose to ignore this error and lessen the improvements provided by this patch, re-run make with the DISABLE_PAX_PLUGINS=y argument.))
366 +else
367 + $(Q)echo "warning, your gcc version does not support plugins, you should upgrade it to gcc 4.5 at least"
368 +endif
369 + $(Q)echo "PAX_MEMORY_STACKLEAK, constification, PAX_LATENT_ENTROPY and other features will be less secure. PAX_SIZE_OVERFLOW will not be active."
370 +endif
371 +endif
372 +
373 include $(srctree)/arch/$(SRCARCH)/Makefile
374
375 ifdef CONFIG_READABLE_ASM
376 @@ -733,7 +793,7 @@ export mod_sign_cmd
377
378
379 ifeq ($(KBUILD_EXTMOD),)
380 -core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/
381 +core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/ grsecurity/
382
383 vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
384 $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
385 @@ -782,6 +842,8 @@ endif
386
387 # The actual objects are generated when descending,
388 # make sure no implicit rule kicks in
389 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
390 +$(filter-out $(init-y),$(vmlinux-deps)): KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
391 $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
392
393 # Handle descending into subdirectories listed in $(vmlinux-dirs)
394 @@ -791,7 +853,7 @@ $(sort $(vmlinux-deps)): $(vmlinux-dirs) ;
395 # Error messages still appears in the original language
396
397 PHONY += $(vmlinux-dirs)
398 -$(vmlinux-dirs): prepare scripts
399 +$(vmlinux-dirs): gcc-plugins prepare scripts
400 $(Q)$(MAKE) $(build)=$@
401
402 define filechk_kernel.release
403 @@ -838,6 +900,7 @@ prepare0: archprepare FORCE
404 $(Q)$(MAKE) $(build)=.
405
406 # All the preparing..
407 +prepare: KBUILD_CFLAGS := $(filter-out $(GCC_PLUGINS_CFLAGS),$(KBUILD_CFLAGS))
408 prepare: prepare0
409
410 # Generate some files
411 @@ -945,6 +1008,8 @@ all: modules
412 # using awk while concatenating to the final file.
413
414 PHONY += modules
415 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
416 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
417 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) modules.builtin
418 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
419 @$(kecho) ' Building modules, stage 2.';
420 @@ -960,7 +1025,7 @@ modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
421
422 # Target to prepare building external modules
423 PHONY += modules_prepare
424 -modules_prepare: prepare scripts
425 +modules_prepare: gcc-plugins prepare scripts
426
427 # Target to install modules
428 PHONY += modules_install
429 @@ -1026,7 +1091,7 @@ MRPROPER_FILES += .config .config.old .version .old_version $(version_h) \
430 Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS \
431 signing_key.priv signing_key.x509 x509.genkey \
432 extra_certificates signing_key.x509.keyid \
433 - signing_key.x509.signer
434 + signing_key.x509.signer tools/gcc/size_overflow_hash.h
435
436 # clean - Delete most, but leave enough to build external modules
437 #
438 @@ -1066,6 +1131,7 @@ distclean: mrproper
439 \( -name '*.orig' -o -name '*.rej' -o -name '*~' \
440 -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \
441 -o -name '.*.rej' \
442 + -o -name '.*.rej' -o -name '*.so' \
443 -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \
444 -type f -print | xargs rm -f
445
446 @@ -1227,6 +1293,8 @@ PHONY += $(module-dirs) modules
447 $(module-dirs): crmodverdir $(objtree)/Module.symvers
448 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
449
450 +modules: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
451 +modules: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
452 modules: $(module-dirs)
453 @$(kecho) ' Building modules, stage 2.';
454 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
455 @@ -1366,17 +1434,21 @@ else
456 target-dir = $(if $(KBUILD_EXTMOD),$(dir $<),$(dir $@))
457 endif
458
459 -%.s: %.c prepare scripts FORCE
460 +%.s: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
461 +%.s: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
462 +%.s: %.c gcc-plugins prepare scripts FORCE
463 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
464 %.i: %.c prepare scripts FORCE
465 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
466 -%.o: %.c prepare scripts FORCE
467 +%.o: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
468 +%.o: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
469 +%.o: %.c gcc-plugins prepare scripts FORCE
470 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
471 %.lst: %.c prepare scripts FORCE
472 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
473 -%.s: %.S prepare scripts FORCE
474 +%.s: %.S gcc-plugins prepare scripts FORCE
475 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
476 -%.o: %.S prepare scripts FORCE
477 +%.o: %.S gcc-plugins prepare scripts FORCE
478 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
479 %.symtypes: %.c prepare scripts FORCE
480 $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
481 @@ -1386,11 +1458,15 @@ endif
482 $(cmd_crmodverdir)
483 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
484 $(build)=$(build-dir)
485 -%/: prepare scripts FORCE
486 +%/: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
487 +%/: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
488 +%/: gcc-plugins prepare scripts FORCE
489 $(cmd_crmodverdir)
490 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
491 $(build)=$(build-dir)
492 -%.ko: prepare scripts FORCE
493 +%.ko: KBUILD_CFLAGS += $(GCC_PLUGINS_CFLAGS)
494 +%.ko: KBUILD_AFLAGS += $(GCC_PLUGINS_AFLAGS)
495 +%.ko: gcc-plugins prepare scripts FORCE
496 $(cmd_crmodverdir)
497 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
498 $(build)=$(build-dir) $(@:.ko=.o)
499 diff --git a/arch/alpha/include/asm/atomic.h b/arch/alpha/include/asm/atomic.h
500 index 78b03ef..da28a51 100644
501 --- a/arch/alpha/include/asm/atomic.h
502 +++ b/arch/alpha/include/asm/atomic.h
503 @@ -292,6 +292,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
504 #define atomic_dec(v) atomic_sub(1,(v))
505 #define atomic64_dec(v) atomic64_sub(1,(v))
506
507 +#define atomic64_read_unchecked(v) atomic64_read(v)
508 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
509 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
510 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
511 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
512 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
513 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
514 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
515 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
516 +
517 #define smp_mb__before_atomic_dec() smp_mb()
518 #define smp_mb__after_atomic_dec() smp_mb()
519 #define smp_mb__before_atomic_inc() smp_mb()
520 diff --git a/arch/alpha/include/asm/cache.h b/arch/alpha/include/asm/cache.h
521 index ad368a9..fbe0f25 100644
522 --- a/arch/alpha/include/asm/cache.h
523 +++ b/arch/alpha/include/asm/cache.h
524 @@ -4,19 +4,19 @@
525 #ifndef __ARCH_ALPHA_CACHE_H
526 #define __ARCH_ALPHA_CACHE_H
527
528 +#include <linux/const.h>
529
530 /* Bytes per L1 (data) cache line. */
531 #if defined(CONFIG_ALPHA_GENERIC) || defined(CONFIG_ALPHA_EV6)
532 -# define L1_CACHE_BYTES 64
533 # define L1_CACHE_SHIFT 6
534 #else
535 /* Both EV4 and EV5 are write-through, read-allocate,
536 direct-mapped, physical.
537 */
538 -# define L1_CACHE_BYTES 32
539 # define L1_CACHE_SHIFT 5
540 #endif
541
542 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
543 #define SMP_CACHE_BYTES L1_CACHE_BYTES
544
545 #endif
546 diff --git a/arch/alpha/include/asm/elf.h b/arch/alpha/include/asm/elf.h
547 index 968d999..d36b2df 100644
548 --- a/arch/alpha/include/asm/elf.h
549 +++ b/arch/alpha/include/asm/elf.h
550 @@ -91,6 +91,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
551
552 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x1000000)
553
554 +#ifdef CONFIG_PAX_ASLR
555 +#define PAX_ELF_ET_DYN_BASE (current->personality & ADDR_LIMIT_32BIT ? 0x10000 : 0x120000000UL)
556 +
557 +#define PAX_DELTA_MMAP_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 28)
558 +#define PAX_DELTA_STACK_LEN (current->personality & ADDR_LIMIT_32BIT ? 14 : 19)
559 +#endif
560 +
561 /* $0 is set by ld.so to a pointer to a function which might be
562 registered using atexit. This provides a mean for the dynamic
563 linker to call DT_FINI functions for shared libraries that have
564 diff --git a/arch/alpha/include/asm/pgalloc.h b/arch/alpha/include/asm/pgalloc.h
565 index bc2a0da..8ad11ee 100644
566 --- a/arch/alpha/include/asm/pgalloc.h
567 +++ b/arch/alpha/include/asm/pgalloc.h
568 @@ -29,6 +29,12 @@ pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
569 pgd_set(pgd, pmd);
570 }
571
572 +static inline void
573 +pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
574 +{
575 + pgd_populate(mm, pgd, pmd);
576 +}
577 +
578 extern pgd_t *pgd_alloc(struct mm_struct *mm);
579
580 static inline void
581 diff --git a/arch/alpha/include/asm/pgtable.h b/arch/alpha/include/asm/pgtable.h
582 index d8f9b7e..f6222fa 100644
583 --- a/arch/alpha/include/asm/pgtable.h
584 +++ b/arch/alpha/include/asm/pgtable.h
585 @@ -102,6 +102,17 @@ struct vm_area_struct;
586 #define PAGE_SHARED __pgprot(_PAGE_VALID | __ACCESS_BITS)
587 #define PAGE_COPY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
588 #define PAGE_READONLY __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW)
589 +
590 +#ifdef CONFIG_PAX_PAGEEXEC
591 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOE)
592 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
593 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_VALID | __ACCESS_BITS | _PAGE_FOW | _PAGE_FOE)
594 +#else
595 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
596 +# define PAGE_COPY_NOEXEC PAGE_COPY
597 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
598 +#endif
599 +
600 #define PAGE_KERNEL __pgprot(_PAGE_VALID | _PAGE_ASM | _PAGE_KRE | _PAGE_KWE)
601
602 #define _PAGE_NORMAL(x) __pgprot(_PAGE_VALID | __ACCESS_BITS | (x))
603 diff --git a/arch/alpha/kernel/module.c b/arch/alpha/kernel/module.c
604 index 2fd00b7..cfd5069 100644
605 --- a/arch/alpha/kernel/module.c
606 +++ b/arch/alpha/kernel/module.c
607 @@ -160,7 +160,7 @@ apply_relocate_add(Elf64_Shdr *sechdrs, const char *strtab,
608
609 /* The small sections were sorted to the end of the segment.
610 The following should definitely cover them. */
611 - gp = (u64)me->module_core + me->core_size - 0x8000;
612 + gp = (u64)me->module_core_rw + me->core_size_rw - 0x8000;
613 got = sechdrs[me->arch.gotsecindex].sh_addr;
614
615 for (i = 0; i < n; i++) {
616 diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
617 index 1402fcc..0b1abd2 100644
618 --- a/arch/alpha/kernel/osf_sys.c
619 +++ b/arch/alpha/kernel/osf_sys.c
620 @@ -1298,10 +1298,11 @@ SYSCALL_DEFINE1(old_adjtimex, struct timex32 __user *, txc_p)
621 generic version except that we know how to honor ADDR_LIMIT_32BIT. */
622
623 static unsigned long
624 -arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
625 - unsigned long limit)
626 +arch_get_unmapped_area_1(struct file *filp, unsigned long addr, unsigned long len,
627 + unsigned long limit, unsigned long flags)
628 {
629 struct vm_unmapped_area_info info;
630 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
631
632 info.flags = 0;
633 info.length = len;
634 @@ -1309,6 +1310,7 @@ arch_get_unmapped_area_1(unsigned long addr, unsigned long len,
635 info.high_limit = limit;
636 info.align_mask = 0;
637 info.align_offset = 0;
638 + info.threadstack_offset = offset;
639 return vm_unmapped_area(&info);
640 }
641
642 @@ -1341,20 +1343,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
643 merely specific addresses, but regions of memory -- perhaps
644 this feature should be incorporated into all ports? */
645
646 +#ifdef CONFIG_PAX_RANDMMAP
647 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
648 +#endif
649 +
650 if (addr) {
651 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(addr), len, limit);
652 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(addr), len, limit, flags);
653 if (addr != (unsigned long) -ENOMEM)
654 return addr;
655 }
656
657 /* Next, try allocating at TASK_UNMAPPED_BASE. */
658 - addr = arch_get_unmapped_area_1 (PAGE_ALIGN(TASK_UNMAPPED_BASE),
659 - len, limit);
660 + addr = arch_get_unmapped_area_1 (filp, PAGE_ALIGN(current->mm->mmap_base), len, limit, flags);
661 +
662 if (addr != (unsigned long) -ENOMEM)
663 return addr;
664
665 /* Finally, try allocating in low memory. */
666 - addr = arch_get_unmapped_area_1 (PAGE_SIZE, len, limit);
667 + addr = arch_get_unmapped_area_1 (filp, PAGE_SIZE, len, limit, flags);
668
669 return addr;
670 }
671 diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
672 index 98838a0..b304fb4 100644
673 --- a/arch/alpha/mm/fault.c
674 +++ b/arch/alpha/mm/fault.c
675 @@ -53,6 +53,124 @@ __load_new_mm_context(struct mm_struct *next_mm)
676 __reload_thread(pcb);
677 }
678
679 +#ifdef CONFIG_PAX_PAGEEXEC
680 +/*
681 + * PaX: decide what to do with offenders (regs->pc = fault address)
682 + *
683 + * returns 1 when task should be killed
684 + * 2 when patched PLT trampoline was detected
685 + * 3 when unpatched PLT trampoline was detected
686 + */
687 +static int pax_handle_fetch_fault(struct pt_regs *regs)
688 +{
689 +
690 +#ifdef CONFIG_PAX_EMUPLT
691 + int err;
692 +
693 + do { /* PaX: patched PLT emulation #1 */
694 + unsigned int ldah, ldq, jmp;
695 +
696 + err = get_user(ldah, (unsigned int *)regs->pc);
697 + err |= get_user(ldq, (unsigned int *)(regs->pc+4));
698 + err |= get_user(jmp, (unsigned int *)(regs->pc+8));
699 +
700 + if (err)
701 + break;
702 +
703 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
704 + (ldq & 0xFFFF0000U) == 0xA77B0000U &&
705 + jmp == 0x6BFB0000U)
706 + {
707 + unsigned long r27, addr;
708 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
709 + unsigned long addrl = ldq | 0xFFFFFFFFFFFF0000UL;
710 +
711 + addr = regs->r27 + ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
712 + err = get_user(r27, (unsigned long *)addr);
713 + if (err)
714 + break;
715 +
716 + regs->r27 = r27;
717 + regs->pc = r27;
718 + return 2;
719 + }
720 + } while (0);
721 +
722 + do { /* PaX: patched PLT emulation #2 */
723 + unsigned int ldah, lda, br;
724 +
725 + err = get_user(ldah, (unsigned int *)regs->pc);
726 + err |= get_user(lda, (unsigned int *)(regs->pc+4));
727 + err |= get_user(br, (unsigned int *)(regs->pc+8));
728 +
729 + if (err)
730 + break;
731 +
732 + if ((ldah & 0xFFFF0000U) == 0x277B0000U &&
733 + (lda & 0xFFFF0000U) == 0xA77B0000U &&
734 + (br & 0xFFE00000U) == 0xC3E00000U)
735 + {
736 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL;
737 + unsigned long addrh = (ldah | 0xFFFFFFFFFFFF0000UL) << 16;
738 + unsigned long addrl = lda | 0xFFFFFFFFFFFF0000UL;
739 +
740 + regs->r27 += ((addrh ^ 0x80000000UL) + 0x80000000UL) + ((addrl ^ 0x8000UL) + 0x8000UL);
741 + regs->pc += 12 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
742 + return 2;
743 + }
744 + } while (0);
745 +
746 + do { /* PaX: unpatched PLT emulation */
747 + unsigned int br;
748 +
749 + err = get_user(br, (unsigned int *)regs->pc);
750 +
751 + if (!err && (br & 0xFFE00000U) == 0xC3800000U) {
752 + unsigned int br2, ldq, nop, jmp;
753 + unsigned long addr = br | 0xFFFFFFFFFFE00000UL, resolver;
754 +
755 + addr = regs->pc + 4 + (((addr ^ 0x00100000UL) + 0x00100000UL) << 2);
756 + err = get_user(br2, (unsigned int *)addr);
757 + err |= get_user(ldq, (unsigned int *)(addr+4));
758 + err |= get_user(nop, (unsigned int *)(addr+8));
759 + err |= get_user(jmp, (unsigned int *)(addr+12));
760 + err |= get_user(resolver, (unsigned long *)(addr+16));
761 +
762 + if (err)
763 + break;
764 +
765 + if (br2 == 0xC3600000U &&
766 + ldq == 0xA77B000CU &&
767 + nop == 0x47FF041FU &&
768 + jmp == 0x6B7B0000U)
769 + {
770 + regs->r28 = regs->pc+4;
771 + regs->r27 = addr+16;
772 + regs->pc = resolver;
773 + return 3;
774 + }
775 + }
776 + } while (0);
777 +#endif
778 +
779 + return 1;
780 +}
781 +
782 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
783 +{
784 + unsigned long i;
785 +
786 + printk(KERN_ERR "PAX: bytes at PC: ");
787 + for (i = 0; i < 5; i++) {
788 + unsigned int c;
789 + if (get_user(c, (unsigned int *)pc+i))
790 + printk(KERN_CONT "???????? ");
791 + else
792 + printk(KERN_CONT "%08x ", c);
793 + }
794 + printk("\n");
795 +}
796 +#endif
797
798 /*
799 * This routine handles page faults. It determines the address,
800 @@ -133,8 +251,29 @@ retry:
801 good_area:
802 si_code = SEGV_ACCERR;
803 if (cause < 0) {
804 - if (!(vma->vm_flags & VM_EXEC))
805 + if (!(vma->vm_flags & VM_EXEC)) {
806 +
807 +#ifdef CONFIG_PAX_PAGEEXEC
808 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->pc)
809 + goto bad_area;
810 +
811 + up_read(&mm->mmap_sem);
812 + switch (pax_handle_fetch_fault(regs)) {
813 +
814 +#ifdef CONFIG_PAX_EMUPLT
815 + case 2:
816 + case 3:
817 + return;
818 +#endif
819 +
820 + }
821 + pax_report_fault(regs, (void *)regs->pc, (void *)rdusp());
822 + do_group_exit(SIGKILL);
823 +#else
824 goto bad_area;
825 +#endif
826 +
827 + }
828 } else if (!cause) {
829 /* Allow reads even for write-only mappings */
830 if (!(vma->vm_flags & (VM_READ | VM_WRITE)))
831 diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
832 index 1ad6fb6..9406b3d 100644
833 --- a/arch/arm/Kconfig
834 +++ b/arch/arm/Kconfig
835 @@ -1832,7 +1832,7 @@ config ALIGNMENT_TRAP
836
837 config UACCESS_WITH_MEMCPY
838 bool "Use kernel mem{cpy,set}() for {copy_to,clear}_user()"
839 - depends on MMU
840 + depends on MMU && !PAX_MEMORY_UDEREF
841 default y if CPU_FEROCEON
842 help
843 Implement faster copy_to_user and clear_user methods for CPU
844 @@ -2097,6 +2097,7 @@ config XIP_PHYS_ADDR
845 config KEXEC
846 bool "Kexec system call (EXPERIMENTAL)"
847 depends on (!SMP || PM_SLEEP_SMP)
848 + depends on !GRKERNSEC_KMEM
849 help
850 kexec is a system call that implements the ability to shutdown your
851 current kernel, and to start another kernel. It is like a reboot
852 diff --git a/arch/arm/include/asm/atomic.h b/arch/arm/include/asm/atomic.h
853 index da1c77d..2ee6056 100644
854 --- a/arch/arm/include/asm/atomic.h
855 +++ b/arch/arm/include/asm/atomic.h
856 @@ -17,17 +17,35 @@
857 #include <asm/barrier.h>
858 #include <asm/cmpxchg.h>
859
860 +#ifdef CONFIG_GENERIC_ATOMIC64
861 +#include <asm-generic/atomic64.h>
862 +#endif
863 +
864 #define ATOMIC_INIT(i) { (i) }
865
866 #ifdef __KERNEL__
867
868 +#define _ASM_EXTABLE(from, to) \
869 +" .pushsection __ex_table,\"a\"\n"\
870 +" .align 3\n" \
871 +" .long " #from ", " #to"\n" \
872 +" .popsection"
873 +
874 /*
875 * On ARM, ordinary assignment (str instruction) doesn't clear the local
876 * strex/ldrex monitor on some implementations. The reason we can use it for
877 * atomic_set() is the clrex or dummy strex done on every exception return.
878 */
879 #define atomic_read(v) (*(volatile int *)&(v)->counter)
880 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
881 +{
882 + return v->counter;
883 +}
884 #define atomic_set(v,i) (((v)->counter) = (i))
885 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
886 +{
887 + v->counter = i;
888 +}
889
890 #if __LINUX_ARM_ARCH__ >= 6
891
892 @@ -42,6 +60,35 @@ static inline void atomic_add(int i, atomic_t *v)
893 int result;
894
895 __asm__ __volatile__("@ atomic_add\n"
896 +"1: ldrex %1, [%3]\n"
897 +" adds %0, %1, %4\n"
898 +
899 +#ifdef CONFIG_PAX_REFCOUNT
900 +" bvc 3f\n"
901 +"2: bkpt 0xf103\n"
902 +"3:\n"
903 +#endif
904 +
905 +" strex %1, %0, [%3]\n"
906 +" teq %1, #0\n"
907 +" bne 1b"
908 +
909 +#ifdef CONFIG_PAX_REFCOUNT
910 +"\n4:\n"
911 + _ASM_EXTABLE(2b, 4b)
912 +#endif
913 +
914 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
915 + : "r" (&v->counter), "Ir" (i)
916 + : "cc");
917 +}
918 +
919 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
920 +{
921 + unsigned long tmp;
922 + int result;
923 +
924 + __asm__ __volatile__("@ atomic_add_unchecked\n"
925 "1: ldrex %0, [%3]\n"
926 " add %0, %0, %4\n"
927 " strex %1, %0, [%3]\n"
928 @@ -60,6 +107,42 @@ static inline int atomic_add_return(int i, atomic_t *v)
929 smp_mb();
930
931 __asm__ __volatile__("@ atomic_add_return\n"
932 +"1: ldrex %1, [%3]\n"
933 +" adds %0, %1, %4\n"
934 +
935 +#ifdef CONFIG_PAX_REFCOUNT
936 +" bvc 3f\n"
937 +" mov %0, %1\n"
938 +"2: bkpt 0xf103\n"
939 +"3:\n"
940 +#endif
941 +
942 +" strex %1, %0, [%3]\n"
943 +" teq %1, #0\n"
944 +" bne 1b"
945 +
946 +#ifdef CONFIG_PAX_REFCOUNT
947 +"\n4:\n"
948 + _ASM_EXTABLE(2b, 4b)
949 +#endif
950 +
951 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
952 + : "r" (&v->counter), "Ir" (i)
953 + : "cc");
954 +
955 + smp_mb();
956 +
957 + return result;
958 +}
959 +
960 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
961 +{
962 + unsigned long tmp;
963 + int result;
964 +
965 + smp_mb();
966 +
967 + __asm__ __volatile__("@ atomic_add_return_unchecked\n"
968 "1: ldrex %0, [%3]\n"
969 " add %0, %0, %4\n"
970 " strex %1, %0, [%3]\n"
971 @@ -80,6 +163,35 @@ static inline void atomic_sub(int i, atomic_t *v)
972 int result;
973
974 __asm__ __volatile__("@ atomic_sub\n"
975 +"1: ldrex %1, [%3]\n"
976 +" subs %0, %1, %4\n"
977 +
978 +#ifdef CONFIG_PAX_REFCOUNT
979 +" bvc 3f\n"
980 +"2: bkpt 0xf103\n"
981 +"3:\n"
982 +#endif
983 +
984 +" strex %1, %0, [%3]\n"
985 +" teq %1, #0\n"
986 +" bne 1b"
987 +
988 +#ifdef CONFIG_PAX_REFCOUNT
989 +"\n4:\n"
990 + _ASM_EXTABLE(2b, 4b)
991 +#endif
992 +
993 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
994 + : "r" (&v->counter), "Ir" (i)
995 + : "cc");
996 +}
997 +
998 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
999 +{
1000 + unsigned long tmp;
1001 + int result;
1002 +
1003 + __asm__ __volatile__("@ atomic_sub_unchecked\n"
1004 "1: ldrex %0, [%3]\n"
1005 " sub %0, %0, %4\n"
1006 " strex %1, %0, [%3]\n"
1007 @@ -98,11 +210,25 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1008 smp_mb();
1009
1010 __asm__ __volatile__("@ atomic_sub_return\n"
1011 -"1: ldrex %0, [%3]\n"
1012 -" sub %0, %0, %4\n"
1013 +"1: ldrex %1, [%3]\n"
1014 +" subs %0, %1, %4\n"
1015 +
1016 +#ifdef CONFIG_PAX_REFCOUNT
1017 +" bvc 3f\n"
1018 +" mov %0, %1\n"
1019 +"2: bkpt 0xf103\n"
1020 +"3:\n"
1021 +#endif
1022 +
1023 " strex %1, %0, [%3]\n"
1024 " teq %1, #0\n"
1025 " bne 1b"
1026 +
1027 +#ifdef CONFIG_PAX_REFCOUNT
1028 +"\n4:\n"
1029 + _ASM_EXTABLE(2b, 4b)
1030 +#endif
1031 +
1032 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1033 : "r" (&v->counter), "Ir" (i)
1034 : "cc");
1035 @@ -134,6 +260,28 @@ static inline int atomic_cmpxchg(atomic_t *ptr, int old, int new)
1036 return oldval;
1037 }
1038
1039 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *ptr, int old, int new)
1040 +{
1041 + unsigned long oldval, res;
1042 +
1043 + smp_mb();
1044 +
1045 + do {
1046 + __asm__ __volatile__("@ atomic_cmpxchg_unchecked\n"
1047 + "ldrex %1, [%3]\n"
1048 + "mov %0, #0\n"
1049 + "teq %1, %4\n"
1050 + "strexeq %0, %5, [%3]\n"
1051 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1052 + : "r" (&ptr->counter), "Ir" (old), "r" (new)
1053 + : "cc");
1054 + } while (res);
1055 +
1056 + smp_mb();
1057 +
1058 + return oldval;
1059 +}
1060 +
1061 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1062 {
1063 unsigned long tmp, tmp2;
1064 @@ -167,7 +315,17 @@ static inline int atomic_add_return(int i, atomic_t *v)
1065
1066 return val;
1067 }
1068 +
1069 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
1070 +{
1071 + return atomic_add_return(i, v);
1072 +}
1073 +
1074 #define atomic_add(i, v) (void) atomic_add_return(i, v)
1075 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
1076 +{
1077 + (void) atomic_add_return(i, v);
1078 +}
1079
1080 static inline int atomic_sub_return(int i, atomic_t *v)
1081 {
1082 @@ -182,6 +340,10 @@ static inline int atomic_sub_return(int i, atomic_t *v)
1083 return val;
1084 }
1085 #define atomic_sub(i, v) (void) atomic_sub_return(i, v)
1086 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
1087 +{
1088 + (void) atomic_sub_return(i, v);
1089 +}
1090
1091 static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1092 {
1093 @@ -197,6 +359,11 @@ static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
1094 return ret;
1095 }
1096
1097 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
1098 +{
1099 + return atomic_cmpxchg(v, old, new);
1100 +}
1101 +
1102 static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1103 {
1104 unsigned long flags;
1105 @@ -209,6 +376,10 @@ static inline void atomic_clear_mask(unsigned long mask, unsigned long *addr)
1106 #endif /* __LINUX_ARM_ARCH__ */
1107
1108 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
1109 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
1110 +{
1111 + return xchg(&v->counter, new);
1112 +}
1113
1114 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1115 {
1116 @@ -221,11 +392,27 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
1117 }
1118
1119 #define atomic_inc(v) atomic_add(1, v)
1120 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
1121 +{
1122 + atomic_add_unchecked(1, v);
1123 +}
1124 #define atomic_dec(v) atomic_sub(1, v)
1125 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
1126 +{
1127 + atomic_sub_unchecked(1, v);
1128 +}
1129
1130 #define atomic_inc_and_test(v) (atomic_add_return(1, v) == 0)
1131 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
1132 +{
1133 + return atomic_add_return_unchecked(1, v) == 0;
1134 +}
1135 #define atomic_dec_and_test(v) (atomic_sub_return(1, v) == 0)
1136 #define atomic_inc_return(v) (atomic_add_return(1, v))
1137 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
1138 +{
1139 + return atomic_add_return_unchecked(1, v);
1140 +}
1141 #define atomic_dec_return(v) (atomic_sub_return(1, v))
1142 #define atomic_sub_and_test(i, v) (atomic_sub_return(i, v) == 0)
1143
1144 @@ -241,6 +428,14 @@ typedef struct {
1145 u64 __aligned(8) counter;
1146 } atomic64_t;
1147
1148 +#ifdef CONFIG_PAX_REFCOUNT
1149 +typedef struct {
1150 + u64 __aligned(8) counter;
1151 +} atomic64_unchecked_t;
1152 +#else
1153 +typedef atomic64_t atomic64_unchecked_t;
1154 +#endif
1155 +
1156 #define ATOMIC64_INIT(i) { (i) }
1157
1158 #ifdef CONFIG_ARM_LPAE
1159 @@ -257,6 +452,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1160 return result;
1161 }
1162
1163 +static inline u64 atomic64_read_unchecked(const atomic64_unchecked_t *v)
1164 +{
1165 + u64 result;
1166 +
1167 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1168 +" ldrd %0, %H0, [%1]"
1169 + : "=&r" (result)
1170 + : "r" (&v->counter), "Qo" (v->counter)
1171 + );
1172 +
1173 + return result;
1174 +}
1175 +
1176 static inline void atomic64_set(atomic64_t *v, u64 i)
1177 {
1178 __asm__ __volatile__("@ atomic64_set\n"
1179 @@ -265,6 +473,15 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1180 : "r" (&v->counter), "r" (i)
1181 );
1182 }
1183 +
1184 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1185 +{
1186 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1187 +" strd %2, %H2, [%1]"
1188 + : "=Qo" (v->counter)
1189 + : "r" (&v->counter), "r" (i)
1190 + );
1191 +}
1192 #else
1193 static inline u64 atomic64_read(const atomic64_t *v)
1194 {
1195 @@ -279,6 +496,19 @@ static inline u64 atomic64_read(const atomic64_t *v)
1196 return result;
1197 }
1198
1199 +static inline u64 atomic64_read_unchecked(atomic64_unchecked_t *v)
1200 +{
1201 + u64 result;
1202 +
1203 + __asm__ __volatile__("@ atomic64_read_unchecked\n"
1204 +" ldrexd %0, %H0, [%1]"
1205 + : "=&r" (result)
1206 + : "r" (&v->counter), "Qo" (v->counter)
1207 + );
1208 +
1209 + return result;
1210 +}
1211 +
1212 static inline void atomic64_set(atomic64_t *v, u64 i)
1213 {
1214 u64 tmp;
1215 @@ -292,6 +522,21 @@ static inline void atomic64_set(atomic64_t *v, u64 i)
1216 : "r" (&v->counter), "r" (i)
1217 : "cc");
1218 }
1219 +
1220 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, u64 i)
1221 +{
1222 + u64 tmp;
1223 +
1224 + __asm__ __volatile__("@ atomic64_set_unchecked\n"
1225 +"1: ldrexd %0, %H0, [%2]\n"
1226 +" strexd %0, %3, %H3, [%2]\n"
1227 +" teq %0, #0\n"
1228 +" bne 1b"
1229 + : "=&r" (tmp), "=Qo" (v->counter)
1230 + : "r" (&v->counter), "r" (i)
1231 + : "cc");
1232 +}
1233 +
1234 #endif
1235
1236 static inline void atomic64_add(u64 i, atomic64_t *v)
1237 @@ -302,6 +547,36 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1238 __asm__ __volatile__("@ atomic64_add\n"
1239 "1: ldrexd %0, %H0, [%3]\n"
1240 " adds %0, %0, %4\n"
1241 +" adcs %H0, %H0, %H4\n"
1242 +
1243 +#ifdef CONFIG_PAX_REFCOUNT
1244 +" bvc 3f\n"
1245 +"2: bkpt 0xf103\n"
1246 +"3:\n"
1247 +#endif
1248 +
1249 +" strexd %1, %0, %H0, [%3]\n"
1250 +" teq %1, #0\n"
1251 +" bne 1b"
1252 +
1253 +#ifdef CONFIG_PAX_REFCOUNT
1254 +"\n4:\n"
1255 + _ASM_EXTABLE(2b, 4b)
1256 +#endif
1257 +
1258 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1259 + : "r" (&v->counter), "r" (i)
1260 + : "cc");
1261 +}
1262 +
1263 +static inline void atomic64_add_unchecked(u64 i, atomic64_unchecked_t *v)
1264 +{
1265 + u64 result;
1266 + unsigned long tmp;
1267 +
1268 + __asm__ __volatile__("@ atomic64_add_unchecked\n"
1269 +"1: ldrexd %0, %H0, [%3]\n"
1270 +" adds %0, %0, %4\n"
1271 " adc %H0, %H0, %H4\n"
1272 " strexd %1, %0, %H0, [%3]\n"
1273 " teq %1, #0\n"
1274 @@ -313,12 +588,49 @@ static inline void atomic64_add(u64 i, atomic64_t *v)
1275
1276 static inline u64 atomic64_add_return(u64 i, atomic64_t *v)
1277 {
1278 - u64 result;
1279 - unsigned long tmp;
1280 + u64 result, tmp;
1281
1282 smp_mb();
1283
1284 __asm__ __volatile__("@ atomic64_add_return\n"
1285 +"1: ldrexd %1, %H1, [%3]\n"
1286 +" adds %0, %1, %4\n"
1287 +" adcs %H0, %H1, %H4\n"
1288 +
1289 +#ifdef CONFIG_PAX_REFCOUNT
1290 +" bvc 3f\n"
1291 +" mov %0, %1\n"
1292 +" mov %H0, %H1\n"
1293 +"2: bkpt 0xf103\n"
1294 +"3:\n"
1295 +#endif
1296 +
1297 +" strexd %1, %0, %H0, [%3]\n"
1298 +" teq %1, #0\n"
1299 +" bne 1b"
1300 +
1301 +#ifdef CONFIG_PAX_REFCOUNT
1302 +"\n4:\n"
1303 + _ASM_EXTABLE(2b, 4b)
1304 +#endif
1305 +
1306 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1307 + : "r" (&v->counter), "r" (i)
1308 + : "cc");
1309 +
1310 + smp_mb();
1311 +
1312 + return result;
1313 +}
1314 +
1315 +static inline u64 atomic64_add_return_unchecked(u64 i, atomic64_unchecked_t *v)
1316 +{
1317 + u64 result;
1318 + unsigned long tmp;
1319 +
1320 + smp_mb();
1321 +
1322 + __asm__ __volatile__("@ atomic64_add_return_unchecked\n"
1323 "1: ldrexd %0, %H0, [%3]\n"
1324 " adds %0, %0, %4\n"
1325 " adc %H0, %H0, %H4\n"
1326 @@ -342,6 +654,36 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1327 __asm__ __volatile__("@ atomic64_sub\n"
1328 "1: ldrexd %0, %H0, [%3]\n"
1329 " subs %0, %0, %4\n"
1330 +" sbcs %H0, %H0, %H4\n"
1331 +
1332 +#ifdef CONFIG_PAX_REFCOUNT
1333 +" bvc 3f\n"
1334 +"2: bkpt 0xf103\n"
1335 +"3:\n"
1336 +#endif
1337 +
1338 +" strexd %1, %0, %H0, [%3]\n"
1339 +" teq %1, #0\n"
1340 +" bne 1b"
1341 +
1342 +#ifdef CONFIG_PAX_REFCOUNT
1343 +"\n4:\n"
1344 + _ASM_EXTABLE(2b, 4b)
1345 +#endif
1346 +
1347 + : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1348 + : "r" (&v->counter), "r" (i)
1349 + : "cc");
1350 +}
1351 +
1352 +static inline void atomic64_sub_unchecked(u64 i, atomic64_unchecked_t *v)
1353 +{
1354 + u64 result;
1355 + unsigned long tmp;
1356 +
1357 + __asm__ __volatile__("@ atomic64_sub_unchecked\n"
1358 +"1: ldrexd %0, %H0, [%3]\n"
1359 +" subs %0, %0, %4\n"
1360 " sbc %H0, %H0, %H4\n"
1361 " strexd %1, %0, %H0, [%3]\n"
1362 " teq %1, #0\n"
1363 @@ -353,18 +695,32 @@ static inline void atomic64_sub(u64 i, atomic64_t *v)
1364
1365 static inline u64 atomic64_sub_return(u64 i, atomic64_t *v)
1366 {
1367 - u64 result;
1368 - unsigned long tmp;
1369 + u64 result, tmp;
1370
1371 smp_mb();
1372
1373 __asm__ __volatile__("@ atomic64_sub_return\n"
1374 -"1: ldrexd %0, %H0, [%3]\n"
1375 -" subs %0, %0, %4\n"
1376 -" sbc %H0, %H0, %H4\n"
1377 +"1: ldrexd %1, %H1, [%3]\n"
1378 +" subs %0, %1, %4\n"
1379 +" sbcs %H0, %H1, %H4\n"
1380 +
1381 +#ifdef CONFIG_PAX_REFCOUNT
1382 +" bvc 3f\n"
1383 +" mov %0, %1\n"
1384 +" mov %H0, %H1\n"
1385 +"2: bkpt 0xf103\n"
1386 +"3:\n"
1387 +#endif
1388 +
1389 " strexd %1, %0, %H0, [%3]\n"
1390 " teq %1, #0\n"
1391 " bne 1b"
1392 +
1393 +#ifdef CONFIG_PAX_REFCOUNT
1394 +"\n4:\n"
1395 + _ASM_EXTABLE(2b, 4b)
1396 +#endif
1397 +
1398 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1399 : "r" (&v->counter), "r" (i)
1400 : "cc");
1401 @@ -398,6 +754,30 @@ static inline u64 atomic64_cmpxchg(atomic64_t *ptr, u64 old, u64 new)
1402 return oldval;
1403 }
1404
1405 +static inline u64 atomic64_cmpxchg_unchecked(atomic64_unchecked_t *ptr, u64 old, u64 new)
1406 +{
1407 + u64 oldval;
1408 + unsigned long res;
1409 +
1410 + smp_mb();
1411 +
1412 + do {
1413 + __asm__ __volatile__("@ atomic64_cmpxchg_unchecked\n"
1414 + "ldrexd %1, %H1, [%3]\n"
1415 + "mov %0, #0\n"
1416 + "teq %1, %4\n"
1417 + "teqeq %H1, %H4\n"
1418 + "strexdeq %0, %5, %H5, [%3]"
1419 + : "=&r" (res), "=&r" (oldval), "+Qo" (ptr->counter)
1420 + : "r" (&ptr->counter), "r" (old), "r" (new)
1421 + : "cc");
1422 + } while (res);
1423 +
1424 + smp_mb();
1425 +
1426 + return oldval;
1427 +}
1428 +
1429 static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1430 {
1431 u64 result;
1432 @@ -421,21 +801,34 @@ static inline u64 atomic64_xchg(atomic64_t *ptr, u64 new)
1433
1434 static inline u64 atomic64_dec_if_positive(atomic64_t *v)
1435 {
1436 - u64 result;
1437 - unsigned long tmp;
1438 + u64 result, tmp;
1439
1440 smp_mb();
1441
1442 __asm__ __volatile__("@ atomic64_dec_if_positive\n"
1443 -"1: ldrexd %0, %H0, [%3]\n"
1444 -" subs %0, %0, #1\n"
1445 -" sbc %H0, %H0, #0\n"
1446 +"1: ldrexd %1, %H1, [%3]\n"
1447 +" subs %0, %1, #1\n"
1448 +" sbcs %H0, %H1, #0\n"
1449 +
1450 +#ifdef CONFIG_PAX_REFCOUNT
1451 +" bvc 3f\n"
1452 +" mov %0, %1\n"
1453 +" mov %H0, %H1\n"
1454 +"2: bkpt 0xf103\n"
1455 +"3:\n"
1456 +#endif
1457 +
1458 " teq %H0, #0\n"
1459 -" bmi 2f\n"
1460 +" bmi 4f\n"
1461 " strexd %1, %0, %H0, [%3]\n"
1462 " teq %1, #0\n"
1463 " bne 1b\n"
1464 -"2:"
1465 +"4:\n"
1466 +
1467 +#ifdef CONFIG_PAX_REFCOUNT
1468 + _ASM_EXTABLE(2b, 4b)
1469 +#endif
1470 +
1471 : "=&r" (result), "=&r" (tmp), "+Qo" (v->counter)
1472 : "r" (&v->counter)
1473 : "cc");
1474 @@ -458,13 +851,25 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1475 " teq %0, %5\n"
1476 " teqeq %H0, %H5\n"
1477 " moveq %1, #0\n"
1478 -" beq 2f\n"
1479 +" beq 4f\n"
1480 " adds %0, %0, %6\n"
1481 -" adc %H0, %H0, %H6\n"
1482 +" adcs %H0, %H0, %H6\n"
1483 +
1484 +#ifdef CONFIG_PAX_REFCOUNT
1485 +" bvc 3f\n"
1486 +"2: bkpt 0xf103\n"
1487 +"3:\n"
1488 +#endif
1489 +
1490 " strexd %2, %0, %H0, [%4]\n"
1491 " teq %2, #0\n"
1492 " bne 1b\n"
1493 -"2:"
1494 +"4:\n"
1495 +
1496 +#ifdef CONFIG_PAX_REFCOUNT
1497 + _ASM_EXTABLE(2b, 4b)
1498 +#endif
1499 +
1500 : "=&r" (val), "+r" (ret), "=&r" (tmp), "+Qo" (v->counter)
1501 : "r" (&v->counter), "r" (u), "r" (a)
1502 : "cc");
1503 @@ -477,10 +882,13 @@ static inline int atomic64_add_unless(atomic64_t *v, u64 a, u64 u)
1504
1505 #define atomic64_add_negative(a, v) (atomic64_add_return((a), (v)) < 0)
1506 #define atomic64_inc(v) atomic64_add(1LL, (v))
1507 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1LL, (v))
1508 #define atomic64_inc_return(v) atomic64_add_return(1LL, (v))
1509 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1LL, (v))
1510 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
1511 #define atomic64_sub_and_test(a, v) (atomic64_sub_return((a), (v)) == 0)
1512 #define atomic64_dec(v) atomic64_sub(1LL, (v))
1513 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1LL, (v))
1514 #define atomic64_dec_return(v) atomic64_sub_return(1LL, (v))
1515 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
1516 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
1517 diff --git a/arch/arm/include/asm/cache.h b/arch/arm/include/asm/cache.h
1518 index 75fe66b..ba3dee4 100644
1519 --- a/arch/arm/include/asm/cache.h
1520 +++ b/arch/arm/include/asm/cache.h
1521 @@ -4,8 +4,10 @@
1522 #ifndef __ASMARM_CACHE_H
1523 #define __ASMARM_CACHE_H
1524
1525 +#include <linux/const.h>
1526 +
1527 #define L1_CACHE_SHIFT CONFIG_ARM_L1_CACHE_SHIFT
1528 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
1529 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
1530
1531 /*
1532 * Memory returned by kmalloc() may be used for DMA, so we must make
1533 @@ -24,5 +26,6 @@
1534 #endif
1535
1536 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
1537 +#define __read_only __attribute__ ((__section__(".data..read_only")))
1538
1539 #endif
1540 diff --git a/arch/arm/include/asm/cacheflush.h b/arch/arm/include/asm/cacheflush.h
1541 index 15f2d5b..43ffa53 100644
1542 --- a/arch/arm/include/asm/cacheflush.h
1543 +++ b/arch/arm/include/asm/cacheflush.h
1544 @@ -116,7 +116,7 @@ struct cpu_cache_fns {
1545 void (*dma_unmap_area)(const void *, size_t, int);
1546
1547 void (*dma_flush_range)(const void *, const void *);
1548 -};
1549 +} __no_const;
1550
1551 /*
1552 * Select the calling method
1553 diff --git a/arch/arm/include/asm/checksum.h b/arch/arm/include/asm/checksum.h
1554 index 6dcc164..b14d917 100644
1555 --- a/arch/arm/include/asm/checksum.h
1556 +++ b/arch/arm/include/asm/checksum.h
1557 @@ -37,7 +37,19 @@ __wsum
1558 csum_partial_copy_nocheck(const void *src, void *dst, int len, __wsum sum);
1559
1560 __wsum
1561 -csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1562 +__csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr);
1563 +
1564 +static inline __wsum
1565 +csum_partial_copy_from_user(const void __user *src, void *dst, int len, __wsum sum, int *err_ptr)
1566 +{
1567 + __wsum ret;
1568 + pax_open_userland();
1569 + ret = __csum_partial_copy_from_user(src, dst, len, sum, err_ptr);
1570 + pax_close_userland();
1571 + return ret;
1572 +}
1573 +
1574 +
1575
1576 /*
1577 * Fold a partial checksum without adding pseudo headers
1578 diff --git a/arch/arm/include/asm/cmpxchg.h b/arch/arm/include/asm/cmpxchg.h
1579 index 4f009c1..466c59b 100644
1580 --- a/arch/arm/include/asm/cmpxchg.h
1581 +++ b/arch/arm/include/asm/cmpxchg.h
1582 @@ -102,6 +102,8 @@ static inline unsigned long __xchg(unsigned long x, volatile void *ptr, int size
1583
1584 #define xchg(ptr,x) \
1585 ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1586 +#define xchg_unchecked(ptr,x) \
1587 + ((__typeof__(*(ptr)))__xchg((unsigned long)(x),(ptr),sizeof(*(ptr))))
1588
1589 #include <asm-generic/cmpxchg-local.h>
1590
1591 diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h
1592 index 6ddbe44..b5e38b1 100644
1593 --- a/arch/arm/include/asm/domain.h
1594 +++ b/arch/arm/include/asm/domain.h
1595 @@ -48,18 +48,37 @@
1596 * Domain types
1597 */
1598 #define DOMAIN_NOACCESS 0
1599 -#define DOMAIN_CLIENT 1
1600 #ifdef CONFIG_CPU_USE_DOMAINS
1601 +#define DOMAIN_USERCLIENT 1
1602 +#define DOMAIN_KERNELCLIENT 1
1603 #define DOMAIN_MANAGER 3
1604 +#define DOMAIN_VECTORS DOMAIN_USER
1605 #else
1606 +
1607 +#ifdef CONFIG_PAX_KERNEXEC
1608 #define DOMAIN_MANAGER 1
1609 +#define DOMAIN_KERNEXEC 3
1610 +#else
1611 +#define DOMAIN_MANAGER 1
1612 +#endif
1613 +
1614 +#ifdef CONFIG_PAX_MEMORY_UDEREF
1615 +#define DOMAIN_USERCLIENT 0
1616 +#define DOMAIN_UDEREF 1
1617 +#define DOMAIN_VECTORS DOMAIN_KERNEL
1618 +#else
1619 +#define DOMAIN_USERCLIENT 1
1620 +#define DOMAIN_VECTORS DOMAIN_USER
1621 +#endif
1622 +#define DOMAIN_KERNELCLIENT 1
1623 +
1624 #endif
1625
1626 #define domain_val(dom,type) ((type) << (2*(dom)))
1627
1628 #ifndef __ASSEMBLY__
1629
1630 -#ifdef CONFIG_CPU_USE_DOMAINS
1631 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
1632 static inline void set_domain(unsigned val)
1633 {
1634 asm volatile(
1635 @@ -68,15 +87,7 @@ static inline void set_domain(unsigned val)
1636 isb();
1637 }
1638
1639 -#define modify_domain(dom,type) \
1640 - do { \
1641 - struct thread_info *thread = current_thread_info(); \
1642 - unsigned int domain = thread->cpu_domain; \
1643 - domain &= ~domain_val(dom, DOMAIN_MANAGER); \
1644 - thread->cpu_domain = domain | domain_val(dom, type); \
1645 - set_domain(thread->cpu_domain); \
1646 - } while (0)
1647 -
1648 +extern void modify_domain(unsigned int dom, unsigned int type);
1649 #else
1650 static inline void set_domain(unsigned val) { }
1651 static inline void modify_domain(unsigned dom, unsigned type) { }
1652 diff --git a/arch/arm/include/asm/elf.h b/arch/arm/include/asm/elf.h
1653 index f4b46d3..abc9b2b 100644
1654 --- a/arch/arm/include/asm/elf.h
1655 +++ b/arch/arm/include/asm/elf.h
1656 @@ -114,7 +114,14 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1657 the loader. We need to make sure that it is out of the way of the program
1658 that it will "exec", and that there is sufficient room for the brk. */
1659
1660 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
1661 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
1662 +
1663 +#ifdef CONFIG_PAX_ASLR
1664 +#define PAX_ELF_ET_DYN_BASE 0x00008000UL
1665 +
1666 +#define PAX_DELTA_MMAP_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1667 +#define PAX_DELTA_STACK_LEN ((current->personality == PER_LINUX_32BIT) ? 16 : 10)
1668 +#endif
1669
1670 /* When the program starts, a1 contains a pointer to a function to be
1671 registered with atexit, as per the SVR4 ABI. A value of 0 means we
1672 @@ -124,10 +131,6 @@ int dump_task_regs(struct task_struct *t, elf_gregset_t *elfregs);
1673 extern void elf_set_personality(const struct elf32_hdr *);
1674 #define SET_PERSONALITY(ex) elf_set_personality(&(ex))
1675
1676 -struct mm_struct;
1677 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
1678 -#define arch_randomize_brk arch_randomize_brk
1679 -
1680 #ifdef CONFIG_MMU
1681 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
1682 struct linux_binprm;
1683 diff --git a/arch/arm/include/asm/fncpy.h b/arch/arm/include/asm/fncpy.h
1684 index de53547..52b9a28 100644
1685 --- a/arch/arm/include/asm/fncpy.h
1686 +++ b/arch/arm/include/asm/fncpy.h
1687 @@ -81,7 +81,9 @@
1688 BUG_ON((uintptr_t)(dest_buf) & (FNCPY_ALIGN - 1) || \
1689 (__funcp_address & ~(uintptr_t)1 & (FNCPY_ALIGN - 1))); \
1690 \
1691 + pax_open_kernel(); \
1692 memcpy(dest_buf, (void const *)(__funcp_address & ~1), size); \
1693 + pax_close_kernel(); \
1694 flush_icache_range((unsigned long)(dest_buf), \
1695 (unsigned long)(dest_buf) + (size)); \
1696 \
1697 diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h
1698 index e42cf59..7b94b8f 100644
1699 --- a/arch/arm/include/asm/futex.h
1700 +++ b/arch/arm/include/asm/futex.h
1701 @@ -50,6 +50,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1702 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1703 return -EFAULT;
1704
1705 + pax_open_userland();
1706 +
1707 smp_mb();
1708 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1709 "1: ldrex %1, [%4]\n"
1710 @@ -65,6 +67,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1711 : "cc", "memory");
1712 smp_mb();
1713
1714 + pax_close_userland();
1715 +
1716 *uval = val;
1717 return ret;
1718 }
1719 @@ -95,6 +99,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1720 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
1721 return -EFAULT;
1722
1723 + pax_open_userland();
1724 +
1725 __asm__ __volatile__("@futex_atomic_cmpxchg_inatomic\n"
1726 "1: " TUSER(ldr) " %1, [%4]\n"
1727 " teq %1, %2\n"
1728 @@ -105,6 +111,8 @@ futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
1729 : "r" (oldval), "r" (newval), "r" (uaddr), "Ir" (-EFAULT)
1730 : "cc", "memory");
1731
1732 + pax_close_userland();
1733 +
1734 *uval = val;
1735 return ret;
1736 }
1737 @@ -127,6 +135,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1738 return -EFAULT;
1739
1740 pagefault_disable(); /* implies preempt_disable() */
1741 + pax_open_userland();
1742
1743 switch (op) {
1744 case FUTEX_OP_SET:
1745 @@ -148,6 +157,7 @@ futex_atomic_op_inuser (int encoded_op, u32 __user *uaddr)
1746 ret = -ENOSYS;
1747 }
1748
1749 + pax_close_userland();
1750 pagefault_enable(); /* subsumes preempt_enable() */
1751
1752 if (!ret) {
1753 diff --git a/arch/arm/include/asm/kmap_types.h b/arch/arm/include/asm/kmap_types.h
1754 index 83eb2f7..ed77159 100644
1755 --- a/arch/arm/include/asm/kmap_types.h
1756 +++ b/arch/arm/include/asm/kmap_types.h
1757 @@ -4,6 +4,6 @@
1758 /*
1759 * This is the "bare minimum". AIO seems to require this.
1760 */
1761 -#define KM_TYPE_NR 16
1762 +#define KM_TYPE_NR 17
1763
1764 #endif
1765 diff --git a/arch/arm/include/asm/mach/dma.h b/arch/arm/include/asm/mach/dma.h
1766 index 9e614a1..3302cca 100644
1767 --- a/arch/arm/include/asm/mach/dma.h
1768 +++ b/arch/arm/include/asm/mach/dma.h
1769 @@ -22,7 +22,7 @@ struct dma_ops {
1770 int (*residue)(unsigned int, dma_t *); /* optional */
1771 int (*setspeed)(unsigned int, dma_t *, int); /* optional */
1772 const char *type;
1773 -};
1774 +} __do_const;
1775
1776 struct dma_struct {
1777 void *addr; /* single DMA address */
1778 diff --git a/arch/arm/include/asm/mach/map.h b/arch/arm/include/asm/mach/map.h
1779 index 2fe141f..192dc01 100644
1780 --- a/arch/arm/include/asm/mach/map.h
1781 +++ b/arch/arm/include/asm/mach/map.h
1782 @@ -27,13 +27,16 @@ struct map_desc {
1783 #define MT_MINICLEAN 6
1784 #define MT_LOW_VECTORS 7
1785 #define MT_HIGH_VECTORS 8
1786 -#define MT_MEMORY 9
1787 +#define MT_MEMORY_RWX 9
1788 #define MT_ROM 10
1789 -#define MT_MEMORY_NONCACHED 11
1790 +#define MT_MEMORY_NONCACHED_RX 11
1791 #define MT_MEMORY_DTCM 12
1792 #define MT_MEMORY_ITCM 13
1793 #define MT_MEMORY_SO 14
1794 #define MT_MEMORY_DMA_READY 15
1795 +#define MT_MEMORY_RW 16
1796 +#define MT_MEMORY_RX 17
1797 +#define MT_MEMORY_NONCACHED_RW 18
1798
1799 #ifdef CONFIG_MMU
1800 extern void iotable_init(struct map_desc *, int);
1801 diff --git a/arch/arm/include/asm/outercache.h b/arch/arm/include/asm/outercache.h
1802 index f94784f..9a09a4a 100644
1803 --- a/arch/arm/include/asm/outercache.h
1804 +++ b/arch/arm/include/asm/outercache.h
1805 @@ -35,7 +35,7 @@ struct outer_cache_fns {
1806 #endif
1807 void (*set_debug)(unsigned long);
1808 void (*resume)(void);
1809 -};
1810 +} __no_const;
1811
1812 extern struct outer_cache_fns outer_cache;
1813
1814 diff --git a/arch/arm/include/asm/page.h b/arch/arm/include/asm/page.h
1815 index 4355f0e..c229913 100644
1816 --- a/arch/arm/include/asm/page.h
1817 +++ b/arch/arm/include/asm/page.h
1818 @@ -114,7 +114,7 @@ struct cpu_user_fns {
1819 void (*cpu_clear_user_highpage)(struct page *page, unsigned long vaddr);
1820 void (*cpu_copy_user_highpage)(struct page *to, struct page *from,
1821 unsigned long vaddr, struct vm_area_struct *vma);
1822 -};
1823 +} __no_const;
1824
1825 #ifdef MULTI_USER
1826 extern struct cpu_user_fns cpu_user;
1827 diff --git a/arch/arm/include/asm/pgalloc.h b/arch/arm/include/asm/pgalloc.h
1828 index 943504f..c37a730 100644
1829 --- a/arch/arm/include/asm/pgalloc.h
1830 +++ b/arch/arm/include/asm/pgalloc.h
1831 @@ -17,6 +17,7 @@
1832 #include <asm/processor.h>
1833 #include <asm/cacheflush.h>
1834 #include <asm/tlbflush.h>
1835 +#include <asm/system_info.h>
1836
1837 #define check_pgt_cache() do { } while (0)
1838
1839 @@ -43,6 +44,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1840 set_pud(pud, __pud(__pa(pmd) | PMD_TYPE_TABLE));
1841 }
1842
1843 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1844 +{
1845 + pud_populate(mm, pud, pmd);
1846 +}
1847 +
1848 #else /* !CONFIG_ARM_LPAE */
1849
1850 /*
1851 @@ -51,6 +57,7 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
1852 #define pmd_alloc_one(mm,addr) ({ BUG(); ((pmd_t *)2); })
1853 #define pmd_free(mm, pmd) do { } while (0)
1854 #define pud_populate(mm,pmd,pte) BUG()
1855 +#define pud_populate_kernel(mm,pmd,pte) BUG()
1856
1857 #endif /* CONFIG_ARM_LPAE */
1858
1859 @@ -126,6 +133,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pte)
1860 __free_page(pte);
1861 }
1862
1863 +static inline void __section_update(pmd_t *pmdp, unsigned long addr, pmdval_t prot)
1864 +{
1865 +#ifdef CONFIG_ARM_LPAE
1866 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1867 +#else
1868 + if (addr & SECTION_SIZE)
1869 + pmdp[1] = __pmd(pmd_val(pmdp[1]) | prot);
1870 + else
1871 + pmdp[0] = __pmd(pmd_val(pmdp[0]) | prot);
1872 +#endif
1873 + flush_pmd_entry(pmdp);
1874 +}
1875 +
1876 static inline void __pmd_populate(pmd_t *pmdp, phys_addr_t pte,
1877 pmdval_t prot)
1878 {
1879 @@ -155,7 +175,7 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmdp, pte_t *ptep)
1880 static inline void
1881 pmd_populate(struct mm_struct *mm, pmd_t *pmdp, pgtable_t ptep)
1882 {
1883 - __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE);
1884 + __pmd_populate(pmdp, page_to_phys(ptep), _PAGE_USER_TABLE | __supported_pmd_mask);
1885 }
1886 #define pmd_pgtable(pmd) pmd_page(pmd)
1887
1888 diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h
1889 index 5cfba15..f415e1a 100644
1890 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h
1891 +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h
1892 @@ -20,12 +20,15 @@
1893 #define PMD_TYPE_FAULT (_AT(pmdval_t, 0) << 0)
1894 #define PMD_TYPE_TABLE (_AT(pmdval_t, 1) << 0)
1895 #define PMD_TYPE_SECT (_AT(pmdval_t, 2) << 0)
1896 +#define PMD_PXNTABLE (_AT(pmdval_t, 1) << 2) /* v7 */
1897 #define PMD_BIT4 (_AT(pmdval_t, 1) << 4)
1898 #define PMD_DOMAIN(x) (_AT(pmdval_t, (x)) << 5)
1899 #define PMD_PROTECTION (_AT(pmdval_t, 1) << 9) /* v5 */
1900 +
1901 /*
1902 * - section
1903 */
1904 +#define PMD_SECT_PXN (_AT(pmdval_t, 1) << 0) /* v7 */
1905 #define PMD_SECT_BUFFERABLE (_AT(pmdval_t, 1) << 2)
1906 #define PMD_SECT_CACHEABLE (_AT(pmdval_t, 1) << 3)
1907 #define PMD_SECT_XN (_AT(pmdval_t, 1) << 4) /* v6 */
1908 @@ -37,6 +40,7 @@
1909 #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */
1910 #define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */
1911 #define PMD_SECT_AF (_AT(pmdval_t, 0))
1912 +#define PMD_SECT_RDONLY (_AT(pmdval_t, 0))
1913
1914 #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0))
1915 #define PMD_SECT_BUFFERED (PMD_SECT_BUFFERABLE)
1916 @@ -66,6 +70,7 @@
1917 * - extended small page/tiny page
1918 */
1919 #define PTE_EXT_XN (_AT(pteval_t, 1) << 0) /* v6 */
1920 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 2) /* v7 */
1921 #define PTE_EXT_AP_MASK (_AT(pteval_t, 3) << 4)
1922 #define PTE_EXT_AP0 (_AT(pteval_t, 1) << 4)
1923 #define PTE_EXT_AP1 (_AT(pteval_t, 2) << 4)
1924 diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h
1925 index f97ee02..cc9fe9e 100644
1926 --- a/arch/arm/include/asm/pgtable-2level.h
1927 +++ b/arch/arm/include/asm/pgtable-2level.h
1928 @@ -126,6 +126,9 @@
1929 #define L_PTE_SHARED (_AT(pteval_t, 1) << 10) /* shared(v6), coherent(xsc3) */
1930 #define L_PTE_NONE (_AT(pteval_t, 1) << 11)
1931
1932 +/* Two-level page tables only have PXN in the PGD, not in the PTE. */
1933 +#define L_PTE_PXN (_AT(pteval_t, 0))
1934 +
1935 /*
1936 * These are the memory types, defined to be compatible with
1937 * pre-ARMv6 CPUs cacheable and bufferable bits: XXCB
1938 diff --git a/arch/arm/include/asm/pgtable-3level-hwdef.h b/arch/arm/include/asm/pgtable-3level-hwdef.h
1939 index 626989f..9d67a33 100644
1940 --- a/arch/arm/include/asm/pgtable-3level-hwdef.h
1941 +++ b/arch/arm/include/asm/pgtable-3level-hwdef.h
1942 @@ -75,6 +75,7 @@
1943 #define PTE_EXT_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1944 #define PTE_EXT_AF (_AT(pteval_t, 1) << 10) /* Access Flag */
1945 #define PTE_EXT_NG (_AT(pteval_t, 1) << 11) /* nG */
1946 +#define PTE_EXT_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1947 #define PTE_EXT_XN (_AT(pteval_t, 1) << 54) /* XN */
1948
1949 /*
1950 diff --git a/arch/arm/include/asm/pgtable-3level.h b/arch/arm/include/asm/pgtable-3level.h
1951 index 5689c18..eea12f9 100644
1952 --- a/arch/arm/include/asm/pgtable-3level.h
1953 +++ b/arch/arm/include/asm/pgtable-3level.h
1954 @@ -82,6 +82,7 @@
1955 #define L_PTE_RDONLY (_AT(pteval_t, 1) << 7) /* AP[2] */
1956 #define L_PTE_SHARED (_AT(pteval_t, 3) << 8) /* SH[1:0], inner shareable */
1957 #define L_PTE_YOUNG (_AT(pteval_t, 1) << 10) /* AF */
1958 +#define L_PTE_PXN (_AT(pteval_t, 1) << 53) /* PXN */
1959 #define L_PTE_XN (_AT(pteval_t, 1) << 54) /* XN */
1960 #define L_PTE_DIRTY (_AT(pteval_t, 1) << 55) /* unused */
1961 #define L_PTE_SPECIAL (_AT(pteval_t, 1) << 56) /* unused */
1962 @@ -95,6 +96,7 @@
1963 /*
1964 * To be used in assembly code with the upper page attributes.
1965 */
1966 +#define L_PTE_PXN_HIGH (1 << (53 - 32))
1967 #define L_PTE_XN_HIGH (1 << (54 - 32))
1968 #define L_PTE_DIRTY_HIGH (1 << (55 - 32))
1969
1970 diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h
1971 index 1571d12..b8a9b43 100644
1972 --- a/arch/arm/include/asm/pgtable.h
1973 +++ b/arch/arm/include/asm/pgtable.h
1974 @@ -33,6 +33,9 @@
1975 #include <asm/pgtable-2level.h>
1976 #endif
1977
1978 +#define ktla_ktva(addr) (addr)
1979 +#define ktva_ktla(addr) (addr)
1980 +
1981 /*
1982 * Just any arbitrary offset to the start of the vmalloc VM area: the
1983 * current 8MB value just means that there will be a 8MB "hole" after the
1984 @@ -48,6 +51,9 @@
1985 #define LIBRARY_TEXT_START 0x0c000000
1986
1987 #ifndef __ASSEMBLY__
1988 +extern pteval_t __supported_pte_mask;
1989 +extern pmdval_t __supported_pmd_mask;
1990 +
1991 extern void __pte_error(const char *file, int line, pte_t);
1992 extern void __pmd_error(const char *file, int line, pmd_t);
1993 extern void __pgd_error(const char *file, int line, pgd_t);
1994 @@ -56,6 +62,48 @@ extern void __pgd_error(const char *file, int line, pgd_t);
1995 #define pmd_ERROR(pmd) __pmd_error(__FILE__, __LINE__, pmd)
1996 #define pgd_ERROR(pgd) __pgd_error(__FILE__, __LINE__, pgd)
1997
1998 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
1999 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
2000 +
2001 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2002 +#include <asm/domain.h>
2003 +#include <linux/thread_info.h>
2004 +#include <linux/preempt.h>
2005 +
2006 +static inline int test_domain(int domain, int domaintype)
2007 +{
2008 + return ((current_thread_info()->cpu_domain) & domain_val(domain, 3)) == domain_val(domain, domaintype);
2009 +}
2010 +#endif
2011 +
2012 +#ifdef CONFIG_PAX_KERNEXEC
2013 +static inline unsigned long pax_open_kernel(void) {
2014 +#ifdef CONFIG_ARM_LPAE
2015 + /* TODO */
2016 +#else
2017 + preempt_disable();
2018 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC));
2019 + modify_domain(DOMAIN_KERNEL, DOMAIN_KERNEXEC);
2020 +#endif
2021 + return 0;
2022 +}
2023 +
2024 +static inline unsigned long pax_close_kernel(void) {
2025 +#ifdef CONFIG_ARM_LPAE
2026 + /* TODO */
2027 +#else
2028 + BUG_ON(test_domain(DOMAIN_KERNEL, DOMAIN_MANAGER));
2029 + /* DOMAIN_MANAGER = "client" under KERNEXEC */
2030 + modify_domain(DOMAIN_KERNEL, DOMAIN_MANAGER);
2031 + preempt_enable_no_resched();
2032 +#endif
2033 + return 0;
2034 +}
2035 +#else
2036 +static inline unsigned long pax_open_kernel(void) { return 0; }
2037 +static inline unsigned long pax_close_kernel(void) { return 0; }
2038 +#endif
2039 +
2040 /*
2041 * This is the lowest virtual address we can permit any user space
2042 * mapping to be mapped at. This is particularly important for
2043 @@ -75,8 +123,8 @@ extern void __pgd_error(const char *file, int line, pgd_t);
2044 /*
2045 * The pgprot_* and protection_map entries will be fixed up in runtime
2046 * to include the cachable and bufferable bits based on memory policy,
2047 - * as well as any architecture dependent bits like global/ASID and SMP
2048 - * shared mapping bits.
2049 + * as well as any architecture dependent bits like global/ASID, PXN,
2050 + * and SMP shared mapping bits.
2051 */
2052 #define _L_PTE_DEFAULT L_PTE_PRESENT | L_PTE_YOUNG
2053
2054 @@ -260,7 +308,7 @@ static inline pte_t pte_mkspecial(pte_t pte) { return pte; }
2055 static inline pte_t pte_modify(pte_t pte, pgprot_t newprot)
2056 {
2057 const pteval_t mask = L_PTE_XN | L_PTE_RDONLY | L_PTE_USER |
2058 - L_PTE_NONE | L_PTE_VALID;
2059 + L_PTE_NONE | L_PTE_VALID | __supported_pte_mask;
2060 pte_val(pte) = (pte_val(pte) & ~mask) | (pgprot_val(newprot) & mask);
2061 return pte;
2062 }
2063 diff --git a/arch/arm/include/asm/proc-fns.h b/arch/arm/include/asm/proc-fns.h
2064 index 5324c11..bcae5f0 100644
2065 --- a/arch/arm/include/asm/proc-fns.h
2066 +++ b/arch/arm/include/asm/proc-fns.h
2067 @@ -75,7 +75,7 @@ extern struct processor {
2068 unsigned int suspend_size;
2069 void (*do_suspend)(void *);
2070 void (*do_resume)(void *);
2071 -} processor;
2072 +} __do_const processor;
2073
2074 #ifndef MULTI_CPU
2075 extern void cpu_proc_init(void);
2076 diff --git a/arch/arm/include/asm/psci.h b/arch/arm/include/asm/psci.h
2077 index c4ae171..ea0c0c2 100644
2078 --- a/arch/arm/include/asm/psci.h
2079 +++ b/arch/arm/include/asm/psci.h
2080 @@ -29,7 +29,7 @@ struct psci_operations {
2081 int (*cpu_off)(struct psci_power_state state);
2082 int (*cpu_on)(unsigned long cpuid, unsigned long entry_point);
2083 int (*migrate)(unsigned long cpuid);
2084 -};
2085 +} __no_const;
2086
2087 extern struct psci_operations psci_ops;
2088 extern struct smp_operations psci_smp_ops;
2089 diff --git a/arch/arm/include/asm/smp.h b/arch/arm/include/asm/smp.h
2090 index a8cae71c..65dd797 100644
2091 --- a/arch/arm/include/asm/smp.h
2092 +++ b/arch/arm/include/asm/smp.h
2093 @@ -110,7 +110,7 @@ struct smp_operations {
2094 int (*cpu_disable)(unsigned int cpu);
2095 #endif
2096 #endif
2097 -};
2098 +} __no_const;
2099
2100 /*
2101 * set platform specific SMP operations
2102 diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
2103 index df5e13d..97efb82 100644
2104 --- a/arch/arm/include/asm/thread_info.h
2105 +++ b/arch/arm/include/asm/thread_info.h
2106 @@ -88,9 +88,9 @@ struct thread_info {
2107 .flags = 0, \
2108 .preempt_count = INIT_PREEMPT_COUNT, \
2109 .addr_limit = KERNEL_DS, \
2110 - .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2111 - domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2112 - domain_val(DOMAIN_IO, DOMAIN_CLIENT), \
2113 + .cpu_domain = domain_val(DOMAIN_USER, DOMAIN_USERCLIENT) | \
2114 + domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT) | \
2115 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT), \
2116 .restart_block = { \
2117 .fn = do_no_restart_syscall, \
2118 }, \
2119 @@ -163,7 +163,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2120 #define TIF_SYSCALL_AUDIT 9
2121 #define TIF_SYSCALL_TRACEPOINT 10
2122 #define TIF_SECCOMP 11 /* seccomp syscall filtering active */
2123 -#define TIF_NOHZ 12 /* in adaptive nohz mode */
2124 +/* within 8 bits of TIF_SYSCALL_TRACE
2125 + * to meet flexible second operand requirements
2126 + */
2127 +#define TIF_GRSEC_SETXID 12
2128 +#define TIF_NOHZ 13 /* in adaptive nohz mode */
2129 #define TIF_USING_IWMMXT 17
2130 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */
2131 #define TIF_RESTORE_SIGMASK 20
2132 @@ -176,10 +180,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
2133 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
2134 #define _TIF_SECCOMP (1 << TIF_SECCOMP)
2135 #define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
2136 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
2137
2138 /* Checks for any syscall work in entry-common.S */
2139 #define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
2140 - _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
2141 + _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_GRSEC_SETXID)
2142
2143 /*
2144 * Change these and you break ASM code in entry-common.S
2145 diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h
2146 index 72abdc5..9eba222 100644
2147 --- a/arch/arm/include/asm/uaccess.h
2148 +++ b/arch/arm/include/asm/uaccess.h
2149 @@ -18,6 +18,7 @@
2150 #include <asm/domain.h>
2151 #include <asm/unified.h>
2152 #include <asm/compiler.h>
2153 +#include <asm/pgtable.h>
2154
2155 #if __LINUX_ARM_ARCH__ < 6
2156 #include <asm-generic/uaccess-unaligned.h>
2157 @@ -70,11 +71,38 @@ extern int __put_user_bad(void);
2158 static inline void set_fs(mm_segment_t fs)
2159 {
2160 current_thread_info()->addr_limit = fs;
2161 - modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER);
2162 + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_KERNELCLIENT : DOMAIN_MANAGER);
2163 }
2164
2165 #define segment_eq(a,b) ((a) == (b))
2166
2167 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
2168 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
2169 +
2170 +static inline void pax_open_userland(void)
2171 +{
2172 +
2173 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2174 + if (segment_eq(get_fs(), USER_DS)) {
2175 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_UDEREF));
2176 + modify_domain(DOMAIN_USER, DOMAIN_UDEREF);
2177 + }
2178 +#endif
2179 +
2180 +}
2181 +
2182 +static inline void pax_close_userland(void)
2183 +{
2184 +
2185 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2186 + if (segment_eq(get_fs(), USER_DS)) {
2187 + BUG_ON(test_domain(DOMAIN_USER, DOMAIN_NOACCESS));
2188 + modify_domain(DOMAIN_USER, DOMAIN_NOACCESS);
2189 + }
2190 +#endif
2191 +
2192 +}
2193 +
2194 #define __addr_ok(addr) ({ \
2195 unsigned long flag; \
2196 __asm__("cmp %2, %0; movlo %0, #0" \
2197 @@ -150,8 +178,12 @@ extern int __get_user_4(void *);
2198
2199 #define get_user(x,p) \
2200 ({ \
2201 + int __e; \
2202 might_fault(); \
2203 - __get_user_check(x,p); \
2204 + pax_open_userland(); \
2205 + __e = __get_user_check(x,p); \
2206 + pax_close_userland(); \
2207 + __e; \
2208 })
2209
2210 extern int __put_user_1(void *, unsigned int);
2211 @@ -195,8 +227,12 @@ extern int __put_user_8(void *, unsigned long long);
2212
2213 #define put_user(x,p) \
2214 ({ \
2215 + int __e; \
2216 might_fault(); \
2217 - __put_user_check(x,p); \
2218 + pax_open_userland(); \
2219 + __e = __put_user_check(x,p); \
2220 + pax_close_userland(); \
2221 + __e; \
2222 })
2223
2224 #else /* CONFIG_MMU */
2225 @@ -237,13 +273,17 @@ static inline void set_fs(mm_segment_t fs)
2226 #define __get_user(x,ptr) \
2227 ({ \
2228 long __gu_err = 0; \
2229 + pax_open_userland(); \
2230 __get_user_err((x),(ptr),__gu_err); \
2231 + pax_close_userland(); \
2232 __gu_err; \
2233 })
2234
2235 #define __get_user_error(x,ptr,err) \
2236 ({ \
2237 + pax_open_userland(); \
2238 __get_user_err((x),(ptr),err); \
2239 + pax_close_userland(); \
2240 (void) 0; \
2241 })
2242
2243 @@ -319,13 +359,17 @@ do { \
2244 #define __put_user(x,ptr) \
2245 ({ \
2246 long __pu_err = 0; \
2247 + pax_open_userland(); \
2248 __put_user_err((x),(ptr),__pu_err); \
2249 + pax_close_userland(); \
2250 __pu_err; \
2251 })
2252
2253 #define __put_user_error(x,ptr,err) \
2254 ({ \
2255 + pax_open_userland(); \
2256 __put_user_err((x),(ptr),err); \
2257 + pax_close_userland(); \
2258 (void) 0; \
2259 })
2260
2261 @@ -425,11 +469,44 @@ do { \
2262
2263
2264 #ifdef CONFIG_MMU
2265 -extern unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n);
2266 -extern unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n);
2267 +extern unsigned long __must_check ___copy_from_user(void *to, const void __user *from, unsigned long n);
2268 +extern unsigned long __must_check ___copy_to_user(void __user *to, const void *from, unsigned long n);
2269 +
2270 +static inline unsigned long __must_check __copy_from_user(void *to, const void __user *from, unsigned long n)
2271 +{
2272 + unsigned long ret;
2273 +
2274 + check_object_size(to, n, false);
2275 + pax_open_userland();
2276 + ret = ___copy_from_user(to, from, n);
2277 + pax_close_userland();
2278 + return ret;
2279 +}
2280 +
2281 +static inline unsigned long __must_check __copy_to_user(void __user *to, const void *from, unsigned long n)
2282 +{
2283 + unsigned long ret;
2284 +
2285 + check_object_size(from, n, true);
2286 + pax_open_userland();
2287 + ret = ___copy_to_user(to, from, n);
2288 + pax_close_userland();
2289 + return ret;
2290 +}
2291 +
2292 extern unsigned long __must_check __copy_to_user_std(void __user *to, const void *from, unsigned long n);
2293 -extern unsigned long __must_check __clear_user(void __user *addr, unsigned long n);
2294 +extern unsigned long __must_check ___clear_user(void __user *addr, unsigned long n);
2295 extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned long n);
2296 +
2297 +static inline unsigned long __must_check __clear_user(void __user *addr, unsigned long n)
2298 +{
2299 + unsigned long ret;
2300 + pax_open_userland();
2301 + ret = ___clear_user(addr, n);
2302 + pax_close_userland();
2303 + return ret;
2304 +}
2305 +
2306 #else
2307 #define __copy_from_user(to,from,n) (memcpy(to, (void __force *)from, n), 0)
2308 #define __copy_to_user(to,from,n) (memcpy((void __force *)to, from, n), 0)
2309 @@ -438,6 +515,9 @@ extern unsigned long __must_check __clear_user_std(void __user *addr, unsigned l
2310
2311 static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
2312 {
2313 + if ((long)n < 0)
2314 + return n;
2315 +
2316 if (access_ok(VERIFY_READ, from, n))
2317 n = __copy_from_user(to, from, n);
2318 else /* security hole - plug it */
2319 @@ -447,6 +527,9 @@ static inline unsigned long __must_check copy_from_user(void *to, const void __u
2320
2321 static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
2322 {
2323 + if ((long)n < 0)
2324 + return n;
2325 +
2326 if (access_ok(VERIFY_WRITE, to, n))
2327 n = __copy_to_user(to, from, n);
2328 return n;
2329 diff --git a/arch/arm/include/uapi/asm/ptrace.h b/arch/arm/include/uapi/asm/ptrace.h
2330 index 5af0ed1..cea83883 100644
2331 --- a/arch/arm/include/uapi/asm/ptrace.h
2332 +++ b/arch/arm/include/uapi/asm/ptrace.h
2333 @@ -92,7 +92,7 @@
2334 * ARMv7 groups of PSR bits
2335 */
2336 #define APSR_MASK 0xf80f0000 /* N, Z, C, V, Q and GE flags */
2337 -#define PSR_ISET_MASK 0x01000010 /* ISA state (J, T) mask */
2338 +#define PSR_ISET_MASK 0x01000020 /* ISA state (J, T) mask */
2339 #define PSR_IT_MASK 0x0600fc00 /* If-Then execution state mask */
2340 #define PSR_ENDIAN_MASK 0x00000200 /* Endianness state mask */
2341
2342 diff --git a/arch/arm/kernel/armksyms.c b/arch/arm/kernel/armksyms.c
2343 index 60d3b73..e5a0f22 100644
2344 --- a/arch/arm/kernel/armksyms.c
2345 +++ b/arch/arm/kernel/armksyms.c
2346 @@ -53,7 +53,7 @@ EXPORT_SYMBOL(arm_delay_ops);
2347
2348 /* networking */
2349 EXPORT_SYMBOL(csum_partial);
2350 -EXPORT_SYMBOL(csum_partial_copy_from_user);
2351 +EXPORT_SYMBOL(__csum_partial_copy_from_user);
2352 EXPORT_SYMBOL(csum_partial_copy_nocheck);
2353 EXPORT_SYMBOL(__csum_ipv6_magic);
2354
2355 @@ -89,9 +89,9 @@ EXPORT_SYMBOL(__memzero);
2356 #ifdef CONFIG_MMU
2357 EXPORT_SYMBOL(copy_page);
2358
2359 -EXPORT_SYMBOL(__copy_from_user);
2360 -EXPORT_SYMBOL(__copy_to_user);
2361 -EXPORT_SYMBOL(__clear_user);
2362 +EXPORT_SYMBOL(___copy_from_user);
2363 +EXPORT_SYMBOL(___copy_to_user);
2364 +EXPORT_SYMBOL(___clear_user);
2365
2366 EXPORT_SYMBOL(__get_user_1);
2367 EXPORT_SYMBOL(__get_user_2);
2368 diff --git a/arch/arm/kernel/entry-armv.S b/arch/arm/kernel/entry-armv.S
2369 index ec3e5cf..b450ee3 100644
2370 --- a/arch/arm/kernel/entry-armv.S
2371 +++ b/arch/arm/kernel/entry-armv.S
2372 @@ -47,6 +47,87 @@
2373 9997:
2374 .endm
2375
2376 + .macro pax_enter_kernel
2377 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2378 + @ make aligned space for saved DACR
2379 + sub sp, sp, #8
2380 + @ save regs
2381 + stmdb sp!, {r1, r2}
2382 + @ read DACR from cpu_domain into r1
2383 + mov r2, sp
2384 + @ assume 8K pages, since we have to split the immediate in two
2385 + bic r2, r2, #(0x1fc0)
2386 + bic r2, r2, #(0x3f)
2387 + ldr r1, [r2, #TI_CPU_DOMAIN]
2388 + @ store old DACR on stack
2389 + str r1, [sp, #8]
2390 +#ifdef CONFIG_PAX_KERNEXEC
2391 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2392 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2393 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2394 +#endif
2395 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2396 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2397 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2398 +#endif
2399 + @ write r1 to current_thread_info()->cpu_domain
2400 + str r1, [r2, #TI_CPU_DOMAIN]
2401 + @ write r1 to DACR
2402 + mcr p15, 0, r1, c3, c0, 0
2403 + @ instruction sync
2404 + instr_sync
2405 + @ restore regs
2406 + ldmia sp!, {r1, r2}
2407 +#endif
2408 + .endm
2409 +
2410 + .macro pax_open_userland
2411 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2412 + @ save regs
2413 + stmdb sp!, {r0, r1}
2414 + @ read DACR from cpu_domain into r1
2415 + mov r0, sp
2416 + @ assume 8K pages, since we have to split the immediate in two
2417 + bic r0, r0, #(0x1fc0)
2418 + bic r0, r0, #(0x3f)
2419 + ldr r1, [r0, #TI_CPU_DOMAIN]
2420 + @ set current DOMAIN_USER to DOMAIN_CLIENT
2421 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2422 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2423 + @ write r1 to current_thread_info()->cpu_domain
2424 + str r1, [r0, #TI_CPU_DOMAIN]
2425 + @ write r1 to DACR
2426 + mcr p15, 0, r1, c3, c0, 0
2427 + @ instruction sync
2428 + instr_sync
2429 + @ restore regs
2430 + ldmia sp!, {r0, r1}
2431 +#endif
2432 + .endm
2433 +
2434 + .macro pax_close_userland
2435 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2436 + @ save regs
2437 + stmdb sp!, {r0, r1}
2438 + @ read DACR from cpu_domain into r1
2439 + mov r0, sp
2440 + @ assume 8K pages, since we have to split the immediate in two
2441 + bic r0, r0, #(0x1fc0)
2442 + bic r0, r0, #(0x3f)
2443 + ldr r1, [r0, #TI_CPU_DOMAIN]
2444 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2445 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2446 + @ write r1 to current_thread_info()->cpu_domain
2447 + str r1, [r0, #TI_CPU_DOMAIN]
2448 + @ write r1 to DACR
2449 + mcr p15, 0, r1, c3, c0, 0
2450 + @ instruction sync
2451 + instr_sync
2452 + @ restore regs
2453 + ldmia sp!, {r0, r1}
2454 +#endif
2455 + .endm
2456 +
2457 .macro pabt_helper
2458 @ PABORT handler takes pt_regs in r2, fault address in r4 and psr in r5
2459 #ifdef MULTI_PABORT
2460 @@ -89,11 +170,15 @@
2461 * Invalid mode handlers
2462 */
2463 .macro inv_entry, reason
2464 +
2465 + pax_enter_kernel
2466 +
2467 sub sp, sp, #S_FRAME_SIZE
2468 ARM( stmib sp, {r1 - lr} )
2469 THUMB( stmia sp, {r0 - r12} )
2470 THUMB( str sp, [sp, #S_SP] )
2471 THUMB( str lr, [sp, #S_LR] )
2472 +
2473 mov r1, #\reason
2474 .endm
2475
2476 @@ -149,7 +234,11 @@ ENDPROC(__und_invalid)
2477 .macro svc_entry, stack_hole=0
2478 UNWIND(.fnstart )
2479 UNWIND(.save {r0 - pc} )
2480 +
2481 + pax_enter_kernel
2482 +
2483 sub sp, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2484 +
2485 #ifdef CONFIG_THUMB2_KERNEL
2486 SPFIX( str r0, [sp] ) @ temporarily saved
2487 SPFIX( mov r0, sp )
2488 @@ -164,7 +253,12 @@ ENDPROC(__und_invalid)
2489 ldmia r0, {r3 - r5}
2490 add r7, sp, #S_SP - 4 @ here for interlock avoidance
2491 mov r6, #-1 @ "" "" "" ""
2492 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2493 + @ offset sp by 8 as done in pax_enter_kernel
2494 + add r2, sp, #(S_FRAME_SIZE + \stack_hole + 4)
2495 +#else
2496 add r2, sp, #(S_FRAME_SIZE + \stack_hole - 4)
2497 +#endif
2498 SPFIX( addeq r2, r2, #4 )
2499 str r3, [sp, #-4]! @ save the "real" r0 copied
2500 @ from the exception stack
2501 @@ -317,6 +411,9 @@ ENDPROC(__pabt_svc)
2502 .macro usr_entry
2503 UNWIND(.fnstart )
2504 UNWIND(.cantunwind ) @ don't unwind the user space
2505 +
2506 + pax_enter_kernel_user
2507 +
2508 sub sp, sp, #S_FRAME_SIZE
2509 ARM( stmib sp, {r1 - r12} )
2510 THUMB( stmia sp, {r0 - r12} )
2511 @@ -416,7 +513,9 @@ __und_usr:
2512 tst r3, #PSR_T_BIT @ Thumb mode?
2513 bne __und_usr_thumb
2514 sub r4, r2, #4 @ ARM instr at LR - 4
2515 + pax_open_userland
2516 1: ldrt r0, [r4]
2517 + pax_close_userland
2518 #ifdef CONFIG_CPU_ENDIAN_BE8
2519 rev r0, r0 @ little endian instruction
2520 #endif
2521 @@ -451,10 +550,14 @@ __und_usr_thumb:
2522 */
2523 .arch armv6t2
2524 #endif
2525 + pax_open_userland
2526 2: ldrht r5, [r4]
2527 + pax_close_userland
2528 cmp r5, #0xe800 @ 32bit instruction if xx != 0
2529 blo __und_usr_fault_16 @ 16bit undefined instruction
2530 + pax_open_userland
2531 3: ldrht r0, [r2]
2532 + pax_close_userland
2533 add r2, r2, #2 @ r2 is PC + 2, make it PC + 4
2534 str r2, [sp, #S_PC] @ it's a 2x16bit instr, update
2535 orr r0, r0, r5, lsl #16
2536 @@ -483,7 +586,8 @@ ENDPROC(__und_usr)
2537 */
2538 .pushsection .fixup, "ax"
2539 .align 2
2540 -4: mov pc, r9
2541 +4: pax_close_userland
2542 + mov pc, r9
2543 .popsection
2544 .pushsection __ex_table,"a"
2545 .long 1b, 4b
2546 @@ -693,7 +797,7 @@ ENTRY(__switch_to)
2547 THUMB( str lr, [ip], #4 )
2548 ldr r4, [r2, #TI_TP_VALUE]
2549 ldr r5, [r2, #TI_TP_VALUE + 4]
2550 -#ifdef CONFIG_CPU_USE_DOMAINS
2551 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2552 ldr r6, [r2, #TI_CPU_DOMAIN]
2553 #endif
2554 switch_tls r1, r4, r5, r3, r7
2555 @@ -702,7 +806,7 @@ ENTRY(__switch_to)
2556 ldr r8, =__stack_chk_guard
2557 ldr r7, [r7, #TSK_STACK_CANARY]
2558 #endif
2559 -#ifdef CONFIG_CPU_USE_DOMAINS
2560 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2561 mcr p15, 0, r6, c3, c0, 0 @ Set domain register
2562 #endif
2563 mov r5, r0
2564 diff --git a/arch/arm/kernel/entry-common.S b/arch/arm/kernel/entry-common.S
2565 index bc6bd96..bd026cb 100644
2566 --- a/arch/arm/kernel/entry-common.S
2567 +++ b/arch/arm/kernel/entry-common.S
2568 @@ -10,18 +10,46 @@
2569
2570 #include <asm/unistd.h>
2571 #include <asm/ftrace.h>
2572 +#include <asm/domain.h>
2573 #include <asm/unwind.h>
2574
2575 +#include "entry-header.S"
2576 +
2577 #ifdef CONFIG_NEED_RET_TO_USER
2578 #include <mach/entry-macro.S>
2579 #else
2580 .macro arch_ret_to_user, tmp1, tmp2
2581 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2582 + @ save regs
2583 + stmdb sp!, {r1, r2}
2584 + @ read DACR from cpu_domain into r1
2585 + mov r2, sp
2586 + @ assume 8K pages, since we have to split the immediate in two
2587 + bic r2, r2, #(0x1fc0)
2588 + bic r2, r2, #(0x3f)
2589 + ldr r1, [r2, #TI_CPU_DOMAIN]
2590 +#ifdef CONFIG_PAX_KERNEXEC
2591 + @ set type of DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2592 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2593 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2594 +#endif
2595 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2596 + @ set current DOMAIN_USER to DOMAIN_UDEREF
2597 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2598 + orr r1, r1, #(domain_val(DOMAIN_USER, DOMAIN_UDEREF))
2599 +#endif
2600 + @ write r1 to current_thread_info()->cpu_domain
2601 + str r1, [r2, #TI_CPU_DOMAIN]
2602 + @ write r1 to DACR
2603 + mcr p15, 0, r1, c3, c0, 0
2604 + @ instruction sync
2605 + instr_sync
2606 + @ restore regs
2607 + ldmia sp!, {r1, r2}
2608 +#endif
2609 .endm
2610 #endif
2611
2612 -#include "entry-header.S"
2613 -
2614 -
2615 .align 5
2616 /*
2617 * This is the fast syscall return path. We do as little as
2618 @@ -413,6 +441,12 @@ ENTRY(vector_swi)
2619 USER( ldr scno, [lr, #-4] ) @ get SWI instruction
2620 #endif
2621
2622 + /*
2623 + * do this here to avoid a performance hit of wrapping the code above
2624 + * that directly dereferences userland to parse the SWI instruction
2625 + */
2626 + pax_enter_kernel_user
2627 +
2628 adr tbl, sys_call_table @ load syscall table pointer
2629
2630 #if defined(CONFIG_OABI_COMPAT)
2631 diff --git a/arch/arm/kernel/entry-header.S b/arch/arm/kernel/entry-header.S
2632 index 39f89fb..d612bd9 100644
2633 --- a/arch/arm/kernel/entry-header.S
2634 +++ b/arch/arm/kernel/entry-header.S
2635 @@ -184,6 +184,60 @@
2636 msr cpsr_c, \rtemp @ switch back to the SVC mode
2637 .endm
2638
2639 + .macro pax_enter_kernel_user
2640 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2641 + @ save regs
2642 + stmdb sp!, {r0, r1}
2643 + @ read DACR from cpu_domain into r1
2644 + mov r0, sp
2645 + @ assume 8K pages, since we have to split the immediate in two
2646 + bic r0, r0, #(0x1fc0)
2647 + bic r0, r0, #(0x3f)
2648 + ldr r1, [r0, #TI_CPU_DOMAIN]
2649 +#ifdef CONFIG_PAX_MEMORY_UDEREF
2650 + @ set current DOMAIN_USER to DOMAIN_NOACCESS
2651 + bic r1, r1, #(domain_val(DOMAIN_USER, 3))
2652 +#endif
2653 +#ifdef CONFIG_PAX_KERNEXEC
2654 + @ set current DOMAIN_KERNEL to DOMAIN_KERNELCLIENT
2655 + bic r1, r1, #(domain_val(DOMAIN_KERNEL, 3))
2656 + orr r1, r1, #(domain_val(DOMAIN_KERNEL, DOMAIN_KERNELCLIENT))
2657 +#endif
2658 + @ write r1 to current_thread_info()->cpu_domain
2659 + str r1, [r0, #TI_CPU_DOMAIN]
2660 + @ write r1 to DACR
2661 + mcr p15, 0, r1, c3, c0, 0
2662 + @ instruction sync
2663 + instr_sync
2664 + @ restore regs
2665 + ldmia sp!, {r0, r1}
2666 +#endif
2667 + .endm
2668 +
2669 + .macro pax_exit_kernel
2670 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
2671 + @ save regs
2672 + stmdb sp!, {r0, r1}
2673 + @ read old DACR from stack into r1
2674 + ldr r1, [sp, #(8 + S_SP)]
2675 + sub r1, r1, #8
2676 + ldr r1, [r1]
2677 +
2678 + @ write r1 to current_thread_info()->cpu_domain
2679 + mov r0, sp
2680 + @ assume 8K pages, since we have to split the immediate in two
2681 + bic r0, r0, #(0x1fc0)
2682 + bic r0, r0, #(0x3f)
2683 + str r1, [r0, #TI_CPU_DOMAIN]
2684 + @ write r1 to DACR
2685 + mcr p15, 0, r1, c3, c0, 0
2686 + @ instruction sync
2687 + instr_sync
2688 + @ restore regs
2689 + ldmia sp!, {r0, r1}
2690 +#endif
2691 + .endm
2692 +
2693 #ifndef CONFIG_THUMB2_KERNEL
2694 .macro svc_exit, rpsr, irq = 0
2695 .if \irq != 0
2696 @@ -203,6 +257,9 @@
2697 blne trace_hardirqs_off
2698 #endif
2699 .endif
2700 +
2701 + pax_exit_kernel
2702 +
2703 msr spsr_cxsf, \rpsr
2704 #if defined(CONFIG_CPU_V6)
2705 ldr r0, [sp]
2706 @@ -266,6 +323,9 @@
2707 blne trace_hardirqs_off
2708 #endif
2709 .endif
2710 +
2711 + pax_exit_kernel
2712 +
2713 ldr lr, [sp, #S_SP] @ top of the stack
2714 ldrd r0, r1, [sp, #S_LR] @ calling lr and pc
2715 clrex @ clear the exclusive monitor
2716 diff --git a/arch/arm/kernel/fiq.c b/arch/arm/kernel/fiq.c
2717 index 918875d..cd5fa27 100644
2718 --- a/arch/arm/kernel/fiq.c
2719 +++ b/arch/arm/kernel/fiq.c
2720 @@ -87,7 +87,10 @@ void set_fiq_handler(void *start, unsigned int length)
2721 void *base = vectors_page;
2722 unsigned offset = FIQ_OFFSET;
2723
2724 + pax_open_kernel();
2725 memcpy(base + offset, start, length);
2726 + pax_close_kernel();
2727 +
2728 if (!cache_is_vipt_nonaliasing())
2729 flush_icache_range((unsigned long)base + offset, offset +
2730 length);
2731 diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S
2732 index 476de57..4857a76 100644
2733 --- a/arch/arm/kernel/head.S
2734 +++ b/arch/arm/kernel/head.S
2735 @@ -52,7 +52,9 @@
2736 .equ swapper_pg_dir, KERNEL_RAM_VADDR - PG_DIR_SIZE
2737
2738 .macro pgtbl, rd, phys
2739 - add \rd, \phys, #TEXT_OFFSET - PG_DIR_SIZE
2740 + mov \rd, #TEXT_OFFSET
2741 + sub \rd, #PG_DIR_SIZE
2742 + add \rd, \rd, \phys
2743 .endm
2744
2745 /*
2746 @@ -432,7 +434,7 @@ __enable_mmu:
2747 mov r5, #(domain_val(DOMAIN_USER, DOMAIN_MANAGER) | \
2748 domain_val(DOMAIN_KERNEL, DOMAIN_MANAGER) | \
2749 domain_val(DOMAIN_TABLE, DOMAIN_MANAGER) | \
2750 - domain_val(DOMAIN_IO, DOMAIN_CLIENT))
2751 + domain_val(DOMAIN_IO, DOMAIN_KERNELCLIENT))
2752 mcr p15, 0, r5, c3, c0, 0 @ load domain access register
2753 mcr p15, 0, r4, c2, c0, 0 @ load page table pointer
2754 #endif
2755 diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
2756 index 084dc88..fce4e68 100644
2757 --- a/arch/arm/kernel/module.c
2758 +++ b/arch/arm/kernel/module.c
2759 @@ -37,12 +37,39 @@
2760 #endif
2761
2762 #ifdef CONFIG_MMU
2763 -void *module_alloc(unsigned long size)
2764 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
2765 {
2766 + if (!size || PAGE_ALIGN(size) > MODULES_END - MODULES_VADDR)
2767 + return NULL;
2768 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
2769 - GFP_KERNEL, PAGE_KERNEL_EXEC, -1,
2770 + GFP_KERNEL, prot, -1,
2771 __builtin_return_address(0));
2772 }
2773 +
2774 +void *module_alloc(unsigned long size)
2775 +{
2776 +
2777 +#ifdef CONFIG_PAX_KERNEXEC
2778 + return __module_alloc(size, PAGE_KERNEL);
2779 +#else
2780 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2781 +#endif
2782 +
2783 +}
2784 +
2785 +#ifdef CONFIG_PAX_KERNEXEC
2786 +void module_free_exec(struct module *mod, void *module_region)
2787 +{
2788 + module_free(mod, module_region);
2789 +}
2790 +EXPORT_SYMBOL(module_free_exec);
2791 +
2792 +void *module_alloc_exec(unsigned long size)
2793 +{
2794 + return __module_alloc(size, PAGE_KERNEL_EXEC);
2795 +}
2796 +EXPORT_SYMBOL(module_alloc_exec);
2797 +#endif
2798 #endif
2799
2800 int
2801 diff --git a/arch/arm/kernel/patch.c b/arch/arm/kernel/patch.c
2802 index 07314af..c46655c 100644
2803 --- a/arch/arm/kernel/patch.c
2804 +++ b/arch/arm/kernel/patch.c
2805 @@ -18,6 +18,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2806 bool thumb2 = IS_ENABLED(CONFIG_THUMB2_KERNEL);
2807 int size;
2808
2809 + pax_open_kernel();
2810 if (thumb2 && __opcode_is_thumb16(insn)) {
2811 *(u16 *)addr = __opcode_to_mem_thumb16(insn);
2812 size = sizeof(u16);
2813 @@ -39,6 +40,7 @@ void __kprobes __patch_text(void *addr, unsigned int insn)
2814 *(u32 *)addr = insn;
2815 size = sizeof(u32);
2816 }
2817 + pax_close_kernel();
2818
2819 flush_icache_range((uintptr_t)(addr),
2820 (uintptr_t)(addr) + size);
2821 diff --git a/arch/arm/kernel/process.c b/arch/arm/kernel/process.c
2822 index 92f7b15..7048500 100644
2823 --- a/arch/arm/kernel/process.c
2824 +++ b/arch/arm/kernel/process.c
2825 @@ -217,6 +217,7 @@ void machine_power_off(void)
2826
2827 if (pm_power_off)
2828 pm_power_off();
2829 + BUG();
2830 }
2831
2832 /*
2833 @@ -230,7 +231,7 @@ void machine_power_off(void)
2834 * executing pre-reset code, and using RAM that the primary CPU's code wishes
2835 * to use. Implementing such co-ordination would be essentially impossible.
2836 */
2837 -void machine_restart(char *cmd)
2838 +__noreturn void machine_restart(char *cmd)
2839 {
2840 local_irq_disable();
2841 smp_send_stop();
2842 @@ -253,8 +254,8 @@ void __show_regs(struct pt_regs *regs)
2843
2844 show_regs_print_info(KERN_DEFAULT);
2845
2846 - print_symbol("PC is at %s\n", instruction_pointer(regs));
2847 - print_symbol("LR is at %s\n", regs->ARM_lr);
2848 + printk("PC is at %pA\n", (void *)instruction_pointer(regs));
2849 + printk("LR is at %pA\n", (void *)regs->ARM_lr);
2850 printk("pc : [<%08lx>] lr : [<%08lx>] psr: %08lx\n"
2851 "sp : %08lx ip : %08lx fp : %08lx\n",
2852 regs->ARM_pc, regs->ARM_lr, regs->ARM_cpsr,
2853 @@ -425,12 +426,6 @@ unsigned long get_wchan(struct task_struct *p)
2854 return 0;
2855 }
2856
2857 -unsigned long arch_randomize_brk(struct mm_struct *mm)
2858 -{
2859 - unsigned long range_end = mm->brk + 0x02000000;
2860 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
2861 -}
2862 -
2863 #ifdef CONFIG_MMU
2864 #ifdef CONFIG_KUSER_HELPERS
2865 /*
2866 @@ -446,7 +441,7 @@ static struct vm_area_struct gate_vma = {
2867
2868 static int __init gate_vma_init(void)
2869 {
2870 - gate_vma.vm_page_prot = PAGE_READONLY_EXEC;
2871 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
2872 return 0;
2873 }
2874 arch_initcall(gate_vma_init);
2875 @@ -472,41 +467,16 @@ int in_gate_area_no_mm(unsigned long addr)
2876
2877 const char *arch_vma_name(struct vm_area_struct *vma)
2878 {
2879 - return is_gate_vma(vma) ? "[vectors]" :
2880 - (vma->vm_mm && vma->vm_start == vma->vm_mm->context.sigpage) ?
2881 - "[sigpage]" : NULL;
2882 + return is_gate_vma(vma) ? "[vectors]" : NULL;
2883 }
2884
2885 -static struct page *signal_page;
2886 -extern struct page *get_signal_page(void);
2887 -
2888 int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
2889 {
2890 struct mm_struct *mm = current->mm;
2891 - unsigned long addr;
2892 - int ret;
2893 -
2894 - if (!signal_page)
2895 - signal_page = get_signal_page();
2896 - if (!signal_page)
2897 - return -ENOMEM;
2898
2899 down_write(&mm->mmap_sem);
2900 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
2901 - if (IS_ERR_VALUE(addr)) {
2902 - ret = addr;
2903 - goto up_fail;
2904 - }
2905 -
2906 - ret = install_special_mapping(mm, addr, PAGE_SIZE,
2907 - VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC,
2908 - &signal_page);
2909 -
2910 - if (ret == 0)
2911 - mm->context.sigpage = addr;
2912 -
2913 - up_fail:
2914 + mm->context.sigpage = (PAGE_OFFSET + (get_random_int() % 0x3FFEFFE0)) & 0xFFFFFFFC;
2915 up_write(&mm->mmap_sem);
2916 - return ret;
2917 + return 0;
2918 }
2919 #endif
2920 diff --git a/arch/arm/kernel/psci.c b/arch/arm/kernel/psci.c
2921 index 4693188..4596c5e 100644
2922 --- a/arch/arm/kernel/psci.c
2923 +++ b/arch/arm/kernel/psci.c
2924 @@ -24,7 +24,7 @@
2925 #include <asm/opcodes-virt.h>
2926 #include <asm/psci.h>
2927
2928 -struct psci_operations psci_ops;
2929 +struct psci_operations psci_ops __read_only;
2930
2931 static int (*invoke_psci_fn)(u32, u32, u32, u32);
2932
2933 diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
2934 index 0dd3b79..e018f64 100644
2935 --- a/arch/arm/kernel/ptrace.c
2936 +++ b/arch/arm/kernel/ptrace.c
2937 @@ -929,10 +929,19 @@ static int tracehook_report_syscall(struct pt_regs *regs,
2938 return current_thread_info()->syscall;
2939 }
2940
2941 +#ifdef CONFIG_GRKERNSEC_SETXID
2942 +extern void gr_delayed_cred_worker(void);
2943 +#endif
2944 +
2945 asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
2946 {
2947 current_thread_info()->syscall = scno;
2948
2949 +#ifdef CONFIG_GRKERNSEC_SETXID
2950 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
2951 + gr_delayed_cred_worker();
2952 +#endif
2953 +
2954 /* Do the secure computing check first; failures should be fast. */
2955 if (secure_computing(scno) == -1)
2956 return -1;
2957 diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
2958 index 0e1e2b3..c0e821d 100644
2959 --- a/arch/arm/kernel/setup.c
2960 +++ b/arch/arm/kernel/setup.c
2961 @@ -98,21 +98,23 @@ EXPORT_SYMBOL(system_serial_high);
2962 unsigned int elf_hwcap __read_mostly;
2963 EXPORT_SYMBOL(elf_hwcap);
2964
2965 +pteval_t __supported_pte_mask __read_only;
2966 +pmdval_t __supported_pmd_mask __read_only;
2967
2968 #ifdef MULTI_CPU
2969 -struct processor processor __read_mostly;
2970 +struct processor processor;
2971 #endif
2972 #ifdef MULTI_TLB
2973 -struct cpu_tlb_fns cpu_tlb __read_mostly;
2974 +struct cpu_tlb_fns cpu_tlb __read_only;
2975 #endif
2976 #ifdef MULTI_USER
2977 -struct cpu_user_fns cpu_user __read_mostly;
2978 +struct cpu_user_fns cpu_user __read_only;
2979 #endif
2980 #ifdef MULTI_CACHE
2981 -struct cpu_cache_fns cpu_cache __read_mostly;
2982 +struct cpu_cache_fns cpu_cache __read_only;
2983 #endif
2984 #ifdef CONFIG_OUTER_CACHE
2985 -struct outer_cache_fns outer_cache __read_mostly;
2986 +struct outer_cache_fns outer_cache __read_only;
2987 EXPORT_SYMBOL(outer_cache);
2988 #endif
2989
2990 @@ -245,9 +247,13 @@ static int __get_cpu_architecture(void)
2991 asm("mrc p15, 0, %0, c0, c1, 4"
2992 : "=r" (mmfr0));
2993 if ((mmfr0 & 0x0000000f) >= 0x00000003 ||
2994 - (mmfr0 & 0x000000f0) >= 0x00000030)
2995 + (mmfr0 & 0x000000f0) >= 0x00000030) {
2996 cpu_arch = CPU_ARCH_ARMv7;
2997 - else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
2998 + if ((mmfr0 & 0x0000000f) == 0x00000005 || (mmfr0 & 0x0000000f) == 0x00000004) {
2999 + __supported_pte_mask |= L_PTE_PXN;
3000 + __supported_pmd_mask |= PMD_PXNTABLE;
3001 + }
3002 + } else if ((mmfr0 & 0x0000000f) == 0x00000002 ||
3003 (mmfr0 & 0x000000f0) == 0x00000020)
3004 cpu_arch = CPU_ARCH_ARMv6;
3005 else
3006 @@ -571,7 +577,7 @@ static void __init setup_processor(void)
3007 __cpu_architecture = __get_cpu_architecture();
3008
3009 #ifdef MULTI_CPU
3010 - processor = *list->proc;
3011 + memcpy((void *)&processor, list->proc, sizeof processor);
3012 #endif
3013 #ifdef MULTI_TLB
3014 cpu_tlb = *list->tlb;
3015 diff --git a/arch/arm/kernel/signal.c b/arch/arm/kernel/signal.c
3016 index ab33042..11248a8 100644
3017 --- a/arch/arm/kernel/signal.c
3018 +++ b/arch/arm/kernel/signal.c
3019 @@ -45,8 +45,6 @@ static const unsigned long sigreturn_codes[7] = {
3020 MOV_R7_NR_RT_SIGRETURN, SWI_SYS_RT_SIGRETURN, SWI_THUMB_RT_SIGRETURN,
3021 };
3022
3023 -static unsigned long signal_return_offset;
3024 -
3025 #ifdef CONFIG_CRUNCH
3026 static int preserve_crunch_context(struct crunch_sigframe __user *frame)
3027 {
3028 @@ -411,8 +409,7 @@ setup_return(struct pt_regs *regs, struct ksignal *ksig,
3029 * except when the MPU has protected the vectors
3030 * page from PL0
3031 */
3032 - retcode = mm->context.sigpage + signal_return_offset +
3033 - (idx << 2) + thumb;
3034 + retcode = mm->context.sigpage + (idx << 2) + thumb;
3035 } else
3036 #endif
3037 {
3038 @@ -616,33 +613,3 @@ do_work_pending(struct pt_regs *regs, unsigned int thread_flags, int syscall)
3039 } while (thread_flags & _TIF_WORK_MASK);
3040 return 0;
3041 }
3042 -
3043 -struct page *get_signal_page(void)
3044 -{
3045 - unsigned long ptr;
3046 - unsigned offset;
3047 - struct page *page;
3048 - void *addr;
3049 -
3050 - page = alloc_pages(GFP_KERNEL, 0);
3051 -
3052 - if (!page)
3053 - return NULL;
3054 -
3055 - addr = page_address(page);
3056 -
3057 - /* Give the signal return code some randomness */
3058 - offset = 0x200 + (get_random_int() & 0x7fc);
3059 - signal_return_offset = offset;
3060 -
3061 - /*
3062 - * Copy signal return handlers into the vector page, and
3063 - * set sigreturn to be a pointer to these.
3064 - */
3065 - memcpy(addr + offset, sigreturn_codes, sizeof(sigreturn_codes));
3066 -
3067 - ptr = (unsigned long)addr + offset;
3068 - flush_icache_range(ptr, ptr + sizeof(sigreturn_codes));
3069 -
3070 - return page;
3071 -}
3072 diff --git a/arch/arm/kernel/smp.c b/arch/arm/kernel/smp.c
3073 index 72024ea..ae302dd 100644
3074 --- a/arch/arm/kernel/smp.c
3075 +++ b/arch/arm/kernel/smp.c
3076 @@ -70,7 +70,7 @@ enum ipi_msg_type {
3077
3078 static DECLARE_COMPLETION(cpu_running);
3079
3080 -static struct smp_operations smp_ops;
3081 +static struct smp_operations smp_ops __read_only;
3082
3083 void __init smp_set_ops(struct smp_operations *ops)
3084 {
3085 diff --git a/arch/arm/kernel/traps.c b/arch/arm/kernel/traps.c
3086 index 65ed63f..430c478 100644
3087 --- a/arch/arm/kernel/traps.c
3088 +++ b/arch/arm/kernel/traps.c
3089 @@ -55,7 +55,7 @@ static void dump_mem(const char *, const char *, unsigned long, unsigned long);
3090 void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
3091 {
3092 #ifdef CONFIG_KALLSYMS
3093 - printk("[<%08lx>] (%pS) from [<%08lx>] (%pS)\n", where, (void *)where, from, (void *)from);
3094 + printk("[<%08lx>] (%pA) from [<%08lx>] (%pA)\n", where, (void *)where, from, (void *)from);
3095 #else
3096 printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
3097 #endif
3098 @@ -257,6 +257,8 @@ static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
3099 static int die_owner = -1;
3100 static unsigned int die_nest_count;
3101
3102 +extern void gr_handle_kernel_exploit(void);
3103 +
3104 static unsigned long oops_begin(void)
3105 {
3106 int cpu;
3107 @@ -299,6 +301,9 @@ static void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
3108 panic("Fatal exception in interrupt");
3109 if (panic_on_oops)
3110 panic("Fatal exception");
3111 +
3112 + gr_handle_kernel_exploit();
3113 +
3114 if (signr)
3115 do_exit(signr);
3116 }
3117 @@ -629,7 +634,9 @@ asmlinkage int arm_syscall(int no, struct pt_regs *regs)
3118 * The user helper at 0xffff0fe0 must be used instead.
3119 * (see entry-armv.S for details)
3120 */
3121 + pax_open_kernel();
3122 *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
3123 + pax_close_kernel();
3124 }
3125 return 0;
3126
3127 @@ -886,7 +893,11 @@ void __init early_trap_init(void *vectors_base)
3128 kuser_init(vectors_base);
3129
3130 flush_icache_range(vectors, vectors + PAGE_SIZE * 2);
3131 - modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
3132 +
3133 +#ifndef CONFIG_PAX_MEMORY_UDEREF
3134 + modify_domain(DOMAIN_USER, DOMAIN_USERCLIENT);
3135 +#endif
3136 +
3137 #else /* ifndef CONFIG_CPU_V7M */
3138 /*
3139 * on V7-M there is no need to copy the vector table to a dedicated
3140 diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S
3141 index 7bcee5c..e2f3249 100644
3142 --- a/arch/arm/kernel/vmlinux.lds.S
3143 +++ b/arch/arm/kernel/vmlinux.lds.S
3144 @@ -8,7 +8,11 @@
3145 #include <asm/thread_info.h>
3146 #include <asm/memory.h>
3147 #include <asm/page.h>
3148 -
3149 +
3150 +#ifdef CONFIG_PAX_KERNEXEC
3151 +#include <asm/pgtable.h>
3152 +#endif
3153 +
3154 #define PROC_INFO \
3155 . = ALIGN(4); \
3156 VMLINUX_SYMBOL(__proc_info_begin) = .; \
3157 @@ -34,7 +38,7 @@
3158 #endif
3159
3160 #if (defined(CONFIG_SMP_ON_UP) && !defined(CONFIG_DEBUG_SPINLOCK)) || \
3161 - defined(CONFIG_GENERIC_BUG)
3162 + defined(CONFIG_GENERIC_BUG) || defined(CONFIG_PAX_REFCOUNT)
3163 #define ARM_EXIT_KEEP(x) x
3164 #define ARM_EXIT_DISCARD(x)
3165 #else
3166 @@ -90,6 +94,11 @@ SECTIONS
3167 _text = .;
3168 HEAD_TEXT
3169 }
3170 +
3171 +#ifdef CONFIG_PAX_KERNEXEC
3172 + . = ALIGN(1<<SECTION_SHIFT);
3173 +#endif
3174 +
3175 .text : { /* Real text segment */
3176 _stext = .; /* Text and read-only data */
3177 __exception_text_start = .;
3178 @@ -112,6 +121,8 @@ SECTIONS
3179 ARM_CPU_KEEP(PROC_INFO)
3180 }
3181
3182 + _etext = .; /* End of text section */
3183 +
3184 RO_DATA(PAGE_SIZE)
3185
3186 . = ALIGN(4);
3187 @@ -142,7 +153,9 @@ SECTIONS
3188
3189 NOTES
3190
3191 - _etext = .; /* End of text and rodata section */
3192 +#ifdef CONFIG_PAX_KERNEXEC
3193 + . = ALIGN(1<<SECTION_SHIFT);
3194 +#endif
3195
3196 #ifndef CONFIG_XIP_KERNEL
3197 . = ALIGN(PAGE_SIZE);
3198 @@ -220,6 +233,11 @@ SECTIONS
3199 . = PAGE_OFFSET + TEXT_OFFSET;
3200 #else
3201 __init_end = .;
3202 +
3203 +#ifdef CONFIG_PAX_KERNEXEC
3204 + . = ALIGN(1<<SECTION_SHIFT);
3205 +#endif
3206 +
3207 . = ALIGN(THREAD_SIZE);
3208 __data_loc = .;
3209 #endif
3210 diff --git a/arch/arm/kvm/arm.c b/arch/arm/kvm/arm.c
3211 index 9c697db..115237f 100644
3212 --- a/arch/arm/kvm/arm.c
3213 +++ b/arch/arm/kvm/arm.c
3214 @@ -56,7 +56,7 @@ static unsigned long hyp_default_vectors;
3215 static DEFINE_PER_CPU(struct kvm_vcpu *, kvm_arm_running_vcpu);
3216
3217 /* The VMID used in the VTTBR */
3218 -static atomic64_t kvm_vmid_gen = ATOMIC64_INIT(1);
3219 +static atomic64_unchecked_t kvm_vmid_gen = ATOMIC64_INIT(1);
3220 static u8 kvm_next_vmid;
3221 static DEFINE_SPINLOCK(kvm_vmid_lock);
3222
3223 @@ -396,7 +396,7 @@ void force_vm_exit(const cpumask_t *mask)
3224 */
3225 static bool need_new_vmid_gen(struct kvm *kvm)
3226 {
3227 - return unlikely(kvm->arch.vmid_gen != atomic64_read(&kvm_vmid_gen));
3228 + return unlikely(kvm->arch.vmid_gen != atomic64_read_unchecked(&kvm_vmid_gen));
3229 }
3230
3231 /**
3232 @@ -429,7 +429,7 @@ static void update_vttbr(struct kvm *kvm)
3233
3234 /* First user of a new VMID generation? */
3235 if (unlikely(kvm_next_vmid == 0)) {
3236 - atomic64_inc(&kvm_vmid_gen);
3237 + atomic64_inc_unchecked(&kvm_vmid_gen);
3238 kvm_next_vmid = 1;
3239
3240 /*
3241 @@ -446,7 +446,7 @@ static void update_vttbr(struct kvm *kvm)
3242 kvm_call_hyp(__kvm_flush_vm_context);
3243 }
3244
3245 - kvm->arch.vmid_gen = atomic64_read(&kvm_vmid_gen);
3246 + kvm->arch.vmid_gen = atomic64_read_unchecked(&kvm_vmid_gen);
3247 kvm->arch.vmid = kvm_next_vmid;
3248 kvm_next_vmid++;
3249
3250 diff --git a/arch/arm/lib/clear_user.S b/arch/arm/lib/clear_user.S
3251 index 14a0d98..7771a7d 100644
3252 --- a/arch/arm/lib/clear_user.S
3253 +++ b/arch/arm/lib/clear_user.S
3254 @@ -12,14 +12,14 @@
3255
3256 .text
3257
3258 -/* Prototype: int __clear_user(void *addr, size_t sz)
3259 +/* Prototype: int ___clear_user(void *addr, size_t sz)
3260 * Purpose : clear some user memory
3261 * Params : addr - user memory address to clear
3262 * : sz - number of bytes to clear
3263 * Returns : number of bytes NOT cleared
3264 */
3265 ENTRY(__clear_user_std)
3266 -WEAK(__clear_user)
3267 +WEAK(___clear_user)
3268 stmfd sp!, {r1, lr}
3269 mov r2, #0
3270 cmp r1, #4
3271 @@ -44,7 +44,7 @@ WEAK(__clear_user)
3272 USER( strnebt r2, [r0])
3273 mov r0, #0
3274 ldmfd sp!, {r1, pc}
3275 -ENDPROC(__clear_user)
3276 +ENDPROC(___clear_user)
3277 ENDPROC(__clear_user_std)
3278
3279 .pushsection .fixup,"ax"
3280 diff --git a/arch/arm/lib/copy_from_user.S b/arch/arm/lib/copy_from_user.S
3281 index 66a477a..bee61d3 100644
3282 --- a/arch/arm/lib/copy_from_user.S
3283 +++ b/arch/arm/lib/copy_from_user.S
3284 @@ -16,7 +16,7 @@
3285 /*
3286 * Prototype:
3287 *
3288 - * size_t __copy_from_user(void *to, const void *from, size_t n)
3289 + * size_t ___copy_from_user(void *to, const void *from, size_t n)
3290 *
3291 * Purpose:
3292 *
3293 @@ -84,11 +84,11 @@
3294
3295 .text
3296
3297 -ENTRY(__copy_from_user)
3298 +ENTRY(___copy_from_user)
3299
3300 #include "copy_template.S"
3301
3302 -ENDPROC(__copy_from_user)
3303 +ENDPROC(___copy_from_user)
3304
3305 .pushsection .fixup,"ax"
3306 .align 0
3307 diff --git a/arch/arm/lib/copy_page.S b/arch/arm/lib/copy_page.S
3308 index 6ee2f67..d1cce76 100644
3309 --- a/arch/arm/lib/copy_page.S
3310 +++ b/arch/arm/lib/copy_page.S
3311 @@ -10,6 +10,7 @@
3312 * ASM optimised string functions
3313 */
3314 #include <linux/linkage.h>
3315 +#include <linux/const.h>
3316 #include <asm/assembler.h>
3317 #include <asm/asm-offsets.h>
3318 #include <asm/cache.h>
3319 diff --git a/arch/arm/lib/copy_to_user.S b/arch/arm/lib/copy_to_user.S
3320 index d066df6..df28194 100644
3321 --- a/arch/arm/lib/copy_to_user.S
3322 +++ b/arch/arm/lib/copy_to_user.S
3323 @@ -16,7 +16,7 @@
3324 /*
3325 * Prototype:
3326 *
3327 - * size_t __copy_to_user(void *to, const void *from, size_t n)
3328 + * size_t ___copy_to_user(void *to, const void *from, size_t n)
3329 *
3330 * Purpose:
3331 *
3332 @@ -88,11 +88,11 @@
3333 .text
3334
3335 ENTRY(__copy_to_user_std)
3336 -WEAK(__copy_to_user)
3337 +WEAK(___copy_to_user)
3338
3339 #include "copy_template.S"
3340
3341 -ENDPROC(__copy_to_user)
3342 +ENDPROC(___copy_to_user)
3343 ENDPROC(__copy_to_user_std)
3344
3345 .pushsection .fixup,"ax"
3346 diff --git a/arch/arm/lib/csumpartialcopyuser.S b/arch/arm/lib/csumpartialcopyuser.S
3347 index 7d08b43..f7ca7ea 100644
3348 --- a/arch/arm/lib/csumpartialcopyuser.S
3349 +++ b/arch/arm/lib/csumpartialcopyuser.S
3350 @@ -57,8 +57,8 @@
3351 * Returns : r0 = checksum, [[sp, #0], #0] = 0 or -EFAULT
3352 */
3353
3354 -#define FN_ENTRY ENTRY(csum_partial_copy_from_user)
3355 -#define FN_EXIT ENDPROC(csum_partial_copy_from_user)
3356 +#define FN_ENTRY ENTRY(__csum_partial_copy_from_user)
3357 +#define FN_EXIT ENDPROC(__csum_partial_copy_from_user)
3358
3359 #include "csumpartialcopygeneric.S"
3360
3361 diff --git a/arch/arm/lib/delay.c b/arch/arm/lib/delay.c
3362 index 5306de3..aed6d03 100644
3363 --- a/arch/arm/lib/delay.c
3364 +++ b/arch/arm/lib/delay.c
3365 @@ -28,7 +28,7 @@
3366 /*
3367 * Default to the loop-based delay implementation.
3368 */
3369 -struct arm_delay_ops arm_delay_ops = {
3370 +struct arm_delay_ops arm_delay_ops __read_only = {
3371 .delay = __loop_delay,
3372 .const_udelay = __loop_const_udelay,
3373 .udelay = __loop_udelay,
3374 diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c
3375 index 025f742..a9e5b3b 100644
3376 --- a/arch/arm/lib/uaccess_with_memcpy.c
3377 +++ b/arch/arm/lib/uaccess_with_memcpy.c
3378 @@ -104,7 +104,7 @@ out:
3379 }
3380
3381 unsigned long
3382 -__copy_to_user(void __user *to, const void *from, unsigned long n)
3383 +___copy_to_user(void __user *to, const void *from, unsigned long n)
3384 {
3385 /*
3386 * This test is stubbed out of the main function above to keep
3387 @@ -155,7 +155,7 @@ out:
3388 return n;
3389 }
3390
3391 -unsigned long __clear_user(void __user *addr, unsigned long n)
3392 +unsigned long ___clear_user(void __user *addr, unsigned long n)
3393 {
3394 /* See rational for this in __copy_to_user() above. */
3395 if (n < 64)
3396 diff --git a/arch/arm/mach-kirkwood/common.c b/arch/arm/mach-kirkwood/common.c
3397 index 1767611..d2e7e24 100644
3398 --- a/arch/arm/mach-kirkwood/common.c
3399 +++ b/arch/arm/mach-kirkwood/common.c
3400 @@ -156,7 +156,16 @@ static void clk_gate_fn_disable(struct clk_hw *hw)
3401 clk_gate_ops.disable(hw);
3402 }
3403
3404 -static struct clk_ops clk_gate_fn_ops;
3405 +static int clk_gate_fn_is_enabled(struct clk_hw *hw)
3406 +{
3407 + return clk_gate_ops.is_enabled(hw);
3408 +}
3409 +
3410 +static struct clk_ops clk_gate_fn_ops = {
3411 + .enable = clk_gate_fn_enable,
3412 + .disable = clk_gate_fn_disable,
3413 + .is_enabled = clk_gate_fn_is_enabled,
3414 +};
3415
3416 static struct clk __init *clk_register_gate_fn(struct device *dev,
3417 const char *name,
3418 @@ -190,14 +199,6 @@ static struct clk __init *clk_register_gate_fn(struct device *dev,
3419 gate_fn->fn_en = fn_en;
3420 gate_fn->fn_dis = fn_dis;
3421
3422 - /* ops is the gate ops, but with our enable/disable functions */
3423 - if (clk_gate_fn_ops.enable != clk_gate_fn_enable ||
3424 - clk_gate_fn_ops.disable != clk_gate_fn_disable) {
3425 - clk_gate_fn_ops = clk_gate_ops;
3426 - clk_gate_fn_ops.enable = clk_gate_fn_enable;
3427 - clk_gate_fn_ops.disable = clk_gate_fn_disable;
3428 - }
3429 -
3430 clk = clk_register(dev, &gate_fn->gate.hw);
3431
3432 if (IS_ERR(clk))
3433 diff --git a/arch/arm/mach-omap2/board-n8x0.c b/arch/arm/mach-omap2/board-n8x0.c
3434 index 827d1500..2885dc6 100644
3435 --- a/arch/arm/mach-omap2/board-n8x0.c
3436 +++ b/arch/arm/mach-omap2/board-n8x0.c
3437 @@ -627,7 +627,7 @@ static int n8x0_menelaus_late_init(struct device *dev)
3438 }
3439 #endif
3440
3441 -static struct menelaus_platform_data n8x0_menelaus_platform_data __initdata = {
3442 +static struct menelaus_platform_data n8x0_menelaus_platform_data __initconst = {
3443 .late_init = n8x0_menelaus_late_init,
3444 };
3445
3446 diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c
3447 index 579697a..1d5a3b2 100644
3448 --- a/arch/arm/mach-omap2/gpmc.c
3449 +++ b/arch/arm/mach-omap2/gpmc.c
3450 @@ -148,7 +148,6 @@ struct omap3_gpmc_regs {
3451 };
3452
3453 static struct gpmc_client_irq gpmc_client_irq[GPMC_NR_IRQ];
3454 -static struct irq_chip gpmc_irq_chip;
3455 static int gpmc_irq_start;
3456
3457 static struct resource gpmc_mem_root;
3458 @@ -716,6 +715,18 @@ static void gpmc_irq_noop(struct irq_data *data) { }
3459
3460 static unsigned int gpmc_irq_noop_ret(struct irq_data *data) { return 0; }
3461
3462 +static struct irq_chip gpmc_irq_chip = {
3463 + .name = "gpmc",
3464 + .irq_startup = gpmc_irq_noop_ret,
3465 + .irq_enable = gpmc_irq_enable,
3466 + .irq_disable = gpmc_irq_disable,
3467 + .irq_shutdown = gpmc_irq_noop,
3468 + .irq_ack = gpmc_irq_noop,
3469 + .irq_mask = gpmc_irq_noop,
3470 + .irq_unmask = gpmc_irq_noop,
3471 +
3472 +};
3473 +
3474 static int gpmc_setup_irq(void)
3475 {
3476 int i;
3477 @@ -730,15 +741,6 @@ static int gpmc_setup_irq(void)
3478 return gpmc_irq_start;
3479 }
3480
3481 - gpmc_irq_chip.name = "gpmc";
3482 - gpmc_irq_chip.irq_startup = gpmc_irq_noop_ret;
3483 - gpmc_irq_chip.irq_enable = gpmc_irq_enable;
3484 - gpmc_irq_chip.irq_disable = gpmc_irq_disable;
3485 - gpmc_irq_chip.irq_shutdown = gpmc_irq_noop;
3486 - gpmc_irq_chip.irq_ack = gpmc_irq_noop;
3487 - gpmc_irq_chip.irq_mask = gpmc_irq_noop;
3488 - gpmc_irq_chip.irq_unmask = gpmc_irq_noop;
3489 -
3490 gpmc_client_irq[0].bitmask = GPMC_IRQ_FIFOEVENTENABLE;
3491 gpmc_client_irq[1].bitmask = GPMC_IRQ_COUNT_EVENT;
3492
3493 diff --git a/arch/arm/mach-omap2/omap-mpuss-lowpower.c b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3494 index f991016..145ebeb 100644
3495 --- a/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3496 +++ b/arch/arm/mach-omap2/omap-mpuss-lowpower.c
3497 @@ -84,7 +84,7 @@ struct cpu_pm_ops {
3498 int (*finish_suspend)(unsigned long cpu_state);
3499 void (*resume)(void);
3500 void (*scu_prepare)(unsigned int cpu_id, unsigned int cpu_state);
3501 -};
3502 +} __no_const;
3503
3504 static DEFINE_PER_CPU(struct omap4_cpu_pm_info, omap4_pm_info);
3505 static struct powerdomain *mpuss_pd;
3506 @@ -102,7 +102,7 @@ static void dummy_cpu_resume(void)
3507 static void dummy_scu_prepare(unsigned int cpu_id, unsigned int cpu_state)
3508 {}
3509
3510 -struct cpu_pm_ops omap_pm_ops = {
3511 +static struct cpu_pm_ops omap_pm_ops __read_only = {
3512 .finish_suspend = default_finish_suspend,
3513 .resume = dummy_cpu_resume,
3514 .scu_prepare = dummy_scu_prepare,
3515 diff --git a/arch/arm/mach-omap2/omap-wakeupgen.c b/arch/arm/mach-omap2/omap-wakeupgen.c
3516 index 813c615..ce467c6 100644
3517 --- a/arch/arm/mach-omap2/omap-wakeupgen.c
3518 +++ b/arch/arm/mach-omap2/omap-wakeupgen.c
3519 @@ -339,7 +339,7 @@ static int irq_cpu_hotplug_notify(struct notifier_block *self,
3520 return NOTIFY_OK;
3521 }
3522
3523 -static struct notifier_block __refdata irq_hotplug_notifier = {
3524 +static struct notifier_block irq_hotplug_notifier = {
3525 .notifier_call = irq_cpu_hotplug_notify,
3526 };
3527
3528 diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
3529 index 53f0735..5b54eb6 100644
3530 --- a/arch/arm/mach-omap2/omap_device.c
3531 +++ b/arch/arm/mach-omap2/omap_device.c
3532 @@ -504,7 +504,7 @@ void omap_device_delete(struct omap_device *od)
3533 struct platform_device __init *omap_device_build(const char *pdev_name,
3534 int pdev_id,
3535 struct omap_hwmod *oh,
3536 - void *pdata, int pdata_len)
3537 + const void *pdata, int pdata_len)
3538 {
3539 struct omap_hwmod *ohs[] = { oh };
3540
3541 @@ -532,7 +532,7 @@ struct platform_device __init *omap_device_build(const char *pdev_name,
3542 struct platform_device __init *omap_device_build_ss(const char *pdev_name,
3543 int pdev_id,
3544 struct omap_hwmod **ohs,
3545 - int oh_cnt, void *pdata,
3546 + int oh_cnt, const void *pdata,
3547 int pdata_len)
3548 {
3549 int ret = -ENOMEM;
3550 diff --git a/arch/arm/mach-omap2/omap_device.h b/arch/arm/mach-omap2/omap_device.h
3551 index 17ca1ae..beba869 100644
3552 --- a/arch/arm/mach-omap2/omap_device.h
3553 +++ b/arch/arm/mach-omap2/omap_device.h
3554 @@ -71,12 +71,12 @@ int omap_device_idle(struct platform_device *pdev);
3555 /* Core code interface */
3556
3557 struct platform_device *omap_device_build(const char *pdev_name, int pdev_id,
3558 - struct omap_hwmod *oh, void *pdata,
3559 + struct omap_hwmod *oh, const void *pdata,
3560 int pdata_len);
3561
3562 struct platform_device *omap_device_build_ss(const char *pdev_name, int pdev_id,
3563 struct omap_hwmod **oh, int oh_cnt,
3564 - void *pdata, int pdata_len);
3565 + const void *pdata, int pdata_len);
3566
3567 struct omap_device *omap_device_alloc(struct platform_device *pdev,
3568 struct omap_hwmod **ohs, int oh_cnt);
3569 diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
3570 index 832adb1..49b62c4 100644
3571 --- a/arch/arm/mach-omap2/omap_hwmod.c
3572 +++ b/arch/arm/mach-omap2/omap_hwmod.c
3573 @@ -194,10 +194,10 @@ struct omap_hwmod_soc_ops {
3574 int (*init_clkdm)(struct omap_hwmod *oh);
3575 void (*update_context_lost)(struct omap_hwmod *oh);
3576 int (*get_context_lost)(struct omap_hwmod *oh);
3577 -};
3578 +} __no_const;
3579
3580 /* soc_ops: adapts the omap_hwmod code to the currently-booted SoC */
3581 -static struct omap_hwmod_soc_ops soc_ops;
3582 +static struct omap_hwmod_soc_ops soc_ops __read_only;
3583
3584 /* omap_hwmod_list contains all registered struct omap_hwmods */
3585 static LIST_HEAD(omap_hwmod_list);
3586 diff --git a/arch/arm/mach-omap2/wd_timer.c b/arch/arm/mach-omap2/wd_timer.c
3587 index d15c7bb..b2d1f0c 100644
3588 --- a/arch/arm/mach-omap2/wd_timer.c
3589 +++ b/arch/arm/mach-omap2/wd_timer.c
3590 @@ -110,7 +110,9 @@ static int __init omap_init_wdt(void)
3591 struct omap_hwmod *oh;
3592 char *oh_name = "wd_timer2";
3593 char *dev_name = "omap_wdt";
3594 - struct omap_wd_timer_platform_data pdata;
3595 + static struct omap_wd_timer_platform_data pdata = {
3596 + .read_reset_sources = prm_read_reset_sources
3597 + };
3598
3599 if (!cpu_class_is_omap2() || of_have_populated_dt())
3600 return 0;
3601 @@ -121,8 +123,6 @@ static int __init omap_init_wdt(void)
3602 return -EINVAL;
3603 }
3604
3605 - pdata.read_reset_sources = prm_read_reset_sources;
3606 -
3607 pdev = omap_device_build(dev_name, id, oh, &pdata,
3608 sizeof(struct omap_wd_timer_platform_data));
3609 WARN(IS_ERR(pdev), "Can't build omap_device for %s:%s.\n",
3610 diff --git a/arch/arm/mach-tegra/cpuidle-tegra20.c b/arch/arm/mach-tegra/cpuidle-tegra20.c
3611 index b82dcae..44ee5b6 100644
3612 --- a/arch/arm/mach-tegra/cpuidle-tegra20.c
3613 +++ b/arch/arm/mach-tegra/cpuidle-tegra20.c
3614 @@ -180,7 +180,7 @@ static int tegra20_idle_lp2_coupled(struct cpuidle_device *dev,
3615 bool entered_lp2 = false;
3616
3617 if (tegra_pending_sgi())
3618 - ACCESS_ONCE(abort_flag) = true;
3619 + ACCESS_ONCE_RW(abort_flag) = true;
3620
3621 cpuidle_coupled_parallel_barrier(dev, &abort_barrier);
3622
3623 diff --git a/arch/arm/mach-ux500/setup.h b/arch/arm/mach-ux500/setup.h
3624 index 656324a..0beba28 100644
3625 --- a/arch/arm/mach-ux500/setup.h
3626 +++ b/arch/arm/mach-ux500/setup.h
3627 @@ -40,13 +40,6 @@ extern void ux500_timer_init(void);
3628 .type = MT_DEVICE, \
3629 }
3630
3631 -#define __MEM_DEV_DESC(x, sz) { \
3632 - .virtual = IO_ADDRESS(x), \
3633 - .pfn = __phys_to_pfn(x), \
3634 - .length = sz, \
3635 - .type = MT_MEMORY, \
3636 -}
3637 -
3638 extern struct smp_operations ux500_smp_ops;
3639 extern void ux500_cpu_die(unsigned int cpu);
3640
3641 diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig
3642 index cd2c88e..4dd9b67 100644
3643 --- a/arch/arm/mm/Kconfig
3644 +++ b/arch/arm/mm/Kconfig
3645 @@ -446,7 +446,7 @@ config CPU_32v5
3646
3647 config CPU_32v6
3648 bool
3649 - select CPU_USE_DOMAINS if CPU_V6 && MMU
3650 + select CPU_USE_DOMAINS if CPU_V6 && MMU && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3651 select TLS_REG_EMUL if !CPU_32v6K && !MMU
3652
3653 config CPU_32v6K
3654 @@ -601,6 +601,7 @@ config CPU_CP15_MPU
3655
3656 config CPU_USE_DOMAINS
3657 bool
3658 + depends on !ARM_LPAE && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
3659 help
3660 This option enables or disables the use of domain switching
3661 via the set_fs() function.
3662 @@ -800,6 +801,7 @@ config NEED_KUSER_HELPERS
3663 config KUSER_HELPERS
3664 bool "Enable kuser helpers in vector page" if !NEED_KUSER_HELPERS
3665 default y
3666 + depends on !(CPU_V6 || CPU_V6K || CPU_V7) || GRKERNSEC_OLD_ARM_USERLAND
3667 help
3668 Warning: disabling this option may break user programs.
3669
3670 @@ -812,7 +814,7 @@ config KUSER_HELPERS
3671 See Documentation/arm/kernel_user_helpers.txt for details.
3672
3673 However, the fixed address nature of these helpers can be used
3674 - by ROP (return orientated programming) authors when creating
3675 + by ROP (Return Oriented Programming) authors when creating
3676 exploits.
3677
3678 If all of the binaries and libraries which run on your platform
3679 diff --git a/arch/arm/mm/alignment.c b/arch/arm/mm/alignment.c
3680 index 6f4585b..7b6f52b 100644
3681 --- a/arch/arm/mm/alignment.c
3682 +++ b/arch/arm/mm/alignment.c
3683 @@ -211,10 +211,12 @@ union offset_union {
3684 #define __get16_unaligned_check(ins,val,addr) \
3685 do { \
3686 unsigned int err = 0, v, a = addr; \
3687 + pax_open_userland(); \
3688 __get8_unaligned_check(ins,v,a,err); \
3689 val = v << ((BE) ? 8 : 0); \
3690 __get8_unaligned_check(ins,v,a,err); \
3691 val |= v << ((BE) ? 0 : 8); \
3692 + pax_close_userland(); \
3693 if (err) \
3694 goto fault; \
3695 } while (0)
3696 @@ -228,6 +230,7 @@ union offset_union {
3697 #define __get32_unaligned_check(ins,val,addr) \
3698 do { \
3699 unsigned int err = 0, v, a = addr; \
3700 + pax_open_userland(); \
3701 __get8_unaligned_check(ins,v,a,err); \
3702 val = v << ((BE) ? 24 : 0); \
3703 __get8_unaligned_check(ins,v,a,err); \
3704 @@ -236,6 +239,7 @@ union offset_union {
3705 val |= v << ((BE) ? 8 : 16); \
3706 __get8_unaligned_check(ins,v,a,err); \
3707 val |= v << ((BE) ? 0 : 24); \
3708 + pax_close_userland(); \
3709 if (err) \
3710 goto fault; \
3711 } while (0)
3712 @@ -249,6 +253,7 @@ union offset_union {
3713 #define __put16_unaligned_check(ins,val,addr) \
3714 do { \
3715 unsigned int err = 0, v = val, a = addr; \
3716 + pax_open_userland(); \
3717 __asm__( FIRST_BYTE_16 \
3718 ARM( "1: "ins" %1, [%2], #1\n" ) \
3719 THUMB( "1: "ins" %1, [%2]\n" ) \
3720 @@ -268,6 +273,7 @@ union offset_union {
3721 " .popsection\n" \
3722 : "=r" (err), "=&r" (v), "=&r" (a) \
3723 : "0" (err), "1" (v), "2" (a)); \
3724 + pax_close_userland(); \
3725 if (err) \
3726 goto fault; \
3727 } while (0)
3728 @@ -281,6 +287,7 @@ union offset_union {
3729 #define __put32_unaligned_check(ins,val,addr) \
3730 do { \
3731 unsigned int err = 0, v = val, a = addr; \
3732 + pax_open_userland(); \
3733 __asm__( FIRST_BYTE_32 \
3734 ARM( "1: "ins" %1, [%2], #1\n" ) \
3735 THUMB( "1: "ins" %1, [%2]\n" ) \
3736 @@ -310,6 +317,7 @@ union offset_union {
3737 " .popsection\n" \
3738 : "=r" (err), "=&r" (v), "=&r" (a) \
3739 : "0" (err), "1" (v), "2" (a)); \
3740 + pax_close_userland(); \
3741 if (err) \
3742 goto fault; \
3743 } while (0)
3744 diff --git a/arch/arm/mm/cache-l2x0.c b/arch/arm/mm/cache-l2x0.c
3745 index 447da6f..77a5057 100644
3746 --- a/arch/arm/mm/cache-l2x0.c
3747 +++ b/arch/arm/mm/cache-l2x0.c
3748 @@ -45,7 +45,7 @@ struct l2x0_of_data {
3749 void (*setup)(const struct device_node *, u32 *, u32 *);
3750 void (*save)(void);
3751 struct outer_cache_fns outer_cache;
3752 -};
3753 +} __do_const;
3754
3755 static bool of_init = false;
3756
3757 diff --git a/arch/arm/mm/context.c b/arch/arm/mm/context.c
3758 index 84e6f77..0b52f31 100644
3759 --- a/arch/arm/mm/context.c
3760 +++ b/arch/arm/mm/context.c
3761 @@ -43,7 +43,7 @@
3762 #define NUM_USER_ASIDS ASID_FIRST_VERSION
3763
3764 static DEFINE_RAW_SPINLOCK(cpu_asid_lock);
3765 -static atomic64_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3766 +static atomic64_unchecked_t asid_generation = ATOMIC64_INIT(ASID_FIRST_VERSION);
3767 static DECLARE_BITMAP(asid_map, NUM_USER_ASIDS);
3768
3769 static DEFINE_PER_CPU(atomic64_t, active_asids);
3770 @@ -180,7 +180,7 @@ static int is_reserved_asid(u64 asid)
3771 static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3772 {
3773 u64 asid = atomic64_read(&mm->context.id);
3774 - u64 generation = atomic64_read(&asid_generation);
3775 + u64 generation = atomic64_read_unchecked(&asid_generation);
3776
3777 if (asid != 0 && is_reserved_asid(asid)) {
3778 /*
3779 @@ -198,7 +198,7 @@ static u64 new_context(struct mm_struct *mm, unsigned int cpu)
3780 */
3781 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3782 if (asid == NUM_USER_ASIDS) {
3783 - generation = atomic64_add_return(ASID_FIRST_VERSION,
3784 + generation = atomic64_add_return_unchecked(ASID_FIRST_VERSION,
3785 &asid_generation);
3786 flush_context(cpu);
3787 asid = find_next_zero_bit(asid_map, NUM_USER_ASIDS, 1);
3788 @@ -227,14 +227,14 @@ void check_and_switch_context(struct mm_struct *mm, struct task_struct *tsk)
3789 cpu_set_reserved_ttbr0();
3790
3791 asid = atomic64_read(&mm->context.id);
3792 - if (!((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS)
3793 + if (!((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS)
3794 && atomic64_xchg(&per_cpu(active_asids, cpu), asid))
3795 goto switch_mm_fastpath;
3796
3797 raw_spin_lock_irqsave(&cpu_asid_lock, flags);
3798 /* Check that our ASID belongs to the current generation. */
3799 asid = atomic64_read(&mm->context.id);
3800 - if ((asid ^ atomic64_read(&asid_generation)) >> ASID_BITS) {
3801 + if ((asid ^ atomic64_read_unchecked(&asid_generation)) >> ASID_BITS) {
3802 asid = new_context(mm, cpu);
3803 atomic64_set(&mm->context.id, asid);
3804 }
3805 diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c
3806 index eb8830a..5360ce7 100644
3807 --- a/arch/arm/mm/fault.c
3808 +++ b/arch/arm/mm/fault.c
3809 @@ -25,6 +25,7 @@
3810 #include <asm/system_misc.h>
3811 #include <asm/system_info.h>
3812 #include <asm/tlbflush.h>
3813 +#include <asm/sections.h>
3814
3815 #include "fault.h"
3816
3817 @@ -138,6 +139,31 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
3818 if (fixup_exception(regs))
3819 return;
3820
3821 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3822 + if (addr < TASK_SIZE) {
3823 + if (current->signal->curr_ip)
3824 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3825 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3826 + else
3827 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3828 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3829 + }
3830 +#endif
3831 +
3832 +#ifdef CONFIG_PAX_KERNEXEC
3833 + if ((fsr & FSR_WRITE) &&
3834 + (((unsigned long)_stext <= addr && addr < init_mm.end_code) ||
3835 + (MODULES_VADDR <= addr && addr < MODULES_END)))
3836 + {
3837 + if (current->signal->curr_ip)
3838 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3839 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3840 + else
3841 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
3842 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
3843 + }
3844 +#endif
3845 +
3846 /*
3847 * No handler, we'll have to terminate things with extreme prejudice.
3848 */
3849 @@ -174,6 +200,13 @@ __do_user_fault(struct task_struct *tsk, unsigned long addr,
3850 }
3851 #endif
3852
3853 +#ifdef CONFIG_PAX_PAGEEXEC
3854 + if (fsr & FSR_LNX_PF) {
3855 + pax_report_fault(regs, (void *)regs->ARM_pc, (void *)regs->ARM_sp);
3856 + do_group_exit(SIGKILL);
3857 + }
3858 +#endif
3859 +
3860 tsk->thread.address = addr;
3861 tsk->thread.error_code = fsr;
3862 tsk->thread.trap_no = 14;
3863 @@ -401,6 +434,33 @@ do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3864 }
3865 #endif /* CONFIG_MMU */
3866
3867 +#ifdef CONFIG_PAX_PAGEEXEC
3868 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
3869 +{
3870 + long i;
3871 +
3872 + printk(KERN_ERR "PAX: bytes at PC: ");
3873 + for (i = 0; i < 20; i++) {
3874 + unsigned char c;
3875 + if (get_user(c, (__force unsigned char __user *)pc+i))
3876 + printk(KERN_CONT "?? ");
3877 + else
3878 + printk(KERN_CONT "%02x ", c);
3879 + }
3880 + printk("\n");
3881 +
3882 + printk(KERN_ERR "PAX: bytes at SP-4: ");
3883 + for (i = -1; i < 20; i++) {
3884 + unsigned long c;
3885 + if (get_user(c, (__force unsigned long __user *)sp+i))
3886 + printk(KERN_CONT "???????? ");
3887 + else
3888 + printk(KERN_CONT "%08lx ", c);
3889 + }
3890 + printk("\n");
3891 +}
3892 +#endif
3893 +
3894 /*
3895 * First Level Translation Fault Handler
3896 *
3897 @@ -548,9 +608,22 @@ do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
3898 const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
3899 struct siginfo info;
3900
3901 +#ifdef CONFIG_PAX_MEMORY_UDEREF
3902 + if (addr < TASK_SIZE && is_domain_fault(fsr)) {
3903 + if (current->signal->curr_ip)
3904 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3905 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3906 + else
3907 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to access userland memory at %08lx\n", current->comm, task_pid_nr(current),
3908 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()), addr);
3909 + goto die;
3910 + }
3911 +#endif
3912 +
3913 if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
3914 return;
3915
3916 +die:
3917 printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
3918 inf->name, fsr, addr);
3919
3920 @@ -574,15 +647,98 @@ hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *
3921 ifsr_info[nr].name = name;
3922 }
3923
3924 +asmlinkage int sys_sigreturn(struct pt_regs *regs);
3925 +asmlinkage int sys_rt_sigreturn(struct pt_regs *regs);
3926 +
3927 asmlinkage void __exception
3928 do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
3929 {
3930 const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
3931 struct siginfo info;
3932 + unsigned long pc = instruction_pointer(regs);
3933 +
3934 + if (user_mode(regs)) {
3935 + unsigned long sigpage = current->mm->context.sigpage;
3936 +
3937 + if (sigpage <= pc && pc < sigpage + 7*4) {
3938 + if (pc < sigpage + 3*4)
3939 + sys_sigreturn(regs);
3940 + else
3941 + sys_rt_sigreturn(regs);
3942 + return;
3943 + }
3944 + if (pc == 0xffff0f60UL) {
3945 + /*
3946 + * PaX: __kuser_cmpxchg64 emulation
3947 + */
3948 + // TODO
3949 + //regs->ARM_pc = regs->ARM_lr;
3950 + //return;
3951 + }
3952 + if (pc == 0xffff0fa0UL) {
3953 + /*
3954 + * PaX: __kuser_memory_barrier emulation
3955 + */
3956 + // dmb(); implied by the exception
3957 + regs->ARM_pc = regs->ARM_lr;
3958 + return;
3959 + }
3960 + if (pc == 0xffff0fc0UL) {
3961 + /*
3962 + * PaX: __kuser_cmpxchg emulation
3963 + */
3964 + // TODO
3965 + //long new;
3966 + //int op;
3967 +
3968 + //op = FUTEX_OP_SET << 28;
3969 + //new = futex_atomic_op_inuser(op, regs->ARM_r2);
3970 + //regs->ARM_r0 = old != new;
3971 + //regs->ARM_pc = regs->ARM_lr;
3972 + //return;
3973 + }
3974 + if (pc == 0xffff0fe0UL) {
3975 + /*
3976 + * PaX: __kuser_get_tls emulation
3977 + */
3978 + regs->ARM_r0 = current_thread_info()->tp_value[0];
3979 + regs->ARM_pc = regs->ARM_lr;
3980 + return;
3981 + }
3982 + }
3983 +
3984 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
3985 + else if (is_domain_fault(ifsr) || is_xn_fault(ifsr)) {
3986 + if (current->signal->curr_ip)
3987 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", &current->signal->curr_ip, current->comm, task_pid_nr(current),
3988 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3989 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3990 + else
3991 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to execute %s memory at %08lx\n", current->comm, task_pid_nr(current),
3992 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()),
3993 + pc >= TASK_SIZE ? "non-executable kernel" : "userland", pc);
3994 + goto die;
3995 + }
3996 +#endif
3997 +
3998 +#ifdef CONFIG_PAX_REFCOUNT
3999 + if (fsr_fs(ifsr) == FAULT_CODE_DEBUG) {
4000 + unsigned int bkpt;
4001 +
4002 + if (!probe_kernel_address(pc, bkpt) && cpu_to_le32(bkpt) == 0xe12f1073) {
4003 + current->thread.error_code = ifsr;
4004 + current->thread.trap_no = 0;
4005 + pax_report_refcount_overflow(regs);
4006 + fixup_exception(regs);
4007 + return;
4008 + }
4009 + }
4010 +#endif
4011
4012 if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
4013 return;
4014
4015 +die:
4016 printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
4017 inf->name, ifsr, addr);
4018
4019 diff --git a/arch/arm/mm/fault.h b/arch/arm/mm/fault.h
4020 index cf08bdf..772656c 100644
4021 --- a/arch/arm/mm/fault.h
4022 +++ b/arch/arm/mm/fault.h
4023 @@ -3,6 +3,7 @@
4024
4025 /*
4026 * Fault status register encodings. We steal bit 31 for our own purposes.
4027 + * Set when the FSR value is from an instruction fault.
4028 */
4029 #define FSR_LNX_PF (1 << 31)
4030 #define FSR_WRITE (1 << 11)
4031 @@ -22,6 +23,17 @@ static inline int fsr_fs(unsigned int fsr)
4032 }
4033 #endif
4034
4035 +/* valid for LPAE and !LPAE */
4036 +static inline int is_xn_fault(unsigned int fsr)
4037 +{
4038 + return ((fsr_fs(fsr) & 0x3c) == 0xc);
4039 +}
4040 +
4041 +static inline int is_domain_fault(unsigned int fsr)
4042 +{
4043 + return ((fsr_fs(fsr) & 0xD) == 0x9);
4044 +}
4045 +
4046 void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
4047 unsigned long search_exception_table(unsigned long addr);
4048
4049 diff --git a/arch/arm/mm/init.c b/arch/arm/mm/init.c
4050 index 18ec4c5..479bb6a 100644
4051 --- a/arch/arm/mm/init.c
4052 +++ b/arch/arm/mm/init.c
4053 @@ -30,6 +30,8 @@
4054 #include <asm/setup.h>
4055 #include <asm/tlb.h>
4056 #include <asm/fixmap.h>
4057 +#include <asm/system_info.h>
4058 +#include <asm/cp15.h>
4059
4060 #include <asm/mach/arch.h>
4061 #include <asm/mach/map.h>
4062 @@ -684,7 +686,46 @@ void free_initmem(void)
4063 {
4064 #ifdef CONFIG_HAVE_TCM
4065 extern char __tcm_start, __tcm_end;
4066 +#endif
4067
4068 +#ifdef CONFIG_PAX_KERNEXEC
4069 + unsigned long addr;
4070 + pgd_t *pgd;
4071 + pud_t *pud;
4072 + pmd_t *pmd;
4073 + int cpu_arch = cpu_architecture();
4074 + unsigned int cr = get_cr();
4075 +
4076 + if (cpu_arch >= CPU_ARCH_ARMv6 && (cr & CR_XP)) {
4077 + /* make pages tables, etc before .text NX */
4078 + for (addr = PAGE_OFFSET; addr < (unsigned long)_stext; addr += SECTION_SIZE) {
4079 + pgd = pgd_offset_k(addr);
4080 + pud = pud_offset(pgd, addr);
4081 + pmd = pmd_offset(pud, addr);
4082 + __section_update(pmd, addr, PMD_SECT_XN);
4083 + }
4084 + /* make init NX */
4085 + for (addr = (unsigned long)__init_begin; addr < (unsigned long)_sdata; addr += SECTION_SIZE) {
4086 + pgd = pgd_offset_k(addr);
4087 + pud = pud_offset(pgd, addr);
4088 + pmd = pmd_offset(pud, addr);
4089 + __section_update(pmd, addr, PMD_SECT_XN);
4090 + }
4091 + /* make kernel code/rodata RX */
4092 + for (addr = (unsigned long)_stext; addr < (unsigned long)__init_begin; addr += SECTION_SIZE) {
4093 + pgd = pgd_offset_k(addr);
4094 + pud = pud_offset(pgd, addr);
4095 + pmd = pmd_offset(pud, addr);
4096 +#ifdef CONFIG_ARM_LPAE
4097 + __section_update(pmd, addr, PMD_SECT_RDONLY);
4098 +#else
4099 + __section_update(pmd, addr, PMD_SECT_APX|PMD_SECT_AP_WRITE);
4100 +#endif
4101 + }
4102 + }
4103 +#endif
4104 +
4105 +#ifdef CONFIG_HAVE_TCM
4106 poison_init_mem(&__tcm_start, &__tcm_end - &__tcm_start);
4107 free_reserved_area(&__tcm_start, &__tcm_end, -1, "TCM link");
4108 #endif
4109 diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c
4110 index f123d6e..04bf569 100644
4111 --- a/arch/arm/mm/ioremap.c
4112 +++ b/arch/arm/mm/ioremap.c
4113 @@ -392,9 +392,9 @@ __arm_ioremap_exec(phys_addr_t phys_addr, size_t size, bool cached)
4114 unsigned int mtype;
4115
4116 if (cached)
4117 - mtype = MT_MEMORY;
4118 + mtype = MT_MEMORY_RX;
4119 else
4120 - mtype = MT_MEMORY_NONCACHED;
4121 + mtype = MT_MEMORY_NONCACHED_RX;
4122
4123 return __arm_ioremap_caller(phys_addr, size, mtype,
4124 __builtin_return_address(0));
4125 diff --git a/arch/arm/mm/mmap.c b/arch/arm/mm/mmap.c
4126 index 304661d..53a6b19 100644
4127 --- a/arch/arm/mm/mmap.c
4128 +++ b/arch/arm/mm/mmap.c
4129 @@ -59,6 +59,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4130 struct vm_area_struct *vma;
4131 int do_align = 0;
4132 int aliasing = cache_is_vipt_aliasing();
4133 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4134 struct vm_unmapped_area_info info;
4135
4136 /*
4137 @@ -81,6 +82,10 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4138 if (len > TASK_SIZE)
4139 return -ENOMEM;
4140
4141 +#ifdef CONFIG_PAX_RANDMMAP
4142 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4143 +#endif
4144 +
4145 if (addr) {
4146 if (do_align)
4147 addr = COLOUR_ALIGN(addr, pgoff);
4148 @@ -88,8 +93,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4149 addr = PAGE_ALIGN(addr);
4150
4151 vma = find_vma(mm, addr);
4152 - if (TASK_SIZE - len >= addr &&
4153 - (!vma || addr + len <= vma->vm_start))
4154 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4155 return addr;
4156 }
4157
4158 @@ -99,6 +103,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
4159 info.high_limit = TASK_SIZE;
4160 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4161 info.align_offset = pgoff << PAGE_SHIFT;
4162 + info.threadstack_offset = offset;
4163 return vm_unmapped_area(&info);
4164 }
4165
4166 @@ -112,6 +117,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4167 unsigned long addr = addr0;
4168 int do_align = 0;
4169 int aliasing = cache_is_vipt_aliasing();
4170 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
4171 struct vm_unmapped_area_info info;
4172
4173 /*
4174 @@ -132,6 +138,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4175 return addr;
4176 }
4177
4178 +#ifdef CONFIG_PAX_RANDMMAP
4179 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4180 +#endif
4181 +
4182 /* requesting a specific address */
4183 if (addr) {
4184 if (do_align)
4185 @@ -139,8 +149,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4186 else
4187 addr = PAGE_ALIGN(addr);
4188 vma = find_vma(mm, addr);
4189 - if (TASK_SIZE - len >= addr &&
4190 - (!vma || addr + len <= vma->vm_start))
4191 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4192 return addr;
4193 }
4194
4195 @@ -150,6 +159,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
4196 info.high_limit = mm->mmap_base;
4197 info.align_mask = do_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
4198 info.align_offset = pgoff << PAGE_SHIFT;
4199 + info.threadstack_offset = offset;
4200 addr = vm_unmapped_area(&info);
4201
4202 /*
4203 @@ -173,6 +183,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4204 {
4205 unsigned long random_factor = 0UL;
4206
4207 +#ifdef CONFIG_PAX_RANDMMAP
4208 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
4209 +#endif
4210 +
4211 /* 8 bits of randomness in 20 address space bits */
4212 if ((current->flags & PF_RANDOMIZE) &&
4213 !(current->personality & ADDR_NO_RANDOMIZE))
4214 @@ -180,9 +194,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
4215
4216 if (mmap_is_legacy()) {
4217 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
4218 +
4219 +#ifdef CONFIG_PAX_RANDMMAP
4220 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4221 + mm->mmap_base += mm->delta_mmap;
4222 +#endif
4223 +
4224 mm->get_unmapped_area = arch_get_unmapped_area;
4225 } else {
4226 mm->mmap_base = mmap_base(random_factor);
4227 +
4228 +#ifdef CONFIG_PAX_RANDMMAP
4229 + if (mm->pax_flags & MF_PAX_RANDMMAP)
4230 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
4231 +#endif
4232 +
4233 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
4234 }
4235 }
4236 diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
4237 index b1d17ee..7a6f4d3 100644
4238 --- a/arch/arm/mm/mmu.c
4239 +++ b/arch/arm/mm/mmu.c
4240 @@ -36,6 +36,22 @@
4241 #include "mm.h"
4242 #include "tcm.h"
4243
4244 +#if defined(CONFIG_CPU_USE_DOMAINS) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
4245 +void modify_domain(unsigned int dom, unsigned int type)
4246 +{
4247 + struct thread_info *thread = current_thread_info();
4248 + unsigned int domain = thread->cpu_domain;
4249 + /*
4250 + * DOMAIN_MANAGER might be defined to some other value,
4251 + * use the arch-defined constant
4252 + */
4253 + domain &= ~domain_val(dom, 3);
4254 + thread->cpu_domain = domain | domain_val(dom, type);
4255 + set_domain(thread->cpu_domain);
4256 +}
4257 +EXPORT_SYMBOL(modify_domain);
4258 +#endif
4259 +
4260 /*
4261 * empty_zero_page is a special page that is used for
4262 * zero-initialized data and COW.
4263 @@ -228,10 +244,18 @@ __setup("noalign", noalign_setup);
4264
4265 #endif /* ifdef CONFIG_CPU_CP15 / else */
4266
4267 -#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY|L_PTE_XN
4268 +#define PROT_PTE_DEVICE L_PTE_PRESENT|L_PTE_YOUNG|L_PTE_DIRTY
4269 #define PROT_SECT_DEVICE PMD_TYPE_SECT|PMD_SECT_AP_WRITE
4270
4271 -static struct mem_type mem_types[] = {
4272 +#ifdef CONFIG_PAX_KERNEXEC
4273 +#define L_PTE_KERNEXEC L_PTE_RDONLY
4274 +#define PMD_SECT_KERNEXEC PMD_SECT_RDONLY
4275 +#else
4276 +#define L_PTE_KERNEXEC L_PTE_DIRTY
4277 +#define PMD_SECT_KERNEXEC PMD_SECT_AP_WRITE
4278 +#endif
4279 +
4280 +static struct mem_type mem_types[] __read_only = {
4281 [MT_DEVICE] = { /* Strongly ordered / ARMv6 shared device */
4282 .prot_pte = PROT_PTE_DEVICE | L_PTE_MT_DEV_SHARED |
4283 L_PTE_SHARED,
4284 @@ -260,16 +284,16 @@ static struct mem_type mem_types[] = {
4285 [MT_UNCACHED] = {
4286 .prot_pte = PROT_PTE_DEVICE,
4287 .prot_l1 = PMD_TYPE_TABLE,
4288 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4289 + .prot_sect = PROT_SECT_DEVICE,
4290 .domain = DOMAIN_IO,
4291 },
4292 [MT_CACHECLEAN] = {
4293 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4294 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4295 .domain = DOMAIN_KERNEL,
4296 },
4297 #ifndef CONFIG_ARM_LPAE
4298 [MT_MINICLEAN] = {
4299 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN | PMD_SECT_MINICACHE,
4300 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_MINICACHE | PMD_SECT_RDONLY,
4301 .domain = DOMAIN_KERNEL,
4302 },
4303 #endif
4304 @@ -277,36 +301,54 @@ static struct mem_type mem_types[] = {
4305 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4306 L_PTE_RDONLY,
4307 .prot_l1 = PMD_TYPE_TABLE,
4308 - .domain = DOMAIN_USER,
4309 + .domain = DOMAIN_VECTORS,
4310 },
4311 [MT_HIGH_VECTORS] = {
4312 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4313 L_PTE_USER | L_PTE_RDONLY,
4314 .prot_l1 = PMD_TYPE_TABLE,
4315 - .domain = DOMAIN_USER,
4316 + .domain = DOMAIN_VECTORS,
4317 },
4318 - [MT_MEMORY] = {
4319 + [MT_MEMORY_RWX] = {
4320 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4321 .prot_l1 = PMD_TYPE_TABLE,
4322 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4323 .domain = DOMAIN_KERNEL,
4324 },
4325 + [MT_MEMORY_RW] = {
4326 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4327 + .prot_l1 = PMD_TYPE_TABLE,
4328 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4329 + .domain = DOMAIN_KERNEL,
4330 + },
4331 + [MT_MEMORY_RX] = {
4332 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC,
4333 + .prot_l1 = PMD_TYPE_TABLE,
4334 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4335 + .domain = DOMAIN_KERNEL,
4336 + },
4337 [MT_ROM] = {
4338 - .prot_sect = PMD_TYPE_SECT,
4339 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4340 .domain = DOMAIN_KERNEL,
4341 },
4342 - [MT_MEMORY_NONCACHED] = {
4343 + [MT_MEMORY_NONCACHED_RW] = {
4344 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4345 L_PTE_MT_BUFFERABLE,
4346 .prot_l1 = PMD_TYPE_TABLE,
4347 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE,
4348 .domain = DOMAIN_KERNEL,
4349 },
4350 + [MT_MEMORY_NONCACHED_RX] = {
4351 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_KERNEXEC |
4352 + L_PTE_MT_BUFFERABLE,
4353 + .prot_l1 = PMD_TYPE_TABLE,
4354 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_KERNEXEC,
4355 + .domain = DOMAIN_KERNEL,
4356 + },
4357 [MT_MEMORY_DTCM] = {
4358 - .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4359 - L_PTE_XN,
4360 + .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY,
4361 .prot_l1 = PMD_TYPE_TABLE,
4362 - .prot_sect = PMD_TYPE_SECT | PMD_SECT_XN,
4363 + .prot_sect = PMD_TYPE_SECT | PMD_SECT_RDONLY,
4364 .domain = DOMAIN_KERNEL,
4365 },
4366 [MT_MEMORY_ITCM] = {
4367 @@ -316,10 +358,10 @@ static struct mem_type mem_types[] = {
4368 },
4369 [MT_MEMORY_SO] = {
4370 .prot_pte = L_PTE_PRESENT | L_PTE_YOUNG | L_PTE_DIRTY |
4371 - L_PTE_MT_UNCACHED | L_PTE_XN,
4372 + L_PTE_MT_UNCACHED,
4373 .prot_l1 = PMD_TYPE_TABLE,
4374 .prot_sect = PMD_TYPE_SECT | PMD_SECT_AP_WRITE | PMD_SECT_S |
4375 - PMD_SECT_UNCACHED | PMD_SECT_XN,
4376 + PMD_SECT_UNCACHED,
4377 .domain = DOMAIN_KERNEL,
4378 },
4379 [MT_MEMORY_DMA_READY] = {
4380 @@ -405,9 +447,35 @@ static void __init build_mem_type_table(void)
4381 * to prevent speculative instruction fetches.
4382 */
4383 mem_types[MT_DEVICE].prot_sect |= PMD_SECT_XN;
4384 + mem_types[MT_DEVICE].prot_pte |= L_PTE_XN;
4385 mem_types[MT_DEVICE_NONSHARED].prot_sect |= PMD_SECT_XN;
4386 + mem_types[MT_DEVICE_NONSHARED].prot_pte |= L_PTE_XN;
4387 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_XN;
4388 + mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_XN;
4389 mem_types[MT_DEVICE_WC].prot_sect |= PMD_SECT_XN;
4390 + mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_XN;
4391 +
4392 + /* Mark other regions on ARMv6+ as execute-never */
4393 +
4394 +#ifdef CONFIG_PAX_KERNEXEC
4395 + mem_types[MT_UNCACHED].prot_sect |= PMD_SECT_XN;
4396 + mem_types[MT_UNCACHED].prot_pte |= L_PTE_XN;
4397 + mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_XN;
4398 + mem_types[MT_CACHECLEAN].prot_pte |= L_PTE_XN;
4399 +#ifndef CONFIG_ARM_LPAE
4400 + mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_XN;
4401 + mem_types[MT_MINICLEAN].prot_pte |= L_PTE_XN;
4402 +#endif
4403 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_XN;
4404 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_XN;
4405 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_XN;
4406 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= PMD_SECT_XN;
4407 + mem_types[MT_MEMORY_DTCM].prot_sect |= PMD_SECT_XN;
4408 + mem_types[MT_MEMORY_DTCM].prot_pte |= L_PTE_XN;
4409 +#endif
4410 +
4411 + mem_types[MT_MEMORY_SO].prot_sect |= PMD_SECT_XN;
4412 + mem_types[MT_MEMORY_SO].prot_pte |= L_PTE_XN;
4413 }
4414 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4415 /*
4416 @@ -468,6 +536,9 @@ static void __init build_mem_type_table(void)
4417 * from SVC mode and no access from userspace.
4418 */
4419 mem_types[MT_ROM].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4420 +#ifdef CONFIG_PAX_KERNEXEC
4421 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4422 +#endif
4423 mem_types[MT_MINICLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4424 mem_types[MT_CACHECLEAN].prot_sect |= PMD_SECT_APX|PMD_SECT_AP_WRITE;
4425 #endif
4426 @@ -485,11 +556,17 @@ static void __init build_mem_type_table(void)
4427 mem_types[MT_DEVICE_WC].prot_pte |= L_PTE_SHARED;
4428 mem_types[MT_DEVICE_CACHED].prot_sect |= PMD_SECT_S;
4429 mem_types[MT_DEVICE_CACHED].prot_pte |= L_PTE_SHARED;
4430 - mem_types[MT_MEMORY].prot_sect |= PMD_SECT_S;
4431 - mem_types[MT_MEMORY].prot_pte |= L_PTE_SHARED;
4432 + mem_types[MT_MEMORY_RWX].prot_sect |= PMD_SECT_S;
4433 + mem_types[MT_MEMORY_RWX].prot_pte |= L_PTE_SHARED;
4434 + mem_types[MT_MEMORY_RW].prot_sect |= PMD_SECT_S;
4435 + mem_types[MT_MEMORY_RW].prot_pte |= L_PTE_SHARED;
4436 + mem_types[MT_MEMORY_RX].prot_sect |= PMD_SECT_S;
4437 + mem_types[MT_MEMORY_RX].prot_pte |= L_PTE_SHARED;
4438 mem_types[MT_MEMORY_DMA_READY].prot_pte |= L_PTE_SHARED;
4439 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_S;
4440 - mem_types[MT_MEMORY_NONCACHED].prot_pte |= L_PTE_SHARED;
4441 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_S;
4442 + mem_types[MT_MEMORY_NONCACHED_RW].prot_pte |= L_PTE_SHARED;
4443 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_S;
4444 + mem_types[MT_MEMORY_NONCACHED_RX].prot_pte |= L_PTE_SHARED;
4445 }
4446 }
4447
4448 @@ -500,15 +577,20 @@ static void __init build_mem_type_table(void)
4449 if (cpu_arch >= CPU_ARCH_ARMv6) {
4450 if (cpu_arch >= CPU_ARCH_ARMv7 && (cr & CR_TRE)) {
4451 /* Non-cacheable Normal is XCB = 001 */
4452 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4453 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4454 + PMD_SECT_BUFFERED;
4455 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4456 PMD_SECT_BUFFERED;
4457 } else {
4458 /* For both ARMv6 and non-TEX-remapping ARMv7 */
4459 - mem_types[MT_MEMORY_NONCACHED].prot_sect |=
4460 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |=
4461 + PMD_SECT_TEX(1);
4462 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |=
4463 PMD_SECT_TEX(1);
4464 }
4465 } else {
4466 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= PMD_SECT_BUFFERABLE;
4467 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= PMD_SECT_BUFFERABLE;
4468 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= PMD_SECT_BUFFERABLE;
4469 }
4470
4471 #ifdef CONFIG_ARM_LPAE
4472 @@ -524,6 +606,8 @@ static void __init build_mem_type_table(void)
4473 vecs_pgprot |= PTE_EXT_AF;
4474 #endif
4475
4476 + user_pgprot |= __supported_pte_mask;
4477 +
4478 for (i = 0; i < 16; i++) {
4479 pteval_t v = pgprot_val(protection_map[i]);
4480 protection_map[i] = __pgprot(v | user_pgprot);
4481 @@ -541,10 +625,15 @@ static void __init build_mem_type_table(void)
4482
4483 mem_types[MT_LOW_VECTORS].prot_l1 |= ecc_mask;
4484 mem_types[MT_HIGH_VECTORS].prot_l1 |= ecc_mask;
4485 - mem_types[MT_MEMORY].prot_sect |= ecc_mask | cp->pmd;
4486 - mem_types[MT_MEMORY].prot_pte |= kern_pgprot;
4487 + mem_types[MT_MEMORY_RWX].prot_sect |= ecc_mask | cp->pmd;
4488 + mem_types[MT_MEMORY_RWX].prot_pte |= kern_pgprot;
4489 + mem_types[MT_MEMORY_RW].prot_sect |= ecc_mask | cp->pmd;
4490 + mem_types[MT_MEMORY_RW].prot_pte |= kern_pgprot;
4491 + mem_types[MT_MEMORY_RX].prot_sect |= ecc_mask | cp->pmd;
4492 + mem_types[MT_MEMORY_RX].prot_pte |= kern_pgprot;
4493 mem_types[MT_MEMORY_DMA_READY].prot_pte |= kern_pgprot;
4494 - mem_types[MT_MEMORY_NONCACHED].prot_sect |= ecc_mask;
4495 + mem_types[MT_MEMORY_NONCACHED_RW].prot_sect |= ecc_mask;
4496 + mem_types[MT_MEMORY_NONCACHED_RX].prot_sect |= ecc_mask;
4497 mem_types[MT_ROM].prot_sect |= cp->pmd;
4498
4499 switch (cp->pmd) {
4500 @@ -1186,18 +1275,15 @@ void __init arm_mm_memblock_reserve(void)
4501 * called function. This means you can't use any function or debugging
4502 * method which may touch any device, otherwise the kernel _will_ crash.
4503 */
4504 +
4505 +static char vectors[PAGE_SIZE * 2] __read_only __aligned(PAGE_SIZE);
4506 +
4507 static void __init devicemaps_init(const struct machine_desc *mdesc)
4508 {
4509 struct map_desc map;
4510 unsigned long addr;
4511 - void *vectors;
4512
4513 - /*
4514 - * Allocate the vector page early.
4515 - */
4516 - vectors = early_alloc(PAGE_SIZE * 2);
4517 -
4518 - early_trap_init(vectors);
4519 + early_trap_init(&vectors);
4520
4521 for (addr = VMALLOC_START; addr; addr += PMD_SIZE)
4522 pmd_clear(pmd_off_k(addr));
4523 @@ -1237,7 +1323,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
4524 * location (0xffff0000). If we aren't using high-vectors, also
4525 * create a mapping at the low-vectors virtual address.
4526 */
4527 - map.pfn = __phys_to_pfn(virt_to_phys(vectors));
4528 + map.pfn = __phys_to_pfn(virt_to_phys(&vectors));
4529 map.virtual = 0xffff0000;
4530 map.length = PAGE_SIZE;
4531 #ifdef CONFIG_KUSER_HELPERS
4532 @@ -1309,8 +1395,39 @@ static void __init map_lowmem(void)
4533 map.pfn = __phys_to_pfn(start);
4534 map.virtual = __phys_to_virt(start);
4535 map.length = end - start;
4536 - map.type = MT_MEMORY;
4537
4538 +#ifdef CONFIG_PAX_KERNEXEC
4539 + if (map.virtual <= (unsigned long)_stext && ((unsigned long)_end < (map.virtual + map.length))) {
4540 + struct map_desc kernel;
4541 + struct map_desc initmap;
4542 +
4543 + /* when freeing initmem we will make this RW */
4544 + initmap.pfn = __phys_to_pfn(__pa(__init_begin));
4545 + initmap.virtual = (unsigned long)__init_begin;
4546 + initmap.length = _sdata - __init_begin;
4547 + initmap.type = MT_MEMORY_RWX;
4548 + create_mapping(&initmap);
4549 +
4550 + /* when freeing initmem we will make this RX */
4551 + kernel.pfn = __phys_to_pfn(__pa(_stext));
4552 + kernel.virtual = (unsigned long)_stext;
4553 + kernel.length = __init_begin - _stext;
4554 + kernel.type = MT_MEMORY_RWX;
4555 + create_mapping(&kernel);
4556 +
4557 + if (map.virtual < (unsigned long)_stext) {
4558 + map.length = (unsigned long)_stext - map.virtual;
4559 + map.type = MT_MEMORY_RWX;
4560 + create_mapping(&map);
4561 + }
4562 +
4563 + map.pfn = __phys_to_pfn(__pa(_sdata));
4564 + map.virtual = (unsigned long)_sdata;
4565 + map.length = end - __pa(_sdata);
4566 + }
4567 +#endif
4568 +
4569 + map.type = MT_MEMORY_RW;
4570 create_mapping(&map);
4571 }
4572 }
4573 diff --git a/arch/arm/plat-omap/sram.c b/arch/arm/plat-omap/sram.c
4574 index a5bc92d..0bb4730 100644
4575 --- a/arch/arm/plat-omap/sram.c
4576 +++ b/arch/arm/plat-omap/sram.c
4577 @@ -93,6 +93,8 @@ void __init omap_map_sram(unsigned long start, unsigned long size,
4578 * Looks like we need to preserve some bootloader code at the
4579 * beginning of SRAM for jumping to flash for reboot to work...
4580 */
4581 + pax_open_kernel();
4582 memset_io(omap_sram_base + omap_sram_skip, 0,
4583 omap_sram_size - omap_sram_skip);
4584 + pax_close_kernel();
4585 }
4586 diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
4587 index ce6d763..cfea917 100644
4588 --- a/arch/arm/plat-samsung/include/plat/dma-ops.h
4589 +++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
4590 @@ -47,7 +47,7 @@ struct samsung_dma_ops {
4591 int (*started)(unsigned ch);
4592 int (*flush)(unsigned ch);
4593 int (*stop)(unsigned ch);
4594 -};
4595 +} __no_const;
4596
4597 extern void *samsung_dmadev_get_ops(void);
4598 extern void *s3c_dma_get_ops(void);
4599 diff --git a/arch/avr32/include/asm/cache.h b/arch/avr32/include/asm/cache.h
4600 index c3a58a1..78fbf54 100644
4601 --- a/arch/avr32/include/asm/cache.h
4602 +++ b/arch/avr32/include/asm/cache.h
4603 @@ -1,8 +1,10 @@
4604 #ifndef __ASM_AVR32_CACHE_H
4605 #define __ASM_AVR32_CACHE_H
4606
4607 +#include <linux/const.h>
4608 +
4609 #define L1_CACHE_SHIFT 5
4610 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4611 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4612
4613 /*
4614 * Memory returned by kmalloc() may be used for DMA, so we must make
4615 diff --git a/arch/avr32/include/asm/elf.h b/arch/avr32/include/asm/elf.h
4616 index d232888..87c8df1 100644
4617 --- a/arch/avr32/include/asm/elf.h
4618 +++ b/arch/avr32/include/asm/elf.h
4619 @@ -84,8 +84,14 @@ typedef struct user_fpu_struct elf_fpregset_t;
4620 the loader. We need to make sure that it is out of the way of the program
4621 that it will "exec", and that there is sufficient room for the brk. */
4622
4623 -#define ELF_ET_DYN_BASE (2 * TASK_SIZE / 3)
4624 +#define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
4625
4626 +#ifdef CONFIG_PAX_ASLR
4627 +#define PAX_ELF_ET_DYN_BASE 0x00001000UL
4628 +
4629 +#define PAX_DELTA_MMAP_LEN 15
4630 +#define PAX_DELTA_STACK_LEN 15
4631 +#endif
4632
4633 /* This yields a mask that user programs can use to figure out what
4634 instruction set this CPU supports. This could be done in user space,
4635 diff --git a/arch/avr32/include/asm/kmap_types.h b/arch/avr32/include/asm/kmap_types.h
4636 index 479330b..53717a8 100644
4637 --- a/arch/avr32/include/asm/kmap_types.h
4638 +++ b/arch/avr32/include/asm/kmap_types.h
4639 @@ -2,9 +2,9 @@
4640 #define __ASM_AVR32_KMAP_TYPES_H
4641
4642 #ifdef CONFIG_DEBUG_HIGHMEM
4643 -# define KM_TYPE_NR 29
4644 +# define KM_TYPE_NR 30
4645 #else
4646 -# define KM_TYPE_NR 14
4647 +# define KM_TYPE_NR 15
4648 #endif
4649
4650 #endif /* __ASM_AVR32_KMAP_TYPES_H */
4651 diff --git a/arch/avr32/mm/fault.c b/arch/avr32/mm/fault.c
4652 index 0eca933..eb78c7b 100644
4653 --- a/arch/avr32/mm/fault.c
4654 +++ b/arch/avr32/mm/fault.c
4655 @@ -41,6 +41,23 @@ static inline int notify_page_fault(struct pt_regs *regs, int trap)
4656
4657 int exception_trace = 1;
4658
4659 +#ifdef CONFIG_PAX_PAGEEXEC
4660 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
4661 +{
4662 + unsigned long i;
4663 +
4664 + printk(KERN_ERR "PAX: bytes at PC: ");
4665 + for (i = 0; i < 20; i++) {
4666 + unsigned char c;
4667 + if (get_user(c, (unsigned char *)pc+i))
4668 + printk(KERN_CONT "???????? ");
4669 + else
4670 + printk(KERN_CONT "%02x ", c);
4671 + }
4672 + printk("\n");
4673 +}
4674 +#endif
4675 +
4676 /*
4677 * This routine handles page faults. It determines the address and the
4678 * problem, and then passes it off to one of the appropriate routines.
4679 @@ -176,6 +193,16 @@ bad_area:
4680 up_read(&mm->mmap_sem);
4681
4682 if (user_mode(regs)) {
4683 +
4684 +#ifdef CONFIG_PAX_PAGEEXEC
4685 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
4686 + if (ecr == ECR_PROTECTION_X || ecr == ECR_TLB_MISS_X) {
4687 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->sp);
4688 + do_group_exit(SIGKILL);
4689 + }
4690 + }
4691 +#endif
4692 +
4693 if (exception_trace && printk_ratelimit())
4694 printk("%s%s[%d]: segfault at %08lx pc %08lx "
4695 "sp %08lx ecr %lu\n",
4696 diff --git a/arch/blackfin/include/asm/cache.h b/arch/blackfin/include/asm/cache.h
4697 index 568885a..f8008df 100644
4698 --- a/arch/blackfin/include/asm/cache.h
4699 +++ b/arch/blackfin/include/asm/cache.h
4700 @@ -7,6 +7,7 @@
4701 #ifndef __ARCH_BLACKFIN_CACHE_H
4702 #define __ARCH_BLACKFIN_CACHE_H
4703
4704 +#include <linux/const.h>
4705 #include <linux/linkage.h> /* for asmlinkage */
4706
4707 /*
4708 @@ -14,7 +15,7 @@
4709 * Blackfin loads 32 bytes for cache
4710 */
4711 #define L1_CACHE_SHIFT 5
4712 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4713 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4714 #define SMP_CACHE_BYTES L1_CACHE_BYTES
4715
4716 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
4717 diff --git a/arch/cris/include/arch-v10/arch/cache.h b/arch/cris/include/arch-v10/arch/cache.h
4718 index aea2718..3639a60 100644
4719 --- a/arch/cris/include/arch-v10/arch/cache.h
4720 +++ b/arch/cris/include/arch-v10/arch/cache.h
4721 @@ -1,8 +1,9 @@
4722 #ifndef _ASM_ARCH_CACHE_H
4723 #define _ASM_ARCH_CACHE_H
4724
4725 +#include <linux/const.h>
4726 /* Etrax 100LX have 32-byte cache-lines. */
4727 -#define L1_CACHE_BYTES 32
4728 #define L1_CACHE_SHIFT 5
4729 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4730
4731 #endif /* _ASM_ARCH_CACHE_H */
4732 diff --git a/arch/cris/include/arch-v32/arch/cache.h b/arch/cris/include/arch-v32/arch/cache.h
4733 index 7caf25d..ee65ac5 100644
4734 --- a/arch/cris/include/arch-v32/arch/cache.h
4735 +++ b/arch/cris/include/arch-v32/arch/cache.h
4736 @@ -1,11 +1,12 @@
4737 #ifndef _ASM_CRIS_ARCH_CACHE_H
4738 #define _ASM_CRIS_ARCH_CACHE_H
4739
4740 +#include <linux/const.h>
4741 #include <arch/hwregs/dma.h>
4742
4743 /* A cache-line is 32 bytes. */
4744 -#define L1_CACHE_BYTES 32
4745 #define L1_CACHE_SHIFT 5
4746 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4747
4748 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
4749
4750 diff --git a/arch/frv/include/asm/atomic.h b/arch/frv/include/asm/atomic.h
4751 index b86329d..6709906 100644
4752 --- a/arch/frv/include/asm/atomic.h
4753 +++ b/arch/frv/include/asm/atomic.h
4754 @@ -186,6 +186,16 @@ static inline void atomic64_dec(atomic64_t *v)
4755 #define atomic64_cmpxchg(v, old, new) (__cmpxchg_64(old, new, &(v)->counter))
4756 #define atomic64_xchg(v, new) (__xchg_64(new, &(v)->counter))
4757
4758 +#define atomic64_read_unchecked(v) atomic64_read(v)
4759 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4760 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4761 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4762 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4763 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4764 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4765 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4766 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4767 +
4768 static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
4769 {
4770 int c, old;
4771 diff --git a/arch/frv/include/asm/cache.h b/arch/frv/include/asm/cache.h
4772 index 2797163..c2a401d 100644
4773 --- a/arch/frv/include/asm/cache.h
4774 +++ b/arch/frv/include/asm/cache.h
4775 @@ -12,10 +12,11 @@
4776 #ifndef __ASM_CACHE_H
4777 #define __ASM_CACHE_H
4778
4779 +#include <linux/const.h>
4780
4781 /* bytes per L1 cache line */
4782 #define L1_CACHE_SHIFT (CONFIG_FRV_L1_CACHE_SHIFT)
4783 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4784 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4785
4786 #define __cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4787 #define ____cacheline_aligned __attribute__((aligned(L1_CACHE_BYTES)))
4788 diff --git a/arch/frv/include/asm/kmap_types.h b/arch/frv/include/asm/kmap_types.h
4789 index 43901f2..0d8b865 100644
4790 --- a/arch/frv/include/asm/kmap_types.h
4791 +++ b/arch/frv/include/asm/kmap_types.h
4792 @@ -2,6 +2,6 @@
4793 #ifndef _ASM_KMAP_TYPES_H
4794 #define _ASM_KMAP_TYPES_H
4795
4796 -#define KM_TYPE_NR 17
4797 +#define KM_TYPE_NR 18
4798
4799 #endif
4800 diff --git a/arch/frv/mm/elf-fdpic.c b/arch/frv/mm/elf-fdpic.c
4801 index 836f147..4cf23f5 100644
4802 --- a/arch/frv/mm/elf-fdpic.c
4803 +++ b/arch/frv/mm/elf-fdpic.c
4804 @@ -61,6 +61,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4805 {
4806 struct vm_area_struct *vma;
4807 struct vm_unmapped_area_info info;
4808 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
4809
4810 if (len > TASK_SIZE)
4811 return -ENOMEM;
4812 @@ -73,8 +74,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4813 if (addr) {
4814 addr = PAGE_ALIGN(addr);
4815 vma = find_vma(current->mm, addr);
4816 - if (TASK_SIZE - len >= addr &&
4817 - (!vma || addr + len <= vma->vm_start))
4818 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
4819 goto success;
4820 }
4821
4822 @@ -85,6 +85,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
4823 info.high_limit = (current->mm->start_stack - 0x00200000);
4824 info.align_mask = 0;
4825 info.align_offset = 0;
4826 + info.threadstack_offset = offset;
4827 addr = vm_unmapped_area(&info);
4828 if (!(addr & ~PAGE_MASK))
4829 goto success;
4830 diff --git a/arch/hexagon/include/asm/cache.h b/arch/hexagon/include/asm/cache.h
4831 index f4ca594..adc72fd6 100644
4832 --- a/arch/hexagon/include/asm/cache.h
4833 +++ b/arch/hexagon/include/asm/cache.h
4834 @@ -21,9 +21,11 @@
4835 #ifndef __ASM_CACHE_H
4836 #define __ASM_CACHE_H
4837
4838 +#include <linux/const.h>
4839 +
4840 /* Bytes per L1 cache line */
4841 -#define L1_CACHE_SHIFT (5)
4842 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4843 +#define L1_CACHE_SHIFT 5
4844 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4845
4846 #define __cacheline_aligned __aligned(L1_CACHE_BYTES)
4847 #define ____cacheline_aligned __aligned(L1_CACHE_BYTES)
4848 diff --git a/arch/ia64/Kconfig b/arch/ia64/Kconfig
4849 index 7740ab1..17fa8c5 100644
4850 --- a/arch/ia64/Kconfig
4851 +++ b/arch/ia64/Kconfig
4852 @@ -554,6 +554,7 @@ source "drivers/sn/Kconfig"
4853 config KEXEC
4854 bool "kexec system call"
4855 depends on !IA64_HP_SIM && (!SMP || HOTPLUG_CPU)
4856 + depends on !GRKERNSEC_KMEM
4857 help
4858 kexec is a system call that implements the ability to shutdown your
4859 current kernel, and to start another kernel. It is like a reboot
4860 diff --git a/arch/ia64/include/asm/atomic.h b/arch/ia64/include/asm/atomic.h
4861 index 6e6fe18..a6ae668 100644
4862 --- a/arch/ia64/include/asm/atomic.h
4863 +++ b/arch/ia64/include/asm/atomic.h
4864 @@ -208,6 +208,16 @@ atomic64_add_negative (__s64 i, atomic64_t *v)
4865 #define atomic64_inc(v) atomic64_add(1, (v))
4866 #define atomic64_dec(v) atomic64_sub(1, (v))
4867
4868 +#define atomic64_read_unchecked(v) atomic64_read(v)
4869 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
4870 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
4871 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
4872 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
4873 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
4874 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
4875 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
4876 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
4877 +
4878 /* Atomic operations are already serializing */
4879 #define smp_mb__before_atomic_dec() barrier()
4880 #define smp_mb__after_atomic_dec() barrier()
4881 diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
4882 index 988254a..e1ee885 100644
4883 --- a/arch/ia64/include/asm/cache.h
4884 +++ b/arch/ia64/include/asm/cache.h
4885 @@ -1,6 +1,7 @@
4886 #ifndef _ASM_IA64_CACHE_H
4887 #define _ASM_IA64_CACHE_H
4888
4889 +#include <linux/const.h>
4890
4891 /*
4892 * Copyright (C) 1998-2000 Hewlett-Packard Co
4893 @@ -9,7 +10,7 @@
4894
4895 /* Bytes per L1 (data) cache line. */
4896 #define L1_CACHE_SHIFT CONFIG_IA64_L1_CACHE_SHIFT
4897 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
4898 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
4899
4900 #ifdef CONFIG_SMP
4901 # define SMP_CACHE_SHIFT L1_CACHE_SHIFT
4902 diff --git a/arch/ia64/include/asm/elf.h b/arch/ia64/include/asm/elf.h
4903 index 5a83c5c..4d7f553 100644
4904 --- a/arch/ia64/include/asm/elf.h
4905 +++ b/arch/ia64/include/asm/elf.h
4906 @@ -42,6 +42,13 @@
4907 */
4908 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x800000000UL)
4909
4910 +#ifdef CONFIG_PAX_ASLR
4911 +#define PAX_ELF_ET_DYN_BASE (current->personality == PER_LINUX32 ? 0x08048000UL : 0x4000000000000000UL)
4912 +
4913 +#define PAX_DELTA_MMAP_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4914 +#define PAX_DELTA_STACK_LEN (current->personality == PER_LINUX32 ? 16 : 3*PAGE_SHIFT - 13)
4915 +#endif
4916 +
4917 #define PT_IA_64_UNWIND 0x70000001
4918
4919 /* IA-64 relocations: */
4920 diff --git a/arch/ia64/include/asm/pgalloc.h b/arch/ia64/include/asm/pgalloc.h
4921 index 96a8d92..617a1cf 100644
4922 --- a/arch/ia64/include/asm/pgalloc.h
4923 +++ b/arch/ia64/include/asm/pgalloc.h
4924 @@ -39,6 +39,12 @@ pgd_populate(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4925 pgd_val(*pgd_entry) = __pa(pud);
4926 }
4927
4928 +static inline void
4929 +pgd_populate_kernel(struct mm_struct *mm, pgd_t * pgd_entry, pud_t * pud)
4930 +{
4931 + pgd_populate(mm, pgd_entry, pud);
4932 +}
4933 +
4934 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
4935 {
4936 return quicklist_alloc(0, GFP_KERNEL, NULL);
4937 @@ -57,6 +63,12 @@ pud_populate(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4938 pud_val(*pud_entry) = __pa(pmd);
4939 }
4940
4941 +static inline void
4942 +pud_populate_kernel(struct mm_struct *mm, pud_t * pud_entry, pmd_t * pmd)
4943 +{
4944 + pud_populate(mm, pud_entry, pmd);
4945 +}
4946 +
4947 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
4948 {
4949 return quicklist_alloc(0, GFP_KERNEL, NULL);
4950 diff --git a/arch/ia64/include/asm/pgtable.h b/arch/ia64/include/asm/pgtable.h
4951 index 7935115..c0eca6a 100644
4952 --- a/arch/ia64/include/asm/pgtable.h
4953 +++ b/arch/ia64/include/asm/pgtable.h
4954 @@ -12,7 +12,7 @@
4955 * David Mosberger-Tang <davidm@hpl.hp.com>
4956 */
4957
4958 -
4959 +#include <linux/const.h>
4960 #include <asm/mman.h>
4961 #include <asm/page.h>
4962 #include <asm/processor.h>
4963 @@ -142,6 +142,17 @@
4964 #define PAGE_READONLY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4965 #define PAGE_COPY __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4966 #define PAGE_COPY_EXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RX)
4967 +
4968 +#ifdef CONFIG_PAX_PAGEEXEC
4969 +# define PAGE_SHARED_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_RW)
4970 +# define PAGE_READONLY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4971 +# define PAGE_COPY_NOEXEC __pgprot(__ACCESS_BITS | _PAGE_PL_3 | _PAGE_AR_R)
4972 +#else
4973 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
4974 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
4975 +# define PAGE_COPY_NOEXEC PAGE_COPY
4976 +#endif
4977 +
4978 #define PAGE_GATE __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_X_RX)
4979 #define PAGE_KERNEL __pgprot(__DIRTY_BITS | _PAGE_PL_0 | _PAGE_AR_RWX)
4980 #define PAGE_KERNELRX __pgprot(__ACCESS_BITS | _PAGE_PL_0 | _PAGE_AR_RX)
4981 diff --git a/arch/ia64/include/asm/spinlock.h b/arch/ia64/include/asm/spinlock.h
4982 index 45698cd..e8e2dbc 100644
4983 --- a/arch/ia64/include/asm/spinlock.h
4984 +++ b/arch/ia64/include/asm/spinlock.h
4985 @@ -71,7 +71,7 @@ static __always_inline void __ticket_spin_unlock(arch_spinlock_t *lock)
4986 unsigned short *p = (unsigned short *)&lock->lock + 1, tmp;
4987
4988 asm volatile ("ld2.bias %0=[%1]" : "=r"(tmp) : "r"(p));
4989 - ACCESS_ONCE(*p) = (tmp + 2) & ~1;
4990 + ACCESS_ONCE_RW(*p) = (tmp + 2) & ~1;
4991 }
4992
4993 static __always_inline void __ticket_spin_unlock_wait(arch_spinlock_t *lock)
4994 diff --git a/arch/ia64/include/asm/uaccess.h b/arch/ia64/include/asm/uaccess.h
4995 index 449c8c0..18965fb 100644
4996 --- a/arch/ia64/include/asm/uaccess.h
4997 +++ b/arch/ia64/include/asm/uaccess.h
4998 @@ -240,12 +240,24 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use
4999 static inline unsigned long
5000 __copy_to_user (void __user *to, const void *from, unsigned long count)
5001 {
5002 + if (count > INT_MAX)
5003 + return count;
5004 +
5005 + if (!__builtin_constant_p(count))
5006 + check_object_size(from, count, true);
5007 +
5008 return __copy_user(to, (__force void __user *) from, count);
5009 }
5010
5011 static inline unsigned long
5012 __copy_from_user (void *to, const void __user *from, unsigned long count)
5013 {
5014 + if (count > INT_MAX)
5015 + return count;
5016 +
5017 + if (!__builtin_constant_p(count))
5018 + check_object_size(to, count, false);
5019 +
5020 return __copy_user((__force void __user *) to, from, count);
5021 }
5022
5023 @@ -255,10 +267,13 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5024 ({ \
5025 void __user *__cu_to = (to); \
5026 const void *__cu_from = (from); \
5027 - long __cu_len = (n); \
5028 + unsigned long __cu_len = (n); \
5029 \
5030 - if (__access_ok(__cu_to, __cu_len, get_fs())) \
5031 + if (__cu_len <= INT_MAX && __access_ok(__cu_to, __cu_len, get_fs())) { \
5032 + if (!__builtin_constant_p(n)) \
5033 + check_object_size(__cu_from, __cu_len, true); \
5034 __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \
5035 + } \
5036 __cu_len; \
5037 })
5038
5039 @@ -266,11 +281,14 @@ __copy_from_user (void *to, const void __user *from, unsigned long count)
5040 ({ \
5041 void *__cu_to = (to); \
5042 const void __user *__cu_from = (from); \
5043 - long __cu_len = (n); \
5044 + unsigned long __cu_len = (n); \
5045 \
5046 __chk_user_ptr(__cu_from); \
5047 - if (__access_ok(__cu_from, __cu_len, get_fs())) \
5048 + if (__cu_len <= INT_MAX && __access_ok(__cu_from, __cu_len, get_fs())) { \
5049 + if (!__builtin_constant_p(n)) \
5050 + check_object_size(__cu_to, __cu_len, false); \
5051 __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \
5052 + } \
5053 __cu_len; \
5054 })
5055
5056 diff --git a/arch/ia64/kernel/module.c b/arch/ia64/kernel/module.c
5057 index 24603be..948052d 100644
5058 --- a/arch/ia64/kernel/module.c
5059 +++ b/arch/ia64/kernel/module.c
5060 @@ -307,8 +307,7 @@ plt_target (struct plt_entry *plt)
5061 void
5062 module_free (struct module *mod, void *module_region)
5063 {
5064 - if (mod && mod->arch.init_unw_table &&
5065 - module_region == mod->module_init) {
5066 + if (mod && mod->arch.init_unw_table && module_region == mod->module_init_rx) {
5067 unw_remove_unwind_table(mod->arch.init_unw_table);
5068 mod->arch.init_unw_table = NULL;
5069 }
5070 @@ -494,15 +493,39 @@ module_frob_arch_sections (Elf_Ehdr *ehdr, Elf_Shdr *sechdrs, char *secstrings,
5071 }
5072
5073 static inline int
5074 +in_init_rx (const struct module *mod, uint64_t addr)
5075 +{
5076 + return addr - (uint64_t) mod->module_init_rx < mod->init_size_rx;
5077 +}
5078 +
5079 +static inline int
5080 +in_init_rw (const struct module *mod, uint64_t addr)
5081 +{
5082 + return addr - (uint64_t) mod->module_init_rw < mod->init_size_rw;
5083 +}
5084 +
5085 +static inline int
5086 in_init (const struct module *mod, uint64_t addr)
5087 {
5088 - return addr - (uint64_t) mod->module_init < mod->init_size;
5089 + return in_init_rx(mod, addr) || in_init_rw(mod, addr);
5090 +}
5091 +
5092 +static inline int
5093 +in_core_rx (const struct module *mod, uint64_t addr)
5094 +{
5095 + return addr - (uint64_t) mod->module_core_rx < mod->core_size_rx;
5096 +}
5097 +
5098 +static inline int
5099 +in_core_rw (const struct module *mod, uint64_t addr)
5100 +{
5101 + return addr - (uint64_t) mod->module_core_rw < mod->core_size_rw;
5102 }
5103
5104 static inline int
5105 in_core (const struct module *mod, uint64_t addr)
5106 {
5107 - return addr - (uint64_t) mod->module_core < mod->core_size;
5108 + return in_core_rx(mod, addr) || in_core_rw(mod, addr);
5109 }
5110
5111 static inline int
5112 @@ -685,7 +708,14 @@ do_reloc (struct module *mod, uint8_t r_type, Elf64_Sym *sym, uint64_t addend,
5113 break;
5114
5115 case RV_BDREL:
5116 - val -= (uint64_t) (in_init(mod, val) ? mod->module_init : mod->module_core);
5117 + if (in_init_rx(mod, val))
5118 + val -= (uint64_t) mod->module_init_rx;
5119 + else if (in_init_rw(mod, val))
5120 + val -= (uint64_t) mod->module_init_rw;
5121 + else if (in_core_rx(mod, val))
5122 + val -= (uint64_t) mod->module_core_rx;
5123 + else if (in_core_rw(mod, val))
5124 + val -= (uint64_t) mod->module_core_rw;
5125 break;
5126
5127 case RV_LTV:
5128 @@ -820,15 +850,15 @@ apply_relocate_add (Elf64_Shdr *sechdrs, const char *strtab, unsigned int symind
5129 * addresses have been selected...
5130 */
5131 uint64_t gp;
5132 - if (mod->core_size > MAX_LTOFF)
5133 + if (mod->core_size_rx + mod->core_size_rw > MAX_LTOFF)
5134 /*
5135 * This takes advantage of fact that SHF_ARCH_SMALL gets allocated
5136 * at the end of the module.
5137 */
5138 - gp = mod->core_size - MAX_LTOFF / 2;
5139 + gp = mod->core_size_rx + mod->core_size_rw - MAX_LTOFF / 2;
5140 else
5141 - gp = mod->core_size / 2;
5142 - gp = (uint64_t) mod->module_core + ((gp + 7) & -8);
5143 + gp = (mod->core_size_rx + mod->core_size_rw) / 2;
5144 + gp = (uint64_t) mod->module_core_rx + ((gp + 7) & -8);
5145 mod->arch.gp = gp;
5146 DEBUGP("%s: placing gp at 0x%lx\n", __func__, gp);
5147 }
5148 diff --git a/arch/ia64/kernel/palinfo.c b/arch/ia64/kernel/palinfo.c
5149 index ab33328..f39506c 100644
5150 --- a/arch/ia64/kernel/palinfo.c
5151 +++ b/arch/ia64/kernel/palinfo.c
5152 @@ -980,7 +980,7 @@ static int palinfo_cpu_callback(struct notifier_block *nfb,
5153 return NOTIFY_OK;
5154 }
5155
5156 -static struct notifier_block __refdata palinfo_cpu_notifier =
5157 +static struct notifier_block palinfo_cpu_notifier =
5158 {
5159 .notifier_call = palinfo_cpu_callback,
5160 .priority = 0,
5161 diff --git a/arch/ia64/kernel/sys_ia64.c b/arch/ia64/kernel/sys_ia64.c
5162 index 41e33f8..65180b2a 100644
5163 --- a/arch/ia64/kernel/sys_ia64.c
5164 +++ b/arch/ia64/kernel/sys_ia64.c
5165 @@ -28,6 +28,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5166 unsigned long align_mask = 0;
5167 struct mm_struct *mm = current->mm;
5168 struct vm_unmapped_area_info info;
5169 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
5170
5171 if (len > RGN_MAP_LIMIT)
5172 return -ENOMEM;
5173 @@ -43,6 +44,13 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5174 if (REGION_NUMBER(addr) == RGN_HPAGE)
5175 addr = 0;
5176 #endif
5177 +
5178 +#ifdef CONFIG_PAX_RANDMMAP
5179 + if (mm->pax_flags & MF_PAX_RANDMMAP)
5180 + addr = mm->free_area_cache;
5181 + else
5182 +#endif
5183 +
5184 if (!addr)
5185 addr = TASK_UNMAPPED_BASE;
5186
5187 @@ -61,6 +69,7 @@ arch_get_unmapped_area (struct file *filp, unsigned long addr, unsigned long len
5188 info.high_limit = TASK_SIZE;
5189 info.align_mask = align_mask;
5190 info.align_offset = 0;
5191 + info.threadstack_offset = offset;
5192 return vm_unmapped_area(&info);
5193 }
5194
5195 diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
5196 index 0ccb28f..8992469 100644
5197 --- a/arch/ia64/kernel/vmlinux.lds.S
5198 +++ b/arch/ia64/kernel/vmlinux.lds.S
5199 @@ -198,7 +198,7 @@ SECTIONS {
5200 /* Per-cpu data: */
5201 . = ALIGN(PERCPU_PAGE_SIZE);
5202 PERCPU_VADDR(SMP_CACHE_BYTES, PERCPU_ADDR, :percpu)
5203 - __phys_per_cpu_start = __per_cpu_load;
5204 + __phys_per_cpu_start = per_cpu_load;
5205 /*
5206 * ensure percpu data fits
5207 * into percpu page size
5208 diff --git a/arch/ia64/mm/fault.c b/arch/ia64/mm/fault.c
5209 index 7225dad..2a7c8256 100644
5210 --- a/arch/ia64/mm/fault.c
5211 +++ b/arch/ia64/mm/fault.c
5212 @@ -72,6 +72,23 @@ mapped_kernel_page_is_present (unsigned long address)
5213 return pte_present(pte);
5214 }
5215
5216 +#ifdef CONFIG_PAX_PAGEEXEC
5217 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
5218 +{
5219 + unsigned long i;
5220 +
5221 + printk(KERN_ERR "PAX: bytes at PC: ");
5222 + for (i = 0; i < 8; i++) {
5223 + unsigned int c;
5224 + if (get_user(c, (unsigned int *)pc+i))
5225 + printk(KERN_CONT "???????? ");
5226 + else
5227 + printk(KERN_CONT "%08x ", c);
5228 + }
5229 + printk("\n");
5230 +}
5231 +#endif
5232 +
5233 # define VM_READ_BIT 0
5234 # define VM_WRITE_BIT 1
5235 # define VM_EXEC_BIT 2
5236 @@ -151,8 +168,21 @@ retry:
5237 if (((isr >> IA64_ISR_R_BIT) & 1UL) && (!(vma->vm_flags & (VM_READ | VM_WRITE))))
5238 goto bad_area;
5239
5240 - if ((vma->vm_flags & mask) != mask)
5241 + if ((vma->vm_flags & mask) != mask) {
5242 +
5243 +#ifdef CONFIG_PAX_PAGEEXEC
5244 + if (!(vma->vm_flags & VM_EXEC) && (mask & VM_EXEC)) {
5245 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || address != regs->cr_iip)
5246 + goto bad_area;
5247 +
5248 + up_read(&mm->mmap_sem);
5249 + pax_report_fault(regs, (void *)regs->cr_iip, (void *)regs->r12);
5250 + do_group_exit(SIGKILL);
5251 + }
5252 +#endif
5253 +
5254 goto bad_area;
5255 + }
5256
5257 /*
5258 * If for any reason at all we couldn't handle the fault, make
5259 diff --git a/arch/ia64/mm/hugetlbpage.c b/arch/ia64/mm/hugetlbpage.c
5260 index 68232db..6ca80af 100644
5261 --- a/arch/ia64/mm/hugetlbpage.c
5262 +++ b/arch/ia64/mm/hugetlbpage.c
5263 @@ -154,6 +154,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5264 unsigned long pgoff, unsigned long flags)
5265 {
5266 struct vm_unmapped_area_info info;
5267 + unsigned long offset = gr_rand_threadstack_offset(current->mm, file, flags);
5268
5269 if (len > RGN_MAP_LIMIT)
5270 return -ENOMEM;
5271 @@ -177,6 +178,7 @@ unsigned long hugetlb_get_unmapped_area(struct file *file, unsigned long addr, u
5272 info.high_limit = HPAGE_REGION_BASE + RGN_MAP_LIMIT;
5273 info.align_mask = PAGE_MASK & (HPAGE_SIZE - 1);
5274 info.align_offset = 0;
5275 + info.threadstack_offset = offset;
5276 return vm_unmapped_area(&info);
5277 }
5278
5279 diff --git a/arch/ia64/mm/init.c b/arch/ia64/mm/init.c
5280 index b6f7f43..c04320d 100644
5281 --- a/arch/ia64/mm/init.c
5282 +++ b/arch/ia64/mm/init.c
5283 @@ -120,6 +120,19 @@ ia64_init_addr_space (void)
5284 vma->vm_start = current->thread.rbs_bot & PAGE_MASK;
5285 vma->vm_end = vma->vm_start + PAGE_SIZE;
5286 vma->vm_flags = VM_DATA_DEFAULT_FLAGS|VM_GROWSUP|VM_ACCOUNT;
5287 +
5288 +#ifdef CONFIG_PAX_PAGEEXEC
5289 + if (current->mm->pax_flags & MF_PAX_PAGEEXEC) {
5290 + vma->vm_flags &= ~VM_EXEC;
5291 +
5292 +#ifdef CONFIG_PAX_MPROTECT
5293 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
5294 + vma->vm_flags &= ~VM_MAYEXEC;
5295 +#endif
5296 +
5297 + }
5298 +#endif
5299 +
5300 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
5301 down_write(&current->mm->mmap_sem);
5302 if (insert_vm_struct(current->mm, vma)) {
5303 diff --git a/arch/m32r/include/asm/cache.h b/arch/m32r/include/asm/cache.h
5304 index 40b3ee9..8c2c112 100644
5305 --- a/arch/m32r/include/asm/cache.h
5306 +++ b/arch/m32r/include/asm/cache.h
5307 @@ -1,8 +1,10 @@
5308 #ifndef _ASM_M32R_CACHE_H
5309 #define _ASM_M32R_CACHE_H
5310
5311 +#include <linux/const.h>
5312 +
5313 /* L1 cache line size */
5314 #define L1_CACHE_SHIFT 4
5315 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5316 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5317
5318 #endif /* _ASM_M32R_CACHE_H */
5319 diff --git a/arch/m32r/lib/usercopy.c b/arch/m32r/lib/usercopy.c
5320 index 82abd15..d95ae5d 100644
5321 --- a/arch/m32r/lib/usercopy.c
5322 +++ b/arch/m32r/lib/usercopy.c
5323 @@ -14,6 +14,9 @@
5324 unsigned long
5325 __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5326 {
5327 + if ((long)n < 0)
5328 + return n;
5329 +
5330 prefetch(from);
5331 if (access_ok(VERIFY_WRITE, to, n))
5332 __copy_user(to,from,n);
5333 @@ -23,6 +26,9 @@ __generic_copy_to_user(void __user *to, const void *from, unsigned long n)
5334 unsigned long
5335 __generic_copy_from_user(void *to, const void __user *from, unsigned long n)
5336 {
5337 + if ((long)n < 0)
5338 + return n;
5339 +
5340 prefetchw(to);
5341 if (access_ok(VERIFY_READ, from, n))
5342 __copy_user_zeroing(to,from,n);
5343 diff --git a/arch/m68k/include/asm/cache.h b/arch/m68k/include/asm/cache.h
5344 index 0395c51..5f26031 100644
5345 --- a/arch/m68k/include/asm/cache.h
5346 +++ b/arch/m68k/include/asm/cache.h
5347 @@ -4,9 +4,11 @@
5348 #ifndef __ARCH_M68K_CACHE_H
5349 #define __ARCH_M68K_CACHE_H
5350
5351 +#include <linux/const.h>
5352 +
5353 /* bytes per L1 cache line */
5354 #define L1_CACHE_SHIFT 4
5355 -#define L1_CACHE_BYTES (1<< L1_CACHE_SHIFT)
5356 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5357
5358 #define ARCH_DMA_MINALIGN L1_CACHE_BYTES
5359
5360 diff --git a/arch/metag/mm/hugetlbpage.c b/arch/metag/mm/hugetlbpage.c
5361 index 0424315..defcca9 100644
5362 --- a/arch/metag/mm/hugetlbpage.c
5363 +++ b/arch/metag/mm/hugetlbpage.c
5364 @@ -205,6 +205,7 @@ hugetlb_get_unmapped_area_new_pmd(unsigned long len)
5365 info.high_limit = TASK_SIZE;
5366 info.align_mask = PAGE_MASK & HUGEPT_MASK;
5367 info.align_offset = 0;
5368 + info.threadstack_offset = 0;
5369 return vm_unmapped_area(&info);
5370 }
5371
5372 diff --git a/arch/microblaze/include/asm/cache.h b/arch/microblaze/include/asm/cache.h
5373 index 4efe96a..60e8699 100644
5374 --- a/arch/microblaze/include/asm/cache.h
5375 +++ b/arch/microblaze/include/asm/cache.h
5376 @@ -13,11 +13,12 @@
5377 #ifndef _ASM_MICROBLAZE_CACHE_H
5378 #define _ASM_MICROBLAZE_CACHE_H
5379
5380 +#include <linux/const.h>
5381 #include <asm/registers.h>
5382
5383 #define L1_CACHE_SHIFT 5
5384 /* word-granular cache in microblaze */
5385 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
5386 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
5387
5388 #define SMP_CACHE_BYTES L1_CACHE_BYTES
5389
5390 diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
5391 index f75ab4a..adc6968 100644
5392 --- a/arch/mips/Kconfig
5393 +++ b/arch/mips/Kconfig
5394 @@ -2283,6 +2283,7 @@ source "kernel/Kconfig.preempt"
5395
5396 config KEXEC
5397 bool "Kexec system call"
5398 + depends on !GRKERNSEC_KMEM
5399 help
5400 kexec is a system call that implements the ability to shutdown your
5401 current kernel, and to start another kernel. It is like a reboot
5402 diff --git a/arch/mips/include/asm/atomic.h b/arch/mips/include/asm/atomic.h
5403 index 08b6079..8b554d2 100644
5404 --- a/arch/mips/include/asm/atomic.h
5405 +++ b/arch/mips/include/asm/atomic.h
5406 @@ -21,15 +21,39 @@
5407 #include <asm/cmpxchg.h>
5408 #include <asm/war.h>
5409
5410 +#ifdef CONFIG_GENERIC_ATOMIC64
5411 +#include <asm-generic/atomic64.h>
5412 +#endif
5413 +
5414 #define ATOMIC_INIT(i) { (i) }
5415
5416 +#ifdef CONFIG_64BIT
5417 +#define _ASM_EXTABLE(from, to) \
5418 +" .section __ex_table,\"a\"\n" \
5419 +" .dword " #from ", " #to"\n" \
5420 +" .previous\n"
5421 +#else
5422 +#define _ASM_EXTABLE(from, to) \
5423 +" .section __ex_table,\"a\"\n" \
5424 +" .word " #from ", " #to"\n" \
5425 +" .previous\n"
5426 +#endif
5427 +
5428 /*
5429 * atomic_read - read atomic variable
5430 * @v: pointer of type atomic_t
5431 *
5432 * Atomically reads the value of @v.
5433 */
5434 -#define atomic_read(v) (*(volatile int *)&(v)->counter)
5435 +static inline int atomic_read(const atomic_t *v)
5436 +{
5437 + return (*(volatile const int *) &v->counter);
5438 +}
5439 +
5440 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
5441 +{
5442 + return (*(volatile const int *) &v->counter);
5443 +}
5444
5445 /*
5446 * atomic_set - set atomic variable
5447 @@ -38,7 +62,15 @@
5448 *
5449 * Atomically sets the value of @v to @i.
5450 */
5451 -#define atomic_set(v, i) ((v)->counter = (i))
5452 +static inline void atomic_set(atomic_t *v, int i)
5453 +{
5454 + v->counter = i;
5455 +}
5456 +
5457 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
5458 +{
5459 + v->counter = i;
5460 +}
5461
5462 /*
5463 * atomic_add - add integer to atomic variable
5464 @@ -47,7 +79,67 @@
5465 *
5466 * Atomically adds @i to @v.
5467 */
5468 -static __inline__ void atomic_add(int i, atomic_t * v)
5469 +static __inline__ void atomic_add(int i, atomic_t *v)
5470 +{
5471 + int temp;
5472 +
5473 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5474 + __asm__ __volatile__(
5475 + " .set mips3 \n"
5476 + "1: ll %0, %1 # atomic_add \n"
5477 +#ifdef CONFIG_PAX_REFCOUNT
5478 + /* Exception on overflow. */
5479 + "2: add %0, %2 \n"
5480 +#else
5481 + " addu %0, %2 \n"
5482 +#endif
5483 + " sc %0, %1 \n"
5484 + " beqzl %0, 1b \n"
5485 +#ifdef CONFIG_PAX_REFCOUNT
5486 + "3: \n"
5487 + _ASM_EXTABLE(2b, 3b)
5488 +#endif
5489 + " .set mips0 \n"
5490 + : "=&r" (temp), "+m" (v->counter)
5491 + : "Ir" (i));
5492 + } else if (kernel_uses_llsc) {
5493 + __asm__ __volatile__(
5494 + " .set mips3 \n"
5495 + "1: ll %0, %1 # atomic_add \n"
5496 +#ifdef CONFIG_PAX_REFCOUNT
5497 + /* Exception on overflow. */
5498 + "2: add %0, %2 \n"
5499 +#else
5500 + " addu %0, %2 \n"
5501 +#endif
5502 + " sc %0, %1 \n"
5503 + " beqz %0, 1b \n"
5504 +#ifdef CONFIG_PAX_REFCOUNT
5505 + "3: \n"
5506 + _ASM_EXTABLE(2b, 3b)
5507 +#endif
5508 + " .set mips0 \n"
5509 + : "=&r" (temp), "+m" (v->counter)
5510 + : "Ir" (i));
5511 + } else {
5512 + unsigned long flags;
5513 +
5514 + raw_local_irq_save(flags);
5515 + __asm__ __volatile__(
5516 +#ifdef CONFIG_PAX_REFCOUNT
5517 + /* Exception on overflow. */
5518 + "1: add %0, %1 \n"
5519 + "2: \n"
5520 + _ASM_EXTABLE(1b, 2b)
5521 +#else
5522 + " addu %0, %1 \n"
5523 +#endif
5524 + : "+r" (v->counter) : "Ir" (i));
5525 + raw_local_irq_restore(flags);
5526 + }
5527 +}
5528 +
5529 +static __inline__ void atomic_add_unchecked(int i, atomic_unchecked_t *v)
5530 {
5531 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5532 int temp;
5533 @@ -90,7 +182,67 @@ static __inline__ void atomic_add(int i, atomic_t * v)
5534 *
5535 * Atomically subtracts @i from @v.
5536 */
5537 -static __inline__ void atomic_sub(int i, atomic_t * v)
5538 +static __inline__ void atomic_sub(int i, atomic_t *v)
5539 +{
5540 + int temp;
5541 +
5542 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5543 + __asm__ __volatile__(
5544 + " .set mips3 \n"
5545 + "1: ll %0, %1 # atomic64_sub \n"
5546 +#ifdef CONFIG_PAX_REFCOUNT
5547 + /* Exception on overflow. */
5548 + "2: sub %0, %2 \n"
5549 +#else
5550 + " subu %0, %2 \n"
5551 +#endif
5552 + " sc %0, %1 \n"
5553 + " beqzl %0, 1b \n"
5554 +#ifdef CONFIG_PAX_REFCOUNT
5555 + "3: \n"
5556 + _ASM_EXTABLE(2b, 3b)
5557 +#endif
5558 + " .set mips0 \n"
5559 + : "=&r" (temp), "+m" (v->counter)
5560 + : "Ir" (i));
5561 + } else if (kernel_uses_llsc) {
5562 + __asm__ __volatile__(
5563 + " .set mips3 \n"
5564 + "1: ll %0, %1 # atomic64_sub \n"
5565 +#ifdef CONFIG_PAX_REFCOUNT
5566 + /* Exception on overflow. */
5567 + "2: sub %0, %2 \n"
5568 +#else
5569 + " subu %0, %2 \n"
5570 +#endif
5571 + " sc %0, %1 \n"
5572 + " beqz %0, 1b \n"
5573 +#ifdef CONFIG_PAX_REFCOUNT
5574 + "3: \n"
5575 + _ASM_EXTABLE(2b, 3b)
5576 +#endif
5577 + " .set mips0 \n"
5578 + : "=&r" (temp), "+m" (v->counter)
5579 + : "Ir" (i));
5580 + } else {
5581 + unsigned long flags;
5582 +
5583 + raw_local_irq_save(flags);
5584 + __asm__ __volatile__(
5585 +#ifdef CONFIG_PAX_REFCOUNT
5586 + /* Exception on overflow. */
5587 + "1: sub %0, %1 \n"
5588 + "2: \n"
5589 + _ASM_EXTABLE(1b, 2b)
5590 +#else
5591 + " subu %0, %1 \n"
5592 +#endif
5593 + : "+r" (v->counter) : "Ir" (i));
5594 + raw_local_irq_restore(flags);
5595 + }
5596 +}
5597 +
5598 +static __inline__ void atomic_sub_unchecked(long i, atomic_unchecked_t *v)
5599 {
5600 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5601 int temp;
5602 @@ -129,7 +281,93 @@ static __inline__ void atomic_sub(int i, atomic_t * v)
5603 /*
5604 * Same as above, but return the result value
5605 */
5606 -static __inline__ int atomic_add_return(int i, atomic_t * v)
5607 +static __inline__ int atomic_add_return(int i, atomic_t *v)
5608 +{
5609 + int result;
5610 + int temp;
5611 +
5612 + smp_mb__before_llsc();
5613 +
5614 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5615 + __asm__ __volatile__(
5616 + " .set mips3 \n"
5617 + "1: ll %1, %2 # atomic_add_return \n"
5618 +#ifdef CONFIG_PAX_REFCOUNT
5619 + "2: add %0, %1, %3 \n"
5620 +#else
5621 + " addu %0, %1, %3 \n"
5622 +#endif
5623 + " sc %0, %2 \n"
5624 + " beqzl %0, 1b \n"
5625 +#ifdef CONFIG_PAX_REFCOUNT
5626 + " b 4f \n"
5627 + " .set noreorder \n"
5628 + "3: b 5f \n"
5629 + " move %0, %1 \n"
5630 + " .set reorder \n"
5631 + _ASM_EXTABLE(2b, 3b)
5632 +#endif
5633 + "4: addu %0, %1, %3 \n"
5634 +#ifdef CONFIG_PAX_REFCOUNT
5635 + "5: \n"
5636 +#endif
5637 + " .set mips0 \n"
5638 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5639 + : "Ir" (i));
5640 + } else if (kernel_uses_llsc) {
5641 + __asm__ __volatile__(
5642 + " .set mips3 \n"
5643 + "1: ll %1, %2 # atomic_add_return \n"
5644 +#ifdef CONFIG_PAX_REFCOUNT
5645 + "2: add %0, %1, %3 \n"
5646 +#else
5647 + " addu %0, %1, %3 \n"
5648 +#endif
5649 + " sc %0, %2 \n"
5650 + " bnez %0, 4f \n"
5651 + " b 1b \n"
5652 +#ifdef CONFIG_PAX_REFCOUNT
5653 + " .set noreorder \n"
5654 + "3: b 5f \n"
5655 + " move %0, %1 \n"
5656 + " .set reorder \n"
5657 + _ASM_EXTABLE(2b, 3b)
5658 +#endif
5659 + "4: addu %0, %1, %3 \n"
5660 +#ifdef CONFIG_PAX_REFCOUNT
5661 + "5: \n"
5662 +#endif
5663 + " .set mips0 \n"
5664 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5665 + : "Ir" (i));
5666 + } else {
5667 + unsigned long flags;
5668 +
5669 + raw_local_irq_save(flags);
5670 + __asm__ __volatile__(
5671 + " lw %0, %1 \n"
5672 +#ifdef CONFIG_PAX_REFCOUNT
5673 + /* Exception on overflow. */
5674 + "1: add %0, %2 \n"
5675 +#else
5676 + " addu %0, %2 \n"
5677 +#endif
5678 + " sw %0, %1 \n"
5679 +#ifdef CONFIG_PAX_REFCOUNT
5680 + /* Note: Dest reg is not modified on overflow */
5681 + "2: \n"
5682 + _ASM_EXTABLE(1b, 2b)
5683 +#endif
5684 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5685 + raw_local_irq_restore(flags);
5686 + }
5687 +
5688 + smp_llsc_mb();
5689 +
5690 + return result;
5691 +}
5692 +
5693 +static __inline__ int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
5694 {
5695 int result;
5696
5697 @@ -178,7 +416,93 @@ static __inline__ int atomic_add_return(int i, atomic_t * v)
5698 return result;
5699 }
5700
5701 -static __inline__ int atomic_sub_return(int i, atomic_t * v)
5702 +static __inline__ int atomic_sub_return(int i, atomic_t *v)
5703 +{
5704 + int result;
5705 + int temp;
5706 +
5707 + smp_mb__before_llsc();
5708 +
5709 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5710 + __asm__ __volatile__(
5711 + " .set mips3 \n"
5712 + "1: ll %1, %2 # atomic_sub_return \n"
5713 +#ifdef CONFIG_PAX_REFCOUNT
5714 + "2: sub %0, %1, %3 \n"
5715 +#else
5716 + " subu %0, %1, %3 \n"
5717 +#endif
5718 + " sc %0, %2 \n"
5719 + " beqzl %0, 1b \n"
5720 +#ifdef CONFIG_PAX_REFCOUNT
5721 + " b 4f \n"
5722 + " .set noreorder \n"
5723 + "3: b 5f \n"
5724 + " move %0, %1 \n"
5725 + " .set reorder \n"
5726 + _ASM_EXTABLE(2b, 3b)
5727 +#endif
5728 + "4: subu %0, %1, %3 \n"
5729 +#ifdef CONFIG_PAX_REFCOUNT
5730 + "5: \n"
5731 +#endif
5732 + " .set mips0 \n"
5733 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
5734 + : "Ir" (i), "m" (v->counter)
5735 + : "memory");
5736 + } else if (kernel_uses_llsc) {
5737 + __asm__ __volatile__(
5738 + " .set mips3 \n"
5739 + "1: ll %1, %2 # atomic_sub_return \n"
5740 +#ifdef CONFIG_PAX_REFCOUNT
5741 + "2: sub %0, %1, %3 \n"
5742 +#else
5743 + " subu %0, %1, %3 \n"
5744 +#endif
5745 + " sc %0, %2 \n"
5746 + " bnez %0, 4f \n"
5747 + " b 1b \n"
5748 +#ifdef CONFIG_PAX_REFCOUNT
5749 + " .set noreorder \n"
5750 + "3: b 5f \n"
5751 + " move %0, %1 \n"
5752 + " .set reorder \n"
5753 + _ASM_EXTABLE(2b, 3b)
5754 +#endif
5755 + "4: subu %0, %1, %3 \n"
5756 +#ifdef CONFIG_PAX_REFCOUNT
5757 + "5: \n"
5758 +#endif
5759 + " .set mips0 \n"
5760 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
5761 + : "Ir" (i));
5762 + } else {
5763 + unsigned long flags;
5764 +
5765 + raw_local_irq_save(flags);
5766 + __asm__ __volatile__(
5767 + " lw %0, %1 \n"
5768 +#ifdef CONFIG_PAX_REFCOUNT
5769 + /* Exception on overflow. */
5770 + "1: sub %0, %2 \n"
5771 +#else
5772 + " subu %0, %2 \n"
5773 +#endif
5774 + " sw %0, %1 \n"
5775 +#ifdef CONFIG_PAX_REFCOUNT
5776 + /* Note: Dest reg is not modified on overflow */
5777 + "2: \n"
5778 + _ASM_EXTABLE(1b, 2b)
5779 +#endif
5780 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
5781 + raw_local_irq_restore(flags);
5782 + }
5783 +
5784 + smp_llsc_mb();
5785 +
5786 + return result;
5787 +}
5788 +static __inline__ int atomic_sub_return_unchecked(int i, atomic_unchecked_t *v)
5789 {
5790 int result;
5791
5792 @@ -238,7 +562,7 @@ static __inline__ int atomic_sub_return(int i, atomic_t * v)
5793 * Atomically test @v and subtract @i if @v is greater or equal than @i.
5794 * The function returns the old value of @v minus @i.
5795 */
5796 -static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5797 +static __inline__ int atomic_sub_if_positive(int i, atomic_t *v)
5798 {
5799 int result;
5800
5801 @@ -295,8 +619,26 @@ static __inline__ int atomic_sub_if_positive(int i, atomic_t * v)
5802 return result;
5803 }
5804
5805 -#define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
5806 -#define atomic_xchg(v, new) (xchg(&((v)->counter), (new)))
5807 +static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
5808 +{
5809 + return cmpxchg(&v->counter, old, new);
5810 +}
5811 +
5812 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old,
5813 + int new)
5814 +{
5815 + return cmpxchg(&(v->counter), old, new);
5816 +}
5817 +
5818 +static inline int atomic_xchg(atomic_t *v, int new)
5819 +{
5820 + return xchg(&v->counter, new);
5821 +}
5822 +
5823 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
5824 +{
5825 + return xchg(&(v->counter), new);
5826 +}
5827
5828 /**
5829 * __atomic_add_unless - add unless the number is a given value
5830 @@ -324,6 +666,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5831
5832 #define atomic_dec_return(v) atomic_sub_return(1, (v))
5833 #define atomic_inc_return(v) atomic_add_return(1, (v))
5834 +static __inline__ int atomic_inc_return_unchecked(atomic_unchecked_t *v)
5835 +{
5836 + return atomic_add_return_unchecked(1, v);
5837 +}
5838
5839 /*
5840 * atomic_sub_and_test - subtract value from variable and test result
5841 @@ -345,6 +691,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5842 * other cases.
5843 */
5844 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
5845 +static __inline__ int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
5846 +{
5847 + return atomic_add_return_unchecked(1, v) == 0;
5848 +}
5849
5850 /*
5851 * atomic_dec_and_test - decrement by 1 and test
5852 @@ -369,6 +719,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5853 * Atomically increments @v by 1.
5854 */
5855 #define atomic_inc(v) atomic_add(1, (v))
5856 +static __inline__ void atomic_inc_unchecked(atomic_unchecked_t *v)
5857 +{
5858 + atomic_add_unchecked(1, v);
5859 +}
5860
5861 /*
5862 * atomic_dec - decrement and test
5863 @@ -377,6 +731,10 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5864 * Atomically decrements @v by 1.
5865 */
5866 #define atomic_dec(v) atomic_sub(1, (v))
5867 +static __inline__ void atomic_dec_unchecked(atomic_unchecked_t *v)
5868 +{
5869 + atomic_sub_unchecked(1, v);
5870 +}
5871
5872 /*
5873 * atomic_add_negative - add and test if negative
5874 @@ -398,14 +756,30 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5875 * @v: pointer of type atomic64_t
5876 *
5877 */
5878 -#define atomic64_read(v) (*(volatile long *)&(v)->counter)
5879 +static inline long atomic64_read(const atomic64_t *v)
5880 +{
5881 + return (*(volatile const long *) &v->counter);
5882 +}
5883 +
5884 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
5885 +{
5886 + return (*(volatile const long *) &v->counter);
5887 +}
5888
5889 /*
5890 * atomic64_set - set atomic variable
5891 * @v: pointer of type atomic64_t
5892 * @i: required value
5893 */
5894 -#define atomic64_set(v, i) ((v)->counter = (i))
5895 +static inline void atomic64_set(atomic64_t *v, long i)
5896 +{
5897 + v->counter = i;
5898 +}
5899 +
5900 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
5901 +{
5902 + v->counter = i;
5903 +}
5904
5905 /*
5906 * atomic64_add - add integer to atomic variable
5907 @@ -414,7 +788,66 @@ static __inline__ int __atomic_add_unless(atomic_t *v, int a, int u)
5908 *
5909 * Atomically adds @i to @v.
5910 */
5911 -static __inline__ void atomic64_add(long i, atomic64_t * v)
5912 +static __inline__ void atomic64_add(long i, atomic64_t *v)
5913 +{
5914 + long temp;
5915 +
5916 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5917 + __asm__ __volatile__(
5918 + " .set mips3 \n"
5919 + "1: lld %0, %1 # atomic64_add \n"
5920 +#ifdef CONFIG_PAX_REFCOUNT
5921 + /* Exception on overflow. */
5922 + "2: dadd %0, %2 \n"
5923 +#else
5924 + " daddu %0, %2 \n"
5925 +#endif
5926 + " scd %0, %1 \n"
5927 + " beqzl %0, 1b \n"
5928 +#ifdef CONFIG_PAX_REFCOUNT
5929 + "3: \n"
5930 + _ASM_EXTABLE(2b, 3b)
5931 +#endif
5932 + " .set mips0 \n"
5933 + : "=&r" (temp), "+m" (v->counter)
5934 + : "Ir" (i));
5935 + } else if (kernel_uses_llsc) {
5936 + __asm__ __volatile__(
5937 + " .set mips3 \n"
5938 + "1: lld %0, %1 # atomic64_add \n"
5939 +#ifdef CONFIG_PAX_REFCOUNT
5940 + /* Exception on overflow. */
5941 + "2: dadd %0, %2 \n"
5942 +#else
5943 + " daddu %0, %2 \n"
5944 +#endif
5945 + " scd %0, %1 \n"
5946 + " beqz %0, 1b \n"
5947 +#ifdef CONFIG_PAX_REFCOUNT
5948 + "3: \n"
5949 + _ASM_EXTABLE(2b, 3b)
5950 +#endif
5951 + " .set mips0 \n"
5952 + : "=&r" (temp), "+m" (v->counter)
5953 + : "Ir" (i));
5954 + } else {
5955 + unsigned long flags;
5956 +
5957 + raw_local_irq_save(flags);
5958 + __asm__ __volatile__(
5959 +#ifdef CONFIG_PAX_REFCOUNT
5960 + /* Exception on overflow. */
5961 + "1: dadd %0, %1 \n"
5962 + "2: \n"
5963 + _ASM_EXTABLE(1b, 2b)
5964 +#else
5965 + " daddu %0, %1 \n"
5966 +#endif
5967 + : "+r" (v->counter) : "Ir" (i));
5968 + raw_local_irq_restore(flags);
5969 + }
5970 +}
5971 +static __inline__ void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
5972 {
5973 if (kernel_uses_llsc && R10000_LLSC_WAR) {
5974 long temp;
5975 @@ -457,7 +890,67 @@ static __inline__ void atomic64_add(long i, atomic64_t * v)
5976 *
5977 * Atomically subtracts @i from @v.
5978 */
5979 -static __inline__ void atomic64_sub(long i, atomic64_t * v)
5980 +static __inline__ void atomic64_sub(long i, atomic64_t *v)
5981 +{
5982 + long temp;
5983 +
5984 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
5985 + __asm__ __volatile__(
5986 + " .set mips3 \n"
5987 + "1: lld %0, %1 # atomic64_sub \n"
5988 +#ifdef CONFIG_PAX_REFCOUNT
5989 + /* Exception on overflow. */
5990 + "2: dsub %0, %2 \n"
5991 +#else
5992 + " dsubu %0, %2 \n"
5993 +#endif
5994 + " scd %0, %1 \n"
5995 + " beqzl %0, 1b \n"
5996 +#ifdef CONFIG_PAX_REFCOUNT
5997 + "3: \n"
5998 + _ASM_EXTABLE(2b, 3b)
5999 +#endif
6000 + " .set mips0 \n"
6001 + : "=&r" (temp), "+m" (v->counter)
6002 + : "Ir" (i));
6003 + } else if (kernel_uses_llsc) {
6004 + __asm__ __volatile__(
6005 + " .set mips3 \n"
6006 + "1: lld %0, %1 # atomic64_sub \n"
6007 +#ifdef CONFIG_PAX_REFCOUNT
6008 + /* Exception on overflow. */
6009 + "2: dsub %0, %2 \n"
6010 +#else
6011 + " dsubu %0, %2 \n"
6012 +#endif
6013 + " scd %0, %1 \n"
6014 + " beqz %0, 1b \n"
6015 +#ifdef CONFIG_PAX_REFCOUNT
6016 + "3: \n"
6017 + _ASM_EXTABLE(2b, 3b)
6018 +#endif
6019 + " .set mips0 \n"
6020 + : "=&r" (temp), "+m" (v->counter)
6021 + : "Ir" (i));
6022 + } else {
6023 + unsigned long flags;
6024 +
6025 + raw_local_irq_save(flags);
6026 + __asm__ __volatile__(
6027 +#ifdef CONFIG_PAX_REFCOUNT
6028 + /* Exception on overflow. */
6029 + "1: dsub %0, %1 \n"
6030 + "2: \n"
6031 + _ASM_EXTABLE(1b, 2b)
6032 +#else
6033 + " dsubu %0, %1 \n"
6034 +#endif
6035 + : "+r" (v->counter) : "Ir" (i));
6036 + raw_local_irq_restore(flags);
6037 + }
6038 +}
6039 +
6040 +static __inline__ void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
6041 {
6042 if (kernel_uses_llsc && R10000_LLSC_WAR) {
6043 long temp;
6044 @@ -496,7 +989,93 @@ static __inline__ void atomic64_sub(long i, atomic64_t * v)
6045 /*
6046 * Same as above, but return the result value
6047 */
6048 -static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6049 +static __inline__ long atomic64_add_return(long i, atomic64_t *v)
6050 +{
6051 + long result;
6052 + long temp;
6053 +
6054 + smp_mb__before_llsc();
6055 +
6056 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6057 + __asm__ __volatile__(
6058 + " .set mips3 \n"
6059 + "1: lld %1, %2 # atomic64_add_return \n"
6060 +#ifdef CONFIG_PAX_REFCOUNT
6061 + "2: dadd %0, %1, %3 \n"
6062 +#else
6063 + " daddu %0, %1, %3 \n"
6064 +#endif
6065 + " scd %0, %2 \n"
6066 + " beqzl %0, 1b \n"
6067 +#ifdef CONFIG_PAX_REFCOUNT
6068 + " b 4f \n"
6069 + " .set noreorder \n"
6070 + "3: b 5f \n"
6071 + " move %0, %1 \n"
6072 + " .set reorder \n"
6073 + _ASM_EXTABLE(2b, 3b)
6074 +#endif
6075 + "4: daddu %0, %1, %3 \n"
6076 +#ifdef CONFIG_PAX_REFCOUNT
6077 + "5: \n"
6078 +#endif
6079 + " .set mips0 \n"
6080 + : "=&r" (result), "=&r" (temp), "+m" (v->counter)
6081 + : "Ir" (i));
6082 + } else if (kernel_uses_llsc) {
6083 + __asm__ __volatile__(
6084 + " .set mips3 \n"
6085 + "1: lld %1, %2 # atomic64_add_return \n"
6086 +#ifdef CONFIG_PAX_REFCOUNT
6087 + "2: dadd %0, %1, %3 \n"
6088 +#else
6089 + " daddu %0, %1, %3 \n"
6090 +#endif
6091 + " scd %0, %2 \n"
6092 + " bnez %0, 4f \n"
6093 + " b 1b \n"
6094 +#ifdef CONFIG_PAX_REFCOUNT
6095 + " .set noreorder \n"
6096 + "3: b 5f \n"
6097 + " move %0, %1 \n"
6098 + " .set reorder \n"
6099 + _ASM_EXTABLE(2b, 3b)
6100 +#endif
6101 + "4: daddu %0, %1, %3 \n"
6102 +#ifdef CONFIG_PAX_REFCOUNT
6103 + "5: \n"
6104 +#endif
6105 + " .set mips0 \n"
6106 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6107 + : "Ir" (i), "m" (v->counter)
6108 + : "memory");
6109 + } else {
6110 + unsigned long flags;
6111 +
6112 + raw_local_irq_save(flags);
6113 + __asm__ __volatile__(
6114 + " ld %0, %1 \n"
6115 +#ifdef CONFIG_PAX_REFCOUNT
6116 + /* Exception on overflow. */
6117 + "1: dadd %0, %2 \n"
6118 +#else
6119 + " daddu %0, %2 \n"
6120 +#endif
6121 + " sd %0, %1 \n"
6122 +#ifdef CONFIG_PAX_REFCOUNT
6123 + /* Note: Dest reg is not modified on overflow */
6124 + "2: \n"
6125 + _ASM_EXTABLE(1b, 2b)
6126 +#endif
6127 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6128 + raw_local_irq_restore(flags);
6129 + }
6130 +
6131 + smp_llsc_mb();
6132 +
6133 + return result;
6134 +}
6135 +static __inline__ long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
6136 {
6137 long result;
6138
6139 @@ -546,7 +1125,97 @@ static __inline__ long atomic64_add_return(long i, atomic64_t * v)
6140 return result;
6141 }
6142
6143 -static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6144 +static __inline__ long atomic64_sub_return(long i, atomic64_t *v)
6145 +{
6146 + long result;
6147 + long temp;
6148 +
6149 + smp_mb__before_llsc();
6150 +
6151 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6152 + long temp;
6153 +
6154 + __asm__ __volatile__(
6155 + " .set mips3 \n"
6156 + "1: lld %1, %2 # atomic64_sub_return \n"
6157 +#ifdef CONFIG_PAX_REFCOUNT
6158 + "2: dsub %0, %1, %3 \n"
6159 +#else
6160 + " dsubu %0, %1, %3 \n"
6161 +#endif
6162 + " scd %0, %2 \n"
6163 + " beqzl %0, 1b \n"
6164 +#ifdef CONFIG_PAX_REFCOUNT
6165 + " b 4f \n"
6166 + " .set noreorder \n"
6167 + "3: b 5f \n"
6168 + " move %0, %1 \n"
6169 + " .set reorder \n"
6170 + _ASM_EXTABLE(2b, 3b)
6171 +#endif
6172 + "4: dsubu %0, %1, %3 \n"
6173 +#ifdef CONFIG_PAX_REFCOUNT
6174 + "5: \n"
6175 +#endif
6176 + " .set mips0 \n"
6177 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6178 + : "Ir" (i), "m" (v->counter)
6179 + : "memory");
6180 + } else if (kernel_uses_llsc) {
6181 + __asm__ __volatile__(
6182 + " .set mips3 \n"
6183 + "1: lld %1, %2 # atomic64_sub_return \n"
6184 +#ifdef CONFIG_PAX_REFCOUNT
6185 + "2: dsub %0, %1, %3 \n"
6186 +#else
6187 + " dsubu %0, %1, %3 \n"
6188 +#endif
6189 + " scd %0, %2 \n"
6190 + " bnez %0, 4f \n"
6191 + " b 1b \n"
6192 +#ifdef CONFIG_PAX_REFCOUNT
6193 + " .set noreorder \n"
6194 + "3: b 5f \n"
6195 + " move %0, %1 \n"
6196 + " .set reorder \n"
6197 + _ASM_EXTABLE(2b, 3b)
6198 +#endif
6199 + "4: dsubu %0, %1, %3 \n"
6200 +#ifdef CONFIG_PAX_REFCOUNT
6201 + "5: \n"
6202 +#endif
6203 + " .set mips0 \n"
6204 + : "=&r" (result), "=&r" (temp), "=m" (v->counter)
6205 + : "Ir" (i), "m" (v->counter)
6206 + : "memory");
6207 + } else {
6208 + unsigned long flags;
6209 +
6210 + raw_local_irq_save(flags);
6211 + __asm__ __volatile__(
6212 + " ld %0, %1 \n"
6213 +#ifdef CONFIG_PAX_REFCOUNT
6214 + /* Exception on overflow. */
6215 + "1: dsub %0, %2 \n"
6216 +#else
6217 + " dsubu %0, %2 \n"
6218 +#endif
6219 + " sd %0, %1 \n"
6220 +#ifdef CONFIG_PAX_REFCOUNT
6221 + /* Note: Dest reg is not modified on overflow */
6222 + "2: \n"
6223 + _ASM_EXTABLE(1b, 2b)
6224 +#endif
6225 + : "=&r" (result), "+m" (v->counter) : "Ir" (i));
6226 + raw_local_irq_restore(flags);
6227 + }
6228 +
6229 + smp_llsc_mb();
6230 +
6231 + return result;
6232 +}
6233 +
6234 +static __inline__ long atomic64_sub_return_unchecked(long i, atomic64_unchecked_t *v)
6235 {
6236 long result;
6237
6238 @@ -605,7 +1274,7 @@ static __inline__ long atomic64_sub_return(long i, atomic64_t * v)
6239 * Atomically test @v and subtract @i if @v is greater or equal than @i.
6240 * The function returns the old value of @v minus @i.
6241 */
6242 -static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6243 +static __inline__ long atomic64_sub_if_positive(long i, atomic64_t *v)
6244 {
6245 long result;
6246
6247 @@ -662,9 +1331,26 @@ static __inline__ long atomic64_sub_if_positive(long i, atomic64_t * v)
6248 return result;
6249 }
6250
6251 -#define atomic64_cmpxchg(v, o, n) \
6252 - ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
6253 -#define atomic64_xchg(v, new) (xchg(&((v)->counter), (new)))
6254 +static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
6255 +{
6256 + return cmpxchg(&v->counter, old, new);
6257 +}
6258 +
6259 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old,
6260 + long new)
6261 +{
6262 + return cmpxchg(&(v->counter), old, new);
6263 +}
6264 +
6265 +static inline long atomic64_xchg(atomic64_t *v, long new)
6266 +{
6267 + return xchg(&v->counter, new);
6268 +}
6269 +
6270 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
6271 +{
6272 + return xchg(&(v->counter), new);
6273 +}
6274
6275 /**
6276 * atomic64_add_unless - add unless the number is a given value
6277 @@ -694,6 +1380,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6278
6279 #define atomic64_dec_return(v) atomic64_sub_return(1, (v))
6280 #define atomic64_inc_return(v) atomic64_add_return(1, (v))
6281 +#define atomic64_inc_return_unchecked(v) atomic64_add_return_unchecked(1, (v))
6282
6283 /*
6284 * atomic64_sub_and_test - subtract value from variable and test result
6285 @@ -715,6 +1402,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6286 * other cases.
6287 */
6288 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
6289 +#define atomic64_inc_and_test_unchecked(v) atomic64_add_return_unchecked(1, (v)) == 0)
6290
6291 /*
6292 * atomic64_dec_and_test - decrement by 1 and test
6293 @@ -739,6 +1427,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6294 * Atomically increments @v by 1.
6295 */
6296 #define atomic64_inc(v) atomic64_add(1, (v))
6297 +#define atomic64_inc_unchecked(v) atomic64_add_unchecked(1, (v))
6298
6299 /*
6300 * atomic64_dec - decrement and test
6301 @@ -747,6 +1436,7 @@ static __inline__ int atomic64_add_unless(atomic64_t *v, long a, long u)
6302 * Atomically decrements @v by 1.
6303 */
6304 #define atomic64_dec(v) atomic64_sub(1, (v))
6305 +#define atomic64_dec_unchecked(v) atomic64_sub_unchecked(1, (v))
6306
6307 /*
6308 * atomic64_add_negative - add and test if negative
6309 diff --git a/arch/mips/include/asm/cache.h b/arch/mips/include/asm/cache.h
6310 index b4db69f..8f3b093 100644
6311 --- a/arch/mips/include/asm/cache.h
6312 +++ b/arch/mips/include/asm/cache.h
6313 @@ -9,10 +9,11 @@
6314 #ifndef _ASM_CACHE_H
6315 #define _ASM_CACHE_H
6316
6317 +#include <linux/const.h>
6318 #include <kmalloc.h>
6319
6320 #define L1_CACHE_SHIFT CONFIG_MIPS_L1_CACHE_SHIFT
6321 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
6322 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
6323
6324 #define SMP_CACHE_SHIFT L1_CACHE_SHIFT
6325 #define SMP_CACHE_BYTES L1_CACHE_BYTES
6326 diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h
6327 index cf3ae24..238d22f 100644
6328 --- a/arch/mips/include/asm/elf.h
6329 +++ b/arch/mips/include/asm/elf.h
6330 @@ -372,13 +372,16 @@ extern const char *__elf_platform;
6331 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
6332 #endif
6333
6334 +#ifdef CONFIG_PAX_ASLR
6335 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6336 +
6337 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6338 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6339 +#endif
6340 +
6341 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
6342 struct linux_binprm;
6343 extern int arch_setup_additional_pages(struct linux_binprm *bprm,
6344 int uses_interp);
6345
6346 -struct mm_struct;
6347 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
6348 -#define arch_randomize_brk arch_randomize_brk
6349 -
6350 #endif /* _ASM_ELF_H */
6351 diff --git a/arch/mips/include/asm/exec.h b/arch/mips/include/asm/exec.h
6352 index c1f6afa..38cc6e9 100644
6353 --- a/arch/mips/include/asm/exec.h
6354 +++ b/arch/mips/include/asm/exec.h
6355 @@ -12,6 +12,6 @@
6356 #ifndef _ASM_EXEC_H
6357 #define _ASM_EXEC_H
6358
6359 -extern unsigned long arch_align_stack(unsigned long sp);
6360 +#define arch_align_stack(x) ((x) & ~0xfUL)
6361
6362 #endif /* _ASM_EXEC_H */
6363 diff --git a/arch/mips/include/asm/local.h b/arch/mips/include/asm/local.h
6364 index d44622c..64990d2 100644
6365 --- a/arch/mips/include/asm/local.h
6366 +++ b/arch/mips/include/asm/local.h
6367 @@ -12,15 +12,25 @@ typedef struct
6368 atomic_long_t a;
6369 } local_t;
6370
6371 +typedef struct {
6372 + atomic_long_unchecked_t a;
6373 +} local_unchecked_t;
6374 +
6375 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
6376
6377 #define local_read(l) atomic_long_read(&(l)->a)
6378 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
6379 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
6380 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
6381
6382 #define local_add(i, l) atomic_long_add((i), (&(l)->a))
6383 +#define local_add_unchecked(i, l) atomic_long_add_unchecked((i), (&(l)->a))
6384 #define local_sub(i, l) atomic_long_sub((i), (&(l)->a))
6385 +#define local_sub_unchecked(i, l) atomic_long_sub_unchecked((i), (&(l)->a))
6386 #define local_inc(l) atomic_long_inc(&(l)->a)
6387 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
6388 #define local_dec(l) atomic_long_dec(&(l)->a)
6389 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
6390
6391 /*
6392 * Same as above, but return the result value
6393 @@ -70,6 +80,51 @@ static __inline__ long local_add_return(long i, local_t * l)
6394 return result;
6395 }
6396
6397 +static __inline__ long local_add_return_unchecked(long i, local_unchecked_t * l)
6398 +{
6399 + unsigned long result;
6400 +
6401 + if (kernel_uses_llsc && R10000_LLSC_WAR) {
6402 + unsigned long temp;
6403 +
6404 + __asm__ __volatile__(
6405 + " .set mips3 \n"
6406 + "1:" __LL "%1, %2 # local_add_return \n"
6407 + " addu %0, %1, %3 \n"
6408 + __SC "%0, %2 \n"
6409 + " beqzl %0, 1b \n"
6410 + " addu %0, %1, %3 \n"
6411 + " .set mips0 \n"
6412 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6413 + : "Ir" (i), "m" (l->a.counter)
6414 + : "memory");
6415 + } else if (kernel_uses_llsc) {
6416 + unsigned long temp;
6417 +
6418 + __asm__ __volatile__(
6419 + " .set mips3 \n"
6420 + "1:" __LL "%1, %2 # local_add_return \n"
6421 + " addu %0, %1, %3 \n"
6422 + __SC "%0, %2 \n"
6423 + " beqz %0, 1b \n"
6424 + " addu %0, %1, %3 \n"
6425 + " .set mips0 \n"
6426 + : "=&r" (result), "=&r" (temp), "=m" (l->a.counter)
6427 + : "Ir" (i), "m" (l->a.counter)
6428 + : "memory");
6429 + } else {
6430 + unsigned long flags;
6431 +
6432 + local_irq_save(flags);
6433 + result = l->a.counter;
6434 + result += i;
6435 + l->a.counter = result;
6436 + local_irq_restore(flags);
6437 + }
6438 +
6439 + return result;
6440 +}
6441 +
6442 static __inline__ long local_sub_return(long i, local_t * l)
6443 {
6444 unsigned long result;
6445 @@ -117,6 +172,8 @@ static __inline__ long local_sub_return(long i, local_t * l)
6446
6447 #define local_cmpxchg(l, o, n) \
6448 ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6449 +#define local_cmpxchg_unchecked(l, o, n) \
6450 + ((long)cmpxchg_local(&((l)->a.counter), (o), (n)))
6451 #define local_xchg(l, n) (atomic_long_xchg((&(l)->a), (n)))
6452
6453 /**
6454 diff --git a/arch/mips/include/asm/page.h b/arch/mips/include/asm/page.h
6455 index f6be474..12ad554 100644
6456 --- a/arch/mips/include/asm/page.h
6457 +++ b/arch/mips/include/asm/page.h
6458 @@ -95,7 +95,7 @@ extern void copy_user_highpage(struct page *to, struct page *from,
6459 #ifdef CONFIG_CPU_MIPS32
6460 typedef struct { unsigned long pte_low, pte_high; } pte_t;
6461 #define pte_val(x) ((x).pte_low | ((unsigned long long)(x).pte_high << 32))
6462 - #define __pte(x) ({ pte_t __pte = {(x), ((unsigned long long)(x)) >> 32}; __pte; })
6463 + #define __pte(x) ({ pte_t __pte = {(x), (x) >> 32}; __pte; })
6464 #else
6465 typedef struct { unsigned long long pte; } pte_t;
6466 #define pte_val(x) ((x).pte)
6467 diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h
6468 index 881d18b..cea38bc 100644
6469 --- a/arch/mips/include/asm/pgalloc.h
6470 +++ b/arch/mips/include/asm/pgalloc.h
6471 @@ -37,6 +37,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6472 {
6473 set_pud(pud, __pud((unsigned long)pmd));
6474 }
6475 +
6476 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
6477 +{
6478 + pud_populate(mm, pud, pmd);
6479 +}
6480 #endif
6481
6482 /*
6483 diff --git a/arch/mips/include/asm/smtc_proc.h b/arch/mips/include/asm/smtc_proc.h
6484 index 25da651..ae2a259 100644
6485 --- a/arch/mips/include/asm/smtc_proc.h
6486 +++ b/arch/mips/include/asm/smtc_proc.h
6487 @@ -18,6 +18,6 @@ extern struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6488
6489 /* Count of number of recoveries of "stolen" FPU access rights on 34K */
6490
6491 -extern atomic_t smtc_fpu_recoveries;
6492 +extern atomic_unchecked_t smtc_fpu_recoveries;
6493
6494 #endif /* __ASM_SMTC_PROC_H */
6495 diff --git a/arch/mips/include/asm/thread_info.h b/arch/mips/include/asm/thread_info.h
6496 index 61215a3..213ee0e 100644
6497 --- a/arch/mips/include/asm/thread_info.h
6498 +++ b/arch/mips/include/asm/thread_info.h
6499 @@ -116,6 +116,8 @@ static inline struct thread_info *current_thread_info(void)
6500 #define TIF_32BIT_ADDR 23 /* 32-bit address space (o32/n32) */
6501 #define TIF_FPUBOUND 24 /* thread bound to FPU-full CPU set */
6502 #define TIF_LOAD_WATCH 25 /* If set, load watch registers */
6503 +/* li takes a 32bit immediate */
6504 +#define TIF_GRSEC_SETXID 29 /* update credentials on syscall entry/exit */
6505 #define TIF_SYSCALL_TRACE 31 /* syscall trace active */
6506
6507 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
6508 @@ -132,20 +134,18 @@ static inline struct thread_info *current_thread_info(void)
6509 #define _TIF_32BIT_ADDR (1<<TIF_32BIT_ADDR)
6510 #define _TIF_FPUBOUND (1<<TIF_FPUBOUND)
6511 #define _TIF_LOAD_WATCH (1<<TIF_LOAD_WATCH)
6512 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
6513
6514 -#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6515 - _TIF_SYSCALL_AUDIT)
6516 +#define _TIF_WORK_SYSCALL_ENTRY (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6517
6518 /* work to do in syscall_trace_leave() */
6519 -#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | \
6520 - _TIF_SYSCALL_AUDIT)
6521 +#define _TIF_WORK_SYSCALL_EXIT (_TIF_NOHZ | _TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_GRSEC_SETXID)
6522
6523 /* work to do on interrupt/exception return */
6524 #define _TIF_WORK_MASK \
6525 (_TIF_SIGPENDING | _TIF_NEED_RESCHED | _TIF_NOTIFY_RESUME)
6526 /* work to do on any return to u-space */
6527 -#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | \
6528 - _TIF_WORK_SYSCALL_EXIT)
6529 +#define _TIF_ALLWORK_MASK (_TIF_NOHZ | _TIF_WORK_MASK | _TIF_WORK_SYSCALL_EXIT | _TIF_GRSEC_SETXID)
6530
6531 #endif /* __KERNEL__ */
6532
6533 diff --git a/arch/mips/kernel/binfmt_elfn32.c b/arch/mips/kernel/binfmt_elfn32.c
6534 index 1188e00..41cf144 100644
6535 --- a/arch/mips/kernel/binfmt_elfn32.c
6536 +++ b/arch/mips/kernel/binfmt_elfn32.c
6537 @@ -50,6 +50,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6538 #undef ELF_ET_DYN_BASE
6539 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6540
6541 +#ifdef CONFIG_PAX_ASLR
6542 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6543 +
6544 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6545 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6546 +#endif
6547 +
6548 #include <asm/processor.h>
6549 #include <linux/module.h>
6550 #include <linux/elfcore.h>
6551 diff --git a/arch/mips/kernel/binfmt_elfo32.c b/arch/mips/kernel/binfmt_elfo32.c
6552 index 202e581..689ca79 100644
6553 --- a/arch/mips/kernel/binfmt_elfo32.c
6554 +++ b/arch/mips/kernel/binfmt_elfo32.c
6555 @@ -56,6 +56,13 @@ typedef elf_fpreg_t elf_fpregset_t[ELF_NFPREG];
6556 #undef ELF_ET_DYN_BASE
6557 #define ELF_ET_DYN_BASE (TASK32_SIZE / 3 * 2)
6558
6559 +#ifdef CONFIG_PAX_ASLR
6560 +#define PAX_ELF_ET_DYN_BASE (TASK_IS_32BIT_ADDR ? 0x00400000UL : 0x00400000UL)
6561 +
6562 +#define PAX_DELTA_MMAP_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6563 +#define PAX_DELTA_STACK_LEN (TASK_IS_32BIT_ADDR ? 27-PAGE_SHIFT : 36-PAGE_SHIFT)
6564 +#endif
6565 +
6566 #include <asm/processor.h>
6567
6568 /*
6569 diff --git a/arch/mips/kernel/irq.c b/arch/mips/kernel/irq.c
6570 index d1fea7a..45602ea 100644
6571 --- a/arch/mips/kernel/irq.c
6572 +++ b/arch/mips/kernel/irq.c
6573 @@ -77,17 +77,17 @@ void ack_bad_irq(unsigned int irq)
6574 printk("unexpected IRQ # %d\n", irq);
6575 }
6576
6577 -atomic_t irq_err_count;
6578 +atomic_unchecked_t irq_err_count;
6579
6580 int arch_show_interrupts(struct seq_file *p, int prec)
6581 {
6582 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
6583 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
6584 return 0;
6585 }
6586
6587 asmlinkage void spurious_interrupt(void)
6588 {
6589 - atomic_inc(&irq_err_count);
6590 + atomic_inc_unchecked(&irq_err_count);
6591 }
6592
6593 void __init init_IRQ(void)
6594 diff --git a/arch/mips/kernel/process.c b/arch/mips/kernel/process.c
6595 index ddc7610..8c58f17 100644
6596 --- a/arch/mips/kernel/process.c
6597 +++ b/arch/mips/kernel/process.c
6598 @@ -566,15 +566,3 @@ unsigned long get_wchan(struct task_struct *task)
6599 out:
6600 return pc;
6601 }
6602 -
6603 -/*
6604 - * Don't forget that the stack pointer must be aligned on a 8 bytes
6605 - * boundary for 32-bits ABI and 16 bytes for 64-bits ABI.
6606 - */
6607 -unsigned long arch_align_stack(unsigned long sp)
6608 -{
6609 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
6610 - sp -= get_random_int() & ~PAGE_MASK;
6611 -
6612 - return sp & ALMASK;
6613 -}
6614 diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c
6615 index 8ae1ebe..1bcbf47 100644
6616 --- a/arch/mips/kernel/ptrace.c
6617 +++ b/arch/mips/kernel/ptrace.c
6618 @@ -529,6 +529,10 @@ static inline int audit_arch(void)
6619 return arch;
6620 }
6621
6622 +#ifdef CONFIG_GRKERNSEC_SETXID
6623 +extern void gr_delayed_cred_worker(void);
6624 +#endif
6625 +
6626 /*
6627 * Notification of system call entry/exit
6628 * - triggered by current->work.syscall_trace
6629 @@ -540,6 +544,11 @@ asmlinkage void syscall_trace_enter(struct pt_regs *regs)
6630 /* do the secure computing check first */
6631 secure_computing_strict(regs->regs[2]);
6632
6633 +#ifdef CONFIG_GRKERNSEC_SETXID
6634 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
6635 + gr_delayed_cred_worker();
6636 +#endif
6637 +
6638 if (!(current->ptrace & PT_PTRACED))
6639 goto out;
6640
6641 diff --git a/arch/mips/kernel/smtc-proc.c b/arch/mips/kernel/smtc-proc.c
6642 index c10aa84..9ec2e60 100644
6643 --- a/arch/mips/kernel/smtc-proc.c
6644 +++ b/arch/mips/kernel/smtc-proc.c
6645 @@ -31,7 +31,7 @@ unsigned long selfipis[NR_CPUS];
6646
6647 struct smtc_cpu_proc smtc_cpu_stats[NR_CPUS];
6648
6649 -atomic_t smtc_fpu_recoveries;
6650 +atomic_unchecked_t smtc_fpu_recoveries;
6651
6652 static int smtc_proc_show(struct seq_file *m, void *v)
6653 {
6654 @@ -48,7 +48,7 @@ static int smtc_proc_show(struct seq_file *m, void *v)
6655 for(i = 0; i < NR_CPUS; i++)
6656 seq_printf(m, "%d: %ld\n", i, smtc_cpu_stats[i].selfipis);
6657 seq_printf(m, "%d Recoveries of \"stolen\" FPU\n",
6658 - atomic_read(&smtc_fpu_recoveries));
6659 + atomic_read_unchecked(&smtc_fpu_recoveries));
6660 return 0;
6661 }
6662
6663 @@ -73,7 +73,7 @@ void init_smtc_stats(void)
6664 smtc_cpu_stats[i].selfipis = 0;
6665 }
6666
6667 - atomic_set(&smtc_fpu_recoveries, 0);
6668 + atomic_set_unchecked(&smtc_fpu_recoveries, 0);
6669
6670 proc_create("smtc", 0444, NULL, &smtc_proc_fops);
6671 }
6672 diff --git a/arch/mips/kernel/smtc.c b/arch/mips/kernel/smtc.c
6673 index dfc1b91..11a2c07 100644
6674 --- a/arch/mips/kernel/smtc.c
6675 +++ b/arch/mips/kernel/smtc.c
6676 @@ -1359,7 +1359,7 @@ void smtc_soft_dump(void)
6677 }
6678 smtc_ipi_qdump();
6679 printk("%d Recoveries of \"stolen\" FPU\n",
6680 - atomic_read(&smtc_fpu_recoveries));
6681 + atomic_read_unchecked(&smtc_fpu_recoveries));
6682 }
6683
6684
6685 diff --git a/arch/mips/kernel/sync-r4k.c b/arch/mips/kernel/sync-r4k.c
6686 index 84536bf..79caa4d 100644
6687 --- a/arch/mips/kernel/sync-r4k.c
6688 +++ b/arch/mips/kernel/sync-r4k.c
6689 @@ -21,8 +21,8 @@
6690 #include <asm/mipsregs.h>
6691
6692 static atomic_t count_start_flag = ATOMIC_INIT(0);
6693 -static atomic_t count_count_start = ATOMIC_INIT(0);
6694 -static atomic_t count_count_stop = ATOMIC_INIT(0);
6695 +static atomic_unchecked_t count_count_start = ATOMIC_INIT(0);
6696 +static atomic_unchecked_t count_count_stop = ATOMIC_INIT(0);
6697 static atomic_t count_reference = ATOMIC_INIT(0);
6698
6699 #define COUNTON 100
6700 @@ -69,13 +69,13 @@ void synchronise_count_master(int cpu)
6701
6702 for (i = 0; i < NR_LOOPS; i++) {
6703 /* slaves loop on '!= 2' */
6704 - while (atomic_read(&count_count_start) != 1)
6705 + while (atomic_read_unchecked(&count_count_start) != 1)
6706 mb();
6707 - atomic_set(&count_count_stop, 0);
6708 + atomic_set_unchecked(&count_count_stop, 0);
6709 smp_wmb();
6710
6711 /* this lets the slaves write their count register */
6712 - atomic_inc(&count_count_start);
6713 + atomic_inc_unchecked(&count_count_start);
6714
6715 /*
6716 * Everyone initialises count in the last loop:
6717 @@ -86,11 +86,11 @@ void synchronise_count_master(int cpu)
6718 /*
6719 * Wait for all slaves to leave the synchronization point:
6720 */
6721 - while (atomic_read(&count_count_stop) != 1)
6722 + while (atomic_read_unchecked(&count_count_stop) != 1)
6723 mb();
6724 - atomic_set(&count_count_start, 0);
6725 + atomic_set_unchecked(&count_count_start, 0);
6726 smp_wmb();
6727 - atomic_inc(&count_count_stop);
6728 + atomic_inc_unchecked(&count_count_stop);
6729 }
6730 /* Arrange for an interrupt in a short while */
6731 write_c0_compare(read_c0_count() + COUNTON);
6732 @@ -131,8 +131,8 @@ void synchronise_count_slave(int cpu)
6733 initcount = atomic_read(&count_reference);
6734
6735 for (i = 0; i < NR_LOOPS; i++) {
6736 - atomic_inc(&count_count_start);
6737 - while (atomic_read(&count_count_start) != 2)
6738 + atomic_inc_unchecked(&count_count_start);
6739 + while (atomic_read_unchecked(&count_count_start) != 2)
6740 mb();
6741
6742 /*
6743 @@ -141,8 +141,8 @@ void synchronise_count_slave(int cpu)
6744 if (i == NR_LOOPS-1)
6745 write_c0_count(initcount);
6746
6747 - atomic_inc(&count_count_stop);
6748 - while (atomic_read(&count_count_stop) != 2)
6749 + atomic_inc_unchecked(&count_count_stop);
6750 + while (atomic_read_unchecked(&count_count_stop) != 2)
6751 mb();
6752 }
6753 /* Arrange for an interrupt in a short while */
6754 diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
6755 index 524841f..3eef41e 100644
6756 --- a/arch/mips/kernel/traps.c
6757 +++ b/arch/mips/kernel/traps.c
6758 @@ -684,7 +684,18 @@ asmlinkage void do_ov(struct pt_regs *regs)
6759 siginfo_t info;
6760
6761 prev_state = exception_enter();
6762 - die_if_kernel("Integer overflow", regs);
6763 + if (unlikely(!user_mode(regs))) {
6764 +
6765 +#ifdef CONFIG_PAX_REFCOUNT
6766 + if (fixup_exception(regs)) {
6767 + pax_report_refcount_overflow(regs);
6768 + exception_exit(prev_state);
6769 + return;
6770 + }
6771 +#endif
6772 +
6773 + die("Integer overflow", regs);
6774 + }
6775
6776 info.si_code = FPE_INTOVF;
6777 info.si_signo = SIGFPE;
6778 diff --git a/arch/mips/mm/fault.c b/arch/mips/mm/fault.c
6779 index becc42b..9e43d4b 100644
6780 --- a/arch/mips/mm/fault.c
6781 +++ b/arch/mips/mm/fault.c
6782 @@ -28,6 +28,23 @@
6783 #include <asm/highmem.h> /* For VMALLOC_END */
6784 #include <linux/kdebug.h>
6785
6786 +#ifdef CONFIG_PAX_PAGEEXEC
6787 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
6788 +{
6789 + unsigned long i;
6790 +
6791 + printk(KERN_ERR "PAX: bytes at PC: ");
6792 + for (i = 0; i < 5; i++) {
6793 + unsigned int c;
6794 + if (get_user(c, (unsigned int *)pc+i))
6795 + printk(KERN_CONT "???????? ");
6796 + else
6797 + printk(KERN_CONT "%08x ", c);
6798 + }
6799 + printk("\n");
6800 +}
6801 +#endif
6802 +
6803 /*
6804 * This routine handles page faults. It determines the address,
6805 * and the problem, and then passes it off to one of the appropriate
6806 @@ -199,6 +216,14 @@ bad_area:
6807 bad_area_nosemaphore:
6808 /* User mode accesses just cause a SIGSEGV */
6809 if (user_mode(regs)) {
6810 +
6811 +#ifdef CONFIG_PAX_PAGEEXEC
6812 + if (cpu_has_rixi && (mm->pax_flags & MF_PAX_PAGEEXEC) && !write && address == instruction_pointer(regs)) {
6813 + pax_report_fault(regs, (void *)address, (void *)user_stack_pointer(regs));
6814 + do_group_exit(SIGKILL);
6815 + }
6816 +#endif
6817 +
6818 tsk->thread.cp0_badvaddr = address;
6819 tsk->thread.error_code = write;
6820 #if 0
6821 diff --git a/arch/mips/mm/mmap.c b/arch/mips/mm/mmap.c
6822 index f1baadd..8537544 100644
6823 --- a/arch/mips/mm/mmap.c
6824 +++ b/arch/mips/mm/mmap.c
6825 @@ -59,6 +59,7 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6826 struct vm_area_struct *vma;
6827 unsigned long addr = addr0;
6828 int do_color_align;
6829 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
6830 struct vm_unmapped_area_info info;
6831
6832 if (unlikely(len > TASK_SIZE))
6833 @@ -84,6 +85,11 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6834 do_color_align = 1;
6835
6836 /* requesting a specific address */
6837 +
6838 +#ifdef CONFIG_PAX_RANDMMAP
6839 + if (!(current->mm->pax_flags & MF_PAX_RANDMMAP))
6840 +#endif
6841 +
6842 if (addr) {
6843 if (do_color_align)
6844 addr = COLOUR_ALIGN(addr, pgoff);
6845 @@ -91,14 +97,14 @@ static unsigned long arch_get_unmapped_area_common(struct file *filp,
6846 addr = PAGE_ALIGN(addr);
6847
6848 vma = find_vma(mm, addr);
6849 - if (TASK_SIZE - len >= addr &&
6850 - (!vma || addr + len <= vma->vm_start))
6851 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vmm, addr, len, offset))
6852 return addr;
6853 }
6854
6855 info.length = len;
6856 info.align_mask = do_color_align ? (PAGE_MASK & shm_align_mask) : 0;
6857 info.align_offset = pgoff << PAGE_SHIFT;
6858 + info.threadstack_offset = offset;
6859
6860 if (dir == DOWN) {
6861 info.flags = VM_UNMAPPED_AREA_TOPDOWN;
6862 @@ -146,6 +152,10 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6863 {
6864 unsigned long random_factor = 0UL;
6865
6866 +#ifdef CONFIG_PAX_RANDMMAP
6867 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
6868 +#endif
6869 +
6870 if (current->flags & PF_RANDOMIZE) {
6871 random_factor = get_random_int();
6872 random_factor = random_factor << PAGE_SHIFT;
6873 @@ -157,40 +167,25 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
6874
6875 if (mmap_is_legacy()) {
6876 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
6877 +
6878 +#ifdef CONFIG_PAX_RANDMMAP
6879 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6880 + mm->mmap_base += mm->delta_mmap;
6881 +#endif
6882 +
6883 mm->get_unmapped_area = arch_get_unmapped_area;
6884 } else {
6885 mm->mmap_base = mmap_base(random_factor);
6886 +
6887 +#ifdef CONFIG_PAX_RANDMMAP
6888 + if (mm->pax_flags & MF_PAX_RANDMMAP)
6889 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
6890 +#endif
6891 +
6892 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
6893 }
6894 }
6895
6896 -static inline unsigned long brk_rnd(void)
6897 -{
6898 - unsigned long rnd = get_random_int();
6899 -
6900 - rnd = rnd << PAGE_SHIFT;
6901 - /* 8MB for 32bit, 256MB for 64bit */
6902 - if (TASK_IS_32BIT_ADDR)
6903 - rnd = rnd & 0x7ffffful;
6904 - else
6905 - rnd = rnd & 0xffffffful;
6906 -
6907 - return rnd;
6908 -}
6909 -
6910 -unsigned long arch_randomize_brk(struct mm_struct *mm)
6911 -{
6912 - unsigned long base = mm->brk;
6913 - unsigned long ret;
6914 -
6915 - ret = PAGE_ALIGN(base + brk_rnd());
6916 -
6917 - if (ret < mm->brk)
6918 - return mm->brk;
6919 -
6920 - return ret;
6921 -}
6922 -
6923 int __virt_addr_valid(const volatile void *kaddr)
6924 {
6925 return pfn_valid(PFN_DOWN(virt_to_phys(kaddr)));
6926 diff --git a/arch/mips/sgi-ip27/ip27-nmi.c b/arch/mips/sgi-ip27/ip27-nmi.c
6927 index a2358b4..7cead4f 100644
6928 --- a/arch/mips/sgi-ip27/ip27-nmi.c
6929 +++ b/arch/mips/sgi-ip27/ip27-nmi.c
6930 @@ -187,9 +187,9 @@ void
6931 cont_nmi_dump(void)
6932 {
6933 #ifndef REAL_NMI_SIGNAL
6934 - static atomic_t nmied_cpus = ATOMIC_INIT(0);
6935 + static atomic_unchecked_t nmied_cpus = ATOMIC_INIT(0);
6936
6937 - atomic_inc(&nmied_cpus);
6938 + atomic_inc_unchecked(&nmied_cpus);
6939 #endif
6940 /*
6941 * Only allow 1 cpu to proceed
6942 @@ -233,7 +233,7 @@ cont_nmi_dump(void)
6943 udelay(10000);
6944 }
6945 #else
6946 - while (atomic_read(&nmied_cpus) != num_online_cpus());
6947 + while (atomic_read_unchecked(&nmied_cpus) != num_online_cpus());
6948 #endif
6949
6950 /*
6951 diff --git a/arch/mn10300/proc-mn103e010/include/proc/cache.h b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6952 index 967d144..db12197 100644
6953 --- a/arch/mn10300/proc-mn103e010/include/proc/cache.h
6954 +++ b/arch/mn10300/proc-mn103e010/include/proc/cache.h
6955 @@ -11,12 +11,14 @@
6956 #ifndef _ASM_PROC_CACHE_H
6957 #define _ASM_PROC_CACHE_H
6958
6959 +#include <linux/const.h>
6960 +
6961 /* L1 cache */
6962
6963 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6964 #define L1_CACHE_NENTRIES 256 /* number of entries in each way */
6965 -#define L1_CACHE_BYTES 16 /* bytes per entry */
6966 #define L1_CACHE_SHIFT 4 /* shift for bytes per entry */
6967 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6968 #define L1_CACHE_WAYDISP 0x1000 /* displacement of one way from the next */
6969
6970 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6971 diff --git a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6972 index bcb5df2..84fabd2 100644
6973 --- a/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6974 +++ b/arch/mn10300/proc-mn2ws0050/include/proc/cache.h
6975 @@ -16,13 +16,15 @@
6976 #ifndef _ASM_PROC_CACHE_H
6977 #define _ASM_PROC_CACHE_H
6978
6979 +#include <linux/const.h>
6980 +
6981 /*
6982 * L1 cache
6983 */
6984 #define L1_CACHE_NWAYS 4 /* number of ways in caches */
6985 #define L1_CACHE_NENTRIES 128 /* number of entries in each way */
6986 -#define L1_CACHE_BYTES 32 /* bytes per entry */
6987 #define L1_CACHE_SHIFT 5 /* shift for bytes per entry */
6988 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT) /* bytes per entry */
6989 #define L1_CACHE_WAYDISP 0x1000 /* distance from one way to the next */
6990
6991 #define L1_CACHE_TAG_VALID 0x00000001 /* cache tag valid bit */
6992 diff --git a/arch/openrisc/include/asm/cache.h b/arch/openrisc/include/asm/cache.h
6993 index 4ce7a01..449202a 100644
6994 --- a/arch/openrisc/include/asm/cache.h
6995 +++ b/arch/openrisc/include/asm/cache.h
6996 @@ -19,11 +19,13 @@
6997 #ifndef __ASM_OPENRISC_CACHE_H
6998 #define __ASM_OPENRISC_CACHE_H
6999
7000 +#include <linux/const.h>
7001 +
7002 /* FIXME: How can we replace these with values from the CPU...
7003 * they shouldn't be hard-coded!
7004 */
7005
7006 -#define L1_CACHE_BYTES 16
7007 #define L1_CACHE_SHIFT 4
7008 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7009
7010 #endif /* __ASM_OPENRISC_CACHE_H */
7011 diff --git a/arch/parisc/include/asm/atomic.h b/arch/parisc/include/asm/atomic.h
7012 index 472886c..00e7df9 100644
7013 --- a/arch/parisc/include/asm/atomic.h
7014 +++ b/arch/parisc/include/asm/atomic.h
7015 @@ -252,6 +252,16 @@ static inline long atomic64_dec_if_positive(atomic64_t *v)
7016 return dec;
7017 }
7018
7019 +#define atomic64_read_unchecked(v) atomic64_read(v)
7020 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7021 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7022 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7023 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7024 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7025 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7026 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7027 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7028 +
7029 #endif /* !CONFIG_64BIT */
7030
7031
7032 diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
7033 index 47f11c7..3420df2 100644
7034 --- a/arch/parisc/include/asm/cache.h
7035 +++ b/arch/parisc/include/asm/cache.h
7036 @@ -5,6 +5,7 @@
7037 #ifndef __ARCH_PARISC_CACHE_H
7038 #define __ARCH_PARISC_CACHE_H
7039
7040 +#include <linux/const.h>
7041
7042 /*
7043 * PA 2.0 processors have 64-byte cachelines; PA 1.1 processors have
7044 @@ -15,13 +16,13 @@
7045 * just ruin performance.
7046 */
7047 #ifdef CONFIG_PA20
7048 -#define L1_CACHE_BYTES 64
7049 #define L1_CACHE_SHIFT 6
7050 #else
7051 -#define L1_CACHE_BYTES 32
7052 #define L1_CACHE_SHIFT 5
7053 #endif
7054
7055 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7056 +
7057 #ifndef __ASSEMBLY__
7058
7059 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7060 diff --git a/arch/parisc/include/asm/elf.h b/arch/parisc/include/asm/elf.h
7061 index ad2b503..bdf1651 100644
7062 --- a/arch/parisc/include/asm/elf.h
7063 +++ b/arch/parisc/include/asm/elf.h
7064 @@ -342,6 +342,13 @@ struct pt_regs; /* forward declaration... */
7065
7066 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE + 0x01000000)
7067
7068 +#ifdef CONFIG_PAX_ASLR
7069 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
7070 +
7071 +#define PAX_DELTA_MMAP_LEN 16
7072 +#define PAX_DELTA_STACK_LEN 16
7073 +#endif
7074 +
7075 /* This yields a mask that user programs can use to figure out what
7076 instruction set this CPU supports. This could be done in user space,
7077 but it's not easy, and we've already done it here. */
7078 diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h
7079 index fc987a1..6e068ef 100644
7080 --- a/arch/parisc/include/asm/pgalloc.h
7081 +++ b/arch/parisc/include/asm/pgalloc.h
7082 @@ -61,6 +61,11 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7083 (__u32)(__pa((unsigned long)pmd) >> PxD_VALUE_SHIFT));
7084 }
7085
7086 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmd)
7087 +{
7088 + pgd_populate(mm, pgd, pmd);
7089 +}
7090 +
7091 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
7092 {
7093 pmd_t *pmd = (pmd_t *)__get_free_pages(GFP_KERNEL|__GFP_REPEAT,
7094 @@ -93,6 +98,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
7095 #define pmd_alloc_one(mm, addr) ({ BUG(); ((pmd_t *)2); })
7096 #define pmd_free(mm, x) do { } while (0)
7097 #define pgd_populate(mm, pmd, pte) BUG()
7098 +#define pgd_populate_kernel(mm, pmd, pte) BUG()
7099
7100 #endif
7101
7102 diff --git a/arch/parisc/include/asm/pgtable.h b/arch/parisc/include/asm/pgtable.h
7103 index 34899b5..02dd060 100644
7104 --- a/arch/parisc/include/asm/pgtable.h
7105 +++ b/arch/parisc/include/asm/pgtable.h
7106 @@ -223,6 +223,17 @@ extern void purge_tlb_entries(struct mm_struct *, unsigned long);
7107 #define PAGE_EXECREAD __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_EXEC |_PAGE_ACCESSED)
7108 #define PAGE_COPY PAGE_EXECREAD
7109 #define PAGE_RWX __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_EXEC |_PAGE_ACCESSED)
7110 +
7111 +#ifdef CONFIG_PAX_PAGEEXEC
7112 +# define PAGE_SHARED_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_WRITE | _PAGE_ACCESSED)
7113 +# define PAGE_COPY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7114 +# define PAGE_READONLY_NOEXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | _PAGE_READ | _PAGE_ACCESSED)
7115 +#else
7116 +# define PAGE_SHARED_NOEXEC PAGE_SHARED
7117 +# define PAGE_COPY_NOEXEC PAGE_COPY
7118 +# define PAGE_READONLY_NOEXEC PAGE_READONLY
7119 +#endif
7120 +
7121 #define PAGE_KERNEL __pgprot(_PAGE_KERNEL)
7122 #define PAGE_KERNEL_EXEC __pgprot(_PAGE_KERNEL_EXEC)
7123 #define PAGE_KERNEL_RWX __pgprot(_PAGE_KERNEL_RWX)
7124 diff --git a/arch/parisc/include/asm/uaccess.h b/arch/parisc/include/asm/uaccess.h
7125 index e0a8235..ce2f1e1 100644
7126 --- a/arch/parisc/include/asm/uaccess.h
7127 +++ b/arch/parisc/include/asm/uaccess.h
7128 @@ -245,10 +245,10 @@ static inline unsigned long __must_check copy_from_user(void *to,
7129 const void __user *from,
7130 unsigned long n)
7131 {
7132 - int sz = __compiletime_object_size(to);
7133 + size_t sz = __compiletime_object_size(to);
7134 int ret = -EFAULT;
7135
7136 - if (likely(sz == -1 || !__builtin_constant_p(n) || sz >= n))
7137 + if (likely(sz == (size_t)-1 || !__builtin_constant_p(n) || sz >= n))
7138 ret = __copy_from_user(to, from, n);
7139 else
7140 copy_from_user_overflow();
7141 diff --git a/arch/parisc/kernel/module.c b/arch/parisc/kernel/module.c
7142 index 2a625fb..9908930 100644
7143 --- a/arch/parisc/kernel/module.c
7144 +++ b/arch/parisc/kernel/module.c
7145 @@ -98,16 +98,38 @@
7146
7147 /* three functions to determine where in the module core
7148 * or init pieces the location is */
7149 +static inline int in_init_rx(struct module *me, void *loc)
7150 +{
7151 + return (loc >= me->module_init_rx &&
7152 + loc < (me->module_init_rx + me->init_size_rx));
7153 +}
7154 +
7155 +static inline int in_init_rw(struct module *me, void *loc)
7156 +{
7157 + return (loc >= me->module_init_rw &&
7158 + loc < (me->module_init_rw + me->init_size_rw));
7159 +}
7160 +
7161 static inline int in_init(struct module *me, void *loc)
7162 {
7163 - return (loc >= me->module_init &&
7164 - loc <= (me->module_init + me->init_size));
7165 + return in_init_rx(me, loc) || in_init_rw(me, loc);
7166 +}
7167 +
7168 +static inline int in_core_rx(struct module *me, void *loc)
7169 +{
7170 + return (loc >= me->module_core_rx &&
7171 + loc < (me->module_core_rx + me->core_size_rx));
7172 +}
7173 +
7174 +static inline int in_core_rw(struct module *me, void *loc)
7175 +{
7176 + return (loc >= me->module_core_rw &&
7177 + loc < (me->module_core_rw + me->core_size_rw));
7178 }
7179
7180 static inline int in_core(struct module *me, void *loc)
7181 {
7182 - return (loc >= me->module_core &&
7183 - loc <= (me->module_core + me->core_size));
7184 + return in_core_rx(me, loc) || in_core_rw(me, loc);
7185 }
7186
7187 static inline int in_local(struct module *me, void *loc)
7188 @@ -371,13 +393,13 @@ int module_frob_arch_sections(CONST Elf_Ehdr *hdr,
7189 }
7190
7191 /* align things a bit */
7192 - me->core_size = ALIGN(me->core_size, 16);
7193 - me->arch.got_offset = me->core_size;
7194 - me->core_size += gots * sizeof(struct got_entry);
7195 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7196 + me->arch.got_offset = me->core_size_rw;
7197 + me->core_size_rw += gots * sizeof(struct got_entry);
7198
7199 - me->core_size = ALIGN(me->core_size, 16);
7200 - me->arch.fdesc_offset = me->core_size;
7201 - me->core_size += fdescs * sizeof(Elf_Fdesc);
7202 + me->core_size_rw = ALIGN(me->core_size_rw, 16);
7203 + me->arch.fdesc_offset = me->core_size_rw;
7204 + me->core_size_rw += fdescs * sizeof(Elf_Fdesc);
7205
7206 me->arch.got_max = gots;
7207 me->arch.fdesc_max = fdescs;
7208 @@ -395,7 +417,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7209
7210 BUG_ON(value == 0);
7211
7212 - got = me->module_core + me->arch.got_offset;
7213 + got = me->module_core_rw + me->arch.got_offset;
7214 for (i = 0; got[i].addr; i++)
7215 if (got[i].addr == value)
7216 goto out;
7217 @@ -413,7 +435,7 @@ static Elf64_Word get_got(struct module *me, unsigned long value, long addend)
7218 #ifdef CONFIG_64BIT
7219 static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7220 {
7221 - Elf_Fdesc *fdesc = me->module_core + me->arch.fdesc_offset;
7222 + Elf_Fdesc *fdesc = me->module_core_rw + me->arch.fdesc_offset;
7223
7224 if (!value) {
7225 printk(KERN_ERR "%s: zero OPD requested!\n", me->name);
7226 @@ -431,7 +453,7 @@ static Elf_Addr get_fdesc(struct module *me, unsigned long value)
7227
7228 /* Create new one */
7229 fdesc->addr = value;
7230 - fdesc->gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7231 + fdesc->gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7232 return (Elf_Addr)fdesc;
7233 }
7234 #endif /* CONFIG_64BIT */
7235 @@ -843,7 +865,7 @@ register_unwind_table(struct module *me,
7236
7237 table = (unsigned char *)sechdrs[me->arch.unwind_section].sh_addr;
7238 end = table + sechdrs[me->arch.unwind_section].sh_size;
7239 - gp = (Elf_Addr)me->module_core + me->arch.got_offset;
7240 + gp = (Elf_Addr)me->module_core_rw + me->arch.got_offset;
7241
7242 DEBUGP("register_unwind_table(), sect = %d at 0x%p - 0x%p (gp=0x%lx)\n",
7243 me->arch.unwind_section, table, end, gp);
7244 diff --git a/arch/parisc/kernel/sys_parisc.c b/arch/parisc/kernel/sys_parisc.c
7245 index 0d3a9d4..44975d0 100644
7246 --- a/arch/parisc/kernel/sys_parisc.c
7247 +++ b/arch/parisc/kernel/sys_parisc.c
7248 @@ -33,9 +33,11 @@
7249 #include <linux/utsname.h>
7250 #include <linux/personality.h>
7251
7252 -static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7253 +static unsigned long get_unshared_area(struct file *filp, unsigned long addr, unsigned long len,
7254 + unsigned long flags)
7255 {
7256 struct vm_unmapped_area_info info;
7257 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7258
7259 info.flags = 0;
7260 info.length = len;
7261 @@ -43,6 +45,7 @@ static unsigned long get_unshared_area(unsigned long addr, unsigned long len)
7262 info.high_limit = TASK_SIZE;
7263 info.align_mask = 0;
7264 info.align_offset = 0;
7265 + info.threadstack_offset = offset;
7266 return vm_unmapped_area(&info);
7267 }
7268
7269 @@ -69,15 +72,17 @@ static unsigned long shared_align_offset(struct file *filp, unsigned long pgoff)
7270 }
7271
7272 static unsigned long get_shared_area(struct file *filp, unsigned long addr,
7273 - unsigned long len, unsigned long pgoff)
7274 + unsigned long len, unsigned long pgoff, unsigned long flags)
7275 {
7276 struct vm_unmapped_area_info info;
7277 + unsigned long offset = gr_rand_threadstack_offset(current->mm, filp, flags);
7278
7279 info.flags = 0;
7280 info.length = len;
7281 info.low_limit = PAGE_ALIGN(addr);
7282 info.high_limit = TASK_SIZE;
7283 info.align_mask = PAGE_MASK & (SHMLBA - 1);
7284 + info.threadstack_offset = offset;
7285 info.align_offset = shared_align_offset(filp, pgoff);
7286 return vm_unmapped_area(&info);
7287 }
7288 @@ -93,13 +98,20 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
7289 return -EINVAL;
7290 return addr;
7291 }
7292 - if (!addr)
7293 + if (!addr) {
7294 addr = TASK_UNMAPPED_BASE;
7295
7296 +#ifdef CONFIG_PAX_RANDMMAP
7297 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
7298 + addr += current->mm->delta_mmap;
7299 +#endif
7300 +
7301 + }
7302 +
7303 if (filp || (flags & MAP_SHARED))
7304 - addr = get_shared_area(filp, addr, len, pgoff);
7305 + addr = get_shared_area(filp, addr, len, pgoff, flags);
7306 else
7307 - addr = get_unshared_area(addr, len);
7308 + addr = get_unshared_area(addr, len, flags);
7309
7310 return addr;
7311 }
7312 diff --git a/arch/parisc/kernel/traps.c b/arch/parisc/kernel/traps.c
7313 index 1cd1d0c..44ec918 100644
7314 --- a/arch/parisc/kernel/traps.c
7315 +++ b/arch/parisc/kernel/traps.c
7316 @@ -722,9 +722,7 @@ void notrace handle_interruption(int code, struct pt_regs *regs)
7317
7318 down_read(&current->mm->mmap_sem);
7319 vma = find_vma(current->mm,regs->iaoq[0]);
7320 - if (vma && (regs->iaoq[0] >= vma->vm_start)
7321 - && (vma->vm_flags & VM_EXEC)) {
7322 -
7323 + if (vma && (regs->iaoq[0] >= vma->vm_start)) {
7324 fault_address = regs->iaoq[0];
7325 fault_space = regs->iasq[0];
7326
7327 diff --git a/arch/parisc/mm/fault.c b/arch/parisc/mm/fault.c
7328 index 0293588..3b229aa 100644
7329 --- a/arch/parisc/mm/fault.c
7330 +++ b/arch/parisc/mm/fault.c
7331 @@ -15,6 +15,7 @@
7332 #include <linux/sched.h>
7333 #include <linux/interrupt.h>
7334 #include <linux/module.h>
7335 +#include <linux/unistd.h>
7336
7337 #include <asm/uaccess.h>
7338 #include <asm/traps.h>
7339 @@ -52,7 +53,7 @@ DEFINE_PER_CPU(struct exception_data, exception_data);
7340 static unsigned long
7341 parisc_acctyp(unsigned long code, unsigned int inst)
7342 {
7343 - if (code == 6 || code == 16)
7344 + if (code == 6 || code == 7 || code == 16)
7345 return VM_EXEC;
7346
7347 switch (inst & 0xf0000000) {
7348 @@ -138,6 +139,116 @@ parisc_acctyp(unsigned long code, unsigned int inst)
7349 }
7350 #endif
7351
7352 +#ifdef CONFIG_PAX_PAGEEXEC
7353 +/*
7354 + * PaX: decide what to do with offenders (instruction_pointer(regs) = fault address)
7355 + *
7356 + * returns 1 when task should be killed
7357 + * 2 when rt_sigreturn trampoline was detected
7358 + * 3 when unpatched PLT trampoline was detected
7359 + */
7360 +static int pax_handle_fetch_fault(struct pt_regs *regs)
7361 +{
7362 +
7363 +#ifdef CONFIG_PAX_EMUPLT
7364 + int err;
7365 +
7366 + do { /* PaX: unpatched PLT emulation */
7367 + unsigned int bl, depwi;
7368 +
7369 + err = get_user(bl, (unsigned int *)instruction_pointer(regs));
7370 + err |= get_user(depwi, (unsigned int *)(instruction_pointer(regs)+4));
7371 +
7372 + if (err)
7373 + break;
7374 +
7375 + if (bl == 0xEA9F1FDDU && depwi == 0xD6801C1EU) {
7376 + unsigned int ldw, bv, ldw2, addr = instruction_pointer(regs)-12;
7377 +
7378 + err = get_user(ldw, (unsigned int *)addr);
7379 + err |= get_user(bv, (unsigned int *)(addr+4));
7380 + err |= get_user(ldw2, (unsigned int *)(addr+8));
7381 +
7382 + if (err)
7383 + break;
7384 +
7385 + if (ldw == 0x0E801096U &&
7386 + bv == 0xEAC0C000U &&
7387 + ldw2 == 0x0E881095U)
7388 + {
7389 + unsigned int resolver, map;
7390 +
7391 + err = get_user(resolver, (unsigned int *)(instruction_pointer(regs)+8));
7392 + err |= get_user(map, (unsigned int *)(instruction_pointer(regs)+12));
7393 + if (err)
7394 + break;
7395 +
7396 + regs->gr[20] = instruction_pointer(regs)+8;
7397 + regs->gr[21] = map;
7398 + regs->gr[22] = resolver;
7399 + regs->iaoq[0] = resolver | 3UL;
7400 + regs->iaoq[1] = regs->iaoq[0] + 4;
7401 + return 3;
7402 + }
7403 + }
7404 + } while (0);
7405 +#endif
7406 +
7407 +#ifdef CONFIG_PAX_EMUTRAMP
7408 +
7409 +#ifndef CONFIG_PAX_EMUSIGRT
7410 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
7411 + return 1;
7412 +#endif
7413 +
7414 + do { /* PaX: rt_sigreturn emulation */
7415 + unsigned int ldi1, ldi2, bel, nop;
7416 +
7417 + err = get_user(ldi1, (unsigned int *)instruction_pointer(regs));
7418 + err |= get_user(ldi2, (unsigned int *)(instruction_pointer(regs)+4));
7419 + err |= get_user(bel, (unsigned int *)(instruction_pointer(regs)+8));
7420 + err |= get_user(nop, (unsigned int *)(instruction_pointer(regs)+12));
7421 +
7422 + if (err)
7423 + break;
7424 +
7425 + if ((ldi1 == 0x34190000U || ldi1 == 0x34190002U) &&
7426 + ldi2 == 0x3414015AU &&
7427 + bel == 0xE4008200U &&
7428 + nop == 0x08000240U)
7429 + {
7430 + regs->gr[25] = (ldi1 & 2) >> 1;
7431 + regs->gr[20] = __NR_rt_sigreturn;
7432 + regs->gr[31] = regs->iaoq[1] + 16;
7433 + regs->sr[0] = regs->iasq[1];
7434 + regs->iaoq[0] = 0x100UL;
7435 + regs->iaoq[1] = regs->iaoq[0] + 4;
7436 + regs->iasq[0] = regs->sr[2];
7437 + regs->iasq[1] = regs->sr[2];
7438 + return 2;
7439 + }
7440 + } while (0);
7441 +#endif
7442 +
7443 + return 1;
7444 +}
7445 +
7446 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
7447 +{
7448 + unsigned long i;
7449 +
7450 + printk(KERN_ERR "PAX: bytes at PC: ");
7451 + for (i = 0; i < 5; i++) {
7452 + unsigned int c;
7453 + if (get_user(c, (unsigned int *)pc+i))
7454 + printk(KERN_CONT "???????? ");
7455 + else
7456 + printk(KERN_CONT "%08x ", c);
7457 + }
7458 + printk("\n");
7459 +}
7460 +#endif
7461 +
7462 int fixup_exception(struct pt_regs *regs)
7463 {
7464 const struct exception_table_entry *fix;
7465 @@ -204,8 +315,33 @@ retry:
7466
7467 good_area:
7468
7469 - if ((vma->vm_flags & acc_type) != acc_type)
7470 + if ((vma->vm_flags & acc_type) != acc_type) {
7471 +
7472 +#ifdef CONFIG_PAX_PAGEEXEC
7473 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && (acc_type & VM_EXEC) &&
7474 + (address & ~3UL) == instruction_pointer(regs))
7475 + {
7476 + up_read(&mm->mmap_sem);
7477 + switch (pax_handle_fetch_fault(regs)) {
7478 +
7479 +#ifdef CONFIG_PAX_EMUPLT
7480 + case 3:
7481 + return;
7482 +#endif
7483 +
7484 +#ifdef CONFIG_PAX_EMUTRAMP
7485 + case 2:
7486 + return;
7487 +#endif
7488 +
7489 + }
7490 + pax_report_fault(regs, (void *)instruction_pointer(regs), (void *)regs->gr[30]);
7491 + do_group_exit(SIGKILL);
7492 + }
7493 +#endif
7494 +
7495 goto bad_area;
7496 + }
7497
7498 /*
7499 * If for any reason at all we couldn't handle the fault, make
7500 diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
7501 index 38f3b7e..7e485c0 100644
7502 --- a/arch/powerpc/Kconfig
7503 +++ b/arch/powerpc/Kconfig
7504 @@ -378,6 +378,7 @@ config ARCH_ENABLE_MEMORY_HOTREMOVE
7505 config KEXEC
7506 bool "kexec system call"
7507 depends on (PPC_BOOK3S || FSL_BOOKE || (44x && !SMP))
7508 + depends on !GRKERNSEC_KMEM
7509 help
7510 kexec is a system call that implements the ability to shutdown your
7511 current kernel, and to start another kernel. It is like a reboot
7512 diff --git a/arch/powerpc/include/asm/atomic.h b/arch/powerpc/include/asm/atomic.h
7513 index e3b1d41..8e81edf 100644
7514 --- a/arch/powerpc/include/asm/atomic.h
7515 +++ b/arch/powerpc/include/asm/atomic.h
7516 @@ -523,6 +523,16 @@ static __inline__ long atomic64_inc_not_zero(atomic64_t *v)
7517 return t1;
7518 }
7519
7520 +#define atomic64_read_unchecked(v) atomic64_read(v)
7521 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
7522 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
7523 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
7524 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
7525 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
7526 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
7527 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
7528 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
7529 +
7530 #endif /* __powerpc64__ */
7531
7532 #endif /* __KERNEL__ */
7533 diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
7534 index 9e495c9..b6878e5 100644
7535 --- a/arch/powerpc/include/asm/cache.h
7536 +++ b/arch/powerpc/include/asm/cache.h
7537 @@ -3,6 +3,7 @@
7538
7539 #ifdef __KERNEL__
7540
7541 +#include <linux/const.h>
7542
7543 /* bytes per L1 cache line */
7544 #if defined(CONFIG_8xx) || defined(CONFIG_403GCX)
7545 @@ -22,7 +23,7 @@
7546 #define L1_CACHE_SHIFT 7
7547 #endif
7548
7549 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
7550 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
7551
7552 #define SMP_CACHE_BYTES L1_CACHE_BYTES
7553
7554 diff --git a/arch/powerpc/include/asm/elf.h b/arch/powerpc/include/asm/elf.h
7555 index cc0655a..13eac2e 100644
7556 --- a/arch/powerpc/include/asm/elf.h
7557 +++ b/arch/powerpc/include/asm/elf.h
7558 @@ -28,8 +28,19 @@
7559 the loader. We need to make sure that it is out of the way of the program
7560 that it will "exec", and that there is sufficient room for the brk. */
7561
7562 -extern unsigned long randomize_et_dyn(unsigned long base);
7563 -#define ELF_ET_DYN_BASE (randomize_et_dyn(0x20000000))
7564 +#define ELF_ET_DYN_BASE (0x20000000)
7565 +
7566 +#ifdef CONFIG_PAX_ASLR
7567 +#define PAX_ELF_ET_DYN_BASE (0x10000000UL)
7568 +
7569 +#ifdef __powerpc64__
7570 +#define PAX_DELTA_MMAP_LEN (is_32bit_task() ? 16 : 28)
7571 +#define PAX_DELTA_STACK_LEN (is_32bit_task() ? 16 : 28)
7572 +#else
7573 +#define PAX_DELTA_MMAP_LEN 15
7574 +#define PAX_DELTA_STACK_LEN 15
7575 +#endif
7576 +#endif
7577
7578 /*
7579 * Our registers are always unsigned longs, whether we're a 32 bit
7580 @@ -123,10 +134,6 @@ extern int arch_setup_additional_pages(struct linux_binprm *bprm,
7581 (0x7ff >> (PAGE_SHIFT - 12)) : \
7582 (0x3ffff >> (PAGE_SHIFT - 12)))
7583
7584 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
7585 -#define arch_randomize_brk arch_randomize_brk
7586 -
7587 -
7588 #ifdef CONFIG_SPU_BASE
7589 /* Notes used in ET_CORE. Note name is "SPU/<fd>/<filename>". */
7590 #define NT_SPU 1
7591 diff --git a/arch/powerpc/include/asm/exec.h b/arch/powerpc/include/asm/exec.h
7592 index 8196e9c..d83a9f3 100644
7593 --- a/arch/powerpc/include/asm/exec.h
7594 +++ b/arch/powerpc/include/asm/exec.h
7595 @@ -4,6 +4,6 @@
7596 #ifndef _ASM_POWERPC_EXEC_H
7597 #define _ASM_POWERPC_EXEC_H
7598
7599 -extern unsigned long arch_align_stack(unsigned long sp);
7600 +#define arch_align_stack(x) ((x) & ~0xfUL)
7601
7602 #endif /* _ASM_POWERPC_EXEC_H */
7603 diff --git a/arch/powerpc/include/asm/kmap_types.h b/arch/powerpc/include/asm/kmap_types.h
7604 index 5acabbd..7ea14fa 100644
7605 --- a/arch/powerpc/include/asm/kmap_types.h
7606 +++ b/arch/powerpc/include/asm/kmap_types.h
7607 @@ -10,7 +10,7 @@
7608 * 2 of the License, or (at your option) any later version.
7609 */
7610
7611 -#define KM_TYPE_NR 16
7612 +#define KM_TYPE_NR 17
7613
7614 #endif /* __KERNEL__ */
7615 #endif /* _ASM_POWERPC_KMAP_TYPES_H */
7616 diff --git a/arch/powerpc/include/asm/mman.h b/arch/powerpc/include/asm/mman.h
7617 index 8565c25..2865190 100644
7618 --- a/arch/powerpc/include/asm/mman.h
7619 +++ b/arch/powerpc/include/asm/mman.h
7620 @@ -24,7 +24,7 @@ static inline unsigned long arch_calc_vm_prot_bits(unsigned long prot)
7621 }
7622 #define arch_calc_vm_prot_bits(prot) arch_calc_vm_prot_bits(prot)
7623
7624 -static inline pgprot_t arch_vm_get_page_prot(unsigned long vm_flags)
7625 +static inline pgprot_t arch_vm_get_page_prot(vm_flags_t vm_flags)
7626 {
7627 return (vm_flags & VM_SAO) ? __pgprot(_PAGE_SAO) : __pgprot(0);
7628 }
7629 diff --git a/arch/powerpc/include/asm/page.h b/arch/powerpc/include/asm/page.h
7630 index b9f4262..dcf04f7 100644
7631 --- a/arch/powerpc/include/asm/page.h
7632 +++ b/arch/powerpc/include/asm/page.h
7633 @@ -230,8 +230,9 @@ extern long long virt_phys_offset;
7634 * and needs to be executable. This means the whole heap ends
7635 * up being executable.
7636 */
7637 -#define VM_DATA_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7638 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7639 +#define VM_DATA_DEFAULT_FLAGS32 \
7640 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7641 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7642
7643 #define VM_DATA_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7644 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7645 @@ -259,6 +260,9 @@ extern long long virt_phys_offset;
7646 #define is_kernel_addr(x) ((x) >= PAGE_OFFSET)
7647 #endif
7648
7649 +#define ktla_ktva(addr) (addr)
7650 +#define ktva_ktla(addr) (addr)
7651 +
7652 #ifndef CONFIG_PPC_BOOK3S_64
7653 /*
7654 * Use the top bit of the higher-level page table entries to indicate whether
7655 diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
7656 index 88693ce..ac6f9ab 100644
7657 --- a/arch/powerpc/include/asm/page_64.h
7658 +++ b/arch/powerpc/include/asm/page_64.h
7659 @@ -153,15 +153,18 @@ do { \
7660 * stack by default, so in the absence of a PT_GNU_STACK program header
7661 * we turn execute permission off.
7662 */
7663 -#define VM_STACK_DEFAULT_FLAGS32 (VM_READ | VM_WRITE | VM_EXEC | \
7664 - VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7665 +#define VM_STACK_DEFAULT_FLAGS32 \
7666 + (((current->personality & READ_IMPLIES_EXEC) ? VM_EXEC : 0) | \
7667 + VM_READ | VM_WRITE | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7668
7669 #define VM_STACK_DEFAULT_FLAGS64 (VM_READ | VM_WRITE | \
7670 VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)
7671
7672 +#ifndef CONFIG_PAX_PAGEEXEC
7673 #define VM_STACK_DEFAULT_FLAGS \
7674 (is_32bit_task() ? \
7675 VM_STACK_DEFAULT_FLAGS32 : VM_STACK_DEFAULT_FLAGS64)
7676 +#endif
7677
7678 #include <asm-generic/getorder.h>
7679
7680 diff --git a/arch/powerpc/include/asm/pgalloc-64.h b/arch/powerpc/include/asm/pgalloc-64.h
7681 index 256d6f8..b0166a7 100644
7682 --- a/arch/powerpc/include/asm/pgalloc-64.h
7683 +++ b/arch/powerpc/include/asm/pgalloc-64.h
7684 @@ -53,6 +53,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
7685 #ifndef CONFIG_PPC_64K_PAGES
7686
7687 #define pgd_populate(MM, PGD, PUD) pgd_set(PGD, PUD)
7688 +#define pgd_populate_kernel(MM, PGD, PUD) pgd_populate((MM), (PGD), (PUD))
7689
7690 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
7691 {
7692 @@ -70,6 +71,11 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7693 pud_set(pud, (unsigned long)pmd);
7694 }
7695
7696 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
7697 +{
7698 + pud_populate(mm, pud, pmd);
7699 +}
7700 +
7701 #define pmd_populate(mm, pmd, pte_page) \
7702 pmd_populate_kernel(mm, pmd, page_address(pte_page))
7703 #define pmd_populate_kernel(mm, pmd, pte) pmd_set(pmd, (unsigned long)(pte))
7704 @@ -169,6 +175,7 @@ extern void __tlb_remove_table(void *_table);
7705 #endif
7706
7707 #define pud_populate(mm, pud, pmd) pud_set(pud, (unsigned long)pmd)
7708 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
7709
7710 static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd,
7711 pte_t *pte)
7712 diff --git a/arch/powerpc/include/asm/pgtable.h b/arch/powerpc/include/asm/pgtable.h
7713 index 7d6eacf..14c0240 100644
7714 --- a/arch/powerpc/include/asm/pgtable.h
7715 +++ b/arch/powerpc/include/asm/pgtable.h
7716 @@ -2,6 +2,7 @@
7717 #define _ASM_POWERPC_PGTABLE_H
7718 #ifdef __KERNEL__
7719
7720 +#include <linux/const.h>
7721 #ifndef __ASSEMBLY__
7722 #include <asm/processor.h> /* For TASK_SIZE */
7723 #include <asm/mmu.h>
7724 diff --git a/arch/powerpc/include/asm/pte-hash32.h b/arch/powerpc/include/asm/pte-hash32.h
7725 index 4aad413..85d86bf 100644
7726 --- a/arch/powerpc/include/asm/pte-hash32.h
7727 +++ b/arch/powerpc/include/asm/pte-hash32.h
7728 @@ -21,6 +21,7 @@
7729 #define _PAGE_FILE 0x004 /* when !present: nonlinear file mapping */
7730 #define _PAGE_USER 0x004 /* usermode access allowed */
7731 #define _PAGE_GUARDED 0x008 /* G: prohibit speculative access */
7732 +#define _PAGE_EXEC _PAGE_GUARDED
7733 #define _PAGE_COHERENT 0x010 /* M: enforce memory coherence (SMP systems) */
7734 #define _PAGE_NO_CACHE 0x020 /* I: cache inhibit */
7735 #define _PAGE_WRITETHRU 0x040 /* W: cache write-through */
7736 diff --git a/arch/powerpc/include/asm/reg.h b/arch/powerpc/include/asm/reg.h
7737 index 10d1ef0..8f83abc 100644
7738 --- a/arch/powerpc/include/asm/reg.h
7739 +++ b/arch/powerpc/include/asm/reg.h
7740 @@ -234,6 +234,7 @@
7741 #define SPRN_DBCR 0x136 /* e300 Data Breakpoint Control Reg */
7742 #define SPRN_DSISR 0x012 /* Data Storage Interrupt Status Register */
7743 #define DSISR_NOHPTE 0x40000000 /* no translation found */
7744 +#define DSISR_GUARDED 0x10000000 /* fetch from guarded storage */
7745 #define DSISR_PROTFAULT 0x08000000 /* protection fault */
7746 #define DSISR_ISSTORE 0x02000000 /* access was a store */
7747 #define DSISR_DABRMATCH 0x00400000 /* hit data breakpoint */
7748 diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h
7749 index 98da78e..dc68271 100644
7750 --- a/arch/powerpc/include/asm/smp.h
7751 +++ b/arch/powerpc/include/asm/smp.h
7752 @@ -50,7 +50,7 @@ struct smp_ops_t {
7753 int (*cpu_disable)(void);
7754 void (*cpu_die)(unsigned int nr);
7755 int (*cpu_bootable)(unsigned int nr);
7756 -};
7757 +} __no_const;
7758
7759 extern void smp_send_debugger_break(void);
7760 extern void start_secondary_resume(void);
7761 diff --git a/arch/powerpc/include/asm/thread_info.h b/arch/powerpc/include/asm/thread_info.h
7762 index ba7b197..d292e26 100644
7763 --- a/arch/powerpc/include/asm/thread_info.h
7764 +++ b/arch/powerpc/include/asm/thread_info.h
7765 @@ -93,7 +93,6 @@ static inline struct thread_info *current_thread_info(void)
7766 #define TIF_POLLING_NRFLAG 3 /* true if poll_idle() is polling
7767 TIF_NEED_RESCHED */
7768 #define TIF_32BIT 4 /* 32 bit binary */
7769 -#define TIF_PERFMON_WORK 5 /* work for pfm_handle_work() */
7770 #define TIF_PERFMON_CTXSW 6 /* perfmon needs ctxsw calls */
7771 #define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
7772 #define TIF_SINGLESTEP 8 /* singlestepping active */
7773 @@ -107,6 +106,9 @@ static inline struct thread_info *current_thread_info(void)
7774 #define TIF_EMULATE_STACK_STORE 16 /* Is an instruction emulation
7775 for stack store? */
7776 #define TIF_MEMDIE 17 /* is terminating due to OOM killer */
7777 +#define TIF_PERFMON_WORK 18 /* work for pfm_handle_work() */
7778 +/* mask must be expressable within 16 bits to satisfy 'andi' instruction reqs */
7779 +#define TIF_GRSEC_SETXID 5 /* update credentials on syscall entry/exit */
7780
7781 /* as above, but as bit values */
7782 #define _TIF_SYSCALL_TRACE (1<<TIF_SYSCALL_TRACE)
7783 @@ -126,9 +128,10 @@ static inline struct thread_info *current_thread_info(void)
7784 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
7785 #define _TIF_EMULATE_STACK_STORE (1<<TIF_EMULATE_STACK_STORE)
7786 #define _TIF_NOHZ (1<<TIF_NOHZ)
7787 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
7788 #define _TIF_SYSCALL_T_OR_A (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
7789 _TIF_SECCOMP | _TIF_SYSCALL_TRACEPOINT | \
7790 - _TIF_NOHZ)
7791 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
7792
7793 #define _TIF_USER_WORK_MASK (_TIF_SIGPENDING | _TIF_NEED_RESCHED | \
7794 _TIF_NOTIFY_RESUME | _TIF_UPROBE)
7795 diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
7796 index 9485b43..4718d50 100644
7797 --- a/arch/powerpc/include/asm/uaccess.h
7798 +++ b/arch/powerpc/include/asm/uaccess.h
7799 @@ -318,52 +318,6 @@ do { \
7800 extern unsigned long __copy_tofrom_user(void __user *to,
7801 const void __user *from, unsigned long size);
7802
7803 -#ifndef __powerpc64__
7804 -
7805 -static inline unsigned long copy_from_user(void *to,
7806 - const void __user *from, unsigned long n)
7807 -{
7808 - unsigned long over;
7809 -
7810 - if (access_ok(VERIFY_READ, from, n))
7811 - return __copy_tofrom_user((__force void __user *)to, from, n);
7812 - if ((unsigned long)from < TASK_SIZE) {
7813 - over = (unsigned long)from + n - TASK_SIZE;
7814 - return __copy_tofrom_user((__force void __user *)to, from,
7815 - n - over) + over;
7816 - }
7817 - return n;
7818 -}
7819 -
7820 -static inline unsigned long copy_to_user(void __user *to,
7821 - const void *from, unsigned long n)
7822 -{
7823 - unsigned long over;
7824 -
7825 - if (access_ok(VERIFY_WRITE, to, n))
7826 - return __copy_tofrom_user(to, (__force void __user *)from, n);
7827 - if ((unsigned long)to < TASK_SIZE) {
7828 - over = (unsigned long)to + n - TASK_SIZE;
7829 - return __copy_tofrom_user(to, (__force void __user *)from,
7830 - n - over) + over;
7831 - }
7832 - return n;
7833 -}
7834 -
7835 -#else /* __powerpc64__ */
7836 -
7837 -#define __copy_in_user(to, from, size) \
7838 - __copy_tofrom_user((to), (from), (size))
7839 -
7840 -extern unsigned long copy_from_user(void *to, const void __user *from,
7841 - unsigned long n);
7842 -extern unsigned long copy_to_user(void __user *to, const void *from,
7843 - unsigned long n);
7844 -extern unsigned long copy_in_user(void __user *to, const void __user *from,
7845 - unsigned long n);
7846 -
7847 -#endif /* __powerpc64__ */
7848 -
7849 static inline unsigned long __copy_from_user_inatomic(void *to,
7850 const void __user *from, unsigned long n)
7851 {
7852 @@ -387,6 +341,10 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
7853 if (ret == 0)
7854 return 0;
7855 }
7856 +
7857 + if (!__builtin_constant_p(n))
7858 + check_object_size(to, n, false);
7859 +
7860 return __copy_tofrom_user((__force void __user *)to, from, n);
7861 }
7862
7863 @@ -413,6 +371,10 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
7864 if (ret == 0)
7865 return 0;
7866 }
7867 +
7868 + if (!__builtin_constant_p(n))
7869 + check_object_size(from, n, true);
7870 +
7871 return __copy_tofrom_user(to, (__force const void __user *)from, n);
7872 }
7873
7874 @@ -430,6 +392,92 @@ static inline unsigned long __copy_to_user(void __user *to,
7875 return __copy_to_user_inatomic(to, from, size);
7876 }
7877
7878 +#ifndef __powerpc64__
7879 +
7880 +static inline unsigned long __must_check copy_from_user(void *to,
7881 + const void __user *from, unsigned long n)
7882 +{
7883 + unsigned long over;
7884 +
7885 + if ((long)n < 0)
7886 + return n;
7887 +
7888 + if (access_ok(VERIFY_READ, from, n)) {
7889 + if (!__builtin_constant_p(n))
7890 + check_object_size(to, n, false);
7891 + return __copy_tofrom_user((__force void __user *)to, from, n);
7892 + }
7893 + if ((unsigned long)from < TASK_SIZE) {
7894 + over = (unsigned long)from + n - TASK_SIZE;
7895 + if (!__builtin_constant_p(n - over))
7896 + check_object_size(to, n - over, false);
7897 + return __copy_tofrom_user((__force void __user *)to, from,
7898 + n - over) + over;
7899 + }
7900 + return n;
7901 +}
7902 +
7903 +static inline unsigned long __must_check copy_to_user(void __user *to,
7904 + const void *from, unsigned long n)
7905 +{
7906 + unsigned long over;
7907 +
7908 + if ((long)n < 0)
7909 + return n;
7910 +
7911 + if (access_ok(VERIFY_WRITE, to, n)) {
7912 + if (!__builtin_constant_p(n))
7913 + check_object_size(from, n, true);
7914 + return __copy_tofrom_user(to, (__force void __user *)from, n);
7915 + }
7916 + if ((unsigned long)to < TASK_SIZE) {
7917 + over = (unsigned long)to + n - TASK_SIZE;
7918 + if (!__builtin_constant_p(n))
7919 + check_object_size(from, n - over, true);
7920 + return __copy_tofrom_user(to, (__force void __user *)from,
7921 + n - over) + over;
7922 + }
7923 + return n;
7924 +}
7925 +
7926 +#else /* __powerpc64__ */
7927 +
7928 +#define __copy_in_user(to, from, size) \
7929 + __copy_tofrom_user((to), (from), (size))
7930 +
7931 +static inline unsigned long __must_check copy_from_user(void *to, const void __user *from, unsigned long n)
7932 +{
7933 + if ((long)n < 0 || n > INT_MAX)
7934 + return n;
7935 +
7936 + if (!__builtin_constant_p(n))
7937 + check_object_size(to, n, false);
7938 +
7939 + if (likely(access_ok(VERIFY_READ, from, n)))
7940 + n = __copy_from_user(to, from, n);
7941 + else
7942 + memset(to, 0, n);
7943 + return n;
7944 +}
7945 +
7946 +static inline unsigned long __must_check copy_to_user(void __user *to, const void *from, unsigned long n)
7947 +{
7948 + if ((long)n < 0 || n > INT_MAX)
7949 + return n;
7950 +
7951 + if (likely(access_ok(VERIFY_WRITE, to, n))) {
7952 + if (!__builtin_constant_p(n))
7953 + check_object_size(from, n, true);
7954 + n = __copy_to_user(to, from, n);
7955 + }
7956 + return n;
7957 +}
7958 +
7959 +extern unsigned long copy_in_user(void __user *to, const void __user *from,
7960 + unsigned long n);
7961 +
7962 +#endif /* __powerpc64__ */
7963 +
7964 extern unsigned long __clear_user(void __user *addr, unsigned long size);
7965
7966 static inline unsigned long clear_user(void __user *addr, unsigned long size)
7967 diff --git a/arch/powerpc/kernel/exceptions-64e.S b/arch/powerpc/kernel/exceptions-64e.S
7968 index 2d06704..1616f1b 100644
7969 --- a/arch/powerpc/kernel/exceptions-64e.S
7970 +++ b/arch/powerpc/kernel/exceptions-64e.S
7971 @@ -757,6 +757,7 @@ storage_fault_common:
7972 std r14,_DAR(r1)
7973 std r15,_DSISR(r1)
7974 addi r3,r1,STACK_FRAME_OVERHEAD
7975 + bl .save_nvgprs
7976 mr r4,r14
7977 mr r5,r15
7978 ld r14,PACA_EXGEN+EX_R14(r13)
7979 @@ -765,8 +766,7 @@ storage_fault_common:
7980 cmpdi r3,0
7981 bne- 1f
7982 b .ret_from_except_lite
7983 -1: bl .save_nvgprs
7984 - mr r5,r3
7985 +1: mr r5,r3
7986 addi r3,r1,STACK_FRAME_OVERHEAD
7987 ld r4,_DAR(r1)
7988 bl .bad_page_fault
7989 diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S
7990 index 3a9ed6a..b534681 100644
7991 --- a/arch/powerpc/kernel/exceptions-64s.S
7992 +++ b/arch/powerpc/kernel/exceptions-64s.S
7993 @@ -1364,10 +1364,10 @@ handle_page_fault:
7994 11: ld r4,_DAR(r1)
7995 ld r5,_DSISR(r1)
7996 addi r3,r1,STACK_FRAME_OVERHEAD
7997 + bl .save_nvgprs
7998 bl .do_page_fault
7999 cmpdi r3,0
8000 beq+ 12f
8001 - bl .save_nvgprs
8002 mr r5,r3
8003 addi r3,r1,STACK_FRAME_OVERHEAD
8004 lwz r4,_DAR(r1)
8005 diff --git a/arch/powerpc/kernel/module_32.c b/arch/powerpc/kernel/module_32.c
8006 index 2e3200c..7118986 100644
8007 --- a/arch/powerpc/kernel/module_32.c
8008 +++ b/arch/powerpc/kernel/module_32.c
8009 @@ -162,7 +162,7 @@ int module_frob_arch_sections(Elf32_Ehdr *hdr,
8010 me->arch.core_plt_section = i;
8011 }
8012 if (!me->arch.core_plt_section || !me->arch.init_plt_section) {
8013 - printk("Module doesn't contain .plt or .init.plt sections.\n");
8014 + printk("Module %s doesn't contain .plt or .init.plt sections.\n", me->name);
8015 return -ENOEXEC;
8016 }
8017
8018 @@ -192,11 +192,16 @@ static uint32_t do_plt_call(void *location,
8019
8020 DEBUGP("Doing plt for call to 0x%x at 0x%x\n", val, (unsigned int)location);
8021 /* Init, or core PLT? */
8022 - if (location >= mod->module_core
8023 - && location < mod->module_core + mod->core_size)
8024 + if ((location >= mod->module_core_rx && location < mod->module_core_rx + mod->core_size_rx) ||
8025 + (location >= mod->module_core_rw && location < mod->module_core_rw + mod->core_size_rw))
8026 entry = (void *)sechdrs[mod->arch.core_plt_section].sh_addr;
8027 - else
8028 + else if ((location >= mod->module_init_rx && location < mod->module_init_rx + mod->init_size_rx) ||
8029 + (location >= mod->module_init_rw && location < mod->module_init_rw + mod->init_size_rw))
8030 entry = (void *)sechdrs[mod->arch.init_plt_section].sh_addr;
8031 + else {
8032 + printk(KERN_ERR "%s: invalid R_PPC_REL24 entry found\n", mod->name);
8033 + return ~0UL;
8034 + }
8035
8036 /* Find this entry, or if that fails, the next avail. entry */
8037 while (entry->jump[0]) {
8038 @@ -300,7 +305,7 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
8039 }
8040 #ifdef CONFIG_DYNAMIC_FTRACE
8041 module->arch.tramp =
8042 - do_plt_call(module->module_core,
8043 + do_plt_call(module->module_core_rx,
8044 (unsigned long)ftrace_caller,
8045 sechdrs, module);
8046 #endif
8047 diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
8048 index 96d2fdf..f6d10c8 100644
8049 --- a/arch/powerpc/kernel/process.c
8050 +++ b/arch/powerpc/kernel/process.c
8051 @@ -886,8 +886,8 @@ void show_regs(struct pt_regs * regs)
8052 * Lookup NIP late so we have the best change of getting the
8053 * above info out without failing
8054 */
8055 - printk("NIP ["REG"] %pS\n", regs->nip, (void *)regs->nip);
8056 - printk("LR ["REG"] %pS\n", regs->link, (void *)regs->link);
8057 + printk("NIP ["REG"] %pA\n", regs->nip, (void *)regs->nip);
8058 + printk("LR ["REG"] %pA\n", regs->link, (void *)regs->link);
8059 #endif
8060 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
8061 printk("PACATMSCRATCH [%llx]\n", get_paca()->tm_scratch);
8062 @@ -1352,10 +1352,10 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8063 newsp = stack[0];
8064 ip = stack[STACK_FRAME_LR_SAVE];
8065 if (!firstframe || ip != lr) {
8066 - printk("["REG"] ["REG"] %pS", sp, ip, (void *)ip);
8067 + printk("["REG"] ["REG"] %pA", sp, ip, (void *)ip);
8068 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
8069 if ((ip == rth || ip == mrth) && curr_frame >= 0) {
8070 - printk(" (%pS)",
8071 + printk(" (%pA)",
8072 (void *)current->ret_stack[curr_frame].ret);
8073 curr_frame--;
8074 }
8075 @@ -1375,7 +1375,7 @@ void show_stack(struct task_struct *tsk, unsigned long *stack)
8076 struct pt_regs *regs = (struct pt_regs *)
8077 (sp + STACK_FRAME_OVERHEAD);
8078 lr = regs->link;
8079 - printk("--- Exception: %lx at %pS\n LR = %pS\n",
8080 + printk("--- Exception: %lx at %pA\n LR = %pA\n",
8081 regs->trap, (void *)regs->nip, (void *)lr);
8082 firstframe = 1;
8083 }
8084 @@ -1411,58 +1411,3 @@ void notrace __ppc64_runlatch_off(void)
8085 mtspr(SPRN_CTRLT, ctrl);
8086 }
8087 #endif /* CONFIG_PPC64 */
8088 -
8089 -unsigned long arch_align_stack(unsigned long sp)
8090 -{
8091 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8092 - sp -= get_random_int() & ~PAGE_MASK;
8093 - return sp & ~0xf;
8094 -}
8095 -
8096 -static inline unsigned long brk_rnd(void)
8097 -{
8098 - unsigned long rnd = 0;
8099 -
8100 - /* 8MB for 32bit, 1GB for 64bit */
8101 - if (is_32bit_task())
8102 - rnd = (long)(get_random_int() % (1<<(23-PAGE_SHIFT)));
8103 - else
8104 - rnd = (long)(get_random_int() % (1<<(30-PAGE_SHIFT)));
8105 -
8106 - return rnd << PAGE_SHIFT;
8107 -}
8108 -
8109 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8110 -{
8111 - unsigned long base = mm->brk;
8112 - unsigned long ret;
8113 -
8114 -#ifdef CONFIG_PPC_STD_MMU_64
8115 - /*
8116 - * If we are using 1TB segments and we are allowed to randomise
8117 - * the heap, we can put it above 1TB so it is backed by a 1TB
8118 - * segment. Otherwise the heap will be in the bottom 1TB
8119 - * which always uses 256MB segments and this may result in a
8120 - * performance penalty.
8121 - */
8122 - if (!is_32bit_task() && (mmu_highuser_ssize == MMU_SEGSIZE_1T))
8123 - base = max_t(unsigned long, mm->brk, 1UL << SID_SHIFT_1T);
8124 -#endif
8125 -
8126 - ret = PAGE_ALIGN(base + brk_rnd());
8127 -
8128 - if (ret < mm->brk)
8129 - return mm->brk;
8130 -
8131 - return ret;
8132 -}
8133 -
8134 -unsigned long randomize_et_dyn(unsigned long base)
8135 -{
8136 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8137 -
8138 - if (ret < base)
8139 - return base;
8140 -
8141 - return ret;
8142 -}
8143 diff --git a/arch/powerpc/kernel/ptrace.c b/arch/powerpc/kernel/ptrace.c
8144 index 9a0d24c..e7fbedf 100644
8145 --- a/arch/powerpc/kernel/ptrace.c
8146 +++ b/arch/powerpc/kernel/ptrace.c
8147 @@ -1761,6 +1761,10 @@ long arch_ptrace(struct task_struct *child, long request,
8148 return ret;
8149 }
8150
8151 +#ifdef CONFIG_GRKERNSEC_SETXID
8152 +extern void gr_delayed_cred_worker(void);
8153 +#endif
8154 +
8155 /*
8156 * We must return the syscall number to actually look up in the table.
8157 * This can be -1L to skip running any syscall at all.
8158 @@ -1773,6 +1777,11 @@ long do_syscall_trace_enter(struct pt_regs *regs)
8159
8160 secure_computing_strict(regs->gpr[0]);
8161
8162 +#ifdef CONFIG_GRKERNSEC_SETXID
8163 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8164 + gr_delayed_cred_worker();
8165 +#endif
8166 +
8167 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
8168 tracehook_report_syscall_entry(regs))
8169 /*
8170 @@ -1807,6 +1816,11 @@ void do_syscall_trace_leave(struct pt_regs *regs)
8171 {
8172 int step;
8173
8174 +#ifdef CONFIG_GRKERNSEC_SETXID
8175 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
8176 + gr_delayed_cred_worker();
8177 +#endif
8178 +
8179 audit_syscall_exit(regs);
8180
8181 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
8182 diff --git a/arch/powerpc/kernel/signal_32.c b/arch/powerpc/kernel/signal_32.c
8183 index fea2dba..a779f6b 100644
8184 --- a/arch/powerpc/kernel/signal_32.c
8185 +++ b/arch/powerpc/kernel/signal_32.c
8186 @@ -1002,7 +1002,7 @@ int handle_rt_signal32(unsigned long sig, struct k_sigaction *ka,
8187 /* Save user registers on the stack */
8188 frame = &rt_sf->uc.uc_mcontext;
8189 addr = frame;
8190 - if (vdso32_rt_sigtramp && current->mm->context.vdso_base) {
8191 + if (vdso32_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8192 sigret = 0;
8193 tramp = current->mm->context.vdso_base + vdso32_rt_sigtramp;
8194 } else {
8195 diff --git a/arch/powerpc/kernel/signal_64.c b/arch/powerpc/kernel/signal_64.c
8196 index 1e7ba88..17afb1b 100644
8197 --- a/arch/powerpc/kernel/signal_64.c
8198 +++ b/arch/powerpc/kernel/signal_64.c
8199 @@ -763,7 +763,7 @@ int handle_rt_signal64(int signr, struct k_sigaction *ka, siginfo_t *info,
8200 #endif
8201
8202 /* Set up to return from userspace. */
8203 - if (vdso64_rt_sigtramp && current->mm->context.vdso_base) {
8204 + if (vdso64_rt_sigtramp && current->mm->context.vdso_base != ~0UL) {
8205 regs->link = current->mm->context.vdso_base + vdso64_rt_sigtramp;
8206 } else {
8207 err |= setup_trampoline(__NR_rt_sigreturn, &frame->tramp[0]);
8208 diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
8209 index f783c93..619baf1 100644
8210 --- a/arch/powerpc/kernel/traps.c
8211 +++ b/arch/powerpc/kernel/traps.c
8212 @@ -142,6 +142,8 @@ static unsigned __kprobes long oops_begin(struct pt_regs *regs)
8213 return flags;
8214 }
8215
8216 +extern void gr_handle_kernel_exploit(void);
8217 +
8218 static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8219 int signr)
8220 {
8221 @@ -191,6 +193,9 @@ static void __kprobes oops_end(unsigned long flags, struct pt_regs *regs,
8222 panic("Fatal exception in interrupt");
8223 if (panic_on_oops)
8224 panic("Fatal exception");
8225 +
8226 + gr_handle_kernel_exploit();
8227 +
8228 do_exit(signr);
8229 }
8230
8231 diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c
8232 index 1d9c926..25f4741 100644
8233 --- a/arch/powerpc/kernel/vdso.c
8234 +++ b/arch/powerpc/kernel/vdso.c
8235 @@ -34,6 +34,7 @@
8236 #include <asm/firmware.h>
8237 #include <asm/vdso.h>
8238 #include <asm/vdso_datapage.h>
8239 +#include <asm/mman.h>
8240
8241 #include "setup.h"
8242
8243 @@ -222,7 +223,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8244 vdso_base = VDSO32_MBASE;
8245 #endif
8246
8247 - current->mm->context.vdso_base = 0;
8248 + current->mm->context.vdso_base = ~0UL;
8249
8250 /* vDSO has a problem and was disabled, just don't "enable" it for the
8251 * process
8252 @@ -242,7 +243,7 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
8253 vdso_base = get_unmapped_area(NULL, vdso_base,
8254 (vdso_pages << PAGE_SHIFT) +
8255 ((VDSO_ALIGNMENT - 1) & PAGE_MASK),
8256 - 0, 0);
8257 + 0, MAP_PRIVATE | MAP_EXECUTABLE);
8258 if (IS_ERR_VALUE(vdso_base)) {
8259 rc = vdso_base;
8260 goto fail_mmapsem;
8261 diff --git a/arch/powerpc/lib/usercopy_64.c b/arch/powerpc/lib/usercopy_64.c
8262 index 5eea6f3..5d10396 100644
8263 --- a/arch/powerpc/lib/usercopy_64.c
8264 +++ b/arch/powerpc/lib/usercopy_64.c
8265 @@ -9,22 +9,6 @@
8266 #include <linux/module.h>
8267 #include <asm/uaccess.h>
8268
8269 -unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
8270 -{
8271 - if (likely(access_ok(VERIFY_READ, from, n)))
8272 - n = __copy_from_user(to, from, n);
8273 - else
8274 - memset(to, 0, n);
8275 - return n;
8276 -}
8277 -
8278 -unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
8279 -{
8280 - if (likely(access_ok(VERIFY_WRITE, to, n)))
8281 - n = __copy_to_user(to, from, n);
8282 - return n;
8283 -}
8284 -
8285 unsigned long copy_in_user(void __user *to, const void __user *from,
8286 unsigned long n)
8287 {
8288 @@ -35,7 +19,5 @@ unsigned long copy_in_user(void __user *to, const void __user *from,
8289 return n;
8290 }
8291
8292 -EXPORT_SYMBOL(copy_from_user);
8293 -EXPORT_SYMBOL(copy_to_user);
8294 EXPORT_SYMBOL(copy_in_user);
8295
8296 diff --git a/arch/powerpc/mm/fault.c b/arch/powerpc/mm/fault.c
8297 index 51ab9e7..7d3c78b 100644
8298 --- a/arch/powerpc/mm/fault.c
8299 +++ b/arch/powerpc/mm/fault.c
8300 @@ -33,6 +33,10 @@
8301 #include <linux/magic.h>
8302 #include <linux/ratelimit.h>
8303 #include <linux/context_tracking.h>
8304 +#include <linux/slab.h>
8305 +#include <linux/pagemap.h>
8306 +#include <linux/compiler.h>
8307 +#include <linux/unistd.h>
8308
8309 #include <asm/firmware.h>
8310 #include <asm/page.h>
8311 @@ -69,6 +73,33 @@ static inline int notify_page_fault(struct pt_regs *regs)
8312 }
8313 #endif
8314
8315 +#ifdef CONFIG_PAX_PAGEEXEC
8316 +/*
8317 + * PaX: decide what to do with offenders (regs->nip = fault address)
8318 + *
8319 + * returns 1 when task should be killed
8320 + */
8321 +static int pax_handle_fetch_fault(struct pt_regs *regs)
8322 +{
8323 + return 1;
8324 +}
8325 +
8326 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
8327 +{
8328 + unsigned long i;
8329 +
8330 + printk(KERN_ERR "PAX: bytes at PC: ");
8331 + for (i = 0; i < 5; i++) {
8332 + unsigned int c;
8333 + if (get_user(c, (unsigned int __user *)pc+i))
8334 + printk(KERN_CONT "???????? ");
8335 + else
8336 + printk(KERN_CONT "%08x ", c);
8337 + }
8338 + printk("\n");
8339 +}
8340 +#endif
8341 +
8342 /*
8343 * Check whether the instruction at regs->nip is a store using
8344 * an update addressing form which will update r1.
8345 @@ -216,7 +247,7 @@ int __kprobes do_page_fault(struct pt_regs *regs, unsigned long address,
8346 * indicate errors in DSISR but can validly be set in SRR1.
8347 */
8348 if (trap == 0x400)
8349 - error_code &= 0x48200000;
8350 + error_code &= 0x58200000;
8351 else
8352 is_write = error_code & DSISR_ISSTORE;
8353 #else
8354 @@ -378,7 +409,7 @@ good_area:
8355 * "undefined". Of those that can be set, this is the only
8356 * one which seems bad.
8357 */
8358 - if (error_code & 0x10000000)
8359 + if (error_code & DSISR_GUARDED)
8360 /* Guarded storage error. */
8361 goto bad_area;
8362 #endif /* CONFIG_8xx */
8363 @@ -393,7 +424,7 @@ good_area:
8364 * processors use the same I/D cache coherency mechanism
8365 * as embedded.
8366 */
8367 - if (error_code & DSISR_PROTFAULT)
8368 + if (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))
8369 goto bad_area;
8370 #endif /* CONFIG_PPC_STD_MMU */
8371
8372 @@ -483,6 +514,23 @@ bad_area:
8373 bad_area_nosemaphore:
8374 /* User mode accesses cause a SIGSEGV */
8375 if (user_mode(regs)) {
8376 +
8377 +#ifdef CONFIG_PAX_PAGEEXEC
8378 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
8379 +#ifdef CONFIG_PPC_STD_MMU
8380 + if (is_exec && (error_code & (DSISR_PROTFAULT | DSISR_GUARDED))) {
8381 +#else
8382 + if (is_exec && regs->nip == address) {
8383 +#endif
8384 + switch (pax_handle_fetch_fault(regs)) {
8385 + }
8386 +
8387 + pax_report_fault(regs, (void *)regs->nip, (void *)regs->gpr[PT_R1]);
8388 + do_group_exit(SIGKILL);
8389 + }
8390 + }
8391 +#endif
8392 +
8393 _exception(SIGSEGV, regs, code, address);
8394 goto bail;
8395 }
8396 diff --git a/arch/powerpc/mm/mmap.c b/arch/powerpc/mm/mmap.c
8397 index cb8bdbe..d770680 100644
8398 --- a/arch/powerpc/mm/mmap.c
8399 +++ b/arch/powerpc/mm/mmap.c
8400 @@ -57,6 +57,10 @@ static unsigned long mmap_rnd(void)
8401 {
8402 unsigned long rnd = 0;
8403
8404 +#ifdef CONFIG_PAX_RANDMMAP
8405 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8406 +#endif
8407 +
8408 if (current->flags & PF_RANDOMIZE) {
8409 /* 8MB for 32bit, 1GB for 64bit */
8410 if (is_32bit_task())
8411 @@ -91,9 +95,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8412 */
8413 if (mmap_is_legacy()) {
8414 mm->mmap_base = TASK_UNMAPPED_BASE;
8415 +
8416 +#ifdef CONFIG_PAX_RANDMMAP
8417 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8418 + mm->mmap_base += mm->delta_mmap;
8419 +#endif
8420 +
8421 mm->get_unmapped_area = arch_get_unmapped_area;
8422 } else {
8423 mm->mmap_base = mmap_base();
8424 +
8425 +#ifdef CONFIG_PAX_RANDMMAP
8426 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8427 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8428 +#endif
8429 +
8430 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8431 }
8432 }
8433 diff --git a/arch/powerpc/mm/slice.c b/arch/powerpc/mm/slice.c
8434 index 7ce9cf3..a964087 100644
8435 --- a/arch/powerpc/mm/slice.c
8436 +++ b/arch/powerpc/mm/slice.c
8437 @@ -103,7 +103,7 @@ static int slice_area_is_free(struct mm_struct *mm, unsigned long addr,
8438 if ((mm->task_size - len) < addr)
8439 return 0;
8440 vma = find_vma(mm, addr);
8441 - return (!vma || (addr + len) <= vma->vm_start);
8442 + return check_heap_stack_gap(vma, addr, len, 0);
8443 }
8444
8445 static int slice_low_has_vma(struct mm_struct *mm, unsigned long slice)
8446 @@ -277,6 +277,12 @@ static unsigned long slice_find_area_bottomup(struct mm_struct *mm,
8447 info.align_offset = 0;
8448
8449 addr = TASK_UNMAPPED_BASE;
8450 +
8451 +#ifdef CONFIG_PAX_RANDMMAP
8452 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8453 + addr += mm->delta_mmap;
8454 +#endif
8455 +
8456 while (addr < TASK_SIZE) {
8457 info.low_limit = addr;
8458 if (!slice_scan_available(addr, available, 1, &addr))
8459 @@ -410,6 +416,11 @@ unsigned long slice_get_unmapped_area(unsigned long addr, unsigned long len,
8460 if (fixed && addr > (mm->task_size - len))
8461 return -EINVAL;
8462
8463 +#ifdef CONFIG_PAX_RANDMMAP
8464 + if (!fixed && (mm->pax_flags & MF_PAX_RANDMMAP))
8465 + addr = 0;
8466 +#endif
8467 +
8468 /* If hint, make sure it matches our alignment restrictions */
8469 if (!fixed && addr) {
8470 addr = _ALIGN_UP(addr, 1ul << pshift);
8471 diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c
8472 index 9098692..3d54cd1 100644
8473 --- a/arch/powerpc/platforms/cell/spufs/file.c
8474 +++ b/arch/powerpc/platforms/cell/spufs/file.c
8475 @@ -280,9 +280,9 @@ spufs_mem_mmap_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
8476 return VM_FAULT_NOPAGE;
8477 }
8478
8479 -static int spufs_mem_mmap_access(struct vm_area_struct *vma,
8480 +static ssize_t spufs_mem_mmap_access(struct vm_area_struct *vma,
8481 unsigned long address,
8482 - void *buf, int len, int write)
8483 + void *buf, size_t len, int write)
8484 {
8485 struct spu_context *ctx = vma->vm_file->private_data;
8486 unsigned long offset = address - vma->vm_start;
8487 diff --git a/arch/s390/include/asm/atomic.h b/arch/s390/include/asm/atomic.h
8488 index c797832..ce575c8 100644
8489 --- a/arch/s390/include/asm/atomic.h
8490 +++ b/arch/s390/include/asm/atomic.h
8491 @@ -326,6 +326,16 @@ static inline long long atomic64_dec_if_positive(atomic64_t *v)
8492 #define atomic64_dec_and_test(_v) (atomic64_sub_return(1, _v) == 0)
8493 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
8494
8495 +#define atomic64_read_unchecked(v) atomic64_read(v)
8496 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
8497 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
8498 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
8499 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
8500 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
8501 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
8502 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
8503 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
8504 +
8505 #define smp_mb__before_atomic_dec() smp_mb()
8506 #define smp_mb__after_atomic_dec() smp_mb()
8507 #define smp_mb__before_atomic_inc() smp_mb()
8508 diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
8509 index 4d7ccac..d03d0ad 100644
8510 --- a/arch/s390/include/asm/cache.h
8511 +++ b/arch/s390/include/asm/cache.h
8512 @@ -9,8 +9,10 @@
8513 #ifndef __ARCH_S390_CACHE_H
8514 #define __ARCH_S390_CACHE_H
8515
8516 -#define L1_CACHE_BYTES 256
8517 +#include <linux/const.h>
8518 +
8519 #define L1_CACHE_SHIFT 8
8520 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8521 #define NET_SKB_PAD 32
8522
8523 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8524 diff --git a/arch/s390/include/asm/elf.h b/arch/s390/include/asm/elf.h
8525 index 78f4f87..598ce39 100644
8526 --- a/arch/s390/include/asm/elf.h
8527 +++ b/arch/s390/include/asm/elf.h
8528 @@ -162,8 +162,14 @@ extern unsigned int vdso_enabled;
8529 the loader. We need to make sure that it is out of the way of the program
8530 that it will "exec", and that there is sufficient room for the brk. */
8531
8532 -extern unsigned long randomize_et_dyn(unsigned long base);
8533 -#define ELF_ET_DYN_BASE (randomize_et_dyn(STACK_TOP / 3 * 2))
8534 +#define ELF_ET_DYN_BASE (STACK_TOP / 3 * 2)
8535 +
8536 +#ifdef CONFIG_PAX_ASLR
8537 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_31BIT) ? 0x10000UL : 0x80000000UL)
8538 +
8539 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8540 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_31BIT) ? 15 : 26)
8541 +#endif
8542
8543 /* This yields a mask that user programs can use to figure out what
8544 instruction set this CPU supports. */
8545 @@ -222,9 +228,6 @@ struct linux_binprm;
8546 #define ARCH_HAS_SETUP_ADDITIONAL_PAGES 1
8547 int arch_setup_additional_pages(struct linux_binprm *, int);
8548
8549 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
8550 -#define arch_randomize_brk arch_randomize_brk
8551 -
8552 void *fill_cpu_elf_notes(void *ptr, struct save_area *sa);
8553
8554 #endif
8555 diff --git a/arch/s390/include/asm/exec.h b/arch/s390/include/asm/exec.h
8556 index c4a93d6..4d2a9b4 100644
8557 --- a/arch/s390/include/asm/exec.h
8558 +++ b/arch/s390/include/asm/exec.h
8559 @@ -7,6 +7,6 @@
8560 #ifndef __ASM_EXEC_H
8561 #define __ASM_EXEC_H
8562
8563 -extern unsigned long arch_align_stack(unsigned long sp);
8564 +#define arch_align_stack(x) ((x) & ~0xfUL)
8565
8566 #endif /* __ASM_EXEC_H */
8567 diff --git a/arch/s390/include/asm/uaccess.h b/arch/s390/include/asm/uaccess.h
8568 index 9c33ed4..e40cbef 100644
8569 --- a/arch/s390/include/asm/uaccess.h
8570 +++ b/arch/s390/include/asm/uaccess.h
8571 @@ -252,6 +252,10 @@ static inline unsigned long __must_check
8572 copy_to_user(void __user *to, const void *from, unsigned long n)
8573 {
8574 might_fault();
8575 +
8576 + if ((long)n < 0)
8577 + return n;
8578 +
8579 return __copy_to_user(to, from, n);
8580 }
8581
8582 @@ -275,6 +279,9 @@ copy_to_user(void __user *to, const void *from, unsigned long n)
8583 static inline unsigned long __must_check
8584 __copy_from_user(void *to, const void __user *from, unsigned long n)
8585 {
8586 + if ((long)n < 0)
8587 + return n;
8588 +
8589 if (__builtin_constant_p(n) && (n <= 256))
8590 return uaccess.copy_from_user_small(n, from, to);
8591 else
8592 @@ -306,10 +313,14 @@ __compiletime_warning("copy_from_user() buffer size is not provably correct")
8593 static inline unsigned long __must_check
8594 copy_from_user(void *to, const void __user *from, unsigned long n)
8595 {
8596 - unsigned int sz = __compiletime_object_size(to);
8597 + size_t sz = __compiletime_object_size(to);
8598
8599 might_fault();
8600 - if (unlikely(sz != -1 && sz < n)) {
8601 +
8602 + if ((long)n < 0)
8603 + return n;
8604 +
8605 + if (unlikely(sz != (size_t)-1 && sz < n)) {
8606 copy_from_user_overflow();
8607 return n;
8608 }
8609 diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
8610 index 7845e15..59c4353 100644
8611 --- a/arch/s390/kernel/module.c
8612 +++ b/arch/s390/kernel/module.c
8613 @@ -169,11 +169,11 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
8614
8615 /* Increase core size by size of got & plt and set start
8616 offsets for got and plt. */
8617 - me->core_size = ALIGN(me->core_size, 4);
8618 - me->arch.got_offset = me->core_size;
8619 - me->core_size += me->arch.got_size;
8620 - me->arch.plt_offset = me->core_size;
8621 - me->core_size += me->arch.plt_size;
8622 + me->core_size_rw = ALIGN(me->core_size_rw, 4);
8623 + me->arch.got_offset = me->core_size_rw;
8624 + me->core_size_rw += me->arch.got_size;
8625 + me->arch.plt_offset = me->core_size_rx;
8626 + me->core_size_rx += me->arch.plt_size;
8627 return 0;
8628 }
8629
8630 @@ -289,7 +289,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8631 if (info->got_initialized == 0) {
8632 Elf_Addr *gotent;
8633
8634 - gotent = me->module_core + me->arch.got_offset +
8635 + gotent = me->module_core_rw + me->arch.got_offset +
8636 info->got_offset;
8637 *gotent = val;
8638 info->got_initialized = 1;
8639 @@ -312,7 +312,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8640 rc = apply_rela_bits(loc, val, 0, 64, 0);
8641 else if (r_type == R_390_GOTENT ||
8642 r_type == R_390_GOTPLTENT) {
8643 - val += (Elf_Addr) me->module_core - loc;
8644 + val += (Elf_Addr) me->module_core_rw - loc;
8645 rc = apply_rela_bits(loc, val, 1, 32, 1);
8646 }
8647 break;
8648 @@ -325,7 +325,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8649 case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */
8650 if (info->plt_initialized == 0) {
8651 unsigned int *ip;
8652 - ip = me->module_core + me->arch.plt_offset +
8653 + ip = me->module_core_rx + me->arch.plt_offset +
8654 info->plt_offset;
8655 #ifndef CONFIG_64BIT
8656 ip[0] = 0x0d105810; /* basr 1,0; l 1,6(1); br 1 */
8657 @@ -350,7 +350,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8658 val - loc + 0xffffUL < 0x1ffffeUL) ||
8659 (r_type == R_390_PLT32DBL &&
8660 val - loc + 0xffffffffULL < 0x1fffffffeULL)))
8661 - val = (Elf_Addr) me->module_core +
8662 + val = (Elf_Addr) me->module_core_rx +
8663 me->arch.plt_offset +
8664 info->plt_offset;
8665 val += rela->r_addend - loc;
8666 @@ -372,7 +372,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8667 case R_390_GOTOFF32: /* 32 bit offset to GOT. */
8668 case R_390_GOTOFF64: /* 64 bit offset to GOT. */
8669 val = val + rela->r_addend -
8670 - ((Elf_Addr) me->module_core + me->arch.got_offset);
8671 + ((Elf_Addr) me->module_core_rw + me->arch.got_offset);
8672 if (r_type == R_390_GOTOFF16)
8673 rc = apply_rela_bits(loc, val, 0, 16, 0);
8674 else if (r_type == R_390_GOTOFF32)
8675 @@ -382,7 +382,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab,
8676 break;
8677 case R_390_GOTPC: /* 32 bit PC relative offset to GOT. */
8678 case R_390_GOTPCDBL: /* 32 bit PC rel. off. to GOT shifted by 1. */
8679 - val = (Elf_Addr) me->module_core + me->arch.got_offset +
8680 + val = (Elf_Addr) me->module_core_rw + me->arch.got_offset +
8681 rela->r_addend - loc;
8682 if (r_type == R_390_GOTPC)
8683 rc = apply_rela_bits(loc, val, 1, 32, 0);
8684 diff --git a/arch/s390/kernel/process.c b/arch/s390/kernel/process.c
8685 index c5dbb33..b41f4ee 100644
8686 --- a/arch/s390/kernel/process.c
8687 +++ b/arch/s390/kernel/process.c
8688 @@ -237,39 +237,3 @@ unsigned long get_wchan(struct task_struct *p)
8689 }
8690 return 0;
8691 }
8692 -
8693 -unsigned long arch_align_stack(unsigned long sp)
8694 -{
8695 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
8696 - sp -= get_random_int() & ~PAGE_MASK;
8697 - return sp & ~0xf;
8698 -}
8699 -
8700 -static inline unsigned long brk_rnd(void)
8701 -{
8702 - /* 8MB for 32bit, 1GB for 64bit */
8703 - if (is_32bit_task())
8704 - return (get_random_int() & 0x7ffUL) << PAGE_SHIFT;
8705 - else
8706 - return (get_random_int() & 0x3ffffUL) << PAGE_SHIFT;
8707 -}
8708 -
8709 -unsigned long arch_randomize_brk(struct mm_struct *mm)
8710 -{
8711 - unsigned long ret = PAGE_ALIGN(mm->brk + brk_rnd());
8712 -
8713 - if (ret < mm->brk)
8714 - return mm->brk;
8715 - return ret;
8716 -}
8717 -
8718 -unsigned long randomize_et_dyn(unsigned long base)
8719 -{
8720 - unsigned long ret = PAGE_ALIGN(base + brk_rnd());
8721 -
8722 - if (!(current->flags & PF_RANDOMIZE))
8723 - return base;
8724 - if (ret < base)
8725 - return base;
8726 - return ret;
8727 -}
8728 diff --git a/arch/s390/mm/mmap.c b/arch/s390/mm/mmap.c
8729 index 4002329..99b67cb 100644
8730 --- a/arch/s390/mm/mmap.c
8731 +++ b/arch/s390/mm/mmap.c
8732 @@ -90,9 +90,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8733 */
8734 if (mmap_is_legacy()) {
8735 mm->mmap_base = TASK_UNMAPPED_BASE;
8736 +
8737 +#ifdef CONFIG_PAX_RANDMMAP
8738 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8739 + mm->mmap_base += mm->delta_mmap;
8740 +#endif
8741 +
8742 mm->get_unmapped_area = arch_get_unmapped_area;
8743 } else {
8744 mm->mmap_base = mmap_base();
8745 +
8746 +#ifdef CONFIG_PAX_RANDMMAP
8747 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8748 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8749 +#endif
8750 +
8751 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
8752 }
8753 }
8754 @@ -173,9 +185,21 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
8755 */
8756 if (mmap_is_legacy()) {
8757 mm->mmap_base = TASK_UNMAPPED_BASE;
8758 +
8759 +#ifdef CONFIG_PAX_RANDMMAP
8760 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8761 + mm->mmap_base += mm->delta_mmap;
8762 +#endif
8763 +
8764 mm->get_unmapped_area = s390_get_unmapped_area;
8765 } else {
8766 mm->mmap_base = mmap_base();
8767 +
8768 +#ifdef CONFIG_PAX_RANDMMAP
8769 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8770 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
8771 +#endif
8772 +
8773 mm->get_unmapped_area = s390_get_unmapped_area_topdown;
8774 }
8775 }
8776 diff --git a/arch/score/include/asm/cache.h b/arch/score/include/asm/cache.h
8777 index ae3d59f..f65f075 100644
8778 --- a/arch/score/include/asm/cache.h
8779 +++ b/arch/score/include/asm/cache.h
8780 @@ -1,7 +1,9 @@
8781 #ifndef _ASM_SCORE_CACHE_H
8782 #define _ASM_SCORE_CACHE_H
8783
8784 +#include <linux/const.h>
8785 +
8786 #define L1_CACHE_SHIFT 4
8787 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8788 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8789
8790 #endif /* _ASM_SCORE_CACHE_H */
8791 diff --git a/arch/score/include/asm/exec.h b/arch/score/include/asm/exec.h
8792 index f9f3cd5..58ff438 100644
8793 --- a/arch/score/include/asm/exec.h
8794 +++ b/arch/score/include/asm/exec.h
8795 @@ -1,6 +1,6 @@
8796 #ifndef _ASM_SCORE_EXEC_H
8797 #define _ASM_SCORE_EXEC_H
8798
8799 -extern unsigned long arch_align_stack(unsigned long sp);
8800 +#define arch_align_stack(x) (x)
8801
8802 #endif /* _ASM_SCORE_EXEC_H */
8803 diff --git a/arch/score/kernel/process.c b/arch/score/kernel/process.c
8804 index a1519ad3..e8ac1ff 100644
8805 --- a/arch/score/kernel/process.c
8806 +++ b/arch/score/kernel/process.c
8807 @@ -116,8 +116,3 @@ unsigned long get_wchan(struct task_struct *task)
8808
8809 return task_pt_regs(task)->cp0_epc;
8810 }
8811 -
8812 -unsigned long arch_align_stack(unsigned long sp)
8813 -{
8814 - return sp;
8815 -}
8816 diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
8817 index ef9e555..331bd29 100644
8818 --- a/arch/sh/include/asm/cache.h
8819 +++ b/arch/sh/include/asm/cache.h
8820 @@ -9,10 +9,11 @@
8821 #define __ASM_SH_CACHE_H
8822 #ifdef __KERNEL__
8823
8824 +#include <linux/const.h>
8825 #include <linux/init.h>
8826 #include <cpu/cache.h>
8827
8828 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
8829 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
8830
8831 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
8832
8833 diff --git a/arch/sh/mm/mmap.c b/arch/sh/mm/mmap.c
8834 index 6777177..cb5e44f 100644
8835 --- a/arch/sh/mm/mmap.c
8836 +++ b/arch/sh/mm/mmap.c
8837 @@ -36,6 +36,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8838 struct mm_struct *mm = current->mm;
8839 struct vm_area_struct *vma;
8840 int do_colour_align;
8841 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8842 struct vm_unmapped_area_info info;
8843
8844 if (flags & MAP_FIXED) {
8845 @@ -55,6 +56,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8846 if (filp || (flags & MAP_SHARED))
8847 do_colour_align = 1;
8848
8849 +#ifdef CONFIG_PAX_RANDMMAP
8850 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8851 +#endif
8852 +
8853 if (addr) {
8854 if (do_colour_align)
8855 addr = COLOUR_ALIGN(addr, pgoff);
8856 @@ -62,14 +67,13 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr,
8857 addr = PAGE_ALIGN(addr);
8858
8859 vma = find_vma(mm, addr);
8860 - if (TASK_SIZE - len >= addr &&
8861 - (!vma || addr + len <= vma->vm_start))
8862 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8863 return addr;
8864 }
8865
8866 info.flags = 0;
8867 info.length = len;
8868 - info.low_limit = TASK_UNMAPPED_BASE;
8869 + info.low_limit = mm->mmap_base;
8870 info.high_limit = TASK_SIZE;
8871 info.align_mask = do_colour_align ? (PAGE_MASK & shm_align_mask) : 0;
8872 info.align_offset = pgoff << PAGE_SHIFT;
8873 @@ -85,6 +89,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8874 struct mm_struct *mm = current->mm;
8875 unsigned long addr = addr0;
8876 int do_colour_align;
8877 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
8878 struct vm_unmapped_area_info info;
8879
8880 if (flags & MAP_FIXED) {
8881 @@ -104,6 +109,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8882 if (filp || (flags & MAP_SHARED))
8883 do_colour_align = 1;
8884
8885 +#ifdef CONFIG_PAX_RANDMMAP
8886 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
8887 +#endif
8888 +
8889 /* requesting a specific address */
8890 if (addr) {
8891 if (do_colour_align)
8892 @@ -112,8 +121,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8893 addr = PAGE_ALIGN(addr);
8894
8895 vma = find_vma(mm, addr);
8896 - if (TASK_SIZE - len >= addr &&
8897 - (!vma || addr + len <= vma->vm_start))
8898 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
8899 return addr;
8900 }
8901
8902 @@ -135,6 +143,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
8903 VM_BUG_ON(addr != -ENOMEM);
8904 info.flags = 0;
8905 info.low_limit = TASK_UNMAPPED_BASE;
8906 +
8907 +#ifdef CONFIG_PAX_RANDMMAP
8908 + if (mm->pax_flags & MF_PAX_RANDMMAP)
8909 + info.low_limit += mm->delta_mmap;
8910 +#endif
8911 +
8912 info.high_limit = TASK_SIZE;
8913 addr = vm_unmapped_area(&info);
8914 }
8915 diff --git a/arch/sparc/include/asm/atomic_64.h b/arch/sparc/include/asm/atomic_64.h
8916 index be56a24..443328f 100644
8917 --- a/arch/sparc/include/asm/atomic_64.h
8918 +++ b/arch/sparc/include/asm/atomic_64.h
8919 @@ -14,18 +14,40 @@
8920 #define ATOMIC64_INIT(i) { (i) }
8921
8922 #define atomic_read(v) (*(volatile int *)&(v)->counter)
8923 +static inline int atomic_read_unchecked(const atomic_unchecked_t *v)
8924 +{
8925 + return v->counter;
8926 +}
8927 #define atomic64_read(v) (*(volatile long *)&(v)->counter)
8928 +static inline long atomic64_read_unchecked(const atomic64_unchecked_t *v)
8929 +{
8930 + return v->counter;
8931 +}
8932
8933 #define atomic_set(v, i) (((v)->counter) = i)
8934 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
8935 +{
8936 + v->counter = i;
8937 +}
8938 #define atomic64_set(v, i) (((v)->counter) = i)
8939 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
8940 +{
8941 + v->counter = i;
8942 +}
8943
8944 extern void atomic_add(int, atomic_t *);
8945 +extern void atomic_add_unchecked(int, atomic_unchecked_t *);
8946 extern void atomic64_add(long, atomic64_t *);
8947 +extern void atomic64_add_unchecked(long, atomic64_unchecked_t *);
8948 extern void atomic_sub(int, atomic_t *);
8949 +extern void atomic_sub_unchecked(int, atomic_unchecked_t *);
8950 extern void atomic64_sub(long, atomic64_t *);
8951 +extern void atomic64_sub_unchecked(long, atomic64_unchecked_t *);
8952
8953 extern int atomic_add_ret(int, atomic_t *);
8954 +extern int atomic_add_ret_unchecked(int, atomic_unchecked_t *);
8955 extern long atomic64_add_ret(long, atomic64_t *);
8956 +extern long atomic64_add_ret_unchecked(long, atomic64_unchecked_t *);
8957 extern int atomic_sub_ret(int, atomic_t *);
8958 extern long atomic64_sub_ret(long, atomic64_t *);
8959
8960 @@ -33,13 +55,29 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8961 #define atomic64_dec_return(v) atomic64_sub_ret(1, v)
8962
8963 #define atomic_inc_return(v) atomic_add_ret(1, v)
8964 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
8965 +{
8966 + return atomic_add_ret_unchecked(1, v);
8967 +}
8968 #define atomic64_inc_return(v) atomic64_add_ret(1, v)
8969 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
8970 +{
8971 + return atomic64_add_ret_unchecked(1, v);
8972 +}
8973
8974 #define atomic_sub_return(i, v) atomic_sub_ret(i, v)
8975 #define atomic64_sub_return(i, v) atomic64_sub_ret(i, v)
8976
8977 #define atomic_add_return(i, v) atomic_add_ret(i, v)
8978 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
8979 +{
8980 + return atomic_add_ret_unchecked(i, v);
8981 +}
8982 #define atomic64_add_return(i, v) atomic64_add_ret(i, v)
8983 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
8984 +{
8985 + return atomic64_add_ret_unchecked(i, v);
8986 +}
8987
8988 /*
8989 * atomic_inc_and_test - increment and test
8990 @@ -50,6 +88,10 @@ extern long atomic64_sub_ret(long, atomic64_t *);
8991 * other cases.
8992 */
8993 #define atomic_inc_and_test(v) (atomic_inc_return(v) == 0)
8994 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
8995 +{
8996 + return atomic_inc_return_unchecked(v) == 0;
8997 +}
8998 #define atomic64_inc_and_test(v) (atomic64_inc_return(v) == 0)
8999
9000 #define atomic_sub_and_test(i, v) (atomic_sub_ret(i, v) == 0)
9001 @@ -59,25 +101,60 @@ extern long atomic64_sub_ret(long, atomic64_t *);
9002 #define atomic64_dec_and_test(v) (atomic64_sub_ret(1, v) == 0)
9003
9004 #define atomic_inc(v) atomic_add(1, v)
9005 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
9006 +{
9007 + atomic_add_unchecked(1, v);
9008 +}
9009 #define atomic64_inc(v) atomic64_add(1, v)
9010 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
9011 +{
9012 + atomic64_add_unchecked(1, v);
9013 +}
9014
9015 #define atomic_dec(v) atomic_sub(1, v)
9016 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
9017 +{
9018 + atomic_sub_unchecked(1, v);
9019 +}
9020 #define atomic64_dec(v) atomic64_sub(1, v)
9021 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
9022 +{
9023 + atomic64_sub_unchecked(1, v);
9024 +}
9025
9026 #define atomic_add_negative(i, v) (atomic_add_ret(i, v) < 0)
9027 #define atomic64_add_negative(i, v) (atomic64_add_ret(i, v) < 0)
9028
9029 #define atomic_cmpxchg(v, o, n) (cmpxchg(&((v)->counter), (o), (n)))
9030 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
9031 +{
9032 + return cmpxchg(&v->counter, old, new);
9033 +}
9034 #define atomic_xchg(v, new) (xchg(&((v)->counter), new))
9035 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
9036 +{
9037 + return xchg(&v->counter, new);
9038 +}
9039
9040 static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9041 {
9042 - int c, old;
9043 + int c, old, new;
9044 c = atomic_read(v);
9045 for (;;) {
9046 - if (unlikely(c == (u)))
9047 + if (unlikely(c == u))
9048 break;
9049 - old = atomic_cmpxchg((v), c, c + (a));
9050 +
9051 + asm volatile("addcc %2, %0, %0\n"
9052 +
9053 +#ifdef CONFIG_PAX_REFCOUNT
9054 + "tvs %%icc, 6\n"
9055 +#endif
9056 +
9057 + : "=r" (new)
9058 + : "0" (c), "ir" (a)
9059 + : "cc");
9060 +
9061 + old = atomic_cmpxchg(v, c, new);
9062 if (likely(old == c))
9063 break;
9064 c = old;
9065 @@ -88,20 +165,35 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
9066 #define atomic64_cmpxchg(v, o, n) \
9067 ((__typeof__((v)->counter))cmpxchg(&((v)->counter), (o), (n)))
9068 #define atomic64_xchg(v, new) (xchg(&((v)->counter), new))
9069 +static inline long atomic64_xchg_unchecked(atomic64_unchecked_t *v, long new)
9070 +{
9071 + return xchg(&v->counter, new);
9072 +}
9073
9074 static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
9075 {
9076 - long c, old;
9077 + long c, old, new;
9078 c = atomic64_read(v);
9079 for (;;) {
9080 - if (unlikely(c == (u)))
9081 + if (unlikely(c == u))
9082 break;
9083 - old = atomic64_cmpxchg((v), c, c + (a));
9084 +
9085 + asm volatile("addcc %2, %0, %0\n"
9086 +
9087 +#ifdef CONFIG_PAX_REFCOUNT
9088 + "tvs %%xcc, 6\n"
9089 +#endif
9090 +
9091 + : "=r" (new)
9092 + : "0" (c), "ir" (a)
9093 + : "cc");
9094 +
9095 + old = atomic64_cmpxchg(v, c, new);
9096 if (likely(old == c))
9097 break;
9098 c = old;
9099 }
9100 - return c != (u);
9101 + return c != u;
9102 }
9103
9104 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
9105 diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
9106 index 5bb6991..5c2132e 100644
9107 --- a/arch/sparc/include/asm/cache.h
9108 +++ b/arch/sparc/include/asm/cache.h
9109 @@ -7,10 +7,12 @@
9110 #ifndef _SPARC_CACHE_H
9111 #define _SPARC_CACHE_H
9112
9113 +#include <linux/const.h>
9114 +
9115 #define ARCH_SLAB_MINALIGN __alignof__(unsigned long long)
9116
9117 #define L1_CACHE_SHIFT 5
9118 -#define L1_CACHE_BYTES 32
9119 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
9120
9121 #ifdef CONFIG_SPARC32
9122 #define SMP_CACHE_BYTES_SHIFT 5
9123 diff --git a/arch/sparc/include/asm/elf_32.h b/arch/sparc/include/asm/elf_32.h
9124 index a24e41f..47677ff 100644
9125 --- a/arch/sparc/include/asm/elf_32.h
9126 +++ b/arch/sparc/include/asm/elf_32.h
9127 @@ -114,6 +114,13 @@ typedef struct {
9128
9129 #define ELF_ET_DYN_BASE (TASK_UNMAPPED_BASE)
9130
9131 +#ifdef CONFIG_PAX_ASLR
9132 +#define PAX_ELF_ET_DYN_BASE 0x10000UL
9133 +
9134 +#define PAX_DELTA_MMAP_LEN 16
9135 +#define PAX_DELTA_STACK_LEN 16
9136 +#endif
9137 +
9138 /* This yields a mask that user programs can use to figure out what
9139 instruction set this cpu supports. This can NOT be done in userspace
9140 on Sparc. */
9141 diff --git a/arch/sparc/include/asm/elf_64.h b/arch/sparc/include/asm/elf_64.h
9142 index 370ca1e..d4f4a98 100644
9143 --- a/arch/sparc/include/asm/elf_64.h
9144 +++ b/arch/sparc/include/asm/elf_64.h
9145 @@ -189,6 +189,13 @@ typedef struct {
9146 #define ELF_ET_DYN_BASE 0x0000010000000000UL
9147 #define COMPAT_ELF_ET_DYN_BASE 0x0000000070000000UL
9148
9149 +#ifdef CONFIG_PAX_ASLR
9150 +#define PAX_ELF_ET_DYN_BASE (test_thread_flag(TIF_32BIT) ? 0x10000UL : 0x100000UL)
9151 +
9152 +#define PAX_DELTA_MMAP_LEN (test_thread_flag(TIF_32BIT) ? 14 : 28)
9153 +#define PAX_DELTA_STACK_LEN (test_thread_flag(TIF_32BIT) ? 15 : 29)
9154 +#endif
9155 +
9156 extern unsigned long sparc64_elf_hwcap;
9157 #define ELF_HWCAP sparc64_elf_hwcap
9158
9159 diff --git a/arch/sparc/include/asm/pgalloc_32.h b/arch/sparc/include/asm/pgalloc_32.h
9160 index 9b1c36d..209298b 100644
9161 --- a/arch/sparc/include/asm/pgalloc_32.h
9162 +++ b/arch/sparc/include/asm/pgalloc_32.h
9163 @@ -33,6 +33,7 @@ static inline void pgd_set(pgd_t * pgdp, pmd_t * pmdp)
9164 }
9165
9166 #define pgd_populate(MM, PGD, PMD) pgd_set(PGD, PMD)
9167 +#define pgd_populate_kernel(MM, PGD, PMD) pgd_populate((MM), (PGD), (PMD))
9168
9169 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm,
9170 unsigned long address)
9171 diff --git a/arch/sparc/include/asm/pgalloc_64.h b/arch/sparc/include/asm/pgalloc_64.h
9172 index bcfe063..b333142 100644
9173 --- a/arch/sparc/include/asm/pgalloc_64.h
9174 +++ b/arch/sparc/include/asm/pgalloc_64.h
9175 @@ -26,6 +26,7 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)
9176 }
9177
9178 #define pud_populate(MM, PUD, PMD) pud_set(PUD, PMD)
9179 +#define pud_populate_kernel(MM, PUD, PMD) pud_populate((MM), (PUD), (PMD))
9180
9181 static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long addr)
9182 {
9183 diff --git a/arch/sparc/include/asm/pgtable_32.h b/arch/sparc/include/asm/pgtable_32.h
9184 index 502f632..da1917f 100644
9185 --- a/arch/sparc/include/asm/pgtable_32.h
9186 +++ b/arch/sparc/include/asm/pgtable_32.h
9187 @@ -50,6 +50,9 @@ extern unsigned long calc_highpages(void);
9188 #define PAGE_SHARED SRMMU_PAGE_SHARED
9189 #define PAGE_COPY SRMMU_PAGE_COPY
9190 #define PAGE_READONLY SRMMU_PAGE_RDONLY
9191 +#define PAGE_SHARED_NOEXEC SRMMU_PAGE_SHARED_NOEXEC
9192 +#define PAGE_COPY_NOEXEC SRMMU_PAGE_COPY_NOEXEC
9193 +#define PAGE_READONLY_NOEXEC SRMMU_PAGE_RDONLY_NOEXEC
9194 #define PAGE_KERNEL SRMMU_PAGE_KERNEL
9195
9196 /* Top-level page directory - dummy used by init-mm.
9197 @@ -62,18 +65,18 @@ extern unsigned long ptr_in_current_pgd;
9198
9199 /* xwr */
9200 #define __P000 PAGE_NONE
9201 -#define __P001 PAGE_READONLY
9202 -#define __P010 PAGE_COPY
9203 -#define __P011 PAGE_COPY
9204 +#define __P001 PAGE_READONLY_NOEXEC
9205 +#define __P010 PAGE_COPY_NOEXEC
9206 +#define __P011 PAGE_COPY_NOEXEC
9207 #define __P100 PAGE_READONLY
9208 #define __P101 PAGE_READONLY
9209 #define __P110 PAGE_COPY
9210 #define __P111 PAGE_COPY
9211
9212 #define __S000 PAGE_NONE
9213 -#define __S001 PAGE_READONLY
9214 -#define __S010 PAGE_SHARED
9215 -#define __S011 PAGE_SHARED
9216 +#define __S001 PAGE_READONLY_NOEXEC
9217 +#define __S010 PAGE_SHARED_NOEXEC
9218 +#define __S011 PAGE_SHARED_NOEXEC
9219 #define __S100 PAGE_READONLY
9220 #define __S101 PAGE_READONLY
9221 #define __S110 PAGE_SHARED
9222 diff --git a/arch/sparc/include/asm/pgtsrmmu.h b/arch/sparc/include/asm/pgtsrmmu.h
9223 index 79da178..c2eede8 100644
9224 --- a/arch/sparc/include/asm/pgtsrmmu.h
9225 +++ b/arch/sparc/include/asm/pgtsrmmu.h
9226 @@ -115,6 +115,11 @@
9227 SRMMU_EXEC | SRMMU_REF)
9228 #define SRMMU_PAGE_RDONLY __pgprot(SRMMU_VALID | SRMMU_CACHE | \
9229 SRMMU_EXEC | SRMMU_REF)
9230 +
9231 +#define SRMMU_PAGE_SHARED_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_WRITE | SRMMU_REF)
9232 +#define SRMMU_PAGE_COPY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9233 +#define SRMMU_PAGE_RDONLY_NOEXEC __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_REF)
9234 +
9235 #define SRMMU_PAGE_KERNEL __pgprot(SRMMU_VALID | SRMMU_CACHE | SRMMU_PRIV | \
9236 SRMMU_DIRTY | SRMMU_REF)
9237
9238 diff --git a/arch/sparc/include/asm/spinlock_64.h b/arch/sparc/include/asm/spinlock_64.h
9239 index 9689176..63c18ea 100644
9240 --- a/arch/sparc/include/asm/spinlock_64.h
9241 +++ b/arch/sparc/include/asm/spinlock_64.h
9242 @@ -92,14 +92,19 @@ static inline void arch_spin_lock_flags(arch_spinlock_t *lock, unsigned long fla
9243
9244 /* Multi-reader locks, these are much saner than the 32-bit Sparc ones... */
9245
9246 -static void inline arch_read_lock(arch_rwlock_t *lock)
9247 +static inline void arch_read_lock(arch_rwlock_t *lock)
9248 {
9249 unsigned long tmp1, tmp2;
9250
9251 __asm__ __volatile__ (
9252 "1: ldsw [%2], %0\n"
9253 " brlz,pn %0, 2f\n"
9254 -"4: add %0, 1, %1\n"
9255 +"4: addcc %0, 1, %1\n"
9256 +
9257 +#ifdef CONFIG_PAX_REFCOUNT
9258 +" tvs %%icc, 6\n"
9259 +#endif
9260 +
9261 " cas [%2], %0, %1\n"
9262 " cmp %0, %1\n"
9263 " bne,pn %%icc, 1b\n"
9264 @@ -112,10 +117,10 @@ static void inline arch_read_lock(arch_rwlock_t *lock)
9265 " .previous"
9266 : "=&r" (tmp1), "=&r" (tmp2)
9267 : "r" (lock)
9268 - : "memory");
9269 + : "memory", "cc");
9270 }
9271
9272 -static int inline arch_read_trylock(arch_rwlock_t *lock)
9273 +static inline int arch_read_trylock(arch_rwlock_t *lock)
9274 {
9275 int tmp1, tmp2;
9276
9277 @@ -123,7 +128,12 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9278 "1: ldsw [%2], %0\n"
9279 " brlz,a,pn %0, 2f\n"
9280 " mov 0, %0\n"
9281 -" add %0, 1, %1\n"
9282 +" addcc %0, 1, %1\n"
9283 +
9284 +#ifdef CONFIG_PAX_REFCOUNT
9285 +" tvs %%icc, 6\n"
9286 +#endif
9287 +
9288 " cas [%2], %0, %1\n"
9289 " cmp %0, %1\n"
9290 " bne,pn %%icc, 1b\n"
9291 @@ -136,13 +146,18 @@ static int inline arch_read_trylock(arch_rwlock_t *lock)
9292 return tmp1;
9293 }
9294
9295 -static void inline arch_read_unlock(arch_rwlock_t *lock)
9296 +static inline void arch_read_unlock(arch_rwlock_t *lock)
9297 {
9298 unsigned long tmp1, tmp2;
9299
9300 __asm__ __volatile__(
9301 "1: lduw [%2], %0\n"
9302 -" sub %0, 1, %1\n"
9303 +" subcc %0, 1, %1\n"
9304 +
9305 +#ifdef CONFIG_PAX_REFCOUNT
9306 +" tvs %%icc, 6\n"
9307 +#endif
9308 +
9309 " cas [%2], %0, %1\n"
9310 " cmp %0, %1\n"
9311 " bne,pn %%xcc, 1b\n"
9312 @@ -152,7 +167,7 @@ static void inline arch_read_unlock(arch_rwlock_t *lock)
9313 : "memory");
9314 }
9315
9316 -static void inline arch_write_lock(arch_rwlock_t *lock)
9317 +static inline void arch_write_lock(arch_rwlock_t *lock)
9318 {
9319 unsigned long mask, tmp1, tmp2;
9320
9321 @@ -177,7 +192,7 @@ static void inline arch_write_lock(arch_rwlock_t *lock)
9322 : "memory");
9323 }
9324
9325 -static void inline arch_write_unlock(arch_rwlock_t *lock)
9326 +static inline void arch_write_unlock(arch_rwlock_t *lock)
9327 {
9328 __asm__ __volatile__(
9329 " stw %%g0, [%0]"
9330 @@ -186,7 +201,7 @@ static void inline arch_write_unlock(arch_rwlock_t *lock)
9331 : "memory");
9332 }
9333
9334 -static int inline arch_write_trylock(arch_rwlock_t *lock)
9335 +static inline int arch_write_trylock(arch_rwlock_t *lock)
9336 {
9337 unsigned long mask, tmp1, tmp2, result;
9338
9339 diff --git a/arch/sparc/include/asm/thread_info_32.h b/arch/sparc/include/asm/thread_info_32.h
9340 index dd38075..e7cac83 100644
9341 --- a/arch/sparc/include/asm/thread_info_32.h
9342 +++ b/arch/sparc/include/asm/thread_info_32.h
9343 @@ -49,6 +49,8 @@ struct thread_info {
9344 unsigned long w_saved;
9345
9346 struct restart_block restart_block;
9347 +
9348 + unsigned long lowest_stack;
9349 };
9350
9351 /*
9352 diff --git a/arch/sparc/include/asm/thread_info_64.h b/arch/sparc/include/asm/thread_info_64.h
9353 index d5e5042..9bfee76 100644
9354 --- a/arch/sparc/include/asm/thread_info_64.h
9355 +++ b/arch/sparc/include/asm/thread_info_64.h
9356 @@ -63,6 +63,8 @@ struct thread_info {
9357 struct pt_regs *kern_una_regs;
9358 unsigned int kern_una_insn;
9359
9360 + unsigned long lowest_stack;
9361 +
9362 unsigned long fpregs[0] __attribute__ ((aligned(64)));
9363 };
9364
9365 @@ -192,10 +194,11 @@ register struct thread_info *current_thread_info_reg asm("g6");
9366 #define TIF_UNALIGNED 5 /* allowed to do unaligned accesses */
9367 /* flag bit 6 is available */
9368 #define TIF_32BIT 7 /* 32-bit binary */
9369 -/* flag bit 8 is available */
9370 +#define TIF_GRSEC_SETXID 8 /* update credentials on syscall entry/exit */
9371 #define TIF_SECCOMP 9 /* secure computing */
9372 #define TIF_SYSCALL_AUDIT 10 /* syscall auditing active */
9373 #define TIF_SYSCALL_TRACEPOINT 11 /* syscall tracepoint instrumentation */
9374 +
9375 /* NOTE: Thread flags >= 12 should be ones we have no interest
9376 * in using in assembly, else we can't use the mask as
9377 * an immediate value in instructions such as andcc.
9378 @@ -214,12 +217,18 @@ register struct thread_info *current_thread_info_reg asm("g6");
9379 #define _TIF_SYSCALL_AUDIT (1<<TIF_SYSCALL_AUDIT)
9380 #define _TIF_SYSCALL_TRACEPOINT (1<<TIF_SYSCALL_TRACEPOINT)
9381 #define _TIF_POLLING_NRFLAG (1<<TIF_POLLING_NRFLAG)
9382 +#define _TIF_GRSEC_SETXID (1<<TIF_GRSEC_SETXID)
9383
9384 #define _TIF_USER_WORK_MASK ((0xff << TI_FLAG_WSAVED_SHIFT) | \
9385 _TIF_DO_NOTIFY_RESUME_MASK | \
9386 _TIF_NEED_RESCHED)
9387 #define _TIF_DO_NOTIFY_RESUME_MASK (_TIF_NOTIFY_RESUME | _TIF_SIGPENDING)
9388
9389 +#define _TIF_WORK_SYSCALL \
9390 + (_TIF_SYSCALL_TRACE | _TIF_SECCOMP | _TIF_SYSCALL_AUDIT | \
9391 + _TIF_SYSCALL_TRACEPOINT | _TIF_GRSEC_SETXID)
9392 +
9393 +
9394 /*
9395 * Thread-synchronous status.
9396 *
9397 diff --git a/arch/sparc/include/asm/uaccess.h b/arch/sparc/include/asm/uaccess.h
9398 index 0167d26..767bb0c 100644
9399 --- a/arch/sparc/include/asm/uaccess.h
9400 +++ b/arch/sparc/include/asm/uaccess.h
9401 @@ -1,5 +1,6 @@
9402 #ifndef ___ASM_SPARC_UACCESS_H
9403 #define ___ASM_SPARC_UACCESS_H
9404 +
9405 #if defined(__sparc__) && defined(__arch64__)
9406 #include <asm/uaccess_64.h>
9407 #else
9408 diff --git a/arch/sparc/include/asm/uaccess_32.h b/arch/sparc/include/asm/uaccess_32.h
9409 index 53a28dd..50c38c3 100644
9410 --- a/arch/sparc/include/asm/uaccess_32.h
9411 +++ b/arch/sparc/include/asm/uaccess_32.h
9412 @@ -250,27 +250,46 @@ extern unsigned long __copy_user(void __user *to, const void __user *from, unsig
9413
9414 static inline unsigned long copy_to_user(void __user *to, const void *from, unsigned long n)
9415 {
9416 - if (n && __access_ok((unsigned long) to, n))
9417 + if ((long)n < 0)
9418 + return n;
9419 +
9420 + if (n && __access_ok((unsigned long) to, n)) {
9421 + if (!__builtin_constant_p(n))
9422 + check_object_size(from, n, true);
9423 return __copy_user(to, (__force void __user *) from, n);
9424 - else
9425 + } else
9426 return n;
9427 }
9428
9429 static inline unsigned long __copy_to_user(void __user *to, const void *from, unsigned long n)
9430 {
9431 + if ((long)n < 0)
9432 + return n;
9433 +
9434 + if (!__builtin_constant_p(n))
9435 + check_object_size(from, n, true);
9436 +
9437 return __copy_user(to, (__force void __user *) from, n);
9438 }
9439
9440 static inline unsigned long copy_from_user(void *to, const void __user *from, unsigned long n)
9441 {
9442 - if (n && __access_ok((unsigned long) from, n))
9443 + if ((long)n < 0)
9444 + return n;
9445 +
9446 + if (n && __access_ok((unsigned long) from, n)) {
9447 + if (!__builtin_constant_p(n))
9448 + check_object_size(to, n, false);
9449 return __copy_user((__force void __user *) to, from, n);
9450 - else
9451 + } else
9452 return n;
9453 }
9454
9455 static inline unsigned long __copy_from_user(void *to, const void __user *from, unsigned long n)
9456 {
9457 + if ((long)n < 0)
9458 + return n;
9459 +
9460 return __copy_user((__force void __user *) to, from, n);
9461 }
9462
9463 diff --git a/arch/sparc/include/asm/uaccess_64.h b/arch/sparc/include/asm/uaccess_64.h
9464 index e562d3c..191f176 100644
9465 --- a/arch/sparc/include/asm/uaccess_64.h
9466 +++ b/arch/sparc/include/asm/uaccess_64.h
9467 @@ -10,6 +10,7 @@
9468 #include <linux/compiler.h>
9469 #include <linux/string.h>
9470 #include <linux/thread_info.h>
9471 +#include <linux/kernel.h>
9472 #include <asm/asi.h>
9473 #include <asm/spitfire.h>
9474 #include <asm-generic/uaccess-unaligned.h>
9475 @@ -214,8 +215,15 @@ extern unsigned long copy_from_user_fixup(void *to, const void __user *from,
9476 static inline unsigned long __must_check
9477 copy_from_user(void *to, const void __user *from, unsigned long size)
9478 {
9479 - unsigned long ret = ___copy_from_user(to, from, size);
9480 + unsigned long ret;
9481
9482 + if ((long)size < 0 || size > INT_MAX)
9483 + return size;
9484 +
9485 + if (!__builtin_constant_p(size))
9486 + check_object_size(to, size, false);
9487 +
9488 + ret = ___copy_from_user(to, from, size);
9489 if (unlikely(ret))
9490 ret = copy_from_user_fixup(to, from, size);
9491
9492 @@ -231,8 +239,15 @@ extern unsigned long copy_to_user_fixup(void __user *to, const void *from,
9493 static inline unsigned long __must_check
9494 copy_to_user(void __user *to, const void *from, unsigned long size)
9495 {
9496 - unsigned long ret = ___copy_to_user(to, from, size);
9497 + unsigned long ret;
9498
9499 + if ((long)size < 0 || size > INT_MAX)
9500 + return size;
9501 +
9502 + if (!__builtin_constant_p(size))
9503 + check_object_size(from, size, true);
9504 +
9505 + ret = ___copy_to_user(to, from, size);
9506 if (unlikely(ret))
9507 ret = copy_to_user_fixup(to, from, size);
9508 return ret;
9509 diff --git a/arch/sparc/kernel/Makefile b/arch/sparc/kernel/Makefile
9510 index d15cc17..d0ae796 100644
9511 --- a/arch/sparc/kernel/Makefile
9512 +++ b/arch/sparc/kernel/Makefile
9513 @@ -4,7 +4,7 @@
9514 #
9515
9516 asflags-y := -ansi
9517 -ccflags-y := -Werror
9518 +#ccflags-y := -Werror
9519
9520 extra-y := head_$(BITS).o
9521
9522 diff --git a/arch/sparc/kernel/process_32.c b/arch/sparc/kernel/process_32.c
9523 index fdd819d..5af08c8 100644
9524 --- a/arch/sparc/kernel/process_32.c
9525 +++ b/arch/sparc/kernel/process_32.c
9526 @@ -116,14 +116,14 @@ void show_regs(struct pt_regs *r)
9527
9528 printk("PSR: %08lx PC: %08lx NPC: %08lx Y: %08lx %s\n",
9529 r->psr, r->pc, r->npc, r->y, print_tainted());
9530 - printk("PC: <%pS>\n", (void *) r->pc);
9531 + printk("PC: <%pA>\n", (void *) r->pc);
9532 printk("%%G: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9533 r->u_regs[0], r->u_regs[1], r->u_regs[2], r->u_regs[3],
9534 r->u_regs[4], r->u_regs[5], r->u_regs[6], r->u_regs[7]);
9535 printk("%%O: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9536 r->u_regs[8], r->u_regs[9], r->u_regs[10], r->u_regs[11],
9537 r->u_regs[12], r->u_regs[13], r->u_regs[14], r->u_regs[15]);
9538 - printk("RPC: <%pS>\n", (void *) r->u_regs[15]);
9539 + printk("RPC: <%pA>\n", (void *) r->u_regs[15]);
9540
9541 printk("%%L: %08lx %08lx %08lx %08lx %08lx %08lx %08lx %08lx\n",
9542 rw->locals[0], rw->locals[1], rw->locals[2], rw->locals[3],
9543 @@ -160,7 +160,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
9544 rw = (struct reg_window32 *) fp;
9545 pc = rw->ins[7];
9546 printk("[%08lx : ", pc);
9547 - printk("%pS ] ", (void *) pc);
9548 + printk("%pA ] ", (void *) pc);
9549 fp = rw->ins[6];
9550 } while (++count < 16);
9551 printk("\n");
9552 diff --git a/arch/sparc/kernel/process_64.c b/arch/sparc/kernel/process_64.c
9553 index baebab2..9cd13b1 100644
9554 --- a/arch/sparc/kernel/process_64.c
9555 +++ b/arch/sparc/kernel/process_64.c
9556 @@ -158,7 +158,7 @@ static void show_regwindow(struct pt_regs *regs)
9557 printk("i4: %016lx i5: %016lx i6: %016lx i7: %016lx\n",
9558 rwk->ins[4], rwk->ins[5], rwk->ins[6], rwk->ins[7]);
9559 if (regs->tstate & TSTATE_PRIV)
9560 - printk("I7: <%pS>\n", (void *) rwk->ins[7]);
9561 + printk("I7: <%pA>\n", (void *) rwk->ins[7]);
9562 }
9563
9564 void show_regs(struct pt_regs *regs)
9565 @@ -167,7 +167,7 @@ void show_regs(struct pt_regs *regs)
9566
9567 printk("TSTATE: %016lx TPC: %016lx TNPC: %016lx Y: %08x %s\n", regs->tstate,
9568 regs->tpc, regs->tnpc, regs->y, print_tainted());
9569 - printk("TPC: <%pS>\n", (void *) regs->tpc);
9570 + printk("TPC: <%pA>\n", (void *) regs->tpc);
9571 printk("g0: %016lx g1: %016lx g2: %016lx g3: %016lx\n",
9572 regs->u_regs[0], regs->u_regs[1], regs->u_regs[2],
9573 regs->u_regs[3]);
9574 @@ -180,7 +180,7 @@ void show_regs(struct pt_regs *regs)
9575 printk("o4: %016lx o5: %016lx sp: %016lx ret_pc: %016lx\n",
9576 regs->u_regs[12], regs->u_regs[13], regs->u_regs[14],
9577 regs->u_regs[15]);
9578 - printk("RPC: <%pS>\n", (void *) regs->u_regs[15]);
9579 + printk("RPC: <%pA>\n", (void *) regs->u_regs[15]);
9580 show_regwindow(regs);
9581 show_stack(current, (unsigned long *) regs->u_regs[UREG_FP]);
9582 }
9583 @@ -269,7 +269,7 @@ void arch_trigger_all_cpu_backtrace(void)
9584 ((tp && tp->task) ? tp->task->pid : -1));
9585
9586 if (gp->tstate & TSTATE_PRIV) {
9587 - printk(" TPC[%pS] O7[%pS] I7[%pS] RPC[%pS]\n",
9588 + printk(" TPC[%pA] O7[%pA] I7[%pA] RPC[%pA]\n",
9589 (void *) gp->tpc,
9590 (void *) gp->o7,
9591 (void *) gp->i7,
9592 diff --git a/arch/sparc/kernel/prom_common.c b/arch/sparc/kernel/prom_common.c
9593 index 79cc0d1..ec62734 100644
9594 --- a/arch/sparc/kernel/prom_common.c
9595 +++ b/arch/sparc/kernel/prom_common.c
9596 @@ -144,7 +144,7 @@ static int __init prom_common_nextprop(phandle node, char *prev, char *buf)
9597
9598 unsigned int prom_early_allocated __initdata;
9599
9600 -static struct of_pdt_ops prom_sparc_ops __initdata = {
9601 +static struct of_pdt_ops prom_sparc_ops __initconst = {
9602 .nextprop = prom_common_nextprop,
9603 .getproplen = prom_getproplen,
9604 .getproperty = prom_getproperty,
9605 diff --git a/arch/sparc/kernel/ptrace_64.c b/arch/sparc/kernel/ptrace_64.c
9606 index 773c1f2..a8bdd87 100644
9607 --- a/arch/sparc/kernel/ptrace_64.c
9608 +++ b/arch/sparc/kernel/ptrace_64.c
9609 @@ -1059,6 +1059,10 @@ long arch_ptrace(struct task_struct *child, long request,
9610 return ret;
9611 }
9612
9613 +#ifdef CONFIG_GRKERNSEC_SETXID
9614 +extern void gr_delayed_cred_worker(void);
9615 +#endif
9616 +
9617 asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9618 {
9619 int ret = 0;
9620 @@ -1066,6 +1070,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9621 /* do the secure computing check first */
9622 secure_computing_strict(regs->u_regs[UREG_G1]);
9623
9624 +#ifdef CONFIG_GRKERNSEC_SETXID
9625 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9626 + gr_delayed_cred_worker();
9627 +#endif
9628 +
9629 if (test_thread_flag(TIF_SYSCALL_TRACE))
9630 ret = tracehook_report_syscall_entry(regs);
9631
9632 @@ -1086,6 +1095,11 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs)
9633
9634 asmlinkage void syscall_trace_leave(struct pt_regs *regs)
9635 {
9636 +#ifdef CONFIG_GRKERNSEC_SETXID
9637 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
9638 + gr_delayed_cred_worker();
9639 +#endif
9640 +
9641 audit_syscall_exit(regs);
9642
9643 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
9644 diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c
9645 index e142545..fd29654 100644
9646 --- a/arch/sparc/kernel/smp_64.c
9647 +++ b/arch/sparc/kernel/smp_64.c
9648 @@ -869,8 +869,8 @@ extern unsigned long xcall_flush_dcache_page_cheetah;
9649 extern unsigned long xcall_flush_dcache_page_spitfire;
9650
9651 #ifdef CONFIG_DEBUG_DCFLUSH
9652 -extern atomic_t dcpage_flushes;
9653 -extern atomic_t dcpage_flushes_xcall;
9654 +extern atomic_unchecked_t dcpage_flushes;
9655 +extern atomic_unchecked_t dcpage_flushes_xcall;
9656 #endif
9657
9658 static inline void __local_flush_dcache_page(struct page *page)
9659 @@ -894,7 +894,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9660 return;
9661
9662 #ifdef CONFIG_DEBUG_DCFLUSH
9663 - atomic_inc(&dcpage_flushes);
9664 + atomic_inc_unchecked(&dcpage_flushes);
9665 #endif
9666
9667 this_cpu = get_cpu();
9668 @@ -918,7 +918,7 @@ void smp_flush_dcache_page_impl(struct page *page, int cpu)
9669 xcall_deliver(data0, __pa(pg_addr),
9670 (u64) pg_addr, cpumask_of(cpu));
9671 #ifdef CONFIG_DEBUG_DCFLUSH
9672 - atomic_inc(&dcpage_flushes_xcall);
9673 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9674 #endif
9675 }
9676 }
9677 @@ -937,7 +937,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9678 preempt_disable();
9679
9680 #ifdef CONFIG_DEBUG_DCFLUSH
9681 - atomic_inc(&dcpage_flushes);
9682 + atomic_inc_unchecked(&dcpage_flushes);
9683 #endif
9684 data0 = 0;
9685 pg_addr = page_address(page);
9686 @@ -954,7 +954,7 @@ void flush_dcache_page_all(struct mm_struct *mm, struct page *page)
9687 xcall_deliver(data0, __pa(pg_addr),
9688 (u64) pg_addr, cpu_online_mask);
9689 #ifdef CONFIG_DEBUG_DCFLUSH
9690 - atomic_inc(&dcpage_flushes_xcall);
9691 + atomic_inc_unchecked(&dcpage_flushes_xcall);
9692 #endif
9693 }
9694 __local_flush_dcache_page(page);
9695 diff --git a/arch/sparc/kernel/sys_sparc_32.c b/arch/sparc/kernel/sys_sparc_32.c
9696 index 3a8d184..49498a8 100644
9697 --- a/arch/sparc/kernel/sys_sparc_32.c
9698 +++ b/arch/sparc/kernel/sys_sparc_32.c
9699 @@ -52,7 +52,7 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9700 if (len > TASK_SIZE - PAGE_SIZE)
9701 return -ENOMEM;
9702 if (!addr)
9703 - addr = TASK_UNMAPPED_BASE;
9704 + addr = current->mm->mmap_base;
9705
9706 info.flags = 0;
9707 info.length = len;
9708 diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c
9709 index 51561b8..8256764 100644
9710 --- a/arch/sparc/kernel/sys_sparc_64.c
9711 +++ b/arch/sparc/kernel/sys_sparc_64.c
9712 @@ -90,13 +90,14 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
9713 struct vm_area_struct * vma;
9714 unsigned long task_size = TASK_SIZE;
9715 int do_color_align;
9716 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9717 struct vm_unmapped_area_info info;
9718
9719 if (flags & MAP_FIXED) {
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 @@ -111,6 +112,10 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
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 if (addr) {
9737 if (do_color_align)
9738 addr = COLOR_ALIGN(addr, pgoff);
9739 @@ -118,22 +123,28 @@ unsigned long arch_get_unmapped_area(struct file *filp, unsigned long addr, unsi
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 info.flags = 0;
9750 info.length = len;
9751 - info.low_limit = TASK_UNMAPPED_BASE;
9752 + info.low_limit = mm->mmap_base;
9753 info.high_limit = min(task_size, VA_EXCLUDE_START);
9754 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9755 info.align_offset = pgoff << PAGE_SHIFT;
9756 + info.threadstack_offset = offset;
9757 addr = vm_unmapped_area(&info);
9758
9759 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
9760 VM_BUG_ON(addr != -ENOMEM);
9761 info.low_limit = VA_EXCLUDE_END;
9762 +
9763 +#ifdef CONFIG_PAX_RANDMMAP
9764 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9765 + info.low_limit += mm->delta_mmap;
9766 +#endif
9767 +
9768 info.high_limit = task_size;
9769 addr = vm_unmapped_area(&info);
9770 }
9771 @@ -151,6 +162,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9772 unsigned long task_size = STACK_TOP32;
9773 unsigned long addr = addr0;
9774 int do_color_align;
9775 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
9776 struct vm_unmapped_area_info info;
9777
9778 /* This should only ever run for 32-bit processes. */
9779 @@ -160,7 +172,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9780 /* We do not accept a shared mapping if it would violate
9781 * cache aliasing constraints.
9782 */
9783 - if ((flags & MAP_SHARED) &&
9784 + if ((filp || (flags & MAP_SHARED)) &&
9785 ((addr - (pgoff << PAGE_SHIFT)) & (SHMLBA - 1)))
9786 return -EINVAL;
9787 return addr;
9788 @@ -173,6 +185,10 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9789 if (filp || (flags & MAP_SHARED))
9790 do_color_align = 1;
9791
9792 +#ifdef CONFIG_PAX_RANDMMAP
9793 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9794 +#endif
9795 +
9796 /* requesting a specific address */
9797 if (addr) {
9798 if (do_color_align)
9799 @@ -181,8 +197,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9800 addr = PAGE_ALIGN(addr);
9801
9802 vma = find_vma(mm, addr);
9803 - if (task_size - len >= addr &&
9804 - (!vma || addr + len <= vma->vm_start))
9805 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
9806 return addr;
9807 }
9808
9809 @@ -192,6 +207,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9810 info.high_limit = mm->mmap_base;
9811 info.align_mask = do_color_align ? (PAGE_MASK & (SHMLBA - 1)) : 0;
9812 info.align_offset = pgoff << PAGE_SHIFT;
9813 + info.threadstack_offset = offset;
9814 addr = vm_unmapped_area(&info);
9815
9816 /*
9817 @@ -204,6 +220,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
9818 VM_BUG_ON(addr != -ENOMEM);
9819 info.flags = 0;
9820 info.low_limit = TASK_UNMAPPED_BASE;
9821 +
9822 +#ifdef CONFIG_PAX_RANDMMAP
9823 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9824 + info.low_limit += mm->delta_mmap;
9825 +#endif
9826 +
9827 info.high_limit = STACK_TOP32;
9828 addr = vm_unmapped_area(&info);
9829 }
9830 @@ -260,10 +282,14 @@ unsigned long get_fb_unmapped_area(struct file *filp, unsigned long orig_addr, u
9831 EXPORT_SYMBOL(get_fb_unmapped_area);
9832
9833 /* Essentially the same as PowerPC. */
9834 -static unsigned long mmap_rnd(void)
9835 +static unsigned long mmap_rnd(struct mm_struct *mm)
9836 {
9837 unsigned long rnd = 0UL;
9838
9839 +#ifdef CONFIG_PAX_RANDMMAP
9840 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
9841 +#endif
9842 +
9843 if (current->flags & PF_RANDOMIZE) {
9844 unsigned long val = get_random_int();
9845 if (test_thread_flag(TIF_32BIT))
9846 @@ -276,7 +302,7 @@ static unsigned long mmap_rnd(void)
9847
9848 void arch_pick_mmap_layout(struct mm_struct *mm)
9849 {
9850 - unsigned long random_factor = mmap_rnd();
9851 + unsigned long random_factor = mmap_rnd(mm);
9852 unsigned long gap;
9853
9854 /*
9855 @@ -289,6 +315,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9856 gap == RLIM_INFINITY ||
9857 sysctl_legacy_va_layout) {
9858 mm->mmap_base = TASK_UNMAPPED_BASE + random_factor;
9859 +
9860 +#ifdef CONFIG_PAX_RANDMMAP
9861 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9862 + mm->mmap_base += mm->delta_mmap;
9863 +#endif
9864 +
9865 mm->get_unmapped_area = arch_get_unmapped_area;
9866 } else {
9867 /* We know it's 32-bit */
9868 @@ -300,6 +332,12 @@ void arch_pick_mmap_layout(struct mm_struct *mm)
9869 gap = (task_size / 6 * 5);
9870
9871 mm->mmap_base = PAGE_ALIGN(task_size - gap - random_factor);
9872 +
9873 +#ifdef CONFIG_PAX_RANDMMAP
9874 + if (mm->pax_flags & MF_PAX_RANDMMAP)
9875 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
9876 +#endif
9877 +
9878 mm->get_unmapped_area = arch_get_unmapped_area_topdown;
9879 }
9880 }
9881 diff --git a/arch/sparc/kernel/syscalls.S b/arch/sparc/kernel/syscalls.S
9882 index d950197..192f9d8 100644
9883 --- a/arch/sparc/kernel/syscalls.S
9884 +++ b/arch/sparc/kernel/syscalls.S
9885 @@ -52,7 +52,7 @@ sys32_rt_sigreturn:
9886 #endif
9887 .align 32
9888 1: ldx [%g6 + TI_FLAGS], %l5
9889 - andcc %l5, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9890 + andcc %l5, _TIF_WORK_SYSCALL, %g0
9891 be,pt %icc, rtrap
9892 nop
9893 call syscall_trace_leave
9894 @@ -184,7 +184,7 @@ linux_sparc_syscall32:
9895
9896 srl %i3, 0, %o3 ! IEU0
9897 srl %i2, 0, %o2 ! IEU0 Group
9898 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9899 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9900 bne,pn %icc, linux_syscall_trace32 ! CTI
9901 mov %i0, %l5 ! IEU1
9902 5: call %l7 ! CTI Group brk forced
9903 @@ -207,7 +207,7 @@ linux_sparc_syscall:
9904
9905 mov %i3, %o3 ! IEU1
9906 mov %i4, %o4 ! IEU0 Group
9907 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9908 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9909 bne,pn %icc, linux_syscall_trace ! CTI Group
9910 mov %i0, %l5 ! IEU0
9911 2: call %l7 ! CTI Group brk forced
9912 @@ -223,7 +223,7 @@ ret_sys_call:
9913
9914 cmp %o0, -ERESTART_RESTARTBLOCK
9915 bgeu,pn %xcc, 1f
9916 - andcc %l0, (_TIF_SYSCALL_TRACE|_TIF_SECCOMP|_TIF_SYSCALL_AUDIT|_TIF_SYSCALL_TRACEPOINT), %g0
9917 + andcc %l0, _TIF_WORK_SYSCALL, %g0
9918 ldx [%sp + PTREGS_OFF + PT_V9_TNPC], %l1 ! pc = npc
9919
9920 2:
9921 diff --git a/arch/sparc/kernel/traps_32.c b/arch/sparc/kernel/traps_32.c
9922 index 6629829..036032d 100644
9923 --- a/arch/sparc/kernel/traps_32.c
9924 +++ b/arch/sparc/kernel/traps_32.c
9925 @@ -44,6 +44,8 @@ static void instruction_dump(unsigned long *pc)
9926 #define __SAVE __asm__ __volatile__("save %sp, -0x40, %sp\n\t")
9927 #define __RESTORE __asm__ __volatile__("restore %g0, %g0, %g0\n\t")
9928
9929 +extern void gr_handle_kernel_exploit(void);
9930 +
9931 void die_if_kernel(char *str, struct pt_regs *regs)
9932 {
9933 static int die_counter;
9934 @@ -76,15 +78,17 @@ void die_if_kernel(char *str, struct pt_regs *regs)
9935 count++ < 30 &&
9936 (((unsigned long) rw) >= PAGE_OFFSET) &&
9937 !(((unsigned long) rw) & 0x7)) {
9938 - printk("Caller[%08lx]: %pS\n", rw->ins[7],
9939 + printk("Caller[%08lx]: %pA\n", rw->ins[7],
9940 (void *) rw->ins[7]);
9941 rw = (struct reg_window32 *)rw->ins[6];
9942 }
9943 }
9944 printk("Instruction DUMP:");
9945 instruction_dump ((unsigned long *) regs->pc);
9946 - if(regs->psr & PSR_PS)
9947 + if(regs->psr & PSR_PS) {
9948 + gr_handle_kernel_exploit();
9949 do_exit(SIGKILL);
9950 + }
9951 do_exit(SIGSEGV);
9952 }
9953
9954 diff --git a/arch/sparc/kernel/traps_64.c b/arch/sparc/kernel/traps_64.c
9955 index b3f833a..f485f80 100644
9956 --- a/arch/sparc/kernel/traps_64.c
9957 +++ b/arch/sparc/kernel/traps_64.c
9958 @@ -76,7 +76,7 @@ static void dump_tl1_traplog(struct tl1_traplog *p)
9959 i + 1,
9960 p->trapstack[i].tstate, p->trapstack[i].tpc,
9961 p->trapstack[i].tnpc, p->trapstack[i].tt);
9962 - printk("TRAPLOG: TPC<%pS>\n", (void *) p->trapstack[i].tpc);
9963 + printk("TRAPLOG: TPC<%pA>\n", (void *) p->trapstack[i].tpc);
9964 }
9965 }
9966
9967 @@ -96,6 +96,12 @@ void bad_trap(struct pt_regs *regs, long lvl)
9968
9969 lvl -= 0x100;
9970 if (regs->tstate & TSTATE_PRIV) {
9971 +
9972 +#ifdef CONFIG_PAX_REFCOUNT
9973 + if (lvl == 6)
9974 + pax_report_refcount_overflow(regs);
9975 +#endif
9976 +
9977 sprintf(buffer, "Kernel bad sw trap %lx", lvl);
9978 die_if_kernel(buffer, regs);
9979 }
9980 @@ -114,11 +120,16 @@ void bad_trap(struct pt_regs *regs, long lvl)
9981 void bad_trap_tl1(struct pt_regs *regs, long lvl)
9982 {
9983 char buffer[32];
9984 -
9985 +
9986 if (notify_die(DIE_TRAP_TL1, "bad trap tl1", regs,
9987 0, lvl, SIGTRAP) == NOTIFY_STOP)
9988 return;
9989
9990 +#ifdef CONFIG_PAX_REFCOUNT
9991 + if (lvl == 6)
9992 + pax_report_refcount_overflow(regs);
9993 +#endif
9994 +
9995 dump_tl1_traplog((struct tl1_traplog *)(regs + 1));
9996
9997 sprintf (buffer, "Bad trap %lx at tl>0", lvl);
9998 @@ -1142,7 +1153,7 @@ static void cheetah_log_errors(struct pt_regs *regs, struct cheetah_err_info *in
9999 regs->tpc, regs->tnpc, regs->u_regs[UREG_I7], regs->tstate);
10000 printk("%s" "ERROR(%d): ",
10001 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id());
10002 - printk("TPC<%pS>\n", (void *) regs->tpc);
10003 + printk("TPC<%pA>\n", (void *) regs->tpc);
10004 printk("%s" "ERROR(%d): M_SYND(%lx), E_SYND(%lx)%s%s\n",
10005 (recoverable ? KERN_WARNING : KERN_CRIT), smp_processor_id(),
10006 (afsr & CHAFSR_M_SYNDROME) >> CHAFSR_M_SYNDROME_SHIFT,
10007 @@ -1749,7 +1760,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10008 smp_processor_id(),
10009 (type & 0x1) ? 'I' : 'D',
10010 regs->tpc);
10011 - printk(KERN_EMERG "TPC<%pS>\n", (void *) regs->tpc);
10012 + printk(KERN_EMERG "TPC<%pA>\n", (void *) regs->tpc);
10013 panic("Irrecoverable Cheetah+ parity error.");
10014 }
10015
10016 @@ -1757,7 +1768,7 @@ void cheetah_plus_parity_error(int type, struct pt_regs *regs)
10017 smp_processor_id(),
10018 (type & 0x1) ? 'I' : 'D',
10019 regs->tpc);
10020 - printk(KERN_WARNING "TPC<%pS>\n", (void *) regs->tpc);
10021 + printk(KERN_WARNING "TPC<%pA>\n", (void *) regs->tpc);
10022 }
10023
10024 struct sun4v_error_entry {
10025 @@ -1830,8 +1841,8 @@ struct sun4v_error_entry {
10026 /*0x38*/u64 reserved_5;
10027 };
10028
10029 -static atomic_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10030 -static atomic_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10031 +static atomic_unchecked_t sun4v_resum_oflow_cnt = ATOMIC_INIT(0);
10032 +static atomic_unchecked_t sun4v_nonresum_oflow_cnt = ATOMIC_INIT(0);
10033
10034 static const char *sun4v_err_type_to_str(u8 type)
10035 {
10036 @@ -1923,7 +1934,7 @@ static void sun4v_report_real_raddr(const char *pfx, struct pt_regs *regs)
10037 }
10038
10039 static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10040 - int cpu, const char *pfx, atomic_t *ocnt)
10041 + int cpu, const char *pfx, atomic_unchecked_t *ocnt)
10042 {
10043 u64 *raw_ptr = (u64 *) ent;
10044 u32 attrs;
10045 @@ -1981,8 +1992,8 @@ static void sun4v_log_error(struct pt_regs *regs, struct sun4v_error_entry *ent,
10046
10047 show_regs(regs);
10048
10049 - if ((cnt = atomic_read(ocnt)) != 0) {
10050 - atomic_set(ocnt, 0);
10051 + if ((cnt = atomic_read_unchecked(ocnt)) != 0) {
10052 + atomic_set_unchecked(ocnt, 0);
10053 wmb();
10054 printk("%s: Queue overflowed %d times.\n",
10055 pfx, cnt);
10056 @@ -2036,7 +2047,7 @@ void sun4v_resum_error(struct pt_regs *regs, unsigned long offset)
10057 */
10058 void sun4v_resum_overflow(struct pt_regs *regs)
10059 {
10060 - atomic_inc(&sun4v_resum_oflow_cnt);
10061 + atomic_inc_unchecked(&sun4v_resum_oflow_cnt);
10062 }
10063
10064 /* We run with %pil set to PIL_NORMAL_MAX and PSTATE_IE enabled in %pstate.
10065 @@ -2089,7 +2100,7 @@ void sun4v_nonresum_overflow(struct pt_regs *regs)
10066 /* XXX Actually even this can make not that much sense. Perhaps
10067 * XXX we should just pull the plug and panic directly from here?
10068 */
10069 - atomic_inc(&sun4v_nonresum_oflow_cnt);
10070 + atomic_inc_unchecked(&sun4v_nonresum_oflow_cnt);
10071 }
10072
10073 unsigned long sun4v_err_itlb_vaddr;
10074 @@ -2104,9 +2115,9 @@ void sun4v_itlb_error_report(struct pt_regs *regs, int tl)
10075
10076 printk(KERN_EMERG "SUN4V-ITLB: Error at TPC[%lx], tl %d\n",
10077 regs->tpc, tl);
10078 - printk(KERN_EMERG "SUN4V-ITLB: TPC<%pS>\n", (void *) regs->tpc);
10079 + printk(KERN_EMERG "SUN4V-ITLB: TPC<%pA>\n", (void *) regs->tpc);
10080 printk(KERN_EMERG "SUN4V-ITLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10081 - printk(KERN_EMERG "SUN4V-ITLB: O7<%pS>\n",
10082 + printk(KERN_EMERG "SUN4V-ITLB: O7<%pA>\n",
10083 (void *) regs->u_regs[UREG_I7]);
10084 printk(KERN_EMERG "SUN4V-ITLB: vaddr[%lx] ctx[%lx] "
10085 "pte[%lx] error[%lx]\n",
10086 @@ -2128,9 +2139,9 @@ void sun4v_dtlb_error_report(struct pt_regs *regs, int tl)
10087
10088 printk(KERN_EMERG "SUN4V-DTLB: Error at TPC[%lx], tl %d\n",
10089 regs->tpc, tl);
10090 - printk(KERN_EMERG "SUN4V-DTLB: TPC<%pS>\n", (void *) regs->tpc);
10091 + printk(KERN_EMERG "SUN4V-DTLB: TPC<%pA>\n", (void *) regs->tpc);
10092 printk(KERN_EMERG "SUN4V-DTLB: O7[%lx]\n", regs->u_regs[UREG_I7]);
10093 - printk(KERN_EMERG "SUN4V-DTLB: O7<%pS>\n",
10094 + printk(KERN_EMERG "SUN4V-DTLB: O7<%pA>\n",
10095 (void *) regs->u_regs[UREG_I7]);
10096 printk(KERN_EMERG "SUN4V-DTLB: vaddr[%lx] ctx[%lx] "
10097 "pte[%lx] error[%lx]\n",
10098 @@ -2336,13 +2347,13 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
10099 fp = (unsigned long)sf->fp + STACK_BIAS;
10100 }
10101
10102 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10103 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10104 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
10105 if ((pc + 8UL) == (unsigned long) &return_to_handler) {
10106 int index = tsk->curr_ret_stack;
10107 if (tsk->ret_stack && index >= graph) {
10108 pc = tsk->ret_stack[index - graph].ret;
10109 - printk(" [%016lx] %pS\n", pc, (void *) pc);
10110 + printk(" [%016lx] %pA\n", pc, (void *) pc);
10111 graph++;
10112 }
10113 }
10114 @@ -2360,6 +2371,8 @@ static inline struct reg_window *kernel_stack_up(struct reg_window *rw)
10115 return (struct reg_window *) (fp + STACK_BIAS);
10116 }
10117
10118 +extern void gr_handle_kernel_exploit(void);
10119 +
10120 void die_if_kernel(char *str, struct pt_regs *regs)
10121 {
10122 static int die_counter;
10123 @@ -2388,7 +2401,7 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10124 while (rw &&
10125 count++ < 30 &&
10126 kstack_valid(tp, (unsigned long) rw)) {
10127 - printk("Caller[%016lx]: %pS\n", rw->ins[7],
10128 + printk("Caller[%016lx]: %pA\n", rw->ins[7],
10129 (void *) rw->ins[7]);
10130
10131 rw = kernel_stack_up(rw);
10132 @@ -2401,8 +2414,10 @@ void die_if_kernel(char *str, struct pt_regs *regs)
10133 }
10134 user_instruction_dump ((unsigned int __user *) regs->tpc);
10135 }
10136 - if (regs->tstate & TSTATE_PRIV)
10137 + if (regs->tstate & TSTATE_PRIV) {
10138 + gr_handle_kernel_exploit();
10139 do_exit(SIGKILL);
10140 + }
10141 do_exit(SIGSEGV);
10142 }
10143 EXPORT_SYMBOL(die_if_kernel);
10144 diff --git a/arch/sparc/kernel/unaligned_64.c b/arch/sparc/kernel/unaligned_64.c
10145 index 8201c25e..072a2a7 100644
10146 --- a/arch/sparc/kernel/unaligned_64.c
10147 +++ b/arch/sparc/kernel/unaligned_64.c
10148 @@ -286,7 +286,7 @@ static void log_unaligned(struct pt_regs *regs)
10149 static DEFINE_RATELIMIT_STATE(ratelimit, 5 * HZ, 5);
10150
10151 if (__ratelimit(&ratelimit)) {
10152 - printk("Kernel unaligned access at TPC[%lx] %pS\n",
10153 + printk("Kernel unaligned access at TPC[%lx] %pA\n",
10154 regs->tpc, (void *) regs->tpc);
10155 }
10156 }
10157 diff --git a/arch/sparc/lib/Makefile b/arch/sparc/lib/Makefile
10158 index dbe119b..089c7c1 100644
10159 --- a/arch/sparc/lib/Makefile
10160 +++ b/arch/sparc/lib/Makefile
10161 @@ -2,7 +2,7 @@
10162 #
10163
10164 asflags-y := -ansi -DST_DIV0=0x02
10165 -ccflags-y := -Werror
10166 +#ccflags-y := -Werror
10167
10168 lib-$(CONFIG_SPARC32) += ashrdi3.o
10169 lib-$(CONFIG_SPARC32) += memcpy.o memset.o
10170 diff --git a/arch/sparc/lib/atomic_64.S b/arch/sparc/lib/atomic_64.S
10171 index 85c233d..68500e0 100644
10172 --- a/arch/sparc/lib/atomic_64.S
10173 +++ b/arch/sparc/lib/atomic_64.S
10174 @@ -17,7 +17,12 @@
10175 ENTRY(atomic_add) /* %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 @@ -27,10 +32,28 @@ ENTRY(atomic_add) /* %o0 = increment, %o1 = atomic_ptr */
10189 2: BACKOFF_SPIN(%o2, %o3, 1b)
10190 ENDPROC(atomic_add)
10191
10192 +ENTRY(atomic_add_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10193 + BACKOFF_SETUP(%o2)
10194 +1: lduw [%o1], %g1
10195 + add %g1, %o0, %g7
10196 + cas [%o1], %g1, %g7
10197 + cmp %g1, %g7
10198 + bne,pn %icc, 2f
10199 + nop
10200 + retl
10201 + nop
10202 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10203 +ENDPROC(atomic_add_unchecked)
10204 +
10205 ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10206 BACKOFF_SETUP(%o2)
10207 1: lduw [%o1], %g1
10208 - sub %g1, %o0, %g7
10209 + subcc %g1, %o0, %g7
10210 +
10211 +#ifdef CONFIG_PAX_REFCOUNT
10212 + tvs %icc, 6
10213 +#endif
10214 +
10215 cas [%o1], %g1, %g7
10216 cmp %g1, %g7
10217 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10218 @@ -40,10 +63,28 @@ ENTRY(atomic_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10219 2: BACKOFF_SPIN(%o2, %o3, 1b)
10220 ENDPROC(atomic_sub)
10221
10222 +ENTRY(atomic_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10223 + BACKOFF_SETUP(%o2)
10224 +1: lduw [%o1], %g1
10225 + sub %g1, %o0, %g7
10226 + cas [%o1], %g1, %g7
10227 + cmp %g1, %g7
10228 + bne,pn %icc, 2f
10229 + nop
10230 + retl
10231 + nop
10232 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10233 +ENDPROC(atomic_sub_unchecked)
10234 +
10235 ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10236 BACKOFF_SETUP(%o2)
10237 1: lduw [%o1], %g1
10238 - add %g1, %o0, %g7
10239 + addcc %g1, %o0, %g7
10240 +
10241 +#ifdef CONFIG_PAX_REFCOUNT
10242 + tvs %icc, 6
10243 +#endif
10244 +
10245 cas [%o1], %g1, %g7
10246 cmp %g1, %g7
10247 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10248 @@ -53,10 +94,29 @@ ENTRY(atomic_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10249 2: BACKOFF_SPIN(%o2, %o3, 1b)
10250 ENDPROC(atomic_add_ret)
10251
10252 +ENTRY(atomic_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10253 + BACKOFF_SETUP(%o2)
10254 +1: lduw [%o1], %g1
10255 + addcc %g1, %o0, %g7
10256 + cas [%o1], %g1, %g7
10257 + cmp %g1, %g7
10258 + bne,pn %icc, 2f
10259 + add %g7, %o0, %g7
10260 + sra %g7, 0, %o0
10261 + retl
10262 + nop
10263 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10264 +ENDPROC(atomic_add_ret_unchecked)
10265 +
10266 ENTRY(atomic_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10267 BACKOFF_SETUP(%o2)
10268 1: lduw [%o1], %g1
10269 - sub %g1, %o0, %g7
10270 + subcc %g1, %o0, %g7
10271 +
10272 +#ifdef CONFIG_PAX_REFCOUNT
10273 + tvs %icc, 6
10274 +#endif
10275 +
10276 cas [%o1], %g1, %g7
10277 cmp %g1, %g7
10278 bne,pn %icc, BACKOFF_LABEL(2f, 1b)
10279 @@ -69,7 +129,12 @@ ENDPROC(atomic_sub_ret)
10280 ENTRY(atomic64_add) /* %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 @@ -79,10 +144,28 @@ ENTRY(atomic64_add) /* %o0 = increment, %o1 = atomic_ptr */
10294 2: BACKOFF_SPIN(%o2, %o3, 1b)
10295 ENDPROC(atomic64_add)
10296
10297 +ENTRY(atomic64_add_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 + nop
10305 + retl
10306 + nop
10307 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10308 +ENDPROC(atomic64_add_unchecked)
10309 +
10310 ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10311 BACKOFF_SETUP(%o2)
10312 1: ldx [%o1], %g1
10313 - sub %g1, %o0, %g7
10314 + subcc %g1, %o0, %g7
10315 +
10316 +#ifdef CONFIG_PAX_REFCOUNT
10317 + tvs %xcc, 6
10318 +#endif
10319 +
10320 casx [%o1], %g1, %g7
10321 cmp %g1, %g7
10322 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10323 @@ -92,10 +175,28 @@ ENTRY(atomic64_sub) /* %o0 = decrement, %o1 = atomic_ptr */
10324 2: BACKOFF_SPIN(%o2, %o3, 1b)
10325 ENDPROC(atomic64_sub)
10326
10327 +ENTRY(atomic64_sub_unchecked) /* %o0 = decrement, %o1 = atomic_ptr */
10328 + BACKOFF_SETUP(%o2)
10329 +1: ldx [%o1], %g1
10330 + subcc %g1, %o0, %g7
10331 + casx [%o1], %g1, %g7
10332 + cmp %g1, %g7
10333 + bne,pn %xcc, 2f
10334 + nop
10335 + retl
10336 + nop
10337 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10338 +ENDPROC(atomic64_sub_unchecked)
10339 +
10340 ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10341 BACKOFF_SETUP(%o2)
10342 1: ldx [%o1], %g1
10343 - add %g1, %o0, %g7
10344 + addcc %g1, %o0, %g7
10345 +
10346 +#ifdef CONFIG_PAX_REFCOUNT
10347 + tvs %xcc, 6
10348 +#endif
10349 +
10350 casx [%o1], %g1, %g7
10351 cmp %g1, %g7
10352 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10353 @@ -105,10 +206,29 @@ ENTRY(atomic64_add_ret) /* %o0 = increment, %o1 = atomic_ptr */
10354 2: BACKOFF_SPIN(%o2, %o3, 1b)
10355 ENDPROC(atomic64_add_ret)
10356
10357 +ENTRY(atomic64_add_ret_unchecked) /* %o0 = increment, %o1 = atomic_ptr */
10358 + BACKOFF_SETUP(%o2)
10359 +1: ldx [%o1], %g1
10360 + addcc %g1, %o0, %g7
10361 + casx [%o1], %g1, %g7
10362 + cmp %g1, %g7
10363 + bne,pn %xcc, 2f
10364 + add %g7, %o0, %g7
10365 + mov %g7, %o0
10366 + retl
10367 + nop
10368 +2: BACKOFF_SPIN(%o2, %o3, 1b)
10369 +ENDPROC(atomic64_add_ret_unchecked)
10370 +
10371 ENTRY(atomic64_sub_ret) /* %o0 = decrement, %o1 = atomic_ptr */
10372 BACKOFF_SETUP(%o2)
10373 1: ldx [%o1], %g1
10374 - sub %g1, %o0, %g7
10375 + subcc %g1, %o0, %g7
10376 +
10377 +#ifdef CONFIG_PAX_REFCOUNT
10378 + tvs %xcc, 6
10379 +#endif
10380 +
10381 casx [%o1], %g1, %g7
10382 cmp %g1, %g7
10383 bne,pn %xcc, BACKOFF_LABEL(2f, 1b)
10384 diff --git a/arch/sparc/lib/ksyms.c b/arch/sparc/lib/ksyms.c
10385 index 323335b..ed85ea2 100644
10386 --- a/arch/sparc/lib/ksyms.c
10387 +++ b/arch/sparc/lib/ksyms.c
10388 @@ -100,12 +100,18 @@ EXPORT_SYMBOL(__clear_user);
10389
10390 /* Atomic counter implementation. */
10391 EXPORT_SYMBOL(atomic_add);
10392 +EXPORT_SYMBOL(atomic_add_unchecked);
10393 EXPORT_SYMBOL(atomic_add_ret);
10394 +EXPORT_SYMBOL(atomic_add_ret_unchecked);
10395 EXPORT_SYMBOL(atomic_sub);
10396 +EXPORT_SYMBOL(atomic_sub_unchecked);
10397 EXPORT_SYMBOL(atomic_sub_ret);
10398 EXPORT_SYMBOL(atomic64_add);
10399 +EXPORT_SYMBOL(atomic64_add_unchecked);
10400 EXPORT_SYMBOL(atomic64_add_ret);
10401 +EXPORT_SYMBOL(atomic64_add_ret_unchecked);
10402 EXPORT_SYMBOL(atomic64_sub);
10403 +EXPORT_SYMBOL(atomic64_sub_unchecked);
10404 EXPORT_SYMBOL(atomic64_sub_ret);
10405 EXPORT_SYMBOL(atomic64_dec_if_positive);
10406
10407 diff --git a/arch/sparc/mm/Makefile b/arch/sparc/mm/Makefile
10408 index 30c3ecc..736f015 100644
10409 --- a/arch/sparc/mm/Makefile
10410 +++ b/arch/sparc/mm/Makefile
10411 @@ -2,7 +2,7 @@
10412 #
10413
10414 asflags-y := -ansi
10415 -ccflags-y := -Werror
10416 +#ccflags-y := -Werror
10417
10418 obj-$(CONFIG_SPARC64) += ultra.o tlb.o tsb.o gup.o
10419 obj-y += fault_$(BITS).o
10420 diff --git a/arch/sparc/mm/fault_32.c b/arch/sparc/mm/fault_32.c
10421 index 59dbd46..1dd7f5e 100644
10422 --- a/arch/sparc/mm/fault_32.c
10423 +++ b/arch/sparc/mm/fault_32.c
10424 @@ -21,6 +21,9 @@
10425 #include <linux/perf_event.h>
10426 #include <linux/interrupt.h>
10427 #include <linux/kdebug.h>
10428 +#include <linux/slab.h>
10429 +#include <linux/pagemap.h>
10430 +#include <linux/compiler.h>
10431
10432 #include <asm/page.h>
10433 #include <asm/pgtable.h>
10434 @@ -159,6 +162,277 @@ static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
10435 return safe_compute_effective_address(regs, insn);
10436 }
10437
10438 +#ifdef CONFIG_PAX_PAGEEXEC
10439 +#ifdef CONFIG_PAX_DLRESOLVE
10440 +static void pax_emuplt_close(struct vm_area_struct *vma)
10441 +{
10442 + vma->vm_mm->call_dl_resolve = 0UL;
10443 +}
10444 +
10445 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10446 +{
10447 + unsigned int *kaddr;
10448 +
10449 + vmf->page = alloc_page(GFP_HIGHUSER);
10450 + if (!vmf->page)
10451 + return VM_FAULT_OOM;
10452 +
10453 + kaddr = kmap(vmf->page);
10454 + memset(kaddr, 0, PAGE_SIZE);
10455 + kaddr[0] = 0x9DE3BFA8U; /* save */
10456 + flush_dcache_page(vmf->page);
10457 + kunmap(vmf->page);
10458 + return VM_FAULT_MAJOR;
10459 +}
10460 +
10461 +static const struct vm_operations_struct pax_vm_ops = {
10462 + .close = pax_emuplt_close,
10463 + .fault = pax_emuplt_fault
10464 +};
10465 +
10466 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10467 +{
10468 + int ret;
10469 +
10470 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10471 + vma->vm_mm = current->mm;
10472 + vma->vm_start = addr;
10473 + vma->vm_end = addr + PAGE_SIZE;
10474 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10475 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10476 + vma->vm_ops = &pax_vm_ops;
10477 +
10478 + ret = insert_vm_struct(current->mm, vma);
10479 + if (ret)
10480 + return ret;
10481 +
10482 + ++current->mm->total_vm;
10483 + return 0;
10484 +}
10485 +#endif
10486 +
10487 +/*
10488 + * PaX: decide what to do with offenders (regs->pc = fault address)
10489 + *
10490 + * returns 1 when task should be killed
10491 + * 2 when patched PLT trampoline was detected
10492 + * 3 when unpatched PLT trampoline was detected
10493 + */
10494 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10495 +{
10496 +
10497 +#ifdef CONFIG_PAX_EMUPLT
10498 + int err;
10499 +
10500 + do { /* PaX: patched PLT emulation #1 */
10501 + unsigned int sethi1, sethi2, jmpl;
10502 +
10503 + err = get_user(sethi1, (unsigned int *)regs->pc);
10504 + err |= get_user(sethi2, (unsigned int *)(regs->pc+4));
10505 + err |= get_user(jmpl, (unsigned int *)(regs->pc+8));
10506 +
10507 + if (err)
10508 + break;
10509 +
10510 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10511 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10512 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10513 + {
10514 + unsigned int addr;
10515 +
10516 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10517 + addr = regs->u_regs[UREG_G1];
10518 + addr += (((jmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10519 + regs->pc = addr;
10520 + regs->npc = addr+4;
10521 + return 2;
10522 + }
10523 + } while (0);
10524 +
10525 + do { /* PaX: patched PLT emulation #2 */
10526 + unsigned int ba;
10527 +
10528 + err = get_user(ba, (unsigned int *)regs->pc);
10529 +
10530 + if (err)
10531 + break;
10532 +
10533 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10534 + unsigned int addr;
10535 +
10536 + if ((ba & 0xFFC00000U) == 0x30800000U)
10537 + addr = regs->pc + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10538 + else
10539 + addr = regs->pc + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10540 + regs->pc = addr;
10541 + regs->npc = addr+4;
10542 + return 2;
10543 + }
10544 + } while (0);
10545 +
10546 + do { /* PaX: patched PLT emulation #3 */
10547 + unsigned int sethi, bajmpl, nop;
10548 +
10549 + err = get_user(sethi, (unsigned int *)regs->pc);
10550 + err |= get_user(bajmpl, (unsigned int *)(regs->pc+4));
10551 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10552 +
10553 + if (err)
10554 + break;
10555 +
10556 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10557 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10558 + nop == 0x01000000U)
10559 + {
10560 + unsigned int addr;
10561 +
10562 + addr = (sethi & 0x003FFFFFU) << 10;
10563 + regs->u_regs[UREG_G1] = addr;
10564 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10565 + addr += (((bajmpl | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10566 + else
10567 + addr = regs->pc + ((((bajmpl | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10568 + regs->pc = addr;
10569 + regs->npc = addr+4;
10570 + return 2;
10571 + }
10572 + } while (0);
10573 +
10574 + do { /* PaX: unpatched PLT emulation step 1 */
10575 + unsigned int sethi, ba, nop;
10576 +
10577 + err = get_user(sethi, (unsigned int *)regs->pc);
10578 + err |= get_user(ba, (unsigned int *)(regs->pc+4));
10579 + err |= get_user(nop, (unsigned int *)(regs->pc+8));
10580 +
10581 + if (err)
10582 + break;
10583 +
10584 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10585 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
10586 + nop == 0x01000000U)
10587 + {
10588 + unsigned int addr, save, call;
10589 +
10590 + if ((ba & 0xFFC00000U) == 0x30800000U)
10591 + addr = regs->pc + 4 + ((((ba | 0xFFC00000U) ^ 0x00200000U) + 0x00200000U) << 2);
10592 + else
10593 + addr = regs->pc + 4 + ((((ba | 0xFFF80000U) ^ 0x00040000U) + 0x00040000U) << 2);
10594 +
10595 + err = get_user(save, (unsigned int *)addr);
10596 + err |= get_user(call, (unsigned int *)(addr+4));
10597 + err |= get_user(nop, (unsigned int *)(addr+8));
10598 + if (err)
10599 + break;
10600 +
10601 +#ifdef CONFIG_PAX_DLRESOLVE
10602 + if (save == 0x9DE3BFA8U &&
10603 + (call & 0xC0000000U) == 0x40000000U &&
10604 + nop == 0x01000000U)
10605 + {
10606 + struct vm_area_struct *vma;
10607 + unsigned long call_dl_resolve;
10608 +
10609 + down_read(&current->mm->mmap_sem);
10610 + call_dl_resolve = current->mm->call_dl_resolve;
10611 + up_read(&current->mm->mmap_sem);
10612 + if (likely(call_dl_resolve))
10613 + goto emulate;
10614 +
10615 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
10616 +
10617 + down_write(&current->mm->mmap_sem);
10618 + if (current->mm->call_dl_resolve) {
10619 + call_dl_resolve = current->mm->call_dl_resolve;
10620 + up_write(&current->mm->mmap_sem);
10621 + if (vma)
10622 + kmem_cache_free(vm_area_cachep, vma);
10623 + goto emulate;
10624 + }
10625 +
10626 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
10627 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
10628 + up_write(&current->mm->mmap_sem);
10629 + if (vma)
10630 + kmem_cache_free(vm_area_cachep, vma);
10631 + return 1;
10632 + }
10633 +
10634 + if (pax_insert_vma(vma, call_dl_resolve)) {
10635 + up_write(&current->mm->mmap_sem);
10636 + kmem_cache_free(vm_area_cachep, vma);
10637 + return 1;
10638 + }
10639 +
10640 + current->mm->call_dl_resolve = call_dl_resolve;
10641 + up_write(&current->mm->mmap_sem);
10642 +
10643 +emulate:
10644 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10645 + regs->pc = call_dl_resolve;
10646 + regs->npc = addr+4;
10647 + return 3;
10648 + }
10649 +#endif
10650 +
10651 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
10652 + if ((save & 0xFFC00000U) == 0x05000000U &&
10653 + (call & 0xFFFFE000U) == 0x85C0A000U &&
10654 + nop == 0x01000000U)
10655 + {
10656 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
10657 + regs->u_regs[UREG_G2] = addr + 4;
10658 + addr = (save & 0x003FFFFFU) << 10;
10659 + addr += (((call | 0xFFFFE000U) ^ 0x00001000U) + 0x00001000U);
10660 + regs->pc = addr;
10661 + regs->npc = addr+4;
10662 + return 3;
10663 + }
10664 + }
10665 + } while (0);
10666 +
10667 + do { /* PaX: unpatched PLT emulation step 2 */
10668 + unsigned int save, call, nop;
10669 +
10670 + err = get_user(save, (unsigned int *)(regs->pc-4));
10671 + err |= get_user(call, (unsigned int *)regs->pc);
10672 + err |= get_user(nop, (unsigned int *)(regs->pc+4));
10673 + if (err)
10674 + break;
10675 +
10676 + if (save == 0x9DE3BFA8U &&
10677 + (call & 0xC0000000U) == 0x40000000U &&
10678 + nop == 0x01000000U)
10679 + {
10680 + unsigned int dl_resolve = regs->pc + ((((call | 0xC0000000U) ^ 0x20000000U) + 0x20000000U) << 2);
10681 +
10682 + regs->u_regs[UREG_RETPC] = regs->pc;
10683 + regs->pc = dl_resolve;
10684 + regs->npc = dl_resolve+4;
10685 + return 3;
10686 + }
10687 + } while (0);
10688 +#endif
10689 +
10690 + return 1;
10691 +}
10692 +
10693 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
10694 +{
10695 + unsigned long i;
10696 +
10697 + printk(KERN_ERR "PAX: bytes at PC: ");
10698 + for (i = 0; i < 8; i++) {
10699 + unsigned int c;
10700 + if (get_user(c, (unsigned int *)pc+i))
10701 + printk(KERN_CONT "???????? ");
10702 + else
10703 + printk(KERN_CONT "%08x ", c);
10704 + }
10705 + printk("\n");
10706 +}
10707 +#endif
10708 +
10709 static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
10710 int text_fault)
10711 {
10712 @@ -229,6 +503,24 @@ good_area:
10713 if (!(vma->vm_flags & VM_WRITE))
10714 goto bad_area;
10715 } else {
10716 +
10717 +#ifdef CONFIG_PAX_PAGEEXEC
10718 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && text_fault && !(vma->vm_flags & VM_EXEC)) {
10719 + up_read(&mm->mmap_sem);
10720 + switch (pax_handle_fetch_fault(regs)) {
10721 +
10722 +#ifdef CONFIG_PAX_EMUPLT
10723 + case 2:
10724 + case 3:
10725 + return;
10726 +#endif
10727 +
10728 + }
10729 + pax_report_fault(regs, (void *)regs->pc, (void *)regs->u_regs[UREG_FP]);
10730 + do_group_exit(SIGKILL);
10731 + }
10732 +#endif
10733 +
10734 /* Allow reads even for write-only mappings */
10735 if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
10736 goto bad_area;
10737 diff --git a/arch/sparc/mm/fault_64.c b/arch/sparc/mm/fault_64.c
10738 index 2ebec26..b212598 100644
10739 --- a/arch/sparc/mm/fault_64.c
10740 +++ b/arch/sparc/mm/fault_64.c
10741 @@ -21,6 +21,9 @@
10742 #include <linux/kprobes.h>
10743 #include <linux/kdebug.h>
10744 #include <linux/percpu.h>
10745 +#include <linux/slab.h>
10746 +#include <linux/pagemap.h>
10747 +#include <linux/compiler.h>
10748
10749 #include <asm/page.h>
10750 #include <asm/pgtable.h>
10751 @@ -74,7 +77,7 @@ static void __kprobes bad_kernel_pc(struct pt_regs *regs, unsigned long vaddr)
10752 printk(KERN_CRIT "OOPS: Bogus kernel PC [%016lx] in fault handler\n",
10753 regs->tpc);
10754 printk(KERN_CRIT "OOPS: RPC [%016lx]\n", regs->u_regs[15]);
10755 - printk("OOPS: RPC <%pS>\n", (void *) regs->u_regs[15]);
10756 + printk("OOPS: RPC <%pA>\n", (void *) regs->u_regs[15]);
10757 printk(KERN_CRIT "OOPS: Fault was to vaddr[%lx]\n", vaddr);
10758 dump_stack();
10759 unhandled_fault(regs->tpc, current, regs);
10760 @@ -270,6 +273,466 @@ static void noinline __kprobes bogus_32bit_fault_address(struct pt_regs *regs,
10761 show_regs(regs);
10762 }
10763
10764 +#ifdef CONFIG_PAX_PAGEEXEC
10765 +#ifdef CONFIG_PAX_DLRESOLVE
10766 +static void pax_emuplt_close(struct vm_area_struct *vma)
10767 +{
10768 + vma->vm_mm->call_dl_resolve = 0UL;
10769 +}
10770 +
10771 +static int pax_emuplt_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
10772 +{
10773 + unsigned int *kaddr;
10774 +
10775 + vmf->page = alloc_page(GFP_HIGHUSER);
10776 + if (!vmf->page)
10777 + return VM_FAULT_OOM;
10778 +
10779 + kaddr = kmap(vmf->page);
10780 + memset(kaddr, 0, PAGE_SIZE);
10781 + kaddr[0] = 0x9DE3BFA8U; /* save */
10782 + flush_dcache_page(vmf->page);
10783 + kunmap(vmf->page);
10784 + return VM_FAULT_MAJOR;
10785 +}
10786 +
10787 +static const struct vm_operations_struct pax_vm_ops = {
10788 + .close = pax_emuplt_close,
10789 + .fault = pax_emuplt_fault
10790 +};
10791 +
10792 +static int pax_insert_vma(struct vm_area_struct *vma, unsigned long addr)
10793 +{
10794 + int ret;
10795 +
10796 + INIT_LIST_HEAD(&vma->anon_vma_chain);
10797 + vma->vm_mm = current->mm;
10798 + vma->vm_start = addr;
10799 + vma->vm_end = addr + PAGE_SIZE;
10800 + vma->vm_flags = VM_READ | VM_EXEC | VM_MAYREAD | VM_MAYEXEC;
10801 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
10802 + vma->vm_ops = &pax_vm_ops;
10803 +
10804 + ret = insert_vm_struct(current->mm, vma);
10805 + if (ret)
10806 + return ret;
10807 +
10808 + ++current->mm->total_vm;
10809 + return 0;
10810 +}
10811 +#endif
10812 +
10813 +/*
10814 + * PaX: decide what to do with offenders (regs->tpc = fault address)
10815 + *
10816 + * returns 1 when task should be killed
10817 + * 2 when patched PLT trampoline was detected
10818 + * 3 when unpatched PLT trampoline was detected
10819 + */
10820 +static int pax_handle_fetch_fault(struct pt_regs *regs)
10821 +{
10822 +
10823 +#ifdef CONFIG_PAX_EMUPLT
10824 + int err;
10825 +
10826 + do { /* PaX: patched PLT emulation #1 */
10827 + unsigned int sethi1, sethi2, jmpl;
10828 +
10829 + err = get_user(sethi1, (unsigned int *)regs->tpc);
10830 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+4));
10831 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+8));
10832 +
10833 + if (err)
10834 + break;
10835 +
10836 + if ((sethi1 & 0xFFC00000U) == 0x03000000U &&
10837 + (sethi2 & 0xFFC00000U) == 0x03000000U &&
10838 + (jmpl & 0xFFFFE000U) == 0x81C06000U)
10839 + {
10840 + unsigned long addr;
10841 +
10842 + regs->u_regs[UREG_G1] = (sethi2 & 0x003FFFFFU) << 10;
10843 + addr = regs->u_regs[UREG_G1];
10844 + addr += (((jmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10845 +
10846 + if (test_thread_flag(TIF_32BIT))
10847 + addr &= 0xFFFFFFFFUL;
10848 +
10849 + regs->tpc = addr;
10850 + regs->tnpc = addr+4;
10851 + return 2;
10852 + }
10853 + } while (0);
10854 +
10855 + do { /* PaX: patched PLT emulation #2 */
10856 + unsigned int ba;
10857 +
10858 + err = get_user(ba, (unsigned int *)regs->tpc);
10859 +
10860 + if (err)
10861 + break;
10862 +
10863 + if ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30480000U) {
10864 + unsigned long addr;
10865 +
10866 + if ((ba & 0xFFC00000U) == 0x30800000U)
10867 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
10868 + else
10869 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10870 +
10871 + if (test_thread_flag(TIF_32BIT))
10872 + addr &= 0xFFFFFFFFUL;
10873 +
10874 + regs->tpc = addr;
10875 + regs->tnpc = addr+4;
10876 + return 2;
10877 + }
10878 + } while (0);
10879 +
10880 + do { /* PaX: patched PLT emulation #3 */
10881 + unsigned int sethi, bajmpl, nop;
10882 +
10883 + err = get_user(sethi, (unsigned int *)regs->tpc);
10884 + err |= get_user(bajmpl, (unsigned int *)(regs->tpc+4));
10885 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
10886 +
10887 + if (err)
10888 + break;
10889 +
10890 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10891 + ((bajmpl & 0xFFFFE000U) == 0x81C06000U || (bajmpl & 0xFFF80000U) == 0x30480000U) &&
10892 + nop == 0x01000000U)
10893 + {
10894 + unsigned long addr;
10895 +
10896 + addr = (sethi & 0x003FFFFFU) << 10;
10897 + regs->u_regs[UREG_G1] = addr;
10898 + if ((bajmpl & 0xFFFFE000U) == 0x81C06000U)
10899 + addr += (((bajmpl | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
10900 + else
10901 + addr = regs->tpc + ((((bajmpl | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
10902 +
10903 + if (test_thread_flag(TIF_32BIT))
10904 + addr &= 0xFFFFFFFFUL;
10905 +
10906 + regs->tpc = addr;
10907 + regs->tnpc = addr+4;
10908 + return 2;
10909 + }
10910 + } while (0);
10911 +
10912 + do { /* PaX: patched PLT emulation #4 */
10913 + unsigned int sethi, mov1, call, mov2;
10914 +
10915 + err = get_user(sethi, (unsigned int *)regs->tpc);
10916 + err |= get_user(mov1, (unsigned int *)(regs->tpc+4));
10917 + err |= get_user(call, (unsigned int *)(regs->tpc+8));
10918 + err |= get_user(mov2, (unsigned int *)(regs->tpc+12));
10919 +
10920 + if (err)
10921 + break;
10922 +
10923 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10924 + mov1 == 0x8210000FU &&
10925 + (call & 0xC0000000U) == 0x40000000U &&
10926 + mov2 == 0x9E100001U)
10927 + {
10928 + unsigned long addr;
10929 +
10930 + regs->u_regs[UREG_G1] = regs->u_regs[UREG_RETPC];
10931 + addr = regs->tpc + 4 + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
10932 +
10933 + if (test_thread_flag(TIF_32BIT))
10934 + addr &= 0xFFFFFFFFUL;
10935 +
10936 + regs->tpc = addr;
10937 + regs->tnpc = addr+4;
10938 + return 2;
10939 + }
10940 + } while (0);
10941 +
10942 + do { /* PaX: patched PLT emulation #5 */
10943 + unsigned int sethi, sethi1, sethi2, or1, or2, sllx, jmpl, nop;
10944 +
10945 + err = get_user(sethi, (unsigned int *)regs->tpc);
10946 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10947 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10948 + err |= get_user(or1, (unsigned int *)(regs->tpc+12));
10949 + err |= get_user(or2, (unsigned int *)(regs->tpc+16));
10950 + err |= get_user(sllx, (unsigned int *)(regs->tpc+20));
10951 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+24));
10952 + err |= get_user(nop, (unsigned int *)(regs->tpc+28));
10953 +
10954 + if (err)
10955 + break;
10956 +
10957 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10958 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10959 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10960 + (or1 & 0xFFFFE000U) == 0x82106000U &&
10961 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
10962 + sllx == 0x83287020U &&
10963 + jmpl == 0x81C04005U &&
10964 + nop == 0x01000000U)
10965 + {
10966 + unsigned long addr;
10967 +
10968 + regs->u_regs[UREG_G1] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
10969 + regs->u_regs[UREG_G1] <<= 32;
10970 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
10971 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
10972 + regs->tpc = addr;
10973 + regs->tnpc = addr+4;
10974 + return 2;
10975 + }
10976 + } while (0);
10977 +
10978 + do { /* PaX: patched PLT emulation #6 */
10979 + unsigned int sethi, sethi1, sethi2, sllx, or, jmpl, nop;
10980 +
10981 + err = get_user(sethi, (unsigned int *)regs->tpc);
10982 + err |= get_user(sethi1, (unsigned int *)(regs->tpc+4));
10983 + err |= get_user(sethi2, (unsigned int *)(regs->tpc+8));
10984 + err |= get_user(sllx, (unsigned int *)(regs->tpc+12));
10985 + err |= get_user(or, (unsigned int *)(regs->tpc+16));
10986 + err |= get_user(jmpl, (unsigned int *)(regs->tpc+20));
10987 + err |= get_user(nop, (unsigned int *)(regs->tpc+24));
10988 +
10989 + if (err)
10990 + break;
10991 +
10992 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
10993 + (sethi1 & 0xFFC00000U) == 0x03000000U &&
10994 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
10995 + sllx == 0x83287020U &&
10996 + (or & 0xFFFFE000U) == 0x8A116000U &&
10997 + jmpl == 0x81C04005U &&
10998 + nop == 0x01000000U)
10999 + {
11000 + unsigned long addr;
11001 +
11002 + regs->u_regs[UREG_G1] = (sethi1 & 0x003FFFFFU) << 10;
11003 + regs->u_regs[UREG_G1] <<= 32;
11004 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or & 0x3FFU);
11005 + addr = regs->u_regs[UREG_G1] + regs->u_regs[UREG_G5];
11006 + regs->tpc = addr;
11007 + regs->tnpc = addr+4;
11008 + return 2;
11009 + }
11010 + } while (0);
11011 +
11012 + do { /* PaX: unpatched PLT emulation step 1 */
11013 + unsigned int sethi, ba, nop;
11014 +
11015 + err = get_user(sethi, (unsigned int *)regs->tpc);
11016 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11017 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11018 +
11019 + if (err)
11020 + break;
11021 +
11022 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11023 + ((ba & 0xFFC00000U) == 0x30800000U || (ba & 0xFFF80000U) == 0x30680000U) &&
11024 + nop == 0x01000000U)
11025 + {
11026 + unsigned long addr;
11027 + unsigned int save, call;
11028 + unsigned int sethi1, sethi2, or1, or2, sllx, add, jmpl;
11029 +
11030 + if ((ba & 0xFFC00000U) == 0x30800000U)
11031 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFC00000UL) ^ 0x00200000UL) + 0x00200000UL) << 2);
11032 + else
11033 + addr = regs->tpc + 4 + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11034 +
11035 + if (test_thread_flag(TIF_32BIT))
11036 + addr &= 0xFFFFFFFFUL;
11037 +
11038 + err = get_user(save, (unsigned int *)addr);
11039 + err |= get_user(call, (unsigned int *)(addr+4));
11040 + err |= get_user(nop, (unsigned int *)(addr+8));
11041 + if (err)
11042 + break;
11043 +
11044 +#ifdef CONFIG_PAX_DLRESOLVE
11045 + if (save == 0x9DE3BFA8U &&
11046 + (call & 0xC0000000U) == 0x40000000U &&
11047 + nop == 0x01000000U)
11048 + {
11049 + struct vm_area_struct *vma;
11050 + unsigned long call_dl_resolve;
11051 +
11052 + down_read(&current->mm->mmap_sem);
11053 + call_dl_resolve = current->mm->call_dl_resolve;
11054 + up_read(&current->mm->mmap_sem);
11055 + if (likely(call_dl_resolve))
11056 + goto emulate;
11057 +
11058 + vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
11059 +
11060 + down_write(&current->mm->mmap_sem);
11061 + if (current->mm->call_dl_resolve) {
11062 + call_dl_resolve = current->mm->call_dl_resolve;
11063 + up_write(&current->mm->mmap_sem);
11064 + if (vma)
11065 + kmem_cache_free(vm_area_cachep, vma);
11066 + goto emulate;
11067 + }
11068 +
11069 + call_dl_resolve = get_unmapped_area(NULL, 0UL, PAGE_SIZE, 0UL, MAP_PRIVATE);
11070 + if (!vma || (call_dl_resolve & ~PAGE_MASK)) {
11071 + up_write(&current->mm->mmap_sem);
11072 + if (vma)
11073 + kmem_cache_free(vm_area_cachep, vma);
11074 + return 1;
11075 + }
11076 +
11077 + if (pax_insert_vma(vma, call_dl_resolve)) {
11078 + up_write(&current->mm->mmap_sem);
11079 + kmem_cache_free(vm_area_cachep, vma);
11080 + return 1;
11081 + }
11082 +
11083 + current->mm->call_dl_resolve = call_dl_resolve;
11084 + up_write(&current->mm->mmap_sem);
11085 +
11086 +emulate:
11087 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11088 + regs->tpc = call_dl_resolve;
11089 + regs->tnpc = addr+4;
11090 + return 3;
11091 + }
11092 +#endif
11093 +
11094 + /* PaX: glibc 2.4+ generates sethi/jmpl instead of save/call */
11095 + if ((save & 0xFFC00000U) == 0x05000000U &&
11096 + (call & 0xFFFFE000U) == 0x85C0A000U &&
11097 + nop == 0x01000000U)
11098 + {
11099 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11100 + regs->u_regs[UREG_G2] = addr + 4;
11101 + addr = (save & 0x003FFFFFU) << 10;
11102 + addr += (((call | 0xFFFFFFFFFFFFE000UL) ^ 0x00001000UL) + 0x00001000UL);
11103 +
11104 + if (test_thread_flag(TIF_32BIT))
11105 + addr &= 0xFFFFFFFFUL;
11106 +
11107 + regs->tpc = addr;
11108 + regs->tnpc = addr+4;
11109 + return 3;
11110 + }
11111 +
11112 + /* PaX: 64-bit PLT stub */
11113 + err = get_user(sethi1, (unsigned int *)addr);
11114 + err |= get_user(sethi2, (unsigned int *)(addr+4));
11115 + err |= get_user(or1, (unsigned int *)(addr+8));
11116 + err |= get_user(or2, (unsigned int *)(addr+12));
11117 + err |= get_user(sllx, (unsigned int *)(addr+16));
11118 + err |= get_user(add, (unsigned int *)(addr+20));
11119 + err |= get_user(jmpl, (unsigned int *)(addr+24));
11120 + err |= get_user(nop, (unsigned int *)(addr+28));
11121 + if (err)
11122 + break;
11123 +
11124 + if ((sethi1 & 0xFFC00000U) == 0x09000000U &&
11125 + (sethi2 & 0xFFC00000U) == 0x0B000000U &&
11126 + (or1 & 0xFFFFE000U) == 0x88112000U &&
11127 + (or2 & 0xFFFFE000U) == 0x8A116000U &&
11128 + sllx == 0x89293020U &&
11129 + add == 0x8A010005U &&
11130 + jmpl == 0x89C14000U &&
11131 + nop == 0x01000000U)
11132 + {
11133 + regs->u_regs[UREG_G1] = (sethi & 0x003FFFFFU) << 10;
11134 + regs->u_regs[UREG_G4] = ((sethi1 & 0x003FFFFFU) << 10) | (or1 & 0x000003FFU);
11135 + regs->u_regs[UREG_G4] <<= 32;
11136 + regs->u_regs[UREG_G5] = ((sethi2 & 0x003FFFFFU) << 10) | (or2 & 0x000003FFU);
11137 + regs->u_regs[UREG_G5] += regs->u_regs[UREG_G4];
11138 + regs->u_regs[UREG_G4] = addr + 24;
11139 + addr = regs->u_regs[UREG_G5];
11140 + regs->tpc = addr;
11141 + regs->tnpc = addr+4;
11142 + return 3;
11143 + }
11144 + }
11145 + } while (0);
11146 +
11147 +#ifdef CONFIG_PAX_DLRESOLVE
11148 + do { /* PaX: unpatched PLT emulation step 2 */
11149 + unsigned int save, call, nop;
11150 +
11151 + err = get_user(save, (unsigned int *)(regs->tpc-4));
11152 + err |= get_user(call, (unsigned int *)regs->tpc);
11153 + err |= get_user(nop, (unsigned int *)(regs->tpc+4));
11154 + if (err)
11155 + break;
11156 +
11157 + if (save == 0x9DE3BFA8U &&
11158 + (call & 0xC0000000U) == 0x40000000U &&
11159 + nop == 0x01000000U)
11160 + {
11161 + unsigned long dl_resolve = regs->tpc + ((((call | 0xFFFFFFFFC0000000UL) ^ 0x20000000UL) + 0x20000000UL) << 2);
11162 +
11163 + if (test_thread_flag(TIF_32BIT))
11164 + dl_resolve &= 0xFFFFFFFFUL;
11165 +
11166 + regs->u_regs[UREG_RETPC] = regs->tpc;
11167 + regs->tpc = dl_resolve;
11168 + regs->tnpc = dl_resolve+4;
11169 + return 3;
11170 + }
11171 + } while (0);
11172 +#endif
11173 +
11174 + do { /* PaX: patched PLT emulation #7, must be AFTER the unpatched PLT emulation */
11175 + unsigned int sethi, ba, nop;
11176 +
11177 + err = get_user(sethi, (unsigned int *)regs->tpc);
11178 + err |= get_user(ba, (unsigned int *)(regs->tpc+4));
11179 + err |= get_user(nop, (unsigned int *)(regs->tpc+8));
11180 +
11181 + if (err)
11182 + break;
11183 +
11184 + if ((sethi & 0xFFC00000U) == 0x03000000U &&
11185 + (ba & 0xFFF00000U) == 0x30600000U &&
11186 + nop == 0x01000000U)
11187 + {
11188 + unsigned long addr;
11189 +
11190 + addr = (sethi & 0x003FFFFFU) << 10;
11191 + regs->u_regs[UREG_G1] = addr;
11192 + addr = regs->tpc + ((((ba | 0xFFFFFFFFFFF80000UL) ^ 0x00040000UL) + 0x00040000UL) << 2);
11193 +
11194 + if (test_thread_flag(TIF_32BIT))
11195 + addr &= 0xFFFFFFFFUL;
11196 +
11197 + regs->tpc = addr;
11198 + regs->tnpc = addr+4;
11199 + return 2;
11200 + }
11201 + } while (0);
11202 +
11203 +#endif
11204 +
11205 + return 1;
11206 +}
11207 +
11208 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
11209 +{
11210 + unsigned long i;
11211 +
11212 + printk(KERN_ERR "PAX: bytes at PC: ");
11213 + for (i = 0; i < 8; i++) {
11214 + unsigned int c;
11215 + if (get_user(c, (unsigned int *)pc+i))
11216 + printk(KERN_CONT "???????? ");
11217 + else
11218 + printk(KERN_CONT "%08x ", c);
11219 + }
11220 + printk("\n");
11221 +}
11222 +#endif
11223 +
11224 asmlinkage void __kprobes do_sparc64_fault(struct pt_regs *regs)
11225 {
11226 struct mm_struct *mm = current->mm;
11227 @@ -342,6 +805,29 @@ retry:
11228 if (!vma)
11229 goto bad_area;
11230
11231 +#ifdef CONFIG_PAX_PAGEEXEC
11232 + /* PaX: detect ITLB misses on non-exec pages */
11233 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && vma->vm_start <= address &&
11234 + !(vma->vm_flags & VM_EXEC) && (fault_code & FAULT_CODE_ITLB))
11235 + {
11236 + if (address != regs->tpc)
11237 + goto good_area;
11238 +
11239 + up_read(&mm->mmap_sem);
11240 + switch (pax_handle_fetch_fault(regs)) {
11241 +
11242 +#ifdef CONFIG_PAX_EMUPLT
11243 + case 2:
11244 + case 3:
11245 + return;
11246 +#endif
11247 +
11248 + }
11249 + pax_report_fault(regs, (void *)regs->tpc, (void *)(regs->u_regs[UREG_FP] + STACK_BIAS));
11250 + do_group_exit(SIGKILL);
11251 + }
11252 +#endif
11253 +
11254 /* Pure DTLB misses do not tell us whether the fault causing
11255 * load/store/atomic was a write or not, it only says that there
11256 * was no match. So in such a case we (carefully) read the
11257 diff --git a/arch/sparc/mm/hugetlbpage.c b/arch/sparc/mm/hugetlbpage.c
11258 index 9639964..806cd0c 100644
11259 --- a/arch/sparc/mm/hugetlbpage.c
11260 +++ b/arch/sparc/mm/hugetlbpage.c
11261 @@ -28,7 +28,8 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11262 unsigned long addr,
11263 unsigned long len,
11264 unsigned long pgoff,
11265 - unsigned long flags)
11266 + unsigned long flags,
11267 + unsigned long offset)
11268 {
11269 unsigned long task_size = TASK_SIZE;
11270 struct vm_unmapped_area_info info;
11271 @@ -38,15 +39,22 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *filp,
11272
11273 info.flags = 0;
11274 info.length = len;
11275 - info.low_limit = TASK_UNMAPPED_BASE;
11276 + info.low_limit = mm->mmap_base;
11277 info.high_limit = min(task_size, VA_EXCLUDE_START);
11278 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11279 info.align_offset = 0;
11280 + info.threadstack_offset = offset;
11281 addr = vm_unmapped_area(&info);
11282
11283 if ((addr & ~PAGE_MASK) && task_size > VA_EXCLUDE_END) {
11284 VM_BUG_ON(addr != -ENOMEM);
11285 info.low_limit = VA_EXCLUDE_END;
11286 +
11287 +#ifdef CONFIG_PAX_RANDMMAP
11288 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11289 + info.low_limit += mm->delta_mmap;
11290 +#endif
11291 +
11292 info.high_limit = task_size;
11293 addr = vm_unmapped_area(&info);
11294 }
11295 @@ -58,7 +66,8 @@ static unsigned long
11296 hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11297 const unsigned long len,
11298 const unsigned long pgoff,
11299 - const unsigned long flags)
11300 + const unsigned long flags,
11301 + const unsigned long offset)
11302 {
11303 struct mm_struct *mm = current->mm;
11304 unsigned long addr = addr0;
11305 @@ -73,6 +82,7 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11306 info.high_limit = mm->mmap_base;
11307 info.align_mask = PAGE_MASK & ~HPAGE_MASK;
11308 info.align_offset = 0;
11309 + info.threadstack_offset = offset;
11310 addr = vm_unmapped_area(&info);
11311
11312 /*
11313 @@ -85,6 +95,12 @@ hugetlb_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
11314 VM_BUG_ON(addr != -ENOMEM);
11315 info.flags = 0;
11316 info.low_limit = TASK_UNMAPPED_BASE;
11317 +
11318 +#ifdef CONFIG_PAX_RANDMMAP
11319 + if (mm->pax_flags & MF_PAX_RANDMMAP)
11320 + info.low_limit += mm->delta_mmap;
11321 +#endif
11322 +
11323 info.high_limit = STACK_TOP32;
11324 addr = vm_unmapped_area(&info);
11325 }
11326 @@ -99,6 +115,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11327 struct mm_struct *mm = current->mm;
11328 struct vm_area_struct *vma;
11329 unsigned long task_size = TASK_SIZE;
11330 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
11331
11332 if (test_thread_flag(TIF_32BIT))
11333 task_size = STACK_TOP32;
11334 @@ -114,19 +131,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
11335 return addr;
11336 }
11337
11338 +#ifdef CONFIG_PAX_RANDMMAP
11339 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
11340 +#endif
11341 +
11342 if (addr) {
11343 addr = ALIGN(addr, HPAGE_SIZE);
11344 vma = find_vma(mm, addr);
11345 - if (task_size - len >= addr &&
11346 - (!vma || addr + len <= vma->vm_start))
11347 + if (task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
11348 return addr;
11349 }
11350 if (mm->get_unmapped_area == arch_get_unmapped_area)
11351 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
11352 - pgoff, flags);
11353 + pgoff, flags, offset);
11354 else
11355 return hugetlb_get_unmapped_area_topdown(file, addr, len,
11356 - pgoff, flags);
11357 + pgoff, flags, offset);
11358 }
11359
11360 pte_t *huge_pte_alloc(struct mm_struct *mm,
11361 diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c
11362 index ed82eda..0d80e77 100644
11363 --- a/arch/sparc/mm/init_64.c
11364 +++ b/arch/sparc/mm/init_64.c
11365 @@ -188,9 +188,9 @@ unsigned long sparc64_kern_sec_context __read_mostly;
11366 int num_kernel_image_mappings;
11367
11368 #ifdef CONFIG_DEBUG_DCFLUSH
11369 -atomic_t dcpage_flushes = ATOMIC_INIT(0);
11370 +atomic_unchecked_t dcpage_flushes = ATOMIC_INIT(0);
11371 #ifdef CONFIG_SMP
11372 -atomic_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11373 +atomic_unchecked_t dcpage_flushes_xcall = ATOMIC_INIT(0);
11374 #endif
11375 #endif
11376
11377 @@ -198,7 +198,7 @@ inline void flush_dcache_page_impl(struct page *page)
11378 {
11379 BUG_ON(tlb_type == hypervisor);
11380 #ifdef CONFIG_DEBUG_DCFLUSH
11381 - atomic_inc(&dcpage_flushes);
11382 + atomic_inc_unchecked(&dcpage_flushes);
11383 #endif
11384
11385 #ifdef DCACHE_ALIASING_POSSIBLE
11386 @@ -466,10 +466,10 @@ void mmu_info(struct seq_file *m)
11387
11388 #ifdef CONFIG_DEBUG_DCFLUSH
11389 seq_printf(m, "DCPageFlushes\t: %d\n",
11390 - atomic_read(&dcpage_flushes));
11391 + atomic_read_unchecked(&dcpage_flushes));
11392 #ifdef CONFIG_SMP
11393 seq_printf(m, "DCPageFlushesXC\t: %d\n",
11394 - atomic_read(&dcpage_flushes_xcall));
11395 + atomic_read_unchecked(&dcpage_flushes_xcall));
11396 #endif /* CONFIG_SMP */
11397 #endif /* CONFIG_DEBUG_DCFLUSH */
11398 }
11399 diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
11400 index d45a2c4..3c05a78 100644
11401 --- a/arch/tile/Kconfig
11402 +++ b/arch/tile/Kconfig
11403 @@ -185,6 +185,7 @@ source "kernel/Kconfig.hz"
11404
11405 config KEXEC
11406 bool "kexec system call"
11407 + depends on !GRKERNSEC_KMEM
11408 ---help---
11409 kexec is a system call that implements the ability to shutdown your
11410 current kernel, and to start another kernel. It is like a reboot
11411 diff --git a/arch/tile/include/asm/atomic_64.h b/arch/tile/include/asm/atomic_64.h
11412 index ad220ee..2f537b3 100644
11413 --- a/arch/tile/include/asm/atomic_64.h
11414 +++ b/arch/tile/include/asm/atomic_64.h
11415 @@ -105,6 +105,16 @@ static inline long atomic64_add_unless(atomic64_t *v, long a, long u)
11416
11417 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
11418
11419 +#define atomic64_read_unchecked(v) atomic64_read(v)
11420 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
11421 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
11422 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
11423 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
11424 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
11425 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
11426 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
11427 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
11428 +
11429 /* Atomic dec and inc don't implement barrier, so provide them if needed. */
11430 #define smp_mb__before_atomic_dec() smp_mb()
11431 #define smp_mb__after_atomic_dec() smp_mb()
11432 diff --git a/arch/tile/include/asm/cache.h b/arch/tile/include/asm/cache.h
11433 index 6160761..00cac88 100644
11434 --- a/arch/tile/include/asm/cache.h
11435 +++ b/arch/tile/include/asm/cache.h
11436 @@ -15,11 +15,12 @@
11437 #ifndef _ASM_TILE_CACHE_H
11438 #define _ASM_TILE_CACHE_H
11439
11440 +#include <linux/const.h>
11441 #include <arch/chip.h>
11442
11443 /* bytes per L1 data cache line */
11444 #define L1_CACHE_SHIFT CHIP_L1D_LOG_LINE_SIZE()
11445 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11446 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11447
11448 /* bytes per L2 cache line */
11449 #define L2_CACHE_SHIFT CHIP_L2_LOG_LINE_SIZE()
11450 diff --git a/arch/tile/include/asm/uaccess.h b/arch/tile/include/asm/uaccess.h
11451 index b6cde32..c0cb736 100644
11452 --- a/arch/tile/include/asm/uaccess.h
11453 +++ b/arch/tile/include/asm/uaccess.h
11454 @@ -414,9 +414,9 @@ static inline unsigned long __must_check copy_from_user(void *to,
11455 const void __user *from,
11456 unsigned long n)
11457 {
11458 - int sz = __compiletime_object_size(to);
11459 + size_t sz = __compiletime_object_size(to);
11460
11461 - if (likely(sz == -1 || sz >= n))
11462 + if (likely(sz == (size_t)-1 || sz >= n))
11463 n = _copy_from_user(to, from, n);
11464 else
11465 copy_from_user_overflow();
11466 diff --git a/arch/tile/mm/hugetlbpage.c b/arch/tile/mm/hugetlbpage.c
11467 index 0cb3bba..7338b2d 100644
11468 --- a/arch/tile/mm/hugetlbpage.c
11469 +++ b/arch/tile/mm/hugetlbpage.c
11470 @@ -212,6 +212,7 @@ static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
11471 info.high_limit = TASK_SIZE;
11472 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11473 info.align_offset = 0;
11474 + info.threadstack_offset = 0;
11475 return vm_unmapped_area(&info);
11476 }
11477
11478 @@ -229,6 +230,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
11479 info.high_limit = current->mm->mmap_base;
11480 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
11481 info.align_offset = 0;
11482 + info.threadstack_offset = 0;
11483 addr = vm_unmapped_area(&info);
11484
11485 /*
11486 diff --git a/arch/um/Makefile b/arch/um/Makefile
11487 index 133f7de..1d6f2f1 100644
11488 --- a/arch/um/Makefile
11489 +++ b/arch/um/Makefile
11490 @@ -62,6 +62,10 @@ USER_CFLAGS = $(patsubst $(KERNEL_DEFINES),,$(patsubst -D__KERNEL__,,\
11491 $(patsubst -I%,,$(KBUILD_CFLAGS)))) $(ARCH_INCLUDE) $(MODE_INCLUDE) \
11492 $(filter -I%,$(CFLAGS)) -D_FILE_OFFSET_BITS=64 -idirafter include
11493
11494 +ifdef CONSTIFY_PLUGIN
11495 +USER_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11496 +endif
11497 +
11498 #This will adjust *FLAGS accordingly to the platform.
11499 include $(srctree)/$(ARCH_DIR)/Makefile-os-$(OS)
11500
11501 diff --git a/arch/um/defconfig b/arch/um/defconfig
11502 index 2665e6b..3e3822b 100644
11503 --- a/arch/um/defconfig
11504 +++ b/arch/um/defconfig
11505 @@ -51,7 +51,6 @@ CONFIG_X86_CMPXCHG=y
11506 CONFIG_X86_L1_CACHE_SHIFT=5
11507 CONFIG_X86_XADD=y
11508 CONFIG_X86_PPRO_FENCE=y
11509 -CONFIG_X86_WP_WORKS_OK=y
11510 CONFIG_X86_INVLPG=y
11511 CONFIG_X86_BSWAP=y
11512 CONFIG_X86_POPAD_OK=y
11513 diff --git a/arch/um/include/asm/cache.h b/arch/um/include/asm/cache.h
11514 index 19e1bdd..3665b77 100644
11515 --- a/arch/um/include/asm/cache.h
11516 +++ b/arch/um/include/asm/cache.h
11517 @@ -1,6 +1,7 @@
11518 #ifndef __UM_CACHE_H
11519 #define __UM_CACHE_H
11520
11521 +#include <linux/const.h>
11522
11523 #if defined(CONFIG_UML_X86) && !defined(CONFIG_64BIT)
11524 # define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
11525 @@ -12,6 +13,6 @@
11526 # define L1_CACHE_SHIFT 5
11527 #endif
11528
11529 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11530 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11531
11532 #endif
11533 diff --git a/arch/um/include/asm/kmap_types.h b/arch/um/include/asm/kmap_types.h
11534 index 2e0a6b1..a64d0f5 100644
11535 --- a/arch/um/include/asm/kmap_types.h
11536 +++ b/arch/um/include/asm/kmap_types.h
11537 @@ -8,6 +8,6 @@
11538
11539 /* No more #include "asm/arch/kmap_types.h" ! */
11540
11541 -#define KM_TYPE_NR 14
11542 +#define KM_TYPE_NR 15
11543
11544 #endif
11545 diff --git a/arch/um/include/asm/page.h b/arch/um/include/asm/page.h
11546 index 5ff53d9..5850cdf 100644
11547 --- a/arch/um/include/asm/page.h
11548 +++ b/arch/um/include/asm/page.h
11549 @@ -14,6 +14,9 @@
11550 #define PAGE_SIZE (_AC(1, UL) << PAGE_SHIFT)
11551 #define PAGE_MASK (~(PAGE_SIZE-1))
11552
11553 +#define ktla_ktva(addr) (addr)
11554 +#define ktva_ktla(addr) (addr)
11555 +
11556 #ifndef __ASSEMBLY__
11557
11558 struct page;
11559 diff --git a/arch/um/include/asm/pgtable-3level.h b/arch/um/include/asm/pgtable-3level.h
11560 index 0032f92..cd151e0 100644
11561 --- a/arch/um/include/asm/pgtable-3level.h
11562 +++ b/arch/um/include/asm/pgtable-3level.h
11563 @@ -58,6 +58,7 @@
11564 #define pud_present(x) (pud_val(x) & _PAGE_PRESENT)
11565 #define pud_populate(mm, pud, pmd) \
11566 set_pud(pud, __pud(_PAGE_TABLE + __pa(pmd)))
11567 +#define pud_populate_kernel(mm, pud, pmd) pud_populate((mm), (pud), (pmd))
11568
11569 #ifdef CONFIG_64BIT
11570 #define set_pud(pudptr, pudval) set_64bit((u64 *) (pudptr), pud_val(pudval))
11571 diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
11572 index bbcef52..6a2a483 100644
11573 --- a/arch/um/kernel/process.c
11574 +++ b/arch/um/kernel/process.c
11575 @@ -367,22 +367,6 @@ int singlestepping(void * t)
11576 return 2;
11577 }
11578
11579 -/*
11580 - * Only x86 and x86_64 have an arch_align_stack().
11581 - * All other arches have "#define arch_align_stack(x) (x)"
11582 - * in their asm/system.h
11583 - * As this is included in UML from asm-um/system-generic.h,
11584 - * we can use it to behave as the subarch does.
11585 - */
11586 -#ifndef arch_align_stack
11587 -unsigned long arch_align_stack(unsigned long sp)
11588 -{
11589 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
11590 - sp -= get_random_int() % 8192;
11591 - return sp & ~0xf;
11592 -}
11593 -#endif
11594 -
11595 unsigned long get_wchan(struct task_struct *p)
11596 {
11597 unsigned long stack_page, sp, ip;
11598 diff --git a/arch/unicore32/include/asm/cache.h b/arch/unicore32/include/asm/cache.h
11599 index ad8f795..2c7eec6 100644
11600 --- a/arch/unicore32/include/asm/cache.h
11601 +++ b/arch/unicore32/include/asm/cache.h
11602 @@ -12,8 +12,10 @@
11603 #ifndef __UNICORE_CACHE_H__
11604 #define __UNICORE_CACHE_H__
11605
11606 -#define L1_CACHE_SHIFT (5)
11607 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
11608 +#include <linux/const.h>
11609 +
11610 +#define L1_CACHE_SHIFT 5
11611 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
11612
11613 /*
11614 * Memory returned by kmalloc() may be used for DMA, so we must make
11615 diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
11616 index f67e839..bfd4748 100644
11617 --- a/arch/x86/Kconfig
11618 +++ b/arch/x86/Kconfig
11619 @@ -247,7 +247,7 @@ config X86_HT
11620
11621 config X86_32_LAZY_GS
11622 def_bool y
11623 - depends on X86_32 && !CC_STACKPROTECTOR
11624 + depends on X86_32 && !CC_STACKPROTECTOR && !PAX_MEMORY_UDEREF
11625
11626 config ARCH_HWEIGHT_CFLAGS
11627 string
11628 @@ -1099,6 +1099,7 @@ config MICROCODE_EARLY
11629
11630 config X86_MSR
11631 tristate "/dev/cpu/*/msr - Model-specific register support"
11632 + depends on !GRKERNSEC_KMEM
11633 ---help---
11634 This device gives privileged processes access to the x86
11635 Model-Specific Registers (MSRs). It is a character device with
11636 @@ -1122,7 +1123,7 @@ choice
11637
11638 config NOHIGHMEM
11639 bool "off"
11640 - depends on !X86_NUMAQ
11641 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11642 ---help---
11643 Linux can use up to 64 Gigabytes of physical memory on x86 systems.
11644 However, the address space of 32-bit x86 processors is only 4
11645 @@ -1159,7 +1160,7 @@ config NOHIGHMEM
11646
11647 config HIGHMEM4G
11648 bool "4GB"
11649 - depends on !X86_NUMAQ
11650 + depends on !X86_NUMAQ && !(PAX_PAGEEXEC && PAX_ENABLE_PAE)
11651 ---help---
11652 Select this if you have a 32-bit processor and between 1 and 4
11653 gigabytes of physical RAM.
11654 @@ -1212,7 +1213,7 @@ config PAGE_OFFSET
11655 hex
11656 default 0xB0000000 if VMSPLIT_3G_OPT
11657 default 0x80000000 if VMSPLIT_2G
11658 - default 0x78000000 if VMSPLIT_2G_OPT
11659 + default 0x70000000 if VMSPLIT_2G_OPT
11660 default 0x40000000 if VMSPLIT_1G
11661 default 0xC0000000
11662 depends on X86_32
11663 @@ -1614,6 +1615,7 @@ config SECCOMP
11664
11665 config CC_STACKPROTECTOR
11666 bool "Enable -fstack-protector buffer overflow detection"
11667 + depends on X86_64 || !PAX_MEMORY_UDEREF
11668 ---help---
11669 This option turns on the -fstack-protector GCC feature. This
11670 feature puts, at the beginning of functions, a canary value on
11671 @@ -1632,6 +1634,7 @@ source kernel/Kconfig.hz
11672
11673 config KEXEC
11674 bool "kexec system call"
11675 + depends on !GRKERNSEC_KMEM
11676 ---help---
11677 kexec is a system call that implements the ability to shutdown your
11678 current kernel, and to start another kernel. It is like a reboot
11679 @@ -1733,6 +1736,8 @@ config X86_NEED_RELOCS
11680 config PHYSICAL_ALIGN
11681 hex "Alignment value to which kernel should be aligned"
11682 default "0x1000000"
11683 + range 0x200000 0x1000000 if PAX_KERNEXEC && X86_PAE
11684 + range 0x400000 0x1000000 if PAX_KERNEXEC && !X86_PAE
11685 range 0x2000 0x1000000 if X86_32
11686 range 0x200000 0x1000000 if X86_64
11687 ---help---
11688 @@ -1812,9 +1817,10 @@ config DEBUG_HOTPLUG_CPU0
11689 If unsure, say N.
11690
11691 config COMPAT_VDSO
11692 - def_bool y
11693 + def_bool n
11694 prompt "Compat VDSO support"
11695 depends on X86_32 || IA32_EMULATION
11696 + depends on !PAX_PAGEEXEC && !PAX_SEGMEXEC && !PAX_KERNEXEC && !PAX_MEMORY_UDEREF
11697 ---help---
11698 Map the 32-bit VDSO to the predictable old-style address too.
11699
11700 diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
11701 index c026cca..14657ae 100644
11702 --- a/arch/x86/Kconfig.cpu
11703 +++ b/arch/x86/Kconfig.cpu
11704 @@ -319,7 +319,7 @@ config X86_PPRO_FENCE
11705
11706 config X86_F00F_BUG
11707 def_bool y
11708 - depends on M586MMX || M586TSC || M586 || M486
11709 + depends on (M586MMX || M586TSC || M586 || M486) && !PAX_KERNEXEC
11710
11711 config X86_INVD_BUG
11712 def_bool y
11713 @@ -327,7 +327,7 @@ config X86_INVD_BUG
11714
11715 config X86_ALIGNMENT_16
11716 def_bool y
11717 - depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || MELAN || MK6 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11718 + depends on MWINCHIP3D || MWINCHIPC6 || MCYRIXIII || X86_ELAN || MK8 || MK7 || MK6 || MCORE2 || MPENTIUM4 || MPENTIUMIII || MPENTIUMII || M686 || M586MMX || M586TSC || M586 || M486 || MVIAC3_2 || MGEODEGX1
11719
11720 config X86_INTEL_USERCOPY
11721 def_bool y
11722 @@ -373,7 +373,7 @@ config X86_CMPXCHG64
11723 # generates cmov.
11724 config X86_CMOV
11725 def_bool y
11726 - depends on (MK8 || MK7 || MCORE2 || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11727 + depends on (MK8 || MK7 || MCORE2 || MPSC || MPENTIUM4 || MPENTIUMM || MPENTIUMIII || MPENTIUMII || M686 || MVIAC3_2 || MVIAC7 || MCRUSOE || MEFFICEON || X86_64 || MATOM || MGEODE_LX)
11728
11729 config X86_MINIMUM_CPU_FAMILY
11730 int
11731 diff --git a/arch/x86/Kconfig.debug b/arch/x86/Kconfig.debug
11732 index 78d91af..8ceb94b 100644
11733 --- a/arch/x86/Kconfig.debug
11734 +++ b/arch/x86/Kconfig.debug
11735 @@ -74,7 +74,7 @@ config X86_PTDUMP
11736 config DEBUG_RODATA
11737 bool "Write protect kernel read-only data structures"
11738 default y
11739 - depends on DEBUG_KERNEL
11740 + depends on DEBUG_KERNEL && BROKEN
11741 ---help---
11742 Mark the kernel read-only data as write-protected in the pagetables,
11743 in order to catch accidental (and incorrect) writes to such const
11744 @@ -92,7 +92,7 @@ config DEBUG_RODATA_TEST
11745
11746 config DEBUG_SET_MODULE_RONX
11747 bool "Set loadable kernel module data as NX and text as RO"
11748 - depends on MODULES
11749 + depends on MODULES && BROKEN
11750 ---help---
11751 This option helps catch unintended modifications to loadable
11752 kernel module's text and read-only data. It also prevents execution
11753 diff --git a/arch/x86/Makefile b/arch/x86/Makefile
11754 index 57d0215..b4373fb 100644
11755 --- a/arch/x86/Makefile
11756 +++ b/arch/x86/Makefile
11757 @@ -49,14 +49,12 @@ ifeq ($(CONFIG_X86_32),y)
11758 # CPU-specific tuning. Anything which can be shared with UML should go here.
11759 include $(srctree)/arch/x86/Makefile_32.cpu
11760 KBUILD_CFLAGS += $(cflags-y)
11761 -
11762 - # temporary until string.h is fixed
11763 - KBUILD_CFLAGS += -ffreestanding
11764 else
11765 BITS := 64
11766 UTS_MACHINE := x86_64
11767 CHECKFLAGS += -D__x86_64__ -m64
11768
11769 + biarch := $(call cc-option,-m64)
11770 KBUILD_AFLAGS += -m64
11771 KBUILD_CFLAGS += -m64
11772
11773 @@ -89,6 +87,9 @@ else
11774 KBUILD_CFLAGS += -maccumulate-outgoing-args
11775 endif
11776
11777 +# temporary until string.h is fixed
11778 +KBUILD_CFLAGS += -ffreestanding
11779 +
11780 ifdef CONFIG_CC_STACKPROTECTOR
11781 cc_has_sp := $(srctree)/scripts/gcc-x86_$(BITS)-has-stack-protector.sh
11782 ifeq ($(shell $(CONFIG_SHELL) $(cc_has_sp) $(CC) $(KBUILD_CPPFLAGS) $(biarch)),y)
11783 @@ -247,3 +248,12 @@ define archhelp
11784 echo ' FDINITRD=file initrd for the booted kernel'
11785 echo ' kvmconfig - Enable additional options for guest kernel support'
11786 endef
11787 +
11788 +define OLD_LD
11789 +
11790 +*** ${VERSION}.${PATCHLEVEL} PaX kernels no longer build correctly with old versions of binutils.
11791 +*** Please upgrade your binutils to 2.18 or newer
11792 +endef
11793 +
11794 +archprepare:
11795 + $(if $(LDFLAGS_BUILD_ID),,$(error $(OLD_LD)))
11796 diff --git a/arch/x86/boot/Makefile b/arch/x86/boot/Makefile
11797 index 6cf0111..f2e2398 100644
11798 --- a/arch/x86/boot/Makefile
11799 +++ b/arch/x86/boot/Makefile
11800 @@ -65,6 +65,9 @@ KBUILD_CFLAGS := $(USERINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ \
11801 $(call cc-option, -fno-unit-at-a-time)) \
11802 $(call cc-option, -fno-stack-protector) \
11803 $(call cc-option, -mpreferred-stack-boundary=2)
11804 +ifdef CONSTIFY_PLUGIN
11805 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11806 +endif
11807 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11808 GCOV_PROFILE := n
11809
11810 diff --git a/arch/x86/boot/bitops.h b/arch/x86/boot/bitops.h
11811 index 878e4b9..20537ab 100644
11812 --- a/arch/x86/boot/bitops.h
11813 +++ b/arch/x86/boot/bitops.h
11814 @@ -26,7 +26,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11815 u8 v;
11816 const u32 *p = (const u32 *)addr;
11817
11818 - asm("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11819 + asm volatile("btl %2,%1; setc %0" : "=qm" (v) : "m" (*p), "Ir" (nr));
11820 return v;
11821 }
11822
11823 @@ -37,7 +37,7 @@ static inline int variable_test_bit(int nr, const void *addr)
11824
11825 static inline void set_bit(int nr, void *addr)
11826 {
11827 - asm("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11828 + asm volatile("btsl %1,%0" : "+m" (*(u32 *)addr) : "Ir" (nr));
11829 }
11830
11831 #endif /* BOOT_BITOPS_H */
11832 diff --git a/arch/x86/boot/boot.h b/arch/x86/boot/boot.h
11833 index ef72bae..353a184 100644
11834 --- a/arch/x86/boot/boot.h
11835 +++ b/arch/x86/boot/boot.h
11836 @@ -85,7 +85,7 @@ static inline void io_delay(void)
11837 static inline u16 ds(void)
11838 {
11839 u16 seg;
11840 - asm("movw %%ds,%0" : "=rm" (seg));
11841 + asm volatile("movw %%ds,%0" : "=rm" (seg));
11842 return seg;
11843 }
11844
11845 @@ -181,7 +181,7 @@ static inline void wrgs32(u32 v, addr_t addr)
11846 static inline int memcmp(const void *s1, const void *s2, size_t len)
11847 {
11848 u8 diff;
11849 - asm("repe; cmpsb; setnz %0"
11850 + asm volatile("repe; cmpsb; setnz %0"
11851 : "=qm" (diff), "+D" (s1), "+S" (s2), "+c" (len));
11852 return diff;
11853 }
11854 diff --git a/arch/x86/boot/compressed/Makefile b/arch/x86/boot/compressed/Makefile
11855 index c8a6792..2402765 100644
11856 --- a/arch/x86/boot/compressed/Makefile
11857 +++ b/arch/x86/boot/compressed/Makefile
11858 @@ -16,6 +16,9 @@ KBUILD_CFLAGS += $(cflags-y)
11859 KBUILD_CFLAGS += -mno-mmx -mno-sse
11860 KBUILD_CFLAGS += $(call cc-option,-ffreestanding)
11861 KBUILD_CFLAGS += $(call cc-option,-fno-stack-protector)
11862 +ifdef CONSTIFY_PLUGIN
11863 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
11864 +endif
11865
11866 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
11867 GCOV_PROFILE := n
11868 diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c
11869 index b7388a4..03844ec 100644
11870 --- a/arch/x86/boot/compressed/eboot.c
11871 +++ b/arch/x86/boot/compressed/eboot.c
11872 @@ -150,7 +150,6 @@ again:
11873 *addr = max_addr;
11874 }
11875
11876 -free_pool:
11877 efi_call_phys1(sys_table->boottime->free_pool, map);
11878
11879 fail:
11880 @@ -214,7 +213,6 @@ static efi_status_t low_alloc(unsigned long size, unsigned long align,
11881 if (i == map_size / desc_size)
11882 status = EFI_NOT_FOUND;
11883
11884 -free_pool:
11885 efi_call_phys1(sys_table->boottime->free_pool, map);
11886 fail:
11887 return status;
11888 diff --git a/arch/x86/boot/compressed/efi_stub_32.S b/arch/x86/boot/compressed/efi_stub_32.S
11889 index a53440e..c3dbf1e 100644
11890 --- a/arch/x86/boot/compressed/efi_stub_32.S
11891 +++ b/arch/x86/boot/compressed/efi_stub_32.S
11892 @@ -46,16 +46,13 @@ ENTRY(efi_call_phys)
11893 * parameter 2, ..., param n. To make things easy, we save the return
11894 * address of efi_call_phys in a global variable.
11895 */
11896 - popl %ecx
11897 - movl %ecx, saved_return_addr(%edx)
11898 - /* get the function pointer into ECX*/
11899 - popl %ecx
11900 - movl %ecx, efi_rt_function_ptr(%edx)
11901 + popl saved_return_addr(%edx)
11902 + popl efi_rt_function_ptr(%edx)
11903
11904 /*
11905 * 3. Call the physical function.
11906 */
11907 - call *%ecx
11908 + call *efi_rt_function_ptr(%edx)
11909
11910 /*
11911 * 4. Balance the stack. And because EAX contain the return value,
11912 @@ -67,15 +64,12 @@ ENTRY(efi_call_phys)
11913 1: popl %edx
11914 subl $1b, %edx
11915
11916 - movl efi_rt_function_ptr(%edx), %ecx
11917 - pushl %ecx
11918 + pushl efi_rt_function_ptr(%edx)
11919
11920 /*
11921 * 10. Push the saved return address onto the stack and return.
11922 */
11923 - movl saved_return_addr(%edx), %ecx
11924 - pushl %ecx
11925 - ret
11926 + jmpl *saved_return_addr(%edx)
11927 ENDPROC(efi_call_phys)
11928 .previous
11929
11930 diff --git a/arch/x86/boot/compressed/head_32.S b/arch/x86/boot/compressed/head_32.S
11931 index 5d6f689..9d06730 100644
11932 --- a/arch/x86/boot/compressed/head_32.S
11933 +++ b/arch/x86/boot/compressed/head_32.S
11934 @@ -118,7 +118,7 @@ preferred_addr:
11935 notl %eax
11936 andl %eax, %ebx
11937 #else
11938 - movl $LOAD_PHYSICAL_ADDR, %ebx
11939 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11940 #endif
11941
11942 /* Target address to relocate to for decompression */
11943 diff --git a/arch/x86/boot/compressed/head_64.S b/arch/x86/boot/compressed/head_64.S
11944 index c337422..2c5be72 100644
11945 --- a/arch/x86/boot/compressed/head_64.S
11946 +++ b/arch/x86/boot/compressed/head_64.S
11947 @@ -95,7 +95,7 @@ ENTRY(startup_32)
11948 notl %eax
11949 andl %eax, %ebx
11950 #else
11951 - movl $LOAD_PHYSICAL_ADDR, %ebx
11952 + movl $____LOAD_PHYSICAL_ADDR, %ebx
11953 #endif
11954
11955 /* Target address to relocate to for decompression */
11956 @@ -270,7 +270,7 @@ preferred_addr:
11957 notq %rax
11958 andq %rax, %rbp
11959 #else
11960 - movq $LOAD_PHYSICAL_ADDR, %rbp
11961 + movq $____LOAD_PHYSICAL_ADDR, %rbp
11962 #endif
11963
11964 /* Target address to relocate to for decompression */
11965 @@ -362,8 +362,8 @@ gdt:
11966 .long gdt
11967 .word 0
11968 .quad 0x0000000000000000 /* NULL descriptor */
11969 - .quad 0x00af9a000000ffff /* __KERNEL_CS */
11970 - .quad 0x00cf92000000ffff /* __KERNEL_DS */
11971 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
11972 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
11973 .quad 0x0080890000000000 /* TS descriptor */
11974 .quad 0x0000000000000000 /* TS continued */
11975 gdt_end:
11976 diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
11977 index 434f077..b6b4b38 100644
11978 --- a/arch/x86/boot/compressed/misc.c
11979 +++ b/arch/x86/boot/compressed/misc.c
11980 @@ -283,7 +283,7 @@ static void handle_relocations(void *output, unsigned long output_len)
11981 * Calculate the delta between where vmlinux was linked to load
11982 * and where it was actually loaded.
11983 */
11984 - delta = min_addr - LOAD_PHYSICAL_ADDR;
11985 + delta = min_addr - ____LOAD_PHYSICAL_ADDR;
11986 if (!delta) {
11987 debug_putstr("No relocation needed... ");
11988 return;
11989 @@ -380,7 +380,7 @@ static void parse_elf(void *output)
11990 case PT_LOAD:
11991 #ifdef CONFIG_RELOCATABLE
11992 dest = output;
11993 - dest += (phdr->p_paddr - LOAD_PHYSICAL_ADDR);
11994 + dest += (phdr->p_paddr - ____LOAD_PHYSICAL_ADDR);
11995 #else
11996 dest = (void *)(phdr->p_paddr);
11997 #endif
11998 @@ -432,7 +432,7 @@ asmlinkage void decompress_kernel(void *rmode, memptr heap,
11999 error("Destination address too large");
12000 #endif
12001 #ifndef CONFIG_RELOCATABLE
12002 - if ((unsigned long)output != LOAD_PHYSICAL_ADDR)
12003 + if ((unsigned long)output != ____LOAD_PHYSICAL_ADDR)
12004 error("Wrong destination address");
12005 #endif
12006
12007 diff --git a/arch/x86/boot/cpucheck.c b/arch/x86/boot/cpucheck.c
12008 index 4d3ff03..e4972ff 100644
12009 --- a/arch/x86/boot/cpucheck.c
12010 +++ b/arch/x86/boot/cpucheck.c
12011 @@ -74,7 +74,7 @@ static int has_fpu(void)
12012 u16 fcw = -1, fsw = -1;
12013 u32 cr0;
12014
12015 - asm("movl %%cr0,%0" : "=r" (cr0));
12016 + asm volatile("movl %%cr0,%0" : "=r" (cr0));
12017 if (cr0 & (X86_CR0_EM|X86_CR0_TS)) {
12018 cr0 &= ~(X86_CR0_EM|X86_CR0_TS);
12019 asm volatile("movl %0,%%cr0" : : "r" (cr0));
12020 @@ -90,7 +90,7 @@ static int has_eflag(u32 mask)
12021 {
12022 u32 f0, f1;
12023
12024 - asm("pushfl ; "
12025 + asm volatile("pushfl ; "
12026 "pushfl ; "
12027 "popl %0 ; "
12028 "movl %0,%1 ; "
12029 @@ -115,7 +115,7 @@ static void get_flags(void)
12030 set_bit(X86_FEATURE_FPU, cpu.flags);
12031
12032 if (has_eflag(X86_EFLAGS_ID)) {
12033 - asm("cpuid"
12034 + asm volatile("cpuid"
12035 : "=a" (max_intel_level),
12036 "=b" (cpu_vendor[0]),
12037 "=d" (cpu_vendor[1]),
12038 @@ -124,7 +124,7 @@ static void get_flags(void)
12039
12040 if (max_intel_level >= 0x00000001 &&
12041 max_intel_level <= 0x0000ffff) {
12042 - asm("cpuid"
12043 + asm volatile("cpuid"
12044 : "=a" (tfms),
12045 "=c" (cpu.flags[4]),
12046 "=d" (cpu.flags[0])
12047 @@ -136,7 +136,7 @@ static void get_flags(void)
12048 cpu.model += ((tfms >> 16) & 0xf) << 4;
12049 }
12050
12051 - asm("cpuid"
12052 + asm volatile("cpuid"
12053 : "=a" (max_amd_level)
12054 : "a" (0x80000000)
12055 : "ebx", "ecx", "edx");
12056 @@ -144,7 +144,7 @@ static void get_flags(void)
12057 if (max_amd_level >= 0x80000001 &&
12058 max_amd_level <= 0x8000ffff) {
12059 u32 eax = 0x80000001;
12060 - asm("cpuid"
12061 + asm volatile("cpuid"
12062 : "+a" (eax),
12063 "=c" (cpu.flags[6]),
12064 "=d" (cpu.flags[1])
12065 @@ -203,9 +203,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12066 u32 ecx = MSR_K7_HWCR;
12067 u32 eax, edx;
12068
12069 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12070 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12071 eax &= ~(1 << 15);
12072 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12073 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12074
12075 get_flags(); /* Make sure it really did something */
12076 err = check_flags();
12077 @@ -218,9 +218,9 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12078 u32 ecx = MSR_VIA_FCR;
12079 u32 eax, edx;
12080
12081 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12082 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12083 eax |= (1<<1)|(1<<7);
12084 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12085 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12086
12087 set_bit(X86_FEATURE_CX8, cpu.flags);
12088 err = check_flags();
12089 @@ -231,12 +231,12 @@ int check_cpu(int *cpu_level_ptr, int *req_level_ptr, u32 **err_flags_ptr)
12090 u32 eax, edx;
12091 u32 level = 1;
12092
12093 - asm("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12094 - asm("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12095 - asm("cpuid"
12096 + asm volatile("rdmsr" : "=a" (eax), "=d" (edx) : "c" (ecx));
12097 + asm volatile("wrmsr" : : "a" (~0), "d" (edx), "c" (ecx));
12098 + asm volatile("cpuid"
12099 : "+a" (level), "=d" (cpu.flags[0])
12100 : : "ecx", "ebx");
12101 - asm("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12102 + asm volatile("wrmsr" : : "a" (eax), "d" (edx), "c" (ecx));
12103
12104 err = check_flags();
12105 }
12106 diff --git a/arch/x86/boot/header.S b/arch/x86/boot/header.S
12107 index 9ec06a1..2c25e79 100644
12108 --- a/arch/x86/boot/header.S
12109 +++ b/arch/x86/boot/header.S
12110 @@ -409,10 +409,14 @@ setup_data: .quad 0 # 64-bit physical pointer to
12111 # single linked list of
12112 # struct setup_data
12113
12114 -pref_address: .quad LOAD_PHYSICAL_ADDR # preferred load addr
12115 +pref_address: .quad ____LOAD_PHYSICAL_ADDR # preferred load addr
12116
12117 #define ZO_INIT_SIZE (ZO__end - ZO_startup_32 + ZO_z_extract_offset)
12118 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
12119 +#define VO_INIT_SIZE (VO__end - VO__text - __PAGE_OFFSET - ____LOAD_PHYSICAL_ADDR)
12120 +#else
12121 #define VO_INIT_SIZE (VO__end - VO__text)
12122 +#endif
12123 #if ZO_INIT_SIZE > VO_INIT_SIZE
12124 #define INIT_SIZE ZO_INIT_SIZE
12125 #else
12126 diff --git a/arch/x86/boot/memory.c b/arch/x86/boot/memory.c
12127 index db75d07..8e6d0af 100644
12128 --- a/arch/x86/boot/memory.c
12129 +++ b/arch/x86/boot/memory.c
12130 @@ -19,7 +19,7 @@
12131
12132 static int detect_memory_e820(void)
12133 {
12134 - int count = 0;
12135 + unsigned int count = 0;
12136 struct biosregs ireg, oreg;
12137 struct e820entry *desc = boot_params.e820_map;
12138 static struct e820entry buf; /* static so it is zeroed */
12139 diff --git a/arch/x86/boot/video-vesa.c b/arch/x86/boot/video-vesa.c
12140 index 11e8c6e..fdbb1ed 100644
12141 --- a/arch/x86/boot/video-vesa.c
12142 +++ b/arch/x86/boot/video-vesa.c
12143 @@ -200,6 +200,7 @@ static void vesa_store_pm_info(void)
12144
12145 boot_params.screen_info.vesapm_seg = oreg.es;
12146 boot_params.screen_info.vesapm_off = oreg.di;
12147 + boot_params.screen_info.vesapm_size = oreg.cx;
12148 }
12149
12150 /*
12151 diff --git a/arch/x86/boot/video.c b/arch/x86/boot/video.c
12152 index 43eda28..5ab5fdb 100644
12153 --- a/arch/x86/boot/video.c
12154 +++ b/arch/x86/boot/video.c
12155 @@ -96,7 +96,7 @@ static void store_mode_params(void)
12156 static unsigned int get_entry(void)
12157 {
12158 char entry_buf[4];
12159 - int i, len = 0;
12160 + unsigned int i, len = 0;
12161 int key;
12162 unsigned int v;
12163
12164 diff --git a/arch/x86/crypto/aes-x86_64-asm_64.S b/arch/x86/crypto/aes-x86_64-asm_64.S
12165 index 9105655..41779c1 100644
12166 --- a/arch/x86/crypto/aes-x86_64-asm_64.S
12167 +++ b/arch/x86/crypto/aes-x86_64-asm_64.S
12168 @@ -8,6 +8,8 @@
12169 * including this sentence is retained in full.
12170 */
12171
12172 +#include <asm/alternative-asm.h>
12173 +
12174 .extern crypto_ft_tab
12175 .extern crypto_it_tab
12176 .extern crypto_fl_tab
12177 @@ -70,6 +72,8 @@
12178 je B192; \
12179 leaq 32(r9),r9;
12180
12181 +#define ret pax_force_retaddr; ret
12182 +
12183 #define epilogue(FUNC,r1,r2,r3,r4,r5,r6,r7,r8,r9) \
12184 movq r1,r2; \
12185 movq r3,r4; \
12186 diff --git a/arch/x86/crypto/aesni-intel_asm.S b/arch/x86/crypto/aesni-intel_asm.S
12187 index 477e9d7..c92c7d8 100644
12188 --- a/arch/x86/crypto/aesni-intel_asm.S
12189 +++ b/arch/x86/crypto/aesni-intel_asm.S
12190 @@ -31,6 +31,7 @@
12191
12192 #include <linux/linkage.h>
12193 #include <asm/inst.h>
12194 +#include <asm/alternative-asm.h>
12195
12196 #ifdef __x86_64__
12197 .data
12198 @@ -205,7 +206,7 @@ enc: .octa 0x2
12199 * num_initial_blocks = b mod 4
12200 * encrypt the initial num_initial_blocks blocks and apply ghash on
12201 * the ciphertext
12202 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12203 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12204 * are clobbered
12205 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12206 */
12207 @@ -214,8 +215,8 @@ enc: .octa 0x2
12208 .macro INITIAL_BLOCKS_DEC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12209 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12210 mov arg7, %r10 # %r10 = AAD
12211 - mov arg8, %r12 # %r12 = aadLen
12212 - mov %r12, %r11
12213 + mov arg8, %r15 # %r15 = aadLen
12214 + mov %r15, %r11
12215 pxor %xmm\i, %xmm\i
12216 _get_AAD_loop\num_initial_blocks\operation:
12217 movd (%r10), \TMP1
12218 @@ -223,15 +224,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12219 psrldq $4, %xmm\i
12220 pxor \TMP1, %xmm\i
12221 add $4, %r10
12222 - sub $4, %r12
12223 + sub $4, %r15
12224 jne _get_AAD_loop\num_initial_blocks\operation
12225 cmp $16, %r11
12226 je _get_AAD_loop2_done\num_initial_blocks\operation
12227 - mov $16, %r12
12228 + mov $16, %r15
12229 _get_AAD_loop2\num_initial_blocks\operation:
12230 psrldq $4, %xmm\i
12231 - sub $4, %r12
12232 - cmp %r11, %r12
12233 + sub $4, %r15
12234 + cmp %r11, %r15
12235 jne _get_AAD_loop2\num_initial_blocks\operation
12236 _get_AAD_loop2_done\num_initial_blocks\operation:
12237 movdqa SHUF_MASK(%rip), %xmm14
12238 @@ -443,7 +444,7 @@ _initial_blocks_done\num_initial_blocks\operation:
12239 * num_initial_blocks = b mod 4
12240 * encrypt the initial num_initial_blocks blocks and apply ghash on
12241 * the ciphertext
12242 -* %r10, %r11, %r12, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12243 +* %r10, %r11, %r15, %rax, %xmm5, %xmm6, %xmm7, %xmm8, %xmm9 registers
12244 * are clobbered
12245 * arg1, %arg2, %arg3, %r14 are used as a pointer only, not modified
12246 */
12247 @@ -452,8 +453,8 @@ _initial_blocks_done\num_initial_blocks\operation:
12248 .macro INITIAL_BLOCKS_ENC num_initial_blocks TMP1 TMP2 TMP3 TMP4 TMP5 XMM0 XMM1 \
12249 XMM2 XMM3 XMM4 XMMDst TMP6 TMP7 i i_seq operation
12250 mov arg7, %r10 # %r10 = AAD
12251 - mov arg8, %r12 # %r12 = aadLen
12252 - mov %r12, %r11
12253 + mov arg8, %r15 # %r15 = aadLen
12254 + mov %r15, %r11
12255 pxor %xmm\i, %xmm\i
12256 _get_AAD_loop\num_initial_blocks\operation:
12257 movd (%r10), \TMP1
12258 @@ -461,15 +462,15 @@ _get_AAD_loop\num_initial_blocks\operation:
12259 psrldq $4, %xmm\i
12260 pxor \TMP1, %xmm\i
12261 add $4, %r10
12262 - sub $4, %r12
12263 + sub $4, %r15
12264 jne _get_AAD_loop\num_initial_blocks\operation
12265 cmp $16, %r11
12266 je _get_AAD_loop2_done\num_initial_blocks\operation
12267 - mov $16, %r12
12268 + mov $16, %r15
12269 _get_AAD_loop2\num_initial_blocks\operation:
12270 psrldq $4, %xmm\i
12271 - sub $4, %r12
12272 - cmp %r11, %r12
12273 + sub $4, %r15
12274 + cmp %r11, %r15
12275 jne _get_AAD_loop2\num_initial_blocks\operation
12276 _get_AAD_loop2_done\num_initial_blocks\operation:
12277 movdqa SHUF_MASK(%rip), %xmm14
12278 @@ -1269,7 +1270,7 @@ TMP7 XMM1 XMM2 XMM3 XMM4 XMMDst
12279 *
12280 *****************************************************************************/
12281 ENTRY(aesni_gcm_dec)
12282 - push %r12
12283 + push %r15
12284 push %r13
12285 push %r14
12286 mov %rsp, %r14
12287 @@ -1279,8 +1280,8 @@ ENTRY(aesni_gcm_dec)
12288 */
12289 sub $VARIABLE_OFFSET, %rsp
12290 and $~63, %rsp # align rsp to 64 bytes
12291 - mov %arg6, %r12
12292 - movdqu (%r12), %xmm13 # %xmm13 = HashKey
12293 + mov %arg6, %r15
12294 + movdqu (%r15), %xmm13 # %xmm13 = HashKey
12295 movdqa SHUF_MASK(%rip), %xmm2
12296 PSHUFB_XMM %xmm2, %xmm13
12297
12298 @@ -1308,10 +1309,10 @@ ENTRY(aesni_gcm_dec)
12299 movdqa %xmm13, HashKey(%rsp) # store HashKey<<1 (mod poly)
12300 mov %arg4, %r13 # save the number of bytes of plaintext/ciphertext
12301 and $-16, %r13 # %r13 = %r13 - (%r13 mod 16)
12302 - mov %r13, %r12
12303 - and $(3<<4), %r12
12304 + mov %r13, %r15
12305 + and $(3<<4), %r15
12306 jz _initial_num_blocks_is_0_decrypt
12307 - cmp $(2<<4), %r12
12308 + cmp $(2<<4), %r15
12309 jb _initial_num_blocks_is_1_decrypt
12310 je _initial_num_blocks_is_2_decrypt
12311 _initial_num_blocks_is_3_decrypt:
12312 @@ -1361,16 +1362,16 @@ _zero_cipher_left_decrypt:
12313 sub $16, %r11
12314 add %r13, %r11
12315 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte block
12316 - lea SHIFT_MASK+16(%rip), %r12
12317 - sub %r13, %r12
12318 + lea SHIFT_MASK+16(%rip), %r15
12319 + sub %r13, %r15
12320 # adjust the shuffle mask pointer to be able to shift 16-%r13 bytes
12321 # (%r13 is the number of bytes in plaintext mod 16)
12322 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12323 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12324 PSHUFB_XMM %xmm2, %xmm1 # right shift 16-%r13 butes
12325
12326 movdqa %xmm1, %xmm2
12327 pxor %xmm1, %xmm0 # Ciphertext XOR E(K, Yn)
12328 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12329 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12330 # get the appropriate mask to mask out top 16-%r13 bytes of %xmm0
12331 pand %xmm1, %xmm0 # mask out top 16-%r13 bytes of %xmm0
12332 pand %xmm1, %xmm2
12333 @@ -1399,9 +1400,9 @@ _less_than_8_bytes_left_decrypt:
12334 sub $1, %r13
12335 jne _less_than_8_bytes_left_decrypt
12336 _multiple_of_16_bytes_decrypt:
12337 - mov arg8, %r12 # %r13 = aadLen (number of bytes)
12338 - shl $3, %r12 # convert into number of bits
12339 - movd %r12d, %xmm15 # len(A) in %xmm15
12340 + mov arg8, %r15 # %r13 = aadLen (number of bytes)
12341 + shl $3, %r15 # convert into number of bits
12342 + movd %r15d, %xmm15 # len(A) in %xmm15
12343 shl $3, %arg4 # len(C) in bits (*128)
12344 MOVQ_R64_XMM %arg4, %xmm1
12345 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12346 @@ -1440,7 +1441,8 @@ _return_T_done_decrypt:
12347 mov %r14, %rsp
12348 pop %r14
12349 pop %r13
12350 - pop %r12
12351 + pop %r15
12352 + pax_force_retaddr
12353 ret
12354 ENDPROC(aesni_gcm_dec)
12355
12356 @@ -1529,7 +1531,7 @@ ENDPROC(aesni_gcm_dec)
12357 * poly = x^128 + x^127 + x^126 + x^121 + 1
12358 ***************************************************************************/
12359 ENTRY(aesni_gcm_enc)
12360 - push %r12
12361 + push %r15
12362 push %r13
12363 push %r14
12364 mov %rsp, %r14
12365 @@ -1539,8 +1541,8 @@ ENTRY(aesni_gcm_enc)
12366 #
12367 sub $VARIABLE_OFFSET, %rsp
12368 and $~63, %rsp
12369 - mov %arg6, %r12
12370 - movdqu (%r12), %xmm13
12371 + mov %arg6, %r15
12372 + movdqu (%r15), %xmm13
12373 movdqa SHUF_MASK(%rip), %xmm2
12374 PSHUFB_XMM %xmm2, %xmm13
12375
12376 @@ -1564,13 +1566,13 @@ ENTRY(aesni_gcm_enc)
12377 movdqa %xmm13, HashKey(%rsp)
12378 mov %arg4, %r13 # %xmm13 holds HashKey<<1 (mod poly)
12379 and $-16, %r13
12380 - mov %r13, %r12
12381 + mov %r13, %r15
12382
12383 # Encrypt first few blocks
12384
12385 - and $(3<<4), %r12
12386 + and $(3<<4), %r15
12387 jz _initial_num_blocks_is_0_encrypt
12388 - cmp $(2<<4), %r12
12389 + cmp $(2<<4), %r15
12390 jb _initial_num_blocks_is_1_encrypt
12391 je _initial_num_blocks_is_2_encrypt
12392 _initial_num_blocks_is_3_encrypt:
12393 @@ -1623,14 +1625,14 @@ _zero_cipher_left_encrypt:
12394 sub $16, %r11
12395 add %r13, %r11
12396 movdqu (%arg3,%r11,1), %xmm1 # receive the last <16 byte blocks
12397 - lea SHIFT_MASK+16(%rip), %r12
12398 - sub %r13, %r12
12399 + lea SHIFT_MASK+16(%rip), %r15
12400 + sub %r13, %r15
12401 # adjust the shuffle mask pointer to be able to shift 16-r13 bytes
12402 # (%r13 is the number of bytes in plaintext mod 16)
12403 - movdqu (%r12), %xmm2 # get the appropriate shuffle mask
12404 + movdqu (%r15), %xmm2 # get the appropriate shuffle mask
12405 PSHUFB_XMM %xmm2, %xmm1 # shift right 16-r13 byte
12406 pxor %xmm1, %xmm0 # Plaintext XOR Encrypt(K, Yn)
12407 - movdqu ALL_F-SHIFT_MASK(%r12), %xmm1
12408 + movdqu ALL_F-SHIFT_MASK(%r15), %xmm1
12409 # get the appropriate mask to mask out top 16-r13 bytes of xmm0
12410 pand %xmm1, %xmm0 # mask out top 16-r13 bytes of xmm0
12411 movdqa SHUF_MASK(%rip), %xmm10
12412 @@ -1663,9 +1665,9 @@ _less_than_8_bytes_left_encrypt:
12413 sub $1, %r13
12414 jne _less_than_8_bytes_left_encrypt
12415 _multiple_of_16_bytes_encrypt:
12416 - mov arg8, %r12 # %r12 = addLen (number of bytes)
12417 - shl $3, %r12
12418 - movd %r12d, %xmm15 # len(A) in %xmm15
12419 + mov arg8, %r15 # %r15 = addLen (number of bytes)
12420 + shl $3, %r15
12421 + movd %r15d, %xmm15 # len(A) in %xmm15
12422 shl $3, %arg4 # len(C) in bits (*128)
12423 MOVQ_R64_XMM %arg4, %xmm1
12424 pslldq $8, %xmm15 # %xmm15 = len(A)||0x0000000000000000
12425 @@ -1704,7 +1706,8 @@ _return_T_done_encrypt:
12426 mov %r14, %rsp
12427 pop %r14
12428 pop %r13
12429 - pop %r12
12430 + pop %r15
12431 + pax_force_retaddr
12432 ret
12433 ENDPROC(aesni_gcm_enc)
12434
12435 @@ -1722,6 +1725,7 @@ _key_expansion_256a:
12436 pxor %xmm1, %xmm0
12437 movaps %xmm0, (TKEYP)
12438 add $0x10, TKEYP
12439 + pax_force_retaddr
12440 ret
12441 ENDPROC(_key_expansion_128)
12442 ENDPROC(_key_expansion_256a)
12443 @@ -1748,6 +1752,7 @@ _key_expansion_192a:
12444 shufps $0b01001110, %xmm2, %xmm1
12445 movaps %xmm1, 0x10(TKEYP)
12446 add $0x20, TKEYP
12447 + pax_force_retaddr
12448 ret
12449 ENDPROC(_key_expansion_192a)
12450
12451 @@ -1768,6 +1773,7 @@ _key_expansion_192b:
12452
12453 movaps %xmm0, (TKEYP)
12454 add $0x10, TKEYP
12455 + pax_force_retaddr
12456 ret
12457 ENDPROC(_key_expansion_192b)
12458
12459 @@ -1781,6 +1787,7 @@ _key_expansion_256b:
12460 pxor %xmm1, %xmm2
12461 movaps %xmm2, (TKEYP)
12462 add $0x10, TKEYP
12463 + pax_force_retaddr
12464 ret
12465 ENDPROC(_key_expansion_256b)
12466
12467 @@ -1894,6 +1901,7 @@ ENTRY(aesni_set_key)
12468 #ifndef __x86_64__
12469 popl KEYP
12470 #endif
12471 + pax_force_retaddr
12472 ret
12473 ENDPROC(aesni_set_key)
12474
12475 @@ -1916,6 +1924,7 @@ ENTRY(aesni_enc)
12476 popl KLEN
12477 popl KEYP
12478 #endif
12479 + pax_force_retaddr
12480 ret
12481 ENDPROC(aesni_enc)
12482
12483 @@ -1974,6 +1983,7 @@ _aesni_enc1:
12484 AESENC KEY STATE
12485 movaps 0x70(TKEYP), KEY
12486 AESENCLAST KEY STATE
12487 + pax_force_retaddr
12488 ret
12489 ENDPROC(_aesni_enc1)
12490
12491 @@ -2083,6 +2093,7 @@ _aesni_enc4:
12492 AESENCLAST KEY STATE2
12493 AESENCLAST KEY STATE3
12494 AESENCLAST KEY STATE4
12495 + pax_force_retaddr
12496 ret
12497 ENDPROC(_aesni_enc4)
12498
12499 @@ -2106,6 +2117,7 @@ ENTRY(aesni_dec)
12500 popl KLEN
12501 popl KEYP
12502 #endif
12503 + pax_force_retaddr
12504 ret
12505 ENDPROC(aesni_dec)
12506
12507 @@ -2164,6 +2176,7 @@ _aesni_dec1:
12508 AESDEC KEY STATE
12509 movaps 0x70(TKEYP), KEY
12510 AESDECLAST KEY STATE
12511 + pax_force_retaddr
12512 ret
12513 ENDPROC(_aesni_dec1)
12514
12515 @@ -2273,6 +2286,7 @@ _aesni_dec4:
12516 AESDECLAST KEY STATE2
12517 AESDECLAST KEY STATE3
12518 AESDECLAST KEY STATE4
12519 + pax_force_retaddr
12520 ret
12521 ENDPROC(_aesni_dec4)
12522
12523 @@ -2331,6 +2345,7 @@ ENTRY(aesni_ecb_enc)
12524 popl KEYP
12525 popl LEN
12526 #endif
12527 + pax_force_retaddr
12528 ret
12529 ENDPROC(aesni_ecb_enc)
12530
12531 @@ -2390,6 +2405,7 @@ ENTRY(aesni_ecb_dec)
12532 popl KEYP
12533 popl LEN
12534 #endif
12535 + pax_force_retaddr
12536 ret
12537 ENDPROC(aesni_ecb_dec)
12538
12539 @@ -2432,6 +2448,7 @@ ENTRY(aesni_cbc_enc)
12540 popl LEN
12541 popl IVP
12542 #endif
12543 + pax_force_retaddr
12544 ret
12545 ENDPROC(aesni_cbc_enc)
12546
12547 @@ -2523,6 +2540,7 @@ ENTRY(aesni_cbc_dec)
12548 popl LEN
12549 popl IVP
12550 #endif
12551 + pax_force_retaddr
12552 ret
12553 ENDPROC(aesni_cbc_dec)
12554
12555 @@ -2550,6 +2568,7 @@ _aesni_inc_init:
12556 mov $1, TCTR_LOW
12557 MOVQ_R64_XMM TCTR_LOW INC
12558 MOVQ_R64_XMM CTR TCTR_LOW
12559 + pax_force_retaddr
12560 ret
12561 ENDPROC(_aesni_inc_init)
12562
12563 @@ -2579,6 +2598,7 @@ _aesni_inc:
12564 .Linc_low:
12565 movaps CTR, IV
12566 PSHUFB_XMM BSWAP_MASK IV
12567 + pax_force_retaddr
12568 ret
12569 ENDPROC(_aesni_inc)
12570
12571 @@ -2640,6 +2660,7 @@ ENTRY(aesni_ctr_enc)
12572 .Lctr_enc_ret:
12573 movups IV, (IVP)
12574 .Lctr_enc_just_ret:
12575 + pax_force_retaddr
12576 ret
12577 ENDPROC(aesni_ctr_enc)
12578
12579 @@ -2766,6 +2787,7 @@ ENTRY(aesni_xts_crypt8)
12580 pxor INC, STATE4
12581 movdqu STATE4, 0x70(OUTP)
12582
12583 + pax_force_retaddr
12584 ret
12585 ENDPROC(aesni_xts_crypt8)
12586
12587 diff --git a/arch/x86/crypto/blowfish-x86_64-asm_64.S b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12588 index 246c670..466e2d6 100644
12589 --- a/arch/x86/crypto/blowfish-x86_64-asm_64.S
12590 +++ b/arch/x86/crypto/blowfish-x86_64-asm_64.S
12591 @@ -21,6 +21,7 @@
12592 */
12593
12594 #include <linux/linkage.h>
12595 +#include <asm/alternative-asm.h>
12596
12597 .file "blowfish-x86_64-asm.S"
12598 .text
12599 @@ -149,9 +150,11 @@ ENTRY(__blowfish_enc_blk)
12600 jnz .L__enc_xor;
12601
12602 write_block();
12603 + pax_force_retaddr
12604 ret;
12605 .L__enc_xor:
12606 xor_block();
12607 + pax_force_retaddr
12608 ret;
12609 ENDPROC(__blowfish_enc_blk)
12610
12611 @@ -183,6 +186,7 @@ ENTRY(blowfish_dec_blk)
12612
12613 movq %r11, %rbp;
12614
12615 + pax_force_retaddr
12616 ret;
12617 ENDPROC(blowfish_dec_blk)
12618
12619 @@ -334,6 +338,7 @@ ENTRY(__blowfish_enc_blk_4way)
12620
12621 popq %rbx;
12622 popq %rbp;
12623 + pax_force_retaddr
12624 ret;
12625
12626 .L__enc_xor4:
12627 @@ -341,6 +346,7 @@ ENTRY(__blowfish_enc_blk_4way)
12628
12629 popq %rbx;
12630 popq %rbp;
12631 + pax_force_retaddr
12632 ret;
12633 ENDPROC(__blowfish_enc_blk_4way)
12634
12635 @@ -375,5 +381,6 @@ ENTRY(blowfish_dec_blk_4way)
12636 popq %rbx;
12637 popq %rbp;
12638
12639 + pax_force_retaddr
12640 ret;
12641 ENDPROC(blowfish_dec_blk_4way)
12642 diff --git a/arch/x86/crypto/camellia-aesni-avx-asm_64.S b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12643 index ce71f92..1dce7ec 100644
12644 --- a/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12645 +++ b/arch/x86/crypto/camellia-aesni-avx-asm_64.S
12646 @@ -16,6 +16,7 @@
12647 */
12648
12649 #include <linux/linkage.h>
12650 +#include <asm/alternative-asm.h>
12651
12652 #define CAMELLIA_TABLE_BYTE_LEN 272
12653
12654 @@ -191,6 +192,7 @@ roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12655 roundsm16(%xmm0, %xmm1, %xmm2, %xmm3, %xmm4, %xmm5, %xmm6, %xmm7,
12656 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14, %xmm15,
12657 %rcx, (%r9));
12658 + pax_force_retaddr
12659 ret;
12660 ENDPROC(roundsm16_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12661
12662 @@ -199,6 +201,7 @@ roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12663 roundsm16(%xmm4, %xmm5, %xmm6, %xmm7, %xmm0, %xmm1, %xmm2, %xmm3,
12664 %xmm12, %xmm13, %xmm14, %xmm15, %xmm8, %xmm9, %xmm10, %xmm11,
12665 %rax, (%r9));
12666 + pax_force_retaddr
12667 ret;
12668 ENDPROC(roundsm16_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12669
12670 @@ -780,6 +783,7 @@ __camellia_enc_blk16:
12671 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12672 %xmm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 16(%rax));
12673
12674 + pax_force_retaddr
12675 ret;
12676
12677 .align 8
12678 @@ -865,6 +869,7 @@ __camellia_dec_blk16:
12679 %xmm8, %xmm9, %xmm10, %xmm11, %xmm12, %xmm13, %xmm14,
12680 %xmm15, (key_table)(CTX), (%rax), 1 * 16(%rax));
12681
12682 + pax_force_retaddr
12683 ret;
12684
12685 .align 8
12686 @@ -904,6 +909,7 @@ ENTRY(camellia_ecb_enc_16way)
12687 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12688 %xmm8, %rsi);
12689
12690 + pax_force_retaddr
12691 ret;
12692 ENDPROC(camellia_ecb_enc_16way)
12693
12694 @@ -932,6 +938,7 @@ ENTRY(camellia_ecb_dec_16way)
12695 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12696 %xmm8, %rsi);
12697
12698 + pax_force_retaddr
12699 ret;
12700 ENDPROC(camellia_ecb_dec_16way)
12701
12702 @@ -981,6 +988,7 @@ ENTRY(camellia_cbc_dec_16way)
12703 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12704 %xmm8, %rsi);
12705
12706 + pax_force_retaddr
12707 ret;
12708 ENDPROC(camellia_cbc_dec_16way)
12709
12710 @@ -1092,6 +1100,7 @@ ENTRY(camellia_ctr_16way)
12711 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12712 %xmm8, %rsi);
12713
12714 + pax_force_retaddr
12715 ret;
12716 ENDPROC(camellia_ctr_16way)
12717
12718 @@ -1234,6 +1243,7 @@ camellia_xts_crypt_16way:
12719 %xmm15, %xmm14, %xmm13, %xmm12, %xmm11, %xmm10, %xmm9,
12720 %xmm8, %rsi);
12721
12722 + pax_force_retaddr
12723 ret;
12724 ENDPROC(camellia_xts_crypt_16way)
12725
12726 diff --git a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12727 index 0e0b886..5a3123c 100644
12728 --- a/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12729 +++ b/arch/x86/crypto/camellia-aesni-avx2-asm_64.S
12730 @@ -11,6 +11,7 @@
12731 */
12732
12733 #include <linux/linkage.h>
12734 +#include <asm/alternative-asm.h>
12735
12736 #define CAMELLIA_TABLE_BYTE_LEN 272
12737
12738 @@ -230,6 +231,7 @@ roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd:
12739 roundsm32(%ymm0, %ymm1, %ymm2, %ymm3, %ymm4, %ymm5, %ymm6, %ymm7,
12740 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14, %ymm15,
12741 %rcx, (%r9));
12742 + pax_force_retaddr
12743 ret;
12744 ENDPROC(roundsm32_x0_x1_x2_x3_x4_x5_x6_x7_y0_y1_y2_y3_y4_y5_y6_y7_cd)
12745
12746 @@ -238,6 +240,7 @@ roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab:
12747 roundsm32(%ymm4, %ymm5, %ymm6, %ymm7, %ymm0, %ymm1, %ymm2, %ymm3,
12748 %ymm12, %ymm13, %ymm14, %ymm15, %ymm8, %ymm9, %ymm10, %ymm11,
12749 %rax, (%r9));
12750 + pax_force_retaddr
12751 ret;
12752 ENDPROC(roundsm32_x4_x5_x6_x7_x0_x1_x2_x3_y4_y5_y6_y7_y0_y1_y2_y3_ab)
12753
12754 @@ -820,6 +823,7 @@ __camellia_enc_blk32:
12755 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12756 %ymm15, (key_table)(CTX, %r8, 8), (%rax), 1 * 32(%rax));
12757
12758 + pax_force_retaddr
12759 ret;
12760
12761 .align 8
12762 @@ -905,6 +909,7 @@ __camellia_dec_blk32:
12763 %ymm8, %ymm9, %ymm10, %ymm11, %ymm12, %ymm13, %ymm14,
12764 %ymm15, (key_table)(CTX), (%rax), 1 * 32(%rax));
12765
12766 + pax_force_retaddr
12767 ret;
12768
12769 .align 8
12770 @@ -948,6 +953,7 @@ ENTRY(camellia_ecb_enc_32way)
12771
12772 vzeroupper;
12773
12774 + pax_force_retaddr
12775 ret;
12776 ENDPROC(camellia_ecb_enc_32way)
12777
12778 @@ -980,6 +986,7 @@ ENTRY(camellia_ecb_dec_32way)
12779
12780 vzeroupper;
12781
12782 + pax_force_retaddr
12783 ret;
12784 ENDPROC(camellia_ecb_dec_32way)
12785
12786 @@ -1046,6 +1053,7 @@ ENTRY(camellia_cbc_dec_32way)
12787
12788 vzeroupper;
12789
12790 + pax_force_retaddr
12791 ret;
12792 ENDPROC(camellia_cbc_dec_32way)
12793
12794 @@ -1184,6 +1192,7 @@ ENTRY(camellia_ctr_32way)
12795
12796 vzeroupper;
12797
12798 + pax_force_retaddr
12799 ret;
12800 ENDPROC(camellia_ctr_32way)
12801
12802 @@ -1349,6 +1358,7 @@ camellia_xts_crypt_32way:
12803
12804 vzeroupper;
12805
12806 + pax_force_retaddr
12807 ret;
12808 ENDPROC(camellia_xts_crypt_32way)
12809
12810 diff --git a/arch/x86/crypto/camellia-x86_64-asm_64.S b/arch/x86/crypto/camellia-x86_64-asm_64.S
12811 index 310319c..db3d7b5 100644
12812 --- a/arch/x86/crypto/camellia-x86_64-asm_64.S
12813 +++ b/arch/x86/crypto/camellia-x86_64-asm_64.S
12814 @@ -21,6 +21,7 @@
12815 */
12816
12817 #include <linux/linkage.h>
12818 +#include <asm/alternative-asm.h>
12819
12820 .file "camellia-x86_64-asm_64.S"
12821 .text
12822 @@ -228,12 +229,14 @@ ENTRY(__camellia_enc_blk)
12823 enc_outunpack(mov, RT1);
12824
12825 movq RRBP, %rbp;
12826 + pax_force_retaddr
12827 ret;
12828
12829 .L__enc_xor:
12830 enc_outunpack(xor, RT1);
12831
12832 movq RRBP, %rbp;
12833 + pax_force_retaddr
12834 ret;
12835 ENDPROC(__camellia_enc_blk)
12836
12837 @@ -272,6 +275,7 @@ ENTRY(camellia_dec_blk)
12838 dec_outunpack();
12839
12840 movq RRBP, %rbp;
12841 + pax_force_retaddr
12842 ret;
12843 ENDPROC(camellia_dec_blk)
12844
12845 @@ -463,6 +467,7 @@ ENTRY(__camellia_enc_blk_2way)
12846
12847 movq RRBP, %rbp;
12848 popq %rbx;
12849 + pax_force_retaddr
12850 ret;
12851
12852 .L__enc2_xor:
12853 @@ -470,6 +475,7 @@ ENTRY(__camellia_enc_blk_2way)
12854
12855 movq RRBP, %rbp;
12856 popq %rbx;
12857 + pax_force_retaddr
12858 ret;
12859 ENDPROC(__camellia_enc_blk_2way)
12860
12861 @@ -510,5 +516,6 @@ ENTRY(camellia_dec_blk_2way)
12862
12863 movq RRBP, %rbp;
12864 movq RXOR, %rbx;
12865 + pax_force_retaddr
12866 ret;
12867 ENDPROC(camellia_dec_blk_2way)
12868 diff --git a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12869 index c35fd5d..2d8c7db 100644
12870 --- a/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12871 +++ b/arch/x86/crypto/cast5-avx-x86_64-asm_64.S
12872 @@ -24,6 +24,7 @@
12873 */
12874
12875 #include <linux/linkage.h>
12876 +#include <asm/alternative-asm.h>
12877
12878 .file "cast5-avx-x86_64-asm_64.S"
12879
12880 @@ -281,6 +282,7 @@ __cast5_enc_blk16:
12881 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12882 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12883
12884 + pax_force_retaddr
12885 ret;
12886 ENDPROC(__cast5_enc_blk16)
12887
12888 @@ -352,6 +354,7 @@ __cast5_dec_blk16:
12889 outunpack_blocks(RR3, RL3, RTMP, RX, RKM);
12890 outunpack_blocks(RR4, RL4, RTMP, RX, RKM);
12891
12892 + pax_force_retaddr
12893 ret;
12894
12895 .L__skip_dec:
12896 @@ -388,6 +391,7 @@ ENTRY(cast5_ecb_enc_16way)
12897 vmovdqu RR4, (6*4*4)(%r11);
12898 vmovdqu RL4, (7*4*4)(%r11);
12899
12900 + pax_force_retaddr
12901 ret;
12902 ENDPROC(cast5_ecb_enc_16way)
12903
12904 @@ -420,6 +424,7 @@ ENTRY(cast5_ecb_dec_16way)
12905 vmovdqu RR4, (6*4*4)(%r11);
12906 vmovdqu RL4, (7*4*4)(%r11);
12907
12908 + pax_force_retaddr
12909 ret;
12910 ENDPROC(cast5_ecb_dec_16way)
12911
12912 @@ -430,10 +435,10 @@ ENTRY(cast5_cbc_dec_16way)
12913 * %rdx: src
12914 */
12915
12916 - pushq %r12;
12917 + pushq %r14;
12918
12919 movq %rsi, %r11;
12920 - movq %rdx, %r12;
12921 + movq %rdx, %r14;
12922
12923 vmovdqu (0*16)(%rdx), RL1;
12924 vmovdqu (1*16)(%rdx), RR1;
12925 @@ -447,16 +452,16 @@ ENTRY(cast5_cbc_dec_16way)
12926 call __cast5_dec_blk16;
12927
12928 /* xor with src */
12929 - vmovq (%r12), RX;
12930 + vmovq (%r14), RX;
12931 vpshufd $0x4f, RX, RX;
12932 vpxor RX, RR1, RR1;
12933 - vpxor 0*16+8(%r12), RL1, RL1;
12934 - vpxor 1*16+8(%r12), RR2, RR2;
12935 - vpxor 2*16+8(%r12), RL2, RL2;
12936 - vpxor 3*16+8(%r12), RR3, RR3;
12937 - vpxor 4*16+8(%r12), RL3, RL3;
12938 - vpxor 5*16+8(%r12), RR4, RR4;
12939 - vpxor 6*16+8(%r12), RL4, RL4;
12940 + vpxor 0*16+8(%r14), RL1, RL1;
12941 + vpxor 1*16+8(%r14), RR2, RR2;
12942 + vpxor 2*16+8(%r14), RL2, RL2;
12943 + vpxor 3*16+8(%r14), RR3, RR3;
12944 + vpxor 4*16+8(%r14), RL3, RL3;
12945 + vpxor 5*16+8(%r14), RR4, RR4;
12946 + vpxor 6*16+8(%r14), RL4, RL4;
12947
12948 vmovdqu RR1, (0*16)(%r11);
12949 vmovdqu RL1, (1*16)(%r11);
12950 @@ -467,8 +472,9 @@ ENTRY(cast5_cbc_dec_16way)
12951 vmovdqu RR4, (6*16)(%r11);
12952 vmovdqu RL4, (7*16)(%r11);
12953
12954 - popq %r12;
12955 + popq %r14;
12956
12957 + pax_force_retaddr
12958 ret;
12959 ENDPROC(cast5_cbc_dec_16way)
12960
12961 @@ -480,10 +486,10 @@ ENTRY(cast5_ctr_16way)
12962 * %rcx: iv (big endian, 64bit)
12963 */
12964
12965 - pushq %r12;
12966 + pushq %r14;
12967
12968 movq %rsi, %r11;
12969 - movq %rdx, %r12;
12970 + movq %rdx, %r14;
12971
12972 vpcmpeqd RTMP, RTMP, RTMP;
12973 vpsrldq $8, RTMP, RTMP; /* low: -1, high: 0 */
12974 @@ -523,14 +529,14 @@ ENTRY(cast5_ctr_16way)
12975 call __cast5_enc_blk16;
12976
12977 /* dst = src ^ iv */
12978 - vpxor (0*16)(%r12), RR1, RR1;
12979 - vpxor (1*16)(%r12), RL1, RL1;
12980 - vpxor (2*16)(%r12), RR2, RR2;
12981 - vpxor (3*16)(%r12), RL2, RL2;
12982 - vpxor (4*16)(%r12), RR3, RR3;
12983 - vpxor (5*16)(%r12), RL3, RL3;
12984 - vpxor (6*16)(%r12), RR4, RR4;
12985 - vpxor (7*16)(%r12), RL4, RL4;
12986 + vpxor (0*16)(%r14), RR1, RR1;
12987 + vpxor (1*16)(%r14), RL1, RL1;
12988 + vpxor (2*16)(%r14), RR2, RR2;
12989 + vpxor (3*16)(%r14), RL2, RL2;
12990 + vpxor (4*16)(%r14), RR3, RR3;
12991 + vpxor (5*16)(%r14), RL3, RL3;
12992 + vpxor (6*16)(%r14), RR4, RR4;
12993 + vpxor (7*16)(%r14), RL4, RL4;
12994 vmovdqu RR1, (0*16)(%r11);
12995 vmovdqu RL1, (1*16)(%r11);
12996 vmovdqu RR2, (2*16)(%r11);
12997 @@ -540,7 +546,8 @@ ENTRY(cast5_ctr_16way)
12998 vmovdqu RR4, (6*16)(%r11);
12999 vmovdqu RL4, (7*16)(%r11);
13000
13001 - popq %r12;
13002 + popq %r14;
13003
13004 + pax_force_retaddr
13005 ret;
13006 ENDPROC(cast5_ctr_16way)
13007 diff --git a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13008 index e3531f8..e123f35 100644
13009 --- a/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13010 +++ b/arch/x86/crypto/cast6-avx-x86_64-asm_64.S
13011 @@ -24,6 +24,7 @@
13012 */
13013
13014 #include <linux/linkage.h>
13015 +#include <asm/alternative-asm.h>
13016 #include "glue_helper-asm-avx.S"
13017
13018 .file "cast6-avx-x86_64-asm_64.S"
13019 @@ -295,6 +296,7 @@ __cast6_enc_blk8:
13020 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13021 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13022
13023 + pax_force_retaddr
13024 ret;
13025 ENDPROC(__cast6_enc_blk8)
13026
13027 @@ -340,6 +342,7 @@ __cast6_dec_blk8:
13028 outunpack_blocks(RA1, RB1, RC1, RD1, RTMP, RX, RKRF, RKM);
13029 outunpack_blocks(RA2, RB2, RC2, RD2, RTMP, RX, RKRF, RKM);
13030
13031 + pax_force_retaddr
13032 ret;
13033 ENDPROC(__cast6_dec_blk8)
13034
13035 @@ -358,6 +361,7 @@ ENTRY(cast6_ecb_enc_8way)
13036
13037 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13038
13039 + pax_force_retaddr
13040 ret;
13041 ENDPROC(cast6_ecb_enc_8way)
13042
13043 @@ -376,6 +380,7 @@ ENTRY(cast6_ecb_dec_8way)
13044
13045 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13046
13047 + pax_force_retaddr
13048 ret;
13049 ENDPROC(cast6_ecb_dec_8way)
13050
13051 @@ -386,19 +391,20 @@ ENTRY(cast6_cbc_dec_8way)
13052 * %rdx: src
13053 */
13054
13055 - pushq %r12;
13056 + pushq %r14;
13057
13058 movq %rsi, %r11;
13059 - movq %rdx, %r12;
13060 + movq %rdx, %r14;
13061
13062 load_8way(%rdx, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13063
13064 call __cast6_dec_blk8;
13065
13066 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13067 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13068
13069 - popq %r12;
13070 + popq %r14;
13071
13072 + pax_force_retaddr
13073 ret;
13074 ENDPROC(cast6_cbc_dec_8way)
13075
13076 @@ -410,20 +416,21 @@ ENTRY(cast6_ctr_8way)
13077 * %rcx: iv (little endian, 128bit)
13078 */
13079
13080 - pushq %r12;
13081 + pushq %r14;
13082
13083 movq %rsi, %r11;
13084 - movq %rdx, %r12;
13085 + movq %rdx, %r14;
13086
13087 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13088 RD2, RX, RKR, RKM);
13089
13090 call __cast6_enc_blk8;
13091
13092 - store_ctr_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13093 + store_ctr_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13094
13095 - popq %r12;
13096 + popq %r14;
13097
13098 + pax_force_retaddr
13099 ret;
13100 ENDPROC(cast6_ctr_8way)
13101
13102 @@ -446,6 +453,7 @@ ENTRY(cast6_xts_enc_8way)
13103 /* dst <= regs xor IVs(in dst) */
13104 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13105
13106 + pax_force_retaddr
13107 ret;
13108 ENDPROC(cast6_xts_enc_8way)
13109
13110 @@ -468,5 +476,6 @@ ENTRY(cast6_xts_dec_8way)
13111 /* dst <= regs xor IVs(in dst) */
13112 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13113
13114 + pax_force_retaddr
13115 ret;
13116 ENDPROC(cast6_xts_dec_8way)
13117 diff --git a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13118 index dbc4339..de6e120 100644
13119 --- a/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13120 +++ b/arch/x86/crypto/crc32c-pcl-intel-asm_64.S
13121 @@ -45,6 +45,7 @@
13122
13123 #include <asm/inst.h>
13124 #include <linux/linkage.h>
13125 +#include <asm/alternative-asm.h>
13126
13127 ## ISCSI CRC 32 Implementation with crc32 and pclmulqdq Instruction
13128
13129 @@ -312,6 +313,7 @@ do_return:
13130 popq %rsi
13131 popq %rdi
13132 popq %rbx
13133 + pax_force_retaddr
13134 ret
13135
13136 ################################################################
13137 diff --git a/arch/x86/crypto/ghash-clmulni-intel_asm.S b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13138 index 586f41a..d02851e 100644
13139 --- a/arch/x86/crypto/ghash-clmulni-intel_asm.S
13140 +++ b/arch/x86/crypto/ghash-clmulni-intel_asm.S
13141 @@ -18,6 +18,7 @@
13142
13143 #include <linux/linkage.h>
13144 #include <asm/inst.h>
13145 +#include <asm/alternative-asm.h>
13146
13147 .data
13148
13149 @@ -93,6 +94,7 @@ __clmul_gf128mul_ble:
13150 psrlq $1, T2
13151 pxor T2, T1
13152 pxor T1, DATA
13153 + pax_force_retaddr
13154 ret
13155 ENDPROC(__clmul_gf128mul_ble)
13156
13157 @@ -105,6 +107,7 @@ ENTRY(clmul_ghash_mul)
13158 call __clmul_gf128mul_ble
13159 PSHUFB_XMM BSWAP DATA
13160 movups DATA, (%rdi)
13161 + pax_force_retaddr
13162 ret
13163 ENDPROC(clmul_ghash_mul)
13164
13165 @@ -132,6 +135,7 @@ ENTRY(clmul_ghash_update)
13166 PSHUFB_XMM BSWAP DATA
13167 movups DATA, (%rdi)
13168 .Lupdate_just_ret:
13169 + pax_force_retaddr
13170 ret
13171 ENDPROC(clmul_ghash_update)
13172
13173 @@ -157,5 +161,6 @@ ENTRY(clmul_ghash_setkey)
13174 pand .Lpoly, %xmm1
13175 pxor %xmm1, %xmm0
13176 movups %xmm0, (%rdi)
13177 + pax_force_retaddr
13178 ret
13179 ENDPROC(clmul_ghash_setkey)
13180 diff --git a/arch/x86/crypto/salsa20-x86_64-asm_64.S b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13181 index 9279e0b..c4b3d2c 100644
13182 --- a/arch/x86/crypto/salsa20-x86_64-asm_64.S
13183 +++ b/arch/x86/crypto/salsa20-x86_64-asm_64.S
13184 @@ -1,4 +1,5 @@
13185 #include <linux/linkage.h>
13186 +#include <asm/alternative-asm.h>
13187
13188 # enter salsa20_encrypt_bytes
13189 ENTRY(salsa20_encrypt_bytes)
13190 @@ -789,6 +790,7 @@ ENTRY(salsa20_encrypt_bytes)
13191 add %r11,%rsp
13192 mov %rdi,%rax
13193 mov %rsi,%rdx
13194 + pax_force_retaddr
13195 ret
13196 # bytesatleast65:
13197 ._bytesatleast65:
13198 @@ -889,6 +891,7 @@ ENTRY(salsa20_keysetup)
13199 add %r11,%rsp
13200 mov %rdi,%rax
13201 mov %rsi,%rdx
13202 + pax_force_retaddr
13203 ret
13204 ENDPROC(salsa20_keysetup)
13205
13206 @@ -914,5 +917,6 @@ ENTRY(salsa20_ivsetup)
13207 add %r11,%rsp
13208 mov %rdi,%rax
13209 mov %rsi,%rdx
13210 + pax_force_retaddr
13211 ret
13212 ENDPROC(salsa20_ivsetup)
13213 diff --git a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13214 index 2f202f4..d9164d6 100644
13215 --- a/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13216 +++ b/arch/x86/crypto/serpent-avx-x86_64-asm_64.S
13217 @@ -24,6 +24,7 @@
13218 */
13219
13220 #include <linux/linkage.h>
13221 +#include <asm/alternative-asm.h>
13222 #include "glue_helper-asm-avx.S"
13223
13224 .file "serpent-avx-x86_64-asm_64.S"
13225 @@ -618,6 +619,7 @@ __serpent_enc_blk8_avx:
13226 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13227 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13228
13229 + pax_force_retaddr
13230 ret;
13231 ENDPROC(__serpent_enc_blk8_avx)
13232
13233 @@ -672,6 +674,7 @@ __serpent_dec_blk8_avx:
13234 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13235 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13236
13237 + pax_force_retaddr
13238 ret;
13239 ENDPROC(__serpent_dec_blk8_avx)
13240
13241 @@ -688,6 +691,7 @@ ENTRY(serpent_ecb_enc_8way_avx)
13242
13243 store_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13244
13245 + pax_force_retaddr
13246 ret;
13247 ENDPROC(serpent_ecb_enc_8way_avx)
13248
13249 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_8way_avx)
13250
13251 store_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13252
13253 + pax_force_retaddr
13254 ret;
13255 ENDPROC(serpent_ecb_dec_8way_avx)
13256
13257 @@ -720,6 +725,7 @@ ENTRY(serpent_cbc_dec_8way_avx)
13258
13259 store_cbc_8way(%rdx, %rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13260
13261 + pax_force_retaddr
13262 ret;
13263 ENDPROC(serpent_cbc_dec_8way_avx)
13264
13265 @@ -738,6 +744,7 @@ ENTRY(serpent_ctr_8way_avx)
13266
13267 store_ctr_8way(%rdx, %rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13268
13269 + pax_force_retaddr
13270 ret;
13271 ENDPROC(serpent_ctr_8way_avx)
13272
13273 @@ -758,6 +765,7 @@ ENTRY(serpent_xts_enc_8way_avx)
13274 /* dst <= regs xor IVs(in dst) */
13275 store_xts_8way(%rsi, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13276
13277 + pax_force_retaddr
13278 ret;
13279 ENDPROC(serpent_xts_enc_8way_avx)
13280
13281 @@ -778,5 +786,6 @@ ENTRY(serpent_xts_dec_8way_avx)
13282 /* dst <= regs xor IVs(in dst) */
13283 store_xts_8way(%rsi, RC1, RD1, RB1, RE1, RC2, RD2, RB2, RE2);
13284
13285 + pax_force_retaddr
13286 ret;
13287 ENDPROC(serpent_xts_dec_8way_avx)
13288 diff --git a/arch/x86/crypto/serpent-avx2-asm_64.S b/arch/x86/crypto/serpent-avx2-asm_64.S
13289 index b222085..abd483c 100644
13290 --- a/arch/x86/crypto/serpent-avx2-asm_64.S
13291 +++ b/arch/x86/crypto/serpent-avx2-asm_64.S
13292 @@ -15,6 +15,7 @@
13293 */
13294
13295 #include <linux/linkage.h>
13296 +#include <asm/alternative-asm.h>
13297 #include "glue_helper-asm-avx2.S"
13298
13299 .file "serpent-avx2-asm_64.S"
13300 @@ -610,6 +611,7 @@ __serpent_enc_blk16:
13301 write_blocks(RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13302 write_blocks(RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13303
13304 + pax_force_retaddr
13305 ret;
13306 ENDPROC(__serpent_enc_blk16)
13307
13308 @@ -664,6 +666,7 @@ __serpent_dec_blk16:
13309 write_blocks(RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13310 write_blocks(RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13311
13312 + pax_force_retaddr
13313 ret;
13314 ENDPROC(__serpent_dec_blk16)
13315
13316 @@ -684,6 +687,7 @@ ENTRY(serpent_ecb_enc_16way)
13317
13318 vzeroupper;
13319
13320 + pax_force_retaddr
13321 ret;
13322 ENDPROC(serpent_ecb_enc_16way)
13323
13324 @@ -704,6 +708,7 @@ ENTRY(serpent_ecb_dec_16way)
13325
13326 vzeroupper;
13327
13328 + pax_force_retaddr
13329 ret;
13330 ENDPROC(serpent_ecb_dec_16way)
13331
13332 @@ -725,6 +730,7 @@ ENTRY(serpent_cbc_dec_16way)
13333
13334 vzeroupper;
13335
13336 + pax_force_retaddr
13337 ret;
13338 ENDPROC(serpent_cbc_dec_16way)
13339
13340 @@ -748,6 +754,7 @@ ENTRY(serpent_ctr_16way)
13341
13342 vzeroupper;
13343
13344 + pax_force_retaddr
13345 ret;
13346 ENDPROC(serpent_ctr_16way)
13347
13348 @@ -772,6 +779,7 @@ ENTRY(serpent_xts_enc_16way)
13349
13350 vzeroupper;
13351
13352 + pax_force_retaddr
13353 ret;
13354 ENDPROC(serpent_xts_enc_16way)
13355
13356 @@ -796,5 +804,6 @@ ENTRY(serpent_xts_dec_16way)
13357
13358 vzeroupper;
13359
13360 + pax_force_retaddr
13361 ret;
13362 ENDPROC(serpent_xts_dec_16way)
13363 diff --git a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13364 index acc066c..1559cc4 100644
13365 --- a/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13366 +++ b/arch/x86/crypto/serpent-sse2-x86_64-asm_64.S
13367 @@ -25,6 +25,7 @@
13368 */
13369
13370 #include <linux/linkage.h>
13371 +#include <asm/alternative-asm.h>
13372
13373 .file "serpent-sse2-x86_64-asm_64.S"
13374 .text
13375 @@ -690,12 +691,14 @@ ENTRY(__serpent_enc_blk_8way)
13376 write_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13377 write_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13378
13379 + pax_force_retaddr
13380 ret;
13381
13382 .L__enc_xor8:
13383 xor_blocks(%rsi, RA1, RB1, RC1, RD1, RK0, RK1, RK2);
13384 xor_blocks(%rax, RA2, RB2, RC2, RD2, RK0, RK1, RK2);
13385
13386 + pax_force_retaddr
13387 ret;
13388 ENDPROC(__serpent_enc_blk_8way)
13389
13390 @@ -750,5 +753,6 @@ ENTRY(serpent_dec_blk_8way)
13391 write_blocks(%rsi, RC1, RD1, RB1, RE1, RK0, RK1, RK2);
13392 write_blocks(%rax, RC2, RD2, RB2, RE2, RK0, RK1, RK2);
13393
13394 + pax_force_retaddr
13395 ret;
13396 ENDPROC(serpent_dec_blk_8way)
13397 diff --git a/arch/x86/crypto/sha1_ssse3_asm.S b/arch/x86/crypto/sha1_ssse3_asm.S
13398 index a410950..9dfe7ad 100644
13399 --- a/arch/x86/crypto/sha1_ssse3_asm.S
13400 +++ b/arch/x86/crypto/sha1_ssse3_asm.S
13401 @@ -29,6 +29,7 @@
13402 */
13403
13404 #include <linux/linkage.h>
13405 +#include <asm/alternative-asm.h>
13406
13407 #define CTX %rdi // arg1
13408 #define BUF %rsi // arg2
13409 @@ -75,9 +76,9 @@
13410
13411 push %rbx
13412 push %rbp
13413 - push %r12
13414 + push %r14
13415
13416 - mov %rsp, %r12
13417 + mov %rsp, %r14
13418 sub $64, %rsp # allocate workspace
13419 and $~15, %rsp # align stack
13420
13421 @@ -99,11 +100,12 @@
13422 xor %rax, %rax
13423 rep stosq
13424
13425 - mov %r12, %rsp # deallocate workspace
13426 + mov %r14, %rsp # deallocate workspace
13427
13428 - pop %r12
13429 + pop %r14
13430 pop %rbp
13431 pop %rbx
13432 + pax_force_retaddr
13433 ret
13434
13435 ENDPROC(\name)
13436 diff --git a/arch/x86/crypto/sha256-avx-asm.S b/arch/x86/crypto/sha256-avx-asm.S
13437 index 642f156..51a513c 100644
13438 --- a/arch/x86/crypto/sha256-avx-asm.S
13439 +++ b/arch/x86/crypto/sha256-avx-asm.S
13440 @@ -49,6 +49,7 @@
13441
13442 #ifdef CONFIG_AS_AVX
13443 #include <linux/linkage.h>
13444 +#include <asm/alternative-asm.h>
13445
13446 ## assume buffers not aligned
13447 #define VMOVDQ vmovdqu
13448 @@ -460,6 +461,7 @@ done_hash:
13449 popq %r13
13450 popq %rbp
13451 popq %rbx
13452 + pax_force_retaddr
13453 ret
13454 ENDPROC(sha256_transform_avx)
13455
13456 diff --git a/arch/x86/crypto/sha256-avx2-asm.S b/arch/x86/crypto/sha256-avx2-asm.S
13457 index 9e86944..3795e6a 100644
13458 --- a/arch/x86/crypto/sha256-avx2-asm.S
13459 +++ b/arch/x86/crypto/sha256-avx2-asm.S
13460 @@ -50,6 +50,7 @@
13461
13462 #ifdef CONFIG_AS_AVX2
13463 #include <linux/linkage.h>
13464 +#include <asm/alternative-asm.h>
13465
13466 ## assume buffers not aligned
13467 #define VMOVDQ vmovdqu
13468 @@ -720,6 +721,7 @@ done_hash:
13469 popq %r12
13470 popq %rbp
13471 popq %rbx
13472 + pax_force_retaddr
13473 ret
13474 ENDPROC(sha256_transform_rorx)
13475
13476 diff --git a/arch/x86/crypto/sha256-ssse3-asm.S b/arch/x86/crypto/sha256-ssse3-asm.S
13477 index f833b74..8c62a9e 100644
13478 --- a/arch/x86/crypto/sha256-ssse3-asm.S
13479 +++ b/arch/x86/crypto/sha256-ssse3-asm.S
13480 @@ -47,6 +47,7 @@
13481 ########################################################################
13482
13483 #include <linux/linkage.h>
13484 +#include <asm/alternative-asm.h>
13485
13486 ## assume buffers not aligned
13487 #define MOVDQ movdqu
13488 @@ -471,6 +472,7 @@ done_hash:
13489 popq %rbp
13490 popq %rbx
13491
13492 + pax_force_retaddr
13493 ret
13494 ENDPROC(sha256_transform_ssse3)
13495
13496 diff --git a/arch/x86/crypto/sha512-avx-asm.S b/arch/x86/crypto/sha512-avx-asm.S
13497 index 974dde9..a823ff9 100644
13498 --- a/arch/x86/crypto/sha512-avx-asm.S
13499 +++ b/arch/x86/crypto/sha512-avx-asm.S
13500 @@ -49,6 +49,7 @@
13501
13502 #ifdef CONFIG_AS_AVX
13503 #include <linux/linkage.h>
13504 +#include <asm/alternative-asm.h>
13505
13506 .text
13507
13508 @@ -364,6 +365,7 @@ updateblock:
13509 mov frame_RSPSAVE(%rsp), %rsp
13510
13511 nowork:
13512 + pax_force_retaddr
13513 ret
13514 ENDPROC(sha512_transform_avx)
13515
13516 diff --git a/arch/x86/crypto/sha512-avx2-asm.S b/arch/x86/crypto/sha512-avx2-asm.S
13517 index 568b961..ed20c37 100644
13518 --- a/arch/x86/crypto/sha512-avx2-asm.S
13519 +++ b/arch/x86/crypto/sha512-avx2-asm.S
13520 @@ -51,6 +51,7 @@
13521
13522 #ifdef CONFIG_AS_AVX2
13523 #include <linux/linkage.h>
13524 +#include <asm/alternative-asm.h>
13525
13526 .text
13527
13528 @@ -678,6 +679,7 @@ done_hash:
13529
13530 # Restore Stack Pointer
13531 mov frame_RSPSAVE(%rsp), %rsp
13532 + pax_force_retaddr
13533 ret
13534 ENDPROC(sha512_transform_rorx)
13535
13536 diff --git a/arch/x86/crypto/sha512-ssse3-asm.S b/arch/x86/crypto/sha512-ssse3-asm.S
13537 index fb56855..6edd768 100644
13538 --- a/arch/x86/crypto/sha512-ssse3-asm.S
13539 +++ b/arch/x86/crypto/sha512-ssse3-asm.S
13540 @@ -48,6 +48,7 @@
13541 ########################################################################
13542
13543 #include <linux/linkage.h>
13544 +#include <asm/alternative-asm.h>
13545
13546 .text
13547
13548 @@ -363,6 +364,7 @@ updateblock:
13549 mov frame_RSPSAVE(%rsp), %rsp
13550
13551 nowork:
13552 + pax_force_retaddr
13553 ret
13554 ENDPROC(sha512_transform_ssse3)
13555
13556 diff --git a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13557 index 0505813..b067311 100644
13558 --- a/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13559 +++ b/arch/x86/crypto/twofish-avx-x86_64-asm_64.S
13560 @@ -24,6 +24,7 @@
13561 */
13562
13563 #include <linux/linkage.h>
13564 +#include <asm/alternative-asm.h>
13565 #include "glue_helper-asm-avx.S"
13566
13567 .file "twofish-avx-x86_64-asm_64.S"
13568 @@ -284,6 +285,7 @@ __twofish_enc_blk8:
13569 outunpack_blocks(RC1, RD1, RA1, RB1, RK1, RX0, RY0, RK2);
13570 outunpack_blocks(RC2, RD2, RA2, RB2, RK1, RX0, RY0, RK2);
13571
13572 + pax_force_retaddr
13573 ret;
13574 ENDPROC(__twofish_enc_blk8)
13575
13576 @@ -324,6 +326,7 @@ __twofish_dec_blk8:
13577 outunpack_blocks(RA1, RB1, RC1, RD1, RK1, RX0, RY0, RK2);
13578 outunpack_blocks(RA2, RB2, RC2, RD2, RK1, RX0, RY0, RK2);
13579
13580 + pax_force_retaddr
13581 ret;
13582 ENDPROC(__twofish_dec_blk8)
13583
13584 @@ -342,6 +345,7 @@ ENTRY(twofish_ecb_enc_8way)
13585
13586 store_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13587
13588 + pax_force_retaddr
13589 ret;
13590 ENDPROC(twofish_ecb_enc_8way)
13591
13592 @@ -360,6 +364,7 @@ ENTRY(twofish_ecb_dec_8way)
13593
13594 store_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13595
13596 + pax_force_retaddr
13597 ret;
13598 ENDPROC(twofish_ecb_dec_8way)
13599
13600 @@ -370,19 +375,20 @@ ENTRY(twofish_cbc_dec_8way)
13601 * %rdx: src
13602 */
13603
13604 - pushq %r12;
13605 + pushq %r14;
13606
13607 movq %rsi, %r11;
13608 - movq %rdx, %r12;
13609 + movq %rdx, %r14;
13610
13611 load_8way(%rdx, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13612
13613 call __twofish_dec_blk8;
13614
13615 - store_cbc_8way(%r12, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13616 + store_cbc_8way(%r14, %r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13617
13618 - popq %r12;
13619 + popq %r14;
13620
13621 + pax_force_retaddr
13622 ret;
13623 ENDPROC(twofish_cbc_dec_8way)
13624
13625 @@ -394,20 +400,21 @@ ENTRY(twofish_ctr_8way)
13626 * %rcx: iv (little endian, 128bit)
13627 */
13628
13629 - pushq %r12;
13630 + pushq %r14;
13631
13632 movq %rsi, %r11;
13633 - movq %rdx, %r12;
13634 + movq %rdx, %r14;
13635
13636 load_ctr_8way(%rcx, .Lbswap128_mask, RA1, RB1, RC1, RD1, RA2, RB2, RC2,
13637 RD2, RX0, RX1, RY0);
13638
13639 call __twofish_enc_blk8;
13640
13641 - store_ctr_8way(%r12, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13642 + store_ctr_8way(%r14, %r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13643
13644 - popq %r12;
13645 + popq %r14;
13646
13647 + pax_force_retaddr
13648 ret;
13649 ENDPROC(twofish_ctr_8way)
13650
13651 @@ -430,6 +437,7 @@ ENTRY(twofish_xts_enc_8way)
13652 /* dst <= regs xor IVs(in dst) */
13653 store_xts_8way(%r11, RC1, RD1, RA1, RB1, RC2, RD2, RA2, RB2);
13654
13655 + pax_force_retaddr
13656 ret;
13657 ENDPROC(twofish_xts_enc_8way)
13658
13659 @@ -452,5 +460,6 @@ ENTRY(twofish_xts_dec_8way)
13660 /* dst <= regs xor IVs(in dst) */
13661 store_xts_8way(%r11, RA1, RB1, RC1, RD1, RA2, RB2, RC2, RD2);
13662
13663 + pax_force_retaddr
13664 ret;
13665 ENDPROC(twofish_xts_dec_8way)
13666 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13667 index 1c3b7ce..02f578d 100644
13668 --- a/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13669 +++ b/arch/x86/crypto/twofish-x86_64-asm_64-3way.S
13670 @@ -21,6 +21,7 @@
13671 */
13672
13673 #include <linux/linkage.h>
13674 +#include <asm/alternative-asm.h>
13675
13676 .file "twofish-x86_64-asm-3way.S"
13677 .text
13678 @@ -258,6 +259,7 @@ ENTRY(__twofish_enc_blk_3way)
13679 popq %r13;
13680 popq %r14;
13681 popq %r15;
13682 + pax_force_retaddr
13683 ret;
13684
13685 .L__enc_xor3:
13686 @@ -269,6 +271,7 @@ ENTRY(__twofish_enc_blk_3way)
13687 popq %r13;
13688 popq %r14;
13689 popq %r15;
13690 + pax_force_retaddr
13691 ret;
13692 ENDPROC(__twofish_enc_blk_3way)
13693
13694 @@ -308,5 +311,6 @@ ENTRY(twofish_dec_blk_3way)
13695 popq %r13;
13696 popq %r14;
13697 popq %r15;
13698 + pax_force_retaddr
13699 ret;
13700 ENDPROC(twofish_dec_blk_3way)
13701 diff --git a/arch/x86/crypto/twofish-x86_64-asm_64.S b/arch/x86/crypto/twofish-x86_64-asm_64.S
13702 index a039d21..524b8b2 100644
13703 --- a/arch/x86/crypto/twofish-x86_64-asm_64.S
13704 +++ b/arch/x86/crypto/twofish-x86_64-asm_64.S
13705 @@ -22,6 +22,7 @@
13706
13707 #include <linux/linkage.h>
13708 #include <asm/asm-offsets.h>
13709 +#include <asm/alternative-asm.h>
13710
13711 #define a_offset 0
13712 #define b_offset 4
13713 @@ -265,6 +266,7 @@ ENTRY(twofish_enc_blk)
13714
13715 popq R1
13716 movq $1,%rax
13717 + pax_force_retaddr
13718 ret
13719 ENDPROC(twofish_enc_blk)
13720
13721 @@ -317,5 +319,6 @@ ENTRY(twofish_dec_blk)
13722
13723 popq R1
13724 movq $1,%rax
13725 + pax_force_retaddr
13726 ret
13727 ENDPROC(twofish_dec_blk)
13728 diff --git a/arch/x86/ia32/ia32_aout.c b/arch/x86/ia32/ia32_aout.c
13729 index bae3aba..c1788c1 100644
13730 --- a/arch/x86/ia32/ia32_aout.c
13731 +++ b/arch/x86/ia32/ia32_aout.c
13732 @@ -159,6 +159,8 @@ static int aout_core_dump(long signr, struct pt_regs *regs, struct file *file,
13733 unsigned long dump_start, dump_size;
13734 struct user32 dump;
13735
13736 + memset(&dump, 0, sizeof(dump));
13737 +
13738 fs = get_fs();
13739 set_fs(KERNEL_DS);
13740 has_dumped = 1;
13741 diff --git a/arch/x86/ia32/ia32_signal.c b/arch/x86/ia32/ia32_signal.c
13742 index 665a730..8e7a67a 100644
13743 --- a/arch/x86/ia32/ia32_signal.c
13744 +++ b/arch/x86/ia32/ia32_signal.c
13745 @@ -338,7 +338,7 @@ static void __user *get_sigframe(struct ksignal *ksig, struct pt_regs *regs,
13746 sp -= frame_size;
13747 /* Align the stack pointer according to the i386 ABI,
13748 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
13749 - sp = ((sp + 4) & -16ul) - 4;
13750 + sp = ((sp - 12) & -16ul) - 4;
13751 return (void __user *) sp;
13752 }
13753
13754 @@ -396,7 +396,7 @@ int ia32_setup_frame(int sig, struct ksignal *ksig,
13755 * These are actually not used anymore, but left because some
13756 * gdb versions depend on them as a marker.
13757 */
13758 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13759 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13760 } put_user_catch(err);
13761
13762 if (err)
13763 @@ -438,7 +438,7 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13764 0xb8,
13765 __NR_ia32_rt_sigreturn,
13766 0x80cd,
13767 - 0,
13768 + 0
13769 };
13770
13771 frame = get_sigframe(ksig, regs, sizeof(*frame), &fpstate);
13772 @@ -461,16 +461,18 @@ int ia32_setup_rt_frame(int sig, struct ksignal *ksig,
13773
13774 if (ksig->ka.sa.sa_flags & SA_RESTORER)
13775 restorer = ksig->ka.sa.sa_restorer;
13776 + else if (current->mm->context.vdso)
13777 + /* Return stub is in 32bit vsyscall page */
13778 + restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
13779 else
13780 - restorer = VDSO32_SYMBOL(current->mm->context.vdso,
13781 - rt_sigreturn);
13782 + restorer = &frame->retcode;
13783 put_user_ex(ptr_to_compat(restorer), &frame->pretcode);
13784
13785 /*
13786 * Not actually used anymore, but left because some gdb
13787 * versions need it.
13788 */
13789 - put_user_ex(*((u64 *)&code), (u64 __user *)frame->retcode);
13790 + put_user_ex(*((const u64 *)&code), (u64 __user *)frame->retcode);
13791 } put_user_catch(err);
13792
13793 err |= copy_siginfo_to_user32(&frame->info, &ksig->info);
13794 diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
13795 index 4299eb0..c0687a7 100644
13796 --- a/arch/x86/ia32/ia32entry.S
13797 +++ b/arch/x86/ia32/ia32entry.S
13798 @@ -15,8 +15,10 @@
13799 #include <asm/irqflags.h>
13800 #include <asm/asm.h>
13801 #include <asm/smap.h>
13802 +#include <asm/pgtable.h>
13803 #include <linux/linkage.h>
13804 #include <linux/err.h>
13805 +#include <asm/alternative-asm.h>
13806
13807 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
13808 #include <linux/elf-em.h>
13809 @@ -62,12 +64,12 @@
13810 */
13811 .macro LOAD_ARGS32 offset, _r9=0
13812 .if \_r9
13813 - movl \offset+16(%rsp),%r9d
13814 + movl \offset+R9(%rsp),%r9d
13815 .endif
13816 - movl \offset+40(%rsp),%ecx
13817 - movl \offset+48(%rsp),%edx
13818 - movl \offset+56(%rsp),%esi
13819 - movl \offset+64(%rsp),%edi
13820 + movl \offset+RCX(%rsp),%ecx
13821 + movl \offset+RDX(%rsp),%edx
13822 + movl \offset+RSI(%rsp),%esi
13823 + movl \offset+RDI(%rsp),%edi
13824 movl %eax,%eax /* zero extension */
13825 .endm
13826
13827 @@ -96,6 +98,32 @@ ENTRY(native_irq_enable_sysexit)
13828 ENDPROC(native_irq_enable_sysexit)
13829 #endif
13830
13831 + .macro pax_enter_kernel_user
13832 + pax_set_fptr_mask
13833 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13834 + call pax_enter_kernel_user
13835 +#endif
13836 + .endm
13837 +
13838 + .macro pax_exit_kernel_user
13839 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13840 + call pax_exit_kernel_user
13841 +#endif
13842 +#ifdef CONFIG_PAX_RANDKSTACK
13843 + pushq %rax
13844 + pushq %r11
13845 + call pax_randomize_kstack
13846 + popq %r11
13847 + popq %rax
13848 +#endif
13849 + .endm
13850 +
13851 + .macro pax_erase_kstack
13852 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
13853 + call pax_erase_kstack
13854 +#endif
13855 + .endm
13856 +
13857 /*
13858 * 32bit SYSENTER instruction entry.
13859 *
13860 @@ -122,12 +150,6 @@ ENTRY(ia32_sysenter_target)
13861 CFI_REGISTER rsp,rbp
13862 SWAPGS_UNSAFE_STACK
13863 movq PER_CPU_VAR(kernel_stack), %rsp
13864 - addq $(KERNEL_STACK_OFFSET),%rsp
13865 - /*
13866 - * No need to follow this irqs on/off section: the syscall
13867 - * disabled irqs, here we enable it straight after entry:
13868 - */
13869 - ENABLE_INTERRUPTS(CLBR_NONE)
13870 movl %ebp,%ebp /* zero extension */
13871 pushq_cfi $__USER32_DS
13872 /*CFI_REL_OFFSET ss,0*/
13873 @@ -135,24 +157,49 @@ ENTRY(ia32_sysenter_target)
13874 CFI_REL_OFFSET rsp,0
13875 pushfq_cfi
13876 /*CFI_REL_OFFSET rflags,0*/
13877 - movl TI_sysenter_return+THREAD_INFO(%rsp,3*8-KERNEL_STACK_OFFSET),%r10d
13878 - CFI_REGISTER rip,r10
13879 + orl $X86_EFLAGS_IF,(%rsp)
13880 + GET_THREAD_INFO(%r11)
13881 + movl TI_sysenter_return(%r11), %r11d
13882 + CFI_REGISTER rip,r11
13883 pushq_cfi $__USER32_CS
13884 /*CFI_REL_OFFSET cs,0*/
13885 movl %eax, %eax
13886 - pushq_cfi %r10
13887 + pushq_cfi %r11
13888 CFI_REL_OFFSET rip,0
13889 pushq_cfi %rax
13890 cld
13891 SAVE_ARGS 0,1,0
13892 + pax_enter_kernel_user
13893 +
13894 +#ifdef CONFIG_PAX_RANDKSTACK
13895 + pax_erase_kstack
13896 +#endif
13897 +
13898 + /*
13899 + * No need to follow this irqs on/off section: the syscall
13900 + * disabled irqs, here we enable it straight after entry:
13901 + */
13902 + ENABLE_INTERRUPTS(CLBR_NONE)
13903 /* no need to do an access_ok check here because rbp has been
13904 32bit zero extended */
13905 +
13906 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13907 + addq pax_user_shadow_base,%rbp
13908 + ASM_PAX_OPEN_USERLAND
13909 +#endif
13910 +
13911 ASM_STAC
13912 1: movl (%rbp),%ebp
13913 _ASM_EXTABLE(1b,ia32_badarg)
13914 ASM_CLAC
13915 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13916 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13917 +
13918 +#ifdef CONFIG_PAX_MEMORY_UDEREF
13919 + ASM_PAX_CLOSE_USERLAND
13920 +#endif
13921 +
13922 + GET_THREAD_INFO(%r11)
13923 + orl $TS_COMPAT,TI_status(%r11)
13924 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
13925 CFI_REMEMBER_STATE
13926 jnz sysenter_tracesys
13927 cmpq $(IA32_NR_syscalls-1),%rax
13928 @@ -162,15 +209,18 @@ sysenter_do_call:
13929 sysenter_dispatch:
13930 call *ia32_sys_call_table(,%rax,8)
13931 movq %rax,RAX-ARGOFFSET(%rsp)
13932 + GET_THREAD_INFO(%r11)
13933 DISABLE_INTERRUPTS(CLBR_NONE)
13934 TRACE_IRQS_OFF
13935 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13936 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
13937 jnz sysexit_audit
13938 sysexit_from_sys_call:
13939 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13940 + pax_exit_kernel_user
13941 + pax_erase_kstack
13942 + andl $~TS_COMPAT,TI_status(%r11)
13943 /* clear IF, that popfq doesn't enable interrupts early */
13944 - andl $~0x200,EFLAGS-R11(%rsp)
13945 - movl RIP-R11(%rsp),%edx /* User %eip */
13946 + andl $~X86_EFLAGS_IF,EFLAGS(%rsp)
13947 + movl RIP(%rsp),%edx /* User %eip */
13948 CFI_REGISTER rip,rdx
13949 RESTORE_ARGS 0,24,0,0,0,0
13950 xorq %r8,%r8
13951 @@ -193,6 +243,9 @@ sysexit_from_sys_call:
13952 movl %eax,%esi /* 2nd arg: syscall number */
13953 movl $AUDIT_ARCH_I386,%edi /* 1st arg: audit arch */
13954 call __audit_syscall_entry
13955 +
13956 + pax_erase_kstack
13957 +
13958 movl RAX-ARGOFFSET(%rsp),%eax /* reload syscall number */
13959 cmpq $(IA32_NR_syscalls-1),%rax
13960 ja ia32_badsys
13961 @@ -204,7 +257,7 @@ sysexit_from_sys_call:
13962 .endm
13963
13964 .macro auditsys_exit exit
13965 - testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13966 + testl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13967 jnz ia32_ret_from_sys_call
13968 TRACE_IRQS_ON
13969 ENABLE_INTERRUPTS(CLBR_NONE)
13970 @@ -215,11 +268,12 @@ sysexit_from_sys_call:
13971 1: setbe %al /* 1 if error, 0 if not */
13972 movzbl %al,%edi /* zero-extend that into %edi */
13973 call __audit_syscall_exit
13974 + GET_THREAD_INFO(%r11)
13975 movq RAX-ARGOFFSET(%rsp),%rax /* reload syscall return value */
13976 movl $(_TIF_ALLWORK_MASK & ~_TIF_SYSCALL_AUDIT),%edi
13977 DISABLE_INTERRUPTS(CLBR_NONE)
13978 TRACE_IRQS_OFF
13979 - testl %edi,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13980 + testl %edi,TI_flags(%r11)
13981 jz \exit
13982 CLEAR_RREGS -ARGOFFSET
13983 jmp int_with_check
13984 @@ -237,7 +291,7 @@ sysexit_audit:
13985
13986 sysenter_tracesys:
13987 #ifdef CONFIG_AUDITSYSCALL
13988 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
13989 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
13990 jz sysenter_auditsys
13991 #endif
13992 SAVE_REST
13993 @@ -249,6 +303,9 @@ sysenter_tracesys:
13994 RESTORE_REST
13995 cmpq $(IA32_NR_syscalls-1),%rax
13996 ja int_ret_from_sys_call /* sysenter_tracesys has set RAX(%rsp) */
13997 +
13998 + pax_erase_kstack
13999 +
14000 jmp sysenter_do_call
14001 CFI_ENDPROC
14002 ENDPROC(ia32_sysenter_target)
14003 @@ -276,19 +333,25 @@ ENDPROC(ia32_sysenter_target)
14004 ENTRY(ia32_cstar_target)
14005 CFI_STARTPROC32 simple
14006 CFI_SIGNAL_FRAME
14007 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
14008 + CFI_DEF_CFA rsp,0
14009 CFI_REGISTER rip,rcx
14010 /*CFI_REGISTER rflags,r11*/
14011 SWAPGS_UNSAFE_STACK
14012 movl %esp,%r8d
14013 CFI_REGISTER rsp,r8
14014 movq PER_CPU_VAR(kernel_stack),%rsp
14015 + SAVE_ARGS 8*6,0,0
14016 + pax_enter_kernel_user
14017 +
14018 +#ifdef CONFIG_PAX_RANDKSTACK
14019 + pax_erase_kstack
14020 +#endif
14021 +
14022 /*
14023 * No need to follow this irqs on/off section: the syscall
14024 * disabled irqs and here we enable it straight after entry:
14025 */
14026 ENABLE_INTERRUPTS(CLBR_NONE)
14027 - SAVE_ARGS 8,0,0
14028 movl %eax,%eax /* zero extension */
14029 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
14030 movq %rcx,RIP-ARGOFFSET(%rsp)
14031 @@ -304,12 +367,25 @@ ENTRY(ia32_cstar_target)
14032 /* no need to do an access_ok check here because r8 has been
14033 32bit zero extended */
14034 /* hardware stack frame is complete now */
14035 +
14036 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14037 + ASM_PAX_OPEN_USERLAND
14038 + movq pax_user_shadow_base,%r8
14039 + addq RSP-ARGOFFSET(%rsp),%r8
14040 +#endif
14041 +
14042 ASM_STAC
14043 1: movl (%r8),%r9d
14044 _ASM_EXTABLE(1b,ia32_badarg)
14045 ASM_CLAC
14046 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14047 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14048 +
14049 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14050 + ASM_PAX_CLOSE_USERLAND
14051 +#endif
14052 +
14053 + GET_THREAD_INFO(%r11)
14054 + orl $TS_COMPAT,TI_status(%r11)
14055 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14056 CFI_REMEMBER_STATE
14057 jnz cstar_tracesys
14058 cmpq $IA32_NR_syscalls-1,%rax
14059 @@ -319,13 +395,16 @@ cstar_do_call:
14060 cstar_dispatch:
14061 call *ia32_sys_call_table(,%rax,8)
14062 movq %rax,RAX-ARGOFFSET(%rsp)
14063 + GET_THREAD_INFO(%r11)
14064 DISABLE_INTERRUPTS(CLBR_NONE)
14065 TRACE_IRQS_OFF
14066 - testl $_TIF_ALLWORK_MASK,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14067 + testl $_TIF_ALLWORK_MASK,TI_flags(%r11)
14068 jnz sysretl_audit
14069 sysretl_from_sys_call:
14070 - andl $~TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14071 - RESTORE_ARGS 0,-ARG_SKIP,0,0,0
14072 + pax_exit_kernel_user
14073 + pax_erase_kstack
14074 + andl $~TS_COMPAT,TI_status(%r11)
14075 + RESTORE_ARGS 0,-ORIG_RAX,0,0,0
14076 movl RIP-ARGOFFSET(%rsp),%ecx
14077 CFI_REGISTER rip,rcx
14078 movl EFLAGS-ARGOFFSET(%rsp),%r11d
14079 @@ -352,7 +431,7 @@ sysretl_audit:
14080
14081 cstar_tracesys:
14082 #ifdef CONFIG_AUDITSYSCALL
14083 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14084 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%r11)
14085 jz cstar_auditsys
14086 #endif
14087 xchgl %r9d,%ebp
14088 @@ -366,11 +445,19 @@ cstar_tracesys:
14089 xchgl %ebp,%r9d
14090 cmpq $(IA32_NR_syscalls-1),%rax
14091 ja int_ret_from_sys_call /* cstar_tracesys has set RAX(%rsp) */
14092 +
14093 + pax_erase_kstack
14094 +
14095 jmp cstar_do_call
14096 END(ia32_cstar_target)
14097
14098 ia32_badarg:
14099 ASM_CLAC
14100 +
14101 +#ifdef CONFIG_PAX_MEMORY_UDEREF
14102 + ASM_PAX_CLOSE_USERLAND
14103 +#endif
14104 +
14105 movq $-EFAULT,%rax
14106 jmp ia32_sysret
14107 CFI_ENDPROC
14108 @@ -407,19 +494,26 @@ ENTRY(ia32_syscall)
14109 CFI_REL_OFFSET rip,RIP-RIP
14110 PARAVIRT_ADJUST_EXCEPTION_FRAME
14111 SWAPGS
14112 - /*
14113 - * No need to follow this irqs on/off section: the syscall
14114 - * disabled irqs and here we enable it straight after entry:
14115 - */
14116 - ENABLE_INTERRUPTS(CLBR_NONE)
14117 movl %eax,%eax
14118 pushq_cfi %rax
14119 cld
14120 /* note the registers are not zero extended to the sf.
14121 this could be a problem. */
14122 SAVE_ARGS 0,1,0
14123 - orl $TS_COMPAT,TI_status+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14124 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
14125 + pax_enter_kernel_user
14126 +
14127 +#ifdef CONFIG_PAX_RANDKSTACK
14128 + pax_erase_kstack
14129 +#endif
14130 +
14131 + /*
14132 + * No need to follow this irqs on/off section: the syscall
14133 + * disabled irqs and here we enable it straight after entry:
14134 + */
14135 + ENABLE_INTERRUPTS(CLBR_NONE)
14136 + GET_THREAD_INFO(%r11)
14137 + orl $TS_COMPAT,TI_status(%r11)
14138 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%r11)
14139 jnz ia32_tracesys
14140 cmpq $(IA32_NR_syscalls-1),%rax
14141 ja ia32_badsys
14142 @@ -442,6 +536,9 @@ ia32_tracesys:
14143 RESTORE_REST
14144 cmpq $(IA32_NR_syscalls-1),%rax
14145 ja int_ret_from_sys_call /* ia32_tracesys has set RAX(%rsp) */
14146 +
14147 + pax_erase_kstack
14148 +
14149 jmp ia32_do_call
14150 END(ia32_syscall)
14151
14152 diff --git a/arch/x86/ia32/sys_ia32.c b/arch/x86/ia32/sys_ia32.c
14153 index 8e0ceec..af13504 100644
14154 --- a/arch/x86/ia32/sys_ia32.c
14155 +++ b/arch/x86/ia32/sys_ia32.c
14156 @@ -69,8 +69,8 @@ asmlinkage long sys32_ftruncate64(unsigned int fd, unsigned long offset_low,
14157 */
14158 static int cp_stat64(struct stat64 __user *ubuf, struct kstat *stat)
14159 {
14160 - typeof(ubuf->st_uid) uid = 0;
14161 - typeof(ubuf->st_gid) gid = 0;
14162 + typeof(((struct stat64 *)0)->st_uid) uid = 0;
14163 + typeof(((struct stat64 *)0)->st_gid) gid = 0;
14164 SET_UID(uid, from_kuid_munged(current_user_ns(), stat->uid));
14165 SET_GID(gid, from_kgid_munged(current_user_ns(), stat->gid));
14166 if (!access_ok(VERIFY_WRITE, ubuf, sizeof(struct stat64)) ||
14167 diff --git a/arch/x86/include/asm/alternative-asm.h b/arch/x86/include/asm/alternative-asm.h
14168 index 372231c..51b537d 100644
14169 --- a/arch/x86/include/asm/alternative-asm.h
14170 +++ b/arch/x86/include/asm/alternative-asm.h
14171 @@ -18,6 +18,45 @@
14172 .endm
14173 #endif
14174
14175 +#ifdef KERNEXEC_PLUGIN
14176 + .macro pax_force_retaddr_bts rip=0
14177 + btsq $63,\rip(%rsp)
14178 + .endm
14179 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
14180 + .macro pax_force_retaddr rip=0, reload=0
14181 + btsq $63,\rip(%rsp)
14182 + .endm
14183 + .macro pax_force_fptr ptr
14184 + btsq $63,\ptr
14185 + .endm
14186 + .macro pax_set_fptr_mask
14187 + .endm
14188 +#endif
14189 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
14190 + .macro pax_force_retaddr rip=0, reload=0
14191 + .if \reload
14192 + pax_set_fptr_mask
14193 + .endif
14194 + orq %r12,\rip(%rsp)
14195 + .endm
14196 + .macro pax_force_fptr ptr
14197 + orq %r12,\ptr
14198 + .endm
14199 + .macro pax_set_fptr_mask
14200 + movabs $0x8000000000000000,%r12
14201 + .endm
14202 +#endif
14203 +#else
14204 + .macro pax_force_retaddr rip=0, reload=0
14205 + .endm
14206 + .macro pax_force_fptr ptr
14207 + .endm
14208 + .macro pax_force_retaddr_bts rip=0
14209 + .endm
14210 + .macro pax_set_fptr_mask
14211 + .endm
14212 +#endif
14213 +
14214 .macro altinstruction_entry orig alt feature orig_len alt_len
14215 .long \orig - .
14216 .long \alt - .
14217 diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
14218 index 0a3f9c9..c9d081d 100644
14219 --- a/arch/x86/include/asm/alternative.h
14220 +++ b/arch/x86/include/asm/alternative.h
14221 @@ -106,7 +106,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14222 ".pushsection .discard,\"aw\",@progbits\n" \
14223 DISCARD_ENTRY(1) \
14224 ".popsection\n" \
14225 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14226 + ".pushsection .altinstr_replacement, \"a\"\n" \
14227 ALTINSTR_REPLACEMENT(newinstr, feature, 1) \
14228 ".popsection"
14229
14230 @@ -120,7 +120,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
14231 DISCARD_ENTRY(1) \
14232 DISCARD_ENTRY(2) \
14233 ".popsection\n" \
14234 - ".pushsection .altinstr_replacement, \"ax\"\n" \
14235 + ".pushsection .altinstr_replacement, \"a\"\n" \
14236 ALTINSTR_REPLACEMENT(newinstr1, feature1, 1) \
14237 ALTINSTR_REPLACEMENT(newinstr2, feature2, 2) \
14238 ".popsection"
14239 diff --git a/arch/x86/include/asm/apic.h b/arch/x86/include/asm/apic.h
14240 index 1d2091a..f5074c1 100644
14241 --- a/arch/x86/include/asm/apic.h
14242 +++ b/arch/x86/include/asm/apic.h
14243 @@ -45,7 +45,7 @@ static inline void generic_apic_probe(void)
14244
14245 #ifdef CONFIG_X86_LOCAL_APIC
14246
14247 -extern unsigned int apic_verbosity;
14248 +extern int apic_verbosity;
14249 extern int local_apic_timer_c2_ok;
14250
14251 extern int disable_apic;
14252 diff --git a/arch/x86/include/asm/apm.h b/arch/x86/include/asm/apm.h
14253 index 20370c6..a2eb9b0 100644
14254 --- a/arch/x86/include/asm/apm.h
14255 +++ b/arch/x86/include/asm/apm.h
14256 @@ -34,7 +34,7 @@ static inline void apm_bios_call_asm(u32 func, u32 ebx_in, u32 ecx_in,
14257 __asm__ __volatile__(APM_DO_ZERO_SEGS
14258 "pushl %%edi\n\t"
14259 "pushl %%ebp\n\t"
14260 - "lcall *%%cs:apm_bios_entry\n\t"
14261 + "lcall *%%ss:apm_bios_entry\n\t"
14262 "setc %%al\n\t"
14263 "popl %%ebp\n\t"
14264 "popl %%edi\n\t"
14265 @@ -58,7 +58,7 @@ static inline u8 apm_bios_call_simple_asm(u32 func, u32 ebx_in,
14266 __asm__ __volatile__(APM_DO_ZERO_SEGS
14267 "pushl %%edi\n\t"
14268 "pushl %%ebp\n\t"
14269 - "lcall *%%cs:apm_bios_entry\n\t"
14270 + "lcall *%%ss:apm_bios_entry\n\t"
14271 "setc %%bl\n\t"
14272 "popl %%ebp\n\t"
14273 "popl %%edi\n\t"
14274 diff --git a/arch/x86/include/asm/atomic.h b/arch/x86/include/asm/atomic.h
14275 index 722aa3b..c392d85 100644
14276 --- a/arch/x86/include/asm/atomic.h
14277 +++ b/arch/x86/include/asm/atomic.h
14278 @@ -22,7 +22,18 @@
14279 */
14280 static inline int atomic_read(const atomic_t *v)
14281 {
14282 - return (*(volatile int *)&(v)->counter);
14283 + return (*(volatile const int *)&(v)->counter);
14284 +}
14285 +
14286 +/**
14287 + * atomic_read_unchecked - read atomic variable
14288 + * @v: pointer of type atomic_unchecked_t
14289 + *
14290 + * Atomically reads the value of @v.
14291 + */
14292 +static inline int __intentional_overflow(-1) atomic_read_unchecked(const atomic_unchecked_t *v)
14293 +{
14294 + return (*(volatile const int *)&(v)->counter);
14295 }
14296
14297 /**
14298 @@ -38,6 +49,18 @@ static inline void atomic_set(atomic_t *v, int i)
14299 }
14300
14301 /**
14302 + * atomic_set_unchecked - set atomic variable
14303 + * @v: pointer of type atomic_unchecked_t
14304 + * @i: required value
14305 + *
14306 + * Atomically sets the value of @v to @i.
14307 + */
14308 +static inline void atomic_set_unchecked(atomic_unchecked_t *v, int i)
14309 +{
14310 + v->counter = i;
14311 +}
14312 +
14313 +/**
14314 * atomic_add - add integer to atomic variable
14315 * @i: integer value to add
14316 * @v: pointer of type atomic_t
14317 @@ -46,7 +69,29 @@ static inline void atomic_set(atomic_t *v, int i)
14318 */
14319 static inline void atomic_add(int i, atomic_t *v)
14320 {
14321 - asm volatile(LOCK_PREFIX "addl %1,%0"
14322 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14323 +
14324 +#ifdef CONFIG_PAX_REFCOUNT
14325 + "jno 0f\n"
14326 + LOCK_PREFIX "subl %1,%0\n"
14327 + "int $4\n0:\n"
14328 + _ASM_EXTABLE(0b, 0b)
14329 +#endif
14330 +
14331 + : "+m" (v->counter)
14332 + : "ir" (i));
14333 +}
14334 +
14335 +/**
14336 + * atomic_add_unchecked - add integer to atomic variable
14337 + * @i: integer value to add
14338 + * @v: pointer of type atomic_unchecked_t
14339 + *
14340 + * Atomically adds @i to @v.
14341 + */
14342 +static inline void atomic_add_unchecked(int i, atomic_unchecked_t *v)
14343 +{
14344 + asm volatile(LOCK_PREFIX "addl %1,%0\n"
14345 : "+m" (v->counter)
14346 : "ir" (i));
14347 }
14348 @@ -60,7 +105,29 @@ static inline void atomic_add(int i, atomic_t *v)
14349 */
14350 static inline void atomic_sub(int i, atomic_t *v)
14351 {
14352 - asm volatile(LOCK_PREFIX "subl %1,%0"
14353 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14354 +
14355 +#ifdef CONFIG_PAX_REFCOUNT
14356 + "jno 0f\n"
14357 + LOCK_PREFIX "addl %1,%0\n"
14358 + "int $4\n0:\n"
14359 + _ASM_EXTABLE(0b, 0b)
14360 +#endif
14361 +
14362 + : "+m" (v->counter)
14363 + : "ir" (i));
14364 +}
14365 +
14366 +/**
14367 + * atomic_sub_unchecked - subtract integer from atomic variable
14368 + * @i: integer value to subtract
14369 + * @v: pointer of type atomic_unchecked_t
14370 + *
14371 + * Atomically subtracts @i from @v.
14372 + */
14373 +static inline void atomic_sub_unchecked(int i, atomic_unchecked_t *v)
14374 +{
14375 + asm volatile(LOCK_PREFIX "subl %1,%0\n"
14376 : "+m" (v->counter)
14377 : "ir" (i));
14378 }
14379 @@ -78,7 +145,16 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14380 {
14381 unsigned char c;
14382
14383 - asm volatile(LOCK_PREFIX "subl %2,%0; sete %1"
14384 + asm volatile(LOCK_PREFIX "subl %2,%0\n"
14385 +
14386 +#ifdef CONFIG_PAX_REFCOUNT
14387 + "jno 0f\n"
14388 + LOCK_PREFIX "addl %2,%0\n"
14389 + "int $4\n0:\n"
14390 + _ASM_EXTABLE(0b, 0b)
14391 +#endif
14392 +
14393 + "sete %1\n"
14394 : "+m" (v->counter), "=qm" (c)
14395 : "ir" (i) : "memory");
14396 return c;
14397 @@ -92,7 +168,27 @@ static inline int atomic_sub_and_test(int i, atomic_t *v)
14398 */
14399 static inline void atomic_inc(atomic_t *v)
14400 {
14401 - asm volatile(LOCK_PREFIX "incl %0"
14402 + asm volatile(LOCK_PREFIX "incl %0\n"
14403 +
14404 +#ifdef CONFIG_PAX_REFCOUNT
14405 + "jno 0f\n"
14406 + LOCK_PREFIX "decl %0\n"
14407 + "int $4\n0:\n"
14408 + _ASM_EXTABLE(0b, 0b)
14409 +#endif
14410 +
14411 + : "+m" (v->counter));
14412 +}
14413 +
14414 +/**
14415 + * atomic_inc_unchecked - increment atomic variable
14416 + * @v: pointer of type atomic_unchecked_t
14417 + *
14418 + * Atomically increments @v by 1.
14419 + */
14420 +static inline void atomic_inc_unchecked(atomic_unchecked_t *v)
14421 +{
14422 + asm volatile(LOCK_PREFIX "incl %0\n"
14423 : "+m" (v->counter));
14424 }
14425
14426 @@ -104,7 +200,27 @@ static inline void atomic_inc(atomic_t *v)
14427 */
14428 static inline void atomic_dec(atomic_t *v)
14429 {
14430 - asm volatile(LOCK_PREFIX "decl %0"
14431 + asm volatile(LOCK_PREFIX "decl %0\n"
14432 +
14433 +#ifdef CONFIG_PAX_REFCOUNT
14434 + "jno 0f\n"
14435 + LOCK_PREFIX "incl %0\n"
14436 + "int $4\n0:\n"
14437 + _ASM_EXTABLE(0b, 0b)
14438 +#endif
14439 +
14440 + : "+m" (v->counter));
14441 +}
14442 +
14443 +/**
14444 + * atomic_dec_unchecked - decrement atomic variable
14445 + * @v: pointer of type atomic_unchecked_t
14446 + *
14447 + * Atomically decrements @v by 1.
14448 + */
14449 +static inline void atomic_dec_unchecked(atomic_unchecked_t *v)
14450 +{
14451 + asm volatile(LOCK_PREFIX "decl %0\n"
14452 : "+m" (v->counter));
14453 }
14454
14455 @@ -120,7 +236,16 @@ static inline int atomic_dec_and_test(atomic_t *v)
14456 {
14457 unsigned char c;
14458
14459 - asm volatile(LOCK_PREFIX "decl %0; sete %1"
14460 + asm volatile(LOCK_PREFIX "decl %0\n"
14461 +
14462 +#ifdef CONFIG_PAX_REFCOUNT
14463 + "jno 0f\n"
14464 + LOCK_PREFIX "incl %0\n"
14465 + "int $4\n0:\n"
14466 + _ASM_EXTABLE(0b, 0b)
14467 +#endif
14468 +
14469 + "sete %1\n"
14470 : "+m" (v->counter), "=qm" (c)
14471 : : "memory");
14472 return c != 0;
14473 @@ -138,7 +263,35 @@ static inline int atomic_inc_and_test(atomic_t *v)
14474 {
14475 unsigned char c;
14476
14477 - asm volatile(LOCK_PREFIX "incl %0; sete %1"
14478 + asm volatile(LOCK_PREFIX "incl %0\n"
14479 +
14480 +#ifdef CONFIG_PAX_REFCOUNT
14481 + "jno 0f\n"
14482 + LOCK_PREFIX "decl %0\n"
14483 + "int $4\n0:\n"
14484 + _ASM_EXTABLE(0b, 0b)
14485 +#endif
14486 +
14487 + "sete %1\n"
14488 + : "+m" (v->counter), "=qm" (c)
14489 + : : "memory");
14490 + return c != 0;
14491 +}
14492 +
14493 +/**
14494 + * atomic_inc_and_test_unchecked - increment and test
14495 + * @v: pointer of type atomic_unchecked_t
14496 + *
14497 + * Atomically increments @v by 1
14498 + * and returns true if the result is zero, or false for all
14499 + * other cases.
14500 + */
14501 +static inline int atomic_inc_and_test_unchecked(atomic_unchecked_t *v)
14502 +{
14503 + unsigned char c;
14504 +
14505 + asm volatile(LOCK_PREFIX "incl %0\n"
14506 + "sete %1\n"
14507 : "+m" (v->counter), "=qm" (c)
14508 : : "memory");
14509 return c != 0;
14510 @@ -157,7 +310,16 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14511 {
14512 unsigned char c;
14513
14514 - asm volatile(LOCK_PREFIX "addl %2,%0; sets %1"
14515 + asm volatile(LOCK_PREFIX "addl %2,%0\n"
14516 +
14517 +#ifdef CONFIG_PAX_REFCOUNT
14518 + "jno 0f\n"
14519 + LOCK_PREFIX "subl %2,%0\n"
14520 + "int $4\n0:\n"
14521 + _ASM_EXTABLE(0b, 0b)
14522 +#endif
14523 +
14524 + "sets %1\n"
14525 : "+m" (v->counter), "=qm" (c)
14526 : "ir" (i) : "memory");
14527 return c;
14528 @@ -172,6 +334,18 @@ static inline int atomic_add_negative(int i, atomic_t *v)
14529 */
14530 static inline int atomic_add_return(int i, atomic_t *v)
14531 {
14532 + return i + xadd_check_overflow(&v->counter, i);
14533 +}
14534 +
14535 +/**
14536 + * atomic_add_return_unchecked - add integer and return
14537 + * @i: integer value to add
14538 + * @v: pointer of type atomic_unchecked_t
14539 + *
14540 + * Atomically adds @i to @v and returns @i + @v
14541 + */
14542 +static inline int atomic_add_return_unchecked(int i, atomic_unchecked_t *v)
14543 +{
14544 return i + xadd(&v->counter, i);
14545 }
14546
14547 @@ -188,9 +362,18 @@ static inline int atomic_sub_return(int i, atomic_t *v)
14548 }
14549
14550 #define atomic_inc_return(v) (atomic_add_return(1, v))
14551 +static inline int atomic_inc_return_unchecked(atomic_unchecked_t *v)
14552 +{
14553 + return atomic_add_return_unchecked(1, v);
14554 +}
14555 #define atomic_dec_return(v) (atomic_sub_return(1, v))
14556
14557 -static inline int atomic_cmpxchg(atomic_t *v, int old, int new)
14558 +static inline int __intentional_overflow(-1) atomic_cmpxchg(atomic_t *v, int old, int new)
14559 +{
14560 + return cmpxchg(&v->counter, old, new);
14561 +}
14562 +
14563 +static inline int atomic_cmpxchg_unchecked(atomic_unchecked_t *v, int old, int new)
14564 {
14565 return cmpxchg(&v->counter, old, new);
14566 }
14567 @@ -200,6 +383,11 @@ static inline int atomic_xchg(atomic_t *v, int new)
14568 return xchg(&v->counter, new);
14569 }
14570
14571 +static inline int atomic_xchg_unchecked(atomic_unchecked_t *v, int new)
14572 +{
14573 + return xchg(&v->counter, new);
14574 +}
14575 +
14576 /**
14577 * __atomic_add_unless - add unless the number is already a given value
14578 * @v: pointer of type atomic_t
14579 @@ -209,14 +397,27 @@ static inline int atomic_xchg(atomic_t *v, int new)
14580 * Atomically adds @a to @v, so long as @v was not already @u.
14581 * Returns the old value of @v.
14582 */
14583 -static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14584 +static inline int __intentional_overflow(-1) __atomic_add_unless(atomic_t *v, int a, int u)
14585 {
14586 - int c, old;
14587 + int c, old, new;
14588 c = atomic_read(v);
14589 for (;;) {
14590 - if (unlikely(c == (u)))
14591 + if (unlikely(c == u))
14592 break;
14593 - old = atomic_cmpxchg((v), c, c + (a));
14594 +
14595 + asm volatile("addl %2,%0\n"
14596 +
14597 +#ifdef CONFIG_PAX_REFCOUNT
14598 + "jno 0f\n"
14599 + "subl %2,%0\n"
14600 + "int $4\n0:\n"
14601 + _ASM_EXTABLE(0b, 0b)
14602 +#endif
14603 +
14604 + : "=r" (new)
14605 + : "0" (c), "ir" (a));
14606 +
14607 + old = atomic_cmpxchg(v, c, new);
14608 if (likely(old == c))
14609 break;
14610 c = old;
14611 @@ -225,6 +426,49 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
14612 }
14613
14614 /**
14615 + * atomic_inc_not_zero_hint - increment if not null
14616 + * @v: pointer of type atomic_t
14617 + * @hint: probable value of the atomic before the increment
14618 + *
14619 + * This version of atomic_inc_not_zero() gives a hint of probable
14620 + * value of the atomic. This helps processor to not read the memory
14621 + * before doing the atomic read/modify/write cycle, lowering
14622 + * number of bus transactions on some arches.
14623 + *
14624 + * Returns: 0 if increment was not done, 1 otherwise.
14625 + */
14626 +#define atomic_inc_not_zero_hint atomic_inc_not_zero_hint
14627 +static inline int atomic_inc_not_zero_hint(atomic_t *v, int hint)
14628 +{
14629 + int val, c = hint, new;
14630 +
14631 + /* sanity test, should be removed by compiler if hint is a constant */
14632 + if (!hint)
14633 + return __atomic_add_unless(v, 1, 0);
14634 +
14635 + do {
14636 + asm volatile("incl %0\n"
14637 +
14638 +#ifdef CONFIG_PAX_REFCOUNT
14639 + "jno 0f\n"
14640 + "decl %0\n"
14641 + "int $4\n0:\n"
14642 + _ASM_EXTABLE(0b, 0b)
14643 +#endif
14644 +
14645 + : "=r" (new)
14646 + : "0" (c));
14647 +
14648 + val = atomic_cmpxchg(v, c, new);
14649 + if (val == c)
14650 + return 1;
14651 + c = val;
14652 + } while (c);
14653 +
14654 + return 0;
14655 +}
14656 +
14657 +/**
14658 * atomic_inc_short - increment of a short integer
14659 * @v: pointer to type int
14660 *
14661 @@ -253,14 +497,37 @@ static inline void atomic_or_long(unsigned long *v1, unsigned long v2)
14662 #endif
14663
14664 /* These are x86-specific, used by some header files */
14665 -#define atomic_clear_mask(mask, addr) \
14666 - asm volatile(LOCK_PREFIX "andl %0,%1" \
14667 - : : "r" (~(mask)), "m" (*(addr)) : "memory")
14668 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
14669 +{
14670 + asm volatile(LOCK_PREFIX "andl %1,%0"
14671 + : "+m" (v->counter)
14672 + : "r" (~(mask))
14673 + : "memory");
14674 +}
14675
14676 -#define atomic_set_mask(mask, addr) \
14677 - asm volatile(LOCK_PREFIX "orl %0,%1" \
14678 - : : "r" ((unsigned)(mask)), "m" (*(addr)) \
14679 - : "memory")
14680 +static inline void atomic_clear_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14681 +{
14682 + asm volatile(LOCK_PREFIX "andl %1,%0"
14683 + : "+m" (v->counter)
14684 + : "r" (~(mask))
14685 + : "memory");
14686 +}
14687 +
14688 +static inline void atomic_set_mask(unsigned int mask, atomic_t *v)
14689 +{
14690 + asm volatile(LOCK_PREFIX "orl %1,%0"
14691 + : "+m" (v->counter)
14692 + : "r" (mask)
14693 + : "memory");
14694 +}
14695 +
14696 +static inline void atomic_set_mask_unchecked(unsigned int mask, atomic_unchecked_t *v)
14697 +{
14698 + asm volatile(LOCK_PREFIX "orl %1,%0"
14699 + : "+m" (v->counter)
14700 + : "r" (mask)
14701 + : "memory");
14702 +}
14703
14704 /* Atomic operations are already serializing on x86 */
14705 #define smp_mb__before_atomic_dec() barrier()
14706 diff --git a/arch/x86/include/asm/atomic64_32.h b/arch/x86/include/asm/atomic64_32.h
14707 index b154de7..bf18a5a 100644
14708 --- a/arch/x86/include/asm/atomic64_32.h
14709 +++ b/arch/x86/include/asm/atomic64_32.h
14710 @@ -12,6 +12,14 @@ typedef struct {
14711 u64 __aligned(8) counter;
14712 } atomic64_t;
14713
14714 +#ifdef CONFIG_PAX_REFCOUNT
14715 +typedef struct {
14716 + u64 __aligned(8) counter;
14717 +} atomic64_unchecked_t;
14718 +#else
14719 +typedef atomic64_t atomic64_unchecked_t;
14720 +#endif
14721 +
14722 #define ATOMIC64_INIT(val) { (val) }
14723
14724 #define __ATOMIC64_DECL(sym) void atomic64_##sym(atomic64_t *, ...)
14725 @@ -37,21 +45,31 @@ typedef struct {
14726 ATOMIC64_DECL_ONE(sym##_386)
14727
14728 ATOMIC64_DECL_ONE(add_386);
14729 +ATOMIC64_DECL_ONE(add_unchecked_386);
14730 ATOMIC64_DECL_ONE(sub_386);
14731 +ATOMIC64_DECL_ONE(sub_unchecked_386);
14732 ATOMIC64_DECL_ONE(inc_386);
14733 +ATOMIC64_DECL_ONE(inc_unchecked_386);
14734 ATOMIC64_DECL_ONE(dec_386);
14735 +ATOMIC64_DECL_ONE(dec_unchecked_386);
14736 #endif
14737
14738 #define alternative_atomic64(f, out, in...) \
14739 __alternative_atomic64(f, f, ASM_OUTPUT2(out), ## in)
14740
14741 ATOMIC64_DECL(read);
14742 +ATOMIC64_DECL(read_unchecked);
14743 ATOMIC64_DECL(set);
14744 +ATOMIC64_DECL(set_unchecked);
14745 ATOMIC64_DECL(xchg);
14746 ATOMIC64_DECL(add_return);
14747 +ATOMIC64_DECL(add_return_unchecked);
14748 ATOMIC64_DECL(sub_return);
14749 +ATOMIC64_DECL(sub_return_unchecked);
14750 ATOMIC64_DECL(inc_return);
14751 +ATOMIC64_DECL(inc_return_unchecked);
14752 ATOMIC64_DECL(dec_return);
14753 +ATOMIC64_DECL(dec_return_unchecked);
14754 ATOMIC64_DECL(dec_if_positive);
14755 ATOMIC64_DECL(inc_not_zero);
14756 ATOMIC64_DECL(add_unless);
14757 @@ -77,6 +95,21 @@ static inline long long atomic64_cmpxchg(atomic64_t *v, long long o, long long n
14758 }
14759
14760 /**
14761 + * atomic64_cmpxchg_unchecked - cmpxchg atomic64 variable
14762 + * @p: pointer to type atomic64_unchecked_t
14763 + * @o: expected value
14764 + * @n: new value
14765 + *
14766 + * Atomically sets @v to @n if it was equal to @o and returns
14767 + * the old value.
14768 + */
14769 +
14770 +static inline long long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long long o, long long n)
14771 +{
14772 + return cmpxchg64(&v->counter, o, n);
14773 +}
14774 +
14775 +/**
14776 * atomic64_xchg - xchg atomic64 variable
14777 * @v: pointer to type atomic64_t
14778 * @n: value to assign
14779 @@ -112,6 +145,22 @@ static inline void atomic64_set(atomic64_t *v, long long i)
14780 }
14781
14782 /**
14783 + * atomic64_set_unchecked - set atomic64 variable
14784 + * @v: pointer to type atomic64_unchecked_t
14785 + * @n: value to assign
14786 + *
14787 + * Atomically sets the value of @v to @n.
14788 + */
14789 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long long i)
14790 +{
14791 + unsigned high = (unsigned)(i >> 32);
14792 + unsigned low = (unsigned)i;
14793 + alternative_atomic64(set, /* no output */,
14794 + "S" (v), "b" (low), "c" (high)
14795 + : "eax", "edx", "memory");
14796 +}
14797 +
14798 +/**
14799 * atomic64_read - read atomic64 variable
14800 * @v: pointer to type atomic64_t
14801 *
14802 @@ -125,6 +174,19 @@ static inline long long atomic64_read(const atomic64_t *v)
14803 }
14804
14805 /**
14806 + * atomic64_read_unchecked - read atomic64 variable
14807 + * @v: pointer to type atomic64_unchecked_t
14808 + *
14809 + * Atomically reads the value of @v and returns it.
14810 + */
14811 +static inline long long __intentional_overflow(-1) atomic64_read_unchecked(atomic64_unchecked_t *v)
14812 +{
14813 + long long r;
14814 + alternative_atomic64(read, "=&A" (r), "c" (v) : "memory");
14815 + return r;
14816 + }
14817 +
14818 +/**
14819 * atomic64_add_return - add and return
14820 * @i: integer value to add
14821 * @v: pointer to type atomic64_t
14822 @@ -139,6 +201,21 @@ static inline long long atomic64_add_return(long long i, atomic64_t *v)
14823 return i;
14824 }
14825
14826 +/**
14827 + * atomic64_add_return_unchecked - add and return
14828 + * @i: integer value to add
14829 + * @v: pointer to type atomic64_unchecked_t
14830 + *
14831 + * Atomically adds @i to @v and returns @i + *@v
14832 + */
14833 +static inline long long atomic64_add_return_unchecked(long long i, atomic64_unchecked_t *v)
14834 +{
14835 + alternative_atomic64(add_return_unchecked,
14836 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14837 + ASM_NO_INPUT_CLOBBER("memory"));
14838 + return i;
14839 +}
14840 +
14841 /*
14842 * Other variants with different arithmetic operators:
14843 */
14844 @@ -158,6 +235,14 @@ static inline long long atomic64_inc_return(atomic64_t *v)
14845 return a;
14846 }
14847
14848 +static inline long long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
14849 +{
14850 + long long a;
14851 + alternative_atomic64(inc_return_unchecked, "=&A" (a),
14852 + "S" (v) : "memory", "ecx");
14853 + return a;
14854 +}
14855 +
14856 static inline long long atomic64_dec_return(atomic64_t *v)
14857 {
14858 long long a;
14859 @@ -182,6 +267,21 @@ static inline long long atomic64_add(long long i, atomic64_t *v)
14860 }
14861
14862 /**
14863 + * atomic64_add_unchecked - add integer to atomic64 variable
14864 + * @i: integer value to add
14865 + * @v: pointer to type atomic64_unchecked_t
14866 + *
14867 + * Atomically adds @i to @v.
14868 + */
14869 +static inline long long atomic64_add_unchecked(long long i, atomic64_unchecked_t *v)
14870 +{
14871 + __alternative_atomic64(add_unchecked, add_return_unchecked,
14872 + ASM_OUTPUT2("+A" (i), "+c" (v)),
14873 + ASM_NO_INPUT_CLOBBER("memory"));
14874 + return i;
14875 +}
14876 +
14877 +/**
14878 * atomic64_sub - subtract the atomic64 variable
14879 * @i: integer value to subtract
14880 * @v: pointer to type atomic64_t
14881 diff --git a/arch/x86/include/asm/atomic64_64.h b/arch/x86/include/asm/atomic64_64.h
14882 index 0e1cbfc..a891fc7 100644
14883 --- a/arch/x86/include/asm/atomic64_64.h
14884 +++ b/arch/x86/include/asm/atomic64_64.h
14885 @@ -18,7 +18,19 @@
14886 */
14887 static inline long atomic64_read(const atomic64_t *v)
14888 {
14889 - return (*(volatile long *)&(v)->counter);
14890 + return (*(volatile const long *)&(v)->counter);
14891 +}
14892 +
14893 +/**
14894 + * atomic64_read_unchecked - read atomic64 variable
14895 + * @v: pointer of type atomic64_unchecked_t
14896 + *
14897 + * Atomically reads the value of @v.
14898 + * Doesn't imply a read memory barrier.
14899 + */
14900 +static inline long __intentional_overflow(-1) atomic64_read_unchecked(const atomic64_unchecked_t *v)
14901 +{
14902 + return (*(volatile const long *)&(v)->counter);
14903 }
14904
14905 /**
14906 @@ -34,6 +46,18 @@ static inline void atomic64_set(atomic64_t *v, long i)
14907 }
14908
14909 /**
14910 + * atomic64_set_unchecked - set atomic64 variable
14911 + * @v: pointer to type atomic64_unchecked_t
14912 + * @i: required value
14913 + *
14914 + * Atomically sets the value of @v to @i.
14915 + */
14916 +static inline void atomic64_set_unchecked(atomic64_unchecked_t *v, long i)
14917 +{
14918 + v->counter = i;
14919 +}
14920 +
14921 +/**
14922 * atomic64_add - add integer to atomic64 variable
14923 * @i: integer value to add
14924 * @v: pointer to type atomic64_t
14925 @@ -42,6 +66,28 @@ static inline void atomic64_set(atomic64_t *v, long i)
14926 */
14927 static inline void atomic64_add(long i, atomic64_t *v)
14928 {
14929 + asm volatile(LOCK_PREFIX "addq %1,%0\n"
14930 +
14931 +#ifdef CONFIG_PAX_REFCOUNT
14932 + "jno 0f\n"
14933 + LOCK_PREFIX "subq %1,%0\n"
14934 + "int $4\n0:\n"
14935 + _ASM_EXTABLE(0b, 0b)
14936 +#endif
14937 +
14938 + : "=m" (v->counter)
14939 + : "er" (i), "m" (v->counter));
14940 +}
14941 +
14942 +/**
14943 + * atomic64_add_unchecked - add integer to atomic64 variable
14944 + * @i: integer value to add
14945 + * @v: pointer to type atomic64_unchecked_t
14946 + *
14947 + * Atomically adds @i to @v.
14948 + */
14949 +static inline void atomic64_add_unchecked(long i, atomic64_unchecked_t *v)
14950 +{
14951 asm volatile(LOCK_PREFIX "addq %1,%0"
14952 : "=m" (v->counter)
14953 : "er" (i), "m" (v->counter));
14954 @@ -56,7 +102,29 @@ static inline void atomic64_add(long i, atomic64_t *v)
14955 */
14956 static inline void atomic64_sub(long i, atomic64_t *v)
14957 {
14958 - asm volatile(LOCK_PREFIX "subq %1,%0"
14959 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14960 +
14961 +#ifdef CONFIG_PAX_REFCOUNT
14962 + "jno 0f\n"
14963 + LOCK_PREFIX "addq %1,%0\n"
14964 + "int $4\n0:\n"
14965 + _ASM_EXTABLE(0b, 0b)
14966 +#endif
14967 +
14968 + : "=m" (v->counter)
14969 + : "er" (i), "m" (v->counter));
14970 +}
14971 +
14972 +/**
14973 + * atomic64_sub_unchecked - subtract the atomic64 variable
14974 + * @i: integer value to subtract
14975 + * @v: pointer to type atomic64_unchecked_t
14976 + *
14977 + * Atomically subtracts @i from @v.
14978 + */
14979 +static inline void atomic64_sub_unchecked(long i, atomic64_unchecked_t *v)
14980 +{
14981 + asm volatile(LOCK_PREFIX "subq %1,%0\n"
14982 : "=m" (v->counter)
14983 : "er" (i), "m" (v->counter));
14984 }
14985 @@ -74,7 +142,16 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
14986 {
14987 unsigned char c;
14988
14989 - asm volatile(LOCK_PREFIX "subq %2,%0; sete %1"
14990 + asm volatile(LOCK_PREFIX "subq %2,%0\n"
14991 +
14992 +#ifdef CONFIG_PAX_REFCOUNT
14993 + "jno 0f\n"
14994 + LOCK_PREFIX "addq %2,%0\n"
14995 + "int $4\n0:\n"
14996 + _ASM_EXTABLE(0b, 0b)
14997 +#endif
14998 +
14999 + "sete %1\n"
15000 : "=m" (v->counter), "=qm" (c)
15001 : "er" (i), "m" (v->counter) : "memory");
15002 return c;
15003 @@ -88,6 +165,27 @@ static inline int atomic64_sub_and_test(long i, atomic64_t *v)
15004 */
15005 static inline void atomic64_inc(atomic64_t *v)
15006 {
15007 + asm volatile(LOCK_PREFIX "incq %0\n"
15008 +
15009 +#ifdef CONFIG_PAX_REFCOUNT
15010 + "jno 0f\n"
15011 + LOCK_PREFIX "decq %0\n"
15012 + "int $4\n0:\n"
15013 + _ASM_EXTABLE(0b, 0b)
15014 +#endif
15015 +
15016 + : "=m" (v->counter)
15017 + : "m" (v->counter));
15018 +}
15019 +
15020 +/**
15021 + * atomic64_inc_unchecked - increment atomic64 variable
15022 + * @v: pointer to type atomic64_unchecked_t
15023 + *
15024 + * Atomically increments @v by 1.
15025 + */
15026 +static inline void atomic64_inc_unchecked(atomic64_unchecked_t *v)
15027 +{
15028 asm volatile(LOCK_PREFIX "incq %0"
15029 : "=m" (v->counter)
15030 : "m" (v->counter));
15031 @@ -101,7 +199,28 @@ static inline void atomic64_inc(atomic64_t *v)
15032 */
15033 static inline void atomic64_dec(atomic64_t *v)
15034 {
15035 - asm volatile(LOCK_PREFIX "decq %0"
15036 + asm volatile(LOCK_PREFIX "decq %0\n"
15037 +
15038 +#ifdef CONFIG_PAX_REFCOUNT
15039 + "jno 0f\n"
15040 + LOCK_PREFIX "incq %0\n"
15041 + "int $4\n0:\n"
15042 + _ASM_EXTABLE(0b, 0b)
15043 +#endif
15044 +
15045 + : "=m" (v->counter)
15046 + : "m" (v->counter));
15047 +}
15048 +
15049 +/**
15050 + * atomic64_dec_unchecked - decrement atomic64 variable
15051 + * @v: pointer to type atomic64_t
15052 + *
15053 + * Atomically decrements @v by 1.
15054 + */
15055 +static inline void atomic64_dec_unchecked(atomic64_unchecked_t *v)
15056 +{
15057 + asm volatile(LOCK_PREFIX "decq %0\n"
15058 : "=m" (v->counter)
15059 : "m" (v->counter));
15060 }
15061 @@ -118,7 +237,16 @@ static inline int atomic64_dec_and_test(atomic64_t *v)
15062 {
15063 unsigned char c;
15064
15065 - asm volatile(LOCK_PREFIX "decq %0; sete %1"
15066 + asm volatile(LOCK_PREFIX "decq %0\n"
15067 +
15068 +#ifdef CONFIG_PAX_REFCOUNT
15069 + "jno 0f\n"
15070 + LOCK_PREFIX "incq %0\n"
15071 + "int $4\n0:\n"
15072 + _ASM_EXTABLE(0b, 0b)
15073 +#endif
15074 +
15075 + "sete %1\n"
15076 : "=m" (v->counter), "=qm" (c)
15077 : "m" (v->counter) : "memory");
15078 return c != 0;
15079 @@ -136,7 +264,16 @@ static inline int atomic64_inc_and_test(atomic64_t *v)
15080 {
15081 unsigned char c;
15082
15083 - asm volatile(LOCK_PREFIX "incq %0; sete %1"
15084 + asm volatile(LOCK_PREFIX "incq %0\n"
15085 +
15086 +#ifdef CONFIG_PAX_REFCOUNT
15087 + "jno 0f\n"
15088 + LOCK_PREFIX "decq %0\n"
15089 + "int $4\n0:\n"
15090 + _ASM_EXTABLE(0b, 0b)
15091 +#endif
15092 +
15093 + "sete %1\n"
15094 : "=m" (v->counter), "=qm" (c)
15095 : "m" (v->counter) : "memory");
15096 return c != 0;
15097 @@ -155,7 +292,16 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15098 {
15099 unsigned char c;
15100
15101 - asm volatile(LOCK_PREFIX "addq %2,%0; sets %1"
15102 + asm volatile(LOCK_PREFIX "addq %2,%0\n"
15103 +
15104 +#ifdef CONFIG_PAX_REFCOUNT
15105 + "jno 0f\n"
15106 + LOCK_PREFIX "subq %2,%0\n"
15107 + "int $4\n0:\n"
15108 + _ASM_EXTABLE(0b, 0b)
15109 +#endif
15110 +
15111 + "sets %1\n"
15112 : "=m" (v->counter), "=qm" (c)
15113 : "er" (i), "m" (v->counter) : "memory");
15114 return c;
15115 @@ -170,6 +316,18 @@ static inline int atomic64_add_negative(long i, atomic64_t *v)
15116 */
15117 static inline long atomic64_add_return(long i, atomic64_t *v)
15118 {
15119 + return i + xadd_check_overflow(&v->counter, i);
15120 +}
15121 +
15122 +/**
15123 + * atomic64_add_return_unchecked - add and return
15124 + * @i: integer value to add
15125 + * @v: pointer to type atomic64_unchecked_t
15126 + *
15127 + * Atomically adds @i to @v and returns @i + @v
15128 + */
15129 +static inline long atomic64_add_return_unchecked(long i, atomic64_unchecked_t *v)
15130 +{
15131 return i + xadd(&v->counter, i);
15132 }
15133
15134 @@ -179,6 +337,10 @@ static inline long atomic64_sub_return(long i, atomic64_t *v)
15135 }
15136
15137 #define atomic64_inc_return(v) (atomic64_add_return(1, (v)))
15138 +static inline long atomic64_inc_return_unchecked(atomic64_unchecked_t *v)
15139 +{
15140 + return atomic64_add_return_unchecked(1, v);
15141 +}
15142 #define atomic64_dec_return(v) (atomic64_sub_return(1, (v)))
15143
15144 static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15145 @@ -186,6 +348,11 @@ static inline long atomic64_cmpxchg(atomic64_t *v, long old, long new)
15146 return cmpxchg(&v->counter, old, new);
15147 }
15148
15149 +static inline long atomic64_cmpxchg_unchecked(atomic64_unchecked_t *v, long old, long new)
15150 +{
15151 + return cmpxchg(&v->counter, old, new);
15152 +}
15153 +
15154 static inline long atomic64_xchg(atomic64_t *v, long new)
15155 {
15156 return xchg(&v->counter, new);
15157 @@ -202,17 +369,30 @@ static inline long atomic64_xchg(atomic64_t *v, long new)
15158 */
15159 static inline int atomic64_add_unless(atomic64_t *v, long a, long u)
15160 {
15161 - long c, old;
15162 + long c, old, new;
15163 c = atomic64_read(v);
15164 for (;;) {
15165 - if (unlikely(c == (u)))
15166 + if (unlikely(c == u))
15167 break;
15168 - old = atomic64_cmpxchg((v), c, c + (a));
15169 +
15170 + asm volatile("add %2,%0\n"
15171 +
15172 +#ifdef CONFIG_PAX_REFCOUNT
15173 + "jno 0f\n"
15174 + "sub %2,%0\n"
15175 + "int $4\n0:\n"
15176 + _ASM_EXTABLE(0b, 0b)
15177 +#endif
15178 +
15179 + : "=r" (new)
15180 + : "0" (c), "ir" (a));
15181 +
15182 + old = atomic64_cmpxchg(v, c, new);
15183 if (likely(old == c))
15184 break;
15185 c = old;
15186 }
15187 - return c != (u);
15188 + return c != u;
15189 }
15190
15191 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1, 0)
15192 diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h
15193 index 41639ce..ebce552 100644
15194 --- a/arch/x86/include/asm/bitops.h
15195 +++ b/arch/x86/include/asm/bitops.h
15196 @@ -48,7 +48,7 @@
15197 * a mask operation on a byte.
15198 */
15199 #define IS_IMMEDIATE(nr) (__builtin_constant_p(nr))
15200 -#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((void *)(addr) + ((nr)>>3))
15201 +#define CONST_MASK_ADDR(nr, addr) BITOP_ADDR((volatile void *)(addr) + ((nr)>>3))
15202 #define CONST_MASK(nr) (1 << ((nr) & 7))
15203
15204 /**
15205 @@ -361,7 +361,7 @@ static int test_bit(int nr, const volatile unsigned long *addr);
15206 *
15207 * Undefined if no bit exists, so code should check against 0 first.
15208 */
15209 -static inline unsigned long __ffs(unsigned long word)
15210 +static inline unsigned long __intentional_overflow(-1) __ffs(unsigned long word)
15211 {
15212 asm("rep; bsf %1,%0"
15213 : "=r" (word)
15214 @@ -375,7 +375,7 @@ static inline unsigned long __ffs(unsigned long word)
15215 *
15216 * Undefined if no zero exists, so code should check against ~0UL first.
15217 */
15218 -static inline unsigned long ffz(unsigned long word)
15219 +static inline unsigned long __intentional_overflow(-1) ffz(unsigned long word)
15220 {
15221 asm("rep; bsf %1,%0"
15222 : "=r" (word)
15223 @@ -389,7 +389,7 @@ static inline unsigned long ffz(unsigned long word)
15224 *
15225 * Undefined if no set bit exists, so code should check against 0 first.
15226 */
15227 -static inline unsigned long __fls(unsigned long word)
15228 +static inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
15229 {
15230 asm("bsr %1,%0"
15231 : "=r" (word)
15232 @@ -452,7 +452,7 @@ static inline int ffs(int x)
15233 * set bit if value is nonzero. The last (most significant) bit is
15234 * at position 32.
15235 */
15236 -static inline int fls(int x)
15237 +static inline int __intentional_overflow(-1) fls(int x)
15238 {
15239 int r;
15240
15241 @@ -494,7 +494,7 @@ static inline int fls(int x)
15242 * at position 64.
15243 */
15244 #ifdef CONFIG_X86_64
15245 -static __always_inline int fls64(__u64 x)
15246 +static __always_inline long fls64(__u64 x)
15247 {
15248 int bitpos = -1;
15249 /*
15250 diff --git a/arch/x86/include/asm/boot.h b/arch/x86/include/asm/boot.h
15251 index 4fa687a..60f2d39 100644
15252 --- a/arch/x86/include/asm/boot.h
15253 +++ b/arch/x86/include/asm/boot.h
15254 @@ -6,10 +6,15 @@
15255 #include <uapi/asm/boot.h>
15256
15257 /* Physical address where kernel should be loaded. */
15258 -#define LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15259 +#define ____LOAD_PHYSICAL_ADDR ((CONFIG_PHYSICAL_START \
15260 + (CONFIG_PHYSICAL_ALIGN - 1)) \
15261 & ~(CONFIG_PHYSICAL_ALIGN - 1))
15262
15263 +#ifndef __ASSEMBLY__
15264 +extern unsigned char __LOAD_PHYSICAL_ADDR[];
15265 +#define LOAD_PHYSICAL_ADDR ((unsigned long)__LOAD_PHYSICAL_ADDR)
15266 +#endif
15267 +
15268 /* Minimum kernel alignment, as a power of two */
15269 #ifdef CONFIG_X86_64
15270 #define MIN_KERNEL_ALIGN_LG2 PMD_SHIFT
15271 diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
15272 index 48f99f1..d78ebf9 100644
15273 --- a/arch/x86/include/asm/cache.h
15274 +++ b/arch/x86/include/asm/cache.h
15275 @@ -5,12 +5,13 @@
15276
15277 /* L1 cache line size */
15278 #define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
15279 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
15280 +#define L1_CACHE_BYTES (_AC(1,UL) << L1_CACHE_SHIFT)
15281
15282 #define __read_mostly __attribute__((__section__(".data..read_mostly")))
15283 +#define __read_only __attribute__((__section__(".data..read_only")))
15284
15285 #define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
15286 -#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
15287 +#define INTERNODE_CACHE_BYTES (_AC(1,UL) << INTERNODE_CACHE_SHIFT)
15288
15289 #ifdef CONFIG_X86_VSMP
15290 #ifdef CONFIG_SMP
15291 diff --git a/arch/x86/include/asm/cacheflush.h b/arch/x86/include/asm/cacheflush.h
15292 index 9863ee3..4a1f8e1 100644
15293 --- a/arch/x86/include/asm/cacheflush.h
15294 +++ b/arch/x86/include/asm/cacheflush.h
15295 @@ -27,7 +27,7 @@ static inline unsigned long get_page_memtype(struct page *pg)
15296 unsigned long pg_flags = pg->flags & _PGMT_MASK;
15297
15298 if (pg_flags == _PGMT_DEFAULT)
15299 - return -1;
15300 + return ~0UL;
15301 else if (pg_flags == _PGMT_WC)
15302 return _PAGE_CACHE_WC;
15303 else if (pg_flags == _PGMT_UC_MINUS)
15304 diff --git a/arch/x86/include/asm/calling.h b/arch/x86/include/asm/calling.h
15305 index 0fa6750..cb7b2c3 100644
15306 --- a/arch/x86/include/asm/calling.h
15307 +++ b/arch/x86/include/asm/calling.h
15308 @@ -80,103 +80,113 @@ For 32-bit we have the following conventions - kernel is built with
15309 #define RSP 152
15310 #define SS 160
15311
15312 -#define ARGOFFSET R11
15313 -#define SWFRAME ORIG_RAX
15314 +#define ARGOFFSET R15
15315
15316 .macro SAVE_ARGS addskip=0, save_rcx=1, save_r891011=1
15317 - subq $9*8+\addskip, %rsp
15318 - CFI_ADJUST_CFA_OFFSET 9*8+\addskip
15319 - movq_cfi rdi, 8*8
15320 - movq_cfi rsi, 7*8
15321 - movq_cfi rdx, 6*8
15322 + subq $ORIG_RAX-ARGOFFSET+\addskip, %rsp
15323 + CFI_ADJUST_CFA_OFFSET ORIG_RAX-ARGOFFSET+\addskip
15324 + movq_cfi rdi, RDI
15325 + movq_cfi rsi, RSI
15326 + movq_cfi rdx, RDX
15327
15328 .if \save_rcx
15329 - movq_cfi rcx, 5*8
15330 + movq_cfi rcx, RCX
15331 .endif
15332
15333 - movq_cfi rax, 4*8
15334 + movq_cfi rax, RAX
15335
15336 .if \save_r891011
15337 - movq_cfi r8, 3*8
15338 - movq_cfi r9, 2*8
15339 - movq_cfi r10, 1*8
15340 - movq_cfi r11, 0*8
15341 + movq_cfi r8, R8
15342 + movq_cfi r9, R9
15343 + movq_cfi r10, R10
15344 + movq_cfi r11, R11
15345 .endif
15346
15347 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15348 + movq_cfi r12, R12
15349 +#endif
15350 +
15351 .endm
15352
15353 -#define ARG_SKIP (9*8)
15354 +#define ARG_SKIP ORIG_RAX
15355
15356 .macro RESTORE_ARGS rstor_rax=1, addskip=0, rstor_rcx=1, rstor_r11=1, \
15357 rstor_r8910=1, rstor_rdx=1
15358 +
15359 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15360 + movq_cfi_restore R12, r12
15361 +#endif
15362 +
15363 .if \rstor_r11
15364 - movq_cfi_restore 0*8, r11
15365 + movq_cfi_restore R11, r11
15366 .endif
15367
15368 .if \rstor_r8910
15369 - movq_cfi_restore 1*8, r10
15370 - movq_cfi_restore 2*8, r9
15371 - movq_cfi_restore 3*8, r8
15372 + movq_cfi_restore R10, r10
15373 + movq_cfi_restore R9, r9
15374 + movq_cfi_restore R8, r8
15375 .endif
15376
15377 .if \rstor_rax
15378 - movq_cfi_restore 4*8, rax
15379 + movq_cfi_restore RAX, rax
15380 .endif
15381
15382 .if \rstor_rcx
15383 - movq_cfi_restore 5*8, rcx
15384 + movq_cfi_restore RCX, rcx
15385 .endif
15386
15387 .if \rstor_rdx
15388 - movq_cfi_restore 6*8, rdx
15389 + movq_cfi_restore RDX, rdx
15390 .endif
15391
15392 - movq_cfi_restore 7*8, rsi
15393 - movq_cfi_restore 8*8, rdi
15394 + movq_cfi_restore RSI, rsi
15395 + movq_cfi_restore RDI, rdi
15396
15397 - .if ARG_SKIP+\addskip > 0
15398 - addq $ARG_SKIP+\addskip, %rsp
15399 - CFI_ADJUST_CFA_OFFSET -(ARG_SKIP+\addskip)
15400 + .if ORIG_RAX+\addskip > 0
15401 + addq $ORIG_RAX+\addskip, %rsp
15402 + CFI_ADJUST_CFA_OFFSET -(ORIG_RAX+\addskip)
15403 .endif
15404 .endm
15405
15406 - .macro LOAD_ARGS offset, skiprax=0
15407 - movq \offset(%rsp), %r11
15408 - movq \offset+8(%rsp), %r10
15409 - movq \offset+16(%rsp), %r9
15410 - movq \offset+24(%rsp), %r8
15411 - movq \offset+40(%rsp), %rcx
15412 - movq \offset+48(%rsp), %rdx
15413 - movq \offset+56(%rsp), %rsi
15414 - movq \offset+64(%rsp), %rdi
15415 + .macro LOAD_ARGS skiprax=0
15416 + movq R11(%rsp), %r11
15417 + movq R10(%rsp), %r10
15418 + movq R9(%rsp), %r9
15419 + movq R8(%rsp), %r8
15420 + movq RCX(%rsp), %rcx
15421 + movq RDX(%rsp), %rdx
15422 + movq RSI(%rsp), %rsi
15423 + movq RDI(%rsp), %rdi
15424 .if \skiprax
15425 .else
15426 - movq \offset+72(%rsp), %rax
15427 + movq RAX(%rsp), %rax
15428 .endif
15429 .endm
15430
15431 -#define REST_SKIP (6*8)
15432 -
15433 .macro SAVE_REST
15434 - subq $REST_SKIP, %rsp
15435 - CFI_ADJUST_CFA_OFFSET REST_SKIP
15436 - movq_cfi rbx, 5*8
15437 - movq_cfi rbp, 4*8
15438 - movq_cfi r12, 3*8
15439 - movq_cfi r13, 2*8
15440 - movq_cfi r14, 1*8
15441 - movq_cfi r15, 0*8
15442 + movq_cfi rbx, RBX
15443 + movq_cfi rbp, RBP
15444 +
15445 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15446 + movq_cfi r12, R12
15447 +#endif
15448 +
15449 + movq_cfi r13, R13
15450 + movq_cfi r14, R14
15451 + movq_cfi r15, R15
15452 .endm
15453
15454 .macro RESTORE_REST
15455 - movq_cfi_restore 0*8, r15
15456 - movq_cfi_restore 1*8, r14
15457 - movq_cfi_restore 2*8, r13
15458 - movq_cfi_restore 3*8, r12
15459 - movq_cfi_restore 4*8, rbp
15460 - movq_cfi_restore 5*8, rbx
15461 - addq $REST_SKIP, %rsp
15462 - CFI_ADJUST_CFA_OFFSET -(REST_SKIP)
15463 + movq_cfi_restore R15, r15
15464 + movq_cfi_restore R14, r14
15465 + movq_cfi_restore R13, r13
15466 +
15467 +#ifndef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
15468 + movq_cfi_restore R12, r12
15469 +#endif
15470 +
15471 + movq_cfi_restore RBP, rbp
15472 + movq_cfi_restore RBX, rbx
15473 .endm
15474
15475 .macro SAVE_ALL
15476 diff --git a/arch/x86/include/asm/checksum_32.h b/arch/x86/include/asm/checksum_32.h
15477 index f50de69..2b0a458 100644
15478 --- a/arch/x86/include/asm/checksum_32.h
15479 +++ b/arch/x86/include/asm/checksum_32.h
15480 @@ -31,6 +31,14 @@ asmlinkage __wsum csum_partial_copy_generic(const void *src, void *dst,
15481 int len, __wsum sum,
15482 int *src_err_ptr, int *dst_err_ptr);
15483
15484 +asmlinkage __wsum csum_partial_copy_generic_to_user(const void *src, void *dst,
15485 + int len, __wsum sum,
15486 + int *src_err_ptr, int *dst_err_ptr);
15487 +
15488 +asmlinkage __wsum csum_partial_copy_generic_from_user(const void *src, void *dst,
15489 + int len, __wsum sum,
15490 + int *src_err_ptr, int *dst_err_ptr);
15491 +
15492 /*
15493 * Note: when you get a NULL pointer exception here this means someone
15494 * passed in an incorrect kernel address to one of these functions.
15495 @@ -53,7 +61,7 @@ static inline __wsum csum_partial_copy_from_user(const void __user *src,
15496
15497 might_sleep();
15498 stac();
15499 - ret = csum_partial_copy_generic((__force void *)src, dst,
15500 + ret = csum_partial_copy_generic_from_user((__force void *)src, dst,
15501 len, sum, err_ptr, NULL);
15502 clac();
15503
15504 @@ -187,7 +195,7 @@ static inline __wsum csum_and_copy_to_user(const void *src,
15505 might_sleep();
15506 if (access_ok(VERIFY_WRITE, dst, len)) {
15507 stac();
15508 - ret = csum_partial_copy_generic(src, (__force void *)dst,
15509 + ret = csum_partial_copy_generic_to_user(src, (__force void *)dst,
15510 len, sum, NULL, err_ptr);
15511 clac();
15512 return ret;
15513 diff --git a/arch/x86/include/asm/cmpxchg.h b/arch/x86/include/asm/cmpxchg.h
15514 index d47786a..ce1b05d 100644
15515 --- a/arch/x86/include/asm/cmpxchg.h
15516 +++ b/arch/x86/include/asm/cmpxchg.h
15517 @@ -14,8 +14,12 @@ extern void __cmpxchg_wrong_size(void)
15518 __compiletime_error("Bad argument size for cmpxchg");
15519 extern void __xadd_wrong_size(void)
15520 __compiletime_error("Bad argument size for xadd");
15521 +extern void __xadd_check_overflow_wrong_size(void)
15522 + __compiletime_error("Bad argument size for xadd_check_overflow");
15523 extern void __add_wrong_size(void)
15524 __compiletime_error("Bad argument size for add");
15525 +extern void __add_check_overflow_wrong_size(void)
15526 + __compiletime_error("Bad argument size for add_check_overflow");
15527
15528 /*
15529 * Constants for operation sizes. On 32-bit, the 64-bit size it set to
15530 @@ -67,6 +71,34 @@ extern void __add_wrong_size(void)
15531 __ret; \
15532 })
15533
15534 +#define __xchg_op_check_overflow(ptr, arg, op, lock) \
15535 + ({ \
15536 + __typeof__ (*(ptr)) __ret = (arg); \
15537 + switch (sizeof(*(ptr))) { \
15538 + case __X86_CASE_L: \
15539 + asm volatile (lock #op "l %0, %1\n" \
15540 + "jno 0f\n" \
15541 + "mov %0,%1\n" \
15542 + "int $4\n0:\n" \
15543 + _ASM_EXTABLE(0b, 0b) \
15544 + : "+r" (__ret), "+m" (*(ptr)) \
15545 + : : "memory", "cc"); \
15546 + break; \
15547 + case __X86_CASE_Q: \
15548 + asm volatile (lock #op "q %q0, %1\n" \
15549 + "jno 0f\n" \
15550 + "mov %0,%1\n" \
15551 + "int $4\n0:\n" \
15552 + _ASM_EXTABLE(0b, 0b) \
15553 + : "+r" (__ret), "+m" (*(ptr)) \
15554 + : : "memory", "cc"); \
15555 + break; \
15556 + default: \
15557 + __ ## op ## _check_overflow_wrong_size(); \
15558 + } \
15559 + __ret; \
15560 + })
15561 +
15562 /*
15563 * Note: no "lock" prefix even on SMP: xchg always implies lock anyway.
15564 * Since this is generally used to protect other memory information, we
15565 @@ -167,6 +199,9 @@ extern void __add_wrong_size(void)
15566 #define xadd_sync(ptr, inc) __xadd((ptr), (inc), "lock; ")
15567 #define xadd_local(ptr, inc) __xadd((ptr), (inc), "")
15568
15569 +#define __xadd_check_overflow(ptr, inc, lock) __xchg_op_check_overflow((ptr), (inc), xadd, lock)
15570 +#define xadd_check_overflow(ptr, inc) __xadd_check_overflow((ptr), (inc), LOCK_PREFIX)
15571 +
15572 #define __add(ptr, inc, lock) \
15573 ({ \
15574 __typeof__ (*(ptr)) __ret = (inc); \
15575 diff --git a/arch/x86/include/asm/compat.h b/arch/x86/include/asm/compat.h
15576 index 59c6c40..5e0b22c 100644
15577 --- a/arch/x86/include/asm/compat.h
15578 +++ b/arch/x86/include/asm/compat.h
15579 @@ -41,7 +41,7 @@ typedef s64 __attribute__((aligned(4))) compat_s64;
15580 typedef u32 compat_uint_t;
15581 typedef u32 compat_ulong_t;
15582 typedef u64 __attribute__((aligned(4))) compat_u64;
15583 -typedef u32 compat_uptr_t;
15584 +typedef u32 __user compat_uptr_t;
15585
15586 struct compat_timespec {
15587 compat_time_t tv_sec;
15588 diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
15589 index 89270b4..f0abf8e 100644
15590 --- a/arch/x86/include/asm/cpufeature.h
15591 +++ b/arch/x86/include/asm/cpufeature.h
15592 @@ -203,7 +203,7 @@
15593 #define X86_FEATURE_DECODEASSISTS (8*32+12) /* AMD Decode Assists support */
15594 #define X86_FEATURE_PAUSEFILTER (8*32+13) /* AMD filtered pause intercept */
15595 #define X86_FEATURE_PFTHRESHOLD (8*32+14) /* AMD pause filter threshold */
15596 -
15597 +#define X86_FEATURE_STRONGUDEREF (8*32+31) /* PaX PCID based strong UDEREF */
15598
15599 /* Intel-defined CPU features, CPUID level 0x00000007:0 (ebx), word 9 */
15600 #define X86_FEATURE_FSGSBASE (9*32+ 0) /* {RD/WR}{FS/GS}BASE instructions*/
15601 @@ -211,7 +211,7 @@
15602 #define X86_FEATURE_BMI1 (9*32+ 3) /* 1st group bit manipulation extensions */
15603 #define X86_FEATURE_HLE (9*32+ 4) /* Hardware Lock Elision */
15604 #define X86_FEATURE_AVX2 (9*32+ 5) /* AVX2 instructions */
15605 -#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Protection */
15606 +#define X86_FEATURE_SMEP (9*32+ 7) /* Supervisor Mode Execution Prevention */
15607 #define X86_FEATURE_BMI2 (9*32+ 8) /* 2nd group bit manipulation extensions */
15608 #define X86_FEATURE_ERMS (9*32+ 9) /* Enhanced REP MOVSB/STOSB */
15609 #define X86_FEATURE_INVPCID (9*32+10) /* Invalidate Processor Context ID */
15610 @@ -353,6 +353,7 @@ extern const char * const x86_power_flags[32];
15611 #undef cpu_has_centaur_mcr
15612 #define cpu_has_centaur_mcr 0
15613
15614 +#define cpu_has_pcid boot_cpu_has(X86_FEATURE_PCID)
15615 #endif /* CONFIG_X86_64 */
15616
15617 #if __GNUC__ >= 4
15618 @@ -405,7 +406,8 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15619
15620 #ifdef CONFIG_X86_DEBUG_STATIC_CPU_HAS
15621 t_warn:
15622 - warn_pre_alternatives();
15623 + if (bit != X86_FEATURE_PCID && bit != X86_FEATURE_INVPCID)
15624 + warn_pre_alternatives();
15625 return false;
15626 #endif
15627
15628 @@ -425,7 +427,7 @@ static __always_inline __pure bool __static_cpu_has(u16 bit)
15629 ".section .discard,\"aw\",@progbits\n"
15630 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15631 ".previous\n"
15632 - ".section .altinstr_replacement,\"ax\"\n"
15633 + ".section .altinstr_replacement,\"a\"\n"
15634 "3: movb $1,%0\n"
15635 "4:\n"
15636 ".previous\n"
15637 @@ -462,7 +464,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15638 " .byte 2b - 1b\n" /* src len */
15639 " .byte 4f - 3f\n" /* repl len */
15640 ".previous\n"
15641 - ".section .altinstr_replacement,\"ax\"\n"
15642 + ".section .altinstr_replacement,\"a\"\n"
15643 "3: .byte 0xe9\n .long %l[t_no] - 2b\n"
15644 "4:\n"
15645 ".previous\n"
15646 @@ -495,7 +497,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15647 ".section .discard,\"aw\",@progbits\n"
15648 " .byte 0xff + (4f-3f) - (2b-1b)\n" /* size check */
15649 ".previous\n"
15650 - ".section .altinstr_replacement,\"ax\"\n"
15651 + ".section .altinstr_replacement,\"a\"\n"
15652 "3: movb $0,%0\n"
15653 "4:\n"
15654 ".previous\n"
15655 @@ -509,7 +511,7 @@ static __always_inline __pure bool _static_cpu_has_safe(u16 bit)
15656 ".section .discard,\"aw\",@progbits\n"
15657 " .byte 0xff + (6f-5f) - (4b-3b)\n" /* size check */
15658 ".previous\n"
15659 - ".section .altinstr_replacement,\"ax\"\n"
15660 + ".section .altinstr_replacement,\"a\"\n"
15661 "5: movb $1,%0\n"
15662 "6:\n"
15663 ".previous\n"
15664 diff --git a/arch/x86/include/asm/desc.h b/arch/x86/include/asm/desc.h
15665 index b90e5df..b462c91 100644
15666 --- a/arch/x86/include/asm/desc.h
15667 +++ b/arch/x86/include/asm/desc.h
15668 @@ -4,6 +4,7 @@
15669 #include <asm/desc_defs.h>
15670 #include <asm/ldt.h>
15671 #include <asm/mmu.h>
15672 +#include <asm/pgtable.h>
15673
15674 #include <linux/smp.h>
15675 #include <linux/percpu.h>
15676 @@ -17,6 +18,7 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15677
15678 desc->type = (info->read_exec_only ^ 1) << 1;
15679 desc->type |= info->contents << 2;
15680 + desc->type |= info->seg_not_present ^ 1;
15681
15682 desc->s = 1;
15683 desc->dpl = 0x3;
15684 @@ -35,19 +37,14 @@ static inline void fill_ldt(struct desc_struct *desc, const struct user_desc *in
15685 }
15686
15687 extern struct desc_ptr idt_descr;
15688 -extern gate_desc idt_table[];
15689 -extern struct desc_ptr debug_idt_descr;
15690 -extern gate_desc debug_idt_table[];
15691 -
15692 -struct gdt_page {
15693 - struct desc_struct gdt[GDT_ENTRIES];
15694 -} __attribute__((aligned(PAGE_SIZE)));
15695 -
15696 -DECLARE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page);
15697 +extern gate_desc idt_table[IDT_ENTRIES];
15698 +extern const struct desc_ptr debug_idt_descr;
15699 +extern gate_desc debug_idt_table[IDT_ENTRIES];
15700
15701 +extern struct desc_struct cpu_gdt_table[NR_CPUS][PAGE_SIZE / sizeof(struct desc_struct)];
15702 static inline struct desc_struct *get_cpu_gdt_table(unsigned int cpu)
15703 {
15704 - return per_cpu(gdt_page, cpu).gdt;
15705 + return cpu_gdt_table[cpu];
15706 }
15707
15708 #ifdef CONFIG_X86_64
15709 @@ -72,8 +69,14 @@ static inline void pack_gate(gate_desc *gate, unsigned char type,
15710 unsigned long base, unsigned dpl, unsigned flags,
15711 unsigned short seg)
15712 {
15713 - gate->a = (seg << 16) | (base & 0xffff);
15714 - gate->b = (base & 0xffff0000) | (((0x80 | type | (dpl << 5)) & 0xff) << 8);
15715 + gate->gate.offset_low = base;
15716 + gate->gate.seg = seg;
15717 + gate->gate.reserved = 0;
15718 + gate->gate.type = type;
15719 + gate->gate.s = 0;
15720 + gate->gate.dpl = dpl;
15721 + gate->gate.p = 1;
15722 + gate->gate.offset_high = base >> 16;
15723 }
15724
15725 #endif
15726 @@ -118,12 +121,16 @@ static inline void paravirt_free_ldt(struct desc_struct *ldt, unsigned entries)
15727
15728 static inline void native_write_idt_entry(gate_desc *idt, int entry, const gate_desc *gate)
15729 {
15730 + pax_open_kernel();
15731 memcpy(&idt[entry], gate, sizeof(*gate));
15732 + pax_close_kernel();
15733 }
15734
15735 static inline void native_write_ldt_entry(struct desc_struct *ldt, int entry, const void *desc)
15736 {
15737 + pax_open_kernel();
15738 memcpy(&ldt[entry], desc, 8);
15739 + pax_close_kernel();
15740 }
15741
15742 static inline void
15743 @@ -137,7 +144,9 @@ native_write_gdt_entry(struct desc_struct *gdt, int entry, const void *desc, int
15744 default: size = sizeof(*gdt); break;
15745 }
15746
15747 + pax_open_kernel();
15748 memcpy(&gdt[entry], desc, size);
15749 + pax_close_kernel();
15750 }
15751
15752 static inline void pack_descriptor(struct desc_struct *desc, unsigned long base,
15753 @@ -210,7 +219,9 @@ static inline void native_set_ldt(const void *addr, unsigned int entries)
15754
15755 static inline void native_load_tr_desc(void)
15756 {
15757 + pax_open_kernel();
15758 asm volatile("ltr %w0"::"q" (GDT_ENTRY_TSS*8));
15759 + pax_close_kernel();
15760 }
15761
15762 static inline void native_load_gdt(const struct desc_ptr *dtr)
15763 @@ -247,8 +258,10 @@ static inline void native_load_tls(struct thread_struct *t, unsigned int cpu)
15764 struct desc_struct *gdt = get_cpu_gdt_table(cpu);
15765 unsigned int i;
15766
15767 + pax_open_kernel();
15768 for (i = 0; i < GDT_ENTRY_TLS_ENTRIES; i++)
15769 gdt[GDT_ENTRY_TLS_MIN + i] = t->tls_array[i];
15770 + pax_close_kernel();
15771 }
15772
15773 #define _LDT_empty(info) \
15774 @@ -287,7 +300,7 @@ static inline void load_LDT(mm_context_t *pc)
15775 preempt_enable();
15776 }
15777
15778 -static inline unsigned long get_desc_base(const struct desc_struct *desc)
15779 +static inline unsigned long __intentional_overflow(-1) get_desc_base(const struct desc_struct *desc)
15780 {
15781 return (unsigned)(desc->base0 | ((desc->base1) << 16) | ((desc->base2) << 24));
15782 }
15783 @@ -311,7 +324,7 @@ static inline void set_desc_limit(struct desc_struct *desc, unsigned long limit)
15784 }
15785
15786 #ifdef CONFIG_X86_64
15787 -static inline void set_nmi_gate(int gate, void *addr)
15788 +static inline void set_nmi_gate(int gate, const void *addr)
15789 {
15790 gate_desc s;
15791
15792 @@ -321,8 +334,8 @@ static inline void set_nmi_gate(int gate, void *addr)
15793 #endif
15794
15795 #ifdef CONFIG_TRACING
15796 -extern struct desc_ptr trace_idt_descr;
15797 -extern gate_desc trace_idt_table[];
15798 +extern const struct desc_ptr trace_idt_descr;
15799 +extern gate_desc trace_idt_table[IDT_ENTRIES];
15800 static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15801 {
15802 write_idt_entry(trace_idt_table, entry, gate);
15803 @@ -333,7 +346,7 @@ static inline void write_trace_idt_entry(int entry, const gate_desc *gate)
15804 }
15805 #endif
15806
15807 -static inline void _set_gate(int gate, unsigned type, void *addr,
15808 +static inline void _set_gate(int gate, unsigned type, const void *addr,
15809 unsigned dpl, unsigned ist, unsigned seg)
15810 {
15811 gate_desc s;
15812 @@ -353,7 +366,7 @@ static inline void _set_gate(int gate, unsigned type, void *addr,
15813 * Pentium F0 0F bugfix can have resulted in the mapped
15814 * IDT being write-protected.
15815 */
15816 -static inline void set_intr_gate(unsigned int n, void *addr)
15817 +static inline void set_intr_gate(unsigned int n, const void *addr)
15818 {
15819 BUG_ON((unsigned)n > 0xFF);
15820 _set_gate(n, GATE_INTERRUPT, addr, 0, 0, __KERNEL_CS);
15821 @@ -410,19 +423,19 @@ static inline void __alloc_intr_gate(unsigned int n, void *addr)
15822 /*
15823 * This routine sets up an interrupt gate at directory privilege level 3.
15824 */
15825 -static inline void set_system_intr_gate(unsigned int n, void *addr)
15826 +static inline void set_system_intr_gate(unsigned int n, const void *addr)
15827 {
15828 BUG_ON((unsigned)n > 0xFF);
15829 _set_gate(n, GATE_INTERRUPT, addr, 0x3, 0, __KERNEL_CS);
15830 }
15831
15832 -static inline void set_system_trap_gate(unsigned int n, void *addr)
15833 +static inline void set_system_trap_gate(unsigned int n, const void *addr)
15834 {
15835 BUG_ON((unsigned)n > 0xFF);
15836 _set_gate(n, GATE_TRAP, addr, 0x3, 0, __KERNEL_CS);
15837 }
15838
15839 -static inline void set_trap_gate(unsigned int n, void *addr)
15840 +static inline void set_trap_gate(unsigned int n, const void *addr)
15841 {
15842 BUG_ON((unsigned)n > 0xFF);
15843 _set_gate(n, GATE_TRAP, addr, 0, 0, __KERNEL_CS);
15844 @@ -431,16 +444,16 @@ static inline void set_trap_gate(unsigned int n, void *addr)
15845 static inline void set_task_gate(unsigned int n, unsigned int gdt_entry)
15846 {
15847 BUG_ON((unsigned)n > 0xFF);
15848 - _set_gate(n, GATE_TASK, (void *)0, 0, 0, (gdt_entry<<3));
15849 + _set_gate(n, GATE_TASK, (const void *)0, 0, 0, (gdt_entry<<3));
15850 }
15851
15852 -static inline void set_intr_gate_ist(int n, void *addr, unsigned ist)
15853 +static inline void set_intr_gate_ist(int n, const void *addr, unsigned ist)
15854 {
15855 BUG_ON((unsigned)n > 0xFF);
15856 _set_gate(n, GATE_INTERRUPT, addr, 0, ist, __KERNEL_CS);
15857 }
15858
15859 -static inline void set_system_intr_gate_ist(int n, void *addr, unsigned ist)
15860 +static inline void set_system_intr_gate_ist(int n, const void *addr, unsigned ist)
15861 {
15862 BUG_ON((unsigned)n > 0xFF);
15863 _set_gate(n, GATE_INTERRUPT, addr, 0x3, ist, __KERNEL_CS);
15864 @@ -512,4 +525,17 @@ static inline void load_current_idt(void)
15865 else
15866 load_idt((const struct desc_ptr *)&idt_descr);
15867 }
15868 +
15869 +#ifdef CONFIG_X86_32
15870 +static inline void set_user_cs(unsigned long base, unsigned long limit, int cpu)
15871 +{
15872 + struct desc_struct d;
15873 +
15874 + if (likely(limit))
15875 + limit = (limit - 1UL) >> PAGE_SHIFT;
15876 + pack_descriptor(&d, base, limit, 0xFB, 0xC);
15877 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_DEFAULT_USER_CS, &d, DESCTYPE_S);
15878 +}
15879 +#endif
15880 +
15881 #endif /* _ASM_X86_DESC_H */
15882 diff --git a/arch/x86/include/asm/desc_defs.h b/arch/x86/include/asm/desc_defs.h
15883 index 278441f..b95a174 100644
15884 --- a/arch/x86/include/asm/desc_defs.h
15885 +++ b/arch/x86/include/asm/desc_defs.h
15886 @@ -31,6 +31,12 @@ struct desc_struct {
15887 unsigned base1: 8, type: 4, s: 1, dpl: 2, p: 1;
15888 unsigned limit: 4, avl: 1, l: 1, d: 1, g: 1, base2: 8;
15889 };
15890 + struct {
15891 + u16 offset_low;
15892 + u16 seg;
15893 + unsigned reserved: 8, type: 4, s: 1, dpl: 2, p: 1;
15894 + unsigned offset_high: 16;
15895 + } gate;
15896 };
15897 } __attribute__((packed));
15898
15899 diff --git a/arch/x86/include/asm/div64.h b/arch/x86/include/asm/div64.h
15900 index ced283a..ffe04cc 100644
15901 --- a/arch/x86/include/asm/div64.h
15902 +++ b/arch/x86/include/asm/div64.h
15903 @@ -39,7 +39,7 @@
15904 __mod; \
15905 })
15906
15907 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15908 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
15909 {
15910 union {
15911 u64 v64;
15912 diff --git a/arch/x86/include/asm/elf.h b/arch/x86/include/asm/elf.h
15913 index 9c999c1..3860cb8 100644
15914 --- a/arch/x86/include/asm/elf.h
15915 +++ b/arch/x86/include/asm/elf.h
15916 @@ -243,7 +243,25 @@ extern int force_personality32;
15917 the loader. We need to make sure that it is out of the way of the program
15918 that it will "exec", and that there is sufficient room for the brk. */
15919
15920 +#ifdef CONFIG_PAX_SEGMEXEC
15921 +#define ELF_ET_DYN_BASE ((current->mm->pax_flags & MF_PAX_SEGMEXEC) ? SEGMEXEC_TASK_SIZE/3*2 : TASK_SIZE/3*2)
15922 +#else
15923 #define ELF_ET_DYN_BASE (TASK_SIZE / 3 * 2)
15924 +#endif
15925 +
15926 +#ifdef CONFIG_PAX_ASLR
15927 +#ifdef CONFIG_X86_32
15928 +#define PAX_ELF_ET_DYN_BASE 0x10000000UL
15929 +
15930 +#define PAX_DELTA_MMAP_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15931 +#define PAX_DELTA_STACK_LEN (current->mm->pax_flags & MF_PAX_SEGMEXEC ? 15 : 16)
15932 +#else
15933 +#define PAX_ELF_ET_DYN_BASE 0x400000UL
15934 +
15935 +#define PAX_DELTA_MMAP_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15936 +#define PAX_DELTA_STACK_LEN ((test_thread_flag(TIF_ADDR32)) ? 16 : TASK_SIZE_MAX_SHIFT - PAGE_SHIFT - 3)
15937 +#endif
15938 +#endif
15939
15940 /* This yields a mask that user programs can use to figure out what
15941 instruction set this CPU supports. This could be done in user space,
15942 @@ -296,16 +314,12 @@ do { \
15943
15944 #define ARCH_DLINFO \
15945 do { \
15946 - if (vdso_enabled) \
15947 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15948 - (unsigned long)current->mm->context.vdso); \
15949 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15950 } while (0)
15951
15952 #define ARCH_DLINFO_X32 \
15953 do { \
15954 - if (vdso_enabled) \
15955 - NEW_AUX_ENT(AT_SYSINFO_EHDR, \
15956 - (unsigned long)current->mm->context.vdso); \
15957 + NEW_AUX_ENT(AT_SYSINFO_EHDR, current->mm->context.vdso); \
15958 } while (0)
15959
15960 #define AT_SYSINFO 32
15961 @@ -320,7 +334,7 @@ else \
15962
15963 #endif /* !CONFIG_X86_32 */
15964
15965 -#define VDSO_CURRENT_BASE ((unsigned long)current->mm->context.vdso)
15966 +#define VDSO_CURRENT_BASE (current->mm->context.vdso)
15967
15968 #define VDSO_ENTRY \
15969 ((unsigned long)VDSO32_SYMBOL(VDSO_CURRENT_BASE, vsyscall))
15970 @@ -336,9 +350,6 @@ extern int x32_setup_additional_pages(struct linux_binprm *bprm,
15971 extern int syscall32_setup_pages(struct linux_binprm *, int exstack);
15972 #define compat_arch_setup_additional_pages syscall32_setup_pages
15973
15974 -extern unsigned long arch_randomize_brk(struct mm_struct *mm);
15975 -#define arch_randomize_brk arch_randomize_brk
15976 -
15977 /*
15978 * True on X86_32 or when emulating IA32 on X86_64
15979 */
15980 diff --git a/arch/x86/include/asm/emergency-restart.h b/arch/x86/include/asm/emergency-restart.h
15981 index 77a99ac..39ff7f5 100644
15982 --- a/arch/x86/include/asm/emergency-restart.h
15983 +++ b/arch/x86/include/asm/emergency-restart.h
15984 @@ -1,6 +1,6 @@
15985 #ifndef _ASM_X86_EMERGENCY_RESTART_H
15986 #define _ASM_X86_EMERGENCY_RESTART_H
15987
15988 -extern void machine_emergency_restart(void);
15989 +extern void machine_emergency_restart(void) __noreturn;
15990
15991 #endif /* _ASM_X86_EMERGENCY_RESTART_H */
15992 diff --git a/arch/x86/include/asm/fpu-internal.h b/arch/x86/include/asm/fpu-internal.h
15993 index 4d0bda7..221da4d 100644
15994 --- a/arch/x86/include/asm/fpu-internal.h
15995 +++ b/arch/x86/include/asm/fpu-internal.h
15996 @@ -124,8 +124,11 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
15997 #define user_insn(insn, output, input...) \
15998 ({ \
15999 int err; \
16000 + pax_open_userland(); \
16001 asm volatile(ASM_STAC "\n" \
16002 - "1:" #insn "\n\t" \
16003 + "1:" \
16004 + __copyuser_seg \
16005 + #insn "\n\t" \
16006 "2: " ASM_CLAC "\n" \
16007 ".section .fixup,\"ax\"\n" \
16008 "3: movl $-1,%[err]\n" \
16009 @@ -134,6 +137,7 @@ static inline void sanitize_i387_state(struct task_struct *tsk)
16010 _ASM_EXTABLE(1b, 3b) \
16011 : [err] "=r" (err), output \
16012 : "0"(0), input); \
16013 + pax_close_userland(); \
16014 err; \
16015 })
16016
16017 @@ -298,7 +302,7 @@ static inline int restore_fpu_checking(struct task_struct *tsk)
16018 "emms\n\t" /* clear stack tags */
16019 "fildl %P[addr]", /* set F?P to defined value */
16020 X86_FEATURE_FXSAVE_LEAK,
16021 - [addr] "m" (tsk->thread.fpu.has_fpu));
16022 + [addr] "m" (init_tss[raw_smp_processor_id()].x86_tss.sp0));
16023
16024 return fpu_restore_checking(&tsk->thread.fpu);
16025 }
16026 diff --git a/arch/x86/include/asm/futex.h b/arch/x86/include/asm/futex.h
16027 index be27ba1..04a8801 100644
16028 --- a/arch/x86/include/asm/futex.h
16029 +++ b/arch/x86/include/asm/futex.h
16030 @@ -12,6 +12,7 @@
16031 #include <asm/smap.h>
16032
16033 #define __futex_atomic_op1(insn, ret, oldval, uaddr, oparg) \
16034 + typecheck(u32 __user *, uaddr); \
16035 asm volatile("\t" ASM_STAC "\n" \
16036 "1:\t" insn "\n" \
16037 "2:\t" ASM_CLAC "\n" \
16038 @@ -20,15 +21,16 @@
16039 "\tjmp\t2b\n" \
16040 "\t.previous\n" \
16041 _ASM_EXTABLE(1b, 3b) \
16042 - : "=r" (oldval), "=r" (ret), "+m" (*uaddr) \
16043 + : "=r" (oldval), "=r" (ret), "+m" (*(u32 __user *)____m(uaddr)) \
16044 : "i" (-EFAULT), "0" (oparg), "1" (0))
16045
16046 #define __futex_atomic_op2(insn, ret, oldval, uaddr, oparg) \
16047 + typecheck(u32 __user *, uaddr); \
16048 asm volatile("\t" ASM_STAC "\n" \
16049 "1:\tmovl %2, %0\n" \
16050 "\tmovl\t%0, %3\n" \
16051 "\t" insn "\n" \
16052 - "2:\t" LOCK_PREFIX "cmpxchgl %3, %2\n" \
16053 + "2:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %3, %2\n" \
16054 "\tjnz\t1b\n" \
16055 "3:\t" ASM_CLAC "\n" \
16056 "\t.section .fixup,\"ax\"\n" \
16057 @@ -38,7 +40,7 @@
16058 _ASM_EXTABLE(1b, 4b) \
16059 _ASM_EXTABLE(2b, 4b) \
16060 : "=&a" (oldval), "=&r" (ret), \
16061 - "+m" (*uaddr), "=&r" (tem) \
16062 + "+m" (*(u32 __user *)____m(uaddr)), "=&r" (tem) \
16063 : "r" (oparg), "i" (-EFAULT), "1" (0))
16064
16065 static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16066 @@ -57,12 +59,13 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16067
16068 pagefault_disable();
16069
16070 + pax_open_userland();
16071 switch (op) {
16072 case FUTEX_OP_SET:
16073 - __futex_atomic_op1("xchgl %0, %2", ret, oldval, uaddr, oparg);
16074 + __futex_atomic_op1(__copyuser_seg"xchgl %0, %2", ret, oldval, uaddr, oparg);
16075 break;
16076 case FUTEX_OP_ADD:
16077 - __futex_atomic_op1(LOCK_PREFIX "xaddl %0, %2", ret, oldval,
16078 + __futex_atomic_op1(LOCK_PREFIX __copyuser_seg"xaddl %0, %2", ret, oldval,
16079 uaddr, oparg);
16080 break;
16081 case FUTEX_OP_OR:
16082 @@ -77,6 +80,7 @@ static inline int futex_atomic_op_inuser(int encoded_op, u32 __user *uaddr)
16083 default:
16084 ret = -ENOSYS;
16085 }
16086 + pax_close_userland();
16087
16088 pagefault_enable();
16089
16090 @@ -115,18 +119,20 @@ static inline int futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr,
16091 if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32)))
16092 return -EFAULT;
16093
16094 + pax_open_userland();
16095 asm volatile("\t" ASM_STAC "\n"
16096 - "1:\t" LOCK_PREFIX "cmpxchgl %4, %2\n"
16097 + "1:\t" LOCK_PREFIX __copyuser_seg"cmpxchgl %4, %2\n"
16098 "2:\t" ASM_CLAC "\n"
16099 "\t.section .fixup, \"ax\"\n"
16100 "3:\tmov %3, %0\n"
16101 "\tjmp 2b\n"
16102 "\t.previous\n"
16103 _ASM_EXTABLE(1b, 3b)
16104 - : "+r" (ret), "=a" (oldval), "+m" (*uaddr)
16105 + : "+r" (ret), "=a" (oldval), "+m" (*(u32 __user *)____m(uaddr))
16106 : "i" (-EFAULT), "r" (newval), "1" (oldval)
16107 : "memory"
16108 );
16109 + pax_close_userland();
16110
16111 *uval = oldval;
16112 return ret;
16113 diff --git a/arch/x86/include/asm/hw_irq.h b/arch/x86/include/asm/hw_irq.h
16114 index 92b3bae..3866449 100644
16115 --- a/arch/x86/include/asm/hw_irq.h
16116 +++ b/arch/x86/include/asm/hw_irq.h
16117 @@ -165,8 +165,8 @@ extern void setup_ioapic_dest(void);
16118 extern void enable_IO_APIC(void);
16119
16120 /* Statistics */
16121 -extern atomic_t irq_err_count;
16122 -extern atomic_t irq_mis_count;
16123 +extern atomic_unchecked_t irq_err_count;
16124 +extern atomic_unchecked_t irq_mis_count;
16125
16126 /* EISA */
16127 extern void eisa_set_level_irq(unsigned int irq);
16128 diff --git a/arch/x86/include/asm/i8259.h b/arch/x86/include/asm/i8259.h
16129 index a203659..9889f1c 100644
16130 --- a/arch/x86/include/asm/i8259.h
16131 +++ b/arch/x86/include/asm/i8259.h
16132 @@ -62,7 +62,7 @@ struct legacy_pic {
16133 void (*init)(int auto_eoi);
16134 int (*irq_pending)(unsigned int irq);
16135 void (*make_irq)(unsigned int irq);
16136 -};
16137 +} __do_const;
16138
16139 extern struct legacy_pic *legacy_pic;
16140 extern struct legacy_pic null_legacy_pic;
16141 diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h
16142 index 34f69cb..6d95446 100644
16143 --- a/arch/x86/include/asm/io.h
16144 +++ b/arch/x86/include/asm/io.h
16145 @@ -51,12 +51,12 @@ static inline void name(type val, volatile void __iomem *addr) \
16146 "m" (*(volatile type __force *)addr) barrier); }
16147
16148 build_mmio_read(readb, "b", unsigned char, "=q", :"memory")
16149 -build_mmio_read(readw, "w", unsigned short, "=r", :"memory")
16150 -build_mmio_read(readl, "l", unsigned int, "=r", :"memory")
16151 +build_mmio_read(__intentional_overflow(-1) readw, "w", unsigned short, "=r", :"memory")
16152 +build_mmio_read(__intentional_overflow(-1) readl, "l", unsigned int, "=r", :"memory")
16153
16154 build_mmio_read(__readb, "b", unsigned char, "=q", )
16155 -build_mmio_read(__readw, "w", unsigned short, "=r", )
16156 -build_mmio_read(__readl, "l", unsigned int, "=r", )
16157 +build_mmio_read(__intentional_overflow(-1) __readw, "w", unsigned short, "=r", )
16158 +build_mmio_read(__intentional_overflow(-1) __readl, "l", unsigned int, "=r", )
16159
16160 build_mmio_write(writeb, "b", unsigned char, "q", :"memory")
16161 build_mmio_write(writew, "w", unsigned short, "r", :"memory")
16162 @@ -184,7 +184,7 @@ static inline void __iomem *ioremap(resource_size_t offset, unsigned long size)
16163 return ioremap_nocache(offset, size);
16164 }
16165
16166 -extern void iounmap(volatile void __iomem *addr);
16167 +extern void iounmap(const volatile void __iomem *addr);
16168
16169 extern void set_iounmap_nonlazy(void);
16170
16171 @@ -194,6 +194,17 @@ extern void set_iounmap_nonlazy(void);
16172
16173 #include <linux/vmalloc.h>
16174
16175 +#define ARCH_HAS_VALID_PHYS_ADDR_RANGE
16176 +static inline int valid_phys_addr_range(unsigned long addr, size_t count)
16177 +{
16178 + return ((addr + count + PAGE_SIZE - 1) >> PAGE_SHIFT) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16179 +}
16180 +
16181 +static inline int valid_mmap_phys_addr_range(unsigned long pfn, size_t count)
16182 +{
16183 + return (pfn + (count >> PAGE_SHIFT)) < (1ULL << (boot_cpu_data.x86_phys_bits - PAGE_SHIFT)) ? 1 : 0;
16184 +}
16185 +
16186 /*
16187 * Convert a virtual cached pointer to an uncached pointer
16188 */
16189 diff --git a/arch/x86/include/asm/irqflags.h b/arch/x86/include/asm/irqflags.h
16190 index bba3cf8..06bc8da 100644
16191 --- a/arch/x86/include/asm/irqflags.h
16192 +++ b/arch/x86/include/asm/irqflags.h
16193 @@ -141,6 +141,11 @@ static inline notrace unsigned long arch_local_irq_save(void)
16194 sti; \
16195 sysexit
16196
16197 +#define GET_CR0_INTO_RDI mov %cr0, %rdi
16198 +#define SET_RDI_INTO_CR0 mov %rdi, %cr0
16199 +#define GET_CR3_INTO_RDI mov %cr3, %rdi
16200 +#define SET_RDI_INTO_CR3 mov %rdi, %cr3
16201 +
16202 #else
16203 #define INTERRUPT_RETURN iret
16204 #define ENABLE_INTERRUPTS_SYSEXIT sti; sysexit
16205 diff --git a/arch/x86/include/asm/kprobes.h b/arch/x86/include/asm/kprobes.h
16206 index 9454c16..e4100e3 100644
16207 --- a/arch/x86/include/asm/kprobes.h
16208 +++ b/arch/x86/include/asm/kprobes.h
16209 @@ -38,13 +38,8 @@ typedef u8 kprobe_opcode_t;
16210 #define RELATIVEJUMP_SIZE 5
16211 #define RELATIVECALL_OPCODE 0xe8
16212 #define RELATIVE_ADDR_SIZE 4
16213 -#define MAX_STACK_SIZE 64
16214 -#define MIN_STACK_SIZE(ADDR) \
16215 - (((MAX_STACK_SIZE) < (((unsigned long)current_thread_info()) + \
16216 - THREAD_SIZE - (unsigned long)(ADDR))) \
16217 - ? (MAX_STACK_SIZE) \
16218 - : (((unsigned long)current_thread_info()) + \
16219 - THREAD_SIZE - (unsigned long)(ADDR)))
16220 +#define MAX_STACK_SIZE 64UL
16221 +#define MIN_STACK_SIZE(ADDR) min(MAX_STACK_SIZE, current->thread.sp0 - (unsigned long)(ADDR))
16222
16223 #define flush_insn_slot(p) do { } while (0)
16224
16225 diff --git a/arch/x86/include/asm/local.h b/arch/x86/include/asm/local.h
16226 index 2d89e39..baee879 100644
16227 --- a/arch/x86/include/asm/local.h
16228 +++ b/arch/x86/include/asm/local.h
16229 @@ -10,33 +10,97 @@ typedef struct {
16230 atomic_long_t a;
16231 } local_t;
16232
16233 +typedef struct {
16234 + atomic_long_unchecked_t a;
16235 +} local_unchecked_t;
16236 +
16237 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
16238
16239 #define local_read(l) atomic_long_read(&(l)->a)
16240 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
16241 #define local_set(l, i) atomic_long_set(&(l)->a, (i))
16242 +#define local_set_unchecked(l, i) atomic_long_set_unchecked(&(l)->a, (i))
16243
16244 static inline void local_inc(local_t *l)
16245 {
16246 - asm volatile(_ASM_INC "%0"
16247 + asm volatile(_ASM_INC "%0\n"
16248 +
16249 +#ifdef CONFIG_PAX_REFCOUNT
16250 + "jno 0f\n"
16251 + _ASM_DEC "%0\n"
16252 + "int $4\n0:\n"
16253 + _ASM_EXTABLE(0b, 0b)
16254 +#endif
16255 +
16256 + : "+m" (l->a.counter));
16257 +}
16258 +
16259 +static inline void local_inc_unchecked(local_unchecked_t *l)
16260 +{
16261 + asm volatile(_ASM_INC "%0\n"
16262 : "+m" (l->a.counter));
16263 }
16264
16265 static inline void local_dec(local_t *l)
16266 {
16267 - asm volatile(_ASM_DEC "%0"
16268 + asm volatile(_ASM_DEC "%0\n"
16269 +
16270 +#ifdef CONFIG_PAX_REFCOUNT
16271 + "jno 0f\n"
16272 + _ASM_INC "%0\n"
16273 + "int $4\n0:\n"
16274 + _ASM_EXTABLE(0b, 0b)
16275 +#endif
16276 +
16277 + : "+m" (l->a.counter));
16278 +}
16279 +
16280 +static inline void local_dec_unchecked(local_unchecked_t *l)
16281 +{
16282 + asm volatile(_ASM_DEC "%0\n"
16283 : "+m" (l->a.counter));
16284 }
16285
16286 static inline void local_add(long i, local_t *l)
16287 {
16288 - asm volatile(_ASM_ADD "%1,%0"
16289 + asm volatile(_ASM_ADD "%1,%0\n"
16290 +
16291 +#ifdef CONFIG_PAX_REFCOUNT
16292 + "jno 0f\n"
16293 + _ASM_SUB "%1,%0\n"
16294 + "int $4\n0:\n"
16295 + _ASM_EXTABLE(0b, 0b)
16296 +#endif
16297 +
16298 + : "+m" (l->a.counter)
16299 + : "ir" (i));
16300 +}
16301 +
16302 +static inline void local_add_unchecked(long i, local_unchecked_t *l)
16303 +{
16304 + asm volatile(_ASM_ADD "%1,%0\n"
16305 : "+m" (l->a.counter)
16306 : "ir" (i));
16307 }
16308
16309 static inline void local_sub(long i, local_t *l)
16310 {
16311 - asm volatile(_ASM_SUB "%1,%0"
16312 + asm volatile(_ASM_SUB "%1,%0\n"
16313 +
16314 +#ifdef CONFIG_PAX_REFCOUNT
16315 + "jno 0f\n"
16316 + _ASM_ADD "%1,%0\n"
16317 + "int $4\n0:\n"
16318 + _ASM_EXTABLE(0b, 0b)
16319 +#endif
16320 +
16321 + : "+m" (l->a.counter)
16322 + : "ir" (i));
16323 +}
16324 +
16325 +static inline void local_sub_unchecked(long i, local_unchecked_t *l)
16326 +{
16327 + asm volatile(_ASM_SUB "%1,%0\n"
16328 : "+m" (l->a.counter)
16329 : "ir" (i));
16330 }
16331 @@ -54,7 +118,16 @@ static inline int local_sub_and_test(long i, local_t *l)
16332 {
16333 unsigned char c;
16334
16335 - asm volatile(_ASM_SUB "%2,%0; sete %1"
16336 + asm volatile(_ASM_SUB "%2,%0\n"
16337 +
16338 +#ifdef CONFIG_PAX_REFCOUNT
16339 + "jno 0f\n"
16340 + _ASM_ADD "%2,%0\n"
16341 + "int $4\n0:\n"
16342 + _ASM_EXTABLE(0b, 0b)
16343 +#endif
16344 +
16345 + "sete %1\n"
16346 : "+m" (l->a.counter), "=qm" (c)
16347 : "ir" (i) : "memory");
16348 return c;
16349 @@ -72,7 +145,16 @@ static inline int local_dec_and_test(local_t *l)
16350 {
16351 unsigned char c;
16352
16353 - asm volatile(_ASM_DEC "%0; sete %1"
16354 + asm volatile(_ASM_DEC "%0\n"
16355 +
16356 +#ifdef CONFIG_PAX_REFCOUNT
16357 + "jno 0f\n"
16358 + _ASM_INC "%0\n"
16359 + "int $4\n0:\n"
16360 + _ASM_EXTABLE(0b, 0b)
16361 +#endif
16362 +
16363 + "sete %1\n"
16364 : "+m" (l->a.counter), "=qm" (c)
16365 : : "memory");
16366 return c != 0;
16367 @@ -90,7 +172,16 @@ static inline int local_inc_and_test(local_t *l)
16368 {
16369 unsigned char c;
16370
16371 - asm volatile(_ASM_INC "%0; sete %1"
16372 + asm volatile(_ASM_INC "%0\n"
16373 +
16374 +#ifdef CONFIG_PAX_REFCOUNT
16375 + "jno 0f\n"
16376 + _ASM_DEC "%0\n"
16377 + "int $4\n0:\n"
16378 + _ASM_EXTABLE(0b, 0b)
16379 +#endif
16380 +
16381 + "sete %1\n"
16382 : "+m" (l->a.counter), "=qm" (c)
16383 : : "memory");
16384 return c != 0;
16385 @@ -109,7 +200,16 @@ static inline int local_add_negative(long i, local_t *l)
16386 {
16387 unsigned char c;
16388
16389 - asm volatile(_ASM_ADD "%2,%0; sets %1"
16390 + asm volatile(_ASM_ADD "%2,%0\n"
16391 +
16392 +#ifdef CONFIG_PAX_REFCOUNT
16393 + "jno 0f\n"
16394 + _ASM_SUB "%2,%0\n"
16395 + "int $4\n0:\n"
16396 + _ASM_EXTABLE(0b, 0b)
16397 +#endif
16398 +
16399 + "sets %1\n"
16400 : "+m" (l->a.counter), "=qm" (c)
16401 : "ir" (i) : "memory");
16402 return c;
16403 @@ -125,6 +225,30 @@ static inline int local_add_negative(long i, local_t *l)
16404 static inline long local_add_return(long i, local_t *l)
16405 {
16406 long __i = i;
16407 + asm volatile(_ASM_XADD "%0, %1\n"
16408 +
16409 +#ifdef CONFIG_PAX_REFCOUNT
16410 + "jno 0f\n"
16411 + _ASM_MOV "%0,%1\n"
16412 + "int $4\n0:\n"
16413 + _ASM_EXTABLE(0b, 0b)
16414 +#endif
16415 +
16416 + : "+r" (i), "+m" (l->a.counter)
16417 + : : "memory");
16418 + return i + __i;
16419 +}
16420 +
16421 +/**
16422 + * local_add_return_unchecked - add and return
16423 + * @i: integer value to add
16424 + * @l: pointer to type local_unchecked_t
16425 + *
16426 + * Atomically adds @i to @l and returns @i + @l
16427 + */
16428 +static inline long local_add_return_unchecked(long i, local_unchecked_t *l)
16429 +{
16430 + long __i = i;
16431 asm volatile(_ASM_XADD "%0, %1;"
16432 : "+r" (i), "+m" (l->a.counter)
16433 : : "memory");
16434 @@ -141,6 +265,8 @@ static inline long local_sub_return(long i, local_t *l)
16435
16436 #define local_cmpxchg(l, o, n) \
16437 (cmpxchg_local(&((l)->a.counter), (o), (n)))
16438 +#define local_cmpxchg_unchecked(l, o, n) \
16439 + (cmpxchg_local(&((l)->a.counter), (o), (n)))
16440 /* Always has a lock prefix */
16441 #define local_xchg(l, n) (xchg(&((l)->a.counter), (n)))
16442
16443 diff --git a/arch/x86/include/asm/mman.h b/arch/x86/include/asm/mman.h
16444 new file mode 100644
16445 index 0000000..2bfd3ba
16446 --- /dev/null
16447 +++ b/arch/x86/include/asm/mman.h
16448 @@ -0,0 +1,15 @@
16449 +#ifndef _X86_MMAN_H
16450 +#define _X86_MMAN_H
16451 +
16452 +#include <uapi/asm/mman.h>
16453 +
16454 +#ifdef __KERNEL__
16455 +#ifndef __ASSEMBLY__
16456 +#ifdef CONFIG_X86_32
16457 +#define arch_mmap_check i386_mmap_check
16458 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags);
16459 +#endif
16460 +#endif
16461 +#endif
16462 +
16463 +#endif /* X86_MMAN_H */
16464 diff --git a/arch/x86/include/asm/mmu.h b/arch/x86/include/asm/mmu.h
16465 index 5f55e69..e20bfb1 100644
16466 --- a/arch/x86/include/asm/mmu.h
16467 +++ b/arch/x86/include/asm/mmu.h
16468 @@ -9,7 +9,7 @@
16469 * we put the segment information here.
16470 */
16471 typedef struct {
16472 - void *ldt;
16473 + struct desc_struct *ldt;
16474 int size;
16475
16476 #ifdef CONFIG_X86_64
16477 @@ -18,7 +18,19 @@ typedef struct {
16478 #endif
16479
16480 struct mutex lock;
16481 - void *vdso;
16482 + unsigned long vdso;
16483 +
16484 +#ifdef CONFIG_X86_32
16485 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
16486 + unsigned long user_cs_base;
16487 + unsigned long user_cs_limit;
16488 +
16489 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16490 + cpumask_t cpu_user_cs_mask;
16491 +#endif
16492 +
16493 +#endif
16494 +#endif
16495 } mm_context_t;
16496
16497 #ifdef CONFIG_SMP
16498 diff --git a/arch/x86/include/asm/mmu_context.h b/arch/x86/include/asm/mmu_context.h
16499 index be12c53..4d24039 100644
16500 --- a/arch/x86/include/asm/mmu_context.h
16501 +++ b/arch/x86/include/asm/mmu_context.h
16502 @@ -24,6 +24,20 @@ void destroy_context(struct mm_struct *mm);
16503
16504 static inline void enter_lazy_tlb(struct mm_struct *mm, struct task_struct *tsk)
16505 {
16506 +
16507 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16508 + if (!(static_cpu_has(X86_FEATURE_PCID))) {
16509 + unsigned int i;
16510 + pgd_t *pgd;
16511 +
16512 + pax_open_kernel();
16513 + pgd = get_cpu_pgd(smp_processor_id(), kernel);
16514 + for (i = USER_PGD_PTRS; i < 2 * USER_PGD_PTRS; ++i)
16515 + set_pgd_batched(pgd+i, native_make_pgd(0));
16516 + pax_close_kernel();
16517 + }
16518 +#endif
16519 +
16520 #ifdef CONFIG_SMP
16521 if (this_cpu_read(cpu_tlbstate.state) == TLBSTATE_OK)
16522 this_cpu_write(cpu_tlbstate.state, TLBSTATE_LAZY);
16523 @@ -34,16 +48,59 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16524 struct task_struct *tsk)
16525 {
16526 unsigned cpu = smp_processor_id();
16527 +#if defined(CONFIG_X86_32) && defined(CONFIG_SMP) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16528 + int tlbstate = TLBSTATE_OK;
16529 +#endif
16530
16531 if (likely(prev != next)) {
16532 #ifdef CONFIG_SMP
16533 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16534 + tlbstate = this_cpu_read(cpu_tlbstate.state);
16535 +#endif
16536 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16537 this_cpu_write(cpu_tlbstate.active_mm, next);
16538 #endif
16539 cpumask_set_cpu(cpu, mm_cpumask(next));
16540
16541 /* Re-load page tables */
16542 +#ifdef CONFIG_PAX_PER_CPU_PGD
16543 + pax_open_kernel();
16544 +
16545 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16546 + if (static_cpu_has(X86_FEATURE_PCID))
16547 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16548 + else
16549 +#endif
16550 +
16551 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16552 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16553 + pax_close_kernel();
16554 + 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));
16555 +
16556 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16557 + if (static_cpu_has(X86_FEATURE_PCID)) {
16558 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16559 + u64 descriptor[2];
16560 + descriptor[0] = PCID_USER;
16561 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16562 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16563 + descriptor[0] = PCID_KERNEL;
16564 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16565 + }
16566 + } else {
16567 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16568 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16569 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16570 + else
16571 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16572 + }
16573 + } else
16574 +#endif
16575 +
16576 + load_cr3(get_cpu_pgd(cpu, kernel));
16577 +#else
16578 load_cr3(next->pgd);
16579 +#endif
16580
16581 /* Stop flush ipis for the previous mm */
16582 cpumask_clear_cpu(cpu, mm_cpumask(prev));
16583 @@ -51,9 +108,67 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16584 /* Load the LDT, if the LDT is different: */
16585 if (unlikely(prev->context.ldt != next->context.ldt))
16586 load_LDT_nolock(&next->context);
16587 +
16588 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
16589 + if (!(__supported_pte_mask & _PAGE_NX)) {
16590 + smp_mb__before_clear_bit();
16591 + cpu_clear(cpu, prev->context.cpu_user_cs_mask);
16592 + smp_mb__after_clear_bit();
16593 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16594 + }
16595 +#endif
16596 +
16597 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16598 + if (unlikely(prev->context.user_cs_base != next->context.user_cs_base ||
16599 + prev->context.user_cs_limit != next->context.user_cs_limit))
16600 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16601 +#ifdef CONFIG_SMP
16602 + else if (unlikely(tlbstate != TLBSTATE_OK))
16603 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16604 +#endif
16605 +#endif
16606 +
16607 }
16608 + else {
16609 +
16610 +#ifdef CONFIG_PAX_PER_CPU_PGD
16611 + pax_open_kernel();
16612 +
16613 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16614 + if (static_cpu_has(X86_FEATURE_PCID))
16615 + __clone_user_pgds(get_cpu_pgd(cpu, user), next->pgd);
16616 + else
16617 +#endif
16618 +
16619 + __clone_user_pgds(get_cpu_pgd(cpu, kernel), next->pgd);
16620 + __shadow_user_pgds(get_cpu_pgd(cpu, kernel) + USER_PGD_PTRS, next->pgd);
16621 + pax_close_kernel();
16622 + 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));
16623 +
16624 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
16625 + if (static_cpu_has(X86_FEATURE_PCID)) {
16626 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
16627 + u64 descriptor[2];
16628 + descriptor[0] = PCID_USER;
16629 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16630 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF)) {
16631 + descriptor[0] = PCID_KERNEL;
16632 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_CONTEXT) : "memory");
16633 + }
16634 + } else {
16635 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
16636 + if (static_cpu_has(X86_FEATURE_STRONGUDEREF))
16637 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
16638 + else
16639 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
16640 + }
16641 + } else
16642 +#endif
16643 +
16644 + load_cr3(get_cpu_pgd(cpu, kernel));
16645 +#endif
16646 +
16647 #ifdef CONFIG_SMP
16648 - else {
16649 this_cpu_write(cpu_tlbstate.state, TLBSTATE_OK);
16650 BUG_ON(this_cpu_read(cpu_tlbstate.active_mm) != next);
16651
16652 @@ -70,11 +185,28 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
16653 * tlb flush IPI delivery. We must reload CR3
16654 * to make sure to use no freed page tables.
16655 */
16656 +
16657 +#ifndef CONFIG_PAX_PER_CPU_PGD
16658 load_cr3(next->pgd);
16659 +#endif
16660 +
16661 load_LDT_nolock(&next->context);
16662 +
16663 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
16664 + if (!(__supported_pte_mask & _PAGE_NX))
16665 + cpu_set(cpu, next->context.cpu_user_cs_mask);
16666 +#endif
16667 +
16668 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC))
16669 +#ifdef CONFIG_PAX_PAGEEXEC
16670 + if (!((next->pax_flags & MF_PAX_PAGEEXEC) && (__supported_pte_mask & _PAGE_NX)))
16671 +#endif
16672 + set_user_cs(next->context.user_cs_base, next->context.user_cs_limit, cpu);
16673 +#endif
16674 +
16675 }
16676 +#endif
16677 }
16678 -#endif
16679 }
16680
16681 #define activate_mm(prev, next) \
16682 diff --git a/arch/x86/include/asm/module.h b/arch/x86/include/asm/module.h
16683 index e3b7819..b257c64 100644
16684 --- a/arch/x86/include/asm/module.h
16685 +++ b/arch/x86/include/asm/module.h
16686 @@ -5,6 +5,7 @@
16687
16688 #ifdef CONFIG_X86_64
16689 /* X86_64 does not define MODULE_PROC_FAMILY */
16690 +#define MODULE_PROC_FAMILY ""
16691 #elif defined CONFIG_M486
16692 #define MODULE_PROC_FAMILY "486 "
16693 #elif defined CONFIG_M586
16694 @@ -57,8 +58,20 @@
16695 #error unknown processor family
16696 #endif
16697
16698 -#ifdef CONFIG_X86_32
16699 -# define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY
16700 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_BTS
16701 +#define MODULE_PAX_KERNEXEC "KERNEXEC_BTS "
16702 +#elif defined(CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR)
16703 +#define MODULE_PAX_KERNEXEC "KERNEXEC_OR "
16704 +#else
16705 +#define MODULE_PAX_KERNEXEC ""
16706 #endif
16707
16708 +#ifdef CONFIG_PAX_MEMORY_UDEREF
16709 +#define MODULE_PAX_UDEREF "UDEREF "
16710 +#else
16711 +#define MODULE_PAX_UDEREF ""
16712 +#endif
16713 +
16714 +#define MODULE_ARCH_VERMAGIC MODULE_PROC_FAMILY MODULE_PAX_KERNEXEC MODULE_PAX_UDEREF
16715 +
16716 #endif /* _ASM_X86_MODULE_H */
16717 diff --git a/arch/x86/include/asm/nmi.h b/arch/x86/include/asm/nmi.h
16718 index 86f9301..b365cda 100644
16719 --- a/arch/x86/include/asm/nmi.h
16720 +++ b/arch/x86/include/asm/nmi.h
16721 @@ -40,11 +40,11 @@ struct nmiaction {
16722 nmi_handler_t handler;
16723 unsigned long flags;
16724 const char *name;
16725 -};
16726 +} __do_const;
16727
16728 #define register_nmi_handler(t, fn, fg, n, init...) \
16729 ({ \
16730 - static struct nmiaction init fn##_na = { \
16731 + static const struct nmiaction init fn##_na = { \
16732 .handler = (fn), \
16733 .name = (n), \
16734 .flags = (fg), \
16735 @@ -52,7 +52,7 @@ struct nmiaction {
16736 __register_nmi_handler((t), &fn##_na); \
16737 })
16738
16739 -int __register_nmi_handler(unsigned int, struct nmiaction *);
16740 +int __register_nmi_handler(unsigned int, const struct nmiaction *);
16741
16742 void unregister_nmi_handler(unsigned int, const char *);
16743
16744 diff --git a/arch/x86/include/asm/page.h b/arch/x86/include/asm/page.h
16745 index c878924..21f4889 100644
16746 --- a/arch/x86/include/asm/page.h
16747 +++ b/arch/x86/include/asm/page.h
16748 @@ -52,6 +52,7 @@ static inline void copy_user_page(void *to, void *from, unsigned long vaddr,
16749 __phys_addr_symbol(__phys_reloc_hide((unsigned long)(x)))
16750
16751 #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET))
16752 +#define __early_va(x) ((void *)((unsigned long)(x)+__START_KERNEL_map - phys_base))
16753
16754 #define __boot_va(x) __va(x)
16755 #define __boot_pa(x) __pa(x)
16756 diff --git a/arch/x86/include/asm/page_64.h b/arch/x86/include/asm/page_64.h
16757 index 0f1ddee..e2fc3d1 100644
16758 --- a/arch/x86/include/asm/page_64.h
16759 +++ b/arch/x86/include/asm/page_64.h
16760 @@ -7,9 +7,9 @@
16761
16762 /* duplicated to the one in bootmem.h */
16763 extern unsigned long max_pfn;
16764 -extern unsigned long phys_base;
16765 +extern const unsigned long phys_base;
16766
16767 -static inline unsigned long __phys_addr_nodebug(unsigned long x)
16768 +static inline unsigned long __intentional_overflow(-1) __phys_addr_nodebug(unsigned long x)
16769 {
16770 unsigned long y = x - __START_KERNEL_map;
16771
16772 diff --git a/arch/x86/include/asm/paravirt.h b/arch/x86/include/asm/paravirt.h
16773 index 401f350..dee5d13 100644
16774 --- a/arch/x86/include/asm/paravirt.h
16775 +++ b/arch/x86/include/asm/paravirt.h
16776 @@ -560,7 +560,7 @@ static inline pmd_t __pmd(pmdval_t val)
16777 return (pmd_t) { ret };
16778 }
16779
16780 -static inline pmdval_t pmd_val(pmd_t pmd)
16781 +static inline __intentional_overflow(-1) pmdval_t pmd_val(pmd_t pmd)
16782 {
16783 pmdval_t ret;
16784
16785 @@ -626,6 +626,18 @@ static inline void set_pgd(pgd_t *pgdp, pgd_t pgd)
16786 val);
16787 }
16788
16789 +static inline void set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
16790 +{
16791 + pgdval_t val = native_pgd_val(pgd);
16792 +
16793 + if (sizeof(pgdval_t) > sizeof(long))
16794 + PVOP_VCALL3(pv_mmu_ops.set_pgd_batched, pgdp,
16795 + val, (u64)val >> 32);
16796 + else
16797 + PVOP_VCALL2(pv_mmu_ops.set_pgd_batched, pgdp,
16798 + val);
16799 +}
16800 +
16801 static inline void pgd_clear(pgd_t *pgdp)
16802 {
16803 set_pgd(pgdp, __pgd(0));
16804 @@ -710,6 +722,21 @@ static inline void __set_fixmap(unsigned /* enum fixed_addresses */ idx,
16805 pv_mmu_ops.set_fixmap(idx, phys, flags);
16806 }
16807
16808 +#ifdef CONFIG_PAX_KERNEXEC
16809 +static inline unsigned long pax_open_kernel(void)
16810 +{
16811 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_open_kernel);
16812 +}
16813 +
16814 +static inline unsigned long pax_close_kernel(void)
16815 +{
16816 + return PVOP_CALL0(unsigned long, pv_mmu_ops.pax_close_kernel);
16817 +}
16818 +#else
16819 +static inline unsigned long pax_open_kernel(void) { return 0; }
16820 +static inline unsigned long pax_close_kernel(void) { return 0; }
16821 +#endif
16822 +
16823 #if defined(CONFIG_SMP) && defined(CONFIG_PARAVIRT_SPINLOCKS)
16824
16825 static __always_inline void __ticket_lock_spinning(struct arch_spinlock *lock,
16826 @@ -906,7 +933,7 @@ extern void default_banner(void);
16827
16828 #define PARA_PATCH(struct, off) ((PARAVIRT_PATCH_##struct + (off)) / 4)
16829 #define PARA_SITE(ptype, clobbers, ops) _PVSITE(ptype, clobbers, ops, .long, 4)
16830 -#define PARA_INDIRECT(addr) *%cs:addr
16831 +#define PARA_INDIRECT(addr) *%ss:addr
16832 #endif
16833
16834 #define INTERRUPT_RETURN \
16835 @@ -981,6 +1008,21 @@ extern void default_banner(void);
16836 PARA_SITE(PARA_PATCH(pv_cpu_ops, PV_CPU_irq_enable_sysexit), \
16837 CLBR_NONE, \
16838 jmp PARA_INDIRECT(pv_cpu_ops+PV_CPU_irq_enable_sysexit))
16839 +
16840 +#define GET_CR0_INTO_RDI \
16841 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0); \
16842 + mov %rax,%rdi
16843 +
16844 +#define SET_RDI_INTO_CR0 \
16845 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
16846 +
16847 +#define GET_CR3_INTO_RDI \
16848 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_read_cr3); \
16849 + mov %rax,%rdi
16850 +
16851 +#define SET_RDI_INTO_CR3 \
16852 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_write_cr3)
16853 +
16854 #endif /* CONFIG_X86_32 */
16855
16856 #endif /* __ASSEMBLY__ */
16857 diff --git a/arch/x86/include/asm/paravirt_types.h b/arch/x86/include/asm/paravirt_types.h
16858 index aab8f67..2531748 100644
16859 --- a/arch/x86/include/asm/paravirt_types.h
16860 +++ b/arch/x86/include/asm/paravirt_types.h
16861 @@ -84,7 +84,7 @@ struct pv_init_ops {
16862 */
16863 unsigned (*patch)(u8 type, u16 clobber, void *insnbuf,
16864 unsigned long addr, unsigned len);
16865 -};
16866 +} __no_const;
16867
16868
16869 struct pv_lazy_ops {
16870 @@ -98,7 +98,7 @@ struct pv_time_ops {
16871 unsigned long long (*sched_clock)(void);
16872 unsigned long long (*steal_clock)(int cpu);
16873 unsigned long (*get_tsc_khz)(void);
16874 -};
16875 +} __no_const;
16876
16877 struct pv_cpu_ops {
16878 /* hooks for various privileged instructions */
16879 @@ -192,7 +192,7 @@ struct pv_cpu_ops {
16880
16881 void (*start_context_switch)(struct task_struct *prev);
16882 void (*end_context_switch)(struct task_struct *next);
16883 -};
16884 +} __no_const;
16885
16886 struct pv_irq_ops {
16887 /*
16888 @@ -223,7 +223,7 @@ struct pv_apic_ops {
16889 unsigned long start_eip,
16890 unsigned long start_esp);
16891 #endif
16892 -};
16893 +} __no_const;
16894
16895 struct pv_mmu_ops {
16896 unsigned long (*read_cr2)(void);
16897 @@ -313,6 +313,7 @@ struct pv_mmu_ops {
16898 struct paravirt_callee_save make_pud;
16899
16900 void (*set_pgd)(pgd_t *pudp, pgd_t pgdval);
16901 + void (*set_pgd_batched)(pgd_t *pudp, pgd_t pgdval);
16902 #endif /* PAGETABLE_LEVELS == 4 */
16903 #endif /* PAGETABLE_LEVELS >= 3 */
16904
16905 @@ -324,6 +325,12 @@ struct pv_mmu_ops {
16906 an mfn. We can tell which is which from the index. */
16907 void (*set_fixmap)(unsigned /* enum fixed_addresses */ idx,
16908 phys_addr_t phys, pgprot_t flags);
16909 +
16910 +#ifdef CONFIG_PAX_KERNEXEC
16911 + unsigned long (*pax_open_kernel)(void);
16912 + unsigned long (*pax_close_kernel)(void);
16913 +#endif
16914 +
16915 };
16916
16917 struct arch_spinlock;
16918 diff --git a/arch/x86/include/asm/pgalloc.h b/arch/x86/include/asm/pgalloc.h
16919 index b4389a4..7024269 100644
16920 --- a/arch/x86/include/asm/pgalloc.h
16921 +++ b/arch/x86/include/asm/pgalloc.h
16922 @@ -63,6 +63,13 @@ static inline void pmd_populate_kernel(struct mm_struct *mm,
16923 pmd_t *pmd, pte_t *pte)
16924 {
16925 paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16926 + set_pmd(pmd, __pmd(__pa(pte) | _KERNPG_TABLE));
16927 +}
16928 +
16929 +static inline void pmd_populate_user(struct mm_struct *mm,
16930 + pmd_t *pmd, pte_t *pte)
16931 +{
16932 + paravirt_alloc_pte(mm, __pa(pte) >> PAGE_SHIFT);
16933 set_pmd(pmd, __pmd(__pa(pte) | _PAGE_TABLE));
16934 }
16935
16936 @@ -99,12 +106,22 @@ static inline void __pmd_free_tlb(struct mmu_gather *tlb, pmd_t *pmd,
16937
16938 #ifdef CONFIG_X86_PAE
16939 extern void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd);
16940 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
16941 +{
16942 + pud_populate(mm, pudp, pmd);
16943 +}
16944 #else /* !CONFIG_X86_PAE */
16945 static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16946 {
16947 paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16948 set_pud(pud, __pud(_PAGE_TABLE | __pa(pmd)));
16949 }
16950 +
16951 +static inline void pud_populate_kernel(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
16952 +{
16953 + paravirt_alloc_pmd(mm, __pa(pmd) >> PAGE_SHIFT);
16954 + set_pud(pud, __pud(_KERNPG_TABLE | __pa(pmd)));
16955 +}
16956 #endif /* CONFIG_X86_PAE */
16957
16958 #if PAGETABLE_LEVELS > 3
16959 @@ -114,6 +131,12 @@ static inline void pgd_populate(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16960 set_pgd(pgd, __pgd(_PAGE_TABLE | __pa(pud)));
16961 }
16962
16963 +static inline void pgd_populate_kernel(struct mm_struct *mm, pgd_t *pgd, pud_t *pud)
16964 +{
16965 + paravirt_alloc_pud(mm, __pa(pud) >> PAGE_SHIFT);
16966 + set_pgd(pgd, __pgd(_KERNPG_TABLE | __pa(pud)));
16967 +}
16968 +
16969 static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long addr)
16970 {
16971 return (pud_t *)get_zeroed_page(GFP_KERNEL|__GFP_REPEAT);
16972 diff --git a/arch/x86/include/asm/pgtable-2level.h b/arch/x86/include/asm/pgtable-2level.h
16973 index 3bf2dd0..23d2a9f 100644
16974 --- a/arch/x86/include/asm/pgtable-2level.h
16975 +++ b/arch/x86/include/asm/pgtable-2level.h
16976 @@ -18,7 +18,9 @@ static inline void native_set_pte(pte_t *ptep , pte_t pte)
16977
16978 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16979 {
16980 + pax_open_kernel();
16981 *pmdp = pmd;
16982 + pax_close_kernel();
16983 }
16984
16985 static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16986 diff --git a/arch/x86/include/asm/pgtable-3level.h b/arch/x86/include/asm/pgtable-3level.h
16987 index 81bb91b..9392125 100644
16988 --- a/arch/x86/include/asm/pgtable-3level.h
16989 +++ b/arch/x86/include/asm/pgtable-3level.h
16990 @@ -92,12 +92,16 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
16991
16992 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
16993 {
16994 + pax_open_kernel();
16995 set_64bit((unsigned long long *)(pmdp), native_pmd_val(pmd));
16996 + pax_close_kernel();
16997 }
16998
16999 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17000 {
17001 + pax_open_kernel();
17002 set_64bit((unsigned long long *)(pudp), native_pud_val(pud));
17003 + pax_close_kernel();
17004 }
17005
17006 /*
17007 diff --git a/arch/x86/include/asm/pgtable.h b/arch/x86/include/asm/pgtable.h
17008 index bbc8b12..f228861 100644
17009 --- a/arch/x86/include/asm/pgtable.h
17010 +++ b/arch/x86/include/asm/pgtable.h
17011 @@ -45,6 +45,7 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17012
17013 #ifndef __PAGETABLE_PUD_FOLDED
17014 #define set_pgd(pgdp, pgd) native_set_pgd(pgdp, pgd)
17015 +#define set_pgd_batched(pgdp, pgd) native_set_pgd_batched(pgdp, pgd)
17016 #define pgd_clear(pgd) native_pgd_clear(pgd)
17017 #endif
17018
17019 @@ -82,12 +83,51 @@ extern struct mm_struct *pgd_page_get_mm(struct page *page);
17020
17021 #define arch_end_context_switch(prev) do {} while(0)
17022
17023 +#define pax_open_kernel() native_pax_open_kernel()
17024 +#define pax_close_kernel() native_pax_close_kernel()
17025 #endif /* CONFIG_PARAVIRT */
17026
17027 +#define __HAVE_ARCH_PAX_OPEN_KERNEL
17028 +#define __HAVE_ARCH_PAX_CLOSE_KERNEL
17029 +
17030 +#ifdef CONFIG_PAX_KERNEXEC
17031 +static inline unsigned long native_pax_open_kernel(void)
17032 +{
17033 + unsigned long cr0;
17034 +
17035 + preempt_disable();
17036 + barrier();
17037 + cr0 = read_cr0() ^ X86_CR0_WP;
17038 + BUG_ON(cr0 & X86_CR0_WP);
17039 + write_cr0(cr0);
17040 + return cr0 ^ X86_CR0_WP;
17041 +}
17042 +
17043 +static inline unsigned long native_pax_close_kernel(void)
17044 +{
17045 + unsigned long cr0;
17046 +
17047 + cr0 = read_cr0() ^ X86_CR0_WP;
17048 + BUG_ON(!(cr0 & X86_CR0_WP));
17049 + write_cr0(cr0);
17050 + barrier();
17051 + preempt_enable_no_resched();
17052 + return cr0 ^ X86_CR0_WP;
17053 +}
17054 +#else
17055 +static inline unsigned long native_pax_open_kernel(void) { return 0; }
17056 +static inline unsigned long native_pax_close_kernel(void) { return 0; }
17057 +#endif
17058 +
17059 /*
17060 * The following only work if pte_present() is true.
17061 * Undefined behaviour if not..
17062 */
17063 +static inline int pte_user(pte_t pte)
17064 +{
17065 + return pte_val(pte) & _PAGE_USER;
17066 +}
17067 +
17068 static inline int pte_dirty(pte_t pte)
17069 {
17070 return pte_flags(pte) & _PAGE_DIRTY;
17071 @@ -148,6 +188,11 @@ static inline unsigned long pud_pfn(pud_t pud)
17072 return (pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT;
17073 }
17074
17075 +static inline unsigned long pgd_pfn(pgd_t pgd)
17076 +{
17077 + return (pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT;
17078 +}
17079 +
17080 #define pte_page(pte) pfn_to_page(pte_pfn(pte))
17081
17082 static inline int pmd_large(pmd_t pte)
17083 @@ -201,9 +246,29 @@ static inline pte_t pte_wrprotect(pte_t pte)
17084 return pte_clear_flags(pte, _PAGE_RW);
17085 }
17086
17087 +static inline pte_t pte_mkread(pte_t pte)
17088 +{
17089 + return __pte(pte_val(pte) | _PAGE_USER);
17090 +}
17091 +
17092 static inline pte_t pte_mkexec(pte_t pte)
17093 {
17094 - return pte_clear_flags(pte, _PAGE_NX);
17095 +#ifdef CONFIG_X86_PAE
17096 + if (__supported_pte_mask & _PAGE_NX)
17097 + return pte_clear_flags(pte, _PAGE_NX);
17098 + else
17099 +#endif
17100 + return pte_set_flags(pte, _PAGE_USER);
17101 +}
17102 +
17103 +static inline pte_t pte_exprotect(pte_t pte)
17104 +{
17105 +#ifdef CONFIG_X86_PAE
17106 + if (__supported_pte_mask & _PAGE_NX)
17107 + return pte_set_flags(pte, _PAGE_NX);
17108 + else
17109 +#endif
17110 + return pte_clear_flags(pte, _PAGE_USER);
17111 }
17112
17113 static inline pte_t pte_mkdirty(pte_t pte)
17114 @@ -430,6 +495,16 @@ pte_t *populate_extra_pte(unsigned long vaddr);
17115 #endif
17116
17117 #ifndef __ASSEMBLY__
17118 +
17119 +#ifdef CONFIG_PAX_PER_CPU_PGD
17120 +extern pgd_t cpu_pgd[NR_CPUS][2][PTRS_PER_PGD];
17121 +enum cpu_pgd_type {kernel = 0, user = 1};
17122 +static inline pgd_t *get_cpu_pgd(unsigned int cpu, enum cpu_pgd_type type)
17123 +{
17124 + return cpu_pgd[cpu][type];
17125 +}
17126 +#endif
17127 +
17128 #include <linux/mm_types.h>
17129 #include <linux/mmdebug.h>
17130 #include <linux/log2.h>
17131 @@ -570,7 +645,7 @@ static inline unsigned long pud_page_vaddr(pud_t pud)
17132 * Currently stuck as a macro due to indirect forward reference to
17133 * linux/mmzone.h's __section_mem_map_addr() definition:
17134 */
17135 -#define pud_page(pud) pfn_to_page(pud_val(pud) >> PAGE_SHIFT)
17136 +#define pud_page(pud) pfn_to_page((pud_val(pud) & PTE_PFN_MASK) >> PAGE_SHIFT)
17137
17138 /* Find an entry in the second-level page table.. */
17139 static inline pmd_t *pmd_offset(pud_t *pud, unsigned long address)
17140 @@ -610,7 +685,7 @@ static inline unsigned long pgd_page_vaddr(pgd_t pgd)
17141 * Currently stuck as a macro due to indirect forward reference to
17142 * linux/mmzone.h's __section_mem_map_addr() definition:
17143 */
17144 -#define pgd_page(pgd) pfn_to_page(pgd_val(pgd) >> PAGE_SHIFT)
17145 +#define pgd_page(pgd) pfn_to_page((pgd_val(pgd) & PTE_PFN_MASK) >> PAGE_SHIFT)
17146
17147 /* to find an entry in a page-table-directory. */
17148 static inline unsigned long pud_index(unsigned long address)
17149 @@ -625,7 +700,7 @@ static inline pud_t *pud_offset(pgd_t *pgd, unsigned long address)
17150
17151 static inline int pgd_bad(pgd_t pgd)
17152 {
17153 - return (pgd_flags(pgd) & ~_PAGE_USER) != _KERNPG_TABLE;
17154 + return (pgd_flags(pgd) & ~(_PAGE_USER | _PAGE_NX)) != _KERNPG_TABLE;
17155 }
17156
17157 static inline int pgd_none(pgd_t pgd)
17158 @@ -648,7 +723,12 @@ static inline int pgd_none(pgd_t pgd)
17159 * pgd_offset() returns a (pgd_t *)
17160 * pgd_index() is used get the offset into the pgd page's array of pgd_t's;
17161 */
17162 -#define pgd_offset(mm, address) ((mm)->pgd + pgd_index((address)))
17163 +#define pgd_offset(mm, address) ((mm)->pgd + pgd_index(address))
17164 +
17165 +#ifdef CONFIG_PAX_PER_CPU_PGD
17166 +#define pgd_offset_cpu(cpu, type, address) (get_cpu_pgd(cpu, type) + pgd_index(address))
17167 +#endif
17168 +
17169 /*
17170 * a shortcut which implies the use of the kernel's pgd, instead
17171 * of a process's
17172 @@ -659,6 +739,23 @@ static inline int pgd_none(pgd_t pgd)
17173 #define KERNEL_PGD_BOUNDARY pgd_index(PAGE_OFFSET)
17174 #define KERNEL_PGD_PTRS (PTRS_PER_PGD - KERNEL_PGD_BOUNDARY)
17175
17176 +#ifdef CONFIG_X86_32
17177 +#define USER_PGD_PTRS KERNEL_PGD_BOUNDARY
17178 +#else
17179 +#define TASK_SIZE_MAX_SHIFT CONFIG_TASK_SIZE_MAX_SHIFT
17180 +#define USER_PGD_PTRS (_AC(1,UL) << (TASK_SIZE_MAX_SHIFT - PGDIR_SHIFT))
17181 +
17182 +#ifdef CONFIG_PAX_MEMORY_UDEREF
17183 +#ifdef __ASSEMBLY__
17184 +#define pax_user_shadow_base pax_user_shadow_base(%rip)
17185 +#else
17186 +extern unsigned long pax_user_shadow_base;
17187 +extern pgdval_t clone_pgd_mask;
17188 +#endif
17189 +#endif
17190 +
17191 +#endif
17192 +
17193 #ifndef __ASSEMBLY__
17194
17195 extern int direct_gbpages;
17196 @@ -825,11 +922,24 @@ static inline void pmdp_set_wrprotect(struct mm_struct *mm,
17197 * dst and src can be on the same page, but the range must not overlap,
17198 * and must not cross a page boundary.
17199 */
17200 -static inline void clone_pgd_range(pgd_t *dst, pgd_t *src, int count)
17201 +static inline void clone_pgd_range(pgd_t *dst, const pgd_t *src, int count)
17202 {
17203 - memcpy(dst, src, count * sizeof(pgd_t));
17204 + pax_open_kernel();
17205 + while (count--)
17206 + *dst++ = *src++;
17207 + pax_close_kernel();
17208 }
17209
17210 +#ifdef CONFIG_PAX_PER_CPU_PGD
17211 +extern void __clone_user_pgds(pgd_t *dst, const pgd_t *src);
17212 +#endif
17213 +
17214 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
17215 +extern void __shadow_user_pgds(pgd_t *dst, const pgd_t *src);
17216 +#else
17217 +static inline void __shadow_user_pgds(pgd_t *dst, const pgd_t *src) {}
17218 +#endif
17219 +
17220 #define PTE_SHIFT ilog2(PTRS_PER_PTE)
17221 static inline int page_level_shift(enum pg_level level)
17222 {
17223 diff --git a/arch/x86/include/asm/pgtable_32.h b/arch/x86/include/asm/pgtable_32.h
17224 index 9ee3221..b979c6b 100644
17225 --- a/arch/x86/include/asm/pgtable_32.h
17226 +++ b/arch/x86/include/asm/pgtable_32.h
17227 @@ -25,9 +25,6 @@
17228 struct mm_struct;
17229 struct vm_area_struct;
17230
17231 -extern pgd_t swapper_pg_dir[1024];
17232 -extern pgd_t initial_page_table[1024];
17233 -
17234 static inline void pgtable_cache_init(void) { }
17235 static inline void check_pgt_cache(void) { }
17236 void paging_init(void);
17237 @@ -48,6 +45,12 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17238 # include <asm/pgtable-2level.h>
17239 #endif
17240
17241 +extern pgd_t swapper_pg_dir[PTRS_PER_PGD];
17242 +extern pgd_t initial_page_table[PTRS_PER_PGD];
17243 +#ifdef CONFIG_X86_PAE
17244 +extern pmd_t swapper_pm_dir[PTRS_PER_PGD][PTRS_PER_PMD];
17245 +#endif
17246 +
17247 #if defined(CONFIG_HIGHPTE)
17248 #define pte_offset_map(dir, address) \
17249 ((pte_t *)kmap_atomic(pmd_page(*(dir))) + \
17250 @@ -62,12 +65,17 @@ extern void set_pmd_pfn(unsigned long, unsigned long, pgprot_t);
17251 /* Clear a kernel PTE and flush it from the TLB */
17252 #define kpte_clear_flush(ptep, vaddr) \
17253 do { \
17254 + pax_open_kernel(); \
17255 pte_clear(&init_mm, (vaddr), (ptep)); \
17256 + pax_close_kernel(); \
17257 __flush_tlb_one((vaddr)); \
17258 } while (0)
17259
17260 #endif /* !__ASSEMBLY__ */
17261
17262 +#define HAVE_ARCH_UNMAPPED_AREA
17263 +#define HAVE_ARCH_UNMAPPED_AREA_TOPDOWN
17264 +
17265 /*
17266 * kern_addr_valid() is (1) for FLATMEM and (0) for
17267 * SPARSEMEM and DISCONTIGMEM
17268 diff --git a/arch/x86/include/asm/pgtable_32_types.h b/arch/x86/include/asm/pgtable_32_types.h
17269 index ed5903b..c7fe163 100644
17270 --- a/arch/x86/include/asm/pgtable_32_types.h
17271 +++ b/arch/x86/include/asm/pgtable_32_types.h
17272 @@ -8,7 +8,7 @@
17273 */
17274 #ifdef CONFIG_X86_PAE
17275 # include <asm/pgtable-3level_types.h>
17276 -# define PMD_SIZE (1UL << PMD_SHIFT)
17277 +# define PMD_SIZE (_AC(1, UL) << PMD_SHIFT)
17278 # define PMD_MASK (~(PMD_SIZE - 1))
17279 #else
17280 # include <asm/pgtable-2level_types.h>
17281 @@ -46,6 +46,19 @@ extern bool __vmalloc_start_set; /* set once high_memory is set */
17282 # define VMALLOC_END (FIXADDR_START - 2 * PAGE_SIZE)
17283 #endif
17284
17285 +#ifdef CONFIG_PAX_KERNEXEC
17286 +#ifndef __ASSEMBLY__
17287 +extern unsigned char MODULES_EXEC_VADDR[];
17288 +extern unsigned char MODULES_EXEC_END[];
17289 +#endif
17290 +#include <asm/boot.h>
17291 +#define ktla_ktva(addr) (addr + LOAD_PHYSICAL_ADDR + PAGE_OFFSET)
17292 +#define ktva_ktla(addr) (addr - LOAD_PHYSICAL_ADDR - PAGE_OFFSET)
17293 +#else
17294 +#define ktla_ktva(addr) (addr)
17295 +#define ktva_ktla(addr) (addr)
17296 +#endif
17297 +
17298 #define MODULES_VADDR VMALLOC_START
17299 #define MODULES_END VMALLOC_END
17300 #define MODULES_LEN (MODULES_VADDR - MODULES_END)
17301 diff --git a/arch/x86/include/asm/pgtable_64.h b/arch/x86/include/asm/pgtable_64.h
17302 index e22c1db..23a625a 100644
17303 --- a/arch/x86/include/asm/pgtable_64.h
17304 +++ b/arch/x86/include/asm/pgtable_64.h
17305 @@ -16,10 +16,14 @@
17306
17307 extern pud_t level3_kernel_pgt[512];
17308 extern pud_t level3_ident_pgt[512];
17309 +extern pud_t level3_vmalloc_start_pgt[512];
17310 +extern pud_t level3_vmalloc_end_pgt[512];
17311 +extern pud_t level3_vmemmap_pgt[512];
17312 +extern pud_t level2_vmemmap_pgt[512];
17313 extern pmd_t level2_kernel_pgt[512];
17314 extern pmd_t level2_fixmap_pgt[512];
17315 -extern pmd_t level2_ident_pgt[512];
17316 -extern pgd_t init_level4_pgt[];
17317 +extern pmd_t level2_ident_pgt[512*2];
17318 +extern pgd_t init_level4_pgt[512];
17319
17320 #define swapper_pg_dir init_level4_pgt
17321
17322 @@ -61,7 +65,9 @@ static inline void native_set_pte_atomic(pte_t *ptep, pte_t pte)
17323
17324 static inline void native_set_pmd(pmd_t *pmdp, pmd_t pmd)
17325 {
17326 + pax_open_kernel();
17327 *pmdp = pmd;
17328 + pax_close_kernel();
17329 }
17330
17331 static inline void native_pmd_clear(pmd_t *pmd)
17332 @@ -97,7 +103,9 @@ static inline pmd_t native_pmdp_get_and_clear(pmd_t *xp)
17333
17334 static inline void native_set_pud(pud_t *pudp, pud_t pud)
17335 {
17336 + pax_open_kernel();
17337 *pudp = pud;
17338 + pax_close_kernel();
17339 }
17340
17341 static inline void native_pud_clear(pud_t *pud)
17342 @@ -107,6 +115,13 @@ static inline void native_pud_clear(pud_t *pud)
17343
17344 static inline void native_set_pgd(pgd_t *pgdp, pgd_t pgd)
17345 {
17346 + pax_open_kernel();
17347 + *pgdp = pgd;
17348 + pax_close_kernel();
17349 +}
17350 +
17351 +static inline void native_set_pgd_batched(pgd_t *pgdp, pgd_t pgd)
17352 +{
17353 *pgdp = pgd;
17354 }
17355
17356 diff --git a/arch/x86/include/asm/pgtable_64_types.h b/arch/x86/include/asm/pgtable_64_types.h
17357 index 2d88344..4679fc3 100644
17358 --- a/arch/x86/include/asm/pgtable_64_types.h
17359 +++ b/arch/x86/include/asm/pgtable_64_types.h
17360 @@ -61,6 +61,11 @@ typedef struct { pteval_t pte; } pte_t;
17361 #define MODULES_VADDR _AC(0xffffffffa0000000, UL)
17362 #define MODULES_END _AC(0xffffffffff000000, UL)
17363 #define MODULES_LEN (MODULES_END - MODULES_VADDR)
17364 +#define MODULES_EXEC_VADDR MODULES_VADDR
17365 +#define MODULES_EXEC_END MODULES_END
17366 +
17367 +#define ktla_ktva(addr) (addr)
17368 +#define ktva_ktla(addr) (addr)
17369
17370 #define EARLY_DYNAMIC_PAGE_TABLES 64
17371
17372 diff --git a/arch/x86/include/asm/pgtable_types.h b/arch/x86/include/asm/pgtable_types.h
17373 index 0ecac25..306c276 100644
17374 --- a/arch/x86/include/asm/pgtable_types.h
17375 +++ b/arch/x86/include/asm/pgtable_types.h
17376 @@ -16,13 +16,12 @@
17377 #define _PAGE_BIT_PSE 7 /* 4 MB (or 2MB) page */
17378 #define _PAGE_BIT_PAT 7 /* on 4KB pages */
17379 #define _PAGE_BIT_GLOBAL 8 /* Global TLB entry PPro+ */
17380 -#define _PAGE_BIT_UNUSED1 9 /* available for programmer */
17381 +#define _PAGE_BIT_SPECIAL 9 /* special mappings, no associated struct page */
17382 #define _PAGE_BIT_IOMAP 10 /* flag used to indicate IO mapping */
17383 #define _PAGE_BIT_HIDDEN 11 /* hidden by kmemcheck */
17384 #define _PAGE_BIT_PAT_LARGE 12 /* On 2MB or 1GB pages */
17385 -#define _PAGE_BIT_SPECIAL _PAGE_BIT_UNUSED1
17386 -#define _PAGE_BIT_CPA_TEST _PAGE_BIT_UNUSED1
17387 -#define _PAGE_BIT_SPLITTING _PAGE_BIT_UNUSED1 /* only valid on a PSE pmd */
17388 +#define _PAGE_BIT_CPA_TEST _PAGE_BIT_SPECIAL
17389 +#define _PAGE_BIT_SPLITTING _PAGE_BIT_SPECIAL /* only valid on a PSE pmd */
17390 #define _PAGE_BIT_NX 63 /* No execute: only valid after cpuid check */
17391
17392 /* If _PAGE_BIT_PRESENT is clear, we use these: */
17393 @@ -40,7 +39,6 @@
17394 #define _PAGE_DIRTY (_AT(pteval_t, 1) << _PAGE_BIT_DIRTY)
17395 #define _PAGE_PSE (_AT(pteval_t, 1) << _PAGE_BIT_PSE)
17396 #define _PAGE_GLOBAL (_AT(pteval_t, 1) << _PAGE_BIT_GLOBAL)
17397 -#define _PAGE_UNUSED1 (_AT(pteval_t, 1) << _PAGE_BIT_UNUSED1)
17398 #define _PAGE_IOMAP (_AT(pteval_t, 1) << _PAGE_BIT_IOMAP)
17399 #define _PAGE_PAT (_AT(pteval_t, 1) << _PAGE_BIT_PAT)
17400 #define _PAGE_PAT_LARGE (_AT(pteval_t, 1) << _PAGE_BIT_PAT_LARGE)
17401 @@ -87,8 +85,10 @@
17402
17403 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
17404 #define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_NX)
17405 -#else
17406 +#elif defined(CONFIG_KMEMCHECK)
17407 #define _PAGE_NX (_AT(pteval_t, 0))
17408 +#else
17409 +#define _PAGE_NX (_AT(pteval_t, 1) << _PAGE_BIT_HIDDEN)
17410 #endif
17411
17412 #define _PAGE_FILE (_AT(pteval_t, 1) << _PAGE_BIT_FILE)
17413 @@ -146,6 +146,9 @@
17414 #define PAGE_READONLY_EXEC __pgprot(_PAGE_PRESENT | _PAGE_USER | \
17415 _PAGE_ACCESSED)
17416
17417 +#define PAGE_READONLY_NOEXEC PAGE_READONLY
17418 +#define PAGE_SHARED_NOEXEC PAGE_SHARED
17419 +
17420 #define __PAGE_KERNEL_EXEC \
17421 (_PAGE_PRESENT | _PAGE_RW | _PAGE_DIRTY | _PAGE_ACCESSED | _PAGE_GLOBAL)
17422 #define __PAGE_KERNEL (__PAGE_KERNEL_EXEC | _PAGE_NX)
17423 @@ -156,7 +159,7 @@
17424 #define __PAGE_KERNEL_WC (__PAGE_KERNEL | _PAGE_CACHE_WC)
17425 #define __PAGE_KERNEL_NOCACHE (__PAGE_KERNEL | _PAGE_PCD | _PAGE_PWT)
17426 #define __PAGE_KERNEL_UC_MINUS (__PAGE_KERNEL | _PAGE_PCD)
17427 -#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RX | _PAGE_USER)
17428 +#define __PAGE_KERNEL_VSYSCALL (__PAGE_KERNEL_RO | _PAGE_USER)
17429 #define __PAGE_KERNEL_VVAR (__PAGE_KERNEL_RO | _PAGE_USER)
17430 #define __PAGE_KERNEL_VVAR_NOCACHE (__PAGE_KERNEL_VVAR | _PAGE_PCD | _PAGE_PWT)
17431 #define __PAGE_KERNEL_LARGE (__PAGE_KERNEL | _PAGE_PSE)
17432 @@ -218,8 +221,8 @@
17433 * bits are combined, this will alow user to access the high address mapped
17434 * VDSO in the presence of CONFIG_COMPAT_VDSO
17435 */
17436 -#define PTE_IDENT_ATTR 0x003 /* PRESENT+RW */
17437 -#define PDE_IDENT_ATTR 0x067 /* PRESENT+RW+USER+DIRTY+ACCESSED */
17438 +#define PTE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
17439 +#define PDE_IDENT_ATTR 0x063 /* PRESENT+RW+DIRTY+ACCESSED */
17440 #define PGD_IDENT_ATTR 0x001 /* PRESENT (no other attributes) */
17441 #endif
17442
17443 @@ -257,7 +260,17 @@ static inline pgdval_t pgd_flags(pgd_t pgd)
17444 {
17445 return native_pgd_val(pgd) & PTE_FLAGS_MASK;
17446 }
17447 +#endif
17448
17449 +#if PAGETABLE_LEVELS == 3
17450 +#include <asm-generic/pgtable-nopud.h>
17451 +#endif
17452 +
17453 +#if PAGETABLE_LEVELS == 2
17454 +#include <asm-generic/pgtable-nopmd.h>
17455 +#endif
17456 +
17457 +#ifndef __ASSEMBLY__
17458 #if PAGETABLE_LEVELS > 3
17459 typedef struct { pudval_t pud; } pud_t;
17460
17461 @@ -271,8 +284,6 @@ static inline pudval_t native_pud_val(pud_t pud)
17462 return pud.pud;
17463 }
17464 #else
17465 -#include <asm-generic/pgtable-nopud.h>
17466 -
17467 static inline pudval_t native_pud_val(pud_t pud)
17468 {
17469 return native_pgd_val(pud.pgd);
17470 @@ -292,8 +303,6 @@ static inline pmdval_t native_pmd_val(pmd_t pmd)
17471 return pmd.pmd;
17472 }
17473 #else
17474 -#include <asm-generic/pgtable-nopmd.h>
17475 -
17476 static inline pmdval_t native_pmd_val(pmd_t pmd)
17477 {
17478 return native_pgd_val(pmd.pud.pgd);
17479 @@ -333,7 +342,6 @@ typedef struct page *pgtable_t;
17480
17481 extern pteval_t __supported_pte_mask;
17482 extern void set_nx(void);
17483 -extern int nx_enabled;
17484
17485 #define pgprot_writecombine pgprot_writecombine
17486 extern pgprot_t pgprot_writecombine(pgprot_t prot);
17487 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
17488 index 987c75e..2723054 100644
17489 --- a/arch/x86/include/asm/processor.h
17490 +++ b/arch/x86/include/asm/processor.h
17491 @@ -199,9 +199,21 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
17492 : "memory");
17493 }
17494
17495 +/* invpcid (%rdx),%rax */
17496 +#define __ASM_INVPCID ".byte 0x66,0x0f,0x38,0x82,0x02"
17497 +
17498 +#define INVPCID_SINGLE_ADDRESS 0UL
17499 +#define INVPCID_SINGLE_CONTEXT 1UL
17500 +#define INVPCID_ALL_GLOBAL 2UL
17501 +#define INVPCID_ALL_MONGLOBAL 3UL
17502 +
17503 +#define PCID_KERNEL 0UL
17504 +#define PCID_USER 1UL
17505 +#define PCID_NOFLUSH (1UL << 63)
17506 +
17507 static inline void load_cr3(pgd_t *pgdir)
17508 {
17509 - write_cr3(__pa(pgdir));
17510 + write_cr3(__pa(pgdir) | PCID_KERNEL);
17511 }
17512
17513 #ifdef CONFIG_X86_32
17514 @@ -283,7 +295,7 @@ struct tss_struct {
17515
17516 } ____cacheline_aligned;
17517
17518 -DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss);
17519 +extern struct tss_struct init_tss[NR_CPUS];
17520
17521 /*
17522 * Save the original ist values for checking stack pointers during debugging
17523 @@ -453,6 +465,7 @@ struct thread_struct {
17524 unsigned short ds;
17525 unsigned short fsindex;
17526 unsigned short gsindex;
17527 + unsigned short ss;
17528 #endif
17529 #ifdef CONFIG_X86_32
17530 unsigned long ip;
17531 @@ -553,29 +566,8 @@ static inline void load_sp0(struct tss_struct *tss,
17532 extern unsigned long mmu_cr4_features;
17533 extern u32 *trampoline_cr4_features;
17534
17535 -static inline void set_in_cr4(unsigned long mask)
17536 -{
17537 - unsigned long cr4;
17538 -
17539 - mmu_cr4_features |= mask;
17540 - if (trampoline_cr4_features)
17541 - *trampoline_cr4_features = mmu_cr4_features;
17542 - cr4 = read_cr4();
17543 - cr4 |= mask;
17544 - write_cr4(cr4);
17545 -}
17546 -
17547 -static inline void clear_in_cr4(unsigned long mask)
17548 -{
17549 - unsigned long cr4;
17550 -
17551 - mmu_cr4_features &= ~mask;
17552 - if (trampoline_cr4_features)
17553 - *trampoline_cr4_features = mmu_cr4_features;
17554 - cr4 = read_cr4();
17555 - cr4 &= ~mask;
17556 - write_cr4(cr4);
17557 -}
17558 +extern void set_in_cr4(unsigned long mask);
17559 +extern void clear_in_cr4(unsigned long mask);
17560
17561 typedef struct {
17562 unsigned long seg;
17563 @@ -824,11 +816,18 @@ static inline void spin_lock_prefetch(const void *x)
17564 */
17565 #define TASK_SIZE PAGE_OFFSET
17566 #define TASK_SIZE_MAX TASK_SIZE
17567 +
17568 +#ifdef CONFIG_PAX_SEGMEXEC
17569 +#define SEGMEXEC_TASK_SIZE (TASK_SIZE / 2)
17570 +#define STACK_TOP ((current->mm->pax_flags & MF_PAX_SEGMEXEC)?SEGMEXEC_TASK_SIZE:TASK_SIZE)
17571 +#else
17572 #define STACK_TOP TASK_SIZE
17573 -#define STACK_TOP_MAX STACK_TOP
17574 +#endif
17575 +
17576 +#define STACK_TOP_MAX TASK_SIZE
17577
17578 #define INIT_THREAD { \
17579 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17580 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17581 .vm86_info = NULL, \
17582 .sysenter_cs = __KERNEL_CS, \
17583 .io_bitmap_ptr = NULL, \
17584 @@ -842,7 +841,7 @@ static inline void spin_lock_prefetch(const void *x)
17585 */
17586 #define INIT_TSS { \
17587 .x86_tss = { \
17588 - .sp0 = sizeof(init_stack) + (long)&init_stack, \
17589 + .sp0 = sizeof(init_stack) + (long)&init_stack - 8, \
17590 .ss0 = __KERNEL_DS, \
17591 .ss1 = __KERNEL_CS, \
17592 .io_bitmap_base = INVALID_IO_BITMAP_OFFSET, \
17593 @@ -853,11 +852,7 @@ static inline void spin_lock_prefetch(const void *x)
17594 extern unsigned long thread_saved_pc(struct task_struct *tsk);
17595
17596 #define THREAD_SIZE_LONGS (THREAD_SIZE/sizeof(unsigned long))
17597 -#define KSTK_TOP(info) \
17598 -({ \
17599 - unsigned long *__ptr = (unsigned long *)(info); \
17600 - (unsigned long)(&__ptr[THREAD_SIZE_LONGS]); \
17601 -})
17602 +#define KSTK_TOP(info) ((container_of(info, struct task_struct, tinfo))->thread.sp0)
17603
17604 /*
17605 * The below -8 is to reserve 8 bytes on top of the ring0 stack.
17606 @@ -872,7 +867,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17607 #define task_pt_regs(task) \
17608 ({ \
17609 struct pt_regs *__regs__; \
17610 - __regs__ = (struct pt_regs *)(KSTK_TOP(task_stack_page(task))-8); \
17611 + __regs__ = (struct pt_regs *)((task)->thread.sp0); \
17612 __regs__ - 1; \
17613 })
17614
17615 @@ -882,13 +877,13 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17616 /*
17617 * User space process size. 47bits minus one guard page.
17618 */
17619 -#define TASK_SIZE_MAX ((1UL << 47) - PAGE_SIZE)
17620 +#define TASK_SIZE_MAX ((1UL << TASK_SIZE_MAX_SHIFT) - PAGE_SIZE)
17621
17622 /* This decides where the kernel will search for a free chunk of vm
17623 * space during mmap's.
17624 */
17625 #define IA32_PAGE_OFFSET ((current->personality & ADDR_LIMIT_3GB) ? \
17626 - 0xc0000000 : 0xFFFFe000)
17627 + 0xc0000000 : 0xFFFFf000)
17628
17629 #define TASK_SIZE (test_thread_flag(TIF_ADDR32) ? \
17630 IA32_PAGE_OFFSET : TASK_SIZE_MAX)
17631 @@ -899,11 +894,11 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk);
17632 #define STACK_TOP_MAX TASK_SIZE_MAX
17633
17634 #define INIT_THREAD { \
17635 - .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17636 + .sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17637 }
17638
17639 #define INIT_TSS { \
17640 - .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) \
17641 + .x86_tss.sp0 = (unsigned long)&init_stack + sizeof(init_stack) - 16 \
17642 }
17643
17644 /*
17645 @@ -931,6 +926,10 @@ extern void start_thread(struct pt_regs *regs, unsigned long new_ip,
17646 */
17647 #define TASK_UNMAPPED_BASE (PAGE_ALIGN(TASK_SIZE / 3))
17648
17649 +#ifdef CONFIG_PAX_SEGMEXEC
17650 +#define SEGMEXEC_TASK_UNMAPPED_BASE (PAGE_ALIGN(SEGMEXEC_TASK_SIZE / 3))
17651 +#endif
17652 +
17653 #define KSTK_EIP(task) (task_pt_regs(task)->ip)
17654
17655 /* Get/set a process' ability to use the timestamp counter instruction */
17656 @@ -957,7 +956,7 @@ static inline uint32_t hypervisor_cpuid_base(const char *sig, uint32_t leaves)
17657 return 0;
17658 }
17659
17660 -extern unsigned long arch_align_stack(unsigned long sp);
17661 +#define arch_align_stack(x) ((x) & ~0xfUL)
17662 extern void free_init_pages(char *what, unsigned long begin, unsigned long end);
17663
17664 void default_idle(void);
17665 @@ -967,6 +966,6 @@ bool xen_set_default_idle(void);
17666 #define xen_set_default_idle 0
17667 #endif
17668
17669 -void stop_this_cpu(void *dummy);
17670 +void stop_this_cpu(void *dummy) __noreturn;
17671 void df_debug(struct pt_regs *regs, long error_code);
17672 #endif /* _ASM_X86_PROCESSOR_H */
17673 diff --git a/arch/x86/include/asm/ptrace.h b/arch/x86/include/asm/ptrace.h
17674 index 942a086..6c26446 100644
17675 --- a/arch/x86/include/asm/ptrace.h
17676 +++ b/arch/x86/include/asm/ptrace.h
17677 @@ -85,28 +85,29 @@ static inline unsigned long regs_return_value(struct pt_regs *regs)
17678 }
17679
17680 /*
17681 - * user_mode_vm(regs) determines whether a register set came from user mode.
17682 + * user_mode(regs) determines whether a register set came from user mode.
17683 * This is true if V8086 mode was enabled OR if the register set was from
17684 * protected mode with RPL-3 CS value. This tricky test checks that with
17685 * one comparison. Many places in the kernel can bypass this full check
17686 - * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
17687 + * if they have already ruled out V8086 mode, so user_mode_novm(regs) can
17688 + * be used.
17689 */
17690 -static inline int user_mode(struct pt_regs *regs)
17691 +static inline int user_mode_novm(struct pt_regs *regs)
17692 {
17693 #ifdef CONFIG_X86_32
17694 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
17695 #else
17696 - return !!(regs->cs & 3);
17697 + return !!(regs->cs & SEGMENT_RPL_MASK);
17698 #endif
17699 }
17700
17701 -static inline int user_mode_vm(struct pt_regs *regs)
17702 +static inline int user_mode(struct pt_regs *regs)
17703 {
17704 #ifdef CONFIG_X86_32
17705 return ((regs->cs & SEGMENT_RPL_MASK) | (regs->flags & X86_VM_MASK)) >=
17706 USER_RPL;
17707 #else
17708 - return user_mode(regs);
17709 + return user_mode_novm(regs);
17710 #endif
17711 }
17712
17713 @@ -122,15 +123,16 @@ static inline int v8086_mode(struct pt_regs *regs)
17714 #ifdef CONFIG_X86_64
17715 static inline bool user_64bit_mode(struct pt_regs *regs)
17716 {
17717 + unsigned long cs = regs->cs & 0xffff;
17718 #ifndef CONFIG_PARAVIRT
17719 /*
17720 * On non-paravirt systems, this is the only long mode CPL 3
17721 * selector. We do not allow long mode selectors in the LDT.
17722 */
17723 - return regs->cs == __USER_CS;
17724 + return cs == __USER_CS;
17725 #else
17726 /* Headers are too twisted for this to go in paravirt.h. */
17727 - return regs->cs == __USER_CS || regs->cs == pv_info.extra_user_64bit_cs;
17728 + return cs == __USER_CS || cs == pv_info.extra_user_64bit_cs;
17729 #endif
17730 }
17731
17732 @@ -181,9 +183,11 @@ static inline unsigned long regs_get_register(struct pt_regs *regs,
17733 * Traps from the kernel do not save sp and ss.
17734 * Use the helper function to retrieve sp.
17735 */
17736 - if (offset == offsetof(struct pt_regs, sp) &&
17737 - regs->cs == __KERNEL_CS)
17738 - return kernel_stack_pointer(regs);
17739 + if (offset == offsetof(struct pt_regs, sp)) {
17740 + unsigned long cs = regs->cs & 0xffff;
17741 + if (cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS)
17742 + return kernel_stack_pointer(regs);
17743 + }
17744 #endif
17745 return *(unsigned long *)((unsigned long)regs + offset);
17746 }
17747 diff --git a/arch/x86/include/asm/realmode.h b/arch/x86/include/asm/realmode.h
17748 index 9c6b890..5305f53 100644
17749 --- a/arch/x86/include/asm/realmode.h
17750 +++ b/arch/x86/include/asm/realmode.h
17751 @@ -22,16 +22,14 @@ struct real_mode_header {
17752 #endif
17753 /* APM/BIOS reboot */
17754 u32 machine_real_restart_asm;
17755 -#ifdef CONFIG_X86_64
17756 u32 machine_real_restart_seg;
17757 -#endif
17758 };
17759
17760 /* This must match data at trampoline_32/64.S */
17761 struct trampoline_header {
17762 #ifdef CONFIG_X86_32
17763 u32 start;
17764 - u16 gdt_pad;
17765 + u16 boot_cs;
17766 u16 gdt_limit;
17767 u32 gdt_base;
17768 #else
17769 diff --git a/arch/x86/include/asm/reboot.h b/arch/x86/include/asm/reboot.h
17770 index a82c4f1..ac45053 100644
17771 --- a/arch/x86/include/asm/reboot.h
17772 +++ b/arch/x86/include/asm/reboot.h
17773 @@ -6,13 +6,13 @@
17774 struct pt_regs;
17775
17776 struct machine_ops {
17777 - void (*restart)(char *cmd);
17778 - void (*halt)(void);
17779 - void (*power_off)(void);
17780 + void (* __noreturn restart)(char *cmd);
17781 + void (* __noreturn halt)(void);
17782 + void (* __noreturn power_off)(void);
17783 void (*shutdown)(void);
17784 void (*crash_shutdown)(struct pt_regs *);
17785 - void (*emergency_restart)(void);
17786 -};
17787 + void (* __noreturn emergency_restart)(void);
17788 +} __no_const;
17789
17790 extern struct machine_ops machine_ops;
17791
17792 diff --git a/arch/x86/include/asm/rwsem.h b/arch/x86/include/asm/rwsem.h
17793 index cad82c9..2e5c5c1 100644
17794 --- a/arch/x86/include/asm/rwsem.h
17795 +++ b/arch/x86/include/asm/rwsem.h
17796 @@ -64,6 +64,14 @@ static inline void __down_read(struct rw_semaphore *sem)
17797 {
17798 asm volatile("# beginning down_read\n\t"
17799 LOCK_PREFIX _ASM_INC "(%1)\n\t"
17800 +
17801 +#ifdef CONFIG_PAX_REFCOUNT
17802 + "jno 0f\n"
17803 + LOCK_PREFIX _ASM_DEC "(%1)\n"
17804 + "int $4\n0:\n"
17805 + _ASM_EXTABLE(0b, 0b)
17806 +#endif
17807 +
17808 /* adds 0x00000001 */
17809 " jns 1f\n"
17810 " call call_rwsem_down_read_failed\n"
17811 @@ -85,6 +93,14 @@ static inline int __down_read_trylock(struct rw_semaphore *sem)
17812 "1:\n\t"
17813 " mov %1,%2\n\t"
17814 " add %3,%2\n\t"
17815 +
17816 +#ifdef CONFIG_PAX_REFCOUNT
17817 + "jno 0f\n"
17818 + "sub %3,%2\n"
17819 + "int $4\n0:\n"
17820 + _ASM_EXTABLE(0b, 0b)
17821 +#endif
17822 +
17823 " jle 2f\n\t"
17824 LOCK_PREFIX " cmpxchg %2,%0\n\t"
17825 " jnz 1b\n\t"
17826 @@ -104,6 +120,14 @@ static inline void __down_write_nested(struct rw_semaphore *sem, int subclass)
17827 long tmp;
17828 asm volatile("# beginning down_write\n\t"
17829 LOCK_PREFIX " xadd %1,(%2)\n\t"
17830 +
17831 +#ifdef CONFIG_PAX_REFCOUNT
17832 + "jno 0f\n"
17833 + "mov %1,(%2)\n"
17834 + "int $4\n0:\n"
17835 + _ASM_EXTABLE(0b, 0b)
17836 +#endif
17837 +
17838 /* adds 0xffff0001, returns the old value */
17839 " test " __ASM_SEL(%w1,%k1) "," __ASM_SEL(%w1,%k1) "\n\t"
17840 /* was the active mask 0 before? */
17841 @@ -155,6 +179,14 @@ static inline void __up_read(struct rw_semaphore *sem)
17842 long tmp;
17843 asm volatile("# beginning __up_read\n\t"
17844 LOCK_PREFIX " xadd %1,(%2)\n\t"
17845 +
17846 +#ifdef CONFIG_PAX_REFCOUNT
17847 + "jno 0f\n"
17848 + "mov %1,(%2)\n"
17849 + "int $4\n0:\n"
17850 + _ASM_EXTABLE(0b, 0b)
17851 +#endif
17852 +
17853 /* subtracts 1, returns the old value */
17854 " jns 1f\n\t"
17855 " call call_rwsem_wake\n" /* expects old value in %edx */
17856 @@ -173,6 +205,14 @@ static inline void __up_write(struct rw_semaphore *sem)
17857 long tmp;
17858 asm volatile("# beginning __up_write\n\t"
17859 LOCK_PREFIX " xadd %1,(%2)\n\t"
17860 +
17861 +#ifdef CONFIG_PAX_REFCOUNT
17862 + "jno 0f\n"
17863 + "mov %1,(%2)\n"
17864 + "int $4\n0:\n"
17865 + _ASM_EXTABLE(0b, 0b)
17866 +#endif
17867 +
17868 /* subtracts 0xffff0001, returns the old value */
17869 " jns 1f\n\t"
17870 " call call_rwsem_wake\n" /* expects old value in %edx */
17871 @@ -190,6 +230,14 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17872 {
17873 asm volatile("# beginning __downgrade_write\n\t"
17874 LOCK_PREFIX _ASM_ADD "%2,(%1)\n\t"
17875 +
17876 +#ifdef CONFIG_PAX_REFCOUNT
17877 + "jno 0f\n"
17878 + LOCK_PREFIX _ASM_SUB "%2,(%1)\n"
17879 + "int $4\n0:\n"
17880 + _ASM_EXTABLE(0b, 0b)
17881 +#endif
17882 +
17883 /*
17884 * transitions 0xZZZZ0001 -> 0xYYYY0001 (i386)
17885 * 0xZZZZZZZZ00000001 -> 0xYYYYYYYY00000001 (x86_64)
17886 @@ -208,7 +256,15 @@ static inline void __downgrade_write(struct rw_semaphore *sem)
17887 */
17888 static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17889 {
17890 - asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0"
17891 + asm volatile(LOCK_PREFIX _ASM_ADD "%1,%0\n"
17892 +
17893 +#ifdef CONFIG_PAX_REFCOUNT
17894 + "jno 0f\n"
17895 + LOCK_PREFIX _ASM_SUB "%1,%0\n"
17896 + "int $4\n0:\n"
17897 + _ASM_EXTABLE(0b, 0b)
17898 +#endif
17899 +
17900 : "+m" (sem->count)
17901 : "er" (delta));
17902 }
17903 @@ -218,7 +274,7 @@ static inline void rwsem_atomic_add(long delta, struct rw_semaphore *sem)
17904 */
17905 static inline long rwsem_atomic_update(long delta, struct rw_semaphore *sem)
17906 {
17907 - return delta + xadd(&sem->count, delta);
17908 + return delta + xadd_check_overflow(&sem->count, delta);
17909 }
17910
17911 #endif /* __KERNEL__ */
17912 diff --git a/arch/x86/include/asm/segment.h b/arch/x86/include/asm/segment.h
17913 index c48a950..bc40804 100644
17914 --- a/arch/x86/include/asm/segment.h
17915 +++ b/arch/x86/include/asm/segment.h
17916 @@ -64,10 +64,15 @@
17917 * 26 - ESPFIX small SS
17918 * 27 - per-cpu [ offset to per-cpu data area ]
17919 * 28 - stack_canary-20 [ for stack protector ]
17920 - * 29 - unused
17921 - * 30 - unused
17922 + * 29 - PCI BIOS CS
17923 + * 30 - PCI BIOS DS
17924 * 31 - TSS for double fault handler
17925 */
17926 +#define GDT_ENTRY_KERNEXEC_EFI_CS (1)
17927 +#define GDT_ENTRY_KERNEXEC_EFI_DS (2)
17928 +#define __KERNEXEC_EFI_CS (GDT_ENTRY_KERNEXEC_EFI_CS*8)
17929 +#define __KERNEXEC_EFI_DS (GDT_ENTRY_KERNEXEC_EFI_DS*8)
17930 +
17931 #define GDT_ENTRY_TLS_MIN 6
17932 #define GDT_ENTRY_TLS_MAX (GDT_ENTRY_TLS_MIN + GDT_ENTRY_TLS_ENTRIES - 1)
17933
17934 @@ -79,6 +84,8 @@
17935
17936 #define GDT_ENTRY_KERNEL_CS (GDT_ENTRY_KERNEL_BASE+0)
17937
17938 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS (4)
17939 +
17940 #define GDT_ENTRY_KERNEL_DS (GDT_ENTRY_KERNEL_BASE+1)
17941
17942 #define GDT_ENTRY_TSS (GDT_ENTRY_KERNEL_BASE+4)
17943 @@ -104,6 +111,12 @@
17944 #define __KERNEL_STACK_CANARY 0
17945 #endif
17946
17947 +#define GDT_ENTRY_PCIBIOS_CS (GDT_ENTRY_KERNEL_BASE+17)
17948 +#define __PCIBIOS_CS (GDT_ENTRY_PCIBIOS_CS * 8)
17949 +
17950 +#define GDT_ENTRY_PCIBIOS_DS (GDT_ENTRY_KERNEL_BASE+18)
17951 +#define __PCIBIOS_DS (GDT_ENTRY_PCIBIOS_DS * 8)
17952 +
17953 #define GDT_ENTRY_DOUBLEFAULT_TSS 31
17954
17955 /*
17956 @@ -141,7 +154,7 @@
17957 */
17958
17959 /* Matches PNP_CS32 and PNP_CS16 (they must be consecutive) */
17960 -#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xf4) == GDT_ENTRY_PNPBIOS_BASE * 8)
17961 +#define SEGMENT_IS_PNP_CODE(x) (((x) & 0xFFFCU) == PNP_CS32 || ((x) & 0xFFFCU) == PNP_CS16)
17962
17963
17964 #else
17965 @@ -165,6 +178,8 @@
17966 #define __USER32_CS (GDT_ENTRY_DEFAULT_USER32_CS*8+3)
17967 #define __USER32_DS __USER_DS
17968
17969 +#define GDT_ENTRY_KERNEXEC_KERNEL_CS 7
17970 +
17971 #define GDT_ENTRY_TSS 8 /* needs two entries */
17972 #define GDT_ENTRY_LDT 10 /* needs two entries */
17973 #define GDT_ENTRY_TLS_MIN 12
17974 @@ -173,6 +188,8 @@
17975 #define GDT_ENTRY_PER_CPU 15 /* Abused to load per CPU data from limit */
17976 #define __PER_CPU_SEG (GDT_ENTRY_PER_CPU * 8 + 3)
17977
17978 +#define GDT_ENTRY_UDEREF_KERNEL_DS 16
17979 +
17980 /* TLS indexes for 64bit - hardcoded in arch_prctl */
17981 #define FS_TLS 0
17982 #define GS_TLS 1
17983 @@ -180,12 +197,14 @@
17984 #define GS_TLS_SEL ((GDT_ENTRY_TLS_MIN+GS_TLS)*8 + 3)
17985 #define FS_TLS_SEL ((GDT_ENTRY_TLS_MIN+FS_TLS)*8 + 3)
17986
17987 -#define GDT_ENTRIES 16
17988 +#define GDT_ENTRIES 17
17989
17990 #endif
17991
17992 #define __KERNEL_CS (GDT_ENTRY_KERNEL_CS*8)
17993 +#define __KERNEXEC_KERNEL_CS (GDT_ENTRY_KERNEXEC_KERNEL_CS*8)
17994 #define __KERNEL_DS (GDT_ENTRY_KERNEL_DS*8)
17995 +#define __UDEREF_KERNEL_DS (GDT_ENTRY_UDEREF_KERNEL_DS*8)
17996 #define __USER_DS (GDT_ENTRY_DEFAULT_USER_DS*8+3)
17997 #define __USER_CS (GDT_ENTRY_DEFAULT_USER_CS*8+3)
17998 #ifndef CONFIG_PARAVIRT
17999 @@ -265,7 +284,7 @@ static inline unsigned long get_limit(unsigned long segment)
18000 {
18001 unsigned long __limit;
18002 asm("lsll %1,%0" : "=r" (__limit) : "r" (segment));
18003 - return __limit + 1;
18004 + return __limit;
18005 }
18006
18007 #endif /* !__ASSEMBLY__ */
18008 diff --git a/arch/x86/include/asm/smap.h b/arch/x86/include/asm/smap.h
18009 index 8d3120f..352b440 100644
18010 --- a/arch/x86/include/asm/smap.h
18011 +++ b/arch/x86/include/asm/smap.h
18012 @@ -25,11 +25,40 @@
18013
18014 #include <asm/alternative-asm.h>
18015
18016 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18017 +#define ASM_PAX_OPEN_USERLAND \
18018 + 661: jmp 663f; \
18019 + .pushsection .altinstr_replacement, "a" ; \
18020 + 662: pushq %rax; nop; \
18021 + .popsection ; \
18022 + .pushsection .altinstructions, "a" ; \
18023 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18024 + .popsection ; \
18025 + call __pax_open_userland; \
18026 + popq %rax; \
18027 + 663:
18028 +
18029 +#define ASM_PAX_CLOSE_USERLAND \
18030 + 661: jmp 663f; \
18031 + .pushsection .altinstr_replacement, "a" ; \
18032 + 662: pushq %rax; nop; \
18033 + .popsection; \
18034 + .pushsection .altinstructions, "a" ; \
18035 + altinstruction_entry 661b, 662b, X86_FEATURE_STRONGUDEREF, 2, 2;\
18036 + .popsection; \
18037 + call __pax_close_userland; \
18038 + popq %rax; \
18039 + 663:
18040 +#else
18041 +#define ASM_PAX_OPEN_USERLAND
18042 +#define ASM_PAX_CLOSE_USERLAND
18043 +#endif
18044 +
18045 #ifdef CONFIG_X86_SMAP
18046
18047 #define ASM_CLAC \
18048 661: ASM_NOP3 ; \
18049 - .pushsection .altinstr_replacement, "ax" ; \
18050 + .pushsection .altinstr_replacement, "a" ; \
18051 662: __ASM_CLAC ; \
18052 .popsection ; \
18053 .pushsection .altinstructions, "a" ; \
18054 @@ -38,7 +67,7 @@
18055
18056 #define ASM_STAC \
18057 661: ASM_NOP3 ; \
18058 - .pushsection .altinstr_replacement, "ax" ; \
18059 + .pushsection .altinstr_replacement, "a" ; \
18060 662: __ASM_STAC ; \
18061 .popsection ; \
18062 .pushsection .altinstructions, "a" ; \
18063 @@ -56,6 +85,37 @@
18064
18065 #include <asm/alternative.h>
18066
18067 +#define __HAVE_ARCH_PAX_OPEN_USERLAND
18068 +#define __HAVE_ARCH_PAX_CLOSE_USERLAND
18069 +
18070 +extern void __pax_open_userland(void);
18071 +static __always_inline unsigned long pax_open_userland(void)
18072 +{
18073 +
18074 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18075 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[open]", X86_FEATURE_STRONGUDEREF)
18076 + :
18077 + : [open] "i" (__pax_open_userland)
18078 + : "memory", "rax");
18079 +#endif
18080 +
18081 + return 0;
18082 +}
18083 +
18084 +extern void __pax_close_userland(void);
18085 +static __always_inline unsigned long pax_close_userland(void)
18086 +{
18087 +
18088 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18089 + asm volatile(ALTERNATIVE(ASM_NOP5, "call %P[close]", X86_FEATURE_STRONGUDEREF)
18090 + :
18091 + : [close] "i" (__pax_close_userland)
18092 + : "memory", "rax");
18093 +#endif
18094 +
18095 + return 0;
18096 +}
18097 +
18098 #ifdef CONFIG_X86_SMAP
18099
18100 static __always_inline void clac(void)
18101 diff --git a/arch/x86/include/asm/smp.h b/arch/x86/include/asm/smp.h
18102 index 4137890..03fa172 100644
18103 --- a/arch/x86/include/asm/smp.h
18104 +++ b/arch/x86/include/asm/smp.h
18105 @@ -36,7 +36,7 @@ DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_core_map);
18106 /* cpus sharing the last level cache: */
18107 DECLARE_PER_CPU_READ_MOSTLY(cpumask_var_t, cpu_llc_shared_map);
18108 DECLARE_PER_CPU_READ_MOSTLY(u16, cpu_llc_id);
18109 -DECLARE_PER_CPU_READ_MOSTLY(int, cpu_number);
18110 +DECLARE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
18111
18112 static inline struct cpumask *cpu_sibling_mask(int cpu)
18113 {
18114 @@ -79,7 +79,7 @@ struct smp_ops {
18115
18116 void (*send_call_func_ipi)(const struct cpumask *mask);
18117 void (*send_call_func_single_ipi)(int cpu);
18118 -};
18119 +} __no_const;
18120
18121 /* Globals due to paravirt */
18122 extern void set_cpu_sibling_map(int cpu);
18123 @@ -191,14 +191,8 @@ extern unsigned disabled_cpus;
18124 extern int safe_smp_processor_id(void);
18125
18126 #elif defined(CONFIG_X86_64_SMP)
18127 -#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18128 -
18129 -#define stack_smp_processor_id() \
18130 -({ \
18131 - struct thread_info *ti; \
18132 - __asm__("andq %%rsp,%0; ":"=r" (ti) : "0" (CURRENT_MASK)); \
18133 - ti->cpu; \
18134 -})
18135 +#define raw_smp_processor_id() (this_cpu_read(cpu_number))
18136 +#define stack_smp_processor_id() raw_smp_processor_id()
18137 #define safe_smp_processor_id() smp_processor_id()
18138
18139 #endif
18140 diff --git a/arch/x86/include/asm/spinlock.h b/arch/x86/include/asm/spinlock.h
18141 index bf156de..1a782ab 100644
18142 --- a/arch/x86/include/asm/spinlock.h
18143 +++ b/arch/x86/include/asm/spinlock.h
18144 @@ -223,6 +223,14 @@ static inline int arch_write_can_lock(arch_rwlock_t *lock)
18145 static inline void arch_read_lock(arch_rwlock_t *rw)
18146 {
18147 asm volatile(LOCK_PREFIX READ_LOCK_SIZE(dec) " (%0)\n\t"
18148 +
18149 +#ifdef CONFIG_PAX_REFCOUNT
18150 + "jno 0f\n"
18151 + LOCK_PREFIX READ_LOCK_SIZE(inc) " (%0)\n"
18152 + "int $4\n0:\n"
18153 + _ASM_EXTABLE(0b, 0b)
18154 +#endif
18155 +
18156 "jns 1f\n"
18157 "call __read_lock_failed\n\t"
18158 "1:\n"
18159 @@ -232,6 +240,14 @@ static inline void arch_read_lock(arch_rwlock_t *rw)
18160 static inline void arch_write_lock(arch_rwlock_t *rw)
18161 {
18162 asm volatile(LOCK_PREFIX WRITE_LOCK_SUB(%1) "(%0)\n\t"
18163 +
18164 +#ifdef CONFIG_PAX_REFCOUNT
18165 + "jno 0f\n"
18166 + LOCK_PREFIX WRITE_LOCK_ADD(%1) "(%0)\n"
18167 + "int $4\n0:\n"
18168 + _ASM_EXTABLE(0b, 0b)
18169 +#endif
18170 +
18171 "jz 1f\n"
18172 "call __write_lock_failed\n\t"
18173 "1:\n"
18174 @@ -261,13 +277,29 @@ static inline int arch_write_trylock(arch_rwlock_t *lock)
18175
18176 static inline void arch_read_unlock(arch_rwlock_t *rw)
18177 {
18178 - asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0"
18179 + asm volatile(LOCK_PREFIX READ_LOCK_SIZE(inc) " %0\n"
18180 +
18181 +#ifdef CONFIG_PAX_REFCOUNT
18182 + "jno 0f\n"
18183 + LOCK_PREFIX READ_LOCK_SIZE(dec) " %0\n"
18184 + "int $4\n0:\n"
18185 + _ASM_EXTABLE(0b, 0b)
18186 +#endif
18187 +
18188 :"+m" (rw->lock) : : "memory");
18189 }
18190
18191 static inline void arch_write_unlock(arch_rwlock_t *rw)
18192 {
18193 - asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0"
18194 + asm volatile(LOCK_PREFIX WRITE_LOCK_ADD(%1) "%0\n"
18195 +
18196 +#ifdef CONFIG_PAX_REFCOUNT
18197 + "jno 0f\n"
18198 + LOCK_PREFIX WRITE_LOCK_SUB(%1) "%0\n"
18199 + "int $4\n0:\n"
18200 + _ASM_EXTABLE(0b, 0b)
18201 +#endif
18202 +
18203 : "+m" (rw->write) : "i" (RW_LOCK_BIAS) : "memory");
18204 }
18205
18206 diff --git a/arch/x86/include/asm/stackprotector.h b/arch/x86/include/asm/stackprotector.h
18207 index 6a99859..03cb807 100644
18208 --- a/arch/x86/include/asm/stackprotector.h
18209 +++ b/arch/x86/include/asm/stackprotector.h
18210 @@ -47,7 +47,7 @@
18211 * head_32 for boot CPU and setup_per_cpu_areas() for others.
18212 */
18213 #define GDT_STACK_CANARY_INIT \
18214 - [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x18),
18215 + [GDT_ENTRY_STACK_CANARY] = GDT_ENTRY_INIT(0x4090, 0, 0x17),
18216
18217 /*
18218 * Initialize the stackprotector canary value.
18219 @@ -112,7 +112,7 @@ static inline void setup_stack_canary_segment(int cpu)
18220
18221 static inline void load_stack_canary_segment(void)
18222 {
18223 -#ifdef CONFIG_X86_32
18224 +#if defined(CONFIG_X86_32) && !defined(CONFIG_PAX_MEMORY_UDEREF)
18225 asm volatile ("mov %0, %%gs" : : "r" (0));
18226 #endif
18227 }
18228 diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
18229 index 70bbe39..4ae2bd4 100644
18230 --- a/arch/x86/include/asm/stacktrace.h
18231 +++ b/arch/x86/include/asm/stacktrace.h
18232 @@ -11,28 +11,20 @@
18233
18234 extern int kstack_depth_to_print;
18235
18236 -struct thread_info;
18237 +struct task_struct;
18238 struct stacktrace_ops;
18239
18240 -typedef unsigned long (*walk_stack_t)(struct thread_info *tinfo,
18241 - unsigned long *stack,
18242 - unsigned long bp,
18243 - const struct stacktrace_ops *ops,
18244 - void *data,
18245 - unsigned long *end,
18246 - int *graph);
18247 +typedef unsigned long walk_stack_t(struct task_struct *task,
18248 + void *stack_start,
18249 + unsigned long *stack,
18250 + unsigned long bp,
18251 + const struct stacktrace_ops *ops,
18252 + void *data,
18253 + unsigned long *end,
18254 + int *graph);
18255
18256 -extern unsigned long
18257 -print_context_stack(struct thread_info *tinfo,
18258 - unsigned long *stack, unsigned long bp,
18259 - const struct stacktrace_ops *ops, void *data,
18260 - unsigned long *end, int *graph);
18261 -
18262 -extern unsigned long
18263 -print_context_stack_bp(struct thread_info *tinfo,
18264 - unsigned long *stack, unsigned long bp,
18265 - const struct stacktrace_ops *ops, void *data,
18266 - unsigned long *end, int *graph);
18267 +extern walk_stack_t print_context_stack;
18268 +extern walk_stack_t print_context_stack_bp;
18269
18270 /* Generic stack tracer with callbacks */
18271
18272 @@ -40,7 +32,7 @@ struct stacktrace_ops {
18273 void (*address)(void *data, unsigned long address, int reliable);
18274 /* On negative return stop dumping */
18275 int (*stack)(void *data, char *name);
18276 - walk_stack_t walk_stack;
18277 + walk_stack_t *walk_stack;
18278 };
18279
18280 void dump_trace(struct task_struct *tsk, struct pt_regs *regs,
18281 diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
18282 index d7f3b3b..3cc39f1 100644
18283 --- a/arch/x86/include/asm/switch_to.h
18284 +++ b/arch/x86/include/asm/switch_to.h
18285 @@ -108,7 +108,7 @@ do { \
18286 "call __switch_to\n\t" \
18287 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
18288 __switch_canary \
18289 - "movq %P[thread_info](%%rsi),%%r8\n\t" \
18290 + "movq "__percpu_arg([thread_info])",%%r8\n\t" \
18291 "movq %%rax,%%rdi\n\t" \
18292 "testl %[_tif_fork],%P[ti_flags](%%r8)\n\t" \
18293 "jnz ret_from_fork\n\t" \
18294 @@ -119,7 +119,7 @@ do { \
18295 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
18296 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
18297 [_tif_fork] "i" (_TIF_FORK), \
18298 - [thread_info] "i" (offsetof(struct task_struct, stack)), \
18299 + [thread_info] "m" (current_tinfo), \
18300 [current_task] "m" (current_task) \
18301 __switch_canary_iparam \
18302 : "memory", "cc" __EXTRA_CLOBBER)
18303 diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h
18304 index 2781119..618b59b 100644
18305 --- a/arch/x86/include/asm/thread_info.h
18306 +++ b/arch/x86/include/asm/thread_info.h
18307 @@ -10,6 +10,7 @@
18308 #include <linux/compiler.h>
18309 #include <asm/page.h>
18310 #include <asm/types.h>
18311 +#include <asm/percpu.h>
18312
18313 /*
18314 * low level task data that entry.S needs immediate access to
18315 @@ -23,7 +24,6 @@ struct exec_domain;
18316 #include <linux/atomic.h>
18317
18318 struct thread_info {
18319 - struct task_struct *task; /* main task structure */
18320 struct exec_domain *exec_domain; /* execution domain */
18321 __u32 flags; /* low level flags */
18322 __u32 status; /* thread synchronous flags */
18323 @@ -33,19 +33,13 @@ struct thread_info {
18324 mm_segment_t addr_limit;
18325 struct restart_block restart_block;
18326 void __user *sysenter_return;
18327 -#ifdef CONFIG_X86_32
18328 - unsigned long previous_esp; /* ESP of the previous stack in
18329 - case of nested (IRQ) stacks
18330 - */
18331 - __u8 supervisor_stack[0];
18332 -#endif
18333 + unsigned long lowest_stack;
18334 unsigned int sig_on_uaccess_error:1;
18335 unsigned int uaccess_err:1; /* uaccess failed */
18336 };
18337
18338 -#define INIT_THREAD_INFO(tsk) \
18339 +#define INIT_THREAD_INFO \
18340 { \
18341 - .task = &tsk, \
18342 .exec_domain = &default_exec_domain, \
18343 .flags = 0, \
18344 .cpu = 0, \
18345 @@ -56,7 +50,7 @@ struct thread_info {
18346 }, \
18347 }
18348
18349 -#define init_thread_info (init_thread_union.thread_info)
18350 +#define init_thread_info (init_thread_union.stack)
18351 #define init_stack (init_thread_union.stack)
18352
18353 #else /* !__ASSEMBLY__ */
18354 @@ -96,6 +90,7 @@ struct thread_info {
18355 #define TIF_SYSCALL_TRACEPOINT 28 /* syscall tracepoint instrumentation */
18356 #define TIF_ADDR32 29 /* 32-bit address space on 64 bits */
18357 #define TIF_X32 30 /* 32-bit native x86-64 binary */
18358 +#define TIF_GRSEC_SETXID 31 /* update credentials on syscall entry/exit */
18359
18360 #define _TIF_SYSCALL_TRACE (1 << TIF_SYSCALL_TRACE)
18361 #define _TIF_NOTIFY_RESUME (1 << TIF_NOTIFY_RESUME)
18362 @@ -119,17 +114,18 @@ struct thread_info {
18363 #define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
18364 #define _TIF_ADDR32 (1 << TIF_ADDR32)
18365 #define _TIF_X32 (1 << TIF_X32)
18366 +#define _TIF_GRSEC_SETXID (1 << TIF_GRSEC_SETXID)
18367
18368 /* work to do in syscall_trace_enter() */
18369 #define _TIF_WORK_SYSCALL_ENTRY \
18370 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | _TIF_SYSCALL_AUDIT | \
18371 _TIF_SECCOMP | _TIF_SINGLESTEP | _TIF_SYSCALL_TRACEPOINT | \
18372 - _TIF_NOHZ)
18373 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
18374
18375 /* work to do in syscall_trace_leave() */
18376 #define _TIF_WORK_SYSCALL_EXIT \
18377 (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP | \
18378 - _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ)
18379 + _TIF_SYSCALL_TRACEPOINT | _TIF_NOHZ | _TIF_GRSEC_SETXID)
18380
18381 /* work to do on interrupt/exception return */
18382 #define _TIF_WORK_MASK \
18383 @@ -140,7 +136,7 @@ struct thread_info {
18384 /* work to do on any return to user space */
18385 #define _TIF_ALLWORK_MASK \
18386 ((0x0000FFFF & ~_TIF_SECCOMP) | _TIF_SYSCALL_TRACEPOINT | \
18387 - _TIF_NOHZ)
18388 + _TIF_NOHZ | _TIF_GRSEC_SETXID)
18389
18390 /* Only used for 64 bit */
18391 #define _TIF_DO_NOTIFY_MASK \
18392 @@ -156,45 +152,40 @@ struct thread_info {
18393
18394 #define PREEMPT_ACTIVE 0x10000000
18395
18396 -#ifdef CONFIG_X86_32
18397 -
18398 -#define STACK_WARN (THREAD_SIZE/8)
18399 -/*
18400 - * macros/functions for gaining access to the thread information structure
18401 - *
18402 - * preempt_count needs to be 1 initially, until the scheduler is functional.
18403 - */
18404 -#ifndef __ASSEMBLY__
18405 -
18406 -
18407 -/* how to get the current stack pointer from C */
18408 -register unsigned long current_stack_pointer asm("esp") __used;
18409 -
18410 -/* how to get the thread information struct from C */
18411 -static inline struct thread_info *current_thread_info(void)
18412 -{
18413 - return (struct thread_info *)
18414 - (current_stack_pointer & ~(THREAD_SIZE - 1));
18415 -}
18416 -
18417 -#else /* !__ASSEMBLY__ */
18418 -
18419 +#ifdef __ASSEMBLY__
18420 /* how to get the thread information struct from ASM */
18421 #define GET_THREAD_INFO(reg) \
18422 - movl $-THREAD_SIZE, reg; \
18423 - andl %esp, reg
18424 + mov PER_CPU_VAR(current_tinfo), reg
18425
18426 /* use this one if reg already contains %esp */
18427 -#define GET_THREAD_INFO_WITH_ESP(reg) \
18428 - andl $-THREAD_SIZE, reg
18429 +#define GET_THREAD_INFO_WITH_ESP(reg) GET_THREAD_INFO(reg)
18430 +#else
18431 +/* how to get the thread information struct from C */
18432 +DECLARE_PER_CPU(struct thread_info *, current_tinfo);
18433 +
18434 +static __always_inline struct thread_info *current_thread_info(void)
18435 +{
18436 + return this_cpu_read_stable(current_tinfo);
18437 +}
18438 +#endif
18439 +
18440 +#ifdef CONFIG_X86_32
18441 +
18442 +#define STACK_WARN (THREAD_SIZE/8)
18443 +/*
18444 + * macros/functions for gaining access to the thread information structure
18445 + *
18446 + * preempt_count needs to be 1 initially, until the scheduler is functional.
18447 + */
18448 +#ifndef __ASSEMBLY__
18449 +
18450 +/* how to get the current stack pointer from C */
18451 +register unsigned long current_stack_pointer asm("esp") __used;
18452
18453 #endif
18454
18455 #else /* X86_32 */
18456
18457 -#include <asm/percpu.h>
18458 -#define KERNEL_STACK_OFFSET (5*8)
18459 -
18460 /*
18461 * macros/functions for gaining access to the thread information structure
18462 * preempt_count needs to be 1 initially, until the scheduler is functional.
18463 @@ -202,27 +193,8 @@ static inline struct thread_info *current_thread_info(void)
18464 #ifndef __ASSEMBLY__
18465 DECLARE_PER_CPU(unsigned long, kernel_stack);
18466
18467 -static inline struct thread_info *current_thread_info(void)
18468 -{
18469 - struct thread_info *ti;
18470 - ti = (void *)(this_cpu_read_stable(kernel_stack) +
18471 - KERNEL_STACK_OFFSET - THREAD_SIZE);
18472 - return ti;
18473 -}
18474 -
18475 -#else /* !__ASSEMBLY__ */
18476 -
18477 -/* how to get the thread information struct from ASM */
18478 -#define GET_THREAD_INFO(reg) \
18479 - movq PER_CPU_VAR(kernel_stack),reg ; \
18480 - subq $(THREAD_SIZE-KERNEL_STACK_OFFSET),reg
18481 -
18482 -/*
18483 - * Same if PER_CPU_VAR(kernel_stack) is, perhaps with some offset, already in
18484 - * a certain register (to be used in assembler memory operands).
18485 - */
18486 -#define THREAD_INFO(reg, off) KERNEL_STACK_OFFSET+(off)-THREAD_SIZE(reg)
18487 -
18488 +/* how to get the current stack pointer from C */
18489 +register unsigned long current_stack_pointer asm("rsp") __used;
18490 #endif
18491
18492 #endif /* !X86_32 */
18493 @@ -281,5 +253,12 @@ static inline bool is_ia32_task(void)
18494 extern void arch_task_cache_init(void);
18495 extern int arch_dup_task_struct(struct task_struct *dst, struct task_struct *src);
18496 extern void arch_release_task_struct(struct task_struct *tsk);
18497 +
18498 +#define __HAVE_THREAD_FUNCTIONS
18499 +#define task_thread_info(task) (&(task)->tinfo)
18500 +#define task_stack_page(task) ((task)->stack)
18501 +#define setup_thread_stack(p, org) do {} while (0)
18502 +#define end_of_stack(p) ((unsigned long *)task_stack_page(p) + 1)
18503 +
18504 #endif
18505 #endif /* _ASM_X86_THREAD_INFO_H */
18506 diff --git a/arch/x86/include/asm/tlbflush.h b/arch/x86/include/asm/tlbflush.h
18507 index e6d90ba..0897f44 100644
18508 --- a/arch/x86/include/asm/tlbflush.h
18509 +++ b/arch/x86/include/asm/tlbflush.h
18510 @@ -17,18 +17,44 @@
18511
18512 static inline void __native_flush_tlb(void)
18513 {
18514 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18515 + u64 descriptor[2];
18516 +
18517 + descriptor[0] = PCID_KERNEL;
18518 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_MONGLOBAL) : "memory");
18519 + return;
18520 + }
18521 +
18522 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18523 + if (static_cpu_has(X86_FEATURE_PCID)) {
18524 + unsigned int cpu = raw_get_cpu();
18525 +
18526 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER);
18527 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL);
18528 + raw_put_cpu_no_resched();
18529 + return;
18530 + }
18531 +#endif
18532 +
18533 native_write_cr3(native_read_cr3());
18534 }
18535
18536 static inline void __native_flush_tlb_global_irq_disabled(void)
18537 {
18538 - unsigned long cr4;
18539 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18540 + u64 descriptor[2];
18541
18542 - cr4 = native_read_cr4();
18543 - /* clear PGE */
18544 - native_write_cr4(cr4 & ~X86_CR4_PGE);
18545 - /* write old PGE again and flush TLBs */
18546 - native_write_cr4(cr4);
18547 + descriptor[0] = PCID_KERNEL;
18548 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_ALL_GLOBAL) : "memory");
18549 + } else {
18550 + unsigned long cr4;
18551 +
18552 + cr4 = native_read_cr4();
18553 + /* clear PGE */
18554 + native_write_cr4(cr4 & ~X86_CR4_PGE);
18555 + /* write old PGE again and flush TLBs */
18556 + native_write_cr4(cr4);
18557 + }
18558 }
18559
18560 static inline void __native_flush_tlb_global(void)
18561 @@ -49,6 +75,42 @@ static inline void __native_flush_tlb_global(void)
18562
18563 static inline void __native_flush_tlb_single(unsigned long addr)
18564 {
18565 +
18566 + if (static_cpu_has(X86_FEATURE_INVPCID)) {
18567 + u64 descriptor[2];
18568 +
18569 + descriptor[0] = PCID_KERNEL;
18570 + descriptor[1] = addr;
18571 +
18572 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18573 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) || addr >= TASK_SIZE_MAX) {
18574 + if (addr < TASK_SIZE_MAX)
18575 + descriptor[1] += pax_user_shadow_base;
18576 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18577 + }
18578 +
18579 + descriptor[0] = PCID_USER;
18580 + descriptor[1] = addr;
18581 +#endif
18582 +
18583 + asm volatile(__ASM_INVPCID : : "d"(&descriptor), "a"(INVPCID_SINGLE_ADDRESS) : "memory");
18584 + return;
18585 + }
18586 +
18587 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18588 + if (static_cpu_has(X86_FEATURE_PCID)) {
18589 + unsigned int cpu = raw_get_cpu();
18590 +
18591 + native_write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
18592 + asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18593 + native_write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
18594 + raw_put_cpu_no_resched();
18595 +
18596 + if (!static_cpu_has(X86_FEATURE_STRONGUDEREF) && addr < TASK_SIZE_MAX)
18597 + addr += pax_user_shadow_base;
18598 + }
18599 +#endif
18600 +
18601 asm volatile("invlpg (%0)" ::"r" (addr) : "memory");
18602 }
18603
18604 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h
18605 index 5838fa9..f7ae572 100644
18606 --- a/arch/x86/include/asm/uaccess.h
18607 +++ b/arch/x86/include/asm/uaccess.h
18608 @@ -7,6 +7,7 @@
18609 #include <linux/compiler.h>
18610 #include <linux/thread_info.h>
18611 #include <linux/string.h>
18612 +#include <linux/sched.h>
18613 #include <asm/asm.h>
18614 #include <asm/page.h>
18615 #include <asm/smap.h>
18616 @@ -29,7 +30,12 @@
18617
18618 #define get_ds() (KERNEL_DS)
18619 #define get_fs() (current_thread_info()->addr_limit)
18620 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18621 +void __set_fs(mm_segment_t x);
18622 +void set_fs(mm_segment_t x);
18623 +#else
18624 #define set_fs(x) (current_thread_info()->addr_limit = (x))
18625 +#endif
18626
18627 #define segment_eq(a, b) ((a).seg == (b).seg)
18628
18629 @@ -77,8 +83,33 @@
18630 * checks that the pointer is in the user space range - after calling
18631 * this function, memory access functions may still return -EFAULT.
18632 */
18633 -#define access_ok(type, addr, size) \
18634 - (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18635 +#define __access_ok(type, addr, size) (likely(__range_not_ok(addr, size, user_addr_max()) == 0))
18636 +#define access_ok(type, addr, size) \
18637 +({ \
18638 + long __size = size; \
18639 + unsigned long __addr = (unsigned long)addr; \
18640 + unsigned long __addr_ao = __addr & PAGE_MASK; \
18641 + unsigned long __end_ao = __addr + __size - 1; \
18642 + bool __ret_ao = __range_not_ok(__addr, __size, user_addr_max()) == 0;\
18643 + if (__ret_ao && unlikely((__end_ao ^ __addr_ao) & PAGE_MASK)) { \
18644 + while(__addr_ao <= __end_ao) { \
18645 + char __c_ao; \
18646 + __addr_ao += PAGE_SIZE; \
18647 + if (__size > PAGE_SIZE) \
18648 + cond_resched(); \
18649 + if (__get_user(__c_ao, (char __user *)__addr)) \
18650 + break; \
18651 + if (type != VERIFY_WRITE) { \
18652 + __addr = __addr_ao; \
18653 + continue; \
18654 + } \
18655 + if (__put_user(__c_ao, (char __user *)__addr)) \
18656 + break; \
18657 + __addr = __addr_ao; \
18658 + } \
18659 + } \
18660 + __ret_ao; \
18661 +})
18662
18663 /*
18664 * The exception table consists of pairs of addresses relative to the
18665 @@ -168,10 +199,12 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18666 register __inttype(*(ptr)) __val_gu asm("%"_ASM_DX); \
18667 __chk_user_ptr(ptr); \
18668 might_fault(); \
18669 + pax_open_userland(); \
18670 asm volatile("call __get_user_%P3" \
18671 : "=a" (__ret_gu), "=r" (__val_gu) \
18672 : "0" (ptr), "i" (sizeof(*(ptr)))); \
18673 (x) = (__typeof__(*(ptr))) __val_gu; \
18674 + pax_close_userland(); \
18675 __ret_gu; \
18676 })
18677
18678 @@ -179,13 +212,21 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18679 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \
18680 : "0" ((typeof(*(ptr)))(x)), "c" (ptr) : "ebx")
18681
18682 -
18683 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
18684 +#define __copyuser_seg "gs;"
18685 +#define __COPYUSER_SET_ES "pushl %%gs; popl %%es\n"
18686 +#define __COPYUSER_RESTORE_ES "pushl %%ss; popl %%es\n"
18687 +#else
18688 +#define __copyuser_seg
18689 +#define __COPYUSER_SET_ES
18690 +#define __COPYUSER_RESTORE_ES
18691 +#endif
18692
18693 #ifdef CONFIG_X86_32
18694 #define __put_user_asm_u64(x, addr, err, errret) \
18695 asm volatile(ASM_STAC "\n" \
18696 - "1: movl %%eax,0(%2)\n" \
18697 - "2: movl %%edx,4(%2)\n" \
18698 + "1: "__copyuser_seg"movl %%eax,0(%2)\n" \
18699 + "2: "__copyuser_seg"movl %%edx,4(%2)\n" \
18700 "3: " ASM_CLAC "\n" \
18701 ".section .fixup,\"ax\"\n" \
18702 "4: movl %3,%0\n" \
18703 @@ -198,8 +239,8 @@ __typeof__(__builtin_choose_expr(sizeof(x) > sizeof(0UL), 0ULL, 0UL))
18704
18705 #define __put_user_asm_ex_u64(x, addr) \
18706 asm volatile(ASM_STAC "\n" \
18707 - "1: movl %%eax,0(%1)\n" \
18708 - "2: movl %%edx,4(%1)\n" \
18709 + "1: "__copyuser_seg"movl %%eax,0(%1)\n" \
18710 + "2: "__copyuser_seg"movl %%edx,4(%1)\n" \
18711 "3: " ASM_CLAC "\n" \
18712 _ASM_EXTABLE_EX(1b, 2b) \
18713 _ASM_EXTABLE_EX(2b, 3b) \
18714 @@ -249,7 +290,8 @@ extern void __put_user_8(void);
18715 __typeof__(*(ptr)) __pu_val; \
18716 __chk_user_ptr(ptr); \
18717 might_fault(); \
18718 - __pu_val = x; \
18719 + __pu_val = (x); \
18720 + pax_open_userland(); \
18721 switch (sizeof(*(ptr))) { \
18722 case 1: \
18723 __put_user_x(1, __pu_val, ptr, __ret_pu); \
18724 @@ -267,6 +309,7 @@ extern void __put_user_8(void);
18725 __put_user_x(X, __pu_val, ptr, __ret_pu); \
18726 break; \
18727 } \
18728 + pax_close_userland(); \
18729 __ret_pu; \
18730 })
18731
18732 @@ -347,8 +390,10 @@ do { \
18733 } while (0)
18734
18735 #define __get_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18736 +do { \
18737 + pax_open_userland(); \
18738 asm volatile(ASM_STAC "\n" \
18739 - "1: mov"itype" %2,%"rtype"1\n" \
18740 + "1: "__copyuser_seg"mov"itype" %2,%"rtype"1\n"\
18741 "2: " ASM_CLAC "\n" \
18742 ".section .fixup,\"ax\"\n" \
18743 "3: mov %3,%0\n" \
18744 @@ -356,8 +401,10 @@ do { \
18745 " jmp 2b\n" \
18746 ".previous\n" \
18747 _ASM_EXTABLE(1b, 3b) \
18748 - : "=r" (err), ltype(x) \
18749 - : "m" (__m(addr)), "i" (errret), "0" (err))
18750 + : "=r" (err), ltype (x) \
18751 + : "m" (__m(addr)), "i" (errret), "0" (err)); \
18752 + pax_close_userland(); \
18753 +} while (0)
18754
18755 #define __get_user_size_ex(x, ptr, size) \
18756 do { \
18757 @@ -381,7 +428,7 @@ do { \
18758 } while (0)
18759
18760 #define __get_user_asm_ex(x, addr, itype, rtype, ltype) \
18761 - asm volatile("1: mov"itype" %1,%"rtype"0\n" \
18762 + asm volatile("1: "__copyuser_seg"mov"itype" %1,%"rtype"0\n"\
18763 "2:\n" \
18764 _ASM_EXTABLE_EX(1b, 2b) \
18765 : ltype(x) : "m" (__m(addr)))
18766 @@ -398,13 +445,24 @@ do { \
18767 int __gu_err; \
18768 unsigned long __gu_val; \
18769 __get_user_size(__gu_val, (ptr), (size), __gu_err, -EFAULT); \
18770 - (x) = (__force __typeof__(*(ptr)))__gu_val; \
18771 + (x) = (__typeof__(*(ptr)))__gu_val; \
18772 __gu_err; \
18773 })
18774
18775 /* FIXME: this hack is definitely wrong -AK */
18776 struct __large_struct { unsigned long buf[100]; };
18777 -#define __m(x) (*(struct __large_struct __user *)(x))
18778 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18779 +#define ____m(x) \
18780 +({ \
18781 + unsigned long ____x = (unsigned long)(x); \
18782 + if (____x < pax_user_shadow_base) \
18783 + ____x += pax_user_shadow_base; \
18784 + (typeof(x))____x; \
18785 +})
18786 +#else
18787 +#define ____m(x) (x)
18788 +#endif
18789 +#define __m(x) (*(struct __large_struct __user *)____m(x))
18790
18791 /*
18792 * Tell gcc we read from memory instead of writing: this is because
18793 @@ -412,8 +470,10 @@ struct __large_struct { unsigned long buf[100]; };
18794 * aliasing issues.
18795 */
18796 #define __put_user_asm(x, addr, err, itype, rtype, ltype, errret) \
18797 +do { \
18798 + pax_open_userland(); \
18799 asm volatile(ASM_STAC "\n" \
18800 - "1: mov"itype" %"rtype"1,%2\n" \
18801 + "1: "__copyuser_seg"mov"itype" %"rtype"1,%2\n"\
18802 "2: " ASM_CLAC "\n" \
18803 ".section .fixup,\"ax\"\n" \
18804 "3: mov %3,%0\n" \
18805 @@ -421,10 +481,12 @@ struct __large_struct { unsigned long buf[100]; };
18806 ".previous\n" \
18807 _ASM_EXTABLE(1b, 3b) \
18808 : "=r"(err) \
18809 - : ltype(x), "m" (__m(addr)), "i" (errret), "0" (err))
18810 + : ltype (x), "m" (__m(addr)), "i" (errret), "0" (err));\
18811 + pax_close_userland(); \
18812 +} while (0)
18813
18814 #define __put_user_asm_ex(x, addr, itype, rtype, ltype) \
18815 - asm volatile("1: mov"itype" %"rtype"0,%1\n" \
18816 + asm volatile("1: "__copyuser_seg"mov"itype" %"rtype"0,%1\n"\
18817 "2:\n" \
18818 _ASM_EXTABLE_EX(1b, 2b) \
18819 : : ltype(x), "m" (__m(addr)))
18820 @@ -434,11 +496,13 @@ struct __large_struct { unsigned long buf[100]; };
18821 */
18822 #define uaccess_try do { \
18823 current_thread_info()->uaccess_err = 0; \
18824 + pax_open_userland(); \
18825 stac(); \
18826 barrier();
18827
18828 #define uaccess_catch(err) \
18829 clac(); \
18830 + pax_close_userland(); \
18831 (err) |= (current_thread_info()->uaccess_err ? -EFAULT : 0); \
18832 } while (0)
18833
18834 @@ -463,8 +527,12 @@ struct __large_struct { unsigned long buf[100]; };
18835 * On error, the variable @x is set to zero.
18836 */
18837
18838 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18839 +#define __get_user(x, ptr) get_user((x), (ptr))
18840 +#else
18841 #define __get_user(x, ptr) \
18842 __get_user_nocheck((x), (ptr), sizeof(*(ptr)))
18843 +#endif
18844
18845 /**
18846 * __put_user: - Write a simple value into user space, with less checking.
18847 @@ -486,8 +554,12 @@ struct __large_struct { unsigned long buf[100]; };
18848 * Returns zero on success, or -EFAULT on error.
18849 */
18850
18851 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
18852 +#define __put_user(x, ptr) put_user((x), (ptr))
18853 +#else
18854 #define __put_user(x, ptr) \
18855 __put_user_nocheck((__typeof__(*(ptr)))(x), (ptr), sizeof(*(ptr)))
18856 +#endif
18857
18858 #define __get_user_unaligned __get_user
18859 #define __put_user_unaligned __put_user
18860 @@ -505,7 +577,7 @@ struct __large_struct { unsigned long buf[100]; };
18861 #define get_user_ex(x, ptr) do { \
18862 unsigned long __gue_val; \
18863 __get_user_size_ex((__gue_val), (ptr), (sizeof(*(ptr)))); \
18864 - (x) = (__force __typeof__(*(ptr)))__gue_val; \
18865 + (x) = (__typeof__(*(ptr)))__gue_val; \
18866 } while (0)
18867
18868 #define put_user_try uaccess_try
18869 diff --git a/arch/x86/include/asm/uaccess_32.h b/arch/x86/include/asm/uaccess_32.h
18870 index 7f760a9..b596b9a 100644
18871 --- a/arch/x86/include/asm/uaccess_32.h
18872 +++ b/arch/x86/include/asm/uaccess_32.h
18873 @@ -43,6 +43,11 @@ unsigned long __must_check __copy_from_user_ll_nocache_nozero
18874 static __always_inline unsigned long __must_check
18875 __copy_to_user_inatomic(void __user *to, const void *from, unsigned long n)
18876 {
18877 + if ((long)n < 0)
18878 + return n;
18879 +
18880 + check_object_size(from, n, true);
18881 +
18882 if (__builtin_constant_p(n)) {
18883 unsigned long ret;
18884
18885 @@ -82,12 +87,16 @@ static __always_inline unsigned long __must_check
18886 __copy_to_user(void __user *to, const void *from, unsigned long n)
18887 {
18888 might_fault();
18889 +
18890 return __copy_to_user_inatomic(to, from, n);
18891 }
18892
18893 static __always_inline unsigned long
18894 __copy_from_user_inatomic(void *to, const void __user *from, unsigned long n)
18895 {
18896 + if ((long)n < 0)
18897 + return n;
18898 +
18899 /* Avoid zeroing the tail if the copy fails..
18900 * If 'n' is constant and 1, 2, or 4, we do still zero on a failure,
18901 * but as the zeroing behaviour is only significant when n is not
18902 @@ -137,6 +146,12 @@ static __always_inline unsigned long
18903 __copy_from_user(void *to, const void __user *from, unsigned long n)
18904 {
18905 might_fault();
18906 +
18907 + if ((long)n < 0)
18908 + return n;
18909 +
18910 + check_object_size(to, n, false);
18911 +
18912 if (__builtin_constant_p(n)) {
18913 unsigned long ret;
18914
18915 @@ -159,6 +174,10 @@ static __always_inline unsigned long __copy_from_user_nocache(void *to,
18916 const void __user *from, unsigned long n)
18917 {
18918 might_fault();
18919 +
18920 + if ((long)n < 0)
18921 + return n;
18922 +
18923 if (__builtin_constant_p(n)) {
18924 unsigned long ret;
18925
18926 @@ -181,15 +200,19 @@ static __always_inline unsigned long
18927 __copy_from_user_inatomic_nocache(void *to, const void __user *from,
18928 unsigned long n)
18929 {
18930 - return __copy_from_user_ll_nocache_nozero(to, from, n);
18931 + if ((long)n < 0)
18932 + return n;
18933 +
18934 + return __copy_from_user_ll_nocache_nozero(to, from, n);
18935 }
18936
18937 -unsigned long __must_check copy_to_user(void __user *to,
18938 - const void *from, unsigned long n);
18939 -unsigned long __must_check _copy_from_user(void *to,
18940 - const void __user *from,
18941 - unsigned long n);
18942 -
18943 +extern void copy_to_user_overflow(void)
18944 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18945 + __compiletime_error("copy_to_user() buffer size is not provably correct")
18946 +#else
18947 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
18948 +#endif
18949 +;
18950
18951 extern void copy_from_user_overflow(void)
18952 #ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
18953 @@ -199,17 +222,60 @@ extern void copy_from_user_overflow(void)
18954 #endif
18955 ;
18956
18957 -static inline unsigned long __must_check copy_from_user(void *to,
18958 - const void __user *from,
18959 - unsigned long n)
18960 +/**
18961 + * copy_to_user: - Copy a block of data into user space.
18962 + * @to: Destination address, in user space.
18963 + * @from: Source address, in kernel space.
18964 + * @n: Number of bytes to copy.
18965 + *
18966 + * Context: User context only. This function may sleep.
18967 + *
18968 + * Copy data from kernel space to user space.
18969 + *
18970 + * Returns number of bytes that could not be copied.
18971 + * On success, this will be zero.
18972 + */
18973 +static inline unsigned long __must_check
18974 +copy_to_user(void __user *to, const void *from, unsigned long n)
18975 {
18976 - int sz = __compiletime_object_size(to);
18977 + size_t sz = __compiletime_object_size(from);
18978
18979 - if (likely(sz == -1 || sz >= n))
18980 - n = _copy_from_user(to, from, n);
18981 - else
18982 + if (unlikely(sz != (size_t)-1 && sz < n))
18983 + copy_to_user_overflow();
18984 + else if (access_ok(VERIFY_WRITE, to, n))
18985 + n = __copy_to_user(to, from, n);
18986 + return n;
18987 +}
18988 +
18989 +/**
18990 + * copy_from_user: - Copy a block of data from user space.
18991 + * @to: Destination address, in kernel space.
18992 + * @from: Source address, in user space.
18993 + * @n: Number of bytes to copy.
18994 + *
18995 + * Context: User context only. This function may sleep.
18996 + *
18997 + * Copy data from user space to kernel space.
18998 + *
18999 + * Returns number of bytes that could not be copied.
19000 + * On success, this will be zero.
19001 + *
19002 + * If some data could not be copied, this function will pad the copied
19003 + * data to the requested size using zero bytes.
19004 + */
19005 +static inline unsigned long __must_check
19006 +copy_from_user(void *to, const void __user *from, unsigned long n)
19007 +{
19008 + size_t sz = __compiletime_object_size(to);
19009 +
19010 + check_object_size(to, n, false);
19011 +
19012 + if (unlikely(sz != (size_t)-1 && sz < n))
19013 copy_from_user_overflow();
19014 -
19015 + else if (access_ok(VERIFY_READ, from, n))
19016 + n = __copy_from_user(to, from, n);
19017 + else if ((long)n > 0)
19018 + memset(to, 0, n);
19019 return n;
19020 }
19021
19022 diff --git a/arch/x86/include/asm/uaccess_64.h b/arch/x86/include/asm/uaccess_64.h
19023 index 4f7923d..201b58d 100644
19024 --- a/arch/x86/include/asm/uaccess_64.h
19025 +++ b/arch/x86/include/asm/uaccess_64.h
19026 @@ -10,6 +10,9 @@
19027 #include <asm/alternative.h>
19028 #include <asm/cpufeature.h>
19029 #include <asm/page.h>
19030 +#include <asm/pgtable.h>
19031 +
19032 +#define set_fs(x) (current_thread_info()->addr_limit = (x))
19033
19034 /*
19035 * Copy To/From Userspace
19036 @@ -17,14 +20,14 @@
19037
19038 /* Handles exceptions in both to and from, but doesn't do access_ok */
19039 __must_check unsigned long
19040 -copy_user_enhanced_fast_string(void *to, const void *from, unsigned len);
19041 +copy_user_enhanced_fast_string(void *to, const void *from, unsigned len) __size_overflow(3);
19042 __must_check unsigned long
19043 -copy_user_generic_string(void *to, const void *from, unsigned len);
19044 +copy_user_generic_string(void *to, const void *from, unsigned len) __size_overflow(3);
19045 __must_check unsigned long
19046 -copy_user_generic_unrolled(void *to, const void *from, unsigned len);
19047 +copy_user_generic_unrolled(void *to, const void *from, unsigned len) __size_overflow(3);
19048
19049 -static __always_inline __must_check unsigned long
19050 -copy_user_generic(void *to, const void *from, unsigned len)
19051 +static __always_inline __must_check unsigned long
19052 +copy_user_generic(void *to, const void *from, unsigned long len)
19053 {
19054 unsigned ret;
19055
19056 @@ -45,138 +48,200 @@ copy_user_generic(void *to, const void *from, unsigned len)
19057 return ret;
19058 }
19059
19060 +static __always_inline __must_check unsigned long
19061 +__copy_to_user(void __user *to, const void *from, unsigned long len);
19062 +static __always_inline __must_check unsigned long
19063 +__copy_from_user(void *to, const void __user *from, unsigned long len);
19064 __must_check unsigned long
19065 -_copy_to_user(void __user *to, const void *from, unsigned len);
19066 -__must_check unsigned long
19067 -_copy_from_user(void *to, const void __user *from, unsigned len);
19068 -__must_check unsigned long
19069 -copy_in_user(void __user *to, const void __user *from, unsigned len);
19070 +copy_in_user(void __user *to, const void __user *from, unsigned long len);
19071 +
19072 +extern void copy_to_user_overflow(void)
19073 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19074 + __compiletime_error("copy_to_user() buffer size is not provably correct")
19075 +#else
19076 + __compiletime_warning("copy_to_user() buffer size is not provably correct")
19077 +#endif
19078 +;
19079 +
19080 +extern void copy_from_user_overflow(void)
19081 +#ifdef CONFIG_DEBUG_STRICT_USER_COPY_CHECKS
19082 + __compiletime_error("copy_from_user() buffer size is not provably correct")
19083 +#else
19084 + __compiletime_warning("copy_from_user() buffer size is not provably correct")
19085 +#endif
19086 +;
19087
19088 static inline unsigned long __must_check copy_from_user(void *to,
19089 const void __user *from,
19090 unsigned long n)
19091 {
19092 - int sz = __compiletime_object_size(to);
19093 -
19094 might_fault();
19095 - if (likely(sz == -1 || sz >= n))
19096 - n = _copy_from_user(to, from, n);
19097 -#ifdef CONFIG_DEBUG_VM
19098 - else
19099 - WARN(1, "Buffer overflow detected!\n");
19100 -#endif
19101 +
19102 + check_object_size(to, n, false);
19103 +
19104 + if (access_ok(VERIFY_READ, from, n))
19105 + n = __copy_from_user(to, from, n);
19106 + else if (n < INT_MAX)
19107 + memset(to, 0, n);
19108 return n;
19109 }
19110
19111 static __always_inline __must_check
19112 -int copy_to_user(void __user *dst, const void *src, unsigned size)
19113 +int copy_to_user(void __user *dst, const void *src, unsigned long size)
19114 {
19115 might_fault();
19116
19117 - return _copy_to_user(dst, src, size);
19118 + if (access_ok(VERIFY_WRITE, dst, size))
19119 + size = __copy_to_user(dst, src, size);
19120 + return size;
19121 }
19122
19123 static __always_inline __must_check
19124 -int __copy_from_user(void *dst, const void __user *src, unsigned size)
19125 +unsigned long __copy_from_user(void *dst, const void __user *src, unsigned long size)
19126 {
19127 - int ret = 0;
19128 + size_t sz = __compiletime_object_size(dst);
19129 + unsigned ret = 0;
19130
19131 might_fault();
19132 +
19133 + if (size > INT_MAX)
19134 + return size;
19135 +
19136 + check_object_size(dst, size, false);
19137 +
19138 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19139 + if (!__access_ok(VERIFY_READ, src, size))
19140 + return size;
19141 +#endif
19142 +
19143 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19144 + copy_from_user_overflow();
19145 + return size;
19146 + }
19147 +
19148 if (!__builtin_constant_p(size))
19149 - return copy_user_generic(dst, (__force void *)src, size);
19150 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19151 switch (size) {
19152 - case 1:__get_user_asm(*(u8 *)dst, (u8 __user *)src,
19153 + case 1:__get_user_asm(*(u8 *)dst, (const u8 __user *)src,
19154 ret, "b", "b", "=q", 1);
19155 return ret;
19156 - case 2:__get_user_asm(*(u16 *)dst, (u16 __user *)src,
19157 + case 2:__get_user_asm(*(u16 *)dst, (const u16 __user *)src,
19158 ret, "w", "w", "=r", 2);
19159 return ret;
19160 - case 4:__get_user_asm(*(u32 *)dst, (u32 __user *)src,
19161 + case 4:__get_user_asm(*(u32 *)dst, (const u32 __user *)src,
19162 ret, "l", "k", "=r", 4);
19163 return ret;
19164 - case 8:__get_user_asm(*(u64 *)dst, (u64 __user *)src,
19165 + case 8:__get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19166 ret, "q", "", "=r", 8);
19167 return ret;
19168 case 10:
19169 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19170 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19171 ret, "q", "", "=r", 10);
19172 if (unlikely(ret))
19173 return ret;
19174 __get_user_asm(*(u16 *)(8 + (char *)dst),
19175 - (u16 __user *)(8 + (char __user *)src),
19176 + (const u16 __user *)(8 + (const char __user *)src),
19177 ret, "w", "w", "=r", 2);
19178 return ret;
19179 case 16:
19180 - __get_user_asm(*(u64 *)dst, (u64 __user *)src,
19181 + __get_user_asm(*(u64 *)dst, (const u64 __user *)src,
19182 ret, "q", "", "=r", 16);
19183 if (unlikely(ret))
19184 return ret;
19185 __get_user_asm(*(u64 *)(8 + (char *)dst),
19186 - (u64 __user *)(8 + (char __user *)src),
19187 + (const u64 __user *)(8 + (const char __user *)src),
19188 ret, "q", "", "=r", 8);
19189 return ret;
19190 default:
19191 - return copy_user_generic(dst, (__force void *)src, size);
19192 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19193 }
19194 }
19195
19196 static __always_inline __must_check
19197 -int __copy_to_user(void __user *dst, const void *src, unsigned size)
19198 +unsigned long __copy_to_user(void __user *dst, const void *src, unsigned long size)
19199 {
19200 - int ret = 0;
19201 + size_t sz = __compiletime_object_size(src);
19202 + unsigned ret = 0;
19203
19204 might_fault();
19205 +
19206 + if (size > INT_MAX)
19207 + return size;
19208 +
19209 + check_object_size(src, size, true);
19210 +
19211 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19212 + if (!__access_ok(VERIFY_WRITE, dst, size))
19213 + return size;
19214 +#endif
19215 +
19216 + if (unlikely(sz != (size_t)-1 && sz < size)) {
19217 + copy_to_user_overflow();
19218 + return size;
19219 + }
19220 +
19221 if (!__builtin_constant_p(size))
19222 - return copy_user_generic((__force void *)dst, src, size);
19223 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19224 switch (size) {
19225 - case 1:__put_user_asm(*(u8 *)src, (u8 __user *)dst,
19226 + case 1:__put_user_asm(*(const u8 *)src, (u8 __user *)dst,
19227 ret, "b", "b", "iq", 1);
19228 return ret;
19229 - case 2:__put_user_asm(*(u16 *)src, (u16 __user *)dst,
19230 + case 2:__put_user_asm(*(const u16 *)src, (u16 __user *)dst,
19231 ret, "w", "w", "ir", 2);
19232 return ret;
19233 - case 4:__put_user_asm(*(u32 *)src, (u32 __user *)dst,
19234 + case 4:__put_user_asm(*(const u32 *)src, (u32 __user *)dst,
19235 ret, "l", "k", "ir", 4);
19236 return ret;
19237 - case 8:__put_user_asm(*(u64 *)src, (u64 __user *)dst,
19238 + case 8:__put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19239 ret, "q", "", "er", 8);
19240 return ret;
19241 case 10:
19242 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
19243 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19244 ret, "q", "", "er", 10);
19245 if (unlikely(ret))
19246 return ret;
19247 asm("":::"memory");
19248 - __put_user_asm(4[(u16 *)src], 4 + (u16 __user *)dst,
19249 + __put_user_asm(4[(const u16 *)src], 4 + (u16 __user *)dst,
19250 ret, "w", "w", "ir", 2);
19251 return ret;
19252 case 16:
19253 - __put_user_asm(*(u64 *)src, (u64 __user *)dst,
19254 + __put_user_asm(*(const u64 *)src, (u64 __user *)dst,
19255 ret, "q", "", "er", 16);
19256 if (unlikely(ret))
19257 return ret;
19258 asm("":::"memory");
19259 - __put_user_asm(1[(u64 *)src], 1 + (u64 __user *)dst,
19260 + __put_user_asm(1[(const u64 *)src], 1 + (u64 __user *)dst,
19261 ret, "q", "", "er", 8);
19262 return ret;
19263 default:
19264 - return copy_user_generic((__force void *)dst, src, size);
19265 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19266 }
19267 }
19268
19269 static __always_inline __must_check
19270 -int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19271 +unsigned long __copy_in_user(void __user *dst, const void __user *src, unsigned long size)
19272 {
19273 - int ret = 0;
19274 + unsigned ret = 0;
19275
19276 might_fault();
19277 +
19278 + if (size > INT_MAX)
19279 + return size;
19280 +
19281 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19282 + if (!__access_ok(VERIFY_READ, src, size))
19283 + return size;
19284 + if (!__access_ok(VERIFY_WRITE, dst, size))
19285 + return size;
19286 +#endif
19287 +
19288 if (!__builtin_constant_p(size))
19289 - return copy_user_generic((__force void *)dst,
19290 - (__force void *)src, size);
19291 + return copy_user_generic((__force_kernel void *)____m(dst),
19292 + (__force_kernel const void *)____m(src), size);
19293 switch (size) {
19294 case 1: {
19295 u8 tmp;
19296 - __get_user_asm(tmp, (u8 __user *)src,
19297 + __get_user_asm(tmp, (const u8 __user *)src,
19298 ret, "b", "b", "=q", 1);
19299 if (likely(!ret))
19300 __put_user_asm(tmp, (u8 __user *)dst,
19301 @@ -185,7 +250,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19302 }
19303 case 2: {
19304 u16 tmp;
19305 - __get_user_asm(tmp, (u16 __user *)src,
19306 + __get_user_asm(tmp, (const u16 __user *)src,
19307 ret, "w", "w", "=r", 2);
19308 if (likely(!ret))
19309 __put_user_asm(tmp, (u16 __user *)dst,
19310 @@ -195,7 +260,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19311
19312 case 4: {
19313 u32 tmp;
19314 - __get_user_asm(tmp, (u32 __user *)src,
19315 + __get_user_asm(tmp, (const u32 __user *)src,
19316 ret, "l", "k", "=r", 4);
19317 if (likely(!ret))
19318 __put_user_asm(tmp, (u32 __user *)dst,
19319 @@ -204,7 +269,7 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19320 }
19321 case 8: {
19322 u64 tmp;
19323 - __get_user_asm(tmp, (u64 __user *)src,
19324 + __get_user_asm(tmp, (const u64 __user *)src,
19325 ret, "q", "", "=r", 8);
19326 if (likely(!ret))
19327 __put_user_asm(tmp, (u64 __user *)dst,
19328 @@ -212,41 +277,74 @@ int __copy_in_user(void __user *dst, const void __user *src, unsigned size)
19329 return ret;
19330 }
19331 default:
19332 - return copy_user_generic((__force void *)dst,
19333 - (__force void *)src, size);
19334 + return copy_user_generic((__force_kernel void *)____m(dst),
19335 + (__force_kernel const void *)____m(src), size);
19336 }
19337 }
19338
19339 -static __must_check __always_inline int
19340 -__copy_from_user_inatomic(void *dst, const void __user *src, unsigned size)
19341 +static __must_check __always_inline unsigned long
19342 +__copy_from_user_inatomic(void *dst, const void __user *src, unsigned long size)
19343 {
19344 - return copy_user_generic(dst, (__force const void *)src, size);
19345 + if (size > INT_MAX)
19346 + return size;
19347 +
19348 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19349 + if (!__access_ok(VERIFY_READ, src, size))
19350 + return size;
19351 +#endif
19352 +
19353 + return copy_user_generic(dst, (__force_kernel const void *)____m(src), size);
19354 }
19355
19356 -static __must_check __always_inline int
19357 -__copy_to_user_inatomic(void __user *dst, const void *src, unsigned size)
19358 +static __must_check __always_inline unsigned long
19359 +__copy_to_user_inatomic(void __user *dst, const void *src, unsigned long size)
19360 {
19361 - return copy_user_generic((__force void *)dst, src, size);
19362 + if (size > INT_MAX)
19363 + return size;
19364 +
19365 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19366 + if (!__access_ok(VERIFY_WRITE, dst, size))
19367 + return size;
19368 +#endif
19369 +
19370 + return copy_user_generic((__force_kernel void *)____m(dst), src, size);
19371 }
19372
19373 -extern long __copy_user_nocache(void *dst, const void __user *src,
19374 - unsigned size, int zerorest);
19375 +extern unsigned long __copy_user_nocache(void *dst, const void __user *src,
19376 + unsigned long size, int zerorest);
19377
19378 -static inline int
19379 -__copy_from_user_nocache(void *dst, const void __user *src, unsigned size)
19380 +static inline unsigned long
19381 +__copy_from_user_nocache(void *dst, const void __user *src, unsigned long size)
19382 {
19383 might_fault();
19384 +
19385 + if (size > INT_MAX)
19386 + return size;
19387 +
19388 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19389 + if (!__access_ok(VERIFY_READ, src, size))
19390 + return size;
19391 +#endif
19392 +
19393 return __copy_user_nocache(dst, src, size, 1);
19394 }
19395
19396 -static inline int
19397 +static inline unsigned long
19398 __copy_from_user_inatomic_nocache(void *dst, const void __user *src,
19399 - unsigned size)
19400 + unsigned long size)
19401 {
19402 + if (size > INT_MAX)
19403 + return size;
19404 +
19405 +#ifdef CONFIG_PAX_MEMORY_UDEREF
19406 + if (!__access_ok(VERIFY_READ, src, size))
19407 + return size;
19408 +#endif
19409 +
19410 return __copy_user_nocache(dst, src, size, 0);
19411 }
19412
19413 unsigned long
19414 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest);
19415 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest) __size_overflow(3);
19416
19417 #endif /* _ASM_X86_UACCESS_64_H */
19418 diff --git a/arch/x86/include/asm/word-at-a-time.h b/arch/x86/include/asm/word-at-a-time.h
19419 index 5b238981..77fdd78 100644
19420 --- a/arch/x86/include/asm/word-at-a-time.h
19421 +++ b/arch/x86/include/asm/word-at-a-time.h
19422 @@ -11,7 +11,7 @@
19423 * and shift, for example.
19424 */
19425 struct word_at_a_time {
19426 - const unsigned long one_bits, high_bits;
19427 + unsigned long one_bits, high_bits;
19428 };
19429
19430 #define WORD_AT_A_TIME_CONSTANTS { REPEAT_BYTE(0x01), REPEAT_BYTE(0x80) }
19431 diff --git a/arch/x86/include/asm/x86_init.h b/arch/x86/include/asm/x86_init.h
19432 index 828a156..650e625 100644
19433 --- a/arch/x86/include/asm/x86_init.h
19434 +++ b/arch/x86/include/asm/x86_init.h
19435 @@ -129,7 +129,7 @@ struct x86_init_ops {
19436 struct x86_init_timers timers;
19437 struct x86_init_iommu iommu;
19438 struct x86_init_pci pci;
19439 -};
19440 +} __no_const;
19441
19442 /**
19443 * struct x86_cpuinit_ops - platform specific cpu hotplug setups
19444 @@ -140,7 +140,7 @@ struct x86_cpuinit_ops {
19445 void (*setup_percpu_clockev)(void);
19446 void (*early_percpu_clock_init)(void);
19447 void (*fixup_cpu_id)(struct cpuinfo_x86 *c, int node);
19448 -};
19449 +} __no_const;
19450
19451 struct timespec;
19452
19453 @@ -168,7 +168,7 @@ struct x86_platform_ops {
19454 void (*save_sched_clock_state)(void);
19455 void (*restore_sched_clock_state)(void);
19456 void (*apic_post_init)(void);
19457 -};
19458 +} __no_const;
19459
19460 struct pci_dev;
19461 struct msi_msg;
19462 @@ -182,7 +182,7 @@ struct x86_msi_ops {
19463 void (*teardown_msi_irqs)(struct pci_dev *dev);
19464 void (*restore_msi_irqs)(struct pci_dev *dev, int irq);
19465 int (*setup_hpet_msi)(unsigned int irq, unsigned int id);
19466 -};
19467 +} __no_const;
19468
19469 struct IO_APIC_route_entry;
19470 struct io_apic_irq_attr;
19471 @@ -203,7 +203,7 @@ struct x86_io_apic_ops {
19472 unsigned int destination, int vector,
19473 struct io_apic_irq_attr *attr);
19474 void (*eoi_ioapic_pin)(int apic, int pin, int vector);
19475 -};
19476 +} __no_const;
19477
19478 extern struct x86_init_ops x86_init;
19479 extern struct x86_cpuinit_ops x86_cpuinit;
19480 diff --git a/arch/x86/include/asm/xen/page.h b/arch/x86/include/asm/xen/page.h
19481 index b913915..4f5a581 100644
19482 --- a/arch/x86/include/asm/xen/page.h
19483 +++ b/arch/x86/include/asm/xen/page.h
19484 @@ -56,7 +56,7 @@ extern int m2p_remove_override(struct page *page,
19485 extern struct page *m2p_find_override(unsigned long mfn);
19486 extern unsigned long m2p_find_override_pfn(unsigned long mfn, unsigned long pfn);
19487
19488 -static inline unsigned long pfn_to_mfn(unsigned long pfn)
19489 +static inline unsigned long __intentional_overflow(-1) pfn_to_mfn(unsigned long pfn)
19490 {
19491 unsigned long mfn;
19492
19493 diff --git a/arch/x86/include/asm/xsave.h b/arch/x86/include/asm/xsave.h
19494 index 0415cda..3b22adc 100644
19495 --- a/arch/x86/include/asm/xsave.h
19496 +++ b/arch/x86/include/asm/xsave.h
19497 @@ -70,8 +70,11 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19498 if (unlikely(err))
19499 return -EFAULT;
19500
19501 + pax_open_userland();
19502 __asm__ __volatile__(ASM_STAC "\n"
19503 - "1: .byte " REX_PREFIX "0x0f,0xae,0x27\n"
19504 + "1:"
19505 + __copyuser_seg
19506 + ".byte " REX_PREFIX "0x0f,0xae,0x27\n"
19507 "2: " ASM_CLAC "\n"
19508 ".section .fixup,\"ax\"\n"
19509 "3: movl $-1,%[err]\n"
19510 @@ -81,18 +84,22 @@ static inline int xsave_user(struct xsave_struct __user *buf)
19511 : [err] "=r" (err)
19512 : "D" (buf), "a" (-1), "d" (-1), "0" (0)
19513 : "memory");
19514 + pax_close_userland();
19515 return err;
19516 }
19517
19518 static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19519 {
19520 int err;
19521 - struct xsave_struct *xstate = ((__force struct xsave_struct *)buf);
19522 + struct xsave_struct *xstate = ((__force_kernel struct xsave_struct *)buf);
19523 u32 lmask = mask;
19524 u32 hmask = mask >> 32;
19525
19526 + pax_open_userland();
19527 __asm__ __volatile__(ASM_STAC "\n"
19528 - "1: .byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19529 + "1:"
19530 + __copyuser_seg
19531 + ".byte " REX_PREFIX "0x0f,0xae,0x2f\n"
19532 "2: " ASM_CLAC "\n"
19533 ".section .fixup,\"ax\"\n"
19534 "3: movl $-1,%[err]\n"
19535 @@ -102,6 +109,7 @@ static inline int xrestore_user(struct xsave_struct __user *buf, u64 mask)
19536 : [err] "=r" (err)
19537 : "D" (xstate), "a" (lmask), "d" (hmask), "0" (0)
19538 : "memory"); /* memory required? */
19539 + pax_close_userland();
19540 return err;
19541 }
19542
19543 diff --git a/arch/x86/include/uapi/asm/e820.h b/arch/x86/include/uapi/asm/e820.h
19544 index bbae024..e1528f9 100644
19545 --- a/arch/x86/include/uapi/asm/e820.h
19546 +++ b/arch/x86/include/uapi/asm/e820.h
19547 @@ -63,7 +63,7 @@ struct e820map {
19548 #define ISA_START_ADDRESS 0xa0000
19549 #define ISA_END_ADDRESS 0x100000
19550
19551 -#define BIOS_BEGIN 0x000a0000
19552 +#define BIOS_BEGIN 0x000c0000
19553 #define BIOS_END 0x00100000
19554
19555 #define BIOS_ROM_BASE 0xffe00000
19556 diff --git a/arch/x86/include/uapi/asm/ptrace-abi.h b/arch/x86/include/uapi/asm/ptrace-abi.h
19557 index 7b0a55a..ad115bf 100644
19558 --- a/arch/x86/include/uapi/asm/ptrace-abi.h
19559 +++ b/arch/x86/include/uapi/asm/ptrace-abi.h
19560 @@ -49,7 +49,6 @@
19561 #define EFLAGS 144
19562 #define RSP 152
19563 #define SS 160
19564 -#define ARGOFFSET R11
19565 #endif /* __ASSEMBLY__ */
19566
19567 /* top of stack page */
19568 diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
19569 index a5408b9..5133813 100644
19570 --- a/arch/x86/kernel/Makefile
19571 +++ b/arch/x86/kernel/Makefile
19572 @@ -24,7 +24,7 @@ obj-y += time.o ioport.o ldt.o dumpstack.o nmi.o
19573 obj-y += setup.o x86_init.o i8259.o irqinit.o jump_label.o
19574 obj-$(CONFIG_IRQ_WORK) += irq_work.o
19575 obj-y += probe_roms.o
19576 -obj-$(CONFIG_X86_32) += i386_ksyms_32.o
19577 +obj-$(CONFIG_X86_32) += sys_i386_32.o i386_ksyms_32.o
19578 obj-$(CONFIG_X86_64) += sys_x86_64.o x8664_ksyms_64.o
19579 obj-y += syscall_$(BITS).o
19580 obj-$(CONFIG_X86_64) += vsyscall_64.o
19581 diff --git a/arch/x86/kernel/acpi/boot.c b/arch/x86/kernel/acpi/boot.c
19582 index 40c7660..f709f4b 100644
19583 --- a/arch/x86/kernel/acpi/boot.c
19584 +++ b/arch/x86/kernel/acpi/boot.c
19585 @@ -1365,7 +1365,7 @@ static int __init dmi_ignore_irq0_timer_override(const struct dmi_system_id *d)
19586 * If your system is blacklisted here, but you find that acpi=force
19587 * works for you, please contact linux-acpi@vger.kernel.org
19588 */
19589 -static struct dmi_system_id __initdata acpi_dmi_table[] = {
19590 +static const struct dmi_system_id __initconst acpi_dmi_table[] = {
19591 /*
19592 * Boxes that need ACPI disabled
19593 */
19594 @@ -1440,7 +1440,7 @@ static struct dmi_system_id __initdata acpi_dmi_table[] = {
19595 };
19596
19597 /* second table for DMI checks that should run after early-quirks */
19598 -static struct dmi_system_id __initdata acpi_dmi_table_late[] = {
19599 +static const struct dmi_system_id __initconst acpi_dmi_table_late[] = {
19600 /*
19601 * HP laptops which use a DSDT reporting as HP/SB400/10000,
19602 * which includes some code which overrides all temperature
19603 diff --git a/arch/x86/kernel/acpi/sleep.c b/arch/x86/kernel/acpi/sleep.c
19604 index 3312010..a65ca7b 100644
19605 --- a/arch/x86/kernel/acpi/sleep.c
19606 +++ b/arch/x86/kernel/acpi/sleep.c
19607 @@ -88,8 +88,12 @@ int x86_acpi_suspend_lowlevel(void)
19608 #else /* CONFIG_64BIT */
19609 #ifdef CONFIG_SMP
19610 stack_start = (unsigned long)temp_stack + sizeof(temp_stack);
19611 +
19612 + pax_open_kernel();
19613 early_gdt_descr.address =
19614 (unsigned long)get_cpu_gdt_table(smp_processor_id());
19615 + pax_close_kernel();
19616 +
19617 initial_gs = per_cpu_offset(smp_processor_id());
19618 #endif
19619 initial_code = (unsigned long)wakeup_long64;
19620 diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
19621 index d1daa66..59fecba 100644
19622 --- a/arch/x86/kernel/acpi/wakeup_32.S
19623 +++ b/arch/x86/kernel/acpi/wakeup_32.S
19624 @@ -29,13 +29,11 @@ wakeup_pmode_return:
19625 # and restore the stack ... but you need gdt for this to work
19626 movl saved_context_esp, %esp
19627
19628 - movl %cs:saved_magic, %eax
19629 - cmpl $0x12345678, %eax
19630 + cmpl $0x12345678, saved_magic
19631 jne bogus_magic
19632
19633 # jump to place where we left off
19634 - movl saved_eip, %eax
19635 - jmp *%eax
19636 + jmp *(saved_eip)
19637
19638 bogus_magic:
19639 jmp bogus_magic
19640 diff --git a/arch/x86/kernel/alternative.c b/arch/x86/kernel/alternative.c
19641 index 15e8563..323cbe1 100644
19642 --- a/arch/x86/kernel/alternative.c
19643 +++ b/arch/x86/kernel/alternative.c
19644 @@ -269,6 +269,13 @@ void __init_or_module apply_alternatives(struct alt_instr *start,
19645 */
19646 for (a = start; a < end; a++) {
19647 instr = (u8 *)&a->instr_offset + a->instr_offset;
19648 +
19649 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19650 + instr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19651 + if (instr < (u8 *)_text || (u8 *)_einittext <= instr)
19652 + instr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19653 +#endif
19654 +
19655 replacement = (u8 *)&a->repl_offset + a->repl_offset;
19656 BUG_ON(a->replacementlen > a->instrlen);
19657 BUG_ON(a->instrlen > sizeof(insnbuf));
19658 @@ -300,10 +307,16 @@ static void alternatives_smp_lock(const s32 *start, const s32 *end,
19659 for (poff = start; poff < end; poff++) {
19660 u8 *ptr = (u8 *)poff + *poff;
19661
19662 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19663 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19664 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19665 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19666 +#endif
19667 +
19668 if (!*poff || ptr < text || ptr >= text_end)
19669 continue;
19670 /* turn DS segment override prefix into lock prefix */
19671 - if (*ptr == 0x3e)
19672 + if (*ktla_ktva(ptr) == 0x3e)
19673 text_poke(ptr, ((unsigned char []){0xf0}), 1);
19674 }
19675 mutex_unlock(&text_mutex);
19676 @@ -318,10 +331,16 @@ static void alternatives_smp_unlock(const s32 *start, const s32 *end,
19677 for (poff = start; poff < end; poff++) {
19678 u8 *ptr = (u8 *)poff + *poff;
19679
19680 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
19681 + ptr += ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19682 + if (ptr < (u8 *)_text || (u8 *)_einittext <= ptr)
19683 + ptr -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
19684 +#endif
19685 +
19686 if (!*poff || ptr < text || ptr >= text_end)
19687 continue;
19688 /* turn lock prefix into DS segment override prefix */
19689 - if (*ptr == 0xf0)
19690 + if (*ktla_ktva(ptr) == 0xf0)
19691 text_poke(ptr, ((unsigned char []){0x3E}), 1);
19692 }
19693 mutex_unlock(&text_mutex);
19694 @@ -469,7 +488,7 @@ void __init_or_module apply_paravirt(struct paravirt_patch_site *start,
19695
19696 BUG_ON(p->len > MAX_PATCH_LEN);
19697 /* prep the buffer with the original instructions */
19698 - memcpy(insnbuf, p->instr, p->len);
19699 + memcpy(insnbuf, ktla_ktva(p->instr), p->len);
19700 used = pv_init_ops.patch(p->instrtype, p->clobbers, insnbuf,
19701 (unsigned long)p->instr, p->len);
19702
19703 @@ -516,7 +535,7 @@ void __init alternative_instructions(void)
19704 if (!uniproc_patched || num_possible_cpus() == 1)
19705 free_init_pages("SMP alternatives",
19706 (unsigned long)__smp_locks,
19707 - (unsigned long)__smp_locks_end);
19708 + PAGE_ALIGN((unsigned long)__smp_locks_end));
19709 #endif
19710
19711 apply_paravirt(__parainstructions, __parainstructions_end);
19712 @@ -536,13 +555,17 @@ void __init alternative_instructions(void)
19713 * instructions. And on the local CPU you need to be protected again NMI or MCE
19714 * handlers seeing an inconsistent instruction while you patch.
19715 */
19716 -void *__init_or_module text_poke_early(void *addr, const void *opcode,
19717 +void *__kprobes text_poke_early(void *addr, const void *opcode,
19718 size_t len)
19719 {
19720 unsigned long flags;
19721 local_irq_save(flags);
19722 - memcpy(addr, opcode, len);
19723 +
19724 + pax_open_kernel();
19725 + memcpy(ktla_ktva(addr), opcode, len);
19726 sync_core();
19727 + pax_close_kernel();
19728 +
19729 local_irq_restore(flags);
19730 /* Could also do a CLFLUSH here to speed up CPU recovery; but
19731 that causes hangs on some VIA CPUs. */
19732 @@ -564,36 +587,22 @@ void *__init_or_module text_poke_early(void *addr, const void *opcode,
19733 */
19734 void *__kprobes text_poke(void *addr, const void *opcode, size_t len)
19735 {
19736 - unsigned long flags;
19737 - char *vaddr;
19738 + unsigned char *vaddr = ktla_ktva(addr);
19739 struct page *pages[2];
19740 - int i;
19741 + size_t i;
19742
19743 if (!core_kernel_text((unsigned long)addr)) {
19744 - pages[0] = vmalloc_to_page(addr);
19745 - pages[1] = vmalloc_to_page(addr + PAGE_SIZE);
19746 + pages[0] = vmalloc_to_page(vaddr);
19747 + pages[1] = vmalloc_to_page(vaddr + PAGE_SIZE);
19748 } else {
19749 - pages[0] = virt_to_page(addr);
19750 + pages[0] = virt_to_page(vaddr);
19751 WARN_ON(!PageReserved(pages[0]));
19752 - pages[1] = virt_to_page(addr + PAGE_SIZE);
19753 + pages[1] = virt_to_page(vaddr + PAGE_SIZE);
19754 }
19755 BUG_ON(!pages[0]);
19756 - local_irq_save(flags);
19757 - set_fixmap(FIX_TEXT_POKE0, page_to_phys(pages[0]));
19758 - if (pages[1])
19759 - set_fixmap(FIX_TEXT_POKE1, page_to_phys(pages[1]));
19760 - vaddr = (char *)fix_to_virt(FIX_TEXT_POKE0);
19761 - memcpy(&vaddr[(unsigned long)addr & ~PAGE_MASK], opcode, len);
19762 - clear_fixmap(FIX_TEXT_POKE0);
19763 - if (pages[1])
19764 - clear_fixmap(FIX_TEXT_POKE1);
19765 - local_flush_tlb();
19766 - sync_core();
19767 - /* Could also do a CLFLUSH here to speed up CPU recovery; but
19768 - that causes hangs on some VIA CPUs. */
19769 + text_poke_early(addr, opcode, len);
19770 for (i = 0; i < len; i++)
19771 - BUG_ON(((char *)addr)[i] != ((char *)opcode)[i]);
19772 - local_irq_restore(flags);
19773 + BUG_ON((vaddr)[i] != ((const unsigned char *)opcode)[i]);
19774 return addr;
19775 }
19776
19777 @@ -613,7 +622,7 @@ int poke_int3_handler(struct pt_regs *regs)
19778 if (likely(!bp_patching_in_progress))
19779 return 0;
19780
19781 - if (user_mode_vm(regs) || regs->ip != (unsigned long)bp_int3_addr)
19782 + if (user_mode(regs) || regs->ip != (unsigned long)bp_int3_addr)
19783 return 0;
19784
19785 /* set up the specified breakpoint handler */
19786 @@ -647,7 +656,7 @@ int poke_int3_handler(struct pt_regs *regs)
19787 */
19788 void *text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
19789 {
19790 - unsigned char int3 = 0xcc;
19791 + const unsigned char int3 = 0xcc;
19792
19793 bp_int3_handler = handler;
19794 bp_int3_addr = (u8 *)addr + sizeof(int3);
19795 diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
19796 index a7eb82d..f6e52d4 100644
19797 --- a/arch/x86/kernel/apic/apic.c
19798 +++ b/arch/x86/kernel/apic/apic.c
19799 @@ -190,7 +190,7 @@ int first_system_vector = 0xfe;
19800 /*
19801 * Debug level, exported for io_apic.c
19802 */
19803 -unsigned int apic_verbosity;
19804 +int apic_verbosity;
19805
19806 int pic_mode;
19807
19808 @@ -1985,7 +1985,7 @@ static inline void __smp_error_interrupt(struct pt_regs *regs)
19809 apic_write(APIC_ESR, 0);
19810 v1 = apic_read(APIC_ESR);
19811 ack_APIC_irq();
19812 - atomic_inc(&irq_err_count);
19813 + atomic_inc_unchecked(&irq_err_count);
19814
19815 apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
19816 smp_processor_id(), v0 , v1);
19817 diff --git a/arch/x86/kernel/apic/apic_flat_64.c b/arch/x86/kernel/apic/apic_flat_64.c
19818 index 00c77cf..2dc6a2d 100644
19819 --- a/arch/x86/kernel/apic/apic_flat_64.c
19820 +++ b/arch/x86/kernel/apic/apic_flat_64.c
19821 @@ -157,7 +157,7 @@ static int flat_probe(void)
19822 return 1;
19823 }
19824
19825 -static struct apic apic_flat = {
19826 +static struct apic apic_flat __read_only = {
19827 .name = "flat",
19828 .probe = flat_probe,
19829 .acpi_madt_oem_check = flat_acpi_madt_oem_check,
19830 @@ -271,7 +271,7 @@ static int physflat_probe(void)
19831 return 0;
19832 }
19833
19834 -static struct apic apic_physflat = {
19835 +static struct apic apic_physflat __read_only = {
19836
19837 .name = "physical flat",
19838 .probe = physflat_probe,
19839 diff --git a/arch/x86/kernel/apic/apic_noop.c b/arch/x86/kernel/apic/apic_noop.c
19840 index e145f28..2752888 100644
19841 --- a/arch/x86/kernel/apic/apic_noop.c
19842 +++ b/arch/x86/kernel/apic/apic_noop.c
19843 @@ -119,7 +119,7 @@ static void noop_apic_write(u32 reg, u32 v)
19844 WARN_ON_ONCE(cpu_has_apic && !disable_apic);
19845 }
19846
19847 -struct apic apic_noop = {
19848 +struct apic apic_noop __read_only = {
19849 .name = "noop",
19850 .probe = noop_probe,
19851 .acpi_madt_oem_check = NULL,
19852 diff --git a/arch/x86/kernel/apic/bigsmp_32.c b/arch/x86/kernel/apic/bigsmp_32.c
19853 index d50e364..543bee3 100644
19854 --- a/arch/x86/kernel/apic/bigsmp_32.c
19855 +++ b/arch/x86/kernel/apic/bigsmp_32.c
19856 @@ -152,7 +152,7 @@ static int probe_bigsmp(void)
19857 return dmi_bigsmp;
19858 }
19859
19860 -static struct apic apic_bigsmp = {
19861 +static struct apic apic_bigsmp __read_only = {
19862
19863 .name = "bigsmp",
19864 .probe = probe_bigsmp,
19865 diff --git a/arch/x86/kernel/apic/es7000_32.c b/arch/x86/kernel/apic/es7000_32.c
19866 index c552247..587a316 100644
19867 --- a/arch/x86/kernel/apic/es7000_32.c
19868 +++ b/arch/x86/kernel/apic/es7000_32.c
19869 @@ -608,8 +608,7 @@ static int es7000_mps_oem_check_cluster(struct mpc_table *mpc, char *oem,
19870 return ret && es7000_apic_is_cluster();
19871 }
19872
19873 -/* We've been warned by a false positive warning.Use __refdata to keep calm. */
19874 -static struct apic __refdata apic_es7000_cluster = {
19875 +static struct apic apic_es7000_cluster __read_only = {
19876
19877 .name = "es7000",
19878 .probe = probe_es7000,
19879 @@ -675,7 +674,7 @@ static struct apic __refdata apic_es7000_cluster = {
19880 .x86_32_early_logical_apicid = es7000_early_logical_apicid,
19881 };
19882
19883 -static struct apic __refdata apic_es7000 = {
19884 +static struct apic apic_es7000 __read_only = {
19885
19886 .name = "es7000",
19887 .probe = probe_es7000,
19888 diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
19889 index e63a5bd..c0babf8 100644
19890 --- a/arch/x86/kernel/apic/io_apic.c
19891 +++ b/arch/x86/kernel/apic/io_apic.c
19892 @@ -1060,7 +1060,7 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
19893 }
19894 EXPORT_SYMBOL(IO_APIC_get_PCI_irq_vector);
19895
19896 -void lock_vector_lock(void)
19897 +void lock_vector_lock(void) __acquires(vector_lock)
19898 {
19899 /* Used to the online set of cpus does not change
19900 * during assign_irq_vector.
19901 @@ -1068,7 +1068,7 @@ void lock_vector_lock(void)
19902 raw_spin_lock(&vector_lock);
19903 }
19904
19905 -void unlock_vector_lock(void)
19906 +void unlock_vector_lock(void) __releases(vector_lock)
19907 {
19908 raw_spin_unlock(&vector_lock);
19909 }
19910 @@ -2367,7 +2367,7 @@ static void ack_apic_edge(struct irq_data *data)
19911 ack_APIC_irq();
19912 }
19913
19914 -atomic_t irq_mis_count;
19915 +atomic_unchecked_t irq_mis_count;
19916
19917 #ifdef CONFIG_GENERIC_PENDING_IRQ
19918 static bool io_apic_level_ack_pending(struct irq_cfg *cfg)
19919 @@ -2508,7 +2508,7 @@ static void ack_apic_level(struct irq_data *data)
19920 * at the cpu.
19921 */
19922 if (!(v & (1 << (i & 0x1f)))) {
19923 - atomic_inc(&irq_mis_count);
19924 + atomic_inc_unchecked(&irq_mis_count);
19925
19926 eoi_ioapic_irq(irq, cfg);
19927 }
19928 diff --git a/arch/x86/kernel/apic/numaq_32.c b/arch/x86/kernel/apic/numaq_32.c
19929 index 1e42e8f..daacf44 100644
19930 --- a/arch/x86/kernel/apic/numaq_32.c
19931 +++ b/arch/x86/kernel/apic/numaq_32.c
19932 @@ -455,8 +455,7 @@ static void numaq_setup_portio_remap(void)
19933 (u_long) xquad_portio, (u_long) num_quads*XQUAD_PORTIO_QUAD);
19934 }
19935
19936 -/* Use __refdata to keep false positive warning calm. */
19937 -static struct apic __refdata apic_numaq = {
19938 +static struct apic apic_numaq __read_only = {
19939
19940 .name = "NUMAQ",
19941 .probe = probe_numaq,
19942 diff --git a/arch/x86/kernel/apic/probe_32.c b/arch/x86/kernel/apic/probe_32.c
19943 index eb35ef9..f184a21 100644
19944 --- a/arch/x86/kernel/apic/probe_32.c
19945 +++ b/arch/x86/kernel/apic/probe_32.c
19946 @@ -72,7 +72,7 @@ static int probe_default(void)
19947 return 1;
19948 }
19949
19950 -static struct apic apic_default = {
19951 +static struct apic apic_default __read_only = {
19952
19953 .name = "default",
19954 .probe = probe_default,
19955 diff --git a/arch/x86/kernel/apic/summit_32.c b/arch/x86/kernel/apic/summit_32.c
19956 index 77c95c0..434f8a4 100644
19957 --- a/arch/x86/kernel/apic/summit_32.c
19958 +++ b/arch/x86/kernel/apic/summit_32.c
19959 @@ -486,7 +486,7 @@ void setup_summit(void)
19960 }
19961 #endif
19962
19963 -static struct apic apic_summit = {
19964 +static struct apic apic_summit __read_only = {
19965
19966 .name = "summit",
19967 .probe = probe_summit,
19968 diff --git a/arch/x86/kernel/apic/x2apic_cluster.c b/arch/x86/kernel/apic/x2apic_cluster.c
19969 index 140e29d..d88bc95 100644
19970 --- a/arch/x86/kernel/apic/x2apic_cluster.c
19971 +++ b/arch/x86/kernel/apic/x2apic_cluster.c
19972 @@ -183,7 +183,7 @@ update_clusterinfo(struct notifier_block *nfb, unsigned long action, void *hcpu)
19973 return notifier_from_errno(err);
19974 }
19975
19976 -static struct notifier_block __refdata x2apic_cpu_notifier = {
19977 +static struct notifier_block x2apic_cpu_notifier = {
19978 .notifier_call = update_clusterinfo,
19979 };
19980
19981 @@ -235,7 +235,7 @@ static void cluster_vector_allocation_domain(int cpu, struct cpumask *retmask,
19982 cpumask_and(retmask, mask, per_cpu(cpus_in_cluster, cpu));
19983 }
19984
19985 -static struct apic apic_x2apic_cluster = {
19986 +static struct apic apic_x2apic_cluster __read_only = {
19987
19988 .name = "cluster x2apic",
19989 .probe = x2apic_cluster_probe,
19990 diff --git a/arch/x86/kernel/apic/x2apic_phys.c b/arch/x86/kernel/apic/x2apic_phys.c
19991 index 562a76d..a003c0f 100644
19992 --- a/arch/x86/kernel/apic/x2apic_phys.c
19993 +++ b/arch/x86/kernel/apic/x2apic_phys.c
19994 @@ -89,7 +89,7 @@ static int x2apic_phys_probe(void)
19995 return apic == &apic_x2apic_phys;
19996 }
19997
19998 -static struct apic apic_x2apic_phys = {
19999 +static struct apic apic_x2apic_phys __read_only = {
20000
20001 .name = "physical x2apic",
20002 .probe = x2apic_phys_probe,
20003 diff --git a/arch/x86/kernel/apic/x2apic_uv_x.c b/arch/x86/kernel/apic/x2apic_uv_x.c
20004 index a419814..1dd34a0 100644
20005 --- a/arch/x86/kernel/apic/x2apic_uv_x.c
20006 +++ b/arch/x86/kernel/apic/x2apic_uv_x.c
20007 @@ -357,7 +357,7 @@ static int uv_probe(void)
20008 return apic == &apic_x2apic_uv_x;
20009 }
20010
20011 -static struct apic __refdata apic_x2apic_uv_x = {
20012 +static struct apic apic_x2apic_uv_x __read_only = {
20013
20014 .name = "UV large system",
20015 .probe = uv_probe,
20016 diff --git a/arch/x86/kernel/apm_32.c b/arch/x86/kernel/apm_32.c
20017 index 3ab0343..814c4787 100644
20018 --- a/arch/x86/kernel/apm_32.c
20019 +++ b/arch/x86/kernel/apm_32.c
20020 @@ -433,7 +433,7 @@ static DEFINE_MUTEX(apm_mutex);
20021 * This is for buggy BIOS's that refer to (real mode) segment 0x40
20022 * even though they are called in protected mode.
20023 */
20024 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
20025 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
20026 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
20027
20028 static const char driver_version[] = "1.16ac"; /* no spaces */
20029 @@ -611,7 +611,10 @@ static long __apm_bios_call(void *_call)
20030 BUG_ON(cpu != 0);
20031 gdt = get_cpu_gdt_table(cpu);
20032 save_desc_40 = gdt[0x40 / 8];
20033 +
20034 + pax_open_kernel();
20035 gdt[0x40 / 8] = bad_bios_desc;
20036 + pax_close_kernel();
20037
20038 apm_irq_save(flags);
20039 APM_DO_SAVE_SEGS;
20040 @@ -620,7 +623,11 @@ static long __apm_bios_call(void *_call)
20041 &call->esi);
20042 APM_DO_RESTORE_SEGS;
20043 apm_irq_restore(flags);
20044 +
20045 + pax_open_kernel();
20046 gdt[0x40 / 8] = save_desc_40;
20047 + pax_close_kernel();
20048 +
20049 put_cpu();
20050
20051 return call->eax & 0xff;
20052 @@ -687,7 +694,10 @@ static long __apm_bios_call_simple(void *_call)
20053 BUG_ON(cpu != 0);
20054 gdt = get_cpu_gdt_table(cpu);
20055 save_desc_40 = gdt[0x40 / 8];
20056 +
20057 + pax_open_kernel();
20058 gdt[0x40 / 8] = bad_bios_desc;
20059 + pax_close_kernel();
20060
20061 apm_irq_save(flags);
20062 APM_DO_SAVE_SEGS;
20063 @@ -695,7 +705,11 @@ static long __apm_bios_call_simple(void *_call)
20064 &call->eax);
20065 APM_DO_RESTORE_SEGS;
20066 apm_irq_restore(flags);
20067 +
20068 + pax_open_kernel();
20069 gdt[0x40 / 8] = save_desc_40;
20070 + pax_close_kernel();
20071 +
20072 put_cpu();
20073 return error;
20074 }
20075 @@ -2362,12 +2376,15 @@ static int __init apm_init(void)
20076 * code to that CPU.
20077 */
20078 gdt = get_cpu_gdt_table(0);
20079 +
20080 + pax_open_kernel();
20081 set_desc_base(&gdt[APM_CS >> 3],
20082 (unsigned long)__va((unsigned long)apm_info.bios.cseg << 4));
20083 set_desc_base(&gdt[APM_CS_16 >> 3],
20084 (unsigned long)__va((unsigned long)apm_info.bios.cseg_16 << 4));
20085 set_desc_base(&gdt[APM_DS >> 3],
20086 (unsigned long)__va((unsigned long)apm_info.bios.dseg << 4));
20087 + pax_close_kernel();
20088
20089 proc_create("apm", 0, NULL, &apm_file_ops);
20090
20091 diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
20092 index 2861082..6d4718e 100644
20093 --- a/arch/x86/kernel/asm-offsets.c
20094 +++ b/arch/x86/kernel/asm-offsets.c
20095 @@ -33,6 +33,8 @@ void common(void) {
20096 OFFSET(TI_status, thread_info, status);
20097 OFFSET(TI_addr_limit, thread_info, addr_limit);
20098 OFFSET(TI_preempt_count, thread_info, preempt_count);
20099 + OFFSET(TI_lowest_stack, thread_info, lowest_stack);
20100 + DEFINE(TI_task_thread_sp0, offsetof(struct task_struct, thread.sp0) - offsetof(struct task_struct, tinfo));
20101
20102 BLANK();
20103 OFFSET(crypto_tfm_ctx_offset, crypto_tfm, __crt_ctx);
20104 @@ -53,8 +55,26 @@ void common(void) {
20105 OFFSET(PV_CPU_irq_enable_sysexit, pv_cpu_ops, irq_enable_sysexit);
20106 OFFSET(PV_CPU_read_cr0, pv_cpu_ops, read_cr0);
20107 OFFSET(PV_MMU_read_cr2, pv_mmu_ops, read_cr2);
20108 +
20109 +#ifdef CONFIG_PAX_KERNEXEC
20110 + OFFSET(PV_CPU_write_cr0, pv_cpu_ops, write_cr0);
20111 #endif
20112
20113 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20114 + OFFSET(PV_MMU_read_cr3, pv_mmu_ops, read_cr3);
20115 + OFFSET(PV_MMU_write_cr3, pv_mmu_ops, write_cr3);
20116 +#ifdef CONFIG_X86_64
20117 + OFFSET(PV_MMU_set_pgd_batched, pv_mmu_ops, set_pgd_batched);
20118 +#endif
20119 +#endif
20120 +
20121 +#endif
20122 +
20123 + BLANK();
20124 + DEFINE(PAGE_SIZE_asm, PAGE_SIZE);
20125 + DEFINE(PAGE_SHIFT_asm, PAGE_SHIFT);
20126 + DEFINE(THREAD_SIZE_asm, THREAD_SIZE);
20127 +
20128 #ifdef CONFIG_XEN
20129 BLANK();
20130 OFFSET(XEN_vcpu_info_mask, vcpu_info, evtchn_upcall_mask);
20131 diff --git a/arch/x86/kernel/asm-offsets_64.c b/arch/x86/kernel/asm-offsets_64.c
20132 index e7c798b..2b2019b 100644
20133 --- a/arch/x86/kernel/asm-offsets_64.c
20134 +++ b/arch/x86/kernel/asm-offsets_64.c
20135 @@ -77,6 +77,7 @@ int main(void)
20136 BLANK();
20137 #undef ENTRY
20138
20139 + DEFINE(TSS_size, sizeof(struct tss_struct));
20140 OFFSET(TSS_ist, tss_struct, x86_tss.ist);
20141 BLANK();
20142
20143 diff --git a/arch/x86/kernel/cpu/Makefile b/arch/x86/kernel/cpu/Makefile
20144 index 47b56a7..efc2bc6 100644
20145 --- a/arch/x86/kernel/cpu/Makefile
20146 +++ b/arch/x86/kernel/cpu/Makefile
20147 @@ -8,10 +8,6 @@ CFLAGS_REMOVE_common.o = -pg
20148 CFLAGS_REMOVE_perf_event.o = -pg
20149 endif
20150
20151 -# Make sure load_percpu_segment has no stackprotector
20152 -nostackp := $(call cc-option, -fno-stack-protector)
20153 -CFLAGS_common.o := $(nostackp)
20154 -
20155 obj-y := intel_cacheinfo.o scattered.o topology.o
20156 obj-y += proc.o capflags.o powerflags.o common.o
20157 obj-y += rdrand.o
20158 diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
20159 index 903a264..fc955f3 100644
20160 --- a/arch/x86/kernel/cpu/amd.c
20161 +++ b/arch/x86/kernel/cpu/amd.c
20162 @@ -743,7 +743,7 @@ static void init_amd(struct cpuinfo_x86 *c)
20163 static unsigned int amd_size_cache(struct cpuinfo_x86 *c, unsigned int size)
20164 {
20165 /* AMD errata T13 (order #21922) */
20166 - if ((c->x86 == 6)) {
20167 + if (c->x86 == 6) {
20168 /* Duron Rev A0 */
20169 if (c->x86_model == 3 && c->x86_mask == 0)
20170 size = 64;
20171 diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
20172 index 2793d1f..b4f313a 100644
20173 --- a/arch/x86/kernel/cpu/common.c
20174 +++ b/arch/x86/kernel/cpu/common.c
20175 @@ -88,60 +88,6 @@ static const struct cpu_dev default_cpu = {
20176
20177 static const struct cpu_dev *this_cpu = &default_cpu;
20178
20179 -DEFINE_PER_CPU_PAGE_ALIGNED(struct gdt_page, gdt_page) = { .gdt = {
20180 -#ifdef CONFIG_X86_64
20181 - /*
20182 - * We need valid kernel segments for data and code in long mode too
20183 - * IRET will check the segment types kkeil 2000/10/28
20184 - * Also sysret mandates a special GDT layout
20185 - *
20186 - * TLS descriptors are currently at a different place compared to i386.
20187 - * Hopefully nobody expects them at a fixed place (Wine?)
20188 - */
20189 - [GDT_ENTRY_KERNEL32_CS] = GDT_ENTRY_INIT(0xc09b, 0, 0xfffff),
20190 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xa09b, 0, 0xfffff),
20191 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc093, 0, 0xfffff),
20192 - [GDT_ENTRY_DEFAULT_USER32_CS] = GDT_ENTRY_INIT(0xc0fb, 0, 0xfffff),
20193 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f3, 0, 0xfffff),
20194 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xa0fb, 0, 0xfffff),
20195 -#else
20196 - [GDT_ENTRY_KERNEL_CS] = GDT_ENTRY_INIT(0xc09a, 0, 0xfffff),
20197 - [GDT_ENTRY_KERNEL_DS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20198 - [GDT_ENTRY_DEFAULT_USER_CS] = GDT_ENTRY_INIT(0xc0fa, 0, 0xfffff),
20199 - [GDT_ENTRY_DEFAULT_USER_DS] = GDT_ENTRY_INIT(0xc0f2, 0, 0xfffff),
20200 - /*
20201 - * Segments used for calling PnP BIOS have byte granularity.
20202 - * They code segments and data segments have fixed 64k limits,
20203 - * the transfer segment sizes are set at run time.
20204 - */
20205 - /* 32-bit code */
20206 - [GDT_ENTRY_PNPBIOS_CS32] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20207 - /* 16-bit code */
20208 - [GDT_ENTRY_PNPBIOS_CS16] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20209 - /* 16-bit data */
20210 - [GDT_ENTRY_PNPBIOS_DS] = GDT_ENTRY_INIT(0x0092, 0, 0xffff),
20211 - /* 16-bit data */
20212 - [GDT_ENTRY_PNPBIOS_TS1] = GDT_ENTRY_INIT(0x0092, 0, 0),
20213 - /* 16-bit data */
20214 - [GDT_ENTRY_PNPBIOS_TS2] = GDT_ENTRY_INIT(0x0092, 0, 0),
20215 - /*
20216 - * The APM segments have byte granularity and their bases
20217 - * are set at run time. All have 64k limits.
20218 - */
20219 - /* 32-bit code */
20220 - [GDT_ENTRY_APMBIOS_BASE] = GDT_ENTRY_INIT(0x409a, 0, 0xffff),
20221 - /* 16-bit code */
20222 - [GDT_ENTRY_APMBIOS_BASE+1] = GDT_ENTRY_INIT(0x009a, 0, 0xffff),
20223 - /* data */
20224 - [GDT_ENTRY_APMBIOS_BASE+2] = GDT_ENTRY_INIT(0x4092, 0, 0xffff),
20225 -
20226 - [GDT_ENTRY_ESPFIX_SS] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20227 - [GDT_ENTRY_PERCPU] = GDT_ENTRY_INIT(0xc092, 0, 0xfffff),
20228 - GDT_STACK_CANARY_INIT
20229 -#endif
20230 -} };
20231 -EXPORT_PER_CPU_SYMBOL_GPL(gdt_page);
20232 -
20233 static int __init x86_xsave_setup(char *s)
20234 {
20235 setup_clear_cpu_cap(X86_FEATURE_XSAVE);
20236 @@ -288,6 +234,59 @@ static __always_inline void setup_smap(struct cpuinfo_x86 *c)
20237 set_in_cr4(X86_CR4_SMAP);
20238 }
20239
20240 +#ifdef CONFIG_X86_64
20241 +static __init int setup_disable_pcid(char *arg)
20242 +{
20243 + setup_clear_cpu_cap(X86_FEATURE_PCID);
20244 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
20245 +
20246 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20247 + if (clone_pgd_mask != ~(pgdval_t)0UL)
20248 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20249 +#endif
20250 +
20251 + return 1;
20252 +}
20253 +__setup("nopcid", setup_disable_pcid);
20254 +
20255 +static void setup_pcid(struct cpuinfo_x86 *c)
20256 +{
20257 + if (!cpu_has(c, X86_FEATURE_PCID)) {
20258 + clear_cpu_cap(c, X86_FEATURE_INVPCID);
20259 +
20260 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20261 + if (clone_pgd_mask != ~(pgdval_t)0UL) {
20262 + pax_open_kernel();
20263 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
20264 + pax_close_kernel();
20265 + printk("PAX: slow and weak UDEREF enabled\n");
20266 + } else
20267 + printk("PAX: UDEREF disabled\n");
20268 +#endif
20269 +
20270 + return;
20271 + }
20272 +
20273 + printk("PAX: PCID detected\n");
20274 + set_in_cr4(X86_CR4_PCIDE);
20275 +
20276 +#ifdef CONFIG_PAX_MEMORY_UDEREF
20277 + pax_open_kernel();
20278 + clone_pgd_mask = ~(pgdval_t)0UL;
20279 + pax_close_kernel();
20280 + if (pax_user_shadow_base)
20281 + printk("PAX: weak UDEREF enabled\n");
20282 + else {
20283 + set_cpu_cap(c, X86_FEATURE_STRONGUDEREF);
20284 + printk("PAX: strong UDEREF enabled\n");
20285 + }
20286 +#endif
20287 +
20288 + if (cpu_has(c, X86_FEATURE_INVPCID))
20289 + printk("PAX: INVPCID detected\n");
20290 +}
20291 +#endif
20292 +
20293 /*
20294 * Some CPU features depend on higher CPUID levels, which may not always
20295 * be available due to CPUID level capping or broken virtualization
20296 @@ -386,7 +385,7 @@ void switch_to_new_gdt(int cpu)
20297 {
20298 struct desc_ptr gdt_descr;
20299
20300 - gdt_descr.address = (long)get_cpu_gdt_table(cpu);
20301 + gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
20302 gdt_descr.size = GDT_SIZE - 1;
20303 load_gdt(&gdt_descr);
20304 /* Reload the per-cpu base */
20305 @@ -875,6 +874,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
20306 setup_smep(c);
20307 setup_smap(c);
20308
20309 +#ifdef CONFIG_X86_64
20310 + setup_pcid(c);
20311 +#endif
20312 +
20313 /*
20314 * The vendor-specific functions might have changed features.
20315 * Now we do "generic changes."
20316 @@ -883,6 +886,10 @@ static void identify_cpu(struct cpuinfo_x86 *c)
20317 /* Filter out anything that depends on CPUID levels we don't have */
20318 filter_cpuid_features(c, true);
20319
20320 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
20321 + setup_clear_cpu_cap(X86_FEATURE_SEP);
20322 +#endif
20323 +
20324 /* If the model name is still unset, do table lookup. */
20325 if (!c->x86_model_id[0]) {
20326 const char *p;
20327 @@ -1070,10 +1077,12 @@ static __init int setup_disablecpuid(char *arg)
20328 }
20329 __setup("clearcpuid=", setup_disablecpuid);
20330
20331 +DEFINE_PER_CPU(struct thread_info *, current_tinfo) = &init_task.tinfo;
20332 +EXPORT_PER_CPU_SYMBOL(current_tinfo);
20333 +
20334 #ifdef CONFIG_X86_64
20335 -struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
20336 -struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1,
20337 - (unsigned long) debug_idt_table };
20338 +struct desc_ptr idt_descr __read_only = { NR_VECTORS * 16 - 1, (unsigned long) idt_table };
20339 +const struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) debug_idt_table };
20340
20341 DEFINE_PER_CPU_FIRST(union irq_stack_union,
20342 irq_stack_union) __aligned(PAGE_SIZE) __visible;
20343 @@ -1087,7 +1096,7 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned =
20344 EXPORT_PER_CPU_SYMBOL(current_task);
20345
20346 DEFINE_PER_CPU(unsigned long, kernel_stack) =
20347 - (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE;
20348 + (unsigned long)&init_thread_union - 16 + THREAD_SIZE;
20349 EXPORT_PER_CPU_SYMBOL(kernel_stack);
20350
20351 DEFINE_PER_CPU(char *, irq_stack_ptr) =
20352 @@ -1232,7 +1241,7 @@ void cpu_init(void)
20353 load_ucode_ap();
20354
20355 cpu = stack_smp_processor_id();
20356 - t = &per_cpu(init_tss, cpu);
20357 + t = init_tss + cpu;
20358 oist = &per_cpu(orig_ist, cpu);
20359
20360 #ifdef CONFIG_NUMA
20361 @@ -1267,7 +1276,6 @@ void cpu_init(void)
20362 wrmsrl(MSR_KERNEL_GS_BASE, 0);
20363 barrier();
20364
20365 - x86_configure_nx();
20366 enable_x2apic();
20367
20368 /*
20369 @@ -1319,7 +1327,7 @@ void cpu_init(void)
20370 {
20371 int cpu = smp_processor_id();
20372 struct task_struct *curr = current;
20373 - struct tss_struct *t = &per_cpu(init_tss, cpu);
20374 + struct tss_struct *t = init_tss + cpu;
20375 struct thread_struct *thread = &curr->thread;
20376
20377 show_ucode_info_early();
20378 diff --git a/arch/x86/kernel/cpu/intel_cacheinfo.c b/arch/x86/kernel/cpu/intel_cacheinfo.c
20379 index 1414c90..1159406 100644
20380 --- a/arch/x86/kernel/cpu/intel_cacheinfo.c
20381 +++ b/arch/x86/kernel/cpu/intel_cacheinfo.c
20382 @@ -1014,6 +1014,22 @@ static struct attribute *default_attrs[] = {
20383 };
20384
20385 #ifdef CONFIG_AMD_NB
20386 +static struct attribute *default_attrs_amd_nb[] = {
20387 + &type.attr,
20388 + &level.attr,
20389 + &coherency_line_size.attr,
20390 + &physical_line_partition.attr,
20391 + &ways_of_associativity.attr,
20392 + &number_of_sets.attr,
20393 + &size.attr,
20394 + &shared_cpu_map.attr,
20395 + &shared_cpu_list.attr,
20396 + NULL,
20397 + NULL,
20398 + NULL,
20399 + NULL
20400 +};
20401 +
20402 static struct attribute **amd_l3_attrs(void)
20403 {
20404 static struct attribute **attrs;
20405 @@ -1024,18 +1040,7 @@ static struct attribute **amd_l3_attrs(void)
20406
20407 n = ARRAY_SIZE(default_attrs);
20408
20409 - if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE))
20410 - n += 2;
20411 -
20412 - if (amd_nb_has_feature(AMD_NB_L3_PARTITIONING))
20413 - n += 1;
20414 -
20415 - attrs = kzalloc(n * sizeof (struct attribute *), GFP_KERNEL);
20416 - if (attrs == NULL)
20417 - return attrs = default_attrs;
20418 -
20419 - for (n = 0; default_attrs[n]; n++)
20420 - attrs[n] = default_attrs[n];
20421 + attrs = default_attrs_amd_nb;
20422
20423 if (amd_nb_has_feature(AMD_NB_L3_INDEX_DISABLE)) {
20424 attrs[n++] = &cache_disable_0.attr;
20425 @@ -1086,6 +1091,13 @@ static struct kobj_type ktype_cache = {
20426 .default_attrs = default_attrs,
20427 };
20428
20429 +#ifdef CONFIG_AMD_NB
20430 +static struct kobj_type ktype_cache_amd_nb = {
20431 + .sysfs_ops = &sysfs_ops,
20432 + .default_attrs = default_attrs_amd_nb,
20433 +};
20434 +#endif
20435 +
20436 static struct kobj_type ktype_percpu_entry = {
20437 .sysfs_ops = &sysfs_ops,
20438 };
20439 @@ -1151,20 +1163,26 @@ static int cache_add_dev(struct device *dev)
20440 return retval;
20441 }
20442
20443 +#ifdef CONFIG_AMD_NB
20444 + amd_l3_attrs();
20445 +#endif
20446 +
20447 for (i = 0; i < num_cache_leaves; i++) {
20448 + struct kobj_type *ktype;
20449 +
20450 this_object = INDEX_KOBJECT_PTR(cpu, i);
20451 this_object->cpu = cpu;
20452 this_object->index = i;
20453
20454 this_leaf = CPUID4_INFO_IDX(cpu, i);
20455
20456 - ktype_cache.default_attrs = default_attrs;
20457 + ktype = &ktype_cache;
20458 #ifdef CONFIG_AMD_NB
20459 if (this_leaf->base.nb)
20460 - ktype_cache.default_attrs = amd_l3_attrs();
20461 + ktype = &ktype_cache_amd_nb;
20462 #endif
20463 retval = kobject_init_and_add(&(this_object->kobj),
20464 - &ktype_cache,
20465 + ktype,
20466 per_cpu(ici_cache_kobject, cpu),
20467 "index%1lu", i);
20468 if (unlikely(retval)) {
20469 diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
20470 index b3218cd..99a75de 100644
20471 --- a/arch/x86/kernel/cpu/mcheck/mce.c
20472 +++ b/arch/x86/kernel/cpu/mcheck/mce.c
20473 @@ -45,6 +45,7 @@
20474 #include <asm/processor.h>
20475 #include <asm/mce.h>
20476 #include <asm/msr.h>
20477 +#include <asm/local.h>
20478
20479 #include "mce-internal.h"
20480
20481 @@ -258,7 +259,7 @@ static void print_mce(struct mce *m)
20482 !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
20483 m->cs, m->ip);
20484
20485 - if (m->cs == __KERNEL_CS)
20486 + if (m->cs == __KERNEL_CS || m->cs == __KERNEXEC_KERNEL_CS)
20487 print_symbol("{%s}", m->ip);
20488 pr_cont("\n");
20489 }
20490 @@ -291,10 +292,10 @@ static void print_mce(struct mce *m)
20491
20492 #define PANIC_TIMEOUT 5 /* 5 seconds */
20493
20494 -static atomic_t mce_paniced;
20495 +static atomic_unchecked_t mce_paniced;
20496
20497 static int fake_panic;
20498 -static atomic_t mce_fake_paniced;
20499 +static atomic_unchecked_t mce_fake_paniced;
20500
20501 /* Panic in progress. Enable interrupts and wait for final IPI */
20502 static void wait_for_panic(void)
20503 @@ -318,7 +319,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20504 /*
20505 * Make sure only one CPU runs in machine check panic
20506 */
20507 - if (atomic_inc_return(&mce_paniced) > 1)
20508 + if (atomic_inc_return_unchecked(&mce_paniced) > 1)
20509 wait_for_panic();
20510 barrier();
20511
20512 @@ -326,7 +327,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20513 console_verbose();
20514 } else {
20515 /* Don't log too much for fake panic */
20516 - if (atomic_inc_return(&mce_fake_paniced) > 1)
20517 + if (atomic_inc_return_unchecked(&mce_fake_paniced) > 1)
20518 return;
20519 }
20520 /* First print corrected ones that are still unlogged */
20521 @@ -365,7 +366,7 @@ static void mce_panic(char *msg, struct mce *final, char *exp)
20522 if (!fake_panic) {
20523 if (panic_timeout == 0)
20524 panic_timeout = mca_cfg.panic_timeout;
20525 - panic(msg);
20526 + panic("%s", msg);
20527 } else
20528 pr_emerg(HW_ERR "Fake kernel panic: %s\n", msg);
20529 }
20530 @@ -695,7 +696,7 @@ static int mce_timed_out(u64 *t)
20531 * might have been modified by someone else.
20532 */
20533 rmb();
20534 - if (atomic_read(&mce_paniced))
20535 + if (atomic_read_unchecked(&mce_paniced))
20536 wait_for_panic();
20537 if (!mca_cfg.monarch_timeout)
20538 goto out;
20539 @@ -1666,7 +1667,7 @@ static void unexpected_machine_check(struct pt_regs *regs, long error_code)
20540 }
20541
20542 /* Call the installed machine check handler for this CPU setup. */
20543 -void (*machine_check_vector)(struct pt_regs *, long error_code) =
20544 +void (*machine_check_vector)(struct pt_regs *, long error_code) __read_only =
20545 unexpected_machine_check;
20546
20547 /*
20548 @@ -1689,7 +1690,9 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
20549 return;
20550 }
20551
20552 + pax_open_kernel();
20553 machine_check_vector = do_machine_check;
20554 + pax_close_kernel();
20555
20556 __mcheck_cpu_init_generic();
20557 __mcheck_cpu_init_vendor(c);
20558 @@ -1703,7 +1706,7 @@ void mcheck_cpu_init(struct cpuinfo_x86 *c)
20559 */
20560
20561 static DEFINE_SPINLOCK(mce_chrdev_state_lock);
20562 -static int mce_chrdev_open_count; /* #times opened */
20563 +static local_t mce_chrdev_open_count; /* #times opened */
20564 static int mce_chrdev_open_exclu; /* already open exclusive? */
20565
20566 static int mce_chrdev_open(struct inode *inode, struct file *file)
20567 @@ -1711,7 +1714,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20568 spin_lock(&mce_chrdev_state_lock);
20569
20570 if (mce_chrdev_open_exclu ||
20571 - (mce_chrdev_open_count && (file->f_flags & O_EXCL))) {
20572 + (local_read(&mce_chrdev_open_count) && (file->f_flags & O_EXCL))) {
20573 spin_unlock(&mce_chrdev_state_lock);
20574
20575 return -EBUSY;
20576 @@ -1719,7 +1722,7 @@ static int mce_chrdev_open(struct inode *inode, struct file *file)
20577
20578 if (file->f_flags & O_EXCL)
20579 mce_chrdev_open_exclu = 1;
20580 - mce_chrdev_open_count++;
20581 + local_inc(&mce_chrdev_open_count);
20582
20583 spin_unlock(&mce_chrdev_state_lock);
20584
20585 @@ -1730,7 +1733,7 @@ static int mce_chrdev_release(struct inode *inode, struct file *file)
20586 {
20587 spin_lock(&mce_chrdev_state_lock);
20588
20589 - mce_chrdev_open_count--;
20590 + local_dec(&mce_chrdev_open_count);
20591 mce_chrdev_open_exclu = 0;
20592
20593 spin_unlock(&mce_chrdev_state_lock);
20594 @@ -2404,7 +2407,7 @@ static __init void mce_init_banks(void)
20595
20596 for (i = 0; i < mca_cfg.banks; i++) {
20597 struct mce_bank *b = &mce_banks[i];
20598 - struct device_attribute *a = &b->attr;
20599 + device_attribute_no_const *a = &b->attr;
20600
20601 sysfs_attr_init(&a->attr);
20602 a->attr.name = b->attrname;
20603 @@ -2472,7 +2475,7 @@ struct dentry *mce_get_debugfs_dir(void)
20604 static void mce_reset(void)
20605 {
20606 cpu_missing = 0;
20607 - atomic_set(&mce_fake_paniced, 0);
20608 + atomic_set_unchecked(&mce_fake_paniced, 0);
20609 atomic_set(&mce_executing, 0);
20610 atomic_set(&mce_callin, 0);
20611 atomic_set(&global_nwo, 0);
20612 diff --git a/arch/x86/kernel/cpu/mcheck/p5.c b/arch/x86/kernel/cpu/mcheck/p5.c
20613 index 1c044b1..37a2a43 100644
20614 --- a/arch/x86/kernel/cpu/mcheck/p5.c
20615 +++ b/arch/x86/kernel/cpu/mcheck/p5.c
20616 @@ -11,6 +11,7 @@
20617 #include <asm/processor.h>
20618 #include <asm/mce.h>
20619 #include <asm/msr.h>
20620 +#include <asm/pgtable.h>
20621
20622 /* By default disabled */
20623 int mce_p5_enabled __read_mostly;
20624 @@ -49,7 +50,9 @@ void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
20625 if (!cpu_has(c, X86_FEATURE_MCE))
20626 return;
20627
20628 + pax_open_kernel();
20629 machine_check_vector = pentium_machine_check;
20630 + pax_close_kernel();
20631 /* Make sure the vector pointer is visible before we enable MCEs: */
20632 wmb();
20633
20634 diff --git a/arch/x86/kernel/cpu/mcheck/winchip.c b/arch/x86/kernel/cpu/mcheck/winchip.c
20635 index e9a701a..35317d6 100644
20636 --- a/arch/x86/kernel/cpu/mcheck/winchip.c
20637 +++ b/arch/x86/kernel/cpu/mcheck/winchip.c
20638 @@ -10,6 +10,7 @@
20639 #include <asm/processor.h>
20640 #include <asm/mce.h>
20641 #include <asm/msr.h>
20642 +#include <asm/pgtable.h>
20643
20644 /* Machine check handler for WinChip C6: */
20645 static void winchip_machine_check(struct pt_regs *regs, long error_code)
20646 @@ -23,7 +24,9 @@ void winchip_mcheck_init(struct cpuinfo_x86 *c)
20647 {
20648 u32 lo, hi;
20649
20650 + pax_open_kernel();
20651 machine_check_vector = winchip_machine_check;
20652 + pax_close_kernel();
20653 /* Make sure the vector pointer is visible before we enable MCEs: */
20654 wmb();
20655
20656 diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c
20657 index f961de9..8a9d332 100644
20658 --- a/arch/x86/kernel/cpu/mtrr/main.c
20659 +++ b/arch/x86/kernel/cpu/mtrr/main.c
20660 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(mtrr_mutex);
20661 u64 size_or_mask, size_and_mask;
20662 static bool mtrr_aps_delayed_init;
20663
20664 -static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM];
20665 +static const struct mtrr_ops *mtrr_ops[X86_VENDOR_NUM] __read_only;
20666
20667 const struct mtrr_ops *mtrr_if;
20668
20669 diff --git a/arch/x86/kernel/cpu/mtrr/mtrr.h b/arch/x86/kernel/cpu/mtrr/mtrr.h
20670 index df5e41f..816c719 100644
20671 --- a/arch/x86/kernel/cpu/mtrr/mtrr.h
20672 +++ b/arch/x86/kernel/cpu/mtrr/mtrr.h
20673 @@ -25,7 +25,7 @@ struct mtrr_ops {
20674 int (*validate_add_page)(unsigned long base, unsigned long size,
20675 unsigned int type);
20676 int (*have_wrcomb)(void);
20677 -};
20678 +} __do_const;
20679
20680 extern int generic_get_free_region(unsigned long base, unsigned long size,
20681 int replace_reg);
20682 diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
20683 index 8a87a32..682a22a 100644
20684 --- a/arch/x86/kernel/cpu/perf_event.c
20685 +++ b/arch/x86/kernel/cpu/perf_event.c
20686 @@ -1348,7 +1348,7 @@ static void __init pmu_check_apic(void)
20687 pr_info("no hardware sampling interrupt available.\n");
20688 }
20689
20690 -static struct attribute_group x86_pmu_format_group = {
20691 +static attribute_group_no_const x86_pmu_format_group = {
20692 .name = "format",
20693 .attrs = NULL,
20694 };
20695 @@ -1447,7 +1447,7 @@ static struct attribute *events_attr[] = {
20696 NULL,
20697 };
20698
20699 -static struct attribute_group x86_pmu_events_group = {
20700 +static attribute_group_no_const x86_pmu_events_group = {
20701 .name = "events",
20702 .attrs = events_attr,
20703 };
20704 @@ -1958,7 +1958,7 @@ static unsigned long get_segment_base(unsigned int segment)
20705 if (idx > GDT_ENTRIES)
20706 return 0;
20707
20708 - desc = __this_cpu_ptr(&gdt_page.gdt[0]);
20709 + desc = get_cpu_gdt_table(smp_processor_id());
20710 }
20711
20712 return get_desc_base(desc + idx);
20713 @@ -2048,7 +2048,7 @@ perf_callchain_user(struct perf_callchain_entry *entry, struct pt_regs *regs)
20714 break;
20715
20716 perf_callchain_store(entry, frame.return_address);
20717 - fp = frame.next_frame;
20718 + fp = (const void __force_user *)frame.next_frame;
20719 }
20720 }
20721
20722 diff --git a/arch/x86/kernel/cpu/perf_event_amd_iommu.c b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20723 index 639d128..e92d7e5 100644
20724 --- a/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20725 +++ b/arch/x86/kernel/cpu/perf_event_amd_iommu.c
20726 @@ -405,7 +405,7 @@ static void perf_iommu_del(struct perf_event *event, int flags)
20727 static __init int _init_events_attrs(struct perf_amd_iommu *perf_iommu)
20728 {
20729 struct attribute **attrs;
20730 - struct attribute_group *attr_group;
20731 + attribute_group_no_const *attr_group;
20732 int i = 0, j;
20733
20734 while (amd_iommu_v2_event_descs[i].attr.attr.name)
20735 diff --git a/arch/x86/kernel/cpu/perf_event_intel.c b/arch/x86/kernel/cpu/perf_event_intel.c
20736 index f31a165..7b46cd8 100644
20737 --- a/arch/x86/kernel/cpu/perf_event_intel.c
20738 +++ b/arch/x86/kernel/cpu/perf_event_intel.c
20739 @@ -2247,10 +2247,10 @@ __init int intel_pmu_init(void)
20740 * v2 and above have a perf capabilities MSR
20741 */
20742 if (version > 1) {
20743 - u64 capabilities;
20744 + u64 capabilities = x86_pmu.intel_cap.capabilities;
20745
20746 - rdmsrl(MSR_IA32_PERF_CAPABILITIES, capabilities);
20747 - x86_pmu.intel_cap.capabilities = capabilities;
20748 + if (rdmsrl_safe(MSR_IA32_PERF_CAPABILITIES, &x86_pmu.intel_cap.capabilities))
20749 + x86_pmu.intel_cap.capabilities = capabilities;
20750 }
20751
20752 intel_ds_init();
20753 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.c b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20754 index 4118f9f..f91d0ab 100644
20755 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20756 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.c
20757 @@ -3204,7 +3204,7 @@ static void __init uncore_types_exit(struct intel_uncore_type **types)
20758 static int __init uncore_type_init(struct intel_uncore_type *type)
20759 {
20760 struct intel_uncore_pmu *pmus;
20761 - struct attribute_group *attr_group;
20762 + attribute_group_no_const *attr_group;
20763 struct attribute **attrs;
20764 int i, j;
20765
20766 diff --git a/arch/x86/kernel/cpu/perf_event_intel_uncore.h b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20767 index a80ab71..4089da5 100644
20768 --- a/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20769 +++ b/arch/x86/kernel/cpu/perf_event_intel_uncore.h
20770 @@ -498,7 +498,7 @@ struct intel_uncore_box {
20771 struct uncore_event_desc {
20772 struct kobj_attribute attr;
20773 const char *config;
20774 -};
20775 +} __do_const;
20776
20777 #define INTEL_UNCORE_EVENT_DESC(_name, _config) \
20778 { \
20779 diff --git a/arch/x86/kernel/cpuid.c b/arch/x86/kernel/cpuid.c
20780 index 7d9481c..99c7e4b 100644
20781 --- a/arch/x86/kernel/cpuid.c
20782 +++ b/arch/x86/kernel/cpuid.c
20783 @@ -170,7 +170,7 @@ static int cpuid_class_cpu_callback(struct notifier_block *nfb,
20784 return notifier_from_errno(err);
20785 }
20786
20787 -static struct notifier_block __refdata cpuid_class_cpu_notifier =
20788 +static struct notifier_block cpuid_class_cpu_notifier =
20789 {
20790 .notifier_call = cpuid_class_cpu_callback,
20791 };
20792 diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
20793 index 18677a9..f67c45b 100644
20794 --- a/arch/x86/kernel/crash.c
20795 +++ b/arch/x86/kernel/crash.c
20796 @@ -58,10 +58,8 @@ static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
20797 {
20798 #ifdef CONFIG_X86_32
20799 struct pt_regs fixed_regs;
20800 -#endif
20801
20802 -#ifdef CONFIG_X86_32
20803 - if (!user_mode_vm(regs)) {
20804 + if (!user_mode(regs)) {
20805 crash_fixup_ss_esp(&fixed_regs, regs);
20806 regs = &fixed_regs;
20807 }
20808 diff --git a/arch/x86/kernel/crash_dump_64.c b/arch/x86/kernel/crash_dump_64.c
20809 index afa64ad..dce67dd 100644
20810 --- a/arch/x86/kernel/crash_dump_64.c
20811 +++ b/arch/x86/kernel/crash_dump_64.c
20812 @@ -36,7 +36,7 @@ ssize_t copy_oldmem_page(unsigned long pfn, char *buf,
20813 return -ENOMEM;
20814
20815 if (userbuf) {
20816 - if (copy_to_user(buf, vaddr + offset, csize)) {
20817 + if (copy_to_user((char __force_user *)buf, vaddr + offset, csize)) {
20818 iounmap(vaddr);
20819 return -EFAULT;
20820 }
20821 diff --git a/arch/x86/kernel/doublefault.c b/arch/x86/kernel/doublefault.c
20822 index 5d3fe8d..02e1429 100644
20823 --- a/arch/x86/kernel/doublefault.c
20824 +++ b/arch/x86/kernel/doublefault.c
20825 @@ -13,7 +13,7 @@
20826
20827 #define DOUBLEFAULT_STACKSIZE (1024)
20828 static unsigned long doublefault_stack[DOUBLEFAULT_STACKSIZE];
20829 -#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE)
20830 +#define STACK_START (unsigned long)(doublefault_stack+DOUBLEFAULT_STACKSIZE-2)
20831
20832 #define ptr_ok(x) ((x) > PAGE_OFFSET && (x) < PAGE_OFFSET + MAXMEM)
20833
20834 @@ -23,7 +23,7 @@ static void doublefault_fn(void)
20835 unsigned long gdt, tss;
20836
20837 native_store_gdt(&gdt_desc);
20838 - gdt = gdt_desc.address;
20839 + gdt = (unsigned long)gdt_desc.address;
20840
20841 printk(KERN_EMERG "PANIC: double fault, gdt at %08lx [%d bytes]\n", gdt, gdt_desc.size);
20842
20843 @@ -60,10 +60,10 @@ struct tss_struct doublefault_tss __cacheline_aligned = {
20844 /* 0x2 bit is always set */
20845 .flags = X86_EFLAGS_SF | 0x2,
20846 .sp = STACK_START,
20847 - .es = __USER_DS,
20848 + .es = __KERNEL_DS,
20849 .cs = __KERNEL_CS,
20850 .ss = __KERNEL_DS,
20851 - .ds = __USER_DS,
20852 + .ds = __KERNEL_DS,
20853 .fs = __KERNEL_PERCPU,
20854
20855 .__cr3 = __pa_nodebug(swapper_pg_dir),
20856 diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
20857 index deb6421..76bbc12 100644
20858 --- a/arch/x86/kernel/dumpstack.c
20859 +++ b/arch/x86/kernel/dumpstack.c
20860 @@ -2,6 +2,9 @@
20861 * Copyright (C) 1991, 1992 Linus Torvalds
20862 * Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
20863 */
20864 +#ifdef CONFIG_GRKERNSEC_HIDESYM
20865 +#define __INCLUDED_BY_HIDESYM 1
20866 +#endif
20867 #include <linux/kallsyms.h>
20868 #include <linux/kprobes.h>
20869 #include <linux/uaccess.h>
20870 @@ -35,16 +38,14 @@ void printk_address(unsigned long address, int reliable)
20871 static void
20872 print_ftrace_graph_addr(unsigned long addr, void *data,
20873 const struct stacktrace_ops *ops,
20874 - struct thread_info *tinfo, int *graph)
20875 + struct task_struct *task, int *graph)
20876 {
20877 - struct task_struct *task;
20878 unsigned long ret_addr;
20879 int index;
20880
20881 if (addr != (unsigned long)return_to_handler)
20882 return;
20883
20884 - task = tinfo->task;
20885 index = task->curr_ret_stack;
20886
20887 if (!task->ret_stack || index < *graph)
20888 @@ -61,7 +62,7 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20889 static inline void
20890 print_ftrace_graph_addr(unsigned long addr, void *data,
20891 const struct stacktrace_ops *ops,
20892 - struct thread_info *tinfo, int *graph)
20893 + struct task_struct *task, int *graph)
20894 { }
20895 #endif
20896
20897 @@ -72,10 +73,8 @@ print_ftrace_graph_addr(unsigned long addr, void *data,
20898 * severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
20899 */
20900
20901 -static inline int valid_stack_ptr(struct thread_info *tinfo,
20902 - void *p, unsigned int size, void *end)
20903 +static inline int valid_stack_ptr(void *t, void *p, unsigned int size, void *end)
20904 {
20905 - void *t = tinfo;
20906 if (end) {
20907 if (p < end && p >= (end-THREAD_SIZE))
20908 return 1;
20909 @@ -86,14 +85,14 @@ static inline int valid_stack_ptr(struct thread_info *tinfo,
20910 }
20911
20912 unsigned long
20913 -print_context_stack(struct thread_info *tinfo,
20914 +print_context_stack(struct task_struct *task, void *stack_start,
20915 unsigned long *stack, unsigned long bp,
20916 const struct stacktrace_ops *ops, void *data,
20917 unsigned long *end, int *graph)
20918 {
20919 struct stack_frame *frame = (struct stack_frame *)bp;
20920
20921 - while (valid_stack_ptr(tinfo, stack, sizeof(*stack), end)) {
20922 + while (valid_stack_ptr(stack_start, stack, sizeof(*stack), end)) {
20923 unsigned long addr;
20924
20925 addr = *stack;
20926 @@ -105,7 +104,7 @@ print_context_stack(struct thread_info *tinfo,
20927 } else {
20928 ops->address(data, addr, 0);
20929 }
20930 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20931 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20932 }
20933 stack++;
20934 }
20935 @@ -114,7 +113,7 @@ print_context_stack(struct thread_info *tinfo,
20936 EXPORT_SYMBOL_GPL(print_context_stack);
20937
20938 unsigned long
20939 -print_context_stack_bp(struct thread_info *tinfo,
20940 +print_context_stack_bp(struct task_struct *task, void *stack_start,
20941 unsigned long *stack, unsigned long bp,
20942 const struct stacktrace_ops *ops, void *data,
20943 unsigned long *end, int *graph)
20944 @@ -122,7 +121,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20945 struct stack_frame *frame = (struct stack_frame *)bp;
20946 unsigned long *ret_addr = &frame->return_address;
20947
20948 - while (valid_stack_ptr(tinfo, ret_addr, sizeof(*ret_addr), end)) {
20949 + while (valid_stack_ptr(stack_start, ret_addr, sizeof(*ret_addr), end)) {
20950 unsigned long addr = *ret_addr;
20951
20952 if (!__kernel_text_address(addr))
20953 @@ -131,7 +130,7 @@ print_context_stack_bp(struct thread_info *tinfo,
20954 ops->address(data, addr, 1);
20955 frame = frame->next_frame;
20956 ret_addr = &frame->return_address;
20957 - print_ftrace_graph_addr(addr, data, ops, tinfo, graph);
20958 + print_ftrace_graph_addr(addr, data, ops, task, graph);
20959 }
20960
20961 return (unsigned long)frame;
20962 @@ -150,7 +149,7 @@ static int print_trace_stack(void *data, char *name)
20963 static void print_trace_address(void *data, unsigned long addr, int reliable)
20964 {
20965 touch_nmi_watchdog();
20966 - printk(data);
20967 + printk("%s", (char *)data);
20968 printk_address(addr, reliable);
20969 }
20970
20971 @@ -219,6 +218,8 @@ unsigned __kprobes long oops_begin(void)
20972 }
20973 EXPORT_SYMBOL_GPL(oops_begin);
20974
20975 +extern void gr_handle_kernel_exploit(void);
20976 +
20977 void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20978 {
20979 if (regs && kexec_should_crash(current))
20980 @@ -240,7 +241,10 @@ void __kprobes oops_end(unsigned long flags, struct pt_regs *regs, int signr)
20981 panic("Fatal exception in interrupt");
20982 if (panic_on_oops)
20983 panic("Fatal exception");
20984 - do_exit(signr);
20985 +
20986 + gr_handle_kernel_exploit();
20987 +
20988 + do_group_exit(signr);
20989 }
20990
20991 int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20992 @@ -268,7 +272,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
20993 print_modules();
20994 show_regs(regs);
20995 #ifdef CONFIG_X86_32
20996 - if (user_mode_vm(regs)) {
20997 + if (user_mode(regs)) {
20998 sp = regs->sp;
20999 ss = regs->ss & 0xffff;
21000 } else {
21001 @@ -296,7 +300,7 @@ void die(const char *str, struct pt_regs *regs, long err)
21002 unsigned long flags = oops_begin();
21003 int sig = SIGSEGV;
21004
21005 - if (!user_mode_vm(regs))
21006 + if (!user_mode(regs))
21007 report_bug(regs->ip, regs);
21008
21009 if (__die(str, regs, err))
21010 diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
21011 index f2a1770..540657f 100644
21012 --- a/arch/x86/kernel/dumpstack_32.c
21013 +++ b/arch/x86/kernel/dumpstack_32.c
21014 @@ -38,15 +38,13 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21015 bp = stack_frame(task, regs);
21016
21017 for (;;) {
21018 - struct thread_info *context;
21019 + void *stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21020
21021 - context = (struct thread_info *)
21022 - ((unsigned long)stack & (~(THREAD_SIZE - 1)));
21023 - bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph);
21024 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21025
21026 - stack = (unsigned long *)context->previous_esp;
21027 - if (!stack)
21028 + if (stack_start == task_stack_page(task))
21029 break;
21030 + stack = *(unsigned long **)stack_start;
21031 if (ops->stack(data, "IRQ") < 0)
21032 break;
21033 touch_nmi_watchdog();
21034 @@ -87,27 +85,28 @@ void show_regs(struct pt_regs *regs)
21035 int i;
21036
21037 show_regs_print_info(KERN_EMERG);
21038 - __show_regs(regs, !user_mode_vm(regs));
21039 + __show_regs(regs, !user_mode(regs));
21040
21041 /*
21042 * When in-kernel, we also print out the stack and code at the
21043 * time of the fault..
21044 */
21045 - if (!user_mode_vm(regs)) {
21046 + if (!user_mode(regs)) {
21047 unsigned int code_prologue = code_bytes * 43 / 64;
21048 unsigned int code_len = code_bytes;
21049 unsigned char c;
21050 u8 *ip;
21051 + unsigned long cs_base = get_desc_base(&get_cpu_gdt_table(0)[(0xffff & regs->cs) >> 3]);
21052
21053 pr_emerg("Stack:\n");
21054 show_stack_log_lvl(NULL, regs, &regs->sp, 0, KERN_EMERG);
21055
21056 pr_emerg("Code:");
21057
21058 - ip = (u8 *)regs->ip - code_prologue;
21059 + ip = (u8 *)regs->ip - code_prologue + cs_base;
21060 if (ip < (u8 *)PAGE_OFFSET || probe_kernel_address(ip, c)) {
21061 /* try starting at IP */
21062 - ip = (u8 *)regs->ip;
21063 + ip = (u8 *)regs->ip + cs_base;
21064 code_len = code_len - code_prologue + 1;
21065 }
21066 for (i = 0; i < code_len; i++, ip++) {
21067 @@ -116,7 +115,7 @@ void show_regs(struct pt_regs *regs)
21068 pr_cont(" Bad EIP value.");
21069 break;
21070 }
21071 - if (ip == (u8 *)regs->ip)
21072 + if (ip == (u8 *)regs->ip + cs_base)
21073 pr_cont(" <%02x>", c);
21074 else
21075 pr_cont(" %02x", c);
21076 @@ -129,6 +128,7 @@ int is_valid_bugaddr(unsigned long ip)
21077 {
21078 unsigned short ud2;
21079
21080 + ip = ktla_ktva(ip);
21081 if (ip < PAGE_OFFSET)
21082 return 0;
21083 if (probe_kernel_address((unsigned short *)ip, ud2))
21084 @@ -136,3 +136,15 @@ int is_valid_bugaddr(unsigned long ip)
21085
21086 return ud2 == 0x0b0f;
21087 }
21088 +
21089 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21090 +void pax_check_alloca(unsigned long size)
21091 +{
21092 + unsigned long sp = (unsigned long)&sp, stack_left;
21093 +
21094 + /* all kernel stacks are of the same size */
21095 + stack_left = sp & (THREAD_SIZE - 1);
21096 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21097 +}
21098 +EXPORT_SYMBOL(pax_check_alloca);
21099 +#endif
21100 diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
21101 index addb207..99635fa 100644
21102 --- a/arch/x86/kernel/dumpstack_64.c
21103 +++ b/arch/x86/kernel/dumpstack_64.c
21104 @@ -119,9 +119,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21105 unsigned long *irq_stack_end =
21106 (unsigned long *)per_cpu(irq_stack_ptr, cpu);
21107 unsigned used = 0;
21108 - struct thread_info *tinfo;
21109 int graph = 0;
21110 unsigned long dummy;
21111 + void *stack_start;
21112
21113 if (!task)
21114 task = current;
21115 @@ -142,10 +142,10 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21116 * current stack address. If the stacks consist of nested
21117 * exceptions
21118 */
21119 - tinfo = task_thread_info(task);
21120 for (;;) {
21121 char *id;
21122 unsigned long *estack_end;
21123 +
21124 estack_end = in_exception_stack(cpu, (unsigned long)stack,
21125 &used, &id);
21126
21127 @@ -153,7 +153,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21128 if (ops->stack(data, id) < 0)
21129 break;
21130
21131 - bp = ops->walk_stack(tinfo, stack, bp, ops,
21132 + bp = ops->walk_stack(task, estack_end - EXCEPTION_STKSZ, stack, bp, ops,
21133 data, estack_end, &graph);
21134 ops->stack(data, "<EOE>");
21135 /*
21136 @@ -161,6 +161,8 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21137 * second-to-last pointer (index -2 to end) in the
21138 * exception stack:
21139 */
21140 + if ((u16)estack_end[-1] != __KERNEL_DS)
21141 + goto out;
21142 stack = (unsigned long *) estack_end[-2];
21143 continue;
21144 }
21145 @@ -172,7 +174,7 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21146 if (in_irq_stack(stack, irq_stack, irq_stack_end)) {
21147 if (ops->stack(data, "IRQ") < 0)
21148 break;
21149 - bp = ops->walk_stack(tinfo, stack, bp,
21150 + bp = ops->walk_stack(task, irq_stack, stack, bp,
21151 ops, data, irq_stack_end, &graph);
21152 /*
21153 * We link to the next stack (which would be
21154 @@ -191,7 +193,9 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs,
21155 /*
21156 * This handles the process stack:
21157 */
21158 - bp = ops->walk_stack(tinfo, stack, bp, ops, data, NULL, &graph);
21159 + stack_start = (void *)((unsigned long)stack & ~(THREAD_SIZE-1));
21160 + bp = ops->walk_stack(task, stack_start, stack, bp, ops, data, NULL, &graph);
21161 +out:
21162 put_cpu();
21163 }
21164 EXPORT_SYMBOL(dump_trace);
21165 @@ -300,3 +304,50 @@ int is_valid_bugaddr(unsigned long ip)
21166
21167 return ud2 == 0x0b0f;
21168 }
21169 +
21170 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21171 +void pax_check_alloca(unsigned long size)
21172 +{
21173 + unsigned long sp = (unsigned long)&sp, stack_start, stack_end;
21174 + unsigned cpu, used;
21175 + char *id;
21176 +
21177 + /* check the process stack first */
21178 + stack_start = (unsigned long)task_stack_page(current);
21179 + stack_end = stack_start + THREAD_SIZE;
21180 + if (likely(stack_start <= sp && sp < stack_end)) {
21181 + unsigned long stack_left = sp & (THREAD_SIZE - 1);
21182 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21183 + return;
21184 + }
21185 +
21186 + cpu = get_cpu();
21187 +
21188 + /* check the irq stacks */
21189 + stack_end = (unsigned long)per_cpu(irq_stack_ptr, cpu);
21190 + stack_start = stack_end - IRQ_STACK_SIZE;
21191 + if (stack_start <= sp && sp < stack_end) {
21192 + unsigned long stack_left = sp & (IRQ_STACK_SIZE - 1);
21193 + put_cpu();
21194 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21195 + return;
21196 + }
21197 +
21198 + /* check the exception stacks */
21199 + used = 0;
21200 + stack_end = (unsigned long)in_exception_stack(cpu, sp, &used, &id);
21201 + stack_start = stack_end - EXCEPTION_STKSZ;
21202 + if (stack_end && stack_start <= sp && sp < stack_end) {
21203 + unsigned long stack_left = sp & (EXCEPTION_STKSZ - 1);
21204 + put_cpu();
21205 + BUG_ON(stack_left < 256 || size >= stack_left - 256);
21206 + return;
21207 + }
21208 +
21209 + put_cpu();
21210 +
21211 + /* unknown stack */
21212 + BUG();
21213 +}
21214 +EXPORT_SYMBOL(pax_check_alloca);
21215 +#endif
21216 diff --git a/arch/x86/kernel/e820.c b/arch/x86/kernel/e820.c
21217 index 174da5f..5e55606 100644
21218 --- a/arch/x86/kernel/e820.c
21219 +++ b/arch/x86/kernel/e820.c
21220 @@ -803,8 +803,8 @@ unsigned long __init e820_end_of_low_ram_pfn(void)
21221
21222 static void early_panic(char *msg)
21223 {
21224 - early_printk(msg);
21225 - panic(msg);
21226 + early_printk("%s", msg);
21227 + panic("%s", msg);
21228 }
21229
21230 static int userdef __initdata;
21231 diff --git a/arch/x86/kernel/early_printk.c b/arch/x86/kernel/early_printk.c
21232 index d15f575..d692043 100644
21233 --- a/arch/x86/kernel/early_printk.c
21234 +++ b/arch/x86/kernel/early_printk.c
21235 @@ -7,6 +7,7 @@
21236 #include <linux/pci_regs.h>
21237 #include <linux/pci_ids.h>
21238 #include <linux/errno.h>
21239 +#include <linux/sched.h>
21240 #include <asm/io.h>
21241 #include <asm/processor.h>
21242 #include <asm/fcntl.h>
21243 diff --git a/arch/x86/kernel/entry_32.S b/arch/x86/kernel/entry_32.S
21244 index f0dcb0c..9f39b80 100644
21245 --- a/arch/x86/kernel/entry_32.S
21246 +++ b/arch/x86/kernel/entry_32.S
21247 @@ -177,13 +177,153 @@
21248 /*CFI_REL_OFFSET gs, PT_GS*/
21249 .endm
21250 .macro SET_KERNEL_GS reg
21251 +
21252 +#ifdef CONFIG_CC_STACKPROTECTOR
21253 movl $(__KERNEL_STACK_CANARY), \reg
21254 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
21255 + movl $(__USER_DS), \reg
21256 +#else
21257 + xorl \reg, \reg
21258 +#endif
21259 +
21260 movl \reg, %gs
21261 .endm
21262
21263 #endif /* CONFIG_X86_32_LAZY_GS */
21264
21265 -.macro SAVE_ALL
21266 +.macro pax_enter_kernel
21267 +#ifdef CONFIG_PAX_KERNEXEC
21268 + call pax_enter_kernel
21269 +#endif
21270 +.endm
21271 +
21272 +.macro pax_exit_kernel
21273 +#ifdef CONFIG_PAX_KERNEXEC
21274 + call pax_exit_kernel
21275 +#endif
21276 +.endm
21277 +
21278 +#ifdef CONFIG_PAX_KERNEXEC
21279 +ENTRY(pax_enter_kernel)
21280 +#ifdef CONFIG_PARAVIRT
21281 + pushl %eax
21282 + pushl %ecx
21283 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0)
21284 + mov %eax, %esi
21285 +#else
21286 + mov %cr0, %esi
21287 +#endif
21288 + bts $16, %esi
21289 + jnc 1f
21290 + mov %cs, %esi
21291 + cmp $__KERNEL_CS, %esi
21292 + jz 3f
21293 + ljmp $__KERNEL_CS, $3f
21294 +1: ljmp $__KERNEXEC_KERNEL_CS, $2f
21295 +2:
21296 +#ifdef CONFIG_PARAVIRT
21297 + mov %esi, %eax
21298 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0)
21299 +#else
21300 + mov %esi, %cr0
21301 +#endif
21302 +3:
21303 +#ifdef CONFIG_PARAVIRT
21304 + popl %ecx
21305 + popl %eax
21306 +#endif
21307 + ret
21308 +ENDPROC(pax_enter_kernel)
21309 +
21310 +ENTRY(pax_exit_kernel)
21311 +#ifdef CONFIG_PARAVIRT
21312 + pushl %eax
21313 + pushl %ecx
21314 +#endif
21315 + mov %cs, %esi
21316 + cmp $__KERNEXEC_KERNEL_CS, %esi
21317 + jnz 2f
21318 +#ifdef CONFIG_PARAVIRT
21319 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_read_cr0);
21320 + mov %eax, %esi
21321 +#else
21322 + mov %cr0, %esi
21323 +#endif
21324 + btr $16, %esi
21325 + ljmp $__KERNEL_CS, $1f
21326 +1:
21327 +#ifdef CONFIG_PARAVIRT
21328 + mov %esi, %eax
21329 + call PARA_INDIRECT(pv_cpu_ops+PV_CPU_write_cr0);
21330 +#else
21331 + mov %esi, %cr0
21332 +#endif
21333 +2:
21334 +#ifdef CONFIG_PARAVIRT
21335 + popl %ecx
21336 + popl %eax
21337 +#endif
21338 + ret
21339 +ENDPROC(pax_exit_kernel)
21340 +#endif
21341 +
21342 + .macro pax_erase_kstack
21343 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21344 + call pax_erase_kstack
21345 +#endif
21346 + .endm
21347 +
21348 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
21349 +/*
21350 + * ebp: thread_info
21351 + */
21352 +ENTRY(pax_erase_kstack)
21353 + pushl %edi
21354 + pushl %ecx
21355 + pushl %eax
21356 +
21357 + mov TI_lowest_stack(%ebp), %edi
21358 + mov $-0xBEEF, %eax
21359 + std
21360 +
21361 +1: mov %edi, %ecx
21362 + and $THREAD_SIZE_asm - 1, %ecx
21363 + shr $2, %ecx
21364 + repne scasl
21365 + jecxz 2f
21366 +
21367 + cmp $2*16, %ecx
21368 + jc 2f
21369 +
21370 + mov $2*16, %ecx
21371 + repe scasl
21372 + jecxz 2f
21373 + jne 1b
21374 +
21375 +2: cld
21376 + mov %esp, %ecx
21377 + sub %edi, %ecx
21378 +
21379 + cmp $THREAD_SIZE_asm, %ecx
21380 + jb 3f
21381 + ud2
21382 +3:
21383 +
21384 + shr $2, %ecx
21385 + rep stosl
21386 +
21387 + mov TI_task_thread_sp0(%ebp), %edi
21388 + sub $128, %edi
21389 + mov %edi, TI_lowest_stack(%ebp)
21390 +
21391 + popl %eax
21392 + popl %ecx
21393 + popl %edi
21394 + ret
21395 +ENDPROC(pax_erase_kstack)
21396 +#endif
21397 +
21398 +.macro __SAVE_ALL _DS
21399 cld
21400 PUSH_GS
21401 pushl_cfi %fs
21402 @@ -206,7 +346,7 @@
21403 CFI_REL_OFFSET ecx, 0
21404 pushl_cfi %ebx
21405 CFI_REL_OFFSET ebx, 0
21406 - movl $(__USER_DS), %edx
21407 + movl $\_DS, %edx
21408 movl %edx, %ds
21409 movl %edx, %es
21410 movl $(__KERNEL_PERCPU), %edx
21411 @@ -214,6 +354,15 @@
21412 SET_KERNEL_GS %edx
21413 .endm
21414
21415 +.macro SAVE_ALL
21416 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
21417 + __SAVE_ALL __KERNEL_DS
21418 + pax_enter_kernel
21419 +#else
21420 + __SAVE_ALL __USER_DS
21421 +#endif
21422 +.endm
21423 +
21424 .macro RESTORE_INT_REGS
21425 popl_cfi %ebx
21426 CFI_RESTORE ebx
21427 @@ -297,7 +446,7 @@ ENTRY(ret_from_fork)
21428 popfl_cfi
21429 jmp syscall_exit
21430 CFI_ENDPROC
21431 -END(ret_from_fork)
21432 +ENDPROC(ret_from_fork)
21433
21434 ENTRY(ret_from_kernel_thread)
21435 CFI_STARTPROC
21436 @@ -344,7 +493,15 @@ ret_from_intr:
21437 andl $SEGMENT_RPL_MASK, %eax
21438 #endif
21439 cmpl $USER_RPL, %eax
21440 +
21441 +#ifdef CONFIG_PAX_KERNEXEC
21442 + jae resume_userspace
21443 +
21444 + pax_exit_kernel
21445 + jmp resume_kernel
21446 +#else
21447 jb resume_kernel # not returning to v8086 or userspace
21448 +#endif
21449
21450 ENTRY(resume_userspace)
21451 LOCKDEP_SYS_EXIT
21452 @@ -356,8 +513,8 @@ ENTRY(resume_userspace)
21453 andl $_TIF_WORK_MASK, %ecx # is there any work to be done on
21454 # int/exception return?
21455 jne work_pending
21456 - jmp restore_all
21457 -END(ret_from_exception)
21458 + jmp restore_all_pax
21459 +ENDPROC(ret_from_exception)
21460
21461 #ifdef CONFIG_PREEMPT
21462 ENTRY(resume_kernel)
21463 @@ -372,7 +529,7 @@ need_resched:
21464 jz restore_all
21465 call preempt_schedule_irq
21466 jmp need_resched
21467 -END(resume_kernel)
21468 +ENDPROC(resume_kernel)
21469 #endif
21470 CFI_ENDPROC
21471 /*
21472 @@ -406,30 +563,45 @@ sysenter_past_esp:
21473 /*CFI_REL_OFFSET cs, 0*/
21474 /*
21475 * Push current_thread_info()->sysenter_return to the stack.
21476 - * A tiny bit of offset fixup is necessary - 4*4 means the 4 words
21477 - * pushed above; +8 corresponds to copy_thread's esp0 setting.
21478 */
21479 - pushl_cfi ((TI_sysenter_return)-THREAD_SIZE+8+4*4)(%esp)
21480 + pushl_cfi $0
21481 CFI_REL_OFFSET eip, 0
21482
21483 pushl_cfi %eax
21484 SAVE_ALL
21485 + GET_THREAD_INFO(%ebp)
21486 + movl TI_sysenter_return(%ebp),%ebp
21487 + movl %ebp,PT_EIP(%esp)
21488 ENABLE_INTERRUPTS(CLBR_NONE)
21489
21490 /*
21491 * Load the potential sixth argument from user stack.
21492 * Careful about security.
21493 */
21494 + movl PT_OLDESP(%esp),%ebp
21495 +
21496 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21497 + mov PT_OLDSS(%esp),%ds
21498 +1: movl %ds:(%ebp),%ebp
21499 + push %ss
21500 + pop %ds
21501 +#else
21502 cmpl $__PAGE_OFFSET-3,%ebp
21503 jae syscall_fault
21504 ASM_STAC
21505 1: movl (%ebp),%ebp
21506 ASM_CLAC
21507 +#endif
21508 +
21509 movl %ebp,PT_EBP(%esp)
21510 _ASM_EXTABLE(1b,syscall_fault)
21511
21512 GET_THREAD_INFO(%ebp)
21513
21514 +#ifdef CONFIG_PAX_RANDKSTACK
21515 + pax_erase_kstack
21516 +#endif
21517 +
21518 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21519 jnz sysenter_audit
21520 sysenter_do_call:
21521 @@ -444,12 +616,24 @@ sysenter_do_call:
21522 testl $_TIF_ALLWORK_MASK, %ecx
21523 jne sysexit_audit
21524 sysenter_exit:
21525 +
21526 +#ifdef CONFIG_PAX_RANDKSTACK
21527 + pushl_cfi %eax
21528 + movl %esp, %eax
21529 + call pax_randomize_kstack
21530 + popl_cfi %eax
21531 +#endif
21532 +
21533 + pax_erase_kstack
21534 +
21535 /* if something modifies registers it must also disable sysexit */
21536 movl PT_EIP(%esp), %edx
21537 movl PT_OLDESP(%esp), %ecx
21538 xorl %ebp,%ebp
21539 TRACE_IRQS_ON
21540 1: mov PT_FS(%esp), %fs
21541 +2: mov PT_DS(%esp), %ds
21542 +3: mov PT_ES(%esp), %es
21543 PTGS_TO_GS
21544 ENABLE_INTERRUPTS_SYSEXIT
21545
21546 @@ -466,6 +650,9 @@ sysenter_audit:
21547 movl %eax,%edx /* 2nd arg: syscall number */
21548 movl $AUDIT_ARCH_I386,%eax /* 1st arg: audit arch */
21549 call __audit_syscall_entry
21550 +
21551 + pax_erase_kstack
21552 +
21553 pushl_cfi %ebx
21554 movl PT_EAX(%esp),%eax /* reload syscall number */
21555 jmp sysenter_do_call
21556 @@ -491,10 +678,16 @@ sysexit_audit:
21557
21558 CFI_ENDPROC
21559 .pushsection .fixup,"ax"
21560 -2: movl $0,PT_FS(%esp)
21561 +4: movl $0,PT_FS(%esp)
21562 + jmp 1b
21563 +5: movl $0,PT_DS(%esp)
21564 + jmp 1b
21565 +6: movl $0,PT_ES(%esp)
21566 jmp 1b
21567 .popsection
21568 - _ASM_EXTABLE(1b,2b)
21569 + _ASM_EXTABLE(1b,4b)
21570 + _ASM_EXTABLE(2b,5b)
21571 + _ASM_EXTABLE(3b,6b)
21572 PTGS_TO_GS_EX
21573 ENDPROC(ia32_sysenter_target)
21574
21575 @@ -509,6 +702,11 @@ ENTRY(system_call)
21576 pushl_cfi %eax # save orig_eax
21577 SAVE_ALL
21578 GET_THREAD_INFO(%ebp)
21579 +
21580 +#ifdef CONFIG_PAX_RANDKSTACK
21581 + pax_erase_kstack
21582 +#endif
21583 +
21584 # system call tracing in operation / emulation
21585 testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%ebp)
21586 jnz syscall_trace_entry
21587 @@ -527,6 +725,15 @@ syscall_exit:
21588 testl $_TIF_ALLWORK_MASK, %ecx # current->work
21589 jne syscall_exit_work
21590
21591 +restore_all_pax:
21592 +
21593 +#ifdef CONFIG_PAX_RANDKSTACK
21594 + movl %esp, %eax
21595 + call pax_randomize_kstack
21596 +#endif
21597 +
21598 + pax_erase_kstack
21599 +
21600 restore_all:
21601 TRACE_IRQS_IRET
21602 restore_all_notrace:
21603 @@ -583,14 +790,34 @@ ldt_ss:
21604 * compensating for the offset by changing to the ESPFIX segment with
21605 * a base address that matches for the difference.
21606 */
21607 -#define GDT_ESPFIX_SS PER_CPU_VAR(gdt_page) + (GDT_ENTRY_ESPFIX_SS * 8)
21608 +#define GDT_ESPFIX_SS (GDT_ENTRY_ESPFIX_SS * 8)(%ebx)
21609 mov %esp, %edx /* load kernel esp */
21610 mov PT_OLDESP(%esp), %eax /* load userspace esp */
21611 mov %dx, %ax /* eax: new kernel esp */
21612 sub %eax, %edx /* offset (low word is 0) */
21613 +#ifdef CONFIG_SMP
21614 + movl PER_CPU_VAR(cpu_number), %ebx
21615 + shll $PAGE_SHIFT_asm, %ebx
21616 + addl $cpu_gdt_table, %ebx
21617 +#else
21618 + movl $cpu_gdt_table, %ebx
21619 +#endif
21620 shr $16, %edx
21621 - mov %dl, GDT_ESPFIX_SS + 4 /* bits 16..23 */
21622 - mov %dh, GDT_ESPFIX_SS + 7 /* bits 24..31 */
21623 +
21624 +#ifdef CONFIG_PAX_KERNEXEC
21625 + mov %cr0, %esi
21626 + btr $16, %esi
21627 + mov %esi, %cr0
21628 +#endif
21629 +
21630 + mov %dl, 4 + GDT_ESPFIX_SS /* bits 16..23 */
21631 + mov %dh, 7 + GDT_ESPFIX_SS /* bits 24..31 */
21632 +
21633 +#ifdef CONFIG_PAX_KERNEXEC
21634 + bts $16, %esi
21635 + mov %esi, %cr0
21636 +#endif
21637 +
21638 pushl_cfi $__ESPFIX_SS
21639 pushl_cfi %eax /* new kernel esp */
21640 /* Disable interrupts, but do not irqtrace this section: we
21641 @@ -619,20 +846,18 @@ work_resched:
21642 movl TI_flags(%ebp), %ecx
21643 andl $_TIF_WORK_MASK, %ecx # is there any work to be done other
21644 # than syscall tracing?
21645 - jz restore_all
21646 + jz restore_all_pax
21647 testb $_TIF_NEED_RESCHED, %cl
21648 jnz work_resched
21649
21650 work_notifysig: # deal with pending signals and
21651 # notify-resume requests
21652 + movl %esp, %eax
21653 #ifdef CONFIG_VM86
21654 testl $X86_EFLAGS_VM, PT_EFLAGS(%esp)
21655 - movl %esp, %eax
21656 jne work_notifysig_v86 # returning to kernel-space or
21657 # vm86-space
21658 1:
21659 -#else
21660 - movl %esp, %eax
21661 #endif
21662 TRACE_IRQS_ON
21663 ENABLE_INTERRUPTS(CLBR_NONE)
21664 @@ -653,7 +878,7 @@ work_notifysig_v86:
21665 movl %eax, %esp
21666 jmp 1b
21667 #endif
21668 -END(work_pending)
21669 +ENDPROC(work_pending)
21670
21671 # perform syscall exit tracing
21672 ALIGN
21673 @@ -661,11 +886,14 @@ syscall_trace_entry:
21674 movl $-ENOSYS,PT_EAX(%esp)
21675 movl %esp, %eax
21676 call syscall_trace_enter
21677 +
21678 + pax_erase_kstack
21679 +
21680 /* What it returned is what we'll actually use. */
21681 cmpl $(NR_syscalls), %eax
21682 jnae syscall_call
21683 jmp syscall_exit
21684 -END(syscall_trace_entry)
21685 +ENDPROC(syscall_trace_entry)
21686
21687 # perform syscall exit tracing
21688 ALIGN
21689 @@ -678,21 +906,25 @@ syscall_exit_work:
21690 movl %esp, %eax
21691 call syscall_trace_leave
21692 jmp resume_userspace
21693 -END(syscall_exit_work)
21694 +ENDPROC(syscall_exit_work)
21695 CFI_ENDPROC
21696
21697 RING0_INT_FRAME # can't unwind into user space anyway
21698 syscall_fault:
21699 +#ifdef CONFIG_PAX_MEMORY_UDEREF
21700 + push %ss
21701 + pop %ds
21702 +#endif
21703 ASM_CLAC
21704 GET_THREAD_INFO(%ebp)
21705 movl $-EFAULT,PT_EAX(%esp)
21706 jmp resume_userspace
21707 -END(syscall_fault)
21708 +ENDPROC(syscall_fault)
21709
21710 syscall_badsys:
21711 movl $-ENOSYS,PT_EAX(%esp)
21712 jmp resume_userspace
21713 -END(syscall_badsys)
21714 +ENDPROC(syscall_badsys)
21715 CFI_ENDPROC
21716 /*
21717 * End of kprobes section
21718 @@ -708,8 +940,15 @@ END(syscall_badsys)
21719 * normal stack and adjusts ESP with the matching offset.
21720 */
21721 /* fixup the stack */
21722 - mov GDT_ESPFIX_SS + 4, %al /* bits 16..23 */
21723 - mov GDT_ESPFIX_SS + 7, %ah /* bits 24..31 */
21724 +#ifdef CONFIG_SMP
21725 + movl PER_CPU_VAR(cpu_number), %ebx
21726 + shll $PAGE_SHIFT_asm, %ebx
21727 + addl $cpu_gdt_table, %ebx
21728 +#else
21729 + movl $cpu_gdt_table, %ebx
21730 +#endif
21731 + mov 4 + GDT_ESPFIX_SS, %al /* bits 16..23 */
21732 + mov 7 + GDT_ESPFIX_SS, %ah /* bits 24..31 */
21733 shl $16, %eax
21734 addl %esp, %eax /* the adjusted stack pointer */
21735 pushl_cfi $__KERNEL_DS
21736 @@ -762,7 +1001,7 @@ vector=vector+1
21737 .endr
21738 2: jmp common_interrupt
21739 .endr
21740 -END(irq_entries_start)
21741 +ENDPROC(irq_entries_start)
21742
21743 .previous
21744 END(interrupt)
21745 @@ -823,7 +1062,7 @@ ENTRY(coprocessor_error)
21746 pushl_cfi $do_coprocessor_error
21747 jmp error_code
21748 CFI_ENDPROC
21749 -END(coprocessor_error)
21750 +ENDPROC(coprocessor_error)
21751
21752 ENTRY(simd_coprocessor_error)
21753 RING0_INT_FRAME
21754 @@ -836,7 +1075,7 @@ ENTRY(simd_coprocessor_error)
21755 .section .altinstructions,"a"
21756 altinstruction_entry 661b, 663f, X86_FEATURE_XMM, 662b-661b, 664f-663f
21757 .previous
21758 -.section .altinstr_replacement,"ax"
21759 +.section .altinstr_replacement,"a"
21760 663: pushl $do_simd_coprocessor_error
21761 664:
21762 .previous
21763 @@ -845,7 +1084,7 @@ ENTRY(simd_coprocessor_error)
21764 #endif
21765 jmp error_code
21766 CFI_ENDPROC
21767 -END(simd_coprocessor_error)
21768 +ENDPROC(simd_coprocessor_error)
21769
21770 ENTRY(device_not_available)
21771 RING0_INT_FRAME
21772 @@ -854,18 +1093,18 @@ ENTRY(device_not_available)
21773 pushl_cfi $do_device_not_available
21774 jmp error_code
21775 CFI_ENDPROC
21776 -END(device_not_available)
21777 +ENDPROC(device_not_available)
21778
21779 #ifdef CONFIG_PARAVIRT
21780 ENTRY(native_iret)
21781 iret
21782 _ASM_EXTABLE(native_iret, iret_exc)
21783 -END(native_iret)
21784 +ENDPROC(native_iret)
21785
21786 ENTRY(native_irq_enable_sysexit)
21787 sti
21788 sysexit
21789 -END(native_irq_enable_sysexit)
21790 +ENDPROC(native_irq_enable_sysexit)
21791 #endif
21792
21793 ENTRY(overflow)
21794 @@ -875,7 +1114,7 @@ ENTRY(overflow)
21795 pushl_cfi $do_overflow
21796 jmp error_code
21797 CFI_ENDPROC
21798 -END(overflow)
21799 +ENDPROC(overflow)
21800
21801 ENTRY(bounds)
21802 RING0_INT_FRAME
21803 @@ -884,7 +1123,7 @@ ENTRY(bounds)
21804 pushl_cfi $do_bounds
21805 jmp error_code
21806 CFI_ENDPROC
21807 -END(bounds)
21808 +ENDPROC(bounds)
21809
21810 ENTRY(invalid_op)
21811 RING0_INT_FRAME
21812 @@ -893,7 +1132,7 @@ ENTRY(invalid_op)
21813 pushl_cfi $do_invalid_op
21814 jmp error_code
21815 CFI_ENDPROC
21816 -END(invalid_op)
21817 +ENDPROC(invalid_op)
21818
21819 ENTRY(coprocessor_segment_overrun)
21820 RING0_INT_FRAME
21821 @@ -902,7 +1141,7 @@ ENTRY(coprocessor_segment_overrun)
21822 pushl_cfi $do_coprocessor_segment_overrun
21823 jmp error_code
21824 CFI_ENDPROC
21825 -END(coprocessor_segment_overrun)
21826 +ENDPROC(coprocessor_segment_overrun)
21827
21828 ENTRY(invalid_TSS)
21829 RING0_EC_FRAME
21830 @@ -910,7 +1149,7 @@ ENTRY(invalid_TSS)
21831 pushl_cfi $do_invalid_TSS
21832 jmp error_code
21833 CFI_ENDPROC
21834 -END(invalid_TSS)
21835 +ENDPROC(invalid_TSS)
21836
21837 ENTRY(segment_not_present)
21838 RING0_EC_FRAME
21839 @@ -918,7 +1157,7 @@ ENTRY(segment_not_present)
21840 pushl_cfi $do_segment_not_present
21841 jmp error_code
21842 CFI_ENDPROC
21843 -END(segment_not_present)
21844 +ENDPROC(segment_not_present)
21845
21846 ENTRY(stack_segment)
21847 RING0_EC_FRAME
21848 @@ -926,7 +1165,7 @@ ENTRY(stack_segment)
21849 pushl_cfi $do_stack_segment
21850 jmp error_code
21851 CFI_ENDPROC
21852 -END(stack_segment)
21853 +ENDPROC(stack_segment)
21854
21855 ENTRY(alignment_check)
21856 RING0_EC_FRAME
21857 @@ -934,7 +1173,7 @@ ENTRY(alignment_check)
21858 pushl_cfi $do_alignment_check
21859 jmp error_code
21860 CFI_ENDPROC
21861 -END(alignment_check)
21862 +ENDPROC(alignment_check)
21863
21864 ENTRY(divide_error)
21865 RING0_INT_FRAME
21866 @@ -943,7 +1182,7 @@ ENTRY(divide_error)
21867 pushl_cfi $do_divide_error
21868 jmp error_code
21869 CFI_ENDPROC
21870 -END(divide_error)
21871 +ENDPROC(divide_error)
21872
21873 #ifdef CONFIG_X86_MCE
21874 ENTRY(machine_check)
21875 @@ -953,7 +1192,7 @@ ENTRY(machine_check)
21876 pushl_cfi machine_check_vector
21877 jmp error_code
21878 CFI_ENDPROC
21879 -END(machine_check)
21880 +ENDPROC(machine_check)
21881 #endif
21882
21883 ENTRY(spurious_interrupt_bug)
21884 @@ -963,7 +1202,7 @@ ENTRY(spurious_interrupt_bug)
21885 pushl_cfi $do_spurious_interrupt_bug
21886 jmp error_code
21887 CFI_ENDPROC
21888 -END(spurious_interrupt_bug)
21889 +ENDPROC(spurious_interrupt_bug)
21890 /*
21891 * End of kprobes section
21892 */
21893 @@ -1073,7 +1312,7 @@ BUILD_INTERRUPT3(hyperv_callback_vector, HYPERVISOR_CALLBACK_VECTOR,
21894
21895 ENTRY(mcount)
21896 ret
21897 -END(mcount)
21898 +ENDPROC(mcount)
21899
21900 ENTRY(ftrace_caller)
21901 cmpl $0, function_trace_stop
21902 @@ -1106,7 +1345,7 @@ ftrace_graph_call:
21903 .globl ftrace_stub
21904 ftrace_stub:
21905 ret
21906 -END(ftrace_caller)
21907 +ENDPROC(ftrace_caller)
21908
21909 ENTRY(ftrace_regs_caller)
21910 pushf /* push flags before compare (in cs location) */
21911 @@ -1210,7 +1449,7 @@ trace:
21912 popl %ecx
21913 popl %eax
21914 jmp ftrace_stub
21915 -END(mcount)
21916 +ENDPROC(mcount)
21917 #endif /* CONFIG_DYNAMIC_FTRACE */
21918 #endif /* CONFIG_FUNCTION_TRACER */
21919
21920 @@ -1228,7 +1467,7 @@ ENTRY(ftrace_graph_caller)
21921 popl %ecx
21922 popl %eax
21923 ret
21924 -END(ftrace_graph_caller)
21925 +ENDPROC(ftrace_graph_caller)
21926
21927 .globl return_to_handler
21928 return_to_handler:
21929 @@ -1284,15 +1523,18 @@ error_code:
21930 movl $-1, PT_ORIG_EAX(%esp) # no syscall to restart
21931 REG_TO_PTGS %ecx
21932 SET_KERNEL_GS %ecx
21933 - movl $(__USER_DS), %ecx
21934 + movl $(__KERNEL_DS), %ecx
21935 movl %ecx, %ds
21936 movl %ecx, %es
21937 +
21938 + pax_enter_kernel
21939 +
21940 TRACE_IRQS_OFF
21941 movl %esp,%eax # pt_regs pointer
21942 call *%edi
21943 jmp ret_from_exception
21944 CFI_ENDPROC
21945 -END(page_fault)
21946 +ENDPROC(page_fault)
21947
21948 /*
21949 * Debug traps and NMI can happen at the one SYSENTER instruction
21950 @@ -1335,7 +1577,7 @@ debug_stack_correct:
21951 call do_debug
21952 jmp ret_from_exception
21953 CFI_ENDPROC
21954 -END(debug)
21955 +ENDPROC(debug)
21956
21957 /*
21958 * NMI is doubly nasty. It can happen _while_ we're handling
21959 @@ -1373,6 +1615,9 @@ nmi_stack_correct:
21960 xorl %edx,%edx # zero error code
21961 movl %esp,%eax # pt_regs pointer
21962 call do_nmi
21963 +
21964 + pax_exit_kernel
21965 +
21966 jmp restore_all_notrace
21967 CFI_ENDPROC
21968
21969 @@ -1409,12 +1654,15 @@ nmi_espfix_stack:
21970 FIXUP_ESPFIX_STACK # %eax == %esp
21971 xorl %edx,%edx # zero error code
21972 call do_nmi
21973 +
21974 + pax_exit_kernel
21975 +
21976 RESTORE_REGS
21977 lss 12+4(%esp), %esp # back to espfix stack
21978 CFI_ADJUST_CFA_OFFSET -24
21979 jmp irq_return
21980 CFI_ENDPROC
21981 -END(nmi)
21982 +ENDPROC(nmi)
21983
21984 ENTRY(int3)
21985 RING0_INT_FRAME
21986 @@ -1427,14 +1675,14 @@ ENTRY(int3)
21987 call do_int3
21988 jmp ret_from_exception
21989 CFI_ENDPROC
21990 -END(int3)
21991 +ENDPROC(int3)
21992
21993 ENTRY(general_protection)
21994 RING0_EC_FRAME
21995 pushl_cfi $do_general_protection
21996 jmp error_code
21997 CFI_ENDPROC
21998 -END(general_protection)
21999 +ENDPROC(general_protection)
22000
22001 #ifdef CONFIG_KVM_GUEST
22002 ENTRY(async_page_fault)
22003 @@ -1443,7 +1691,7 @@ ENTRY(async_page_fault)
22004 pushl_cfi $do_async_page_fault
22005 jmp error_code
22006 CFI_ENDPROC
22007 -END(async_page_fault)
22008 +ENDPROC(async_page_fault)
22009 #endif
22010
22011 /*
22012 diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S
22013 index b077f4c..8e0df9f 100644
22014 --- a/arch/x86/kernel/entry_64.S
22015 +++ b/arch/x86/kernel/entry_64.S
22016 @@ -59,6 +59,8 @@
22017 #include <asm/context_tracking.h>
22018 #include <asm/smap.h>
22019 #include <linux/err.h>
22020 +#include <asm/pgtable.h>
22021 +#include <asm/alternative-asm.h>
22022
22023 /* Avoid __ASSEMBLER__'ifying <linux/audit.h> just for this. */
22024 #include <linux/elf-em.h>
22025 @@ -80,8 +82,9 @@
22026 #ifdef CONFIG_DYNAMIC_FTRACE
22027
22028 ENTRY(function_hook)
22029 + pax_force_retaddr
22030 retq
22031 -END(function_hook)
22032 +ENDPROC(function_hook)
22033
22034 /* skip is set if stack has been adjusted */
22035 .macro ftrace_caller_setup skip=0
22036 @@ -122,8 +125,9 @@ GLOBAL(ftrace_graph_call)
22037 #endif
22038
22039 GLOBAL(ftrace_stub)
22040 + pax_force_retaddr
22041 retq
22042 -END(ftrace_caller)
22043 +ENDPROC(ftrace_caller)
22044
22045 ENTRY(ftrace_regs_caller)
22046 /* Save the current flags before compare (in SS location)*/
22047 @@ -191,7 +195,7 @@ ftrace_restore_flags:
22048 popfq
22049 jmp ftrace_stub
22050
22051 -END(ftrace_regs_caller)
22052 +ENDPROC(ftrace_regs_caller)
22053
22054
22055 #else /* ! CONFIG_DYNAMIC_FTRACE */
22056 @@ -212,6 +216,7 @@ ENTRY(function_hook)
22057 #endif
22058
22059 GLOBAL(ftrace_stub)
22060 + pax_force_retaddr
22061 retq
22062
22063 trace:
22064 @@ -225,12 +230,13 @@ trace:
22065 #endif
22066 subq $MCOUNT_INSN_SIZE, %rdi
22067
22068 + pax_force_fptr ftrace_trace_function
22069 call *ftrace_trace_function
22070
22071 MCOUNT_RESTORE_FRAME
22072
22073 jmp ftrace_stub
22074 -END(function_hook)
22075 +ENDPROC(function_hook)
22076 #endif /* CONFIG_DYNAMIC_FTRACE */
22077 #endif /* CONFIG_FUNCTION_TRACER */
22078
22079 @@ -252,8 +258,9 @@ ENTRY(ftrace_graph_caller)
22080
22081 MCOUNT_RESTORE_FRAME
22082
22083 + pax_force_retaddr
22084 retq
22085 -END(ftrace_graph_caller)
22086 +ENDPROC(ftrace_graph_caller)
22087
22088 GLOBAL(return_to_handler)
22089 subq $24, %rsp
22090 @@ -269,7 +276,9 @@ GLOBAL(return_to_handler)
22091 movq 8(%rsp), %rdx
22092 movq (%rsp), %rax
22093 addq $24, %rsp
22094 + pax_force_fptr %rdi
22095 jmp *%rdi
22096 +ENDPROC(return_to_handler)
22097 #endif
22098
22099
22100 @@ -284,6 +293,430 @@ ENTRY(native_usergs_sysret64)
22101 ENDPROC(native_usergs_sysret64)
22102 #endif /* CONFIG_PARAVIRT */
22103
22104 + .macro ljmpq sel, off
22105 +#if defined(CONFIG_MPSC) || defined(CONFIG_MCORE2) || defined (CONFIG_MATOM)
22106 + .byte 0x48; ljmp *1234f(%rip)
22107 + .pushsection .rodata
22108 + .align 16
22109 + 1234: .quad \off; .word \sel
22110 + .popsection
22111 +#else
22112 + pushq $\sel
22113 + pushq $\off
22114 + lretq
22115 +#endif
22116 + .endm
22117 +
22118 + .macro pax_enter_kernel
22119 + pax_set_fptr_mask
22120 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22121 + call pax_enter_kernel
22122 +#endif
22123 + .endm
22124 +
22125 + .macro pax_exit_kernel
22126 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22127 + call pax_exit_kernel
22128 +#endif
22129 +
22130 + .endm
22131 +
22132 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
22133 +ENTRY(pax_enter_kernel)
22134 + pushq %rdi
22135 +
22136 +#ifdef CONFIG_PARAVIRT
22137 + PV_SAVE_REGS(CLBR_RDI)
22138 +#endif
22139 +
22140 +#ifdef CONFIG_PAX_KERNEXEC
22141 + GET_CR0_INTO_RDI
22142 + bts $16,%rdi
22143 + jnc 3f
22144 + mov %cs,%edi
22145 + cmp $__KERNEL_CS,%edi
22146 + jnz 2f
22147 +1:
22148 +#endif
22149 +
22150 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22151 + 661: jmp 111f
22152 + .pushsection .altinstr_replacement, "a"
22153 + 662: ASM_NOP2
22154 + .popsection
22155 + .pushsection .altinstructions, "a"
22156 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22157 + .popsection
22158 + GET_CR3_INTO_RDI
22159 + cmp $0,%dil
22160 + jnz 112f
22161 + mov $__KERNEL_DS,%edi
22162 + mov %edi,%ss
22163 + jmp 111f
22164 +112: cmp $1,%dil
22165 + jz 113f
22166 + ud2
22167 +113: sub $4097,%rdi
22168 + bts $63,%rdi
22169 + SET_RDI_INTO_CR3
22170 + mov $__UDEREF_KERNEL_DS,%edi
22171 + mov %edi,%ss
22172 +111:
22173 +#endif
22174 +
22175 +#ifdef CONFIG_PARAVIRT
22176 + PV_RESTORE_REGS(CLBR_RDI)
22177 +#endif
22178 +
22179 + popq %rdi
22180 + pax_force_retaddr
22181 + retq
22182 +
22183 +#ifdef CONFIG_PAX_KERNEXEC
22184 +2: ljmpq __KERNEL_CS,1b
22185 +3: ljmpq __KERNEXEC_KERNEL_CS,4f
22186 +4: SET_RDI_INTO_CR0
22187 + jmp 1b
22188 +#endif
22189 +ENDPROC(pax_enter_kernel)
22190 +
22191 +ENTRY(pax_exit_kernel)
22192 + pushq %rdi
22193 +
22194 +#ifdef CONFIG_PARAVIRT
22195 + PV_SAVE_REGS(CLBR_RDI)
22196 +#endif
22197 +
22198 +#ifdef CONFIG_PAX_KERNEXEC
22199 + mov %cs,%rdi
22200 + cmp $__KERNEXEC_KERNEL_CS,%edi
22201 + jz 2f
22202 + GET_CR0_INTO_RDI
22203 + bts $16,%rdi
22204 + jnc 4f
22205 +1:
22206 +#endif
22207 +
22208 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22209 + 661: jmp 111f
22210 + .pushsection .altinstr_replacement, "a"
22211 + 662: ASM_NOP2
22212 + .popsection
22213 + .pushsection .altinstructions, "a"
22214 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22215 + .popsection
22216 + mov %ss,%edi
22217 + cmp $__UDEREF_KERNEL_DS,%edi
22218 + jnz 111f
22219 + GET_CR3_INTO_RDI
22220 + cmp $0,%dil
22221 + jz 112f
22222 + ud2
22223 +112: add $4097,%rdi
22224 + bts $63,%rdi
22225 + SET_RDI_INTO_CR3
22226 + mov $__KERNEL_DS,%edi
22227 + mov %edi,%ss
22228 +111:
22229 +#endif
22230 +
22231 +#ifdef CONFIG_PARAVIRT
22232 + PV_RESTORE_REGS(CLBR_RDI);
22233 +#endif
22234 +
22235 + popq %rdi
22236 + pax_force_retaddr
22237 + retq
22238 +
22239 +#ifdef CONFIG_PAX_KERNEXEC
22240 +2: GET_CR0_INTO_RDI
22241 + btr $16,%rdi
22242 + jnc 4f
22243 + ljmpq __KERNEL_CS,3f
22244 +3: SET_RDI_INTO_CR0
22245 + jmp 1b
22246 +4: ud2
22247 + jmp 4b
22248 +#endif
22249 +ENDPROC(pax_exit_kernel)
22250 +#endif
22251 +
22252 + .macro pax_enter_kernel_user
22253 + pax_set_fptr_mask
22254 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22255 + call pax_enter_kernel_user
22256 +#endif
22257 + .endm
22258 +
22259 + .macro pax_exit_kernel_user
22260 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22261 + call pax_exit_kernel_user
22262 +#endif
22263 +#ifdef CONFIG_PAX_RANDKSTACK
22264 + pushq %rax
22265 + pushq %r11
22266 + call pax_randomize_kstack
22267 + popq %r11
22268 + popq %rax
22269 +#endif
22270 + .endm
22271 +
22272 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22273 +ENTRY(pax_enter_kernel_user)
22274 + pushq %rdi
22275 + pushq %rbx
22276 +
22277 +#ifdef CONFIG_PARAVIRT
22278 + PV_SAVE_REGS(CLBR_RDI)
22279 +#endif
22280 +
22281 + 661: jmp 111f
22282 + .pushsection .altinstr_replacement, "a"
22283 + 662: ASM_NOP2
22284 + .popsection
22285 + .pushsection .altinstructions, "a"
22286 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22287 + .popsection
22288 + GET_CR3_INTO_RDI
22289 + cmp $1,%dil
22290 + jnz 4f
22291 + sub $4097,%rdi
22292 + bts $63,%rdi
22293 + SET_RDI_INTO_CR3
22294 + jmp 3f
22295 +111:
22296 +
22297 + GET_CR3_INTO_RDI
22298 + mov %rdi,%rbx
22299 + add $__START_KERNEL_map,%rbx
22300 + sub phys_base(%rip),%rbx
22301 +
22302 +#ifdef CONFIG_PARAVIRT
22303 + cmpl $0, pv_info+PARAVIRT_enabled
22304 + jz 1f
22305 + pushq %rdi
22306 + i = 0
22307 + .rept USER_PGD_PTRS
22308 + mov i*8(%rbx),%rsi
22309 + mov $0,%sil
22310 + lea i*8(%rbx),%rdi
22311 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
22312 + i = i + 1
22313 + .endr
22314 + popq %rdi
22315 + jmp 2f
22316 +1:
22317 +#endif
22318 +
22319 + i = 0
22320 + .rept USER_PGD_PTRS
22321 + movb $0,i*8(%rbx)
22322 + i = i + 1
22323 + .endr
22324 +
22325 +2: SET_RDI_INTO_CR3
22326 +
22327 +#ifdef CONFIG_PAX_KERNEXEC
22328 + GET_CR0_INTO_RDI
22329 + bts $16,%rdi
22330 + SET_RDI_INTO_CR0
22331 +#endif
22332 +
22333 +3:
22334 +
22335 +#ifdef CONFIG_PARAVIRT
22336 + PV_RESTORE_REGS(CLBR_RDI)
22337 +#endif
22338 +
22339 + popq %rbx
22340 + popq %rdi
22341 + pax_force_retaddr
22342 + retq
22343 +4: ud2
22344 +ENDPROC(pax_enter_kernel_user)
22345 +
22346 +ENTRY(pax_exit_kernel_user)
22347 + pushq %rdi
22348 + pushq %rbx
22349 +
22350 +#ifdef CONFIG_PARAVIRT
22351 + PV_SAVE_REGS(CLBR_RDI)
22352 +#endif
22353 +
22354 + GET_CR3_INTO_RDI
22355 + 661: jmp 1f
22356 + .pushsection .altinstr_replacement, "a"
22357 + 662: ASM_NOP2
22358 + .popsection
22359 + .pushsection .altinstructions, "a"
22360 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22361 + .popsection
22362 + cmp $0,%dil
22363 + jnz 3f
22364 + add $4097,%rdi
22365 + bts $63,%rdi
22366 + SET_RDI_INTO_CR3
22367 + jmp 2f
22368 +1:
22369 +
22370 + mov %rdi,%rbx
22371 +
22372 +#ifdef CONFIG_PAX_KERNEXEC
22373 + GET_CR0_INTO_RDI
22374 + btr $16,%rdi
22375 + jnc 3f
22376 + SET_RDI_INTO_CR0
22377 +#endif
22378 +
22379 + add $__START_KERNEL_map,%rbx
22380 + sub phys_base(%rip),%rbx
22381 +
22382 +#ifdef CONFIG_PARAVIRT
22383 + cmpl $0, pv_info+PARAVIRT_enabled
22384 + jz 1f
22385 + i = 0
22386 + .rept USER_PGD_PTRS
22387 + mov i*8(%rbx),%rsi
22388 + mov $0x67,%sil
22389 + lea i*8(%rbx),%rdi
22390 + call PARA_INDIRECT(pv_mmu_ops+PV_MMU_set_pgd_batched)
22391 + i = i + 1
22392 + .endr
22393 + jmp 2f
22394 +1:
22395 +#endif
22396 +
22397 + i = 0
22398 + .rept USER_PGD_PTRS
22399 + movb $0x67,i*8(%rbx)
22400 + i = i + 1
22401 + .endr
22402 +2:
22403 +
22404 +#ifdef CONFIG_PARAVIRT
22405 + PV_RESTORE_REGS(CLBR_RDI)
22406 +#endif
22407 +
22408 + popq %rbx
22409 + popq %rdi
22410 + pax_force_retaddr
22411 + retq
22412 +3: ud2
22413 +ENDPROC(pax_exit_kernel_user)
22414 +#endif
22415 +
22416 + .macro pax_enter_kernel_nmi
22417 + pax_set_fptr_mask
22418 +
22419 +#ifdef CONFIG_PAX_KERNEXEC
22420 + GET_CR0_INTO_RDI
22421 + bts $16,%rdi
22422 + jc 110f
22423 + SET_RDI_INTO_CR0
22424 + or $2,%ebx
22425 +110:
22426 +#endif
22427 +
22428 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22429 + 661: jmp 111f
22430 + .pushsection .altinstr_replacement, "a"
22431 + 662: ASM_NOP2
22432 + .popsection
22433 + .pushsection .altinstructions, "a"
22434 + altinstruction_entry 661b, 662b, X86_FEATURE_PCID, 2, 2
22435 + .popsection
22436 + GET_CR3_INTO_RDI
22437 + cmp $0,%dil
22438 + jz 111f
22439 + sub $4097,%rdi
22440 + or $4,%ebx
22441 + bts $63,%rdi
22442 + SET_RDI_INTO_CR3
22443 + mov $__UDEREF_KERNEL_DS,%edi
22444 + mov %edi,%ss
22445 +111:
22446 +#endif
22447 + .endm
22448 +
22449 + .macro pax_exit_kernel_nmi
22450 +#ifdef CONFIG_PAX_KERNEXEC
22451 + btr $1,%ebx
22452 + jnc 110f
22453 + GET_CR0_INTO_RDI
22454 + btr $16,%rdi
22455 + SET_RDI_INTO_CR0
22456 +110:
22457 +#endif
22458 +
22459 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22460 + btr $2,%ebx
22461 + jnc 111f
22462 + GET_CR3_INTO_RDI
22463 + add $4097,%rdi
22464 + bts $63,%rdi
22465 + SET_RDI_INTO_CR3
22466 + mov $__KERNEL_DS,%edi
22467 + mov %edi,%ss
22468 +111:
22469 +#endif
22470 + .endm
22471 +
22472 + .macro pax_erase_kstack
22473 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22474 + call pax_erase_kstack
22475 +#endif
22476 + .endm
22477 +
22478 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
22479 +ENTRY(pax_erase_kstack)
22480 + pushq %rdi
22481 + pushq %rcx
22482 + pushq %rax
22483 + pushq %r11
22484 +
22485 + GET_THREAD_INFO(%r11)
22486 + mov TI_lowest_stack(%r11), %rdi
22487 + mov $-0xBEEF, %rax
22488 + std
22489 +
22490 +1: mov %edi, %ecx
22491 + and $THREAD_SIZE_asm - 1, %ecx
22492 + shr $3, %ecx
22493 + repne scasq
22494 + jecxz 2f
22495 +
22496 + cmp $2*8, %ecx
22497 + jc 2f
22498 +
22499 + mov $2*8, %ecx
22500 + repe scasq
22501 + jecxz 2f
22502 + jne 1b
22503 +
22504 +2: cld
22505 + mov %esp, %ecx
22506 + sub %edi, %ecx
22507 +
22508 + cmp $THREAD_SIZE_asm, %rcx
22509 + jb 3f
22510 + ud2
22511 +3:
22512 +
22513 + shr $3, %ecx
22514 + rep stosq
22515 +
22516 + mov TI_task_thread_sp0(%r11), %rdi
22517 + sub $256, %rdi
22518 + mov %rdi, TI_lowest_stack(%r11)
22519 +
22520 + popq %r11
22521 + popq %rax
22522 + popq %rcx
22523 + popq %rdi
22524 + pax_force_retaddr
22525 + ret
22526 +ENDPROC(pax_erase_kstack)
22527 +#endif
22528
22529 .macro TRACE_IRQS_IRETQ offset=ARGOFFSET
22530 #ifdef CONFIG_TRACE_IRQFLAGS
22531 @@ -320,7 +753,7 @@ ENDPROC(native_usergs_sysret64)
22532 .endm
22533
22534 .macro TRACE_IRQS_IRETQ_DEBUG offset=ARGOFFSET
22535 - bt $9,EFLAGS-\offset(%rsp) /* interrupts off? */
22536 + bt $X86_EFLAGS_IF_BIT,EFLAGS-\offset(%rsp) /* interrupts off? */
22537 jnc 1f
22538 TRACE_IRQS_ON_DEBUG
22539 1:
22540 @@ -358,27 +791,6 @@ ENDPROC(native_usergs_sysret64)
22541 movq \tmp,R11+\offset(%rsp)
22542 .endm
22543
22544 - .macro FAKE_STACK_FRAME child_rip
22545 - /* push in order ss, rsp, eflags, cs, rip */
22546 - xorl %eax, %eax
22547 - pushq_cfi $__KERNEL_DS /* ss */
22548 - /*CFI_REL_OFFSET ss,0*/
22549 - pushq_cfi %rax /* rsp */
22550 - CFI_REL_OFFSET rsp,0
22551 - pushq_cfi $(X86_EFLAGS_IF|X86_EFLAGS_FIXED) /* eflags - interrupts on */
22552 - /*CFI_REL_OFFSET rflags,0*/
22553 - pushq_cfi $__KERNEL_CS /* cs */
22554 - /*CFI_REL_OFFSET cs,0*/
22555 - pushq_cfi \child_rip /* rip */
22556 - CFI_REL_OFFSET rip,0
22557 - pushq_cfi %rax /* orig rax */
22558 - .endm
22559 -
22560 - .macro UNFAKE_STACK_FRAME
22561 - addq $8*6, %rsp
22562 - CFI_ADJUST_CFA_OFFSET -(6*8)
22563 - .endm
22564 -
22565 /*
22566 * initial frame state for interrupts (and exceptions without error code)
22567 */
22568 @@ -445,25 +857,26 @@ ENDPROC(native_usergs_sysret64)
22569 /* save partial stack frame */
22570 .macro SAVE_ARGS_IRQ
22571 cld
22572 - /* start from rbp in pt_regs and jump over */
22573 - movq_cfi rdi, (RDI-RBP)
22574 - movq_cfi rsi, (RSI-RBP)
22575 - movq_cfi rdx, (RDX-RBP)
22576 - movq_cfi rcx, (RCX-RBP)
22577 - movq_cfi rax, (RAX-RBP)
22578 - movq_cfi r8, (R8-RBP)
22579 - movq_cfi r9, (R9-RBP)
22580 - movq_cfi r10, (R10-RBP)
22581 - movq_cfi r11, (R11-RBP)
22582 + /* start from r15 in pt_regs and jump over */
22583 + movq_cfi rdi, RDI
22584 + movq_cfi rsi, RSI
22585 + movq_cfi rdx, RDX
22586 + movq_cfi rcx, RCX
22587 + movq_cfi rax, RAX
22588 + movq_cfi r8, R8
22589 + movq_cfi r9, R9
22590 + movq_cfi r10, R10
22591 + movq_cfi r11, R11
22592 + movq_cfi r12, R12
22593
22594 /* Save rbp so that we can unwind from get_irq_regs() */
22595 - movq_cfi rbp, 0
22596 + movq_cfi rbp, RBP
22597
22598 /* Save previous stack value */
22599 movq %rsp, %rsi
22600
22601 - leaq -RBP(%rsp),%rdi /* arg1 for handler */
22602 - testl $3, CS-RBP(%rsi)
22603 + movq %rsp,%rdi /* arg1 for handler */
22604 + testb $3, CS(%rsi)
22605 je 1f
22606 SWAPGS
22607 /*
22608 @@ -514,9 +927,10 @@ ENTRY(save_paranoid)
22609 js 1f /* negative -> in kernel */
22610 SWAPGS
22611 xorl %ebx,%ebx
22612 -1: ret
22613 +1: pax_force_retaddr_bts
22614 + ret
22615 CFI_ENDPROC
22616 -END(save_paranoid)
22617 +ENDPROC(save_paranoid)
22618 .popsection
22619
22620 /*
22621 @@ -538,7 +952,7 @@ ENTRY(ret_from_fork)
22622
22623 RESTORE_REST
22624
22625 - testl $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22626 + testb $3, CS-ARGOFFSET(%rsp) # from kernel_thread?
22627 jz 1f
22628
22629 testl $_TIF_IA32, TI_flags(%rcx) # 32-bit compat task needs IRET
22630 @@ -548,15 +962,13 @@ ENTRY(ret_from_fork)
22631 jmp ret_from_sys_call # go to the SYSRET fastpath
22632
22633 1:
22634 - subq $REST_SKIP, %rsp # leave space for volatiles
22635 - CFI_ADJUST_CFA_OFFSET REST_SKIP
22636 movq %rbp, %rdi
22637 call *%rbx
22638 movl $0, RAX(%rsp)
22639 RESTORE_REST
22640 jmp int_ret_from_sys_call
22641 CFI_ENDPROC
22642 -END(ret_from_fork)
22643 +ENDPROC(ret_from_fork)
22644
22645 /*
22646 * System call entry. Up to 6 arguments in registers are supported.
22647 @@ -593,7 +1005,7 @@ END(ret_from_fork)
22648 ENTRY(system_call)
22649 CFI_STARTPROC simple
22650 CFI_SIGNAL_FRAME
22651 - CFI_DEF_CFA rsp,KERNEL_STACK_OFFSET
22652 + CFI_DEF_CFA rsp,0
22653 CFI_REGISTER rip,rcx
22654 /*CFI_REGISTER rflags,r11*/
22655 SWAPGS_UNSAFE_STACK
22656 @@ -606,16 +1018,23 @@ GLOBAL(system_call_after_swapgs)
22657
22658 movq %rsp,PER_CPU_VAR(old_rsp)
22659 movq PER_CPU_VAR(kernel_stack),%rsp
22660 + SAVE_ARGS 8*6,0
22661 + pax_enter_kernel_user
22662 +
22663 +#ifdef CONFIG_PAX_RANDKSTACK
22664 + pax_erase_kstack
22665 +#endif
22666 +
22667 /*
22668 * No need to follow this irqs off/on section - it's straight
22669 * and short:
22670 */
22671 ENABLE_INTERRUPTS(CLBR_NONE)
22672 - SAVE_ARGS 8,0
22673 movq %rax,ORIG_RAX-ARGOFFSET(%rsp)
22674 movq %rcx,RIP-ARGOFFSET(%rsp)
22675 CFI_REL_OFFSET rip,RIP-ARGOFFSET
22676 - testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22677 + GET_THREAD_INFO(%rcx)
22678 + testl $_TIF_WORK_SYSCALL_ENTRY,TI_flags(%rcx)
22679 jnz tracesys
22680 system_call_fastpath:
22681 #if __SYSCALL_MASK == ~0
22682 @@ -639,10 +1058,13 @@ sysret_check:
22683 LOCKDEP_SYS_EXIT
22684 DISABLE_INTERRUPTS(CLBR_NONE)
22685 TRACE_IRQS_OFF
22686 - movl TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET),%edx
22687 + GET_THREAD_INFO(%rcx)
22688 + movl TI_flags(%rcx),%edx
22689 andl %edi,%edx
22690 jnz sysret_careful
22691 CFI_REMEMBER_STATE
22692 + pax_exit_kernel_user
22693 + pax_erase_kstack
22694 /*
22695 * sysretq will re-enable interrupts:
22696 */
22697 @@ -701,6 +1123,9 @@ auditsys:
22698 movq %rax,%rsi /* 2nd arg: syscall number */
22699 movl $AUDIT_ARCH_X86_64,%edi /* 1st arg: audit arch */
22700 call __audit_syscall_entry
22701 +
22702 + pax_erase_kstack
22703 +
22704 LOAD_ARGS 0 /* reload call-clobbered registers */
22705 jmp system_call_fastpath
22706
22707 @@ -722,7 +1147,7 @@ sysret_audit:
22708 /* Do syscall tracing */
22709 tracesys:
22710 #ifdef CONFIG_AUDITSYSCALL
22711 - testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags+THREAD_INFO(%rsp,RIP-ARGOFFSET)
22712 + testl $(_TIF_WORK_SYSCALL_ENTRY & ~_TIF_SYSCALL_AUDIT),TI_flags(%rcx)
22713 jz auditsys
22714 #endif
22715 SAVE_REST
22716 @@ -730,12 +1155,15 @@ tracesys:
22717 FIXUP_TOP_OF_STACK %rdi
22718 movq %rsp,%rdi
22719 call syscall_trace_enter
22720 +
22721 + pax_erase_kstack
22722 +
22723 /*
22724 * Reload arg registers from stack in case ptrace changed them.
22725 * We don't reload %rax because syscall_trace_enter() returned
22726 * the value it wants us to use in the table lookup.
22727 */
22728 - LOAD_ARGS ARGOFFSET, 1
22729 + LOAD_ARGS 1
22730 RESTORE_REST
22731 #if __SYSCALL_MASK == ~0
22732 cmpq $__NR_syscall_max,%rax
22733 @@ -765,7 +1193,9 @@ GLOBAL(int_with_check)
22734 andl %edi,%edx
22735 jnz int_careful
22736 andl $~TS_COMPAT,TI_status(%rcx)
22737 - jmp retint_swapgs
22738 + pax_exit_kernel_user
22739 + pax_erase_kstack
22740 + jmp retint_swapgs_pax
22741
22742 /* Either reschedule or signal or syscall exit tracking needed. */
22743 /* First do a reschedule test. */
22744 @@ -811,7 +1241,7 @@ int_restore_rest:
22745 TRACE_IRQS_OFF
22746 jmp int_with_check
22747 CFI_ENDPROC
22748 -END(system_call)
22749 +ENDPROC(system_call)
22750
22751 .macro FORK_LIKE func
22752 ENTRY(stub_\func)
22753 @@ -824,9 +1254,10 @@ ENTRY(stub_\func)
22754 DEFAULT_FRAME 0 8 /* offset 8: return address */
22755 call sys_\func
22756 RESTORE_TOP_OF_STACK %r11, 8
22757 - ret $REST_SKIP /* pop extended registers */
22758 + pax_force_retaddr
22759 + ret
22760 CFI_ENDPROC
22761 -END(stub_\func)
22762 +ENDPROC(stub_\func)
22763 .endm
22764
22765 .macro FIXED_FRAME label,func
22766 @@ -836,9 +1267,10 @@ ENTRY(\label)
22767 FIXUP_TOP_OF_STACK %r11, 8-ARGOFFSET
22768 call \func
22769 RESTORE_TOP_OF_STACK %r11, 8-ARGOFFSET
22770 + pax_force_retaddr
22771 ret
22772 CFI_ENDPROC
22773 -END(\label)
22774 +ENDPROC(\label)
22775 .endm
22776
22777 FORK_LIKE clone
22778 @@ -846,19 +1278,6 @@ END(\label)
22779 FORK_LIKE vfork
22780 FIXED_FRAME stub_iopl, sys_iopl
22781
22782 -ENTRY(ptregscall_common)
22783 - DEFAULT_FRAME 1 8 /* offset 8: return address */
22784 - RESTORE_TOP_OF_STACK %r11, 8
22785 - movq_cfi_restore R15+8, r15
22786 - movq_cfi_restore R14+8, r14
22787 - movq_cfi_restore R13+8, r13
22788 - movq_cfi_restore R12+8, r12
22789 - movq_cfi_restore RBP+8, rbp
22790 - movq_cfi_restore RBX+8, rbx
22791 - ret $REST_SKIP /* pop extended registers */
22792 - CFI_ENDPROC
22793 -END(ptregscall_common)
22794 -
22795 ENTRY(stub_execve)
22796 CFI_STARTPROC
22797 addq $8, %rsp
22798 @@ -870,7 +1289,7 @@ ENTRY(stub_execve)
22799 RESTORE_REST
22800 jmp int_ret_from_sys_call
22801 CFI_ENDPROC
22802 -END(stub_execve)
22803 +ENDPROC(stub_execve)
22804
22805 /*
22806 * sigreturn is special because it needs to restore all registers on return.
22807 @@ -887,7 +1306,7 @@ ENTRY(stub_rt_sigreturn)
22808 RESTORE_REST
22809 jmp int_ret_from_sys_call
22810 CFI_ENDPROC
22811 -END(stub_rt_sigreturn)
22812 +ENDPROC(stub_rt_sigreturn)
22813
22814 #ifdef CONFIG_X86_X32_ABI
22815 ENTRY(stub_x32_rt_sigreturn)
22816 @@ -901,7 +1320,7 @@ ENTRY(stub_x32_rt_sigreturn)
22817 RESTORE_REST
22818 jmp int_ret_from_sys_call
22819 CFI_ENDPROC
22820 -END(stub_x32_rt_sigreturn)
22821 +ENDPROC(stub_x32_rt_sigreturn)
22822
22823 ENTRY(stub_x32_execve)
22824 CFI_STARTPROC
22825 @@ -915,7 +1334,7 @@ ENTRY(stub_x32_execve)
22826 RESTORE_REST
22827 jmp int_ret_from_sys_call
22828 CFI_ENDPROC
22829 -END(stub_x32_execve)
22830 +ENDPROC(stub_x32_execve)
22831
22832 #endif
22833
22834 @@ -952,7 +1371,7 @@ vector=vector+1
22835 2: jmp common_interrupt
22836 .endr
22837 CFI_ENDPROC
22838 -END(irq_entries_start)
22839 +ENDPROC(irq_entries_start)
22840
22841 .previous
22842 END(interrupt)
22843 @@ -969,9 +1388,19 @@ END(interrupt)
22844 /* 0(%rsp): ~(interrupt number) */
22845 .macro interrupt func
22846 /* reserve pt_regs for scratch regs and rbp */
22847 - subq $ORIG_RAX-RBP, %rsp
22848 - CFI_ADJUST_CFA_OFFSET ORIG_RAX-RBP
22849 + subq $ORIG_RAX, %rsp
22850 + CFI_ADJUST_CFA_OFFSET ORIG_RAX
22851 SAVE_ARGS_IRQ
22852 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22853 + testb $3, CS(%rdi)
22854 + jnz 1f
22855 + pax_enter_kernel
22856 + jmp 2f
22857 +1: pax_enter_kernel_user
22858 +2:
22859 +#else
22860 + pax_enter_kernel
22861 +#endif
22862 call \func
22863 .endm
22864
22865 @@ -997,14 +1426,14 @@ ret_from_intr:
22866
22867 /* Restore saved previous stack */
22868 popq %rsi
22869 - CFI_DEF_CFA rsi,SS+8-RBP /* reg/off reset after def_cfa_expr */
22870 - leaq ARGOFFSET-RBP(%rsi), %rsp
22871 + CFI_DEF_CFA rsi,SS+8 /* reg/off reset after def_cfa_expr */
22872 + movq %rsi, %rsp
22873 CFI_DEF_CFA_REGISTER rsp
22874 - CFI_ADJUST_CFA_OFFSET RBP-ARGOFFSET
22875 + CFI_ADJUST_CFA_OFFSET -ARGOFFSET
22876
22877 exit_intr:
22878 GET_THREAD_INFO(%rcx)
22879 - testl $3,CS-ARGOFFSET(%rsp)
22880 + testb $3,CS-ARGOFFSET(%rsp)
22881 je retint_kernel
22882
22883 /* Interrupt came from user space */
22884 @@ -1026,12 +1455,16 @@ retint_swapgs: /* return to user-space */
22885 * The iretq could re-enable interrupts:
22886 */
22887 DISABLE_INTERRUPTS(CLBR_ANY)
22888 + pax_exit_kernel_user
22889 +retint_swapgs_pax:
22890 TRACE_IRQS_IRETQ
22891 SWAPGS
22892 jmp restore_args
22893
22894 retint_restore_args: /* return to kernel space */
22895 DISABLE_INTERRUPTS(CLBR_ANY)
22896 + pax_exit_kernel
22897 + pax_force_retaddr (RIP-ARGOFFSET)
22898 /*
22899 * The iretq could re-enable interrupts:
22900 */
22901 @@ -1114,7 +1547,7 @@ ENTRY(retint_kernel)
22902 #endif
22903
22904 CFI_ENDPROC
22905 -END(common_interrupt)
22906 +ENDPROC(common_interrupt)
22907 /*
22908 * End of kprobes section
22909 */
22910 @@ -1132,7 +1565,7 @@ ENTRY(\sym)
22911 interrupt \do_sym
22912 jmp ret_from_intr
22913 CFI_ENDPROC
22914 -END(\sym)
22915 +ENDPROC(\sym)
22916 .endm
22917
22918 #ifdef CONFIG_TRACING
22919 @@ -1215,12 +1648,22 @@ ENTRY(\sym)
22920 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22921 call error_entry
22922 DEFAULT_FRAME 0
22923 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22924 + testb $3, CS(%rsp)
22925 + jnz 1f
22926 + pax_enter_kernel
22927 + jmp 2f
22928 +1: pax_enter_kernel_user
22929 +2:
22930 +#else
22931 + pax_enter_kernel
22932 +#endif
22933 movq %rsp,%rdi /* pt_regs pointer */
22934 xorl %esi,%esi /* no error code */
22935 call \do_sym
22936 jmp error_exit /* %ebx: no swapgs flag */
22937 CFI_ENDPROC
22938 -END(\sym)
22939 +ENDPROC(\sym)
22940 .endm
22941
22942 .macro paranoidzeroentry sym do_sym
22943 @@ -1233,15 +1676,25 @@ ENTRY(\sym)
22944 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22945 call save_paranoid
22946 TRACE_IRQS_OFF
22947 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22948 + testb $3, CS(%rsp)
22949 + jnz 1f
22950 + pax_enter_kernel
22951 + jmp 2f
22952 +1: pax_enter_kernel_user
22953 +2:
22954 +#else
22955 + pax_enter_kernel
22956 +#endif
22957 movq %rsp,%rdi /* pt_regs pointer */
22958 xorl %esi,%esi /* no error code */
22959 call \do_sym
22960 jmp paranoid_exit /* %ebx: no swapgs flag */
22961 CFI_ENDPROC
22962 -END(\sym)
22963 +ENDPROC(\sym)
22964 .endm
22965
22966 -#define INIT_TSS_IST(x) PER_CPU_VAR(init_tss) + (TSS_ist + ((x) - 1) * 8)
22967 +#define INIT_TSS_IST(x) (TSS_ist + ((x) - 1) * 8)(%r13)
22968 .macro paranoidzeroentry_ist sym do_sym ist
22969 ENTRY(\sym)
22970 INTR_FRAME
22971 @@ -1252,14 +1705,30 @@ ENTRY(\sym)
22972 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
22973 call save_paranoid
22974 TRACE_IRQS_OFF_DEBUG
22975 +#ifdef CONFIG_PAX_MEMORY_UDEREF
22976 + testb $3, CS(%rsp)
22977 + jnz 1f
22978 + pax_enter_kernel
22979 + jmp 2f
22980 +1: pax_enter_kernel_user
22981 +2:
22982 +#else
22983 + pax_enter_kernel
22984 +#endif
22985 movq %rsp,%rdi /* pt_regs pointer */
22986 xorl %esi,%esi /* no error code */
22987 +#ifdef CONFIG_SMP
22988 + imul $TSS_size, PER_CPU_VAR(cpu_number), %r13d
22989 + lea init_tss(%r13), %r13
22990 +#else
22991 + lea init_tss(%rip), %r13
22992 +#endif
22993 subq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22994 call \do_sym
22995 addq $EXCEPTION_STKSZ, INIT_TSS_IST(\ist)
22996 jmp paranoid_exit /* %ebx: no swapgs flag */
22997 CFI_ENDPROC
22998 -END(\sym)
22999 +ENDPROC(\sym)
23000 .endm
23001
23002 .macro errorentry sym do_sym
23003 @@ -1271,13 +1740,23 @@ ENTRY(\sym)
23004 CFI_ADJUST_CFA_OFFSET ORIG_RAX-R15
23005 call error_entry
23006 DEFAULT_FRAME 0
23007 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23008 + testb $3, CS(%rsp)
23009 + jnz 1f
23010 + pax_enter_kernel
23011 + jmp 2f
23012 +1: pax_enter_kernel_user
23013 +2:
23014 +#else
23015 + pax_enter_kernel
23016 +#endif
23017 movq %rsp,%rdi /* pt_regs pointer */
23018 movq ORIG_RAX(%rsp),%rsi /* get error code */
23019 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
23020 call \do_sym
23021 jmp error_exit /* %ebx: no swapgs flag */
23022 CFI_ENDPROC
23023 -END(\sym)
23024 +ENDPROC(\sym)
23025 .endm
23026
23027 /* error code is on the stack already */
23028 @@ -1291,13 +1770,23 @@ ENTRY(\sym)
23029 call save_paranoid
23030 DEFAULT_FRAME 0
23031 TRACE_IRQS_OFF
23032 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23033 + testb $3, CS(%rsp)
23034 + jnz 1f
23035 + pax_enter_kernel
23036 + jmp 2f
23037 +1: pax_enter_kernel_user
23038 +2:
23039 +#else
23040 + pax_enter_kernel
23041 +#endif
23042 movq %rsp,%rdi /* pt_regs pointer */
23043 movq ORIG_RAX(%rsp),%rsi /* get error code */
23044 movq $-1,ORIG_RAX(%rsp) /* no syscall to restart */
23045 call \do_sym
23046 jmp paranoid_exit /* %ebx: no swapgs flag */
23047 CFI_ENDPROC
23048 -END(\sym)
23049 +ENDPROC(\sym)
23050 .endm
23051
23052 zeroentry divide_error do_divide_error
23053 @@ -1327,9 +1816,10 @@ gs_change:
23054 2: mfence /* workaround */
23055 SWAPGS
23056 popfq_cfi
23057 + pax_force_retaddr
23058 ret
23059 CFI_ENDPROC
23060 -END(native_load_gs_index)
23061 +ENDPROC(native_load_gs_index)
23062
23063 _ASM_EXTABLE(gs_change,bad_gs)
23064 .section .fixup,"ax"
23065 @@ -1357,9 +1847,10 @@ ENTRY(call_softirq)
23066 CFI_DEF_CFA_REGISTER rsp
23067 CFI_ADJUST_CFA_OFFSET -8
23068 decl PER_CPU_VAR(irq_count)
23069 + pax_force_retaddr
23070 ret
23071 CFI_ENDPROC
23072 -END(call_softirq)
23073 +ENDPROC(call_softirq)
23074
23075 #ifdef CONFIG_XEN
23076 zeroentry xen_hypervisor_callback xen_do_hypervisor_callback
23077 @@ -1397,7 +1888,7 @@ ENTRY(xen_do_hypervisor_callback) # do_hypervisor_callback(struct *pt_regs)
23078 decl PER_CPU_VAR(irq_count)
23079 jmp error_exit
23080 CFI_ENDPROC
23081 -END(xen_do_hypervisor_callback)
23082 +ENDPROC(xen_do_hypervisor_callback)
23083
23084 /*
23085 * Hypervisor uses this for application faults while it executes.
23086 @@ -1456,7 +1947,7 @@ ENTRY(xen_failsafe_callback)
23087 SAVE_ALL
23088 jmp error_exit
23089 CFI_ENDPROC
23090 -END(xen_failsafe_callback)
23091 +ENDPROC(xen_failsafe_callback)
23092
23093 apicinterrupt3 HYPERVISOR_CALLBACK_VECTOR \
23094 xen_hvm_callback_vector xen_evtchn_do_upcall
23095 @@ -1508,18 +1999,33 @@ ENTRY(paranoid_exit)
23096 DEFAULT_FRAME
23097 DISABLE_INTERRUPTS(CLBR_NONE)
23098 TRACE_IRQS_OFF_DEBUG
23099 - testl %ebx,%ebx /* swapgs needed? */
23100 + testl $1,%ebx /* swapgs needed? */
23101 jnz paranoid_restore
23102 - testl $3,CS(%rsp)
23103 + testb $3,CS(%rsp)
23104 jnz paranoid_userspace
23105 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23106 + pax_exit_kernel
23107 + TRACE_IRQS_IRETQ 0
23108 + SWAPGS_UNSAFE_STACK
23109 + RESTORE_ALL 8
23110 + pax_force_retaddr_bts
23111 + jmp irq_return
23112 +#endif
23113 paranoid_swapgs:
23114 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23115 + pax_exit_kernel_user
23116 +#else
23117 + pax_exit_kernel
23118 +#endif
23119 TRACE_IRQS_IRETQ 0
23120 SWAPGS_UNSAFE_STACK
23121 RESTORE_ALL 8
23122 jmp irq_return
23123 paranoid_restore:
23124 + pax_exit_kernel
23125 TRACE_IRQS_IRETQ_DEBUG 0
23126 RESTORE_ALL 8
23127 + pax_force_retaddr_bts
23128 jmp irq_return
23129 paranoid_userspace:
23130 GET_THREAD_INFO(%rcx)
23131 @@ -1548,7 +2054,7 @@ paranoid_schedule:
23132 TRACE_IRQS_OFF
23133 jmp paranoid_userspace
23134 CFI_ENDPROC
23135 -END(paranoid_exit)
23136 +ENDPROC(paranoid_exit)
23137
23138 /*
23139 * Exception entry point. This expects an error code/orig_rax on the stack.
23140 @@ -1575,12 +2081,13 @@ ENTRY(error_entry)
23141 movq_cfi r14, R14+8
23142 movq_cfi r15, R15+8
23143 xorl %ebx,%ebx
23144 - testl $3,CS+8(%rsp)
23145 + testb $3,CS+8(%rsp)
23146 je error_kernelspace
23147 error_swapgs:
23148 SWAPGS
23149 error_sti:
23150 TRACE_IRQS_OFF
23151 + pax_force_retaddr_bts
23152 ret
23153
23154 /*
23155 @@ -1607,7 +2114,7 @@ bstep_iret:
23156 movq %rcx,RIP+8(%rsp)
23157 jmp error_swapgs
23158 CFI_ENDPROC
23159 -END(error_entry)
23160 +ENDPROC(error_entry)
23161
23162
23163 /* ebx: no swapgs flag (1: don't need swapgs, 0: need it) */
23164 @@ -1618,7 +2125,7 @@ ENTRY(error_exit)
23165 DISABLE_INTERRUPTS(CLBR_NONE)
23166 TRACE_IRQS_OFF
23167 GET_THREAD_INFO(%rcx)
23168 - testl %eax,%eax
23169 + testl $1,%eax
23170 jne retint_kernel
23171 LOCKDEP_SYS_EXIT_IRQ
23172 movl TI_flags(%rcx),%edx
23173 @@ -1627,7 +2134,7 @@ ENTRY(error_exit)
23174 jnz retint_careful
23175 jmp retint_swapgs
23176 CFI_ENDPROC
23177 -END(error_exit)
23178 +ENDPROC(error_exit)
23179
23180 /*
23181 * Test if a given stack is an NMI stack or not.
23182 @@ -1685,9 +2192,11 @@ ENTRY(nmi)
23183 * If %cs was not the kernel segment, then the NMI triggered in user
23184 * space, which means it is definitely not nested.
23185 */
23186 + cmpl $__KERNEXEC_KERNEL_CS, 16(%rsp)
23187 + je 1f
23188 cmpl $__KERNEL_CS, 16(%rsp)
23189 jne first_nmi
23190 -
23191 +1:
23192 /*
23193 * Check the special variable on the stack to see if NMIs are
23194 * executing.
23195 @@ -1721,8 +2230,7 @@ nested_nmi:
23196
23197 1:
23198 /* Set up the interrupted NMIs stack to jump to repeat_nmi */
23199 - leaq -1*8(%rsp), %rdx
23200 - movq %rdx, %rsp
23201 + subq $8, %rsp
23202 CFI_ADJUST_CFA_OFFSET 1*8
23203 leaq -10*8(%rsp), %rdx
23204 pushq_cfi $__KERNEL_DS
23205 @@ -1740,6 +2248,7 @@ nested_nmi_out:
23206 CFI_RESTORE rdx
23207
23208 /* No need to check faults here */
23209 +# pax_force_retaddr_bts
23210 INTERRUPT_RETURN
23211
23212 CFI_RESTORE_STATE
23213 @@ -1852,9 +2361,11 @@ end_repeat_nmi:
23214 * NMI itself takes a page fault, the page fault that was preempted
23215 * will read the information from the NMI page fault and not the
23216 * origin fault. Save it off and restore it if it changes.
23217 - * Use the r12 callee-saved register.
23218 + * Use the r13 callee-saved register.
23219 */
23220 - movq %cr2, %r12
23221 + movq %cr2, %r13
23222 +
23223 + pax_enter_kernel_nmi
23224
23225 /* paranoidentry do_nmi, 0; without TRACE_IRQS_OFF */
23226 movq %rsp,%rdi
23227 @@ -1863,31 +2374,36 @@ end_repeat_nmi:
23228
23229 /* Did the NMI take a page fault? Restore cr2 if it did */
23230 movq %cr2, %rcx
23231 - cmpq %rcx, %r12
23232 + cmpq %rcx, %r13
23233 je 1f
23234 - movq %r12, %cr2
23235 + movq %r13, %cr2
23236 1:
23237
23238 - testl %ebx,%ebx /* swapgs needed? */
23239 + testl $1,%ebx /* swapgs needed? */
23240 jnz nmi_restore
23241 nmi_swapgs:
23242 SWAPGS_UNSAFE_STACK
23243 nmi_restore:
23244 + pax_exit_kernel_nmi
23245 /* Pop the extra iret frame at once */
23246 RESTORE_ALL 6*8
23247 + testb $3, 8(%rsp)
23248 + jnz 1f
23249 + pax_force_retaddr_bts
23250 +1:
23251
23252 /* Clear the NMI executing stack variable */
23253 movq $0, 5*8(%rsp)
23254 jmp irq_return
23255 CFI_ENDPROC
23256 -END(nmi)
23257 +ENDPROC(nmi)
23258
23259 ENTRY(ignore_sysret)
23260 CFI_STARTPROC
23261 mov $-ENOSYS,%eax
23262 sysret
23263 CFI_ENDPROC
23264 -END(ignore_sysret)
23265 +ENDPROC(ignore_sysret)
23266
23267 /*
23268 * End of kprobes section
23269 diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c
23270 index d4bdd25..912664c 100644
23271 --- a/arch/x86/kernel/ftrace.c
23272 +++ b/arch/x86/kernel/ftrace.c
23273 @@ -105,6 +105,8 @@ ftrace_modify_code_direct(unsigned long ip, unsigned const char *old_code,
23274 {
23275 unsigned char replaced[MCOUNT_INSN_SIZE];
23276
23277 + ip = ktla_ktva(ip);
23278 +
23279 /*
23280 * Note: Due to modules and __init, code can
23281 * disappear and change, we need to protect against faulting
23282 @@ -227,7 +229,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
23283 unsigned char old[MCOUNT_INSN_SIZE], *new;
23284 int ret;
23285
23286 - memcpy(old, &ftrace_call, MCOUNT_INSN_SIZE);
23287 + memcpy(old, (void *)ktla_ktva((unsigned long)ftrace_call), MCOUNT_INSN_SIZE);
23288 new = ftrace_call_replace(ip, (unsigned long)func);
23289
23290 /* See comment above by declaration of modifying_ftrace_code */
23291 @@ -238,7 +240,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func)
23292 /* Also update the regs callback function */
23293 if (!ret) {
23294 ip = (unsigned long)(&ftrace_regs_call);
23295 - memcpy(old, &ftrace_regs_call, MCOUNT_INSN_SIZE);
23296 + memcpy(old, ktla_ktva((void *)&ftrace_regs_call), MCOUNT_INSN_SIZE);
23297 new = ftrace_call_replace(ip, (unsigned long)func);
23298 ret = ftrace_modify_code(ip, old, new);
23299 }
23300 @@ -291,7 +293,7 @@ static int ftrace_write(unsigned long ip, const char *val, int size)
23301 * kernel identity mapping to modify code.
23302 */
23303 if (within(ip, (unsigned long)_text, (unsigned long)_etext))
23304 - ip = (unsigned long)__va(__pa_symbol(ip));
23305 + ip = (unsigned long)__va(__pa_symbol(ktla_ktva(ip)));
23306
23307 return probe_kernel_write((void *)ip, val, size);
23308 }
23309 @@ -301,7 +303,7 @@ static int add_break(unsigned long ip, const char *old)
23310 unsigned char replaced[MCOUNT_INSN_SIZE];
23311 unsigned char brk = BREAKPOINT_INSTRUCTION;
23312
23313 - if (probe_kernel_read(replaced, (void *)ip, MCOUNT_INSN_SIZE))
23314 + if (probe_kernel_read(replaced, (void *)ktla_ktva(ip), MCOUNT_INSN_SIZE))
23315 return -EFAULT;
23316
23317 /* Make sure it is what we expect it to be */
23318 @@ -649,7 +651,7 @@ ftrace_modify_code(unsigned long ip, unsigned const char *old_code,
23319 return ret;
23320
23321 fail_update:
23322 - probe_kernel_write((void *)ip, &old_code[0], 1);
23323 + probe_kernel_write((void *)ktla_ktva(ip), &old_code[0], 1);
23324 goto out;
23325 }
23326
23327 @@ -682,6 +684,8 @@ static int ftrace_mod_jmp(unsigned long ip,
23328 {
23329 unsigned char code[MCOUNT_INSN_SIZE];
23330
23331 + ip = ktla_ktva(ip);
23332 +
23333 if (probe_kernel_read(code, (void *)ip, MCOUNT_INSN_SIZE))
23334 return -EFAULT;
23335
23336 diff --git a/arch/x86/kernel/head64.c b/arch/x86/kernel/head64.c
23337 index 1be8e43..d9b9ef6 100644
23338 --- a/arch/x86/kernel/head64.c
23339 +++ b/arch/x86/kernel/head64.c
23340 @@ -67,12 +67,12 @@ again:
23341 pgd = *pgd_p;
23342
23343 /*
23344 - * The use of __START_KERNEL_map rather than __PAGE_OFFSET here is
23345 - * critical -- __PAGE_OFFSET would point us back into the dynamic
23346 + * The use of __early_va rather than __va here is critical:
23347 + * __va would point us back into the dynamic
23348 * range and we might end up looping forever...
23349 */
23350 if (pgd)
23351 - pud_p = (pudval_t *)((pgd & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
23352 + pud_p = (pudval_t *)(__early_va(pgd & PTE_PFN_MASK));
23353 else {
23354 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
23355 reset_early_page_tables();
23356 @@ -82,13 +82,13 @@ again:
23357 pud_p = (pudval_t *)early_dynamic_pgts[next_early_pgt++];
23358 for (i = 0; i < PTRS_PER_PUD; i++)
23359 pud_p[i] = 0;
23360 - *pgd_p = (pgdval_t)pud_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
23361 + *pgd_p = (pgdval_t)__pa(pud_p) + _KERNPG_TABLE;
23362 }
23363 pud_p += pud_index(address);
23364 pud = *pud_p;
23365
23366 if (pud)
23367 - pmd_p = (pmdval_t *)((pud & PTE_PFN_MASK) + __START_KERNEL_map - phys_base);
23368 + pmd_p = (pmdval_t *)(__early_va(pud & PTE_PFN_MASK));
23369 else {
23370 if (next_early_pgt >= EARLY_DYNAMIC_PAGE_TABLES) {
23371 reset_early_page_tables();
23372 @@ -98,7 +98,7 @@ again:
23373 pmd_p = (pmdval_t *)early_dynamic_pgts[next_early_pgt++];
23374 for (i = 0; i < PTRS_PER_PMD; i++)
23375 pmd_p[i] = 0;
23376 - *pud_p = (pudval_t)pmd_p - __START_KERNEL_map + phys_base + _KERNPG_TABLE;
23377 + *pud_p = (pudval_t)__pa(pmd_p) + _KERNPG_TABLE;
23378 }
23379 pmd = (physaddr & PMD_MASK) + early_pmd_flags;
23380 pmd_p[pmd_index(address)] = pmd;
23381 @@ -175,7 +175,6 @@ asmlinkage void __init x86_64_start_kernel(char * real_mode_data)
23382 if (console_loglevel == 10)
23383 early_printk("Kernel alive\n");
23384
23385 - clear_page(init_level4_pgt);
23386 /* set init_level4_pgt kernel high mapping*/
23387 init_level4_pgt[511] = early_level4_pgt[511];
23388
23389 diff --git a/arch/x86/kernel/head_32.S b/arch/x86/kernel/head_32.S
23390 index 81ba276..30c5411 100644
23391 --- a/arch/x86/kernel/head_32.S
23392 +++ b/arch/x86/kernel/head_32.S
23393 @@ -26,6 +26,12 @@
23394 /* Physical address */
23395 #define pa(X) ((X) - __PAGE_OFFSET)
23396
23397 +#ifdef CONFIG_PAX_KERNEXEC
23398 +#define ta(X) (X)
23399 +#else
23400 +#define ta(X) ((X) - __PAGE_OFFSET)
23401 +#endif
23402 +
23403 /*
23404 * References to members of the new_cpu_data structure.
23405 */
23406 @@ -55,11 +61,7 @@
23407 * and small than max_low_pfn, otherwise will waste some page table entries
23408 */
23409
23410 -#if PTRS_PER_PMD > 1
23411 -#define PAGE_TABLE_SIZE(pages) (((pages) / PTRS_PER_PMD) + PTRS_PER_PGD)
23412 -#else
23413 -#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PGD)
23414 -#endif
23415 +#define PAGE_TABLE_SIZE(pages) ((pages) / PTRS_PER_PTE)
23416
23417 /* Number of possible pages in the lowmem region */
23418 LOWMEM_PAGES = (((1<<32) - __PAGE_OFFSET) >> PAGE_SHIFT)
23419 @@ -78,6 +80,12 @@ INIT_MAP_SIZE = PAGE_TABLE_SIZE(KERNEL_PAGES) * PAGE_SIZE
23420 RESERVE_BRK(pagetables, INIT_MAP_SIZE)
23421
23422 /*
23423 + * Real beginning of normal "text" segment
23424 + */
23425 +ENTRY(stext)
23426 +ENTRY(_stext)
23427 +
23428 +/*
23429 * 32-bit kernel entrypoint; only used by the boot CPU. On entry,
23430 * %esi points to the real-mode code as a 32-bit pointer.
23431 * CS and DS must be 4 GB flat segments, but we don't depend on
23432 @@ -85,6 +93,13 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE)
23433 * can.
23434 */
23435 __HEAD
23436 +
23437 +#ifdef CONFIG_PAX_KERNEXEC
23438 + jmp startup_32
23439 +/* PaX: fill first page in .text with int3 to catch NULL derefs in kernel mode */
23440 +.fill PAGE_SIZE-5,1,0xcc
23441 +#endif
23442 +
23443 ENTRY(startup_32)
23444 movl pa(stack_start),%ecx
23445
23446 @@ -106,6 +121,59 @@ ENTRY(startup_32)
23447 2:
23448 leal -__PAGE_OFFSET(%ecx),%esp
23449
23450 +#ifdef CONFIG_SMP
23451 + movl $pa(cpu_gdt_table),%edi
23452 + movl $__per_cpu_load,%eax
23453 + movw %ax,GDT_ENTRY_PERCPU * 8 + 2(%edi)
23454 + rorl $16,%eax
23455 + movb %al,GDT_ENTRY_PERCPU * 8 + 4(%edi)
23456 + movb %ah,GDT_ENTRY_PERCPU * 8 + 7(%edi)
23457 + movl $__per_cpu_end - 1,%eax
23458 + subl $__per_cpu_start,%eax
23459 + movw %ax,GDT_ENTRY_PERCPU * 8 + 0(%edi)
23460 +#endif
23461 +
23462 +#ifdef CONFIG_PAX_MEMORY_UDEREF
23463 + movl $NR_CPUS,%ecx
23464 + movl $pa(cpu_gdt_table),%edi
23465 +1:
23466 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c09700),GDT_ENTRY_KERNEL_DS * 8 + 4(%edi)
23467 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0fb00),GDT_ENTRY_DEFAULT_USER_CS * 8 + 4(%edi)
23468 + movl $((((__PAGE_OFFSET-1) & 0xf0000000) >> 12) | 0x00c0f300),GDT_ENTRY_DEFAULT_USER_DS * 8 + 4(%edi)
23469 + addl $PAGE_SIZE_asm,%edi
23470 + loop 1b
23471 +#endif
23472 +
23473 +#ifdef CONFIG_PAX_KERNEXEC
23474 + movl $pa(boot_gdt),%edi
23475 + movl $__LOAD_PHYSICAL_ADDR,%eax
23476 + movw %ax,GDT_ENTRY_BOOT_CS * 8 + 2(%edi)
23477 + rorl $16,%eax
23478 + movb %al,GDT_ENTRY_BOOT_CS * 8 + 4(%edi)
23479 + movb %ah,GDT_ENTRY_BOOT_CS * 8 + 7(%edi)
23480 + rorl $16,%eax
23481 +
23482 + ljmp $(__BOOT_CS),$1f
23483 +1:
23484 +
23485 + movl $NR_CPUS,%ecx
23486 + movl $pa(cpu_gdt_table),%edi
23487 + addl $__PAGE_OFFSET,%eax
23488 +1:
23489 + movb $0xc0,GDT_ENTRY_KERNEL_CS * 8 + 6(%edi)
23490 + movb $0xc0,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 6(%edi)
23491 + movw %ax,GDT_ENTRY_KERNEL_CS * 8 + 2(%edi)
23492 + movw %ax,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 2(%edi)
23493 + rorl $16,%eax
23494 + movb %al,GDT_ENTRY_KERNEL_CS * 8 + 4(%edi)
23495 + movb %al,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 4(%edi)
23496 + movb %ah,GDT_ENTRY_KERNEL_CS * 8 + 7(%edi)
23497 + movb %ah,GDT_ENTRY_KERNEXEC_KERNEL_CS * 8 + 7(%edi)
23498 + rorl $16,%eax
23499 + addl $PAGE_SIZE_asm,%edi
23500 + loop 1b
23501 +#endif
23502 +
23503 /*
23504 * Clear BSS first so that there are no surprises...
23505 */
23506 @@ -201,8 +269,11 @@ ENTRY(startup_32)
23507 movl %eax, pa(max_pfn_mapped)
23508
23509 /* Do early initialization of the fixmap area */
23510 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23511 - movl %eax,pa(initial_pg_pmd+0x1000*KPMDS-8)
23512 +#ifdef CONFIG_COMPAT_VDSO
23513 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_pg_pmd+0x1000*KPMDS-8)
23514 +#else
23515 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_pg_pmd+0x1000*KPMDS-8)
23516 +#endif
23517 #else /* Not PAE */
23518
23519 page_pde_offset = (__PAGE_OFFSET >> 20);
23520 @@ -232,8 +303,11 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23521 movl %eax, pa(max_pfn_mapped)
23522
23523 /* Do early initialization of the fixmap area */
23524 - movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,%eax
23525 - movl %eax,pa(initial_page_table+0xffc)
23526 +#ifdef CONFIG_COMPAT_VDSO
23527 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR+_PAGE_USER,pa(initial_page_table+0xffc)
23528 +#else
23529 + movl $pa(initial_pg_fixmap)+PDE_IDENT_ATTR,pa(initial_page_table+0xffc)
23530 +#endif
23531 #endif
23532
23533 #ifdef CONFIG_PARAVIRT
23534 @@ -247,9 +321,7 @@ page_pde_offset = (__PAGE_OFFSET >> 20);
23535 cmpl $num_subarch_entries, %eax
23536 jae bad_subarch
23537
23538 - movl pa(subarch_entries)(,%eax,4), %eax
23539 - subl $__PAGE_OFFSET, %eax
23540 - jmp *%eax
23541 + jmp *pa(subarch_entries)(,%eax,4)
23542
23543 bad_subarch:
23544 WEAK(lguest_entry)
23545 @@ -261,10 +333,10 @@ WEAK(xen_entry)
23546 __INITDATA
23547
23548 subarch_entries:
23549 - .long default_entry /* normal x86/PC */
23550 - .long lguest_entry /* lguest hypervisor */
23551 - .long xen_entry /* Xen hypervisor */
23552 - .long default_entry /* Moorestown MID */
23553 + .long ta(default_entry) /* normal x86/PC */
23554 + .long ta(lguest_entry) /* lguest hypervisor */
23555 + .long ta(xen_entry) /* Xen hypervisor */
23556 + .long ta(default_entry) /* Moorestown MID */
23557 num_subarch_entries = (. - subarch_entries) / 4
23558 .previous
23559 #else
23560 @@ -354,6 +426,7 @@ default_entry:
23561 movl pa(mmu_cr4_features),%eax
23562 movl %eax,%cr4
23563
23564 +#ifdef CONFIG_X86_PAE
23565 testb $X86_CR4_PAE, %al # check if PAE is enabled
23566 jz enable_paging
23567
23568 @@ -382,6 +455,9 @@ default_entry:
23569 /* Make changes effective */
23570 wrmsr
23571
23572 + btsl $_PAGE_BIT_NX-32,pa(__supported_pte_mask+4)
23573 +#endif
23574 +
23575 enable_paging:
23576
23577 /*
23578 @@ -449,14 +525,20 @@ is486:
23579 1: movl $(__KERNEL_DS),%eax # reload all the segment registers
23580 movl %eax,%ss # after changing gdt.
23581
23582 - movl $(__USER_DS),%eax # DS/ES contains default USER segment
23583 +# movl $(__KERNEL_DS),%eax # DS/ES contains default KERNEL segment
23584 movl %eax,%ds
23585 movl %eax,%es
23586
23587 movl $(__KERNEL_PERCPU), %eax
23588 movl %eax,%fs # set this cpu's percpu
23589
23590 +#ifdef CONFIG_CC_STACKPROTECTOR
23591 movl $(__KERNEL_STACK_CANARY),%eax
23592 +#elif defined(CONFIG_PAX_MEMORY_UDEREF)
23593 + movl $(__USER_DS),%eax
23594 +#else
23595 + xorl %eax,%eax
23596 +#endif
23597 movl %eax,%gs
23598
23599 xorl %eax,%eax # Clear LDT
23600 @@ -512,8 +594,11 @@ setup_once:
23601 * relocation. Manually set base address in stack canary
23602 * segment descriptor.
23603 */
23604 - movl $gdt_page,%eax
23605 + movl $cpu_gdt_table,%eax
23606 movl $stack_canary,%ecx
23607 +#ifdef CONFIG_SMP
23608 + addl $__per_cpu_load,%ecx
23609 +#endif
23610 movw %cx, 8 * GDT_ENTRY_STACK_CANARY + 2(%eax)
23611 shrl $16, %ecx
23612 movb %cl, 8 * GDT_ENTRY_STACK_CANARY + 4(%eax)
23613 @@ -544,7 +629,7 @@ ENDPROC(early_idt_handlers)
23614 /* This is global to keep gas from relaxing the jumps */
23615 ENTRY(early_idt_handler)
23616 cld
23617 - cmpl $2,%ss:early_recursion_flag
23618 + cmpl $1,%ss:early_recursion_flag
23619 je hlt_loop
23620 incl %ss:early_recursion_flag
23621
23622 @@ -582,8 +667,8 @@ ENTRY(early_idt_handler)
23623 pushl (20+6*4)(%esp) /* trapno */
23624 pushl $fault_msg
23625 call printk
23626 -#endif
23627 call dump_stack
23628 +#endif
23629 hlt_loop:
23630 hlt
23631 jmp hlt_loop
23632 @@ -602,8 +687,11 @@ ENDPROC(early_idt_handler)
23633 /* This is the default interrupt "handler" :-) */
23634 ALIGN
23635 ignore_int:
23636 - cld
23637 #ifdef CONFIG_PRINTK
23638 + cmpl $2,%ss:early_recursion_flag
23639 + je hlt_loop
23640 + incl %ss:early_recursion_flag
23641 + cld
23642 pushl %eax
23643 pushl %ecx
23644 pushl %edx
23645 @@ -612,9 +700,6 @@ ignore_int:
23646 movl $(__KERNEL_DS),%eax
23647 movl %eax,%ds
23648 movl %eax,%es
23649 - cmpl $2,early_recursion_flag
23650 - je hlt_loop
23651 - incl early_recursion_flag
23652 pushl 16(%esp)
23653 pushl 24(%esp)
23654 pushl 32(%esp)
23655 @@ -648,29 +733,34 @@ ENTRY(setup_once_ref)
23656 /*
23657 * BSS section
23658 */
23659 -__PAGE_ALIGNED_BSS
23660 - .align PAGE_SIZE
23661 #ifdef CONFIG_X86_PAE
23662 +.section .initial_pg_pmd,"a",@progbits
23663 initial_pg_pmd:
23664 .fill 1024*KPMDS,4,0
23665 #else
23666 +.section .initial_page_table,"a",@progbits
23667 ENTRY(initial_page_table)
23668 .fill 1024,4,0
23669 #endif
23670 +.section .initial_pg_fixmap,"a",@progbits
23671 initial_pg_fixmap:
23672 .fill 1024,4,0
23673 +.section .empty_zero_page,"a",@progbits
23674 ENTRY(empty_zero_page)
23675 .fill 4096,1,0
23676 +.section .swapper_pg_dir,"a",@progbits
23677 ENTRY(swapper_pg_dir)
23678 +#ifdef CONFIG_X86_PAE
23679 + .fill 4,8,0
23680 +#else
23681 .fill 1024,4,0
23682 +#endif
23683
23684 /*
23685 * This starts the data section.
23686 */
23687 #ifdef CONFIG_X86_PAE
23688 -__PAGE_ALIGNED_DATA
23689 - /* Page-aligned for the benefit of paravirt? */
23690 - .align PAGE_SIZE
23691 +.section .initial_page_table,"a",@progbits
23692 ENTRY(initial_page_table)
23693 .long pa(initial_pg_pmd+PGD_IDENT_ATTR),0 /* low identity map */
23694 # if KPMDS == 3
23695 @@ -689,12 +779,20 @@ ENTRY(initial_page_table)
23696 # error "Kernel PMDs should be 1, 2 or 3"
23697 # endif
23698 .align PAGE_SIZE /* needs to be page-sized too */
23699 +
23700 +#ifdef CONFIG_PAX_PER_CPU_PGD
23701 +ENTRY(cpu_pgd)
23702 + .rept 2*NR_CPUS
23703 + .fill 4,8,0
23704 + .endr
23705 +#endif
23706 +
23707 #endif
23708
23709 .data
23710 .balign 4
23711 ENTRY(stack_start)
23712 - .long init_thread_union+THREAD_SIZE
23713 + .long init_thread_union+THREAD_SIZE-8
23714
23715 __INITRODATA
23716 int_msg:
23717 @@ -722,7 +820,7 @@ fault_msg:
23718 * segment size, and 32-bit linear address value:
23719 */
23720
23721 - .data
23722 +.section .rodata,"a",@progbits
23723 .globl boot_gdt_descr
23724 .globl idt_descr
23725
23726 @@ -731,7 +829,7 @@ fault_msg:
23727 .word 0 # 32 bit align gdt_desc.address
23728 boot_gdt_descr:
23729 .word __BOOT_DS+7
23730 - .long boot_gdt - __PAGE_OFFSET
23731 + .long pa(boot_gdt)
23732
23733 .word 0 # 32-bit align idt_desc.address
23734 idt_descr:
23735 @@ -742,7 +840,7 @@ idt_descr:
23736 .word 0 # 32 bit align gdt_desc.address
23737 ENTRY(early_gdt_descr)
23738 .word GDT_ENTRIES*8-1
23739 - .long gdt_page /* Overwritten for secondary CPUs */
23740 + .long cpu_gdt_table /* Overwritten for secondary CPUs */
23741
23742 /*
23743 * The boot_gdt must mirror the equivalent in setup.S and is
23744 @@ -751,5 +849,65 @@ ENTRY(early_gdt_descr)
23745 .align L1_CACHE_BYTES
23746 ENTRY(boot_gdt)
23747 .fill GDT_ENTRY_BOOT_CS,8,0
23748 - .quad 0x00cf9a000000ffff /* kernel 4GB code at 0x00000000 */
23749 - .quad 0x00cf92000000ffff /* kernel 4GB data at 0x00000000 */
23750 + .quad 0x00cf9b000000ffff /* kernel 4GB code at 0x00000000 */
23751 + .quad 0x00cf93000000ffff /* kernel 4GB data at 0x00000000 */
23752 +
23753 + .align PAGE_SIZE_asm
23754 +ENTRY(cpu_gdt_table)
23755 + .rept NR_CPUS
23756 + .quad 0x0000000000000000 /* NULL descriptor */
23757 + .quad 0x0000000000000000 /* 0x0b reserved */
23758 + .quad 0x0000000000000000 /* 0x13 reserved */
23759 + .quad 0x0000000000000000 /* 0x1b reserved */
23760 +
23761 +#ifdef CONFIG_PAX_KERNEXEC
23762 + .quad 0x00cf9b000000ffff /* 0x20 alternate kernel 4GB code at 0x00000000 */
23763 +#else
23764 + .quad 0x0000000000000000 /* 0x20 unused */
23765 +#endif
23766 +
23767 + .quad 0x0000000000000000 /* 0x28 unused */
23768 + .quad 0x0000000000000000 /* 0x33 TLS entry 1 */
23769 + .quad 0x0000000000000000 /* 0x3b TLS entry 2 */
23770 + .quad 0x0000000000000000 /* 0x43 TLS entry 3 */
23771 + .quad 0x0000000000000000 /* 0x4b reserved */
23772 + .quad 0x0000000000000000 /* 0x53 reserved */
23773 + .quad 0x0000000000000000 /* 0x5b reserved */
23774 +
23775 + .quad 0x00cf9b000000ffff /* 0x60 kernel 4GB code at 0x00000000 */
23776 + .quad 0x00cf93000000ffff /* 0x68 kernel 4GB data at 0x00000000 */
23777 + .quad 0x00cffb000000ffff /* 0x73 user 4GB code at 0x00000000 */
23778 + .quad 0x00cff3000000ffff /* 0x7b user 4GB data at 0x00000000 */
23779 +
23780 + .quad 0x0000000000000000 /* 0x80 TSS descriptor */
23781 + .quad 0x0000000000000000 /* 0x88 LDT descriptor */
23782 +
23783 + /*
23784 + * Segments used for calling PnP BIOS have byte granularity.
23785 + * The code segments and data segments have fixed 64k limits,
23786 + * the transfer segment sizes are set at run time.
23787 + */
23788 + .quad 0x00409b000000ffff /* 0x90 32-bit code */
23789 + .quad 0x00009b000000ffff /* 0x98 16-bit code */
23790 + .quad 0x000093000000ffff /* 0xa0 16-bit data */
23791 + .quad 0x0000930000000000 /* 0xa8 16-bit data */
23792 + .quad 0x0000930000000000 /* 0xb0 16-bit data */
23793 +
23794 + /*
23795 + * The APM segments have byte granularity and their bases
23796 + * are set at run time. All have 64k limits.
23797 + */
23798 + .quad 0x00409b000000ffff /* 0xb8 APM CS code */
23799 + .quad 0x00009b000000ffff /* 0xc0 APM CS 16 code (16 bit) */
23800 + .quad 0x004093000000ffff /* 0xc8 APM DS data */
23801 +
23802 + .quad 0x00c0930000000000 /* 0xd0 - ESPFIX SS */
23803 + .quad 0x0040930000000000 /* 0xd8 - PERCPU */
23804 + .quad 0x0040910000000017 /* 0xe0 - STACK_CANARY */
23805 + .quad 0x0000000000000000 /* 0xe8 - PCIBIOS_CS */
23806 + .quad 0x0000000000000000 /* 0xf0 - PCIBIOS_DS */
23807 + .quad 0x0000000000000000 /* 0xf8 - GDT entry 31: double-fault TSS */
23808 +
23809 + /* Be sure this is zeroed to avoid false validations in Xen */
23810 + .fill PAGE_SIZE_asm - GDT_SIZE,1,0
23811 + .endr
23812 diff --git a/arch/x86/kernel/head_64.S b/arch/x86/kernel/head_64.S
23813 index e1aabdb..fee4fee 100644
23814 --- a/arch/x86/kernel/head_64.S
23815 +++ b/arch/x86/kernel/head_64.S
23816 @@ -20,6 +20,8 @@
23817 #include <asm/processor-flags.h>
23818 #include <asm/percpu.h>
23819 #include <asm/nops.h>
23820 +#include <asm/cpufeature.h>
23821 +#include <asm/alternative-asm.h>
23822
23823 #ifdef CONFIG_PARAVIRT
23824 #include <asm/asm-offsets.h>
23825 @@ -41,6 +43,12 @@ L4_PAGE_OFFSET = pgd_index(__PAGE_OFFSET)
23826 L3_PAGE_OFFSET = pud_index(__PAGE_OFFSET)
23827 L4_START_KERNEL = pgd_index(__START_KERNEL_map)
23828 L3_START_KERNEL = pud_index(__START_KERNEL_map)
23829 +L4_VMALLOC_START = pgd_index(VMALLOC_START)
23830 +L3_VMALLOC_START = pud_index(VMALLOC_START)
23831 +L4_VMALLOC_END = pgd_index(VMALLOC_END)
23832 +L3_VMALLOC_END = pud_index(VMALLOC_END)
23833 +L4_VMEMMAP_START = pgd_index(VMEMMAP_START)
23834 +L3_VMEMMAP_START = pud_index(VMEMMAP_START)
23835
23836 .text
23837 __HEAD
23838 @@ -89,11 +97,24 @@ startup_64:
23839 * Fixup the physical addresses in the page table
23840 */
23841 addq %rbp, early_level4_pgt + (L4_START_KERNEL*8)(%rip)
23842 + addq %rbp, init_level4_pgt + (L4_PAGE_OFFSET*8)(%rip)
23843 + addq %rbp, init_level4_pgt + (L4_VMALLOC_START*8)(%rip)
23844 + addq %rbp, init_level4_pgt + (L4_VMALLOC_END*8)(%rip)
23845 + addq %rbp, init_level4_pgt + (L4_VMEMMAP_START*8)(%rip)
23846 + addq %rbp, init_level4_pgt + (L4_START_KERNEL*8)(%rip)
23847
23848 - addq %rbp, level3_kernel_pgt + (510*8)(%rip)
23849 - addq %rbp, level3_kernel_pgt + (511*8)(%rip)
23850 + addq %rbp, level3_ident_pgt + (0*8)(%rip)
23851 +#ifndef CONFIG_XEN
23852 + addq %rbp, level3_ident_pgt + (1*8)(%rip)
23853 +#endif
23854 +
23855 + addq %rbp, level3_vmemmap_pgt + (L3_VMEMMAP_START*8)(%rip)
23856 +
23857 + addq %rbp, level3_kernel_pgt + (L3_START_KERNEL*8)(%rip)
23858 + addq %rbp, level3_kernel_pgt + ((L3_START_KERNEL+1)*8)(%rip)
23859
23860 addq %rbp, level2_fixmap_pgt + (506*8)(%rip)
23861 + addq %rbp, level2_fixmap_pgt + (507*8)(%rip)
23862
23863 /*
23864 * Set up the identity mapping for the switchover. These
23865 @@ -177,8 +198,8 @@ ENTRY(secondary_startup_64)
23866 movq $(init_level4_pgt - __START_KERNEL_map), %rax
23867 1:
23868
23869 - /* Enable PAE mode and PGE */
23870 - movl $(X86_CR4_PAE | X86_CR4_PGE), %ecx
23871 + /* Enable PAE mode and PSE/PGE */
23872 + movl $(X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE), %ecx
23873 movq %rcx, %cr4
23874
23875 /* Setup early boot stage 4 level pagetables. */
23876 @@ -199,10 +220,19 @@ ENTRY(secondary_startup_64)
23877 movl $MSR_EFER, %ecx
23878 rdmsr
23879 btsl $_EFER_SCE, %eax /* Enable System Call */
23880 - btl $20,%edi /* No Execute supported? */
23881 + btl $(X86_FEATURE_NX & 31),%edi /* No Execute supported? */
23882 jnc 1f
23883 btsl $_EFER_NX, %eax
23884 btsq $_PAGE_BIT_NX,early_pmd_flags(%rip)
23885 +#ifndef CONFIG_EFI
23886 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_PAGE_OFFSET(%rip)
23887 +#endif
23888 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_START(%rip)
23889 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMALLOC_END(%rip)
23890 + btsq $_PAGE_BIT_NX, init_level4_pgt + 8*L4_VMEMMAP_START(%rip)
23891 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*506(%rip)
23892 + btsq $_PAGE_BIT_NX, level2_fixmap_pgt + 8*507(%rip)
23893 + btsq $_PAGE_BIT_NX, __supported_pte_mask(%rip)
23894 1: wrmsr /* Make changes effective */
23895
23896 /* Setup cr0 */
23897 @@ -282,6 +312,7 @@ ENTRY(secondary_startup_64)
23898 * REX.W + FF /5 JMP m16:64 Jump far, absolute indirect,
23899 * address given in m16:64.
23900 */
23901 + pax_set_fptr_mask
23902 movq initial_code(%rip),%rax
23903 pushq $0 # fake return address to stop unwinder
23904 pushq $__KERNEL_CS # set correct cs
23905 @@ -388,7 +419,7 @@ ENTRY(early_idt_handler)
23906 call dump_stack
23907 #ifdef CONFIG_KALLSYMS
23908 leaq early_idt_ripmsg(%rip),%rdi
23909 - movq 40(%rsp),%rsi # %rip again
23910 + movq 88(%rsp),%rsi # %rip again
23911 call __print_symbol
23912 #endif
23913 #endif /* EARLY_PRINTK */
23914 @@ -416,6 +447,7 @@ ENDPROC(early_idt_handler)
23915 early_recursion_flag:
23916 .long 0
23917
23918 + .section .rodata,"a",@progbits
23919 #ifdef CONFIG_EARLY_PRINTK
23920 early_idt_msg:
23921 .asciz "PANIC: early exception %02lx rip %lx:%lx error %lx cr2 %lx\n"
23922 @@ -443,29 +475,52 @@ NEXT_PAGE(early_level4_pgt)
23923 NEXT_PAGE(early_dynamic_pgts)
23924 .fill 512*EARLY_DYNAMIC_PAGE_TABLES,8,0
23925
23926 - .data
23927 + .section .rodata,"a",@progbits
23928
23929 -#ifndef CONFIG_XEN
23930 NEXT_PAGE(init_level4_pgt)
23931 - .fill 512,8,0
23932 -#else
23933 -NEXT_PAGE(init_level4_pgt)
23934 - .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23935 .org init_level4_pgt + L4_PAGE_OFFSET*8, 0
23936 .quad level3_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23937 + .org init_level4_pgt + L4_VMALLOC_START*8, 0
23938 + .quad level3_vmalloc_start_pgt - __START_KERNEL_map + _KERNPG_TABLE
23939 + .org init_level4_pgt + L4_VMALLOC_END*8, 0
23940 + .quad level3_vmalloc_end_pgt - __START_KERNEL_map + _KERNPG_TABLE
23941 + .org init_level4_pgt + L4_VMEMMAP_START*8, 0
23942 + .quad level3_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23943 .org init_level4_pgt + L4_START_KERNEL*8, 0
23944 /* (2^48-(2*1024*1024*1024))/(2^39) = 511 */
23945 .quad level3_kernel_pgt - __START_KERNEL_map + _PAGE_TABLE
23946
23947 +#ifdef CONFIG_PAX_PER_CPU_PGD
23948 +NEXT_PAGE(cpu_pgd)
23949 + .rept 2*NR_CPUS
23950 + .fill 512,8,0
23951 + .endr
23952 +#endif
23953 +
23954 NEXT_PAGE(level3_ident_pgt)
23955 .quad level2_ident_pgt - __START_KERNEL_map + _KERNPG_TABLE
23956 +#ifdef CONFIG_XEN
23957 .fill 511, 8, 0
23958 +#else
23959 + .quad level2_ident_pgt + PAGE_SIZE - __START_KERNEL_map + _KERNPG_TABLE
23960 + .fill 510,8,0
23961 +#endif
23962 +
23963 +NEXT_PAGE(level3_vmalloc_start_pgt)
23964 + .fill 512,8,0
23965 +
23966 +NEXT_PAGE(level3_vmalloc_end_pgt)
23967 + .fill 512,8,0
23968 +
23969 +NEXT_PAGE(level3_vmemmap_pgt)
23970 + .fill L3_VMEMMAP_START,8,0
23971 + .quad level2_vmemmap_pgt - __START_KERNEL_map + _KERNPG_TABLE
23972 +
23973 NEXT_PAGE(level2_ident_pgt)
23974 - /* Since I easily can, map the first 1G.
23975 + /* Since I easily can, map the first 2G.
23976 * Don't set NX because code runs from these pages.
23977 */
23978 - PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, PTRS_PER_PMD)
23979 -#endif
23980 + PMDS(0, __PAGE_KERNEL_IDENT_LARGE_EXEC, 2*PTRS_PER_PMD)
23981
23982 NEXT_PAGE(level3_kernel_pgt)
23983 .fill L3_START_KERNEL,8,0
23984 @@ -473,6 +528,9 @@ NEXT_PAGE(level3_kernel_pgt)
23985 .quad level2_kernel_pgt - __START_KERNEL_map + _KERNPG_TABLE
23986 .quad level2_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23987
23988 +NEXT_PAGE(level2_vmemmap_pgt)
23989 + .fill 512,8,0
23990 +
23991 NEXT_PAGE(level2_kernel_pgt)
23992 /*
23993 * 512 MB kernel mapping. We spend a full page on this pagetable
23994 @@ -490,28 +548,64 @@ NEXT_PAGE(level2_kernel_pgt)
23995 NEXT_PAGE(level2_fixmap_pgt)
23996 .fill 506,8,0
23997 .quad level1_fixmap_pgt - __START_KERNEL_map + _PAGE_TABLE
23998 - /* 8MB reserved for vsyscalls + a 2MB hole = 4 + 1 entries */
23999 - .fill 5,8,0
24000 + .quad level1_vsyscall_pgt - __START_KERNEL_map + _PAGE_TABLE
24001 + /* 6MB reserved for vsyscalls + a 2MB hole = 3 + 1 entries */
24002 + .fill 4,8,0
24003
24004 NEXT_PAGE(level1_fixmap_pgt)
24005 .fill 512,8,0
24006
24007 +NEXT_PAGE(level1_vsyscall_pgt)
24008 + .fill 512,8,0
24009 +
24010 #undef PMDS
24011
24012 - .data
24013 + .align PAGE_SIZE
24014 +ENTRY(cpu_gdt_table)
24015 + .rept NR_CPUS
24016 + .quad 0x0000000000000000 /* NULL descriptor */
24017 + .quad 0x00cf9b000000ffff /* __KERNEL32_CS */
24018 + .quad 0x00af9b000000ffff /* __KERNEL_CS */
24019 + .quad 0x00cf93000000ffff /* __KERNEL_DS */
24020 + .quad 0x00cffb000000ffff /* __USER32_CS */
24021 + .quad 0x00cff3000000ffff /* __USER_DS, __USER32_DS */
24022 + .quad 0x00affb000000ffff /* __USER_CS */
24023 +
24024 +#ifdef CONFIG_PAX_KERNEXEC
24025 + .quad 0x00af9b000000ffff /* __KERNEXEC_KERNEL_CS */
24026 +#else
24027 + .quad 0x0 /* unused */
24028 +#endif
24029 +
24030 + .quad 0,0 /* TSS */
24031 + .quad 0,0 /* LDT */
24032 + .quad 0,0,0 /* three TLS descriptors */
24033 + .quad 0x0000f40000000000 /* node/CPU stored in limit */
24034 + /* asm/segment.h:GDT_ENTRIES must match this */
24035 +
24036 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24037 + .quad 0x00cf93000000ffff /* __UDEREF_KERNEL_DS */
24038 +#else
24039 + .quad 0x0 /* unused */
24040 +#endif
24041 +
24042 + /* zero the remaining page */
24043 + .fill PAGE_SIZE / 8 - GDT_ENTRIES,8,0
24044 + .endr
24045 +
24046 .align 16
24047 .globl early_gdt_descr
24048 early_gdt_descr:
24049 .word GDT_ENTRIES*8-1
24050 early_gdt_descr_base:
24051 - .quad INIT_PER_CPU_VAR(gdt_page)
24052 + .quad cpu_gdt_table
24053
24054 ENTRY(phys_base)
24055 /* This must match the first entry in level2_kernel_pgt */
24056 .quad 0x0000000000000000
24057
24058 #include "../../x86/xen/xen-head.S"
24059 -
24060 - __PAGE_ALIGNED_BSS
24061 +
24062 + .section .rodata,"a",@progbits
24063 NEXT_PAGE(empty_zero_page)
24064 .skip PAGE_SIZE
24065 diff --git a/arch/x86/kernel/i386_ksyms_32.c b/arch/x86/kernel/i386_ksyms_32.c
24066 index 0fa6912..b37438b 100644
24067 --- a/arch/x86/kernel/i386_ksyms_32.c
24068 +++ b/arch/x86/kernel/i386_ksyms_32.c
24069 @@ -20,8 +20,12 @@ extern void cmpxchg8b_emu(void);
24070 EXPORT_SYMBOL(cmpxchg8b_emu);
24071 #endif
24072
24073 +EXPORT_SYMBOL_GPL(cpu_gdt_table);
24074 +
24075 /* Networking helper routines. */
24076 EXPORT_SYMBOL(csum_partial_copy_generic);
24077 +EXPORT_SYMBOL(csum_partial_copy_generic_to_user);
24078 +EXPORT_SYMBOL(csum_partial_copy_generic_from_user);
24079
24080 EXPORT_SYMBOL(__get_user_1);
24081 EXPORT_SYMBOL(__get_user_2);
24082 @@ -37,3 +41,11 @@ EXPORT_SYMBOL(strstr);
24083
24084 EXPORT_SYMBOL(csum_partial);
24085 EXPORT_SYMBOL(empty_zero_page);
24086 +
24087 +#ifdef CONFIG_PAX_KERNEXEC
24088 +EXPORT_SYMBOL(__LOAD_PHYSICAL_ADDR);
24089 +#endif
24090 +
24091 +#ifdef CONFIG_PAX_PER_CPU_PGD
24092 +EXPORT_SYMBOL(cpu_pgd);
24093 +#endif
24094 diff --git a/arch/x86/kernel/i387.c b/arch/x86/kernel/i387.c
24095 index 5d576ab..1403a03 100644
24096 --- a/arch/x86/kernel/i387.c
24097 +++ b/arch/x86/kernel/i387.c
24098 @@ -51,7 +51,7 @@ static inline bool interrupted_kernel_fpu_idle(void)
24099 static inline bool interrupted_user_mode(void)
24100 {
24101 struct pt_regs *regs = get_irq_regs();
24102 - return regs && user_mode_vm(regs);
24103 + return regs && user_mode(regs);
24104 }
24105
24106 /*
24107 diff --git a/arch/x86/kernel/i8259.c b/arch/x86/kernel/i8259.c
24108 index 9a5c460..84868423 100644
24109 --- a/arch/x86/kernel/i8259.c
24110 +++ b/arch/x86/kernel/i8259.c
24111 @@ -110,7 +110,7 @@ static int i8259A_irq_pending(unsigned int irq)
24112 static void make_8259A_irq(unsigned int irq)
24113 {
24114 disable_irq_nosync(irq);
24115 - io_apic_irqs &= ~(1<<irq);
24116 + io_apic_irqs &= ~(1UL<<irq);
24117 irq_set_chip_and_handler_name(irq, &i8259A_chip, handle_level_irq,
24118 i8259A_chip.name);
24119 enable_irq(irq);
24120 @@ -209,7 +209,7 @@ spurious_8259A_irq:
24121 "spurious 8259A interrupt: IRQ%d.\n", irq);
24122 spurious_irq_mask |= irqmask;
24123 }
24124 - atomic_inc(&irq_err_count);
24125 + atomic_inc_unchecked(&irq_err_count);
24126 /*
24127 * Theoretically we do not have to handle this IRQ,
24128 * but in Linux this does not cause problems and is
24129 @@ -333,14 +333,16 @@ static void init_8259A(int auto_eoi)
24130 /* (slave's support for AEOI in flat mode is to be investigated) */
24131 outb_pic(SLAVE_ICW4_DEFAULT, PIC_SLAVE_IMR);
24132
24133 + pax_open_kernel();
24134 if (auto_eoi)
24135 /*
24136 * In AEOI mode we just have to mask the interrupt
24137 * when acking.
24138 */
24139 - i8259A_chip.irq_mask_ack = disable_8259A_irq;
24140 + *(void **)&i8259A_chip.irq_mask_ack = disable_8259A_irq;
24141 else
24142 - i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24143 + *(void **)&i8259A_chip.irq_mask_ack = mask_and_ack_8259A;
24144 + pax_close_kernel();
24145
24146 udelay(100); /* wait for 8259A to initialize */
24147
24148 diff --git a/arch/x86/kernel/io_delay.c b/arch/x86/kernel/io_delay.c
24149 index a979b5b..1d6db75 100644
24150 --- a/arch/x86/kernel/io_delay.c
24151 +++ b/arch/x86/kernel/io_delay.c
24152 @@ -58,7 +58,7 @@ static int __init dmi_io_delay_0xed_port(const struct dmi_system_id *id)
24153 * Quirk table for systems that misbehave (lock up, etc.) if port
24154 * 0x80 is used:
24155 */
24156 -static struct dmi_system_id __initdata io_delay_0xed_port_dmi_table[] = {
24157 +static const struct dmi_system_id __initconst io_delay_0xed_port_dmi_table[] = {
24158 {
24159 .callback = dmi_io_delay_0xed_port,
24160 .ident = "Compaq Presario V6000",
24161 diff --git a/arch/x86/kernel/ioport.c b/arch/x86/kernel/ioport.c
24162 index 4ddaf66..49d5c18 100644
24163 --- a/arch/x86/kernel/ioport.c
24164 +++ b/arch/x86/kernel/ioport.c
24165 @@ -6,6 +6,7 @@
24166 #include <linux/sched.h>
24167 #include <linux/kernel.h>
24168 #include <linux/capability.h>
24169 +#include <linux/security.h>
24170 #include <linux/errno.h>
24171 #include <linux/types.h>
24172 #include <linux/ioport.h>
24173 @@ -30,6 +31,12 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24174 return -EINVAL;
24175 if (turn_on && !capable(CAP_SYS_RAWIO))
24176 return -EPERM;
24177 +#ifdef CONFIG_GRKERNSEC_IO
24178 + if (turn_on && grsec_disable_privio) {
24179 + gr_handle_ioperm();
24180 + return -ENODEV;
24181 + }
24182 +#endif
24183
24184 /*
24185 * If it's the first ioperm() call in this thread's lifetime, set the
24186 @@ -54,7 +61,7 @@ asmlinkage long sys_ioperm(unsigned long from, unsigned long num, int turn_on)
24187 * because the ->io_bitmap_max value must match the bitmap
24188 * contents:
24189 */
24190 - tss = &per_cpu(init_tss, get_cpu());
24191 + tss = init_tss + get_cpu();
24192
24193 if (turn_on)
24194 bitmap_clear(t->io_bitmap_ptr, from, num);
24195 @@ -105,6 +112,12 @@ SYSCALL_DEFINE1(iopl, unsigned int, level)
24196 if (level > old) {
24197 if (!capable(CAP_SYS_RAWIO))
24198 return -EPERM;
24199 +#ifdef CONFIG_GRKERNSEC_IO
24200 + if (grsec_disable_privio) {
24201 + gr_handle_iopl();
24202 + return -ENODEV;
24203 + }
24204 +#endif
24205 }
24206 regs->flags = (regs->flags & ~X86_EFLAGS_IOPL) | (level << 12);
24207 t->iopl = level << 12;
24208 diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c
24209 index 22d0687..e07b2a5 100644
24210 --- a/arch/x86/kernel/irq.c
24211 +++ b/arch/x86/kernel/irq.c
24212 @@ -21,7 +21,7 @@
24213 #define CREATE_TRACE_POINTS
24214 #include <asm/trace/irq_vectors.h>
24215
24216 -atomic_t irq_err_count;
24217 +atomic_unchecked_t irq_err_count;
24218
24219 /* Function pointer for generic interrupt vector handling */
24220 void (*x86_platform_ipi_callback)(void) = NULL;
24221 @@ -125,9 +125,9 @@ int arch_show_interrupts(struct seq_file *p, int prec)
24222 seq_printf(p, "%10u ", per_cpu(mce_poll_count, j));
24223 seq_printf(p, " Machine check polls\n");
24224 #endif
24225 - seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count));
24226 + seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read_unchecked(&irq_err_count));
24227 #if defined(CONFIG_X86_IO_APIC)
24228 - seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count));
24229 + seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read_unchecked(&irq_mis_count));
24230 #endif
24231 return 0;
24232 }
24233 @@ -167,7 +167,7 @@ u64 arch_irq_stat_cpu(unsigned int cpu)
24234
24235 u64 arch_irq_stat(void)
24236 {
24237 - u64 sum = atomic_read(&irq_err_count);
24238 + u64 sum = atomic_read_unchecked(&irq_err_count);
24239 return sum;
24240 }
24241
24242 diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c
24243 index 4186755..784efa0 100644
24244 --- a/arch/x86/kernel/irq_32.c
24245 +++ b/arch/x86/kernel/irq_32.c
24246 @@ -39,7 +39,7 @@ static int check_stack_overflow(void)
24247 __asm__ __volatile__("andl %%esp,%0" :
24248 "=r" (sp) : "0" (THREAD_SIZE - 1));
24249
24250 - return sp < (sizeof(struct thread_info) + STACK_WARN);
24251 + return sp < STACK_WARN;
24252 }
24253
24254 static void print_stack_overflow(void)
24255 @@ -59,8 +59,8 @@ static inline void print_stack_overflow(void) { }
24256 * per-CPU IRQ handling contexts (thread information and stack)
24257 */
24258 union irq_ctx {
24259 - struct thread_info tinfo;
24260 - u32 stack[THREAD_SIZE/sizeof(u32)];
24261 + unsigned long previous_esp;
24262 + u32 stack[THREAD_SIZE/sizeof(u32)];
24263 } __attribute__((aligned(THREAD_SIZE)));
24264
24265 static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx);
24266 @@ -80,10 +80,9 @@ static void call_on_stack(void *func, void *stack)
24267 static inline int
24268 execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24269 {
24270 - union irq_ctx *curctx, *irqctx;
24271 + union irq_ctx *irqctx;
24272 u32 *isp, arg1, arg2;
24273
24274 - curctx = (union irq_ctx *) current_thread_info();
24275 irqctx = __this_cpu_read(hardirq_ctx);
24276
24277 /*
24278 @@ -92,16 +91,16 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24279 * handler) we can't do that and just have to keep using the
24280 * current stack (which is the irq stack already after all)
24281 */
24282 - if (unlikely(curctx == irqctx))
24283 + if (unlikely((void *)current_stack_pointer - (void *)irqctx < THREAD_SIZE))
24284 return 0;
24285
24286 /* build the stack frame on the IRQ stack */
24287 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
24288 - irqctx->tinfo.task = curctx->tinfo.task;
24289 - irqctx->tinfo.previous_esp = current_stack_pointer;
24290 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
24291 + irqctx->previous_esp = current_stack_pointer;
24292
24293 - /* Copy the preempt_count so that the [soft]irq checks work. */
24294 - irqctx->tinfo.preempt_count = curctx->tinfo.preempt_count;
24295 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24296 + __set_fs(MAKE_MM_SEG(0));
24297 +#endif
24298
24299 if (unlikely(overflow))
24300 call_on_stack(print_stack_overflow, isp);
24301 @@ -113,6 +112,11 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24302 : "0" (irq), "1" (desc), "2" (isp),
24303 "D" (desc->handle_irq)
24304 : "memory", "cc", "ecx");
24305 +
24306 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24307 + __set_fs(current_thread_info()->addr_limit);
24308 +#endif
24309 +
24310 return 1;
24311 }
24312
24313 @@ -121,29 +125,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq)
24314 */
24315 void irq_ctx_init(int cpu)
24316 {
24317 - union irq_ctx *irqctx;
24318 -
24319 if (per_cpu(hardirq_ctx, cpu))
24320 return;
24321
24322 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
24323 - THREADINFO_GFP,
24324 - THREAD_SIZE_ORDER));
24325 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
24326 - irqctx->tinfo.cpu = cpu;
24327 - irqctx->tinfo.preempt_count = HARDIRQ_OFFSET;
24328 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
24329 + per_cpu(hardirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
24330 + per_cpu(softirq_ctx, cpu) = page_address(alloc_pages_node(cpu_to_node(cpu), THREADINFO_GFP, THREAD_SIZE_ORDER));
24331
24332 - per_cpu(hardirq_ctx, cpu) = irqctx;
24333 -
24334 - irqctx = page_address(alloc_pages_node(cpu_to_node(cpu),
24335 - THREADINFO_GFP,
24336 - THREAD_SIZE_ORDER));
24337 - memset(&irqctx->tinfo, 0, sizeof(struct thread_info));
24338 - irqctx->tinfo.cpu = cpu;
24339 - irqctx->tinfo.addr_limit = MAKE_MM_SEG(0);
24340 -
24341 - per_cpu(softirq_ctx, cpu) = irqctx;
24342 + printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
24343 + cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
24344
24345 printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n",
24346 cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu));
24347 @@ -152,7 +141,6 @@ void irq_ctx_init(int cpu)
24348 asmlinkage void do_softirq(void)
24349 {
24350 unsigned long flags;
24351 - struct thread_info *curctx;
24352 union irq_ctx *irqctx;
24353 u32 *isp;
24354
24355 @@ -162,15 +150,22 @@ asmlinkage void do_softirq(void)
24356 local_irq_save(flags);
24357
24358 if (local_softirq_pending()) {
24359 - curctx = current_thread_info();
24360 irqctx = __this_cpu_read(softirq_ctx);
24361 - irqctx->tinfo.task = curctx->task;
24362 - irqctx->tinfo.previous_esp = current_stack_pointer;
24363 + irqctx->previous_esp = current_stack_pointer;
24364
24365 /* build the stack frame on the softirq stack */
24366 - isp = (u32 *) ((char *)irqctx + sizeof(*irqctx));
24367 + isp = (u32 *) ((char *)irqctx + sizeof(*irqctx) - 8);
24368 +
24369 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24370 + __set_fs(MAKE_MM_SEG(0));
24371 +#endif
24372
24373 call_on_stack(__do_softirq, isp);
24374 +
24375 +#ifdef CONFIG_PAX_MEMORY_UDEREF
24376 + __set_fs(current_thread_info()->addr_limit);
24377 +#endif
24378 +
24379 /*
24380 * Shouldn't happen, we returned above if in_interrupt():
24381 */
24382 @@ -191,7 +186,7 @@ bool handle_irq(unsigned irq, struct pt_regs *regs)
24383 if (unlikely(!desc))
24384 return false;
24385
24386 - if (user_mode_vm(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
24387 + if (user_mode(regs) || !execute_on_irq_stack(overflow, desc, irq)) {
24388 if (unlikely(overflow))
24389 print_stack_overflow();
24390 desc->handle_irq(irq, desc);
24391 diff --git a/arch/x86/kernel/irq_64.c b/arch/x86/kernel/irq_64.c
24392 index d04d3ec..ea4b374 100644
24393 --- a/arch/x86/kernel/irq_64.c
24394 +++ b/arch/x86/kernel/irq_64.c
24395 @@ -44,7 +44,7 @@ static inline void stack_overflow_check(struct pt_regs *regs)
24396 u64 estack_top, estack_bottom;
24397 u64 curbase = (u64)task_stack_page(current);
24398
24399 - if (user_mode_vm(regs))
24400 + if (user_mode(regs))
24401 return;
24402
24403 if (regs->sp >= curbase + sizeof(struct thread_info) +
24404 diff --git a/arch/x86/kernel/jump_label.c b/arch/x86/kernel/jump_label.c
24405 index ee11b7d..4df4d0c 100644
24406 --- a/arch/x86/kernel/jump_label.c
24407 +++ b/arch/x86/kernel/jump_label.c
24408 @@ -49,7 +49,7 @@ static void __jump_label_transform(struct jump_entry *entry,
24409 * We are enabling this jump label. If it is not a nop
24410 * then something must have gone wrong.
24411 */
24412 - if (unlikely(memcmp((void *)entry->code, ideal_nop, 5) != 0))
24413 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), ideal_nop, 5) != 0))
24414 bug_at((void *)entry->code, __LINE__);
24415
24416 code.jump = 0xe9;
24417 @@ -64,13 +64,13 @@ static void __jump_label_transform(struct jump_entry *entry,
24418 */
24419 if (init) {
24420 const unsigned char default_nop[] = { STATIC_KEY_INIT_NOP };
24421 - if (unlikely(memcmp((void *)entry->code, default_nop, 5) != 0))
24422 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), default_nop, 5) != 0))
24423 bug_at((void *)entry->code, __LINE__);
24424 } else {
24425 code.jump = 0xe9;
24426 code.offset = entry->target -
24427 (entry->code + JUMP_LABEL_NOP_SIZE);
24428 - if (unlikely(memcmp((void *)entry->code, &code, 5) != 0))
24429 + if (unlikely(memcmp((void *)ktla_ktva(entry->code), &code, 5) != 0))
24430 bug_at((void *)entry->code, __LINE__);
24431 }
24432 memcpy(&code, ideal_nops[NOP_ATOMIC5], JUMP_LABEL_NOP_SIZE);
24433 diff --git a/arch/x86/kernel/kgdb.c b/arch/x86/kernel/kgdb.c
24434 index 836f832..a8bda67 100644
24435 --- a/arch/x86/kernel/kgdb.c
24436 +++ b/arch/x86/kernel/kgdb.c
24437 @@ -127,11 +127,11 @@ char *dbg_get_reg(int regno, void *mem, struct pt_regs *regs)
24438 #ifdef CONFIG_X86_32
24439 switch (regno) {
24440 case GDB_SS:
24441 - if (!user_mode_vm(regs))
24442 + if (!user_mode(regs))
24443 *(unsigned long *)mem = __KERNEL_DS;
24444 break;
24445 case GDB_SP:
24446 - if (!user_mode_vm(regs))
24447 + if (!user_mode(regs))
24448 *(unsigned long *)mem = kernel_stack_pointer(regs);
24449 break;
24450 case GDB_GS:
24451 @@ -229,7 +229,10 @@ static void kgdb_correct_hw_break(void)
24452 bp->attr.bp_addr = breakinfo[breakno].addr;
24453 bp->attr.bp_len = breakinfo[breakno].len;
24454 bp->attr.bp_type = breakinfo[breakno].type;
24455 - info->address = breakinfo[breakno].addr;
24456 + if (breakinfo[breakno].type == X86_BREAKPOINT_EXECUTE)
24457 + info->address = ktla_ktva(breakinfo[breakno].addr);
24458 + else
24459 + info->address = breakinfo[breakno].addr;
24460 info->len = breakinfo[breakno].len;
24461 info->type = breakinfo[breakno].type;
24462 val = arch_install_hw_breakpoint(bp);
24463 @@ -476,12 +479,12 @@ int kgdb_arch_handle_exception(int e_vector, int signo, int err_code,
24464 case 'k':
24465 /* clear the trace bit */
24466 linux_regs->flags &= ~X86_EFLAGS_TF;
24467 - atomic_set(&kgdb_cpu_doing_single_step, -1);
24468 + atomic_set_unchecked(&kgdb_cpu_doing_single_step, -1);
24469
24470 /* set the trace bit if we're stepping */
24471 if (remcomInBuffer[0] == 's') {
24472 linux_regs->flags |= X86_EFLAGS_TF;
24473 - atomic_set(&kgdb_cpu_doing_single_step,
24474 + atomic_set_unchecked(&kgdb_cpu_doing_single_step,
24475 raw_smp_processor_id());
24476 }
24477
24478 @@ -546,7 +549,7 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
24479
24480 switch (cmd) {
24481 case DIE_DEBUG:
24482 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
24483 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
24484 if (user_mode(regs))
24485 return single_step_cont(regs, args);
24486 break;
24487 @@ -751,11 +754,11 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24488 #endif /* CONFIG_DEBUG_RODATA */
24489
24490 bpt->type = BP_BREAKPOINT;
24491 - err = probe_kernel_read(bpt->saved_instr, (char *)bpt->bpt_addr,
24492 + err = probe_kernel_read(bpt->saved_instr, ktla_ktva((char *)bpt->bpt_addr),
24493 BREAK_INSTR_SIZE);
24494 if (err)
24495 return err;
24496 - err = probe_kernel_write((char *)bpt->bpt_addr,
24497 + err = probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24498 arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE);
24499 #ifdef CONFIG_DEBUG_RODATA
24500 if (!err)
24501 @@ -768,7 +771,7 @@ int kgdb_arch_set_breakpoint(struct kgdb_bkpt *bpt)
24502 return -EBUSY;
24503 text_poke((void *)bpt->bpt_addr, arch_kgdb_ops.gdb_bpt_instr,
24504 BREAK_INSTR_SIZE);
24505 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24506 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24507 if (err)
24508 return err;
24509 if (memcmp(opc, arch_kgdb_ops.gdb_bpt_instr, BREAK_INSTR_SIZE))
24510 @@ -793,13 +796,13 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt)
24511 if (mutex_is_locked(&text_mutex))
24512 goto knl_write;
24513 text_poke((void *)bpt->bpt_addr, bpt->saved_instr, BREAK_INSTR_SIZE);
24514 - err = probe_kernel_read(opc, (char *)bpt->bpt_addr, BREAK_INSTR_SIZE);
24515 + err = probe_kernel_read(opc, ktla_ktva((char *)bpt->bpt_addr), BREAK_INSTR_SIZE);
24516 if (err || memcmp(opc, bpt->saved_instr, BREAK_INSTR_SIZE))
24517 goto knl_write;
24518 return err;
24519 knl_write:
24520 #endif /* CONFIG_DEBUG_RODATA */
24521 - return probe_kernel_write((char *)bpt->bpt_addr,
24522 + return probe_kernel_write(ktla_ktva((char *)bpt->bpt_addr),
24523 (char *)bpt->saved_instr, BREAK_INSTR_SIZE);
24524 }
24525
24526 diff --git a/arch/x86/kernel/kprobes/core.c b/arch/x86/kernel/kprobes/core.c
24527 index 79a3f96..6ba030a 100644
24528 --- a/arch/x86/kernel/kprobes/core.c
24529 +++ b/arch/x86/kernel/kprobes/core.c
24530 @@ -119,9 +119,12 @@ static void __kprobes __synthesize_relative_insn(void *from, void *to, u8 op)
24531 s32 raddr;
24532 } __packed *insn;
24533
24534 - insn = (struct __arch_relative_insn *)from;
24535 + insn = (struct __arch_relative_insn *)ktla_ktva(from);
24536 +
24537 + pax_open_kernel();
24538 insn->raddr = (s32)((long)(to) - ((long)(from) + 5));
24539 insn->op = op;
24540 + pax_close_kernel();
24541 }
24542
24543 /* Insert a jump instruction at address 'from', which jumps to address 'to'.*/
24544 @@ -164,7 +167,7 @@ int __kprobes can_boost(kprobe_opcode_t *opcodes)
24545 kprobe_opcode_t opcode;
24546 kprobe_opcode_t *orig_opcodes = opcodes;
24547
24548 - if (search_exception_tables((unsigned long)opcodes))
24549 + if (search_exception_tables(ktva_ktla((unsigned long)opcodes)))
24550 return 0; /* Page fault may occur on this address. */
24551
24552 retry:
24553 @@ -238,9 +241,9 @@ __recover_probed_insn(kprobe_opcode_t *buf, unsigned long addr)
24554 * for the first byte, we can recover the original instruction
24555 * from it and kp->opcode.
24556 */
24557 - memcpy(buf, kp->addr, MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24558 + memcpy(buf, ktla_ktva(kp->addr), MAX_INSN_SIZE * sizeof(kprobe_opcode_t));
24559 buf[0] = kp->opcode;
24560 - return (unsigned long)buf;
24561 + return ktva_ktla((unsigned long)buf);
24562 }
24563
24564 /*
24565 @@ -332,7 +335,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24566 /* Another subsystem puts a breakpoint, failed to recover */
24567 if (insn.opcode.bytes[0] == BREAKPOINT_INSTRUCTION)
24568 return 0;
24569 + pax_open_kernel();
24570 memcpy(dest, insn.kaddr, insn.length);
24571 + pax_close_kernel();
24572
24573 #ifdef CONFIG_X86_64
24574 if (insn_rip_relative(&insn)) {
24575 @@ -359,7 +364,9 @@ int __kprobes __copy_instruction(u8 *dest, u8 *src)
24576 return 0;
24577 }
24578 disp = (u8 *) dest + insn_offset_displacement(&insn);
24579 + pax_open_kernel();
24580 *(s32 *) disp = (s32) newdisp;
24581 + pax_close_kernel();
24582 }
24583 #endif
24584 return insn.length;
24585 @@ -498,7 +505,7 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24586 * nor set current_kprobe, because it doesn't use single
24587 * stepping.
24588 */
24589 - regs->ip = (unsigned long)p->ainsn.insn;
24590 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24591 preempt_enable_no_resched();
24592 return;
24593 }
24594 @@ -515,9 +522,9 @@ setup_singlestep(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *k
24595 regs->flags &= ~X86_EFLAGS_IF;
24596 /* single step inline if the instruction is an int3 */
24597 if (p->opcode == BREAKPOINT_INSTRUCTION)
24598 - regs->ip = (unsigned long)p->addr;
24599 + regs->ip = ktla_ktva((unsigned long)p->addr);
24600 else
24601 - regs->ip = (unsigned long)p->ainsn.insn;
24602 + regs->ip = ktva_ktla((unsigned long)p->ainsn.insn);
24603 }
24604
24605 /*
24606 @@ -596,7 +603,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
24607 setup_singlestep(p, regs, kcb, 0);
24608 return 1;
24609 }
24610 - } else if (*addr != BREAKPOINT_INSTRUCTION) {
24611 + } else if (*(kprobe_opcode_t *)ktla_ktva((unsigned long)addr) != BREAKPOINT_INSTRUCTION) {
24612 /*
24613 * The breakpoint instruction was removed right
24614 * after we hit it. Another cpu has removed
24615 @@ -642,6 +649,9 @@ static void __used __kprobes kretprobe_trampoline_holder(void)
24616 " movq %rax, 152(%rsp)\n"
24617 RESTORE_REGS_STRING
24618 " popfq\n"
24619 +#ifdef KERNEXEC_PLUGIN
24620 + " btsq $63,(%rsp)\n"
24621 +#endif
24622 #else
24623 " pushf\n"
24624 SAVE_REGS_STRING
24625 @@ -779,7 +789,7 @@ static void __kprobes
24626 resume_execution(struct kprobe *p, struct pt_regs *regs, struct kprobe_ctlblk *kcb)
24627 {
24628 unsigned long *tos = stack_addr(regs);
24629 - unsigned long copy_ip = (unsigned long)p->ainsn.insn;
24630 + unsigned long copy_ip = ktva_ktla((unsigned long)p->ainsn.insn);
24631 unsigned long orig_ip = (unsigned long)p->addr;
24632 kprobe_opcode_t *insn = p->ainsn.insn;
24633
24634 @@ -961,7 +971,7 @@ kprobe_exceptions_notify(struct notifier_block *self, unsigned long val, void *d
24635 struct die_args *args = data;
24636 int ret = NOTIFY_DONE;
24637
24638 - if (args->regs && user_mode_vm(args->regs))
24639 + if (args->regs && user_mode(args->regs))
24640 return ret;
24641
24642 switch (val) {
24643 diff --git a/arch/x86/kernel/kprobes/opt.c b/arch/x86/kernel/kprobes/opt.c
24644 index 898160b..758cde8 100644
24645 --- a/arch/x86/kernel/kprobes/opt.c
24646 +++ b/arch/x86/kernel/kprobes/opt.c
24647 @@ -79,6 +79,7 @@ found:
24648 /* Insert a move instruction which sets a pointer to eax/rdi (1st arg). */
24649 static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long val)
24650 {
24651 + pax_open_kernel();
24652 #ifdef CONFIG_X86_64
24653 *addr++ = 0x48;
24654 *addr++ = 0xbf;
24655 @@ -86,6 +87,7 @@ static void __kprobes synthesize_set_arg1(kprobe_opcode_t *addr, unsigned long v
24656 *addr++ = 0xb8;
24657 #endif
24658 *(unsigned long *)addr = val;
24659 + pax_close_kernel();
24660 }
24661
24662 asm (
24663 @@ -335,7 +337,7 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24664 * Verify if the address gap is in 2GB range, because this uses
24665 * a relative jump.
24666 */
24667 - rel = (long)op->optinsn.insn - (long)op->kp.addr + RELATIVEJUMP_SIZE;
24668 + rel = (long)op->optinsn.insn - ktla_ktva((long)op->kp.addr) + RELATIVEJUMP_SIZE;
24669 if (abs(rel) > 0x7fffffff)
24670 return -ERANGE;
24671
24672 @@ -350,16 +352,18 @@ int __kprobes arch_prepare_optimized_kprobe(struct optimized_kprobe *op)
24673 op->optinsn.size = ret;
24674
24675 /* Copy arch-dep-instance from template */
24676 - memcpy(buf, &optprobe_template_entry, TMPL_END_IDX);
24677 + pax_open_kernel();
24678 + memcpy(buf, ktla_ktva(&optprobe_template_entry), TMPL_END_IDX);
24679 + pax_close_kernel();
24680
24681 /* Set probe information */
24682 synthesize_set_arg1(buf + TMPL_MOVE_IDX, (unsigned long)op);
24683
24684 /* Set probe function call */
24685 - synthesize_relcall(buf + TMPL_CALL_IDX, optimized_callback);
24686 + synthesize_relcall(ktva_ktla(buf) + TMPL_CALL_IDX, optimized_callback);
24687
24688 /* Set returning jmp instruction at the tail of out-of-line buffer */
24689 - synthesize_reljump(buf + TMPL_END_IDX + op->optinsn.size,
24690 + synthesize_reljump(ktva_ktla(buf) + TMPL_END_IDX + op->optinsn.size,
24691 (u8 *)op->kp.addr + op->optinsn.size);
24692
24693 flush_icache_range((unsigned long) buf,
24694 @@ -384,7 +388,7 @@ void __kprobes arch_optimize_kprobes(struct list_head *oplist)
24695 WARN_ON(kprobe_disabled(&op->kp));
24696
24697 /* Backup instructions which will be replaced by jump address */
24698 - memcpy(op->optinsn.copied_insn, op->kp.addr + INT3_SIZE,
24699 + memcpy(op->optinsn.copied_insn, ktla_ktva(op->kp.addr) + INT3_SIZE,
24700 RELATIVE_ADDR_SIZE);
24701
24702 insn_buf[0] = RELATIVEJUMP_OPCODE;
24703 @@ -433,7 +437,7 @@ setup_detour_execution(struct kprobe *p, struct pt_regs *regs, int reenter)
24704 /* This kprobe is really able to run optimized path. */
24705 op = container_of(p, struct optimized_kprobe, kp);
24706 /* Detour through copied instructions */
24707 - regs->ip = (unsigned long)op->optinsn.insn + TMPL_END_IDX;
24708 + regs->ip = ktva_ktla((unsigned long)op->optinsn.insn) + TMPL_END_IDX;
24709 if (!reenter)
24710 reset_current_kprobe();
24711 preempt_enable_no_resched();
24712 diff --git a/arch/x86/kernel/ldt.c b/arch/x86/kernel/ldt.c
24713 index ebc9873..1b9724b 100644
24714 --- a/arch/x86/kernel/ldt.c
24715 +++ b/arch/x86/kernel/ldt.c
24716 @@ -66,13 +66,13 @@ static int alloc_ldt(mm_context_t *pc, int mincount, int reload)
24717 if (reload) {
24718 #ifdef CONFIG_SMP
24719 preempt_disable();
24720 - load_LDT(pc);
24721 + load_LDT_nolock(pc);
24722 if (!cpumask_equal(mm_cpumask(current->mm),
24723 cpumask_of(smp_processor_id())))
24724 smp_call_function(flush_ldt, current->mm, 1);
24725 preempt_enable();
24726 #else
24727 - load_LDT(pc);
24728 + load_LDT_nolock(pc);
24729 #endif
24730 }
24731 if (oldsize) {
24732 @@ -94,7 +94,7 @@ static inline int copy_ldt(mm_context_t *new, mm_context_t *old)
24733 return err;
24734
24735 for (i = 0; i < old->size; i++)
24736 - write_ldt_entry(new->ldt, i, old->ldt + i * LDT_ENTRY_SIZE);
24737 + write_ldt_entry(new->ldt, i, old->ldt + i);
24738 return 0;
24739 }
24740
24741 @@ -115,6 +115,24 @@ int init_new_context(struct task_struct *tsk, struct mm_struct *mm)
24742 retval = copy_ldt(&mm->context, &old_mm->context);
24743 mutex_unlock(&old_mm->context.lock);
24744 }
24745 +
24746 + if (tsk == current) {
24747 + mm->context.vdso = 0;
24748 +
24749 +#ifdef CONFIG_X86_32
24750 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
24751 + mm->context.user_cs_base = 0UL;
24752 + mm->context.user_cs_limit = ~0UL;
24753 +
24754 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_SMP)
24755 + cpus_clear(mm->context.cpu_user_cs_mask);
24756 +#endif
24757 +
24758 +#endif
24759 +#endif
24760 +
24761 + }
24762 +
24763 return retval;
24764 }
24765
24766 @@ -229,6 +247,13 @@ static int write_ldt(void __user *ptr, unsigned long bytecount, int oldmode)
24767 }
24768 }
24769
24770 +#ifdef CONFIG_PAX_SEGMEXEC
24771 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (ldt_info.contents & MODIFY_LDT_CONTENTS_CODE)) {
24772 + error = -EINVAL;
24773 + goto out_unlock;
24774 + }
24775 +#endif
24776 +
24777 fill_ldt(&ldt, &ldt_info);
24778 if (oldmode)
24779 ldt.avl = 0;
24780 diff --git a/arch/x86/kernel/machine_kexec_32.c b/arch/x86/kernel/machine_kexec_32.c
24781 index 5b19e4d..6476a76 100644
24782 --- a/arch/x86/kernel/machine_kexec_32.c
24783 +++ b/arch/x86/kernel/machine_kexec_32.c
24784 @@ -26,7 +26,7 @@
24785 #include <asm/cacheflush.h>
24786 #include <asm/debugreg.h>
24787
24788 -static void set_idt(void *newidt, __u16 limit)
24789 +static void set_idt(struct desc_struct *newidt, __u16 limit)
24790 {
24791 struct desc_ptr curidt;
24792
24793 @@ -38,7 +38,7 @@ static void set_idt(void *newidt, __u16 limit)
24794 }
24795
24796
24797 -static void set_gdt(void *newgdt, __u16 limit)
24798 +static void set_gdt(struct desc_struct *newgdt, __u16 limit)
24799 {
24800 struct desc_ptr curgdt;
24801
24802 @@ -216,7 +216,7 @@ void machine_kexec(struct kimage *image)
24803 }
24804
24805 control_page = page_address(image->control_code_page);
24806 - memcpy(control_page, relocate_kernel, KEXEC_CONTROL_CODE_MAX_SIZE);
24807 + memcpy(control_page, (void *)ktla_ktva((unsigned long)relocate_kernel), KEXEC_CONTROL_CODE_MAX_SIZE);
24808
24809 relocate_kernel_ptr = control_page;
24810 page_list[PA_CONTROL_PAGE] = __pa(control_page);
24811 diff --git a/arch/x86/kernel/microcode_core.c b/arch/x86/kernel/microcode_core.c
24812 index 15c9876..0a43909 100644
24813 --- a/arch/x86/kernel/microcode_core.c
24814 +++ b/arch/x86/kernel/microcode_core.c
24815 @@ -513,7 +513,7 @@ mc_cpu_callback(struct notifier_block *nb, unsigned long action, void *hcpu)
24816 return NOTIFY_OK;
24817 }
24818
24819 -static struct notifier_block __refdata mc_cpu_notifier = {
24820 +static struct notifier_block mc_cpu_notifier = {
24821 .notifier_call = mc_cpu_callback,
24822 };
24823
24824 diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
24825 index 5fb2ceb..3ae90bb 100644
24826 --- a/arch/x86/kernel/microcode_intel.c
24827 +++ b/arch/x86/kernel/microcode_intel.c
24828 @@ -293,13 +293,13 @@ static enum ucode_state request_microcode_fw(int cpu, struct device *device,
24829
24830 static int get_ucode_user(void *to, const void *from, size_t n)
24831 {
24832 - return copy_from_user(to, from, n);
24833 + return copy_from_user(to, (const void __force_user *)from, n);
24834 }
24835
24836 static enum ucode_state
24837 request_microcode_user(int cpu, const void __user *buf, size_t size)
24838 {
24839 - return generic_load_microcode(cpu, (void *)buf, size, &get_ucode_user);
24840 + return generic_load_microcode(cpu, (__force_kernel void *)buf, size, &get_ucode_user);
24841 }
24842
24843 static void microcode_fini_cpu(int cpu)
24844 diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
24845 index 216a4d7..228255a 100644
24846 --- a/arch/x86/kernel/module.c
24847 +++ b/arch/x86/kernel/module.c
24848 @@ -43,15 +43,60 @@ do { \
24849 } while (0)
24850 #endif
24851
24852 -void *module_alloc(unsigned long size)
24853 +static inline void *__module_alloc(unsigned long size, pgprot_t prot)
24854 {
24855 - if (PAGE_ALIGN(size) > MODULES_LEN)
24856 + if (!size || PAGE_ALIGN(size) > MODULES_LEN)
24857 return NULL;
24858 return __vmalloc_node_range(size, 1, MODULES_VADDR, MODULES_END,
24859 - GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
24860 + GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, prot,
24861 -1, __builtin_return_address(0));
24862 }
24863
24864 +void *module_alloc(unsigned long size)
24865 +{
24866 +
24867 +#ifdef CONFIG_PAX_KERNEXEC
24868 + return __module_alloc(size, PAGE_KERNEL);
24869 +#else
24870 + return __module_alloc(size, PAGE_KERNEL_EXEC);
24871 +#endif
24872 +
24873 +}
24874 +
24875 +#ifdef CONFIG_PAX_KERNEXEC
24876 +#ifdef CONFIG_X86_32
24877 +void *module_alloc_exec(unsigned long size)
24878 +{
24879 + struct vm_struct *area;
24880 +
24881 + if (size == 0)
24882 + return NULL;
24883 +
24884 + area = __get_vm_area(size, VM_ALLOC, (unsigned long)&MODULES_EXEC_VADDR, (unsigned long)&MODULES_EXEC_END);
24885 + return area ? area->addr : NULL;
24886 +}
24887 +EXPORT_SYMBOL(module_alloc_exec);
24888 +
24889 +void module_free_exec(struct module *mod, void *module_region)
24890 +{
24891 + vunmap(module_region);
24892 +}
24893 +EXPORT_SYMBOL(module_free_exec);
24894 +#else
24895 +void module_free_exec(struct module *mod, void *module_region)
24896 +{
24897 + module_free(mod, module_region);
24898 +}
24899 +EXPORT_SYMBOL(module_free_exec);
24900 +
24901 +void *module_alloc_exec(unsigned long size)
24902 +{
24903 + return __module_alloc(size, PAGE_KERNEL_RX);
24904 +}
24905 +EXPORT_SYMBOL(module_alloc_exec);
24906 +#endif
24907 +#endif
24908 +
24909 #ifdef CONFIG_X86_32
24910 int apply_relocate(Elf32_Shdr *sechdrs,
24911 const char *strtab,
24912 @@ -62,14 +107,16 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24913 unsigned int i;
24914 Elf32_Rel *rel = (void *)sechdrs[relsec].sh_addr;
24915 Elf32_Sym *sym;
24916 - uint32_t *location;
24917 + uint32_t *plocation, location;
24918
24919 DEBUGP("Applying relocate section %u to %u\n",
24920 relsec, sechdrs[relsec].sh_info);
24921 for (i = 0; i < sechdrs[relsec].sh_size / sizeof(*rel); i++) {
24922 /* This is where to make the change */
24923 - location = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr
24924 - + rel[i].r_offset;
24925 + plocation = (void *)sechdrs[sechdrs[relsec].sh_info].sh_addr + rel[i].r_offset;
24926 + location = (uint32_t)plocation;
24927 + if (sechdrs[sechdrs[relsec].sh_info].sh_flags & SHF_EXECINSTR)
24928 + plocation = ktla_ktva((void *)plocation);
24929 /* This is the symbol it is referring to. Note that all
24930 undefined symbols have been resolved. */
24931 sym = (Elf32_Sym *)sechdrs[symindex].sh_addr
24932 @@ -78,11 +125,15 @@ int apply_relocate(Elf32_Shdr *sechdrs,
24933 switch (ELF32_R_TYPE(rel[i].r_info)) {
24934 case R_386_32:
24935 /* We add the value into the location given */
24936 - *location += sym->st_value;
24937 + pax_open_kernel();
24938 + *plocation += sym->st_value;
24939 + pax_close_kernel();
24940 break;
24941 case R_386_PC32:
24942 /* Add the value, subtract its position */
24943 - *location += sym->st_value - (uint32_t)location;
24944 + pax_open_kernel();
24945 + *plocation += sym->st_value - location;
24946 + pax_close_kernel();
24947 break;
24948 default:
24949 pr_err("%s: Unknown relocation: %u\n",
24950 @@ -127,21 +178,30 @@ int apply_relocate_add(Elf64_Shdr *sechdrs,
24951 case R_X86_64_NONE:
24952 break;
24953 case R_X86_64_64:
24954 + pax_open_kernel();
24955 *(u64 *)loc = val;
24956 + pax_close_kernel();
24957 break;
24958 case R_X86_64_32:
24959 + pax_open_kernel();
24960 *(u32 *)loc = val;
24961 + pax_close_kernel();
24962 if (val != *(u32 *)loc)
24963 goto overflow;
24964 break;
24965 case R_X86_64_32S:
24966 + pax_open_kernel();
24967 *(s32 *)loc = val;
24968 + pax_close_kernel();
24969 if ((s64)val != *(s32 *)loc)
24970 goto overflow;
24971 break;
24972 case R_X86_64_PC32:
24973 val -= (u64)loc;
24974 + pax_open_kernel();
24975 *(u32 *)loc = val;
24976 + pax_close_kernel();
24977 +
24978 #if 0
24979 if ((s64)val != *(s32 *)loc)
24980 goto overflow;
24981 diff --git a/arch/x86/kernel/msr.c b/arch/x86/kernel/msr.c
24982 index 88458fa..349f7a4 100644
24983 --- a/arch/x86/kernel/msr.c
24984 +++ b/arch/x86/kernel/msr.c
24985 @@ -233,7 +233,7 @@ static int msr_class_cpu_callback(struct notifier_block *nfb,
24986 return notifier_from_errno(err);
24987 }
24988
24989 -static struct notifier_block __refdata msr_class_cpu_notifier = {
24990 +static struct notifier_block msr_class_cpu_notifier = {
24991 .notifier_call = msr_class_cpu_callback,
24992 };
24993
24994 diff --git a/arch/x86/kernel/nmi.c b/arch/x86/kernel/nmi.c
24995 index 6fcb49c..5b3f4ff 100644
24996 --- a/arch/x86/kernel/nmi.c
24997 +++ b/arch/x86/kernel/nmi.c
24998 @@ -138,7 +138,7 @@ static int __kprobes nmi_handle(unsigned int type, struct pt_regs *regs, bool b2
24999 return handled;
25000 }
25001
25002 -int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25003 +int __register_nmi_handler(unsigned int type, const struct nmiaction *action)
25004 {
25005 struct nmi_desc *desc = nmi_to_desc(type);
25006 unsigned long flags;
25007 @@ -162,9 +162,9 @@ int __register_nmi_handler(unsigned int type, struct nmiaction *action)
25008 * event confuses some handlers (kdump uses this flag)
25009 */
25010 if (action->flags & NMI_FLAG_FIRST)
25011 - list_add_rcu(&action->list, &desc->head);
25012 + pax_list_add_rcu((struct list_head *)&action->list, &desc->head);
25013 else
25014 - list_add_tail_rcu(&action->list, &desc->head);
25015 + pax_list_add_tail_rcu((struct list_head *)&action->list, &desc->head);
25016
25017 spin_unlock_irqrestore(&desc->lock, flags);
25018 return 0;
25019 @@ -187,7 +187,7 @@ void unregister_nmi_handler(unsigned int type, const char *name)
25020 if (!strcmp(n->name, name)) {
25021 WARN(in_nmi(),
25022 "Trying to free NMI (%s) from NMI context!\n", n->name);
25023 - list_del_rcu(&n->list);
25024 + pax_list_del_rcu((struct list_head *)&n->list);
25025 break;
25026 }
25027 }
25028 @@ -512,6 +512,17 @@ static inline void nmi_nesting_postprocess(void)
25029 dotraplinkage notrace __kprobes void
25030 do_nmi(struct pt_regs *regs, long error_code)
25031 {
25032 +
25033 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
25034 + if (!user_mode(regs)) {
25035 + unsigned long cs = regs->cs & 0xFFFF;
25036 + unsigned long ip = ktva_ktla(regs->ip);
25037 +
25038 + if ((cs == __KERNEL_CS || cs == __KERNEXEC_KERNEL_CS) && ip <= (unsigned long)_etext)
25039 + regs->ip = ip;
25040 + }
25041 +#endif
25042 +
25043 nmi_nesting_preprocess(regs);
25044
25045 nmi_enter();
25046 diff --git a/arch/x86/kernel/nmi_selftest.c b/arch/x86/kernel/nmi_selftest.c
25047 index 6d9582e..f746287 100644
25048 --- a/arch/x86/kernel/nmi_selftest.c
25049 +++ b/arch/x86/kernel/nmi_selftest.c
25050 @@ -43,7 +43,7 @@ static void __init init_nmi_testsuite(void)
25051 {
25052 /* trap all the unknown NMIs we may generate */
25053 register_nmi_handler(NMI_UNKNOWN, nmi_unk_cb, 0, "nmi_selftest_unk",
25054 - __initdata);
25055 + __initconst);
25056 }
25057
25058 static void __init cleanup_nmi_testsuite(void)
25059 @@ -66,7 +66,7 @@ static void __init test_nmi_ipi(struct cpumask *mask)
25060 unsigned long timeout;
25061
25062 if (register_nmi_handler(NMI_LOCAL, test_nmi_ipi_callback,
25063 - NMI_FLAG_FIRST, "nmi_selftest", __initdata)) {
25064 + NMI_FLAG_FIRST, "nmi_selftest", __initconst)) {
25065 nmi_fail = FAILURE;
25066 return;
25067 }
25068 diff --git a/arch/x86/kernel/paravirt-spinlocks.c b/arch/x86/kernel/paravirt-spinlocks.c
25069 index bbb6c73..24a58ef 100644
25070 --- a/arch/x86/kernel/paravirt-spinlocks.c
25071 +++ b/arch/x86/kernel/paravirt-spinlocks.c
25072 @@ -8,7 +8,7 @@
25073
25074 #include <asm/paravirt.h>
25075
25076 -struct pv_lock_ops pv_lock_ops = {
25077 +struct pv_lock_ops pv_lock_ops __read_only = {
25078 #ifdef CONFIG_SMP
25079 .lock_spinning = __PV_IS_CALLEE_SAVE(paravirt_nop),
25080 .unlock_kick = paravirt_nop,
25081 diff --git a/arch/x86/kernel/paravirt.c b/arch/x86/kernel/paravirt.c
25082 index 1b10af8..0b58cbc 100644
25083 --- a/arch/x86/kernel/paravirt.c
25084 +++ b/arch/x86/kernel/paravirt.c
25085 @@ -55,6 +55,9 @@ u64 _paravirt_ident_64(u64 x)
25086 {
25087 return x;
25088 }
25089 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25090 +PV_CALLEE_SAVE_REGS_THUNK(_paravirt_ident_64);
25091 +#endif
25092
25093 void __init default_banner(void)
25094 {
25095 @@ -142,15 +145,19 @@ unsigned paravirt_patch_default(u8 type, u16 clobbers, void *insnbuf,
25096 if (opfunc == NULL)
25097 /* If there's no function, patch it with a ud2a (BUG) */
25098 ret = paravirt_patch_insns(insnbuf, len, ud2a, ud2a+sizeof(ud2a));
25099 - else if (opfunc == _paravirt_nop)
25100 + else if (opfunc == (void *)_paravirt_nop)
25101 /* If the operation is a nop, then nop the callsite */
25102 ret = paravirt_patch_nop();
25103
25104 /* identity functions just return their single argument */
25105 - else if (opfunc == _paravirt_ident_32)
25106 + else if (opfunc == (void *)_paravirt_ident_32)
25107 ret = paravirt_patch_ident_32(insnbuf, len);
25108 - else if (opfunc == _paravirt_ident_64)
25109 + else if (opfunc == (void *)_paravirt_ident_64)
25110 ret = paravirt_patch_ident_64(insnbuf, len);
25111 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
25112 + else if (opfunc == (void *)__raw_callee_save__paravirt_ident_64)
25113 + ret = paravirt_patch_ident_64(insnbuf, len);
25114 +#endif
25115
25116 else if (type == PARAVIRT_PATCH(pv_cpu_ops.iret) ||
25117 type == PARAVIRT_PATCH(pv_cpu_ops.irq_enable_sysexit) ||
25118 @@ -175,7 +182,7 @@ unsigned paravirt_patch_insns(void *insnbuf, unsigned len,
25119 if (insn_len > len || start == NULL)
25120 insn_len = len;
25121 else
25122 - memcpy(insnbuf, start, insn_len);
25123 + memcpy(insnbuf, ktla_ktva(start), insn_len);
25124
25125 return insn_len;
25126 }
25127 @@ -299,7 +306,7 @@ enum paravirt_lazy_mode paravirt_get_lazy_mode(void)
25128 return this_cpu_read(paravirt_lazy_mode);
25129 }
25130
25131 -struct pv_info pv_info = {
25132 +struct pv_info pv_info __read_only = {
25133 .name = "bare hardware",
25134 .paravirt_enabled = 0,
25135 .kernel_rpl = 0,
25136 @@ -310,16 +317,16 @@ struct pv_info pv_info = {
25137 #endif
25138 };
25139
25140 -struct pv_init_ops pv_init_ops = {
25141 +struct pv_init_ops pv_init_ops __read_only = {
25142 .patch = native_patch,
25143 };
25144
25145 -struct pv_time_ops pv_time_ops = {
25146 +struct pv_time_ops pv_time_ops __read_only = {
25147 .sched_clock = native_sched_clock,
25148 .steal_clock = native_steal_clock,
25149 };
25150
25151 -__visible struct pv_irq_ops pv_irq_ops = {
25152 +__visible struct pv_irq_ops pv_irq_ops __read_only = {
25153 .save_fl = __PV_IS_CALLEE_SAVE(native_save_fl),
25154 .restore_fl = __PV_IS_CALLEE_SAVE(native_restore_fl),
25155 .irq_disable = __PV_IS_CALLEE_SAVE(native_irq_disable),
25156 @@ -331,7 +338,7 @@ __visible struct pv_irq_ops pv_irq_ops = {
25157 #endif
25158 };
25159
25160 -__visible struct pv_cpu_ops pv_cpu_ops = {
25161 +__visible struct pv_cpu_ops pv_cpu_ops __read_only = {
25162 .cpuid = native_cpuid,
25163 .get_debugreg = native_get_debugreg,
25164 .set_debugreg = native_set_debugreg,
25165 @@ -389,21 +396,26 @@ __visible struct pv_cpu_ops pv_cpu_ops = {
25166 .end_context_switch = paravirt_nop,
25167 };
25168
25169 -struct pv_apic_ops pv_apic_ops = {
25170 +struct pv_apic_ops pv_apic_ops __read_only= {
25171 #ifdef CONFIG_X86_LOCAL_APIC
25172 .startup_ipi_hook = paravirt_nop,
25173 #endif
25174 };
25175
25176 -#if defined(CONFIG_X86_32) && !defined(CONFIG_X86_PAE)
25177 +#ifdef CONFIG_X86_32
25178 +#ifdef CONFIG_X86_PAE
25179 +/* 64-bit pagetable entries */
25180 +#define PTE_IDENT PV_CALLEE_SAVE(_paravirt_ident_64)
25181 +#else
25182 /* 32-bit pagetable entries */
25183 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_32)
25184 +#endif
25185 #else
25186 /* 64-bit pagetable entries */
25187 #define PTE_IDENT __PV_IS_CALLEE_SAVE(_paravirt_ident_64)
25188 #endif
25189
25190 -struct pv_mmu_ops pv_mmu_ops = {
25191 +struct pv_mmu_ops pv_mmu_ops __read_only = {
25192
25193 .read_cr2 = native_read_cr2,
25194 .write_cr2 = native_write_cr2,
25195 @@ -453,6 +465,7 @@ struct pv_mmu_ops pv_mmu_ops = {
25196 .make_pud = PTE_IDENT,
25197
25198 .set_pgd = native_set_pgd,
25199 + .set_pgd_batched = native_set_pgd_batched,
25200 #endif
25201 #endif /* PAGETABLE_LEVELS >= 3 */
25202
25203 @@ -473,6 +486,12 @@ struct pv_mmu_ops pv_mmu_ops = {
25204 },
25205
25206 .set_fixmap = native_set_fixmap,
25207 +
25208 +#ifdef CONFIG_PAX_KERNEXEC
25209 + .pax_open_kernel = native_pax_open_kernel,
25210 + .pax_close_kernel = native_pax_close_kernel,
25211 +#endif
25212 +
25213 };
25214
25215 EXPORT_SYMBOL_GPL(pv_time_ops);
25216 diff --git a/arch/x86/kernel/pci-calgary_64.c b/arch/x86/kernel/pci-calgary_64.c
25217 index 299d493..2ccb0ee 100644
25218 --- a/arch/x86/kernel/pci-calgary_64.c
25219 +++ b/arch/x86/kernel/pci-calgary_64.c
25220 @@ -1339,7 +1339,7 @@ static void __init get_tce_space_from_tar(void)
25221 tce_space = be64_to_cpu(readq(target));
25222 tce_space = tce_space & TAR_SW_BITS;
25223
25224 - tce_space = tce_space & (~specified_table_size);
25225 + tce_space = tce_space & (~(unsigned long)specified_table_size);
25226 info->tce_space = (u64 *)__va(tce_space);
25227 }
25228 }
25229 diff --git a/arch/x86/kernel/pci-iommu_table.c b/arch/x86/kernel/pci-iommu_table.c
25230 index 35ccf75..7a15747 100644
25231 --- a/arch/x86/kernel/pci-iommu_table.c
25232 +++ b/arch/x86/kernel/pci-iommu_table.c
25233 @@ -2,7 +2,7 @@
25234 #include <asm/iommu_table.h>
25235 #include <linux/string.h>
25236 #include <linux/kallsyms.h>
25237 -
25238 +#include <linux/sched.h>
25239
25240 #define DEBUG 1
25241
25242 diff --git a/arch/x86/kernel/pci-swiotlb.c b/arch/x86/kernel/pci-swiotlb.c
25243 index 6c483ba..d10ce2f 100644
25244 --- a/arch/x86/kernel/pci-swiotlb.c
25245 +++ b/arch/x86/kernel/pci-swiotlb.c
25246 @@ -32,7 +32,7 @@ static void x86_swiotlb_free_coherent(struct device *dev, size_t size,
25247 void *vaddr, dma_addr_t dma_addr,
25248 struct dma_attrs *attrs)
25249 {
25250 - swiotlb_free_coherent(dev, size, vaddr, dma_addr);
25251 + swiotlb_free_coherent(dev, size, vaddr, dma_addr, attrs);
25252 }
25253
25254 static struct dma_map_ops swiotlb_dma_ops = {
25255 diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
25256 index 3fb8d95..254dc51 100644
25257 --- a/arch/x86/kernel/process.c
25258 +++ b/arch/x86/kernel/process.c
25259 @@ -36,7 +36,8 @@
25260 * section. Since TSS's are completely CPU-local, we want them
25261 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
25262 */
25263 -__visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, init_tss) = INIT_TSS;
25264 +struct tss_struct init_tss[NR_CPUS] __visible ____cacheline_internodealigned_in_smp = { [0 ... NR_CPUS-1] = INIT_TSS };
25265 +EXPORT_SYMBOL(init_tss);
25266
25267 #ifdef CONFIG_X86_64
25268 static DEFINE_PER_CPU(unsigned char, is_idle);
25269 @@ -92,7 +93,7 @@ void arch_task_cache_init(void)
25270 task_xstate_cachep =
25271 kmem_cache_create("task_xstate", xstate_size,
25272 __alignof__(union thread_xstate),
25273 - SLAB_PANIC | SLAB_NOTRACK, NULL);
25274 + SLAB_PANIC | SLAB_NOTRACK | SLAB_USERCOPY, NULL);
25275 }
25276
25277 /*
25278 @@ -105,7 +106,7 @@ void exit_thread(void)
25279 unsigned long *bp = t->io_bitmap_ptr;
25280
25281 if (bp) {
25282 - struct tss_struct *tss = &per_cpu(init_tss, get_cpu());
25283 + struct tss_struct *tss = init_tss + get_cpu();
25284
25285 t->io_bitmap_ptr = NULL;
25286 clear_thread_flag(TIF_IO_BITMAP);
25287 @@ -125,6 +126,9 @@ void flush_thread(void)
25288 {
25289 struct task_struct *tsk = current;
25290
25291 +#if defined(CONFIG_X86_32) && !defined(CONFIG_CC_STACKPROTECTOR) && !defined(CONFIG_PAX_MEMORY_UDEREF)
25292 + loadsegment(gs, 0);
25293 +#endif
25294 flush_ptrace_hw_breakpoint(tsk);
25295 memset(tsk->thread.tls_array, 0, sizeof(tsk->thread.tls_array));
25296 drop_init_fpu(tsk);
25297 @@ -271,7 +275,7 @@ static void __exit_idle(void)
25298 void exit_idle(void)
25299 {
25300 /* idle loop has pid 0 */
25301 - if (current->pid)
25302 + if (task_pid_nr(current))
25303 return;
25304 __exit_idle();
25305 }
25306 @@ -327,7 +331,7 @@ bool xen_set_default_idle(void)
25307 return ret;
25308 }
25309 #endif
25310 -void stop_this_cpu(void *dummy)
25311 +__noreturn void stop_this_cpu(void *dummy)
25312 {
25313 local_irq_disable();
25314 /*
25315 @@ -456,16 +460,37 @@ static int __init idle_setup(char *str)
25316 }
25317 early_param("idle", idle_setup);
25318
25319 -unsigned long arch_align_stack(unsigned long sp)
25320 +#ifdef CONFIG_PAX_RANDKSTACK
25321 +void pax_randomize_kstack(struct pt_regs *regs)
25322 {
25323 - if (!(current->personality & ADDR_NO_RANDOMIZE) && randomize_va_space)
25324 - sp -= get_random_int() % 8192;
25325 - return sp & ~0xf;
25326 -}
25327 + struct thread_struct *thread = &current->thread;
25328 + unsigned long time;
25329
25330 -unsigned long arch_randomize_brk(struct mm_struct *mm)
25331 -{
25332 - unsigned long range_end = mm->brk + 0x02000000;
25333 - return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
25334 -}
25335 + if (!randomize_va_space)
25336 + return;
25337 +
25338 + if (v8086_mode(regs))
25339 + return;
25340
25341 + rdtscl(time);
25342 +
25343 + /* P4 seems to return a 0 LSB, ignore it */
25344 +#ifdef CONFIG_MPENTIUM4
25345 + time &= 0x3EUL;
25346 + time <<= 2;
25347 +#elif defined(CONFIG_X86_64)
25348 + time &= 0xFUL;
25349 + time <<= 4;
25350 +#else
25351 + time &= 0x1FUL;
25352 + time <<= 3;
25353 +#endif
25354 +
25355 + thread->sp0 ^= time;
25356 + load_sp0(init_tss + smp_processor_id(), thread);
25357 +
25358 +#ifdef CONFIG_X86_64
25359 + this_cpu_write(kernel_stack, thread->sp0);
25360 +#endif
25361 +}
25362 +#endif
25363 diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
25364 index 884f98f..ec23e04 100644
25365 --- a/arch/x86/kernel/process_32.c
25366 +++ b/arch/x86/kernel/process_32.c
25367 @@ -65,6 +65,7 @@ asmlinkage void ret_from_kernel_thread(void) __asm__("ret_from_kernel_thread");
25368 unsigned long thread_saved_pc(struct task_struct *tsk)
25369 {
25370 return ((unsigned long *)tsk->thread.sp)[3];
25371 +//XXX return tsk->thread.eip;
25372 }
25373
25374 void __show_regs(struct pt_regs *regs, int all)
25375 @@ -74,19 +75,18 @@ void __show_regs(struct pt_regs *regs, int all)
25376 unsigned long sp;
25377 unsigned short ss, gs;
25378
25379 - if (user_mode_vm(regs)) {
25380 + if (user_mode(regs)) {
25381 sp = regs->sp;
25382 ss = regs->ss & 0xffff;
25383 - gs = get_user_gs(regs);
25384 } else {
25385 sp = kernel_stack_pointer(regs);
25386 savesegment(ss, ss);
25387 - savesegment(gs, gs);
25388 }
25389 + gs = get_user_gs(regs);
25390
25391 printk(KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n",
25392 (u16)regs->cs, regs->ip, regs->flags,
25393 - smp_processor_id());
25394 + raw_smp_processor_id());
25395 print_symbol("EIP is at %s\n", regs->ip);
25396
25397 printk(KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
25398 @@ -133,20 +133,21 @@ void release_thread(struct task_struct *dead_task)
25399 int copy_thread(unsigned long clone_flags, unsigned long sp,
25400 unsigned long arg, struct task_struct *p)
25401 {
25402 - struct pt_regs *childregs = task_pt_regs(p);
25403 + struct pt_regs *childregs = task_stack_page(p) + THREAD_SIZE - sizeof(struct pt_regs) - 8;
25404 struct task_struct *tsk;
25405 int err;
25406
25407 p->thread.sp = (unsigned long) childregs;
25408 p->thread.sp0 = (unsigned long) (childregs+1);
25409 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25410
25411 if (unlikely(p->flags & PF_KTHREAD)) {
25412 /* kernel thread */
25413 memset(childregs, 0, sizeof(struct pt_regs));
25414 p->thread.ip = (unsigned long) ret_from_kernel_thread;
25415 - task_user_gs(p) = __KERNEL_STACK_CANARY;
25416 - childregs->ds = __USER_DS;
25417 - childregs->es = __USER_DS;
25418 + savesegment(gs, childregs->gs);
25419 + childregs->ds = __KERNEL_DS;
25420 + childregs->es = __KERNEL_DS;
25421 childregs->fs = __KERNEL_PERCPU;
25422 childregs->bx = sp; /* function */
25423 childregs->bp = arg;
25424 @@ -253,7 +254,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25425 struct thread_struct *prev = &prev_p->thread,
25426 *next = &next_p->thread;
25427 int cpu = smp_processor_id();
25428 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25429 + struct tss_struct *tss = init_tss + cpu;
25430 fpu_switch_t fpu;
25431
25432 /* never put a printk in __switch_to... printk() calls wake_up*() indirectly */
25433 @@ -277,6 +278,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25434 */
25435 lazy_save_gs(prev->gs);
25436
25437 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25438 + __set_fs(task_thread_info(next_p)->addr_limit);
25439 +#endif
25440 +
25441 /*
25442 * Load the per-thread Thread-Local Storage descriptor.
25443 */
25444 @@ -307,6 +312,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25445 */
25446 arch_end_context_switch(next_p);
25447
25448 + this_cpu_write(current_task, next_p);
25449 + this_cpu_write(current_tinfo, &next_p->tinfo);
25450 +
25451 /*
25452 * Restore %gs if needed (which is common)
25453 */
25454 @@ -315,8 +323,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25455
25456 switch_fpu_finish(next_p, fpu);
25457
25458 - this_cpu_write(current_task, next_p);
25459 -
25460 return prev_p;
25461 }
25462
25463 @@ -346,4 +352,3 @@ unsigned long get_wchan(struct task_struct *p)
25464 } while (count++ < 16);
25465 return 0;
25466 }
25467 -
25468 diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
25469 index bb1dc51..08dda7f 100644
25470 --- a/arch/x86/kernel/process_64.c
25471 +++ b/arch/x86/kernel/process_64.c
25472 @@ -158,10 +158,11 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25473 struct pt_regs *childregs;
25474 struct task_struct *me = current;
25475
25476 - p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE;
25477 + p->thread.sp0 = (unsigned long)task_stack_page(p) + THREAD_SIZE - 16;
25478 childregs = task_pt_regs(p);
25479 p->thread.sp = (unsigned long) childregs;
25480 p->thread.usersp = me->thread.usersp;
25481 + p->tinfo.lowest_stack = (unsigned long)task_stack_page(p);
25482 set_tsk_thread_flag(p, TIF_FORK);
25483 p->fpu_counter = 0;
25484 p->thread.io_bitmap_ptr = NULL;
25485 @@ -172,6 +173,8 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
25486 p->thread.fs = p->thread.fsindex ? 0 : me->thread.fs;
25487 savesegment(es, p->thread.es);
25488 savesegment(ds, p->thread.ds);
25489 + savesegment(ss, p->thread.ss);
25490 + BUG_ON(p->thread.ss == __UDEREF_KERNEL_DS);
25491 memset(p->thread.ptrace_bps, 0, sizeof(p->thread.ptrace_bps));
25492
25493 if (unlikely(p->flags & PF_KTHREAD)) {
25494 @@ -280,7 +283,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25495 struct thread_struct *prev = &prev_p->thread;
25496 struct thread_struct *next = &next_p->thread;
25497 int cpu = smp_processor_id();
25498 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
25499 + struct tss_struct *tss = init_tss + cpu;
25500 unsigned fsindex, gsindex;
25501 fpu_switch_t fpu;
25502
25503 @@ -303,6 +306,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25504 if (unlikely(next->ds | prev->ds))
25505 loadsegment(ds, next->ds);
25506
25507 + savesegment(ss, prev->ss);
25508 + if (unlikely(next->ss != prev->ss))
25509 + loadsegment(ss, next->ss);
25510
25511 /* We must save %fs and %gs before load_TLS() because
25512 * %fs and %gs may be cleared by load_TLS().
25513 @@ -362,10 +368,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
25514 prev->usersp = this_cpu_read(old_rsp);
25515 this_cpu_write(old_rsp, next->usersp);
25516 this_cpu_write(current_task, next_p);
25517 + this_cpu_write(current_tinfo, &next_p->tinfo);
25518
25519 - this_cpu_write(kernel_stack,
25520 - (unsigned long)task_stack_page(next_p) +
25521 - THREAD_SIZE - KERNEL_STACK_OFFSET);
25522 + this_cpu_write(kernel_stack, next->sp0);
25523
25524 /*
25525 * Now maybe reload the debug registers and handle I/O bitmaps
25526 @@ -434,12 +439,11 @@ unsigned long get_wchan(struct task_struct *p)
25527 if (!p || p == current || p->state == TASK_RUNNING)
25528 return 0;
25529 stack = (unsigned long)task_stack_page(p);
25530 - if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
25531 + if (p->thread.sp < stack || p->thread.sp > stack+THREAD_SIZE-16-sizeof(u64))
25532 return 0;
25533 fp = *(u64 *)(p->thread.sp);
25534 do {
25535 - if (fp < (unsigned long)stack ||
25536 - fp >= (unsigned long)stack+THREAD_SIZE)
25537 + if (fp < stack || fp > stack+THREAD_SIZE-16-sizeof(u64))
25538 return 0;
25539 ip = *(u64 *)(fp+8);
25540 if (!in_sched_functions(ip))
25541 diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c
25542 index 7461f50..1334029 100644
25543 --- a/arch/x86/kernel/ptrace.c
25544 +++ b/arch/x86/kernel/ptrace.c
25545 @@ -184,14 +184,13 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs)
25546 {
25547 unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1);
25548 unsigned long sp = (unsigned long)&regs->sp;
25549 - struct thread_info *tinfo;
25550
25551 - if (context == (sp & ~(THREAD_SIZE - 1)))
25552 + if (context == ((sp + 8) & ~(THREAD_SIZE - 1)))
25553 return sp;
25554
25555 - tinfo = (struct thread_info *)context;
25556 - if (tinfo->previous_esp)
25557 - return tinfo->previous_esp;
25558 + sp = *(unsigned long *)context;
25559 + if (sp)
25560 + return sp;
25561
25562 return (unsigned long)regs;
25563 }
25564 @@ -588,7 +587,7 @@ static void ptrace_triggered(struct perf_event *bp,
25565 static unsigned long ptrace_get_dr7(struct perf_event *bp[])
25566 {
25567 int i;
25568 - int dr7 = 0;
25569 + unsigned long dr7 = 0;
25570 struct arch_hw_breakpoint *info;
25571
25572 for (i = 0; i < HBP_NUM; i++) {
25573 @@ -822,7 +821,7 @@ long arch_ptrace(struct task_struct *child, long request,
25574 unsigned long addr, unsigned long data)
25575 {
25576 int ret;
25577 - unsigned long __user *datap = (unsigned long __user *)data;
25578 + unsigned long __user *datap = (__force unsigned long __user *)data;
25579
25580 switch (request) {
25581 /* read the word at location addr in the USER area. */
25582 @@ -907,14 +906,14 @@ long arch_ptrace(struct task_struct *child, long request,
25583 if ((int) addr < 0)
25584 return -EIO;
25585 ret = do_get_thread_area(child, addr,
25586 - (struct user_desc __user *)data);
25587 + (__force struct user_desc __user *) data);
25588 break;
25589
25590 case PTRACE_SET_THREAD_AREA:
25591 if ((int) addr < 0)
25592 return -EIO;
25593 ret = do_set_thread_area(child, addr,
25594 - (struct user_desc __user *)data, 0);
25595 + (__force struct user_desc __user *) data, 0);
25596 break;
25597 #endif
25598
25599 @@ -1292,7 +1291,7 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
25600
25601 #ifdef CONFIG_X86_64
25602
25603 -static struct user_regset x86_64_regsets[] __read_mostly = {
25604 +static user_regset_no_const x86_64_regsets[] __read_only = {
25605 [REGSET_GENERAL] = {
25606 .core_note_type = NT_PRSTATUS,
25607 .n = sizeof(struct user_regs_struct) / sizeof(long),
25608 @@ -1333,7 +1332,7 @@ static const struct user_regset_view user_x86_64_view = {
25609 #endif /* CONFIG_X86_64 */
25610
25611 #if defined CONFIG_X86_32 || defined CONFIG_IA32_EMULATION
25612 -static struct user_regset x86_32_regsets[] __read_mostly = {
25613 +static user_regset_no_const x86_32_regsets[] __read_only = {
25614 [REGSET_GENERAL] = {
25615 .core_note_type = NT_PRSTATUS,
25616 .n = sizeof(struct user_regs_struct32) / sizeof(u32),
25617 @@ -1386,7 +1385,7 @@ static const struct user_regset_view user_x86_32_view = {
25618 */
25619 u64 xstate_fx_sw_bytes[USER_XSTATE_FX_SW_WORDS];
25620
25621 -void update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25622 +void __init update_regset_xstate_info(unsigned int size, u64 xstate_mask)
25623 {
25624 #ifdef CONFIG_X86_64
25625 x86_64_regsets[REGSET_XSTATE].n = size / sizeof(u64);
25626 @@ -1421,7 +1420,7 @@ static void fill_sigtrap_info(struct task_struct *tsk,
25627 memset(info, 0, sizeof(*info));
25628 info->si_signo = SIGTRAP;
25629 info->si_code = si_code;
25630 - info->si_addr = user_mode_vm(regs) ? (void __user *)regs->ip : NULL;
25631 + info->si_addr = user_mode(regs) ? (__force void __user *)regs->ip : NULL;
25632 }
25633
25634 void user_single_step_siginfo(struct task_struct *tsk,
25635 @@ -1450,6 +1449,10 @@ void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
25636 # define IS_IA32 0
25637 #endif
25638
25639 +#ifdef CONFIG_GRKERNSEC_SETXID
25640 +extern void gr_delayed_cred_worker(void);
25641 +#endif
25642 +
25643 /*
25644 * We must return the syscall number to actually look up in the table.
25645 * This can be -1L to skip running any syscall at all.
25646 @@ -1460,6 +1463,11 @@ long syscall_trace_enter(struct pt_regs *regs)
25647
25648 user_exit();
25649
25650 +#ifdef CONFIG_GRKERNSEC_SETXID
25651 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25652 + gr_delayed_cred_worker();
25653 +#endif
25654 +
25655 /*
25656 * If we stepped into a sysenter/syscall insn, it trapped in
25657 * kernel mode; do_debug() cleared TF and set TIF_SINGLESTEP.
25658 @@ -1515,6 +1523,11 @@ void syscall_trace_leave(struct pt_regs *regs)
25659 */
25660 user_exit();
25661
25662 +#ifdef CONFIG_GRKERNSEC_SETXID
25663 + if (unlikely(test_and_clear_thread_flag(TIF_GRSEC_SETXID)))
25664 + gr_delayed_cred_worker();
25665 +#endif
25666 +
25667 audit_syscall_exit(regs);
25668
25669 if (unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT)))
25670 diff --git a/arch/x86/kernel/pvclock.c b/arch/x86/kernel/pvclock.c
25671 index a16bae3..1f65f25 100644
25672 --- a/arch/x86/kernel/pvclock.c
25673 +++ b/arch/x86/kernel/pvclock.c
25674 @@ -43,11 +43,11 @@ unsigned long pvclock_tsc_khz(struct pvclock_vcpu_time_info *src)
25675 return pv_tsc_khz;
25676 }
25677
25678 -static atomic64_t last_value = ATOMIC64_INIT(0);
25679 +static atomic64_unchecked_t last_value = ATOMIC64_INIT(0);
25680
25681 void pvclock_resume(void)
25682 {
25683 - atomic64_set(&last_value, 0);
25684 + atomic64_set_unchecked(&last_value, 0);
25685 }
25686
25687 u8 pvclock_read_flags(struct pvclock_vcpu_time_info *src)
25688 @@ -92,11 +92,11 @@ cycle_t pvclock_clocksource_read(struct pvclock_vcpu_time_info *src)
25689 * updating at the same time, and one of them could be slightly behind,
25690 * making the assumption that last_value always go forward fail to hold.
25691 */
25692 - last = atomic64_read(&last_value);
25693 + last = atomic64_read_unchecked(&last_value);
25694 do {
25695 if (ret < last)
25696 return last;
25697 - last = atomic64_cmpxchg(&last_value, last, ret);
25698 + last = atomic64_cmpxchg_unchecked(&last_value, last, ret);
25699 } while (unlikely(last != ret));
25700
25701 return ret;
25702 diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c
25703 index 618ce26..ec7e21c 100644
25704 --- a/arch/x86/kernel/reboot.c
25705 +++ b/arch/x86/kernel/reboot.c
25706 @@ -68,6 +68,11 @@ static int __init set_bios_reboot(const struct dmi_system_id *d)
25707
25708 void __noreturn machine_real_restart(unsigned int type)
25709 {
25710 +
25711 +#if defined(CONFIG_X86_32) && (defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF))
25712 + struct desc_struct *gdt;
25713 +#endif
25714 +
25715 local_irq_disable();
25716
25717 /*
25718 @@ -95,7 +100,29 @@ void __noreturn machine_real_restart(unsigned int type)
25719
25720 /* Jump to the identity-mapped low memory code */
25721 #ifdef CONFIG_X86_32
25722 - asm volatile("jmpl *%0" : :
25723 +
25724 +#if defined(CONFIG_PAX_KERNEXEC) || defined(CONFIG_PAX_MEMORY_UDEREF)
25725 + gdt = get_cpu_gdt_table(smp_processor_id());
25726 + pax_open_kernel();
25727 +#ifdef CONFIG_PAX_MEMORY_UDEREF
25728 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
25729 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
25730 + loadsegment(ds, __KERNEL_DS);
25731 + loadsegment(es, __KERNEL_DS);
25732 + loadsegment(ss, __KERNEL_DS);
25733 +#endif
25734 +#ifdef CONFIG_PAX_KERNEXEC
25735 + gdt[GDT_ENTRY_KERNEL_CS].base0 = 0;
25736 + gdt[GDT_ENTRY_KERNEL_CS].base1 = 0;
25737 + gdt[GDT_ENTRY_KERNEL_CS].base2 = 0;
25738 + gdt[GDT_ENTRY_KERNEL_CS].limit0 = 0xffff;
25739 + gdt[GDT_ENTRY_KERNEL_CS].limit = 0xf;
25740 + gdt[GDT_ENTRY_KERNEL_CS].g = 1;
25741 +#endif
25742 + pax_close_kernel();
25743 +#endif
25744 +
25745 + asm volatile("ljmpl *%0" : :
25746 "rm" (real_mode_header->machine_real_restart_asm),
25747 "a" (type));
25748 #else
25749 @@ -466,7 +493,7 @@ void __attribute__((weak)) mach_reboot_fixups(void)
25750 * try to force a triple fault and then cycle between hitting the keyboard
25751 * controller and doing that
25752 */
25753 -static void native_machine_emergency_restart(void)
25754 +static void __noreturn native_machine_emergency_restart(void)
25755 {
25756 int i;
25757 int attempt = 0;
25758 @@ -575,13 +602,13 @@ void native_machine_shutdown(void)
25759 #endif
25760 }
25761
25762 -static void __machine_emergency_restart(int emergency)
25763 +static void __noreturn __machine_emergency_restart(int emergency)
25764 {
25765 reboot_emergency = emergency;
25766 machine_ops.emergency_restart();
25767 }
25768
25769 -static void native_machine_restart(char *__unused)
25770 +static void __noreturn native_machine_restart(char *__unused)
25771 {
25772 pr_notice("machine restart\n");
25773
25774 @@ -590,7 +617,7 @@ static void native_machine_restart(char *__unused)
25775 __machine_emergency_restart(0);
25776 }
25777
25778 -static void native_machine_halt(void)
25779 +static void __noreturn native_machine_halt(void)
25780 {
25781 /* Stop other cpus and apics */
25782 machine_shutdown();
25783 @@ -600,7 +627,7 @@ static void native_machine_halt(void)
25784 stop_this_cpu(NULL);
25785 }
25786
25787 -static void native_machine_power_off(void)
25788 +static void __noreturn native_machine_power_off(void)
25789 {
25790 if (pm_power_off) {
25791 if (!reboot_force)
25792 @@ -609,9 +636,10 @@ static void native_machine_power_off(void)
25793 }
25794 /* A fallback in case there is no PM info available */
25795 tboot_shutdown(TB_SHUTDOWN_HALT);
25796 + unreachable();
25797 }
25798
25799 -struct machine_ops machine_ops = {
25800 +struct machine_ops machine_ops __read_only = {
25801 .power_off = native_machine_power_off,
25802 .shutdown = native_machine_shutdown,
25803 .emergency_restart = native_machine_emergency_restart,
25804 diff --git a/arch/x86/kernel/reboot_fixups_32.c b/arch/x86/kernel/reboot_fixups_32.c
25805 index c8e41e9..64049ef 100644
25806 --- a/arch/x86/kernel/reboot_fixups_32.c
25807 +++ b/arch/x86/kernel/reboot_fixups_32.c
25808 @@ -57,7 +57,7 @@ struct device_fixup {
25809 unsigned int vendor;
25810 unsigned int device;
25811 void (*reboot_fixup)(struct pci_dev *);
25812 -};
25813 +} __do_const;
25814
25815 /*
25816 * PCI ids solely used for fixups_table go here
25817 diff --git a/arch/x86/kernel/relocate_kernel_64.S b/arch/x86/kernel/relocate_kernel_64.S
25818 index 3fd2c69..16ef367 100644
25819 --- a/arch/x86/kernel/relocate_kernel_64.S
25820 +++ b/arch/x86/kernel/relocate_kernel_64.S
25821 @@ -11,6 +11,7 @@
25822 #include <asm/kexec.h>
25823 #include <asm/processor-flags.h>
25824 #include <asm/pgtable_types.h>
25825 +#include <asm/alternative-asm.h>
25826
25827 /*
25828 * Must be relocatable PIC code callable as a C function
25829 @@ -96,8 +97,7 @@ relocate_kernel:
25830
25831 /* jump to identity mapped page */
25832 addq $(identity_mapped - relocate_kernel), %r8
25833 - pushq %r8
25834 - ret
25835 + jmp *%r8
25836
25837 identity_mapped:
25838 /* set return address to 0 if not preserving context */
25839 @@ -167,6 +167,7 @@ identity_mapped:
25840 xorl %r14d, %r14d
25841 xorl %r15d, %r15d
25842
25843 + pax_force_retaddr 0, 1
25844 ret
25845
25846 1:
25847 diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c
25848 index f0de629..a4978a8f 100644
25849 --- a/arch/x86/kernel/setup.c
25850 +++ b/arch/x86/kernel/setup.c
25851 @@ -110,6 +110,7 @@
25852 #include <asm/mce.h>
25853 #include <asm/alternative.h>
25854 #include <asm/prom.h>
25855 +#include <asm/boot.h>
25856
25857 /*
25858 * max_low_pfn_mapped: highest direct mapped pfn under 4GB
25859 @@ -205,12 +206,50 @@ EXPORT_SYMBOL(boot_cpu_data);
25860 #endif
25861
25862
25863 -#if !defined(CONFIG_X86_PAE) || defined(CONFIG_X86_64)
25864 -__visible unsigned long mmu_cr4_features;
25865 +#ifdef CONFIG_X86_64
25866 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PSE | X86_CR4_PAE | X86_CR4_PGE;
25867 +#elif defined(CONFIG_X86_PAE)
25868 +__visible unsigned long mmu_cr4_features __read_only = X86_CR4_PAE;
25869 #else
25870 -__visible unsigned long mmu_cr4_features = X86_CR4_PAE;
25871 +__visible unsigned long mmu_cr4_features __read_only;
25872 #endif
25873
25874 +void set_in_cr4(unsigned long mask)
25875 +{
25876 + unsigned long cr4 = read_cr4();
25877 +
25878 + if ((cr4 & mask) == mask && cr4 == mmu_cr4_features)
25879 + return;
25880 +
25881 + pax_open_kernel();
25882 + mmu_cr4_features |= mask;
25883 + pax_close_kernel();
25884 +
25885 + if (trampoline_cr4_features)
25886 + *trampoline_cr4_features = mmu_cr4_features;
25887 + cr4 |= mask;
25888 + write_cr4(cr4);
25889 +}
25890 +EXPORT_SYMBOL(set_in_cr4);
25891 +
25892 +void clear_in_cr4(unsigned long mask)
25893 +{
25894 + unsigned long cr4 = read_cr4();
25895 +
25896 + if (!(cr4 & mask) && cr4 == mmu_cr4_features)
25897 + return;
25898 +
25899 + pax_open_kernel();
25900 + mmu_cr4_features &= ~mask;
25901 + pax_close_kernel();
25902 +
25903 + if (trampoline_cr4_features)
25904 + *trampoline_cr4_features = mmu_cr4_features;
25905 + cr4 &= ~mask;
25906 + write_cr4(cr4);
25907 +}
25908 +EXPORT_SYMBOL(clear_in_cr4);
25909 +
25910 /* Boot loader ID and version as integers, for the benefit of proc_dointvec */
25911 int bootloader_type, bootloader_version;
25912
25913 @@ -768,7 +807,7 @@ static void __init trim_bios_range(void)
25914 * area (640->1Mb) as ram even though it is not.
25915 * take them out.
25916 */
25917 - e820_remove_range(BIOS_BEGIN, BIOS_END - BIOS_BEGIN, E820_RAM, 1);
25918 + e820_remove_range(ISA_START_ADDRESS, ISA_END_ADDRESS - ISA_START_ADDRESS, E820_RAM, 1);
25919
25920 sanitize_e820_map(e820.map, ARRAY_SIZE(e820.map), &e820.nr_map);
25921 }
25922 @@ -776,7 +815,7 @@ static void __init trim_bios_range(void)
25923 /* called before trim_bios_range() to spare extra sanitize */
25924 static void __init e820_add_kernel_range(void)
25925 {
25926 - u64 start = __pa_symbol(_text);
25927 + u64 start = __pa_symbol(ktla_ktva(_text));
25928 u64 size = __pa_symbol(_end) - start;
25929
25930 /*
25931 @@ -838,8 +877,12 @@ static void __init trim_low_memory_range(void)
25932
25933 void __init setup_arch(char **cmdline_p)
25934 {
25935 +#ifdef CONFIG_X86_32
25936 + memblock_reserve(LOAD_PHYSICAL_ADDR, __pa_symbol(__bss_stop) - LOAD_PHYSICAL_ADDR);
25937 +#else
25938 memblock_reserve(__pa_symbol(_text),
25939 (unsigned long)__bss_stop - (unsigned long)_text);
25940 +#endif
25941
25942 early_reserve_initrd();
25943
25944 @@ -931,14 +974,14 @@ void __init setup_arch(char **cmdline_p)
25945
25946 if (!boot_params.hdr.root_flags)
25947 root_mountflags &= ~MS_RDONLY;
25948 - init_mm.start_code = (unsigned long) _text;
25949 - init_mm.end_code = (unsigned long) _etext;
25950 + init_mm.start_code = ktla_ktva((unsigned long) _text);
25951 + init_mm.end_code = ktla_ktva((unsigned long) _etext);
25952 init_mm.end_data = (unsigned long) _edata;
25953 init_mm.brk = _brk_end;
25954
25955 - code_resource.start = __pa_symbol(_text);
25956 - code_resource.end = __pa_symbol(_etext)-1;
25957 - data_resource.start = __pa_symbol(_etext);
25958 + code_resource.start = __pa_symbol(ktla_ktva(_text));
25959 + code_resource.end = __pa_symbol(ktla_ktva(_etext))-1;
25960 + data_resource.start = __pa_symbol(_sdata);
25961 data_resource.end = __pa_symbol(_edata)-1;
25962 bss_resource.start = __pa_symbol(__bss_start);
25963 bss_resource.end = __pa_symbol(__bss_stop)-1;
25964 diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
25965 index 5cdff03..80fa283 100644
25966 --- a/arch/x86/kernel/setup_percpu.c
25967 +++ b/arch/x86/kernel/setup_percpu.c
25968 @@ -21,19 +21,17 @@
25969 #include <asm/cpu.h>
25970 #include <asm/stackprotector.h>
25971
25972 -DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number);
25973 +#ifdef CONFIG_SMP
25974 +DEFINE_PER_CPU_READ_MOSTLY(unsigned int, cpu_number);
25975 EXPORT_PER_CPU_SYMBOL(cpu_number);
25976 +#endif
25977
25978 -#ifdef CONFIG_X86_64
25979 #define BOOT_PERCPU_OFFSET ((unsigned long)__per_cpu_load)
25980 -#else
25981 -#define BOOT_PERCPU_OFFSET 0
25982 -#endif
25983
25984 DEFINE_PER_CPU(unsigned long, this_cpu_off) = BOOT_PERCPU_OFFSET;
25985 EXPORT_PER_CPU_SYMBOL(this_cpu_off);
25986
25987 -unsigned long __per_cpu_offset[NR_CPUS] __read_mostly = {
25988 +unsigned long __per_cpu_offset[NR_CPUS] __read_only = {
25989 [0 ... NR_CPUS-1] = BOOT_PERCPU_OFFSET,
25990 };
25991 EXPORT_SYMBOL(__per_cpu_offset);
25992 @@ -66,7 +64,7 @@ static bool __init pcpu_need_numa(void)
25993 {
25994 #ifdef CONFIG_NEED_MULTIPLE_NODES
25995 pg_data_t *last = NULL;
25996 - unsigned int cpu;
25997 + int cpu;
25998
25999 for_each_possible_cpu(cpu) {
26000 int node = early_cpu_to_node(cpu);
26001 @@ -155,10 +153,10 @@ static inline void setup_percpu_segment(int cpu)
26002 {
26003 #ifdef CONFIG_X86_32
26004 struct desc_struct gdt;
26005 + unsigned long base = per_cpu_offset(cpu);
26006
26007 - pack_descriptor(&gdt, per_cpu_offset(cpu), 0xFFFFF,
26008 - 0x2 | DESCTYPE_S, 0x8);
26009 - gdt.s = 1;
26010 + pack_descriptor(&gdt, base, (VMALLOC_END - base - 1) >> PAGE_SHIFT,
26011 + 0x83 | DESCTYPE_S, 0xC);
26012 write_gdt_entry(get_cpu_gdt_table(cpu),
26013 GDT_ENTRY_PERCPU, &gdt, DESCTYPE_S);
26014 #endif
26015 @@ -219,6 +217,11 @@ void __init setup_per_cpu_areas(void)
26016 /* alrighty, percpu areas up and running */
26017 delta = (unsigned long)pcpu_base_addr - (unsigned long)__per_cpu_start;
26018 for_each_possible_cpu(cpu) {
26019 +#ifdef CONFIG_CC_STACKPROTECTOR
26020 +#ifdef CONFIG_X86_32
26021 + unsigned long canary = per_cpu(stack_canary.canary, cpu);
26022 +#endif
26023 +#endif
26024 per_cpu_offset(cpu) = delta + pcpu_unit_offsets[cpu];
26025 per_cpu(this_cpu_off, cpu) = per_cpu_offset(cpu);
26026 per_cpu(cpu_number, cpu) = cpu;
26027 @@ -259,6 +262,12 @@ void __init setup_per_cpu_areas(void)
26028 */
26029 set_cpu_numa_node(cpu, early_cpu_to_node(cpu));
26030 #endif
26031 +#ifdef CONFIG_CC_STACKPROTECTOR
26032 +#ifdef CONFIG_X86_32
26033 + if (!cpu)
26034 + per_cpu(stack_canary.canary, cpu) = canary;
26035 +#endif
26036 +#endif
26037 /*
26038 * Up to this point, the boot CPU has been using .init.data
26039 * area. Reload any changed state for the boot CPU.
26040 diff --git a/arch/x86/kernel/signal.c b/arch/x86/kernel/signal.c
26041 index 9e5de68..16c53cb 100644
26042 --- a/arch/x86/kernel/signal.c
26043 +++ b/arch/x86/kernel/signal.c
26044 @@ -190,7 +190,7 @@ static unsigned long align_sigframe(unsigned long sp)
26045 * Align the stack pointer according to the i386 ABI,
26046 * i.e. so that on function entry ((sp + 4) & 15) == 0.
26047 */
26048 - sp = ((sp + 4) & -16ul) - 4;
26049 + sp = ((sp - 12) & -16ul) - 4;
26050 #else /* !CONFIG_X86_32 */
26051 sp = round_down(sp, 16) - 8;
26052 #endif
26053 @@ -298,9 +298,9 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26054 }
26055
26056 if (current->mm->context.vdso)
26057 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26058 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, sigreturn);
26059 else
26060 - restorer = &frame->retcode;
26061 + restorer = (void __user *)&frame->retcode;
26062 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26063 restorer = ksig->ka.sa.sa_restorer;
26064
26065 @@ -314,7 +314,7 @@ __setup_frame(int sig, struct ksignal *ksig, sigset_t *set,
26066 * reasons and because gdb uses it as a signature to notice
26067 * signal handler stack frames.
26068 */
26069 - err |= __put_user(*((u64 *)&retcode), (u64 *)frame->retcode);
26070 + err |= __put_user(*((u64 *)&retcode), (u64 __user *)frame->retcode);
26071
26072 if (err)
26073 return -EFAULT;
26074 @@ -361,7 +361,10 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26075 save_altstack_ex(&frame->uc.uc_stack, regs->sp);
26076
26077 /* Set up to return from userspace. */
26078 - restorer = VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26079 + if (current->mm->context.vdso)
26080 + restorer = (__force void __user *)VDSO32_SYMBOL(current->mm->context.vdso, rt_sigreturn);
26081 + else
26082 + restorer = (void __user *)&frame->retcode;
26083 if (ksig->ka.sa.sa_flags & SA_RESTORER)
26084 restorer = ksig->ka.sa.sa_restorer;
26085 put_user_ex(restorer, &frame->pretcode);
26086 @@ -373,7 +376,7 @@ static int __setup_rt_frame(int sig, struct ksignal *ksig,
26087 * reasons and because gdb uses it as a signature to notice
26088 * signal handler stack frames.
26089 */
26090 - put_user_ex(*((u64 *)&rt_retcode), (u64 *)frame->retcode);
26091 + put_user_ex(*((u64 *)&rt_retcode), (u64 __user *)frame->retcode);
26092 } put_user_catch(err);
26093
26094 err |= copy_siginfo_to_user(&frame->info, &ksig->info);
26095 @@ -609,7 +612,12 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26096 {
26097 int usig = signr_convert(ksig->sig);
26098 sigset_t *set = sigmask_to_save();
26099 - compat_sigset_t *cset = (compat_sigset_t *) set;
26100 + sigset_t sigcopy;
26101 + compat_sigset_t *cset;
26102 +
26103 + sigcopy = *set;
26104 +
26105 + cset = (compat_sigset_t *) &sigcopy;
26106
26107 /* Set up the stack frame */
26108 if (is_ia32_frame()) {
26109 @@ -620,7 +628,7 @@ setup_rt_frame(struct ksignal *ksig, struct pt_regs *regs)
26110 } else if (is_x32_frame()) {
26111 return x32_setup_rt_frame(ksig, cset, regs);
26112 } else {
26113 - return __setup_rt_frame(ksig->sig, ksig, set, regs);
26114 + return __setup_rt_frame(ksig->sig, ksig, &sigcopy, regs);
26115 }
26116 }
26117
26118 diff --git a/arch/x86/kernel/smp.c b/arch/x86/kernel/smp.c
26119 index 7c3a5a6..f0a8961 100644
26120 --- a/arch/x86/kernel/smp.c
26121 +++ b/arch/x86/kernel/smp.c
26122 @@ -341,7 +341,7 @@ static int __init nonmi_ipi_setup(char *str)
26123
26124 __setup("nonmi_ipi", nonmi_ipi_setup);
26125
26126 -struct smp_ops smp_ops = {
26127 +struct smp_ops smp_ops __read_only = {
26128 .smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
26129 .smp_prepare_cpus = native_smp_prepare_cpus,
26130 .smp_cpus_done = native_smp_cpus_done,
26131 diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c
26132 index 6cacab6..750636a 100644
26133 --- a/arch/x86/kernel/smpboot.c
26134 +++ b/arch/x86/kernel/smpboot.c
26135 @@ -251,14 +251,18 @@ static void notrace start_secondary(void *unused)
26136
26137 enable_start_cpu0 = 0;
26138
26139 -#ifdef CONFIG_X86_32
26140 - /* switch away from the initial page table */
26141 - load_cr3(swapper_pg_dir);
26142 - __flush_tlb_all();
26143 -#endif
26144 -
26145 /* otherwise gcc will move up smp_processor_id before the cpu_init */
26146 barrier();
26147 +
26148 + /* switch away from the initial page table */
26149 +#ifdef CONFIG_PAX_PER_CPU_PGD
26150 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
26151 + __flush_tlb_all();
26152 +#elif defined(CONFIG_X86_32)
26153 + load_cr3(swapper_pg_dir);
26154 + __flush_tlb_all();
26155 +#endif
26156 +
26157 /*
26158 * Check TSC synchronization with the BP:
26159 */
26160 @@ -749,6 +753,7 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26161 idle->thread.sp = (unsigned long) (((struct pt_regs *)
26162 (THREAD_SIZE + task_stack_page(idle))) - 1);
26163 per_cpu(current_task, cpu) = idle;
26164 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
26165
26166 #ifdef CONFIG_X86_32
26167 /* Stack for startup_32 can be just as for start_secondary onwards */
26168 @@ -756,11 +761,13 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle)
26169 #else
26170 clear_tsk_thread_flag(idle, TIF_FORK);
26171 initial_gs = per_cpu_offset(cpu);
26172 - per_cpu(kernel_stack, cpu) =
26173 - (unsigned long)task_stack_page(idle) -
26174 - KERNEL_STACK_OFFSET + THREAD_SIZE;
26175 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
26176 #endif
26177 +
26178 + pax_open_kernel();
26179 early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu);
26180 + pax_close_kernel();
26181 +
26182 initial_code = (unsigned long)start_secondary;
26183 stack_start = idle->thread.sp;
26184
26185 @@ -909,6 +916,15 @@ int native_cpu_up(unsigned int cpu, struct task_struct *tidle)
26186 /* the FPU context is blank, nobody can own it */
26187 __cpu_disable_lazy_restore(cpu);
26188
26189 +#ifdef CONFIG_PAX_PER_CPU_PGD
26190 + clone_pgd_range(get_cpu_pgd(cpu, kernel) + KERNEL_PGD_BOUNDARY,
26191 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
26192 + KERNEL_PGD_PTRS);
26193 + clone_pgd_range(get_cpu_pgd(cpu, user) + KERNEL_PGD_BOUNDARY,
26194 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
26195 + KERNEL_PGD_PTRS);
26196 +#endif
26197 +
26198 err = do_boot_cpu(apicid, cpu, tidle);
26199 if (err) {
26200 pr_debug("do_boot_cpu failed %d\n", err);
26201 diff --git a/arch/x86/kernel/step.c b/arch/x86/kernel/step.c
26202 index 9b4d51d..5d28b58 100644
26203 --- a/arch/x86/kernel/step.c
26204 +++ b/arch/x86/kernel/step.c
26205 @@ -27,10 +27,10 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
26206 struct desc_struct *desc;
26207 unsigned long base;
26208
26209 - seg &= ~7UL;
26210 + seg >>= 3;
26211
26212 mutex_lock(&child->mm->context.lock);
26213 - if (unlikely((seg >> 3) >= child->mm->context.size))
26214 + if (unlikely(seg >= child->mm->context.size))
26215 addr = -1L; /* bogus selector, access would fault */
26216 else {
26217 desc = child->mm->context.ldt + seg;
26218 @@ -42,7 +42,8 @@ unsigned long convert_ip_to_linear(struct task_struct *child, struct pt_regs *re
26219 addr += base;
26220 }
26221 mutex_unlock(&child->mm->context.lock);
26222 - }
26223 + } else if (seg == __KERNEL_CS || seg == __KERNEXEC_KERNEL_CS)
26224 + addr = ktla_ktva(addr);
26225
26226 return addr;
26227 }
26228 @@ -53,6 +54,9 @@ static int is_setting_trap_flag(struct task_struct *child, struct pt_regs *regs)
26229 unsigned char opcode[15];
26230 unsigned long addr = convert_ip_to_linear(child, regs);
26231
26232 + if (addr == -EINVAL)
26233 + return 0;
26234 +
26235 copied = access_process_vm(child, addr, opcode, sizeof(opcode), 0);
26236 for (i = 0; i < copied; i++) {
26237 switch (opcode[i]) {
26238 diff --git a/arch/x86/kernel/sys_i386_32.c b/arch/x86/kernel/sys_i386_32.c
26239 new file mode 100644
26240 index 0000000..5877189
26241 --- /dev/null
26242 +++ b/arch/x86/kernel/sys_i386_32.c
26243 @@ -0,0 +1,189 @@
26244 +/*
26245 + * This file contains various random system calls that
26246 + * have a non-standard calling sequence on the Linux/i386
26247 + * platform.
26248 + */
26249 +
26250 +#include <linux/errno.h>
26251 +#include <linux/sched.h>
26252 +#include <linux/mm.h>
26253 +#include <linux/fs.h>
26254 +#include <linux/smp.h>
26255 +#include <linux/sem.h>
26256 +#include <linux/msg.h>
26257 +#include <linux/shm.h>
26258 +#include <linux/stat.h>
26259 +#include <linux/syscalls.h>
26260 +#include <linux/mman.h>
26261 +#include <linux/file.h>
26262 +#include <linux/utsname.h>
26263 +#include <linux/ipc.h>
26264 +#include <linux/elf.h>
26265 +
26266 +#include <linux/uaccess.h>
26267 +#include <linux/unistd.h>
26268 +
26269 +#include <asm/syscalls.h>
26270 +
26271 +int i386_mmap_check(unsigned long addr, unsigned long len, unsigned long flags)
26272 +{
26273 + unsigned long pax_task_size = TASK_SIZE;
26274 +
26275 +#ifdef CONFIG_PAX_SEGMEXEC
26276 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
26277 + pax_task_size = SEGMEXEC_TASK_SIZE;
26278 +#endif
26279 +
26280 + if (flags & MAP_FIXED)
26281 + if (len > pax_task_size || addr > pax_task_size - len)
26282 + return -EINVAL;
26283 +
26284 + return 0;
26285 +}
26286 +
26287 +/*
26288 + * Align a virtual address to avoid aliasing in the I$ on AMD F15h.
26289 + */
26290 +static unsigned long get_align_mask(void)
26291 +{
26292 + if (va_align.flags < 0 || !(va_align.flags & ALIGN_VA_32))
26293 + return 0;
26294 +
26295 + if (!(current->flags & PF_RANDOMIZE))
26296 + return 0;
26297 +
26298 + return va_align.mask;
26299 +}
26300 +
26301 +unsigned long
26302 +arch_get_unmapped_area(struct file *filp, unsigned long addr,
26303 + unsigned long len, unsigned long pgoff, unsigned long flags)
26304 +{
26305 + struct mm_struct *mm = current->mm;
26306 + struct vm_area_struct *vma;
26307 + unsigned long pax_task_size = TASK_SIZE;
26308 + struct vm_unmapped_area_info info;
26309 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26310 +
26311 +#ifdef CONFIG_PAX_SEGMEXEC
26312 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
26313 + pax_task_size = SEGMEXEC_TASK_SIZE;
26314 +#endif
26315 +
26316 + pax_task_size -= PAGE_SIZE;
26317 +
26318 + if (len > pax_task_size)
26319 + return -ENOMEM;
26320 +
26321 + if (flags & MAP_FIXED)
26322 + return addr;
26323 +
26324 +#ifdef CONFIG_PAX_RANDMMAP
26325 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26326 +#endif
26327 +
26328 + if (addr) {
26329 + addr = PAGE_ALIGN(addr);
26330 + if (pax_task_size - len >= addr) {
26331 + vma = find_vma(mm, addr);
26332 + if (check_heap_stack_gap(vma, addr, len, offset))
26333 + return addr;
26334 + }
26335 + }
26336 +
26337 + info.flags = 0;
26338 + info.length = len;
26339 + info.align_mask = filp ? get_align_mask() : 0;
26340 + info.align_offset = pgoff << PAGE_SHIFT;
26341 + info.threadstack_offset = offset;
26342 +
26343 +#ifdef CONFIG_PAX_PAGEEXEC
26344 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE)) {
26345 + info.low_limit = 0x00110000UL;
26346 + info.high_limit = mm->start_code;
26347 +
26348 +#ifdef CONFIG_PAX_RANDMMAP
26349 + if (mm->pax_flags & MF_PAX_RANDMMAP)
26350 + info.low_limit += mm->delta_mmap & 0x03FFF000UL;
26351 +#endif
26352 +
26353 + if (info.low_limit < info.high_limit) {
26354 + addr = vm_unmapped_area(&info);
26355 + if (!IS_ERR_VALUE(addr))
26356 + return addr;
26357 + }
26358 + } else
26359 +#endif
26360 +
26361 + info.low_limit = mm->mmap_base;
26362 + info.high_limit = pax_task_size;
26363 +
26364 + return vm_unmapped_area(&info);
26365 +}
26366 +
26367 +unsigned long
26368 +arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26369 + const unsigned long len, const unsigned long pgoff,
26370 + const unsigned long flags)
26371 +{
26372 + struct vm_area_struct *vma;
26373 + struct mm_struct *mm = current->mm;
26374 + unsigned long addr = addr0, pax_task_size = TASK_SIZE;
26375 + struct vm_unmapped_area_info info;
26376 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26377 +
26378 +#ifdef CONFIG_PAX_SEGMEXEC
26379 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
26380 + pax_task_size = SEGMEXEC_TASK_SIZE;
26381 +#endif
26382 +
26383 + pax_task_size -= PAGE_SIZE;
26384 +
26385 + /* requested length too big for entire address space */
26386 + if (len > pax_task_size)
26387 + return -ENOMEM;
26388 +
26389 + if (flags & MAP_FIXED)
26390 + return addr;
26391 +
26392 +#ifdef CONFIG_PAX_PAGEEXEC
26393 + if (!(__supported_pte_mask & _PAGE_NX) && (mm->pax_flags & MF_PAX_PAGEEXEC) && (flags & MAP_EXECUTABLE))
26394 + goto bottomup;
26395 +#endif
26396 +
26397 +#ifdef CONFIG_PAX_RANDMMAP
26398 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26399 +#endif
26400 +
26401 + /* requesting a specific address */
26402 + if (addr) {
26403 + addr = PAGE_ALIGN(addr);
26404 + if (pax_task_size - len >= addr) {
26405 + vma = find_vma(mm, addr);
26406 + if (check_heap_stack_gap(vma, addr, len, offset))
26407 + return addr;
26408 + }
26409 + }
26410 +
26411 + info.flags = VM_UNMAPPED_AREA_TOPDOWN;
26412 + info.length = len;
26413 + info.low_limit = PAGE_SIZE;
26414 + info.high_limit = mm->mmap_base;
26415 + info.align_mask = filp ? get_align_mask() : 0;
26416 + info.align_offset = pgoff << PAGE_SHIFT;
26417 + info.threadstack_offset = offset;
26418 +
26419 + addr = vm_unmapped_area(&info);
26420 + if (!(addr & ~PAGE_MASK))
26421 + return addr;
26422 + VM_BUG_ON(addr != -ENOMEM);
26423 +
26424 +bottomup:
26425 + /*
26426 + * A failed mmap() very likely causes application failure,
26427 + * so fall back to the bottom-up function here. This scenario
26428 + * can happen with large stack limits and large mmap()
26429 + * allocations.
26430 + */
26431 + return arch_get_unmapped_area(filp, addr0, len, pgoff, flags);
26432 +}
26433 diff --git a/arch/x86/kernel/sys_x86_64.c b/arch/x86/kernel/sys_x86_64.c
26434 index 30277e2..5664a29 100644
26435 --- a/arch/x86/kernel/sys_x86_64.c
26436 +++ b/arch/x86/kernel/sys_x86_64.c
26437 @@ -81,8 +81,8 @@ out:
26438 return error;
26439 }
26440
26441 -static void find_start_end(unsigned long flags, unsigned long *begin,
26442 - unsigned long *end)
26443 +static void find_start_end(struct mm_struct *mm, unsigned long flags,
26444 + unsigned long *begin, unsigned long *end)
26445 {
26446 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT)) {
26447 unsigned long new_begin;
26448 @@ -101,7 +101,7 @@ static void find_start_end(unsigned long flags, unsigned long *begin,
26449 *begin = new_begin;
26450 }
26451 } else {
26452 - *begin = current->mm->mmap_legacy_base;
26453 + *begin = mm->mmap_legacy_base;
26454 *end = TASK_SIZE;
26455 }
26456 }
26457 @@ -114,20 +114,24 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26458 struct vm_area_struct *vma;
26459 struct vm_unmapped_area_info info;
26460 unsigned long begin, end;
26461 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26462
26463 if (flags & MAP_FIXED)
26464 return addr;
26465
26466 - find_start_end(flags, &begin, &end);
26467 + find_start_end(mm, flags, &begin, &end);
26468
26469 if (len > end)
26470 return -ENOMEM;
26471
26472 +#ifdef CONFIG_PAX_RANDMMAP
26473 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26474 +#endif
26475 +
26476 if (addr) {
26477 addr = PAGE_ALIGN(addr);
26478 vma = find_vma(mm, addr);
26479 - if (end - len >= addr &&
26480 - (!vma || addr + len <= vma->vm_start))
26481 + if (end - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26482 return addr;
26483 }
26484
26485 @@ -137,6 +141,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
26486 info.high_limit = end;
26487 info.align_mask = filp ? get_align_mask() : 0;
26488 info.align_offset = pgoff << PAGE_SHIFT;
26489 + info.threadstack_offset = offset;
26490 return vm_unmapped_area(&info);
26491 }
26492
26493 @@ -149,6 +154,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26494 struct mm_struct *mm = current->mm;
26495 unsigned long addr = addr0;
26496 struct vm_unmapped_area_info info;
26497 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
26498
26499 /* requested length too big for entire address space */
26500 if (len > TASK_SIZE)
26501 @@ -161,12 +167,15 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26502 if (!test_thread_flag(TIF_ADDR32) && (flags & MAP_32BIT))
26503 goto bottomup;
26504
26505 +#ifdef CONFIG_PAX_RANDMMAP
26506 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
26507 +#endif
26508 +
26509 /* requesting a specific address */
26510 if (addr) {
26511 addr = PAGE_ALIGN(addr);
26512 vma = find_vma(mm, addr);
26513 - if (TASK_SIZE - len >= addr &&
26514 - (!vma || addr + len <= vma->vm_start))
26515 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
26516 return addr;
26517 }
26518
26519 @@ -176,6 +185,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
26520 info.high_limit = mm->mmap_base;
26521 info.align_mask = filp ? get_align_mask() : 0;
26522 info.align_offset = pgoff << PAGE_SHIFT;
26523 + info.threadstack_offset = offset;
26524 addr = vm_unmapped_area(&info);
26525 if (!(addr & ~PAGE_MASK))
26526 return addr;
26527 diff --git a/arch/x86/kernel/tboot.c b/arch/x86/kernel/tboot.c
26528 index 91a4496..1730bff 100644
26529 --- a/arch/x86/kernel/tboot.c
26530 +++ b/arch/x86/kernel/tboot.c
26531 @@ -221,7 +221,7 @@ static int tboot_setup_sleep(void)
26532
26533 void tboot_shutdown(u32 shutdown_type)
26534 {
26535 - void (*shutdown)(void);
26536 + void (* __noreturn shutdown)(void);
26537
26538 if (!tboot_enabled())
26539 return;
26540 @@ -243,7 +243,7 @@ void tboot_shutdown(u32 shutdown_type)
26541
26542 switch_to_tboot_pt();
26543
26544 - shutdown = (void(*)(void))(unsigned long)tboot->shutdown_entry;
26545 + shutdown = (void *)tboot->shutdown_entry;
26546 shutdown();
26547
26548 /* should not reach here */
26549 @@ -310,7 +310,7 @@ static int tboot_extended_sleep(u8 sleep_state, u32 val_a, u32 val_b)
26550 return -ENODEV;
26551 }
26552
26553 -static atomic_t ap_wfs_count;
26554 +static atomic_unchecked_t ap_wfs_count;
26555
26556 static int tboot_wait_for_aps(int num_aps)
26557 {
26558 @@ -334,9 +334,9 @@ static int tboot_cpu_callback(struct notifier_block *nfb, unsigned long action,
26559 {
26560 switch (action) {
26561 case CPU_DYING:
26562 - atomic_inc(&ap_wfs_count);
26563 + atomic_inc_unchecked(&ap_wfs_count);
26564 if (num_online_cpus() == 1)
26565 - if (tboot_wait_for_aps(atomic_read(&ap_wfs_count)))
26566 + if (tboot_wait_for_aps(atomic_read_unchecked(&ap_wfs_count)))
26567 return NOTIFY_BAD;
26568 break;
26569 }
26570 @@ -422,7 +422,7 @@ static __init int tboot_late_init(void)
26571
26572 tboot_create_trampoline();
26573
26574 - atomic_set(&ap_wfs_count, 0);
26575 + atomic_set_unchecked(&ap_wfs_count, 0);
26576 register_hotcpu_notifier(&tboot_cpu_notifier);
26577
26578 #ifdef CONFIG_DEBUG_FS
26579 diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c
26580 index 24d3c91..d06b473 100644
26581 --- a/arch/x86/kernel/time.c
26582 +++ b/arch/x86/kernel/time.c
26583 @@ -30,9 +30,9 @@ unsigned long profile_pc(struct pt_regs *regs)
26584 {
26585 unsigned long pc = instruction_pointer(regs);
26586
26587 - if (!user_mode_vm(regs) && in_lock_functions(pc)) {
26588 + if (!user_mode(regs) && in_lock_functions(pc)) {
26589 #ifdef CONFIG_FRAME_POINTER
26590 - return *(unsigned long *)(regs->bp + sizeof(long));
26591 + return ktla_ktva(*(unsigned long *)(regs->bp + sizeof(long)));
26592 #else
26593 unsigned long *sp =
26594 (unsigned long *)kernel_stack_pointer(regs);
26595 @@ -41,11 +41,17 @@ unsigned long profile_pc(struct pt_regs *regs)
26596 * or above a saved flags. Eflags has bits 22-31 zero,
26597 * kernel addresses don't.
26598 */
26599 +
26600 +#ifdef CONFIG_PAX_KERNEXEC
26601 + return ktla_ktva(sp[0]);
26602 +#else
26603 if (sp[0] >> 22)
26604 return sp[0];
26605 if (sp[1] >> 22)
26606 return sp[1];
26607 #endif
26608 +
26609 +#endif
26610 }
26611 return pc;
26612 }
26613 diff --git a/arch/x86/kernel/tls.c b/arch/x86/kernel/tls.c
26614 index f7fec09..9991981 100644
26615 --- a/arch/x86/kernel/tls.c
26616 +++ b/arch/x86/kernel/tls.c
26617 @@ -84,6 +84,11 @@ int do_set_thread_area(struct task_struct *p, int idx,
26618 if (idx < GDT_ENTRY_TLS_MIN || idx > GDT_ENTRY_TLS_MAX)
26619 return -EINVAL;
26620
26621 +#ifdef CONFIG_PAX_SEGMEXEC
26622 + if ((p->mm->pax_flags & MF_PAX_SEGMEXEC) && (info.contents & MODIFY_LDT_CONTENTS_CODE))
26623 + return -EINVAL;
26624 +#endif
26625 +
26626 set_tls_desc(p, idx, &info, 1);
26627
26628 return 0;
26629 @@ -200,7 +205,7 @@ int regset_tls_set(struct task_struct *target, const struct user_regset *regset,
26630
26631 if (kbuf)
26632 info = kbuf;
26633 - else if (__copy_from_user(infobuf, ubuf, count))
26634 + else if (count > sizeof infobuf || __copy_from_user(infobuf, ubuf, count))
26635 return -EFAULT;
26636 else
26637 info = infobuf;
26638 diff --git a/arch/x86/kernel/tracepoint.c b/arch/x86/kernel/tracepoint.c
26639 index 1c113db..287b42e 100644
26640 --- a/arch/x86/kernel/tracepoint.c
26641 +++ b/arch/x86/kernel/tracepoint.c
26642 @@ -9,11 +9,11 @@
26643 #include <linux/atomic.h>
26644
26645 atomic_t trace_idt_ctr = ATOMIC_INIT(0);
26646 -struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
26647 +const struct desc_ptr trace_idt_descr = { NR_VECTORS * 16 - 1,
26648 (unsigned long) trace_idt_table };
26649
26650 /* No need to be aligned, but done to keep all IDTs defined the same way. */
26651 -gate_desc trace_idt_table[NR_VECTORS] __page_aligned_bss;
26652 +gate_desc trace_idt_table[NR_VECTORS] __page_aligned_rodata;
26653
26654 static int trace_irq_vector_refcount;
26655 static DEFINE_MUTEX(irq_vector_mutex);
26656 diff --git a/arch/x86/kernel/traps.c b/arch/x86/kernel/traps.c
26657 index 8c8093b..c93f581 100644
26658 --- a/arch/x86/kernel/traps.c
26659 +++ b/arch/x86/kernel/traps.c
26660 @@ -66,7 +66,7 @@
26661 #include <asm/proto.h>
26662
26663 /* No need to be aligned, but done to keep all IDTs defined the same way. */
26664 -gate_desc debug_idt_table[NR_VECTORS] __page_aligned_bss;
26665 +gate_desc debug_idt_table[NR_VECTORS] __page_aligned_rodata;
26666 #else
26667 #include <asm/processor-flags.h>
26668 #include <asm/setup.h>
26669 @@ -75,7 +75,7 @@ asmlinkage int system_call(void);
26670 #endif
26671
26672 /* Must be page-aligned because the real IDT is used in a fixmap. */
26673 -gate_desc idt_table[NR_VECTORS] __page_aligned_bss;
26674 +gate_desc idt_table[NR_VECTORS] __page_aligned_rodata;
26675
26676 DECLARE_BITMAP(used_vectors, NR_VECTORS);
26677 EXPORT_SYMBOL_GPL(used_vectors);
26678 @@ -107,11 +107,11 @@ static inline void preempt_conditional_cli(struct pt_regs *regs)
26679 }
26680
26681 static int __kprobes
26682 -do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26683 +do_trap_no_signal(struct task_struct *tsk, int trapnr, const char *str,
26684 struct pt_regs *regs, long error_code)
26685 {
26686 #ifdef CONFIG_X86_32
26687 - if (regs->flags & X86_VM_MASK) {
26688 + if (v8086_mode(regs)) {
26689 /*
26690 * Traps 0, 1, 3, 4, and 5 should be forwarded to vm86.
26691 * On nmi (interrupt 2), do_trap should not be called.
26692 @@ -124,12 +124,24 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26693 return -1;
26694 }
26695 #endif
26696 - if (!user_mode(regs)) {
26697 + if (!user_mode_novm(regs)) {
26698 if (!fixup_exception(regs)) {
26699 tsk->thread.error_code = error_code;
26700 tsk->thread.trap_nr = trapnr;
26701 +
26702 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26703 + if (trapnr == 12 && ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS))
26704 + str = "PAX: suspicious stack segment fault";
26705 +#endif
26706 +
26707 die(str, regs, error_code);
26708 }
26709 +
26710 +#ifdef CONFIG_PAX_REFCOUNT
26711 + if (trapnr == 4)
26712 + pax_report_refcount_overflow(regs);
26713 +#endif
26714 +
26715 return 0;
26716 }
26717
26718 @@ -137,7 +149,7 @@ do_trap_no_signal(struct task_struct *tsk, int trapnr, char *str,
26719 }
26720
26721 static void __kprobes
26722 -do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26723 +do_trap(int trapnr, int signr, const char *str, struct pt_regs *regs,
26724 long error_code, siginfo_t *info)
26725 {
26726 struct task_struct *tsk = current;
26727 @@ -161,7 +173,7 @@ do_trap(int trapnr, int signr, char *str, struct pt_regs *regs,
26728 if (show_unhandled_signals && unhandled_signal(tsk, signr) &&
26729 printk_ratelimit()) {
26730 pr_info("%s[%d] trap %s ip:%lx sp:%lx error:%lx",
26731 - tsk->comm, tsk->pid, str,
26732 + tsk->comm, task_pid_nr(tsk), str,
26733 regs->ip, regs->sp, error_code);
26734 print_vma_addr(" in ", regs->ip);
26735 pr_cont("\n");
26736 @@ -277,7 +289,7 @@ do_general_protection(struct pt_regs *regs, long error_code)
26737 conditional_sti(regs);
26738
26739 #ifdef CONFIG_X86_32
26740 - if (regs->flags & X86_VM_MASK) {
26741 + if (v8086_mode(regs)) {
26742 local_irq_enable();
26743 handle_vm86_fault((struct kernel_vm86_regs *) regs, error_code);
26744 goto exit;
26745 @@ -285,18 +297,42 @@ do_general_protection(struct pt_regs *regs, long error_code)
26746 #endif
26747
26748 tsk = current;
26749 - if (!user_mode(regs)) {
26750 + if (!user_mode_novm(regs)) {
26751 if (fixup_exception(regs))
26752 goto exit;
26753
26754 tsk->thread.error_code = error_code;
26755 tsk->thread.trap_nr = X86_TRAP_GP;
26756 if (notify_die(DIE_GPF, "general protection fault", regs, error_code,
26757 - X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP)
26758 + X86_TRAP_GP, SIGSEGV) != NOTIFY_STOP) {
26759 +
26760 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26761 + if ((regs->cs & 0xFFFF) == __KERNEL_CS || (regs->cs & 0xFFFF) == __KERNEXEC_KERNEL_CS)
26762 + die("PAX: suspicious general protection fault", regs, error_code);
26763 + else
26764 +#endif
26765 +
26766 die("general protection fault", regs, error_code);
26767 + }
26768 goto exit;
26769 }
26770
26771 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
26772 + if (!(__supported_pte_mask & _PAGE_NX) && tsk->mm && (tsk->mm->pax_flags & MF_PAX_PAGEEXEC)) {
26773 + struct mm_struct *mm = tsk->mm;
26774 + unsigned long limit;
26775 +
26776 + down_write(&mm->mmap_sem);
26777 + limit = mm->context.user_cs_limit;
26778 + if (limit < TASK_SIZE) {
26779 + track_exec_limit(mm, limit, TASK_SIZE, VM_EXEC);
26780 + up_write(&mm->mmap_sem);
26781 + return;
26782 + }
26783 + up_write(&mm->mmap_sem);
26784 + }
26785 +#endif
26786 +
26787 tsk->thread.error_code = error_code;
26788 tsk->thread.trap_nr = X86_TRAP_GP;
26789
26790 @@ -457,7 +493,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26791 /* It's safe to allow irq's after DR6 has been saved */
26792 preempt_conditional_sti(regs);
26793
26794 - if (regs->flags & X86_VM_MASK) {
26795 + if (v8086_mode(regs)) {
26796 handle_vm86_trap((struct kernel_vm86_regs *) regs, error_code,
26797 X86_TRAP_DB);
26798 preempt_conditional_cli(regs);
26799 @@ -472,7 +508,7 @@ dotraplinkage void __kprobes do_debug(struct pt_regs *regs, long error_code)
26800 * We already checked v86 mode above, so we can check for kernel mode
26801 * by just checking the CPL of CS.
26802 */
26803 - if ((dr6 & DR_STEP) && !user_mode(regs)) {
26804 + if ((dr6 & DR_STEP) && !user_mode_novm(regs)) {
26805 tsk->thread.debugreg6 &= ~DR_STEP;
26806 set_tsk_thread_flag(tsk, TIF_SINGLESTEP);
26807 regs->flags &= ~X86_EFLAGS_TF;
26808 @@ -504,7 +540,7 @@ void math_error(struct pt_regs *regs, int error_code, int trapnr)
26809 return;
26810 conditional_sti(regs);
26811
26812 - if (!user_mode_vm(regs))
26813 + if (!user_mode(regs))
26814 {
26815 if (!fixup_exception(regs)) {
26816 task->thread.error_code = error_code;
26817 diff --git a/arch/x86/kernel/uprobes.c b/arch/x86/kernel/uprobes.c
26818 index 2ed8459..7cf329f 100644
26819 --- a/arch/x86/kernel/uprobes.c
26820 +++ b/arch/x86/kernel/uprobes.c
26821 @@ -629,7 +629,7 @@ int arch_uprobe_exception_notify(struct notifier_block *self, unsigned long val,
26822 int ret = NOTIFY_DONE;
26823
26824 /* We are only interested in userspace traps */
26825 - if (regs && !user_mode_vm(regs))
26826 + if (regs && !user_mode(regs))
26827 return NOTIFY_DONE;
26828
26829 switch (val) {
26830 @@ -719,7 +719,7 @@ arch_uretprobe_hijack_return_addr(unsigned long trampoline_vaddr, struct pt_regs
26831
26832 if (ncopied != rasize) {
26833 pr_err("uprobe: return address clobbered: pid=%d, %%sp=%#lx, "
26834 - "%%ip=%#lx\n", current->pid, regs->sp, regs->ip);
26835 + "%%ip=%#lx\n", task_pid_nr(current), regs->sp, regs->ip);
26836
26837 force_sig_info(SIGSEGV, SEND_SIG_FORCED, current);
26838 }
26839 diff --git a/arch/x86/kernel/verify_cpu.S b/arch/x86/kernel/verify_cpu.S
26840 index b9242ba..50c5edd 100644
26841 --- a/arch/x86/kernel/verify_cpu.S
26842 +++ b/arch/x86/kernel/verify_cpu.S
26843 @@ -20,6 +20,7 @@
26844 * arch/x86/boot/compressed/head_64.S: Boot cpu verification
26845 * arch/x86/kernel/trampoline_64.S: secondary processor verification
26846 * arch/x86/kernel/head_32.S: processor startup
26847 + * arch/x86/kernel/acpi/realmode/wakeup.S: 32bit processor resume
26848 *
26849 * verify_cpu, returns the status of longmode and SSE in register %eax.
26850 * 0: Success 1: Failure
26851 diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
26852 index e8edcf5..27f9344 100644
26853 --- a/arch/x86/kernel/vm86_32.c
26854 +++ b/arch/x86/kernel/vm86_32.c
26855 @@ -44,6 +44,7 @@
26856 #include <linux/ptrace.h>
26857 #include <linux/audit.h>
26858 #include <linux/stddef.h>
26859 +#include <linux/grsecurity.h>
26860
26861 #include <asm/uaccess.h>
26862 #include <asm/io.h>
26863 @@ -150,7 +151,7 @@ struct pt_regs *save_v86_state(struct kernel_vm86_regs *regs)
26864 do_exit(SIGSEGV);
26865 }
26866
26867 - tss = &per_cpu(init_tss, get_cpu());
26868 + tss = init_tss + get_cpu();
26869 current->thread.sp0 = current->thread.saved_sp0;
26870 current->thread.sysenter_cs = __KERNEL_CS;
26871 load_sp0(tss, &current->thread);
26872 @@ -214,6 +215,14 @@ SYSCALL_DEFINE1(vm86old, struct vm86_struct __user *, v86)
26873
26874 if (tsk->thread.saved_sp0)
26875 return -EPERM;
26876 +
26877 +#ifdef CONFIG_GRKERNSEC_VM86
26878 + if (!capable(CAP_SYS_RAWIO)) {
26879 + gr_handle_vm86();
26880 + return -EPERM;
26881 + }
26882 +#endif
26883 +
26884 tmp = copy_vm86_regs_from_user(&info.regs, &v86->regs,
26885 offsetof(struct kernel_vm86_struct, vm86plus) -
26886 sizeof(info.regs));
26887 @@ -238,6 +247,13 @@ SYSCALL_DEFINE2(vm86, unsigned long, cmd, unsigned long, arg)
26888 int tmp;
26889 struct vm86plus_struct __user *v86;
26890
26891 +#ifdef CONFIG_GRKERNSEC_VM86
26892 + if (!capable(CAP_SYS_RAWIO)) {
26893 + gr_handle_vm86();
26894 + return -EPERM;
26895 + }
26896 +#endif
26897 +
26898 tsk = current;
26899 switch (cmd) {
26900 case VM86_REQUEST_IRQ:
26901 @@ -318,7 +334,7 @@ static void do_sys_vm86(struct kernel_vm86_struct *info, struct task_struct *tsk
26902 tsk->thread.saved_fs = info->regs32->fs;
26903 tsk->thread.saved_gs = get_user_gs(info->regs32);
26904
26905 - tss = &per_cpu(init_tss, get_cpu());
26906 + tss = init_tss + get_cpu();
26907 tsk->thread.sp0 = (unsigned long) &info->VM86_TSS_ESP0;
26908 if (cpu_has_sep)
26909 tsk->thread.sysenter_cs = 0;
26910 @@ -525,7 +541,7 @@ static void do_int(struct kernel_vm86_regs *regs, int i,
26911 goto cannot_handle;
26912 if (i == 0x21 && is_revectored(AH(regs), &KVM86->int21_revectored))
26913 goto cannot_handle;
26914 - intr_ptr = (unsigned long __user *) (i << 2);
26915 + intr_ptr = (__force unsigned long __user *) (i << 2);
26916 if (get_user(segoffs, intr_ptr))
26917 goto cannot_handle;
26918 if ((segoffs >> 16) == BIOSSEG)
26919 diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
26920 index 10c4f30..65408b9 100644
26921 --- a/arch/x86/kernel/vmlinux.lds.S
26922 +++ b/arch/x86/kernel/vmlinux.lds.S
26923 @@ -26,6 +26,13 @@
26924 #include <asm/page_types.h>
26925 #include <asm/cache.h>
26926 #include <asm/boot.h>
26927 +#include <asm/segment.h>
26928 +
26929 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
26930 +#define __KERNEL_TEXT_OFFSET (LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR)
26931 +#else
26932 +#define __KERNEL_TEXT_OFFSET 0
26933 +#endif
26934
26935 #undef i386 /* in case the preprocessor is a 32bit one */
26936
26937 @@ -69,30 +76,43 @@ jiffies_64 = jiffies;
26938
26939 PHDRS {
26940 text PT_LOAD FLAGS(5); /* R_E */
26941 +#ifdef CONFIG_X86_32
26942 + module PT_LOAD FLAGS(5); /* R_E */
26943 +#endif
26944 +#ifdef CONFIG_XEN
26945 + rodata PT_LOAD FLAGS(5); /* R_E */
26946 +#else
26947 + rodata PT_LOAD FLAGS(4); /* R__ */
26948 +#endif
26949 data PT_LOAD FLAGS(6); /* RW_ */
26950 -#ifdef CONFIG_X86_64
26951 + init.begin PT_LOAD FLAGS(6); /* RW_ */
26952 #ifdef CONFIG_SMP
26953 percpu PT_LOAD FLAGS(6); /* RW_ */
26954 #endif
26955 + text.init PT_LOAD FLAGS(5); /* R_E */
26956 + text.exit PT_LOAD FLAGS(5); /* R_E */
26957 init PT_LOAD FLAGS(7); /* RWE */
26958 -#endif
26959 note PT_NOTE FLAGS(0); /* ___ */
26960 }
26961
26962 SECTIONS
26963 {
26964 #ifdef CONFIG_X86_32
26965 - . = LOAD_OFFSET + LOAD_PHYSICAL_ADDR;
26966 - phys_startup_32 = startup_32 - LOAD_OFFSET;
26967 + . = LOAD_OFFSET + ____LOAD_PHYSICAL_ADDR;
26968 #else
26969 - . = __START_KERNEL;
26970 - phys_startup_64 = startup_64 - LOAD_OFFSET;
26971 + . = __START_KERNEL;
26972 #endif
26973
26974 /* Text and read-only data */
26975 - .text : AT(ADDR(.text) - LOAD_OFFSET) {
26976 - _text = .;
26977 + .text (. - __KERNEL_TEXT_OFFSET): AT(ADDR(.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
26978 /* bootstrapping code */
26979 +#ifdef CONFIG_X86_32
26980 + phys_startup_32 = startup_32 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26981 +#else
26982 + phys_startup_64 = startup_64 - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26983 +#endif
26984 + __LOAD_PHYSICAL_ADDR = . - LOAD_OFFSET + __KERNEL_TEXT_OFFSET;
26985 + _text = .;
26986 HEAD_TEXT
26987 . = ALIGN(8);
26988 _stext = .;
26989 @@ -104,13 +124,47 @@ SECTIONS
26990 IRQENTRY_TEXT
26991 *(.fixup)
26992 *(.gnu.warning)
26993 - /* End of text section */
26994 - _etext = .;
26995 } :text = 0x9090
26996
26997 - NOTES :text :note
26998 + . += __KERNEL_TEXT_OFFSET;
26999
27000 - EXCEPTION_TABLE(16) :text = 0x9090
27001 +#ifdef CONFIG_X86_32
27002 + . = ALIGN(PAGE_SIZE);
27003 + .module.text : AT(ADDR(.module.text) - LOAD_OFFSET) {
27004 +
27005 +#ifdef CONFIG_PAX_KERNEXEC
27006 + MODULES_EXEC_VADDR = .;
27007 + BYTE(0)
27008 + . += (CONFIG_PAX_KERNEXEC_MODULE_TEXT * 1024 * 1024);
27009 + . = ALIGN(HPAGE_SIZE) - 1;
27010 + MODULES_EXEC_END = .;
27011 +#endif
27012 +
27013 + } :module
27014 +#endif
27015 +
27016 + .text.end : AT(ADDR(.text.end) - LOAD_OFFSET) {
27017 + /* End of text section */
27018 + BYTE(0)
27019 + _etext = . - __KERNEL_TEXT_OFFSET;
27020 + }
27021 +
27022 +#ifdef CONFIG_X86_32
27023 + . = ALIGN(PAGE_SIZE);
27024 + .rodata.page_aligned : AT(ADDR(.rodata.page_aligned) - LOAD_OFFSET) {
27025 + . = ALIGN(PAGE_SIZE);
27026 + *(.empty_zero_page)
27027 + *(.initial_pg_fixmap)
27028 + *(.initial_pg_pmd)
27029 + *(.initial_page_table)
27030 + *(.swapper_pg_dir)
27031 + } :rodata
27032 +#endif
27033 +
27034 + . = ALIGN(PAGE_SIZE);
27035 + NOTES :rodata :note
27036 +
27037 + EXCEPTION_TABLE(16) :rodata
27038
27039 #if defined(CONFIG_DEBUG_RODATA)
27040 /* .text should occupy whole number of pages */
27041 @@ -122,16 +176,20 @@ SECTIONS
27042
27043 /* Data */
27044 .data : AT(ADDR(.data) - LOAD_OFFSET) {
27045 +
27046 +#ifdef CONFIG_PAX_KERNEXEC
27047 + . = ALIGN(HPAGE_SIZE);
27048 +#else
27049 + . = ALIGN(PAGE_SIZE);
27050 +#endif
27051 +
27052 /* Start of data section */
27053 _sdata = .;
27054
27055 /* init_task */
27056 INIT_TASK_DATA(THREAD_SIZE)
27057
27058 -#ifdef CONFIG_X86_32
27059 - /* 32 bit has nosave before _edata */
27060 NOSAVE_DATA
27061 -#endif
27062
27063 PAGE_ALIGNED_DATA(PAGE_SIZE)
27064
27065 @@ -172,12 +230,19 @@ SECTIONS
27066 #endif /* CONFIG_X86_64 */
27067
27068 /* Init code and data - will be freed after init */
27069 - . = ALIGN(PAGE_SIZE);
27070 .init.begin : AT(ADDR(.init.begin) - LOAD_OFFSET) {
27071 + BYTE(0)
27072 +
27073 +#ifdef CONFIG_PAX_KERNEXEC
27074 + . = ALIGN(HPAGE_SIZE);
27075 +#else
27076 + . = ALIGN(PAGE_SIZE);
27077 +#endif
27078 +
27079 __init_begin = .; /* paired with __init_end */
27080 - }
27081 + } :init.begin
27082
27083 -#if defined(CONFIG_X86_64) && defined(CONFIG_SMP)
27084 +#ifdef CONFIG_SMP
27085 /*
27086 * percpu offsets are zero-based on SMP. PERCPU_VADDR() changes the
27087 * output PHDR, so the next output section - .init.text - should
27088 @@ -186,12 +251,27 @@ SECTIONS
27089 PERCPU_VADDR(INTERNODE_CACHE_BYTES, 0, :percpu)
27090 #endif
27091
27092 - INIT_TEXT_SECTION(PAGE_SIZE)
27093 -#ifdef CONFIG_X86_64
27094 - :init
27095 -#endif
27096 + . = ALIGN(PAGE_SIZE);
27097 + init_begin = .;
27098 + .init.text (. - __KERNEL_TEXT_OFFSET): AT(init_begin - LOAD_OFFSET) {
27099 + VMLINUX_SYMBOL(_sinittext) = .;
27100 + INIT_TEXT
27101 + VMLINUX_SYMBOL(_einittext) = .;
27102 + . = ALIGN(PAGE_SIZE);
27103 + } :text.init
27104
27105 - INIT_DATA_SECTION(16)
27106 + /*
27107 + * .exit.text is discard at runtime, not link time, to deal with
27108 + * references from .altinstructions and .eh_frame
27109 + */
27110 + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET + __KERNEL_TEXT_OFFSET) {
27111 + EXIT_TEXT
27112 + . = ALIGN(16);
27113 + } :text.exit
27114 + . = init_begin + SIZEOF(.init.text) + SIZEOF(.exit.text);
27115 +
27116 + . = ALIGN(PAGE_SIZE);
27117 + INIT_DATA_SECTION(16) :init
27118
27119 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
27120 __x86_cpu_dev_start = .;
27121 @@ -253,19 +333,12 @@ SECTIONS
27122 }
27123
27124 . = ALIGN(8);
27125 - /*
27126 - * .exit.text is discard at runtime, not link time, to deal with
27127 - * references from .altinstructions and .eh_frame
27128 - */
27129 - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) {
27130 - EXIT_TEXT
27131 - }
27132
27133 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) {
27134 EXIT_DATA
27135 }
27136
27137 -#if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
27138 +#ifndef CONFIG_SMP
27139 PERCPU_SECTION(INTERNODE_CACHE_BYTES)
27140 #endif
27141
27142 @@ -284,16 +357,10 @@ SECTIONS
27143 .smp_locks : AT(ADDR(.smp_locks) - LOAD_OFFSET) {
27144 __smp_locks = .;
27145 *(.smp_locks)
27146 - . = ALIGN(PAGE_SIZE);
27147 __smp_locks_end = .;
27148 + . = ALIGN(PAGE_SIZE);
27149 }
27150
27151 -#ifdef CONFIG_X86_64
27152 - .data_nosave : AT(ADDR(.data_nosave) - LOAD_OFFSET) {
27153 - NOSAVE_DATA
27154 - }
27155 -#endif
27156 -
27157 /* BSS */
27158 . = ALIGN(PAGE_SIZE);
27159 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
27160 @@ -309,6 +376,7 @@ SECTIONS
27161 __brk_base = .;
27162 . += 64 * 1024; /* 64k alignment slop space */
27163 *(.brk_reservation) /* areas brk users have reserved */
27164 + . = ALIGN(HPAGE_SIZE);
27165 __brk_limit = .;
27166 }
27167
27168 @@ -335,13 +403,12 @@ SECTIONS
27169 * for the boot processor.
27170 */
27171 #define INIT_PER_CPU(x) init_per_cpu__##x = x + __per_cpu_load
27172 -INIT_PER_CPU(gdt_page);
27173 INIT_PER_CPU(irq_stack_union);
27174
27175 /*
27176 * Build-time check on the image size:
27177 */
27178 -. = ASSERT((_end - _text <= KERNEL_IMAGE_SIZE),
27179 +. = ASSERT((_end - _text - __KERNEL_TEXT_OFFSET <= KERNEL_IMAGE_SIZE),
27180 "kernel image bigger than KERNEL_IMAGE_SIZE");
27181
27182 #ifdef CONFIG_SMP
27183 diff --git a/arch/x86/kernel/vsyscall_64.c b/arch/x86/kernel/vsyscall_64.c
27184 index 1f96f93..d5c8f7a 100644
27185 --- a/arch/x86/kernel/vsyscall_64.c
27186 +++ b/arch/x86/kernel/vsyscall_64.c
27187 @@ -56,15 +56,13 @@
27188 DEFINE_VVAR(int, vgetcpu_mode);
27189 DEFINE_VVAR(struct vsyscall_gtod_data, vsyscall_gtod_data);
27190
27191 -static enum { EMULATE, NATIVE, NONE } vsyscall_mode = EMULATE;
27192 +static enum { EMULATE, NONE } vsyscall_mode = EMULATE;
27193
27194 static int __init vsyscall_setup(char *str)
27195 {
27196 if (str) {
27197 if (!strcmp("emulate", str))
27198 vsyscall_mode = EMULATE;
27199 - else if (!strcmp("native", str))
27200 - vsyscall_mode = NATIVE;
27201 else if (!strcmp("none", str))
27202 vsyscall_mode = NONE;
27203 else
27204 @@ -323,8 +321,7 @@ do_ret:
27205 return true;
27206
27207 sigsegv:
27208 - force_sig(SIGSEGV, current);
27209 - return true;
27210 + do_group_exit(SIGKILL);
27211 }
27212
27213 /*
27214 @@ -377,10 +374,7 @@ void __init map_vsyscall(void)
27215 extern char __vvar_page;
27216 unsigned long physaddr_vvar_page = __pa_symbol(&__vvar_page);
27217
27218 - __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall,
27219 - vsyscall_mode == NATIVE
27220 - ? PAGE_KERNEL_VSYSCALL
27221 - : PAGE_KERNEL_VVAR);
27222 + __set_fixmap(VSYSCALL_FIRST_PAGE, physaddr_vsyscall, PAGE_KERNEL_VVAR);
27223 BUILD_BUG_ON((unsigned long)__fix_to_virt(VSYSCALL_FIRST_PAGE) !=
27224 (unsigned long)VSYSCALL_START);
27225
27226 diff --git a/arch/x86/kernel/x8664_ksyms_64.c b/arch/x86/kernel/x8664_ksyms_64.c
27227 index b014d94..e775258 100644
27228 --- a/arch/x86/kernel/x8664_ksyms_64.c
27229 +++ b/arch/x86/kernel/x8664_ksyms_64.c
27230 @@ -34,8 +34,6 @@ EXPORT_SYMBOL(copy_user_generic_string);
27231 EXPORT_SYMBOL(copy_user_generic_unrolled);
27232 EXPORT_SYMBOL(copy_user_enhanced_fast_string);
27233 EXPORT_SYMBOL(__copy_user_nocache);
27234 -EXPORT_SYMBOL(_copy_from_user);
27235 -EXPORT_SYMBOL(_copy_to_user);
27236
27237 EXPORT_SYMBOL(copy_page);
27238 EXPORT_SYMBOL(clear_page);
27239 @@ -66,3 +64,7 @@ EXPORT_SYMBOL(empty_zero_page);
27240 #ifndef CONFIG_PARAVIRT
27241 EXPORT_SYMBOL(native_load_gs_index);
27242 #endif
27243 +
27244 +#ifdef CONFIG_PAX_PER_CPU_PGD
27245 +EXPORT_SYMBOL(cpu_pgd);
27246 +#endif
27247 diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
27248 index 8ce0072..431a0e7 100644
27249 --- a/arch/x86/kernel/x86_init.c
27250 +++ b/arch/x86/kernel/x86_init.c
27251 @@ -93,7 +93,7 @@ struct x86_cpuinit_ops x86_cpuinit = {
27252 static void default_nmi_init(void) { };
27253 static int default_i8042_detect(void) { return 1; };
27254
27255 -struct x86_platform_ops x86_platform = {
27256 +struct x86_platform_ops x86_platform __read_only = {
27257 .calibrate_tsc = native_calibrate_tsc,
27258 .get_wallclock = mach_get_cmos_time,
27259 .set_wallclock = mach_set_rtc_mmss,
27260 @@ -109,7 +109,7 @@ struct x86_platform_ops x86_platform = {
27261 EXPORT_SYMBOL_GPL(x86_platform);
27262
27263 #if defined(CONFIG_PCI_MSI)
27264 -struct x86_msi_ops x86_msi = {
27265 +struct x86_msi_ops x86_msi __read_only = {
27266 .setup_msi_irqs = native_setup_msi_irqs,
27267 .compose_msi_msg = native_compose_msi_msg,
27268 .teardown_msi_irq = native_teardown_msi_irq,
27269 @@ -140,7 +140,7 @@ void arch_restore_msi_irqs(struct pci_dev *dev, int irq)
27270 }
27271 #endif
27272
27273 -struct x86_io_apic_ops x86_io_apic_ops = {
27274 +struct x86_io_apic_ops x86_io_apic_ops __read_only = {
27275 .init = native_io_apic_init_mappings,
27276 .read = native_io_apic_read,
27277 .write = native_io_apic_write,
27278 diff --git a/arch/x86/kernel/xsave.c b/arch/x86/kernel/xsave.c
27279 index 422fd82..c3687ca 100644
27280 --- a/arch/x86/kernel/xsave.c
27281 +++ b/arch/x86/kernel/xsave.c
27282 @@ -199,6 +199,7 @@ static inline int save_user_xstate(struct xsave_struct __user *buf)
27283 {
27284 int err;
27285
27286 + buf = (struct xsave_struct __user *)____m(buf);
27287 if (use_xsave())
27288 err = xsave_user(buf);
27289 else if (use_fxsr())
27290 @@ -311,6 +312,7 @@ sanitize_restored_xstate(struct task_struct *tsk,
27291 */
27292 static inline int restore_user_xstate(void __user *buf, u64 xbv, int fx_only)
27293 {
27294 + buf = (void __user *)____m(buf);
27295 if (use_xsave()) {
27296 if ((unsigned long)buf % 64 || fx_only) {
27297 u64 init_bv = pcntxt_mask & ~XSTATE_FPSSE;
27298 diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
27299 index b110fe6..d9c19f2 100644
27300 --- a/arch/x86/kvm/cpuid.c
27301 +++ b/arch/x86/kvm/cpuid.c
27302 @@ -124,15 +124,20 @@ int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
27303 struct kvm_cpuid2 *cpuid,
27304 struct kvm_cpuid_entry2 __user *entries)
27305 {
27306 - int r;
27307 + int r, i;
27308
27309 r = -E2BIG;
27310 if (cpuid->nent > KVM_MAX_CPUID_ENTRIES)
27311 goto out;
27312 r = -EFAULT;
27313 - if (copy_from_user(&vcpu->arch.cpuid_entries, entries,
27314 - cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
27315 + if (!access_ok(VERIFY_READ, entries, cpuid->nent * sizeof(struct kvm_cpuid_entry2)))
27316 goto out;
27317 + for (i = 0; i < cpuid->nent; ++i) {
27318 + struct kvm_cpuid_entry2 cpuid_entry;
27319 + if (__copy_from_user(&cpuid_entry, entries + i, sizeof(cpuid_entry)))
27320 + goto out;
27321 + vcpu->arch.cpuid_entries[i] = cpuid_entry;
27322 + }
27323 vcpu->arch.cpuid_nent = cpuid->nent;
27324 kvm_apic_set_version(vcpu);
27325 kvm_x86_ops->cpuid_update(vcpu);
27326 @@ -147,15 +152,19 @@ int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
27327 struct kvm_cpuid2 *cpuid,
27328 struct kvm_cpuid_entry2 __user *entries)
27329 {
27330 - int r;
27331 + int r, i;
27332
27333 r = -E2BIG;
27334 if (cpuid->nent < vcpu->arch.cpuid_nent)
27335 goto out;
27336 r = -EFAULT;
27337 - if (copy_to_user(entries, &vcpu->arch.cpuid_entries,
27338 - vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
27339 + if (!access_ok(VERIFY_WRITE, entries, vcpu->arch.cpuid_nent * sizeof(struct kvm_cpuid_entry2)))
27340 goto out;
27341 + for (i = 0; i < vcpu->arch.cpuid_nent; ++i) {
27342 + struct kvm_cpuid_entry2 cpuid_entry = vcpu->arch.cpuid_entries[i];
27343 + if (__copy_to_user(entries + i, &cpuid_entry, sizeof(cpuid_entry)))
27344 + goto out;
27345 + }
27346 return 0;
27347
27348 out:
27349 diff --git a/arch/x86/kvm/lapic.c b/arch/x86/kvm/lapic.c
27350 index 1673940..4bce95e 100644
27351 --- a/arch/x86/kvm/lapic.c
27352 +++ b/arch/x86/kvm/lapic.c
27353 @@ -55,7 +55,7 @@
27354 #define APIC_BUS_CYCLE_NS 1
27355
27356 /* #define apic_debug(fmt,arg...) printk(KERN_WARNING fmt,##arg) */
27357 -#define apic_debug(fmt, arg...)
27358 +#define apic_debug(fmt, arg...) do {} while (0)
27359
27360 #define APIC_LVT_NUM 6
27361 /* 14 is the version for Xeon and Pentium 8.4.8*/
27362 diff --git a/arch/x86/kvm/paging_tmpl.h b/arch/x86/kvm/paging_tmpl.h
27363 index ad75d77..a679d32 100644
27364 --- a/arch/x86/kvm/paging_tmpl.h
27365 +++ b/arch/x86/kvm/paging_tmpl.h
27366 @@ -331,7 +331,7 @@ retry_walk:
27367 if (unlikely(kvm_is_error_hva(host_addr)))
27368 goto error;
27369
27370 - ptep_user = (pt_element_t __user *)((void *)host_addr + offset);
27371 + ptep_user = (pt_element_t __force_user *)((void *)host_addr + offset);
27372 if (unlikely(__copy_from_user(&pte, ptep_user, sizeof(pte))))
27373 goto error;
27374 walker->ptep_user[walker->level - 1] = ptep_user;
27375 diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
27376 index c0bc803..6837a50 100644
27377 --- a/arch/x86/kvm/svm.c
27378 +++ b/arch/x86/kvm/svm.c
27379 @@ -3501,7 +3501,11 @@ static void reload_tss(struct kvm_vcpu *vcpu)
27380 int cpu = raw_smp_processor_id();
27381
27382 struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
27383 +
27384 + pax_open_kernel();
27385 sd->tss_desc->type = 9; /* available 32/64-bit TSS */
27386 + pax_close_kernel();
27387 +
27388 load_TR_desc();
27389 }
27390
27391 @@ -3902,6 +3906,10 @@ static void svm_vcpu_run(struct kvm_vcpu *vcpu)
27392 #endif
27393 #endif
27394
27395 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
27396 + __set_fs(current_thread_info()->addr_limit);
27397 +#endif
27398 +
27399 reload_tss(vcpu);
27400
27401 local_irq_disable();
27402 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
27403 index 6128914..8be1dd2 100644
27404 --- a/arch/x86/kvm/vmx.c
27405 +++ b/arch/x86/kvm/vmx.c
27406 @@ -1316,12 +1316,12 @@ static void vmcs_write64(unsigned long field, u64 value)
27407 #endif
27408 }
27409
27410 -static void vmcs_clear_bits(unsigned long field, u32 mask)
27411 +static void vmcs_clear_bits(unsigned long field, unsigned long mask)
27412 {
27413 vmcs_writel(field, vmcs_readl(field) & ~mask);
27414 }
27415
27416 -static void vmcs_set_bits(unsigned long field, u32 mask)
27417 +static void vmcs_set_bits(unsigned long field, unsigned long mask)
27418 {
27419 vmcs_writel(field, vmcs_readl(field) | mask);
27420 }
27421 @@ -1522,7 +1522,11 @@ static void reload_tss(void)
27422 struct desc_struct *descs;
27423
27424 descs = (void *)gdt->address;
27425 +
27426 + pax_open_kernel();
27427 descs[GDT_ENTRY_TSS].type = 9; /* available TSS */
27428 + pax_close_kernel();
27429 +
27430 load_TR_desc();
27431 }
27432
27433 @@ -1746,6 +1750,10 @@ static void vmx_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
27434 vmcs_writel(HOST_TR_BASE, kvm_read_tr_base()); /* 22.2.4 */
27435 vmcs_writel(HOST_GDTR_BASE, gdt->address); /* 22.2.4 */
27436
27437 +#ifdef CONFIG_PAX_PER_CPU_PGD
27438 + vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27439 +#endif
27440 +
27441 rdmsrl(MSR_IA32_SYSENTER_ESP, sysenter_esp);
27442 vmcs_writel(HOST_IA32_SYSENTER_ESP, sysenter_esp); /* 22.2.3 */
27443 vmx->loaded_vmcs->cpu = cpu;
27444 @@ -2037,7 +2045,7 @@ static void setup_msrs(struct vcpu_vmx *vmx)
27445 * reads and returns guest's timestamp counter "register"
27446 * guest_tsc = host_tsc + tsc_offset -- 21.3
27447 */
27448 -static u64 guest_read_tsc(void)
27449 +static u64 __intentional_overflow(-1) guest_read_tsc(void)
27450 {
27451 u64 host_tsc, tsc_offset;
27452
27453 @@ -2982,8 +2990,11 @@ static __init int hardware_setup(void)
27454 if (!cpu_has_vmx_flexpriority())
27455 flexpriority_enabled = 0;
27456
27457 - if (!cpu_has_vmx_tpr_shadow())
27458 - kvm_x86_ops->update_cr8_intercept = NULL;
27459 + if (!cpu_has_vmx_tpr_shadow()) {
27460 + pax_open_kernel();
27461 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27462 + pax_close_kernel();
27463 + }
27464
27465 if (enable_ept && !cpu_has_vmx_ept_2m_page())
27466 kvm_disable_largepages();
27467 @@ -2994,13 +3005,15 @@ static __init int hardware_setup(void)
27468 if (!cpu_has_vmx_apicv())
27469 enable_apicv = 0;
27470
27471 + pax_open_kernel();
27472 if (enable_apicv)
27473 - kvm_x86_ops->update_cr8_intercept = NULL;
27474 + *(void **)&kvm_x86_ops->update_cr8_intercept = NULL;
27475 else {
27476 - kvm_x86_ops->hwapic_irr_update = NULL;
27477 - kvm_x86_ops->deliver_posted_interrupt = NULL;
27478 - kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27479 + *(void **)&kvm_x86_ops->hwapic_irr_update = NULL;
27480 + *(void **)&kvm_x86_ops->deliver_posted_interrupt = NULL;
27481 + *(void **)&kvm_x86_ops->sync_pir_to_irr = vmx_sync_pir_to_irr_dummy;
27482 }
27483 + pax_close_kernel();
27484
27485 if (nested)
27486 nested_vmx_setup_ctls_msrs();
27487 @@ -4127,7 +4140,10 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27488
27489 vmcs_writel(HOST_CR0, read_cr0() & ~X86_CR0_TS); /* 22.2.3 */
27490 vmcs_writel(HOST_CR4, read_cr4()); /* 22.2.3, 22.2.5 */
27491 +
27492 +#ifndef CONFIG_PAX_PER_CPU_PGD
27493 vmcs_writel(HOST_CR3, read_cr3()); /* 22.2.3 FIXME: shadow tables */
27494 +#endif
27495
27496 vmcs_write16(HOST_CS_SELECTOR, __KERNEL_CS); /* 22.2.4 */
27497 #ifdef CONFIG_X86_64
27498 @@ -4149,7 +4165,7 @@ static void vmx_set_constant_host_state(struct vcpu_vmx *vmx)
27499 vmcs_writel(HOST_IDTR_BASE, dt.address); /* 22.2.4 */
27500 vmx->host_idt_base = dt.address;
27501
27502 - vmcs_writel(HOST_RIP, vmx_return); /* 22.2.5 */
27503 + vmcs_writel(HOST_RIP, ktla_ktva(vmx_return)); /* 22.2.5 */
27504
27505 rdmsr(MSR_IA32_SYSENTER_CS, low32, high32);
27506 vmcs_write32(HOST_IA32_SYSENTER_CS, low32);
27507 @@ -7191,6 +7207,12 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27508 "jmp 2f \n\t"
27509 "1: " __ex(ASM_VMX_VMRESUME) "\n\t"
27510 "2: "
27511 +
27512 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27513 + "ljmp %[cs],$3f\n\t"
27514 + "3: "
27515 +#endif
27516 +
27517 /* Save guest registers, load host registers, keep flags */
27518 "mov %0, %c[wordsize](%%" _ASM_SP ") \n\t"
27519 "pop %0 \n\t"
27520 @@ -7243,6 +7265,11 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27521 #endif
27522 [cr2]"i"(offsetof(struct vcpu_vmx, vcpu.arch.cr2)),
27523 [wordsize]"i"(sizeof(ulong))
27524 +
27525 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
27526 + ,[cs]"i"(__KERNEL_CS)
27527 +#endif
27528 +
27529 : "cc", "memory"
27530 #ifdef CONFIG_X86_64
27531 , "rax", "rbx", "rdi", "rsi"
27532 @@ -7256,7 +7283,7 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27533 if (debugctlmsr)
27534 update_debugctlmsr(debugctlmsr);
27535
27536 -#ifndef CONFIG_X86_64
27537 +#ifdef CONFIG_X86_32
27538 /*
27539 * The sysexit path does not restore ds/es, so we must set them to
27540 * a reasonable value ourselves.
27541 @@ -7265,8 +7292,18 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
27542 * may be executed in interrupt context, which saves and restore segments
27543 * around it, nullifying its effect.
27544 */
27545 - loadsegment(ds, __USER_DS);
27546 - loadsegment(es, __USER_DS);
27547 + loadsegment(ds, __KERNEL_DS);
27548 + loadsegment(es, __KERNEL_DS);
27549 + loadsegment(ss, __KERNEL_DS);
27550 +
27551 +#ifdef CONFIG_PAX_KERNEXEC
27552 + loadsegment(fs, __KERNEL_PERCPU);
27553 +#endif
27554 +
27555 +#ifdef CONFIG_PAX_MEMORY_UDEREF
27556 + __set_fs(current_thread_info()->addr_limit);
27557 +#endif
27558 +
27559 #endif
27560
27561 vcpu->arch.regs_avail = ~((1 << VCPU_REGS_RIP) | (1 << VCPU_REGS_RSP)
27562 diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
27563 index eb9b9c9..0f30b12 100644
27564 --- a/arch/x86/kvm/x86.c
27565 +++ b/arch/x86/kvm/x86.c
27566 @@ -1779,8 +1779,8 @@ static int xen_hvm_config(struct kvm_vcpu *vcpu, u64 data)
27567 {
27568 struct kvm *kvm = vcpu->kvm;
27569 int lm = is_long_mode(vcpu);
27570 - u8 *blob_addr = lm ? (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27571 - : (u8 *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27572 + u8 __user *blob_addr = lm ? (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_64
27573 + : (u8 __user *)(long)kvm->arch.xen_hvm_config.blob_addr_32;
27574 u8 blob_size = lm ? kvm->arch.xen_hvm_config.blob_size_64
27575 : kvm->arch.xen_hvm_config.blob_size_32;
27576 u32 page_num = data & ~PAGE_MASK;
27577 @@ -2663,6 +2663,8 @@ long kvm_arch_dev_ioctl(struct file *filp,
27578 if (n < msr_list.nmsrs)
27579 goto out;
27580 r = -EFAULT;
27581 + if (num_msrs_to_save > ARRAY_SIZE(msrs_to_save))
27582 + goto out;
27583 if (copy_to_user(user_msr_list->indices, &msrs_to_save,
27584 num_msrs_to_save * sizeof(u32)))
27585 goto out;
27586 @@ -5461,7 +5463,7 @@ static struct notifier_block pvclock_gtod_notifier = {
27587 };
27588 #endif
27589
27590 -int kvm_arch_init(void *opaque)
27591 +int kvm_arch_init(const void *opaque)
27592 {
27593 int r;
27594 struct kvm_x86_ops *ops = opaque;
27595 diff --git a/arch/x86/lguest/boot.c b/arch/x86/lguest/boot.c
27596 index bdf8532..f63c587 100644
27597 --- a/arch/x86/lguest/boot.c
27598 +++ b/arch/x86/lguest/boot.c
27599 @@ -1206,9 +1206,10 @@ static __init int early_put_chars(u32 vtermno, const char *buf, int count)
27600 * Rebooting also tells the Host we're finished, but the RESTART flag tells the
27601 * Launcher to reboot us.
27602 */
27603 -static void lguest_restart(char *reason)
27604 +static __noreturn void lguest_restart(char *reason)
27605 {
27606 hcall(LHCALL_SHUTDOWN, __pa(reason), LGUEST_SHUTDOWN_RESTART, 0, 0);
27607 + BUG();
27608 }
27609
27610 /*G:050
27611 diff --git a/arch/x86/lib/atomic64_386_32.S b/arch/x86/lib/atomic64_386_32.S
27612 index 00933d5..3a64af9 100644
27613 --- a/arch/x86/lib/atomic64_386_32.S
27614 +++ b/arch/x86/lib/atomic64_386_32.S
27615 @@ -48,6 +48,10 @@ BEGIN(read)
27616 movl (v), %eax
27617 movl 4(v), %edx
27618 RET_ENDP
27619 +BEGIN(read_unchecked)
27620 + movl (v), %eax
27621 + movl 4(v), %edx
27622 +RET_ENDP
27623 #undef v
27624
27625 #define v %esi
27626 @@ -55,6 +59,10 @@ BEGIN(set)
27627 movl %ebx, (v)
27628 movl %ecx, 4(v)
27629 RET_ENDP
27630 +BEGIN(set_unchecked)
27631 + movl %ebx, (v)
27632 + movl %ecx, 4(v)
27633 +RET_ENDP
27634 #undef v
27635
27636 #define v %esi
27637 @@ -70,6 +78,20 @@ RET_ENDP
27638 BEGIN(add)
27639 addl %eax, (v)
27640 adcl %edx, 4(v)
27641 +
27642 +#ifdef CONFIG_PAX_REFCOUNT
27643 + jno 0f
27644 + subl %eax, (v)
27645 + sbbl %edx, 4(v)
27646 + int $4
27647 +0:
27648 + _ASM_EXTABLE(0b, 0b)
27649 +#endif
27650 +
27651 +RET_ENDP
27652 +BEGIN(add_unchecked)
27653 + addl %eax, (v)
27654 + adcl %edx, 4(v)
27655 RET_ENDP
27656 #undef v
27657
27658 @@ -77,6 +99,24 @@ RET_ENDP
27659 BEGIN(add_return)
27660 addl (v), %eax
27661 adcl 4(v), %edx
27662 +
27663 +#ifdef CONFIG_PAX_REFCOUNT
27664 + into
27665 +1234:
27666 + _ASM_EXTABLE(1234b, 2f)
27667 +#endif
27668 +
27669 + movl %eax, (v)
27670 + movl %edx, 4(v)
27671 +
27672 +#ifdef CONFIG_PAX_REFCOUNT
27673 +2:
27674 +#endif
27675 +
27676 +RET_ENDP
27677 +BEGIN(add_return_unchecked)
27678 + addl (v), %eax
27679 + adcl 4(v), %edx
27680 movl %eax, (v)
27681 movl %edx, 4(v)
27682 RET_ENDP
27683 @@ -86,6 +126,20 @@ RET_ENDP
27684 BEGIN(sub)
27685 subl %eax, (v)
27686 sbbl %edx, 4(v)
27687 +
27688 +#ifdef CONFIG_PAX_REFCOUNT
27689 + jno 0f
27690 + addl %eax, (v)
27691 + adcl %edx, 4(v)
27692 + int $4
27693 +0:
27694 + _ASM_EXTABLE(0b, 0b)
27695 +#endif
27696 +
27697 +RET_ENDP
27698 +BEGIN(sub_unchecked)
27699 + subl %eax, (v)
27700 + sbbl %edx, 4(v)
27701 RET_ENDP
27702 #undef v
27703
27704 @@ -96,6 +150,27 @@ BEGIN(sub_return)
27705 sbbl $0, %edx
27706 addl (v), %eax
27707 adcl 4(v), %edx
27708 +
27709 +#ifdef CONFIG_PAX_REFCOUNT
27710 + into
27711 +1234:
27712 + _ASM_EXTABLE(1234b, 2f)
27713 +#endif
27714 +
27715 + movl %eax, (v)
27716 + movl %edx, 4(v)
27717 +
27718 +#ifdef CONFIG_PAX_REFCOUNT
27719 +2:
27720 +#endif
27721 +
27722 +RET_ENDP
27723 +BEGIN(sub_return_unchecked)
27724 + negl %edx
27725 + negl %eax
27726 + sbbl $0, %edx
27727 + addl (v), %eax
27728 + adcl 4(v), %edx
27729 movl %eax, (v)
27730 movl %edx, 4(v)
27731 RET_ENDP
27732 @@ -105,6 +180,20 @@ RET_ENDP
27733 BEGIN(inc)
27734 addl $1, (v)
27735 adcl $0, 4(v)
27736 +
27737 +#ifdef CONFIG_PAX_REFCOUNT
27738 + jno 0f
27739 + subl $1, (v)
27740 + sbbl $0, 4(v)
27741 + int $4
27742 +0:
27743 + _ASM_EXTABLE(0b, 0b)
27744 +#endif
27745 +
27746 +RET_ENDP
27747 +BEGIN(inc_unchecked)
27748 + addl $1, (v)
27749 + adcl $0, 4(v)
27750 RET_ENDP
27751 #undef v
27752
27753 @@ -114,6 +203,26 @@ BEGIN(inc_return)
27754 movl 4(v), %edx
27755 addl $1, %eax
27756 adcl $0, %edx
27757 +
27758 +#ifdef CONFIG_PAX_REFCOUNT
27759 + into
27760 +1234:
27761 + _ASM_EXTABLE(1234b, 2f)
27762 +#endif
27763 +
27764 + movl %eax, (v)
27765 + movl %edx, 4(v)
27766 +
27767 +#ifdef CONFIG_PAX_REFCOUNT
27768 +2:
27769 +#endif
27770 +
27771 +RET_ENDP
27772 +BEGIN(inc_return_unchecked)
27773 + movl (v), %eax
27774 + movl 4(v), %edx
27775 + addl $1, %eax
27776 + adcl $0, %edx
27777 movl %eax, (v)
27778 movl %edx, 4(v)
27779 RET_ENDP
27780 @@ -123,6 +232,20 @@ RET_ENDP
27781 BEGIN(dec)
27782 subl $1, (v)
27783 sbbl $0, 4(v)
27784 +
27785 +#ifdef CONFIG_PAX_REFCOUNT
27786 + jno 0f
27787 + addl $1, (v)
27788 + adcl $0, 4(v)
27789 + int $4
27790 +0:
27791 + _ASM_EXTABLE(0b, 0b)
27792 +#endif
27793 +
27794 +RET_ENDP
27795 +BEGIN(dec_unchecked)
27796 + subl $1, (v)
27797 + sbbl $0, 4(v)
27798 RET_ENDP
27799 #undef v
27800
27801 @@ -132,6 +255,26 @@ BEGIN(dec_return)
27802 movl 4(v), %edx
27803 subl $1, %eax
27804 sbbl $0, %edx
27805 +
27806 +#ifdef CONFIG_PAX_REFCOUNT
27807 + into
27808 +1234:
27809 + _ASM_EXTABLE(1234b, 2f)
27810 +#endif
27811 +
27812 + movl %eax, (v)
27813 + movl %edx, 4(v)
27814 +
27815 +#ifdef CONFIG_PAX_REFCOUNT
27816 +2:
27817 +#endif
27818 +
27819 +RET_ENDP
27820 +BEGIN(dec_return_unchecked)
27821 + movl (v), %eax
27822 + movl 4(v), %edx
27823 + subl $1, %eax
27824 + sbbl $0, %edx
27825 movl %eax, (v)
27826 movl %edx, 4(v)
27827 RET_ENDP
27828 @@ -143,6 +286,13 @@ BEGIN(add_unless)
27829 adcl %edx, %edi
27830 addl (v), %eax
27831 adcl 4(v), %edx
27832 +
27833 +#ifdef CONFIG_PAX_REFCOUNT
27834 + into
27835 +1234:
27836 + _ASM_EXTABLE(1234b, 2f)
27837 +#endif
27838 +
27839 cmpl %eax, %ecx
27840 je 3f
27841 1:
27842 @@ -168,6 +318,13 @@ BEGIN(inc_not_zero)
27843 1:
27844 addl $1, %eax
27845 adcl $0, %edx
27846 +
27847 +#ifdef CONFIG_PAX_REFCOUNT
27848 + into
27849 +1234:
27850 + _ASM_EXTABLE(1234b, 2f)
27851 +#endif
27852 +
27853 movl %eax, (v)
27854 movl %edx, 4(v)
27855 movl $1, %eax
27856 @@ -186,6 +343,13 @@ BEGIN(dec_if_positive)
27857 movl 4(v), %edx
27858 subl $1, %eax
27859 sbbl $0, %edx
27860 +
27861 +#ifdef CONFIG_PAX_REFCOUNT
27862 + into
27863 +1234:
27864 + _ASM_EXTABLE(1234b, 1f)
27865 +#endif
27866 +
27867 js 1f
27868 movl %eax, (v)
27869 movl %edx, 4(v)
27870 diff --git a/arch/x86/lib/atomic64_cx8_32.S b/arch/x86/lib/atomic64_cx8_32.S
27871 index f5cc9eb..51fa319 100644
27872 --- a/arch/x86/lib/atomic64_cx8_32.S
27873 +++ b/arch/x86/lib/atomic64_cx8_32.S
27874 @@ -35,10 +35,20 @@ ENTRY(atomic64_read_cx8)
27875 CFI_STARTPROC
27876
27877 read64 %ecx
27878 + pax_force_retaddr
27879 ret
27880 CFI_ENDPROC
27881 ENDPROC(atomic64_read_cx8)
27882
27883 +ENTRY(atomic64_read_unchecked_cx8)
27884 + CFI_STARTPROC
27885 +
27886 + read64 %ecx
27887 + pax_force_retaddr
27888 + ret
27889 + CFI_ENDPROC
27890 +ENDPROC(atomic64_read_unchecked_cx8)
27891 +
27892 ENTRY(atomic64_set_cx8)
27893 CFI_STARTPROC
27894
27895 @@ -48,10 +58,25 @@ ENTRY(atomic64_set_cx8)
27896 cmpxchg8b (%esi)
27897 jne 1b
27898
27899 + pax_force_retaddr
27900 ret
27901 CFI_ENDPROC
27902 ENDPROC(atomic64_set_cx8)
27903
27904 +ENTRY(atomic64_set_unchecked_cx8)
27905 + CFI_STARTPROC
27906 +
27907 +1:
27908 +/* we don't need LOCK_PREFIX since aligned 64-bit writes
27909 + * are atomic on 586 and newer */
27910 + cmpxchg8b (%esi)
27911 + jne 1b
27912 +
27913 + pax_force_retaddr
27914 + ret
27915 + CFI_ENDPROC
27916 +ENDPROC(atomic64_set_unchecked_cx8)
27917 +
27918 ENTRY(atomic64_xchg_cx8)
27919 CFI_STARTPROC
27920
27921 @@ -60,12 +85,13 @@ ENTRY(atomic64_xchg_cx8)
27922 cmpxchg8b (%esi)
27923 jne 1b
27924
27925 + pax_force_retaddr
27926 ret
27927 CFI_ENDPROC
27928 ENDPROC(atomic64_xchg_cx8)
27929
27930 -.macro addsub_return func ins insc
27931 -ENTRY(atomic64_\func\()_return_cx8)
27932 +.macro addsub_return func ins insc unchecked=""
27933 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27934 CFI_STARTPROC
27935 SAVE ebp
27936 SAVE ebx
27937 @@ -82,27 +108,44 @@ ENTRY(atomic64_\func\()_return_cx8)
27938 movl %edx, %ecx
27939 \ins\()l %esi, %ebx
27940 \insc\()l %edi, %ecx
27941 +
27942 +.ifb \unchecked
27943 +#ifdef CONFIG_PAX_REFCOUNT
27944 + into
27945 +2:
27946 + _ASM_EXTABLE(2b, 3f)
27947 +#endif
27948 +.endif
27949 +
27950 LOCK_PREFIX
27951 cmpxchg8b (%ebp)
27952 jne 1b
27953 -
27954 -10:
27955 movl %ebx, %eax
27956 movl %ecx, %edx
27957 +
27958 +.ifb \unchecked
27959 +#ifdef CONFIG_PAX_REFCOUNT
27960 +3:
27961 +#endif
27962 +.endif
27963 +
27964 RESTORE edi
27965 RESTORE esi
27966 RESTORE ebx
27967 RESTORE ebp
27968 + pax_force_retaddr
27969 ret
27970 CFI_ENDPROC
27971 -ENDPROC(atomic64_\func\()_return_cx8)
27972 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
27973 .endm
27974
27975 addsub_return add add adc
27976 addsub_return sub sub sbb
27977 +addsub_return add add adc _unchecked
27978 +addsub_return sub sub sbb _unchecked
27979
27980 -.macro incdec_return func ins insc
27981 -ENTRY(atomic64_\func\()_return_cx8)
27982 +.macro incdec_return func ins insc unchecked=""
27983 +ENTRY(atomic64_\func\()_return\unchecked\()_cx8)
27984 CFI_STARTPROC
27985 SAVE ebx
27986
27987 @@ -112,21 +155,39 @@ ENTRY(atomic64_\func\()_return_cx8)
27988 movl %edx, %ecx
27989 \ins\()l $1, %ebx
27990 \insc\()l $0, %ecx
27991 +
27992 +.ifb \unchecked
27993 +#ifdef CONFIG_PAX_REFCOUNT
27994 + into
27995 +2:
27996 + _ASM_EXTABLE(2b, 3f)
27997 +#endif
27998 +.endif
27999 +
28000 LOCK_PREFIX
28001 cmpxchg8b (%esi)
28002 jne 1b
28003
28004 -10:
28005 movl %ebx, %eax
28006 movl %ecx, %edx
28007 +
28008 +.ifb \unchecked
28009 +#ifdef CONFIG_PAX_REFCOUNT
28010 +3:
28011 +#endif
28012 +.endif
28013 +
28014 RESTORE ebx
28015 + pax_force_retaddr
28016 ret
28017 CFI_ENDPROC
28018 -ENDPROC(atomic64_\func\()_return_cx8)
28019 +ENDPROC(atomic64_\func\()_return\unchecked\()_cx8)
28020 .endm
28021
28022 incdec_return inc add adc
28023 incdec_return dec sub sbb
28024 +incdec_return inc add adc _unchecked
28025 +incdec_return dec sub sbb _unchecked
28026
28027 ENTRY(atomic64_dec_if_positive_cx8)
28028 CFI_STARTPROC
28029 @@ -138,6 +199,13 @@ ENTRY(atomic64_dec_if_positive_cx8)
28030 movl %edx, %ecx
28031 subl $1, %ebx
28032 sbb $0, %ecx
28033 +
28034 +#ifdef CONFIG_PAX_REFCOUNT
28035 + into
28036 +1234:
28037 + _ASM_EXTABLE(1234b, 2f)
28038 +#endif
28039 +
28040 js 2f
28041 LOCK_PREFIX
28042 cmpxchg8b (%esi)
28043 @@ -147,6 +215,7 @@ ENTRY(atomic64_dec_if_positive_cx8)
28044 movl %ebx, %eax
28045 movl %ecx, %edx
28046 RESTORE ebx
28047 + pax_force_retaddr
28048 ret
28049 CFI_ENDPROC
28050 ENDPROC(atomic64_dec_if_positive_cx8)
28051 @@ -171,6 +240,13 @@ ENTRY(atomic64_add_unless_cx8)
28052 movl %edx, %ecx
28053 addl %ebp, %ebx
28054 adcl %edi, %ecx
28055 +
28056 +#ifdef CONFIG_PAX_REFCOUNT
28057 + into
28058 +1234:
28059 + _ASM_EXTABLE(1234b, 3f)
28060 +#endif
28061 +
28062 LOCK_PREFIX
28063 cmpxchg8b (%esi)
28064 jne 1b
28065 @@ -181,6 +257,7 @@ ENTRY(atomic64_add_unless_cx8)
28066 CFI_ADJUST_CFA_OFFSET -8
28067 RESTORE ebx
28068 RESTORE ebp
28069 + pax_force_retaddr
28070 ret
28071 4:
28072 cmpl %edx, 4(%esp)
28073 @@ -203,6 +280,13 @@ ENTRY(atomic64_inc_not_zero_cx8)
28074 xorl %ecx, %ecx
28075 addl $1, %ebx
28076 adcl %edx, %ecx
28077 +
28078 +#ifdef CONFIG_PAX_REFCOUNT
28079 + into
28080 +1234:
28081 + _ASM_EXTABLE(1234b, 3f)
28082 +#endif
28083 +
28084 LOCK_PREFIX
28085 cmpxchg8b (%esi)
28086 jne 1b
28087 @@ -210,6 +294,7 @@ ENTRY(atomic64_inc_not_zero_cx8)
28088 movl $1, %eax
28089 3:
28090 RESTORE ebx
28091 + pax_force_retaddr
28092 ret
28093 CFI_ENDPROC
28094 ENDPROC(atomic64_inc_not_zero_cx8)
28095 diff --git a/arch/x86/lib/checksum_32.S b/arch/x86/lib/checksum_32.S
28096 index e78b8ee..7e173a8 100644
28097 --- a/arch/x86/lib/checksum_32.S
28098 +++ b/arch/x86/lib/checksum_32.S
28099 @@ -29,7 +29,8 @@
28100 #include <asm/dwarf2.h>
28101 #include <asm/errno.h>
28102 #include <asm/asm.h>
28103 -
28104 +#include <asm/segment.h>
28105 +
28106 /*
28107 * computes a partial checksum, e.g. for TCP/UDP fragments
28108 */
28109 @@ -293,9 +294,24 @@ unsigned int csum_partial_copy_generic (const char *src, char *dst,
28110
28111 #define ARGBASE 16
28112 #define FP 12
28113 -
28114 -ENTRY(csum_partial_copy_generic)
28115 +
28116 +ENTRY(csum_partial_copy_generic_to_user)
28117 CFI_STARTPROC
28118 +
28119 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28120 + pushl_cfi %gs
28121 + popl_cfi %es
28122 + jmp csum_partial_copy_generic
28123 +#endif
28124 +
28125 +ENTRY(csum_partial_copy_generic_from_user)
28126 +
28127 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28128 + pushl_cfi %gs
28129 + popl_cfi %ds
28130 +#endif
28131 +
28132 +ENTRY(csum_partial_copy_generic)
28133 subl $4,%esp
28134 CFI_ADJUST_CFA_OFFSET 4
28135 pushl_cfi %edi
28136 @@ -317,7 +333,7 @@ ENTRY(csum_partial_copy_generic)
28137 jmp 4f
28138 SRC(1: movw (%esi), %bx )
28139 addl $2, %esi
28140 -DST( movw %bx, (%edi) )
28141 +DST( movw %bx, %es:(%edi) )
28142 addl $2, %edi
28143 addw %bx, %ax
28144 adcl $0, %eax
28145 @@ -329,30 +345,30 @@ DST( movw %bx, (%edi) )
28146 SRC(1: movl (%esi), %ebx )
28147 SRC( movl 4(%esi), %edx )
28148 adcl %ebx, %eax
28149 -DST( movl %ebx, (%edi) )
28150 +DST( movl %ebx, %es:(%edi) )
28151 adcl %edx, %eax
28152 -DST( movl %edx, 4(%edi) )
28153 +DST( movl %edx, %es:4(%edi) )
28154
28155 SRC( movl 8(%esi), %ebx )
28156 SRC( movl 12(%esi), %edx )
28157 adcl %ebx, %eax
28158 -DST( movl %ebx, 8(%edi) )
28159 +DST( movl %ebx, %es:8(%edi) )
28160 adcl %edx, %eax
28161 -DST( movl %edx, 12(%edi) )
28162 +DST( movl %edx, %es:12(%edi) )
28163
28164 SRC( movl 16(%esi), %ebx )
28165 SRC( movl 20(%esi), %edx )
28166 adcl %ebx, %eax
28167 -DST( movl %ebx, 16(%edi) )
28168 +DST( movl %ebx, %es:16(%edi) )
28169 adcl %edx, %eax
28170 -DST( movl %edx, 20(%edi) )
28171 +DST( movl %edx, %es:20(%edi) )
28172
28173 SRC( movl 24(%esi), %ebx )
28174 SRC( movl 28(%esi), %edx )
28175 adcl %ebx, %eax
28176 -DST( movl %ebx, 24(%edi) )
28177 +DST( movl %ebx, %es:24(%edi) )
28178 adcl %edx, %eax
28179 -DST( movl %edx, 28(%edi) )
28180 +DST( movl %edx, %es:28(%edi) )
28181
28182 lea 32(%esi), %esi
28183 lea 32(%edi), %edi
28184 @@ -366,7 +382,7 @@ DST( movl %edx, 28(%edi) )
28185 shrl $2, %edx # This clears CF
28186 SRC(3: movl (%esi), %ebx )
28187 adcl %ebx, %eax
28188 -DST( movl %ebx, (%edi) )
28189 +DST( movl %ebx, %es:(%edi) )
28190 lea 4(%esi), %esi
28191 lea 4(%edi), %edi
28192 dec %edx
28193 @@ -378,12 +394,12 @@ DST( movl %ebx, (%edi) )
28194 jb 5f
28195 SRC( movw (%esi), %cx )
28196 leal 2(%esi), %esi
28197 -DST( movw %cx, (%edi) )
28198 +DST( movw %cx, %es:(%edi) )
28199 leal 2(%edi), %edi
28200 je 6f
28201 shll $16,%ecx
28202 SRC(5: movb (%esi), %cl )
28203 -DST( movb %cl, (%edi) )
28204 +DST( movb %cl, %es:(%edi) )
28205 6: addl %ecx, %eax
28206 adcl $0, %eax
28207 7:
28208 @@ -394,7 +410,7 @@ DST( movb %cl, (%edi) )
28209
28210 6001:
28211 movl ARGBASE+20(%esp), %ebx # src_err_ptr
28212 - movl $-EFAULT, (%ebx)
28213 + movl $-EFAULT, %ss:(%ebx)
28214
28215 # zero the complete destination - computing the rest
28216 # is too much work
28217 @@ -407,11 +423,15 @@ DST( movb %cl, (%edi) )
28218
28219 6002:
28220 movl ARGBASE+24(%esp), %ebx # dst_err_ptr
28221 - movl $-EFAULT,(%ebx)
28222 + movl $-EFAULT,%ss:(%ebx)
28223 jmp 5000b
28224
28225 .previous
28226
28227 + pushl_cfi %ss
28228 + popl_cfi %ds
28229 + pushl_cfi %ss
28230 + popl_cfi %es
28231 popl_cfi %ebx
28232 CFI_RESTORE ebx
28233 popl_cfi %esi
28234 @@ -421,26 +441,43 @@ DST( movb %cl, (%edi) )
28235 popl_cfi %ecx # equivalent to addl $4,%esp
28236 ret
28237 CFI_ENDPROC
28238 -ENDPROC(csum_partial_copy_generic)
28239 +ENDPROC(csum_partial_copy_generic_to_user)
28240
28241 #else
28242
28243 /* Version for PentiumII/PPro */
28244
28245 #define ROUND1(x) \
28246 + nop; nop; nop; \
28247 SRC(movl x(%esi), %ebx ) ; \
28248 addl %ebx, %eax ; \
28249 - DST(movl %ebx, x(%edi) ) ;
28250 + DST(movl %ebx, %es:x(%edi)) ;
28251
28252 #define ROUND(x) \
28253 + nop; nop; nop; \
28254 SRC(movl x(%esi), %ebx ) ; \
28255 adcl %ebx, %eax ; \
28256 - DST(movl %ebx, x(%edi) ) ;
28257 + DST(movl %ebx, %es:x(%edi)) ;
28258
28259 #define ARGBASE 12
28260 -
28261 -ENTRY(csum_partial_copy_generic)
28262 +
28263 +ENTRY(csum_partial_copy_generic_to_user)
28264 CFI_STARTPROC
28265 +
28266 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28267 + pushl_cfi %gs
28268 + popl_cfi %es
28269 + jmp csum_partial_copy_generic
28270 +#endif
28271 +
28272 +ENTRY(csum_partial_copy_generic_from_user)
28273 +
28274 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28275 + pushl_cfi %gs
28276 + popl_cfi %ds
28277 +#endif
28278 +
28279 +ENTRY(csum_partial_copy_generic)
28280 pushl_cfi %ebx
28281 CFI_REL_OFFSET ebx, 0
28282 pushl_cfi %edi
28283 @@ -461,7 +498,7 @@ ENTRY(csum_partial_copy_generic)
28284 subl %ebx, %edi
28285 lea -1(%esi),%edx
28286 andl $-32,%edx
28287 - lea 3f(%ebx,%ebx), %ebx
28288 + lea 3f(%ebx,%ebx,2), %ebx
28289 testl %esi, %esi
28290 jmp *%ebx
28291 1: addl $64,%esi
28292 @@ -482,19 +519,19 @@ ENTRY(csum_partial_copy_generic)
28293 jb 5f
28294 SRC( movw (%esi), %dx )
28295 leal 2(%esi), %esi
28296 -DST( movw %dx, (%edi) )
28297 +DST( movw %dx, %es:(%edi) )
28298 leal 2(%edi), %edi
28299 je 6f
28300 shll $16,%edx
28301 5:
28302 SRC( movb (%esi), %dl )
28303 -DST( movb %dl, (%edi) )
28304 +DST( movb %dl, %es:(%edi) )
28305 6: addl %edx, %eax
28306 adcl $0, %eax
28307 7:
28308 .section .fixup, "ax"
28309 6001: movl ARGBASE+20(%esp), %ebx # src_err_ptr
28310 - movl $-EFAULT, (%ebx)
28311 + movl $-EFAULT, %ss:(%ebx)
28312 # zero the complete destination (computing the rest is too much work)
28313 movl ARGBASE+8(%esp),%edi # dst
28314 movl ARGBASE+12(%esp),%ecx # len
28315 @@ -502,10 +539,17 @@ DST( movb %dl, (%edi) )
28316 rep; stosb
28317 jmp 7b
28318 6002: movl ARGBASE+24(%esp), %ebx # dst_err_ptr
28319 - movl $-EFAULT, (%ebx)
28320 + movl $-EFAULT, %ss:(%ebx)
28321 jmp 7b
28322 .previous
28323
28324 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28325 + pushl_cfi %ss
28326 + popl_cfi %ds
28327 + pushl_cfi %ss
28328 + popl_cfi %es
28329 +#endif
28330 +
28331 popl_cfi %esi
28332 CFI_RESTORE esi
28333 popl_cfi %edi
28334 @@ -514,7 +558,7 @@ DST( movb %dl, (%edi) )
28335 CFI_RESTORE ebx
28336 ret
28337 CFI_ENDPROC
28338 -ENDPROC(csum_partial_copy_generic)
28339 +ENDPROC(csum_partial_copy_generic_to_user)
28340
28341 #undef ROUND
28342 #undef ROUND1
28343 diff --git a/arch/x86/lib/clear_page_64.S b/arch/x86/lib/clear_page_64.S
28344 index f2145cf..cea889d 100644
28345 --- a/arch/x86/lib/clear_page_64.S
28346 +++ b/arch/x86/lib/clear_page_64.S
28347 @@ -11,6 +11,7 @@ ENTRY(clear_page_c)
28348 movl $4096/8,%ecx
28349 xorl %eax,%eax
28350 rep stosq
28351 + pax_force_retaddr
28352 ret
28353 CFI_ENDPROC
28354 ENDPROC(clear_page_c)
28355 @@ -20,6 +21,7 @@ ENTRY(clear_page_c_e)
28356 movl $4096,%ecx
28357 xorl %eax,%eax
28358 rep stosb
28359 + pax_force_retaddr
28360 ret
28361 CFI_ENDPROC
28362 ENDPROC(clear_page_c_e)
28363 @@ -43,6 +45,7 @@ ENTRY(clear_page)
28364 leaq 64(%rdi),%rdi
28365 jnz .Lloop
28366 nop
28367 + pax_force_retaddr
28368 ret
28369 CFI_ENDPROC
28370 .Lclear_page_end:
28371 @@ -58,7 +61,7 @@ ENDPROC(clear_page)
28372
28373 #include <asm/cpufeature.h>
28374
28375 - .section .altinstr_replacement,"ax"
28376 + .section .altinstr_replacement,"a"
28377 1: .byte 0xeb /* jmp <disp8> */
28378 .byte (clear_page_c - clear_page) - (2f - 1b) /* offset */
28379 2: .byte 0xeb /* jmp <disp8> */
28380 diff --git a/arch/x86/lib/cmpxchg16b_emu.S b/arch/x86/lib/cmpxchg16b_emu.S
28381 index 1e572c5..2a162cd 100644
28382 --- a/arch/x86/lib/cmpxchg16b_emu.S
28383 +++ b/arch/x86/lib/cmpxchg16b_emu.S
28384 @@ -53,11 +53,13 @@ this_cpu_cmpxchg16b_emu:
28385
28386 popf
28387 mov $1, %al
28388 + pax_force_retaddr
28389 ret
28390
28391 not_same:
28392 popf
28393 xor %al,%al
28394 + pax_force_retaddr
28395 ret
28396
28397 CFI_ENDPROC
28398 diff --git a/arch/x86/lib/copy_page_64.S b/arch/x86/lib/copy_page_64.S
28399 index 176cca6..e0d658e 100644
28400 --- a/arch/x86/lib/copy_page_64.S
28401 +++ b/arch/x86/lib/copy_page_64.S
28402 @@ -9,6 +9,7 @@ copy_page_rep:
28403 CFI_STARTPROC
28404 movl $4096/8, %ecx
28405 rep movsq
28406 + pax_force_retaddr
28407 ret
28408 CFI_ENDPROC
28409 ENDPROC(copy_page_rep)
28410 @@ -24,8 +25,8 @@ ENTRY(copy_page)
28411 CFI_ADJUST_CFA_OFFSET 2*8
28412 movq %rbx, (%rsp)
28413 CFI_REL_OFFSET rbx, 0
28414 - movq %r12, 1*8(%rsp)
28415 - CFI_REL_OFFSET r12, 1*8
28416 + movq %r13, 1*8(%rsp)
28417 + CFI_REL_OFFSET r13, 1*8
28418
28419 movl $(4096/64)-5, %ecx
28420 .p2align 4
28421 @@ -38,7 +39,7 @@ ENTRY(copy_page)
28422 movq 0x8*4(%rsi), %r9
28423 movq 0x8*5(%rsi), %r10
28424 movq 0x8*6(%rsi), %r11
28425 - movq 0x8*7(%rsi), %r12
28426 + movq 0x8*7(%rsi), %r13
28427
28428 prefetcht0 5*64(%rsi)
28429
28430 @@ -49,7 +50,7 @@ ENTRY(copy_page)
28431 movq %r9, 0x8*4(%rdi)
28432 movq %r10, 0x8*5(%rdi)
28433 movq %r11, 0x8*6(%rdi)
28434 - movq %r12, 0x8*7(%rdi)
28435 + movq %r13, 0x8*7(%rdi)
28436
28437 leaq 64 (%rsi), %rsi
28438 leaq 64 (%rdi), %rdi
28439 @@ -68,7 +69,7 @@ ENTRY(copy_page)
28440 movq 0x8*4(%rsi), %r9
28441 movq 0x8*5(%rsi), %r10
28442 movq 0x8*6(%rsi), %r11
28443 - movq 0x8*7(%rsi), %r12
28444 + movq 0x8*7(%rsi), %r13
28445
28446 movq %rax, 0x8*0(%rdi)
28447 movq %rbx, 0x8*1(%rdi)
28448 @@ -77,7 +78,7 @@ ENTRY(copy_page)
28449 movq %r9, 0x8*4(%rdi)
28450 movq %r10, 0x8*5(%rdi)
28451 movq %r11, 0x8*6(%rdi)
28452 - movq %r12, 0x8*7(%rdi)
28453 + movq %r13, 0x8*7(%rdi)
28454
28455 leaq 64(%rdi), %rdi
28456 leaq 64(%rsi), %rsi
28457 @@ -85,10 +86,11 @@ ENTRY(copy_page)
28458
28459 movq (%rsp), %rbx
28460 CFI_RESTORE rbx
28461 - movq 1*8(%rsp), %r12
28462 - CFI_RESTORE r12
28463 + movq 1*8(%rsp), %r13
28464 + CFI_RESTORE r13
28465 addq $2*8, %rsp
28466 CFI_ADJUST_CFA_OFFSET -2*8
28467 + pax_force_retaddr
28468 ret
28469 .Lcopy_page_end:
28470 CFI_ENDPROC
28471 @@ -99,7 +101,7 @@ ENDPROC(copy_page)
28472
28473 #include <asm/cpufeature.h>
28474
28475 - .section .altinstr_replacement,"ax"
28476 + .section .altinstr_replacement,"a"
28477 1: .byte 0xeb /* jmp <disp8> */
28478 .byte (copy_page_rep - copy_page) - (2f - 1b) /* offset */
28479 2:
28480 diff --git a/arch/x86/lib/copy_user_64.S b/arch/x86/lib/copy_user_64.S
28481 index a30ca15..407412b 100644
28482 --- a/arch/x86/lib/copy_user_64.S
28483 +++ b/arch/x86/lib/copy_user_64.S
28484 @@ -18,31 +18,7 @@
28485 #include <asm/alternative-asm.h>
28486 #include <asm/asm.h>
28487 #include <asm/smap.h>
28488 -
28489 -/*
28490 - * By placing feature2 after feature1 in altinstructions section, we logically
28491 - * implement:
28492 - * If CPU has feature2, jmp to alt2 is used
28493 - * else if CPU has feature1, jmp to alt1 is used
28494 - * else jmp to orig is used.
28495 - */
28496 - .macro ALTERNATIVE_JUMP feature1,feature2,orig,alt1,alt2
28497 -0:
28498 - .byte 0xe9 /* 32bit jump */
28499 - .long \orig-1f /* by default jump to orig */
28500 -1:
28501 - .section .altinstr_replacement,"ax"
28502 -2: .byte 0xe9 /* near jump with 32bit immediate */
28503 - .long \alt1-1b /* offset */ /* or alternatively to alt1 */
28504 -3: .byte 0xe9 /* near jump with 32bit immediate */
28505 - .long \alt2-1b /* offset */ /* or alternatively to alt2 */
28506 - .previous
28507 -
28508 - .section .altinstructions,"a"
28509 - altinstruction_entry 0b,2b,\feature1,5,5
28510 - altinstruction_entry 0b,3b,\feature2,5,5
28511 - .previous
28512 - .endm
28513 +#include <asm/pgtable.h>
28514
28515 .macro ALIGN_DESTINATION
28516 #ifdef FIX_ALIGNMENT
28517 @@ -70,52 +46,6 @@
28518 #endif
28519 .endm
28520
28521 -/* Standard copy_to_user with segment limit checking */
28522 -ENTRY(_copy_to_user)
28523 - CFI_STARTPROC
28524 - GET_THREAD_INFO(%rax)
28525 - movq %rdi,%rcx
28526 - addq %rdx,%rcx
28527 - jc bad_to_user
28528 - cmpq TI_addr_limit(%rax),%rcx
28529 - ja bad_to_user
28530 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28531 - copy_user_generic_unrolled,copy_user_generic_string, \
28532 - copy_user_enhanced_fast_string
28533 - CFI_ENDPROC
28534 -ENDPROC(_copy_to_user)
28535 -
28536 -/* Standard copy_from_user with segment limit checking */
28537 -ENTRY(_copy_from_user)
28538 - CFI_STARTPROC
28539 - GET_THREAD_INFO(%rax)
28540 - movq %rsi,%rcx
28541 - addq %rdx,%rcx
28542 - jc bad_from_user
28543 - cmpq TI_addr_limit(%rax),%rcx
28544 - ja bad_from_user
28545 - ALTERNATIVE_JUMP X86_FEATURE_REP_GOOD,X86_FEATURE_ERMS, \
28546 - copy_user_generic_unrolled,copy_user_generic_string, \
28547 - copy_user_enhanced_fast_string
28548 - CFI_ENDPROC
28549 -ENDPROC(_copy_from_user)
28550 -
28551 - .section .fixup,"ax"
28552 - /* must zero dest */
28553 -ENTRY(bad_from_user)
28554 -bad_from_user:
28555 - CFI_STARTPROC
28556 - movl %edx,%ecx
28557 - xorl %eax,%eax
28558 - rep
28559 - stosb
28560 -bad_to_user:
28561 - movl %edx,%eax
28562 - ret
28563 - CFI_ENDPROC
28564 -ENDPROC(bad_from_user)
28565 - .previous
28566 -
28567 /*
28568 * copy_user_generic_unrolled - memory copy with exception handling.
28569 * This version is for CPUs like P4 that don't have efficient micro
28570 @@ -131,6 +61,7 @@ ENDPROC(bad_from_user)
28571 */
28572 ENTRY(copy_user_generic_unrolled)
28573 CFI_STARTPROC
28574 + ASM_PAX_OPEN_USERLAND
28575 ASM_STAC
28576 cmpl $8,%edx
28577 jb 20f /* less then 8 bytes, go to byte copy loop */
28578 @@ -180,6 +111,8 @@ ENTRY(copy_user_generic_unrolled)
28579 jnz 21b
28580 23: xor %eax,%eax
28581 ASM_CLAC
28582 + ASM_PAX_CLOSE_USERLAND
28583 + pax_force_retaddr
28584 ret
28585
28586 .section .fixup,"ax"
28587 @@ -235,6 +168,7 @@ ENDPROC(copy_user_generic_unrolled)
28588 */
28589 ENTRY(copy_user_generic_string)
28590 CFI_STARTPROC
28591 + ASM_PAX_OPEN_USERLAND
28592 ASM_STAC
28593 andl %edx,%edx
28594 jz 4f
28595 @@ -251,6 +185,8 @@ ENTRY(copy_user_generic_string)
28596 movsb
28597 4: xorl %eax,%eax
28598 ASM_CLAC
28599 + ASM_PAX_CLOSE_USERLAND
28600 + pax_force_retaddr
28601 ret
28602
28603 .section .fixup,"ax"
28604 @@ -278,6 +214,7 @@ ENDPROC(copy_user_generic_string)
28605 */
28606 ENTRY(copy_user_enhanced_fast_string)
28607 CFI_STARTPROC
28608 + ASM_PAX_OPEN_USERLAND
28609 ASM_STAC
28610 andl %edx,%edx
28611 jz 2f
28612 @@ -286,6 +223,8 @@ ENTRY(copy_user_enhanced_fast_string)
28613 movsb
28614 2: xorl %eax,%eax
28615 ASM_CLAC
28616 + ASM_PAX_CLOSE_USERLAND
28617 + pax_force_retaddr
28618 ret
28619
28620 .section .fixup,"ax"
28621 diff --git a/arch/x86/lib/copy_user_nocache_64.S b/arch/x86/lib/copy_user_nocache_64.S
28622 index 6a4f43c..c70fb52 100644
28623 --- a/arch/x86/lib/copy_user_nocache_64.S
28624 +++ b/arch/x86/lib/copy_user_nocache_64.S
28625 @@ -8,6 +8,7 @@
28626
28627 #include <linux/linkage.h>
28628 #include <asm/dwarf2.h>
28629 +#include <asm/alternative-asm.h>
28630
28631 #define FIX_ALIGNMENT 1
28632
28633 @@ -16,6 +17,7 @@
28634 #include <asm/thread_info.h>
28635 #include <asm/asm.h>
28636 #include <asm/smap.h>
28637 +#include <asm/pgtable.h>
28638
28639 .macro ALIGN_DESTINATION
28640 #ifdef FIX_ALIGNMENT
28641 @@ -49,6 +51,16 @@
28642 */
28643 ENTRY(__copy_user_nocache)
28644 CFI_STARTPROC
28645 +
28646 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28647 + mov pax_user_shadow_base,%rcx
28648 + cmp %rcx,%rsi
28649 + jae 1f
28650 + add %rcx,%rsi
28651 +1:
28652 +#endif
28653 +
28654 + ASM_PAX_OPEN_USERLAND
28655 ASM_STAC
28656 cmpl $8,%edx
28657 jb 20f /* less then 8 bytes, go to byte copy loop */
28658 @@ -98,7 +110,9 @@ ENTRY(__copy_user_nocache)
28659 jnz 21b
28660 23: xorl %eax,%eax
28661 ASM_CLAC
28662 + ASM_PAX_CLOSE_USERLAND
28663 sfence
28664 + pax_force_retaddr
28665 ret
28666
28667 .section .fixup,"ax"
28668 diff --git a/arch/x86/lib/csum-copy_64.S b/arch/x86/lib/csum-copy_64.S
28669 index 2419d5f..fe52d0e 100644
28670 --- a/arch/x86/lib/csum-copy_64.S
28671 +++ b/arch/x86/lib/csum-copy_64.S
28672 @@ -9,6 +9,7 @@
28673 #include <asm/dwarf2.h>
28674 #include <asm/errno.h>
28675 #include <asm/asm.h>
28676 +#include <asm/alternative-asm.h>
28677
28678 /*
28679 * Checksum copy with exception handling.
28680 @@ -56,8 +57,8 @@ ENTRY(csum_partial_copy_generic)
28681 CFI_ADJUST_CFA_OFFSET 7*8
28682 movq %rbx, 2*8(%rsp)
28683 CFI_REL_OFFSET rbx, 2*8
28684 - movq %r12, 3*8(%rsp)
28685 - CFI_REL_OFFSET r12, 3*8
28686 + movq %r15, 3*8(%rsp)
28687 + CFI_REL_OFFSET r15, 3*8
28688 movq %r14, 4*8(%rsp)
28689 CFI_REL_OFFSET r14, 4*8
28690 movq %r13, 5*8(%rsp)
28691 @@ -72,16 +73,16 @@ ENTRY(csum_partial_copy_generic)
28692 movl %edx, %ecx
28693
28694 xorl %r9d, %r9d
28695 - movq %rcx, %r12
28696 + movq %rcx, %r15
28697
28698 - shrq $6, %r12
28699 + shrq $6, %r15
28700 jz .Lhandle_tail /* < 64 */
28701
28702 clc
28703
28704 /* main loop. clear in 64 byte blocks */
28705 /* r9: zero, r8: temp2, rbx: temp1, rax: sum, rcx: saved length */
28706 - /* r11: temp3, rdx: temp4, r12 loopcnt */
28707 + /* r11: temp3, rdx: temp4, r15 loopcnt */
28708 /* r10: temp5, rbp: temp6, r14 temp7, r13 temp8 */
28709 .p2align 4
28710 .Lloop:
28711 @@ -115,7 +116,7 @@ ENTRY(csum_partial_copy_generic)
28712 adcq %r14, %rax
28713 adcq %r13, %rax
28714
28715 - decl %r12d
28716 + decl %r15d
28717
28718 dest
28719 movq %rbx, (%rsi)
28720 @@ -210,8 +211,8 @@ ENTRY(csum_partial_copy_generic)
28721 .Lende:
28722 movq 2*8(%rsp), %rbx
28723 CFI_RESTORE rbx
28724 - movq 3*8(%rsp), %r12
28725 - CFI_RESTORE r12
28726 + movq 3*8(%rsp), %r15
28727 + CFI_RESTORE r15
28728 movq 4*8(%rsp), %r14
28729 CFI_RESTORE r14
28730 movq 5*8(%rsp), %r13
28731 @@ -220,6 +221,7 @@ ENTRY(csum_partial_copy_generic)
28732 CFI_RESTORE rbp
28733 addq $7*8, %rsp
28734 CFI_ADJUST_CFA_OFFSET -7*8
28735 + pax_force_retaddr
28736 ret
28737 CFI_RESTORE_STATE
28738
28739 diff --git a/arch/x86/lib/csum-wrappers_64.c b/arch/x86/lib/csum-wrappers_64.c
28740 index 7609e0e..b449b98 100644
28741 --- a/arch/x86/lib/csum-wrappers_64.c
28742 +++ b/arch/x86/lib/csum-wrappers_64.c
28743 @@ -53,10 +53,12 @@ csum_partial_copy_from_user(const void __user *src, void *dst,
28744 len -= 2;
28745 }
28746 }
28747 + pax_open_userland();
28748 stac();
28749 - isum = csum_partial_copy_generic((__force const void *)src,
28750 + isum = csum_partial_copy_generic((const void __force_kernel *)____m(src),
28751 dst, len, isum, errp, NULL);
28752 clac();
28753 + pax_close_userland();
28754 if (unlikely(*errp))
28755 goto out_err;
28756
28757 @@ -110,10 +112,12 @@ csum_partial_copy_to_user(const void *src, void __user *dst,
28758 }
28759
28760 *errp = 0;
28761 + pax_open_userland();
28762 stac();
28763 - ret = csum_partial_copy_generic(src, (void __force *)dst,
28764 + ret = csum_partial_copy_generic(src, (void __force_kernel *)____m(dst),
28765 len, isum, NULL, errp);
28766 clac();
28767 + pax_close_userland();
28768 return ret;
28769 }
28770 EXPORT_SYMBOL(csum_partial_copy_to_user);
28771 diff --git a/arch/x86/lib/getuser.S b/arch/x86/lib/getuser.S
28772 index a451235..1daa956 100644
28773 --- a/arch/x86/lib/getuser.S
28774 +++ b/arch/x86/lib/getuser.S
28775 @@ -33,17 +33,40 @@
28776 #include <asm/thread_info.h>
28777 #include <asm/asm.h>
28778 #include <asm/smap.h>
28779 +#include <asm/segment.h>
28780 +#include <asm/pgtable.h>
28781 +#include <asm/alternative-asm.h>
28782 +
28783 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
28784 +#define __copyuser_seg gs;
28785 +#else
28786 +#define __copyuser_seg
28787 +#endif
28788
28789 .text
28790 ENTRY(__get_user_1)
28791 CFI_STARTPROC
28792 +
28793 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28794 GET_THREAD_INFO(%_ASM_DX)
28795 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28796 jae bad_get_user
28797 ASM_STAC
28798 -1: movzbl (%_ASM_AX),%edx
28799 +
28800 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28801 + mov pax_user_shadow_base,%_ASM_DX
28802 + cmp %_ASM_DX,%_ASM_AX
28803 + jae 1234f
28804 + add %_ASM_DX,%_ASM_AX
28805 +1234:
28806 +#endif
28807 +
28808 +#endif
28809 +
28810 +1: __copyuser_seg movzbl (%_ASM_AX),%edx
28811 xor %eax,%eax
28812 ASM_CLAC
28813 + pax_force_retaddr
28814 ret
28815 CFI_ENDPROC
28816 ENDPROC(__get_user_1)
28817 @@ -51,14 +74,28 @@ ENDPROC(__get_user_1)
28818 ENTRY(__get_user_2)
28819 CFI_STARTPROC
28820 add $1,%_ASM_AX
28821 +
28822 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28823 jc bad_get_user
28824 GET_THREAD_INFO(%_ASM_DX)
28825 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28826 jae bad_get_user
28827 ASM_STAC
28828 -2: movzwl -1(%_ASM_AX),%edx
28829 +
28830 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28831 + mov pax_user_shadow_base,%_ASM_DX
28832 + cmp %_ASM_DX,%_ASM_AX
28833 + jae 1234f
28834 + add %_ASM_DX,%_ASM_AX
28835 +1234:
28836 +#endif
28837 +
28838 +#endif
28839 +
28840 +2: __copyuser_seg movzwl -1(%_ASM_AX),%edx
28841 xor %eax,%eax
28842 ASM_CLAC
28843 + pax_force_retaddr
28844 ret
28845 CFI_ENDPROC
28846 ENDPROC(__get_user_2)
28847 @@ -66,14 +103,28 @@ ENDPROC(__get_user_2)
28848 ENTRY(__get_user_4)
28849 CFI_STARTPROC
28850 add $3,%_ASM_AX
28851 +
28852 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
28853 jc bad_get_user
28854 GET_THREAD_INFO(%_ASM_DX)
28855 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28856 jae bad_get_user
28857 ASM_STAC
28858 -3: movl -3(%_ASM_AX),%edx
28859 +
28860 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
28861 + mov pax_user_shadow_base,%_ASM_DX
28862 + cmp %_ASM_DX,%_ASM_AX
28863 + jae 1234f
28864 + add %_ASM_DX,%_ASM_AX
28865 +1234:
28866 +#endif
28867 +
28868 +#endif
28869 +
28870 +3: __copyuser_seg movl -3(%_ASM_AX),%edx
28871 xor %eax,%eax
28872 ASM_CLAC
28873 + pax_force_retaddr
28874 ret
28875 CFI_ENDPROC
28876 ENDPROC(__get_user_4)
28877 @@ -86,10 +137,20 @@ ENTRY(__get_user_8)
28878 GET_THREAD_INFO(%_ASM_DX)
28879 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28880 jae bad_get_user
28881 +
28882 +#ifdef CONFIG_PAX_MEMORY_UDEREF
28883 + mov pax_user_shadow_base,%_ASM_DX
28884 + cmp %_ASM_DX,%_ASM_AX
28885 + jae 1234f
28886 + add %_ASM_DX,%_ASM_AX
28887 +1234:
28888 +#endif
28889 +
28890 ASM_STAC
28891 4: movq -7(%_ASM_AX),%rdx
28892 xor %eax,%eax
28893 ASM_CLAC
28894 + pax_force_retaddr
28895 ret
28896 #else
28897 add $7,%_ASM_AX
28898 @@ -98,10 +159,11 @@ ENTRY(__get_user_8)
28899 cmp TI_addr_limit(%_ASM_DX),%_ASM_AX
28900 jae bad_get_user_8
28901 ASM_STAC
28902 -4: movl -7(%_ASM_AX),%edx
28903 -5: movl -3(%_ASM_AX),%ecx
28904 +4: __copyuser_seg movl -7(%_ASM_AX),%edx
28905 +5: __copyuser_seg movl -3(%_ASM_AX),%ecx
28906 xor %eax,%eax
28907 ASM_CLAC
28908 + pax_force_retaddr
28909 ret
28910 #endif
28911 CFI_ENDPROC
28912 @@ -113,6 +175,7 @@ bad_get_user:
28913 xor %edx,%edx
28914 mov $(-EFAULT),%_ASM_AX
28915 ASM_CLAC
28916 + pax_force_retaddr
28917 ret
28918 CFI_ENDPROC
28919 END(bad_get_user)
28920 @@ -124,6 +187,7 @@ bad_get_user_8:
28921 xor %ecx,%ecx
28922 mov $(-EFAULT),%_ASM_AX
28923 ASM_CLAC
28924 + pax_force_retaddr
28925 ret
28926 CFI_ENDPROC
28927 END(bad_get_user_8)
28928 diff --git a/arch/x86/lib/insn.c b/arch/x86/lib/insn.c
28929 index 54fcffe..7be149e 100644
28930 --- a/arch/x86/lib/insn.c
28931 +++ b/arch/x86/lib/insn.c
28932 @@ -20,8 +20,10 @@
28933
28934 #ifdef __KERNEL__
28935 #include <linux/string.h>
28936 +#include <asm/pgtable_types.h>
28937 #else
28938 #include <string.h>
28939 +#define ktla_ktva(addr) addr
28940 #endif
28941 #include <asm/inat.h>
28942 #include <asm/insn.h>
28943 @@ -53,8 +55,8 @@
28944 void insn_init(struct insn *insn, const void *kaddr, int x86_64)
28945 {
28946 memset(insn, 0, sizeof(*insn));
28947 - insn->kaddr = kaddr;
28948 - insn->next_byte = kaddr;
28949 + insn->kaddr = ktla_ktva(kaddr);
28950 + insn->next_byte = ktla_ktva(kaddr);
28951 insn->x86_64 = x86_64 ? 1 : 0;
28952 insn->opnd_bytes = 4;
28953 if (x86_64)
28954 diff --git a/arch/x86/lib/iomap_copy_64.S b/arch/x86/lib/iomap_copy_64.S
28955 index 05a95e7..326f2fa 100644
28956 --- a/arch/x86/lib/iomap_copy_64.S
28957 +++ b/arch/x86/lib/iomap_copy_64.S
28958 @@ -17,6 +17,7 @@
28959
28960 #include <linux/linkage.h>
28961 #include <asm/dwarf2.h>
28962 +#include <asm/alternative-asm.h>
28963
28964 /*
28965 * override generic version in lib/iomap_copy.c
28966 @@ -25,6 +26,7 @@ ENTRY(__iowrite32_copy)
28967 CFI_STARTPROC
28968 movl %edx,%ecx
28969 rep movsd
28970 + pax_force_retaddr
28971 ret
28972 CFI_ENDPROC
28973 ENDPROC(__iowrite32_copy)
28974 diff --git a/arch/x86/lib/memcpy_64.S b/arch/x86/lib/memcpy_64.S
28975 index 56313a3..0db417e 100644
28976 --- a/arch/x86/lib/memcpy_64.S
28977 +++ b/arch/x86/lib/memcpy_64.S
28978 @@ -24,7 +24,7 @@
28979 * This gets patched over the unrolled variant (below) via the
28980 * alternative instructions framework:
28981 */
28982 - .section .altinstr_replacement, "ax", @progbits
28983 + .section .altinstr_replacement, "a", @progbits
28984 .Lmemcpy_c:
28985 movq %rdi, %rax
28986 movq %rdx, %rcx
28987 @@ -33,6 +33,7 @@
28988 rep movsq
28989 movl %edx, %ecx
28990 rep movsb
28991 + pax_force_retaddr
28992 ret
28993 .Lmemcpy_e:
28994 .previous
28995 @@ -44,11 +45,12 @@
28996 * This gets patched over the unrolled variant (below) via the
28997 * alternative instructions framework:
28998 */
28999 - .section .altinstr_replacement, "ax", @progbits
29000 + .section .altinstr_replacement, "a", @progbits
29001 .Lmemcpy_c_e:
29002 movq %rdi, %rax
29003 movq %rdx, %rcx
29004 rep movsb
29005 + pax_force_retaddr
29006 ret
29007 .Lmemcpy_e_e:
29008 .previous
29009 @@ -136,6 +138,7 @@ ENTRY(memcpy)
29010 movq %r9, 1*8(%rdi)
29011 movq %r10, -2*8(%rdi, %rdx)
29012 movq %r11, -1*8(%rdi, %rdx)
29013 + pax_force_retaddr
29014 retq
29015 .p2align 4
29016 .Lless_16bytes:
29017 @@ -148,6 +151,7 @@ ENTRY(memcpy)
29018 movq -1*8(%rsi, %rdx), %r9
29019 movq %r8, 0*8(%rdi)
29020 movq %r9, -1*8(%rdi, %rdx)
29021 + pax_force_retaddr
29022 retq
29023 .p2align 4
29024 .Lless_8bytes:
29025 @@ -161,6 +165,7 @@ ENTRY(memcpy)
29026 movl -4(%rsi, %rdx), %r8d
29027 movl %ecx, (%rdi)
29028 movl %r8d, -4(%rdi, %rdx)
29029 + pax_force_retaddr
29030 retq
29031 .p2align 4
29032 .Lless_3bytes:
29033 @@ -179,6 +184,7 @@ ENTRY(memcpy)
29034 movb %cl, (%rdi)
29035
29036 .Lend:
29037 + pax_force_retaddr
29038 retq
29039 CFI_ENDPROC
29040 ENDPROC(memcpy)
29041 diff --git a/arch/x86/lib/memmove_64.S b/arch/x86/lib/memmove_64.S
29042 index 65268a6..dd1de11 100644
29043 --- a/arch/x86/lib/memmove_64.S
29044 +++ b/arch/x86/lib/memmove_64.S
29045 @@ -202,14 +202,16 @@ ENTRY(memmove)
29046 movb (%rsi), %r11b
29047 movb %r11b, (%rdi)
29048 13:
29049 + pax_force_retaddr
29050 retq
29051 CFI_ENDPROC
29052
29053 - .section .altinstr_replacement,"ax"
29054 + .section .altinstr_replacement,"a"
29055 .Lmemmove_begin_forward_efs:
29056 /* Forward moving data. */
29057 movq %rdx, %rcx
29058 rep movsb
29059 + pax_force_retaddr
29060 retq
29061 .Lmemmove_end_forward_efs:
29062 .previous
29063 diff --git a/arch/x86/lib/memset_64.S b/arch/x86/lib/memset_64.S
29064 index 2dcb380..2eb79fe 100644
29065 --- a/arch/x86/lib/memset_64.S
29066 +++ b/arch/x86/lib/memset_64.S
29067 @@ -16,7 +16,7 @@
29068 *
29069 * rax original destination
29070 */
29071 - .section .altinstr_replacement, "ax", @progbits
29072 + .section .altinstr_replacement, "a", @progbits
29073 .Lmemset_c:
29074 movq %rdi,%r9
29075 movq %rdx,%rcx
29076 @@ -30,6 +30,7 @@
29077 movl %edx,%ecx
29078 rep stosb
29079 movq %r9,%rax
29080 + pax_force_retaddr
29081 ret
29082 .Lmemset_e:
29083 .previous
29084 @@ -45,13 +46,14 @@
29085 *
29086 * rax original destination
29087 */
29088 - .section .altinstr_replacement, "ax", @progbits
29089 + .section .altinstr_replacement, "a", @progbits
29090 .Lmemset_c_e:
29091 movq %rdi,%r9
29092 movb %sil,%al
29093 movq %rdx,%rcx
29094 rep stosb
29095 movq %r9,%rax
29096 + pax_force_retaddr
29097 ret
29098 .Lmemset_e_e:
29099 .previous
29100 @@ -118,6 +120,7 @@ ENTRY(__memset)
29101
29102 .Lende:
29103 movq %r10,%rax
29104 + pax_force_retaddr
29105 ret
29106
29107 CFI_RESTORE_STATE
29108 diff --git a/arch/x86/lib/mmx_32.c b/arch/x86/lib/mmx_32.c
29109 index c9f2d9b..e7fd2c0 100644
29110 --- a/arch/x86/lib/mmx_32.c
29111 +++ b/arch/x86/lib/mmx_32.c
29112 @@ -29,6 +29,7 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29113 {
29114 void *p;
29115 int i;
29116 + unsigned long cr0;
29117
29118 if (unlikely(in_interrupt()))
29119 return __memcpy(to, from, len);
29120 @@ -39,44 +40,72 @@ void *_mmx_memcpy(void *to, const void *from, size_t len)
29121 kernel_fpu_begin();
29122
29123 __asm__ __volatile__ (
29124 - "1: prefetch (%0)\n" /* This set is 28 bytes */
29125 - " prefetch 64(%0)\n"
29126 - " prefetch 128(%0)\n"
29127 - " prefetch 192(%0)\n"
29128 - " prefetch 256(%0)\n"
29129 + "1: prefetch (%1)\n" /* This set is 28 bytes */
29130 + " prefetch 64(%1)\n"
29131 + " prefetch 128(%1)\n"
29132 + " prefetch 192(%1)\n"
29133 + " prefetch 256(%1)\n"
29134 "2: \n"
29135 ".section .fixup, \"ax\"\n"
29136 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29137 + "3: \n"
29138 +
29139 +#ifdef CONFIG_PAX_KERNEXEC
29140 + " movl %%cr0, %0\n"
29141 + " movl %0, %%eax\n"
29142 + " andl $0xFFFEFFFF, %%eax\n"
29143 + " movl %%eax, %%cr0\n"
29144 +#endif
29145 +
29146 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29147 +
29148 +#ifdef CONFIG_PAX_KERNEXEC
29149 + " movl %0, %%cr0\n"
29150 +#endif
29151 +
29152 " jmp 2b\n"
29153 ".previous\n"
29154 _ASM_EXTABLE(1b, 3b)
29155 - : : "r" (from));
29156 + : "=&r" (cr0) : "r" (from) : "ax");
29157
29158 for ( ; i > 5; i--) {
29159 __asm__ __volatile__ (
29160 - "1: prefetch 320(%0)\n"
29161 - "2: movq (%0), %%mm0\n"
29162 - " movq 8(%0), %%mm1\n"
29163 - " movq 16(%0), %%mm2\n"
29164 - " movq 24(%0), %%mm3\n"
29165 - " movq %%mm0, (%1)\n"
29166 - " movq %%mm1, 8(%1)\n"
29167 - " movq %%mm2, 16(%1)\n"
29168 - " movq %%mm3, 24(%1)\n"
29169 - " movq 32(%0), %%mm0\n"
29170 - " movq 40(%0), %%mm1\n"
29171 - " movq 48(%0), %%mm2\n"
29172 - " movq 56(%0), %%mm3\n"
29173 - " movq %%mm0, 32(%1)\n"
29174 - " movq %%mm1, 40(%1)\n"
29175 - " movq %%mm2, 48(%1)\n"
29176 - " movq %%mm3, 56(%1)\n"
29177 + "1: prefetch 320(%1)\n"
29178 + "2: movq (%1), %%mm0\n"
29179 + " movq 8(%1), %%mm1\n"
29180 + " movq 16(%1), %%mm2\n"
29181 + " movq 24(%1), %%mm3\n"
29182 + " movq %%mm0, (%2)\n"
29183 + " movq %%mm1, 8(%2)\n"
29184 + " movq %%mm2, 16(%2)\n"
29185 + " movq %%mm3, 24(%2)\n"
29186 + " movq 32(%1), %%mm0\n"
29187 + " movq 40(%1), %%mm1\n"
29188 + " movq 48(%1), %%mm2\n"
29189 + " movq 56(%1), %%mm3\n"
29190 + " movq %%mm0, 32(%2)\n"
29191 + " movq %%mm1, 40(%2)\n"
29192 + " movq %%mm2, 48(%2)\n"
29193 + " movq %%mm3, 56(%2)\n"
29194 ".section .fixup, \"ax\"\n"
29195 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29196 + "3:\n"
29197 +
29198 +#ifdef CONFIG_PAX_KERNEXEC
29199 + " movl %%cr0, %0\n"
29200 + " movl %0, %%eax\n"
29201 + " andl $0xFFFEFFFF, %%eax\n"
29202 + " movl %%eax, %%cr0\n"
29203 +#endif
29204 +
29205 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29206 +
29207 +#ifdef CONFIG_PAX_KERNEXEC
29208 + " movl %0, %%cr0\n"
29209 +#endif
29210 +
29211 " jmp 2b\n"
29212 ".previous\n"
29213 _ASM_EXTABLE(1b, 3b)
29214 - : : "r" (from), "r" (to) : "memory");
29215 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29216
29217 from += 64;
29218 to += 64;
29219 @@ -158,6 +187,7 @@ static void fast_clear_page(void *page)
29220 static void fast_copy_page(void *to, void *from)
29221 {
29222 int i;
29223 + unsigned long cr0;
29224
29225 kernel_fpu_begin();
29226
29227 @@ -166,42 +196,70 @@ static void fast_copy_page(void *to, void *from)
29228 * but that is for later. -AV
29229 */
29230 __asm__ __volatile__(
29231 - "1: prefetch (%0)\n"
29232 - " prefetch 64(%0)\n"
29233 - " prefetch 128(%0)\n"
29234 - " prefetch 192(%0)\n"
29235 - " prefetch 256(%0)\n"
29236 + "1: prefetch (%1)\n"
29237 + " prefetch 64(%1)\n"
29238 + " prefetch 128(%1)\n"
29239 + " prefetch 192(%1)\n"
29240 + " prefetch 256(%1)\n"
29241 "2: \n"
29242 ".section .fixup, \"ax\"\n"
29243 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29244 + "3: \n"
29245 +
29246 +#ifdef CONFIG_PAX_KERNEXEC
29247 + " movl %%cr0, %0\n"
29248 + " movl %0, %%eax\n"
29249 + " andl $0xFFFEFFFF, %%eax\n"
29250 + " movl %%eax, %%cr0\n"
29251 +#endif
29252 +
29253 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29254 +
29255 +#ifdef CONFIG_PAX_KERNEXEC
29256 + " movl %0, %%cr0\n"
29257 +#endif
29258 +
29259 " jmp 2b\n"
29260 ".previous\n"
29261 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29262 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29263
29264 for (i = 0; i < (4096-320)/64; i++) {
29265 __asm__ __volatile__ (
29266 - "1: prefetch 320(%0)\n"
29267 - "2: movq (%0), %%mm0\n"
29268 - " movntq %%mm0, (%1)\n"
29269 - " movq 8(%0), %%mm1\n"
29270 - " movntq %%mm1, 8(%1)\n"
29271 - " movq 16(%0), %%mm2\n"
29272 - " movntq %%mm2, 16(%1)\n"
29273 - " movq 24(%0), %%mm3\n"
29274 - " movntq %%mm3, 24(%1)\n"
29275 - " movq 32(%0), %%mm4\n"
29276 - " movntq %%mm4, 32(%1)\n"
29277 - " movq 40(%0), %%mm5\n"
29278 - " movntq %%mm5, 40(%1)\n"
29279 - " movq 48(%0), %%mm6\n"
29280 - " movntq %%mm6, 48(%1)\n"
29281 - " movq 56(%0), %%mm7\n"
29282 - " movntq %%mm7, 56(%1)\n"
29283 + "1: prefetch 320(%1)\n"
29284 + "2: movq (%1), %%mm0\n"
29285 + " movntq %%mm0, (%2)\n"
29286 + " movq 8(%1), %%mm1\n"
29287 + " movntq %%mm1, 8(%2)\n"
29288 + " movq 16(%1), %%mm2\n"
29289 + " movntq %%mm2, 16(%2)\n"
29290 + " movq 24(%1), %%mm3\n"
29291 + " movntq %%mm3, 24(%2)\n"
29292 + " movq 32(%1), %%mm4\n"
29293 + " movntq %%mm4, 32(%2)\n"
29294 + " movq 40(%1), %%mm5\n"
29295 + " movntq %%mm5, 40(%2)\n"
29296 + " movq 48(%1), %%mm6\n"
29297 + " movntq %%mm6, 48(%2)\n"
29298 + " movq 56(%1), %%mm7\n"
29299 + " movntq %%mm7, 56(%2)\n"
29300 ".section .fixup, \"ax\"\n"
29301 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29302 + "3:\n"
29303 +
29304 +#ifdef CONFIG_PAX_KERNEXEC
29305 + " movl %%cr0, %0\n"
29306 + " movl %0, %%eax\n"
29307 + " andl $0xFFFEFFFF, %%eax\n"
29308 + " movl %%eax, %%cr0\n"
29309 +#endif
29310 +
29311 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29312 +
29313 +#ifdef CONFIG_PAX_KERNEXEC
29314 + " movl %0, %%cr0\n"
29315 +#endif
29316 +
29317 " jmp 2b\n"
29318 ".previous\n"
29319 - _ASM_EXTABLE(1b, 3b) : : "r" (from), "r" (to) : "memory");
29320 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29321
29322 from += 64;
29323 to += 64;
29324 @@ -280,47 +338,76 @@ static void fast_clear_page(void *page)
29325 static void fast_copy_page(void *to, void *from)
29326 {
29327 int i;
29328 + unsigned long cr0;
29329
29330 kernel_fpu_begin();
29331
29332 __asm__ __volatile__ (
29333 - "1: prefetch (%0)\n"
29334 - " prefetch 64(%0)\n"
29335 - " prefetch 128(%0)\n"
29336 - " prefetch 192(%0)\n"
29337 - " prefetch 256(%0)\n"
29338 + "1: prefetch (%1)\n"
29339 + " prefetch 64(%1)\n"
29340 + " prefetch 128(%1)\n"
29341 + " prefetch 192(%1)\n"
29342 + " prefetch 256(%1)\n"
29343 "2: \n"
29344 ".section .fixup, \"ax\"\n"
29345 - "3: movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29346 + "3: \n"
29347 +
29348 +#ifdef CONFIG_PAX_KERNEXEC
29349 + " movl %%cr0, %0\n"
29350 + " movl %0, %%eax\n"
29351 + " andl $0xFFFEFFFF, %%eax\n"
29352 + " movl %%eax, %%cr0\n"
29353 +#endif
29354 +
29355 + " movw $0x1AEB, 1b\n" /* jmp on 26 bytes */
29356 +
29357 +#ifdef CONFIG_PAX_KERNEXEC
29358 + " movl %0, %%cr0\n"
29359 +#endif
29360 +
29361 " jmp 2b\n"
29362 ".previous\n"
29363 - _ASM_EXTABLE(1b, 3b) : : "r" (from));
29364 + _ASM_EXTABLE(1b, 3b) : "=&r" (cr0) : "r" (from) : "ax");
29365
29366 for (i = 0; i < 4096/64; i++) {
29367 __asm__ __volatile__ (
29368 - "1: prefetch 320(%0)\n"
29369 - "2: movq (%0), %%mm0\n"
29370 - " movq 8(%0), %%mm1\n"
29371 - " movq 16(%0), %%mm2\n"
29372 - " movq 24(%0), %%mm3\n"
29373 - " movq %%mm0, (%1)\n"
29374 - " movq %%mm1, 8(%1)\n"
29375 - " movq %%mm2, 16(%1)\n"
29376 - " movq %%mm3, 24(%1)\n"
29377 - " movq 32(%0), %%mm0\n"
29378 - " movq 40(%0), %%mm1\n"
29379 - " movq 48(%0), %%mm2\n"
29380 - " movq 56(%0), %%mm3\n"
29381 - " movq %%mm0, 32(%1)\n"
29382 - " movq %%mm1, 40(%1)\n"
29383 - " movq %%mm2, 48(%1)\n"
29384 - " movq %%mm3, 56(%1)\n"
29385 + "1: prefetch 320(%1)\n"
29386 + "2: movq (%1), %%mm0\n"
29387 + " movq 8(%1), %%mm1\n"
29388 + " movq 16(%1), %%mm2\n"
29389 + " movq 24(%1), %%mm3\n"
29390 + " movq %%mm0, (%2)\n"
29391 + " movq %%mm1, 8(%2)\n"
29392 + " movq %%mm2, 16(%2)\n"
29393 + " movq %%mm3, 24(%2)\n"
29394 + " movq 32(%1), %%mm0\n"
29395 + " movq 40(%1), %%mm1\n"
29396 + " movq 48(%1), %%mm2\n"
29397 + " movq 56(%1), %%mm3\n"
29398 + " movq %%mm0, 32(%2)\n"
29399 + " movq %%mm1, 40(%2)\n"
29400 + " movq %%mm2, 48(%2)\n"
29401 + " movq %%mm3, 56(%2)\n"
29402 ".section .fixup, \"ax\"\n"
29403 - "3: movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29404 + "3:\n"
29405 +
29406 +#ifdef CONFIG_PAX_KERNEXEC
29407 + " movl %%cr0, %0\n"
29408 + " movl %0, %%eax\n"
29409 + " andl $0xFFFEFFFF, %%eax\n"
29410 + " movl %%eax, %%cr0\n"
29411 +#endif
29412 +
29413 + " movw $0x05EB, 1b\n" /* jmp on 5 bytes */
29414 +
29415 +#ifdef CONFIG_PAX_KERNEXEC
29416 + " movl %0, %%cr0\n"
29417 +#endif
29418 +
29419 " jmp 2b\n"
29420 ".previous\n"
29421 _ASM_EXTABLE(1b, 3b)
29422 - : : "r" (from), "r" (to) : "memory");
29423 + : "=&r" (cr0) : "r" (from), "r" (to) : "memory", "ax");
29424
29425 from += 64;
29426 to += 64;
29427 diff --git a/arch/x86/lib/msr-reg.S b/arch/x86/lib/msr-reg.S
29428 index f6d13ee..d789440 100644
29429 --- a/arch/x86/lib/msr-reg.S
29430 +++ b/arch/x86/lib/msr-reg.S
29431 @@ -3,6 +3,7 @@
29432 #include <asm/dwarf2.h>
29433 #include <asm/asm.h>
29434 #include <asm/msr.h>
29435 +#include <asm/alternative-asm.h>
29436
29437 #ifdef CONFIG_X86_64
29438 /*
29439 @@ -37,6 +38,7 @@ ENTRY(\op\()_safe_regs)
29440 movl %edi, 28(%r10)
29441 popq_cfi %rbp
29442 popq_cfi %rbx
29443 + pax_force_retaddr
29444 ret
29445 3:
29446 CFI_RESTORE_STATE
29447 diff --git a/arch/x86/lib/putuser.S b/arch/x86/lib/putuser.S
29448 index fc6ba17..d4d989d 100644
29449 --- a/arch/x86/lib/putuser.S
29450 +++ b/arch/x86/lib/putuser.S
29451 @@ -16,7 +16,9 @@
29452 #include <asm/errno.h>
29453 #include <asm/asm.h>
29454 #include <asm/smap.h>
29455 -
29456 +#include <asm/segment.h>
29457 +#include <asm/pgtable.h>
29458 +#include <asm/alternative-asm.h>
29459
29460 /*
29461 * __put_user_X
29462 @@ -30,57 +32,125 @@
29463 * as they get called from within inline assembly.
29464 */
29465
29466 -#define ENTER CFI_STARTPROC ; \
29467 - GET_THREAD_INFO(%_ASM_BX)
29468 -#define EXIT ASM_CLAC ; \
29469 - ret ; \
29470 +#define ENTER CFI_STARTPROC
29471 +#define EXIT ASM_CLAC ; \
29472 + pax_force_retaddr ; \
29473 + ret ; \
29474 CFI_ENDPROC
29475
29476 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29477 +#define _DEST %_ASM_CX,%_ASM_BX
29478 +#else
29479 +#define _DEST %_ASM_CX
29480 +#endif
29481 +
29482 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_MEMORY_UDEREF)
29483 +#define __copyuser_seg gs;
29484 +#else
29485 +#define __copyuser_seg
29486 +#endif
29487 +
29488 .text
29489 ENTRY(__put_user_1)
29490 ENTER
29491 +
29492 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29493 + GET_THREAD_INFO(%_ASM_BX)
29494 cmp TI_addr_limit(%_ASM_BX),%_ASM_CX
29495 jae bad_put_user
29496 ASM_STAC
29497 -1: movb %al,(%_ASM_CX)
29498 +
29499 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29500 + mov pax_user_shadow_base,%_ASM_BX
29501 + cmp %_ASM_BX,%_ASM_CX
29502 + jb 1234f
29503 + xor %ebx,%ebx
29504 +1234:
29505 +#endif
29506 +
29507 +#endif
29508 +
29509 +1: __copyuser_seg movb %al,(_DEST)
29510 xor %eax,%eax
29511 EXIT
29512 ENDPROC(__put_user_1)
29513
29514 ENTRY(__put_user_2)
29515 ENTER
29516 +
29517 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29518 + GET_THREAD_INFO(%_ASM_BX)
29519 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29520 sub $1,%_ASM_BX
29521 cmp %_ASM_BX,%_ASM_CX
29522 jae bad_put_user
29523 ASM_STAC
29524 -2: movw %ax,(%_ASM_CX)
29525 +
29526 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29527 + mov pax_user_shadow_base,%_ASM_BX
29528 + cmp %_ASM_BX,%_ASM_CX
29529 + jb 1234f
29530 + xor %ebx,%ebx
29531 +1234:
29532 +#endif
29533 +
29534 +#endif
29535 +
29536 +2: __copyuser_seg movw %ax,(_DEST)
29537 xor %eax,%eax
29538 EXIT
29539 ENDPROC(__put_user_2)
29540
29541 ENTRY(__put_user_4)
29542 ENTER
29543 +
29544 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29545 + GET_THREAD_INFO(%_ASM_BX)
29546 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29547 sub $3,%_ASM_BX
29548 cmp %_ASM_BX,%_ASM_CX
29549 jae bad_put_user
29550 ASM_STAC
29551 -3: movl %eax,(%_ASM_CX)
29552 +
29553 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29554 + mov pax_user_shadow_base,%_ASM_BX
29555 + cmp %_ASM_BX,%_ASM_CX
29556 + jb 1234f
29557 + xor %ebx,%ebx
29558 +1234:
29559 +#endif
29560 +
29561 +#endif
29562 +
29563 +3: __copyuser_seg movl %eax,(_DEST)
29564 xor %eax,%eax
29565 EXIT
29566 ENDPROC(__put_user_4)
29567
29568 ENTRY(__put_user_8)
29569 ENTER
29570 +
29571 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_MEMORY_UDEREF)
29572 + GET_THREAD_INFO(%_ASM_BX)
29573 mov TI_addr_limit(%_ASM_BX),%_ASM_BX
29574 sub $7,%_ASM_BX
29575 cmp %_ASM_BX,%_ASM_CX
29576 jae bad_put_user
29577 ASM_STAC
29578 -4: mov %_ASM_AX,(%_ASM_CX)
29579 +
29580 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
29581 + mov pax_user_shadow_base,%_ASM_BX
29582 + cmp %_ASM_BX,%_ASM_CX
29583 + jb 1234f
29584 + xor %ebx,%ebx
29585 +1234:
29586 +#endif
29587 +
29588 +#endif
29589 +
29590 +4: __copyuser_seg mov %_ASM_AX,(_DEST)
29591 #ifdef CONFIG_X86_32
29592 -5: movl %edx,4(%_ASM_CX)
29593 +5: __copyuser_seg movl %edx,4(_DEST)
29594 #endif
29595 xor %eax,%eax
29596 EXIT
29597 diff --git a/arch/x86/lib/rwlock.S b/arch/x86/lib/rwlock.S
29598 index 1cad221..de671ee 100644
29599 --- a/arch/x86/lib/rwlock.S
29600 +++ b/arch/x86/lib/rwlock.S
29601 @@ -16,13 +16,34 @@ ENTRY(__write_lock_failed)
29602 FRAME
29603 0: LOCK_PREFIX
29604 WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29605 +
29606 +#ifdef CONFIG_PAX_REFCOUNT
29607 + jno 1234f
29608 + LOCK_PREFIX
29609 + WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29610 + int $4
29611 +1234:
29612 + _ASM_EXTABLE(1234b, 1234b)
29613 +#endif
29614 +
29615 1: rep; nop
29616 cmpl $WRITE_LOCK_CMP, (%__lock_ptr)
29617 jne 1b
29618 LOCK_PREFIX
29619 WRITE_LOCK_SUB($RW_LOCK_BIAS) (%__lock_ptr)
29620 +
29621 +#ifdef CONFIG_PAX_REFCOUNT
29622 + jno 1234f
29623 + LOCK_PREFIX
29624 + WRITE_LOCK_ADD($RW_LOCK_BIAS) (%__lock_ptr)
29625 + int $4
29626 +1234:
29627 + _ASM_EXTABLE(1234b, 1234b)
29628 +#endif
29629 +
29630 jnz 0b
29631 ENDFRAME
29632 + pax_force_retaddr
29633 ret
29634 CFI_ENDPROC
29635 END(__write_lock_failed)
29636 @@ -32,13 +53,34 @@ ENTRY(__read_lock_failed)
29637 FRAME
29638 0: LOCK_PREFIX
29639 READ_LOCK_SIZE(inc) (%__lock_ptr)
29640 +
29641 +#ifdef CONFIG_PAX_REFCOUNT
29642 + jno 1234f
29643 + LOCK_PREFIX
29644 + READ_LOCK_SIZE(dec) (%__lock_ptr)
29645 + int $4
29646 +1234:
29647 + _ASM_EXTABLE(1234b, 1234b)
29648 +#endif
29649 +
29650 1: rep; nop
29651 READ_LOCK_SIZE(cmp) $1, (%__lock_ptr)
29652 js 1b
29653 LOCK_PREFIX
29654 READ_LOCK_SIZE(dec) (%__lock_ptr)
29655 +
29656 +#ifdef CONFIG_PAX_REFCOUNT
29657 + jno 1234f
29658 + LOCK_PREFIX
29659 + READ_LOCK_SIZE(inc) (%__lock_ptr)
29660 + int $4
29661 +1234:
29662 + _ASM_EXTABLE(1234b, 1234b)
29663 +#endif
29664 +
29665 js 0b
29666 ENDFRAME
29667 + pax_force_retaddr
29668 ret
29669 CFI_ENDPROC
29670 END(__read_lock_failed)
29671 diff --git a/arch/x86/lib/rwsem.S b/arch/x86/lib/rwsem.S
29672 index 5dff5f0..cadebf4 100644
29673 --- a/arch/x86/lib/rwsem.S
29674 +++ b/arch/x86/lib/rwsem.S
29675 @@ -94,6 +94,7 @@ ENTRY(call_rwsem_down_read_failed)
29676 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29677 CFI_RESTORE __ASM_REG(dx)
29678 restore_common_regs
29679 + pax_force_retaddr
29680 ret
29681 CFI_ENDPROC
29682 ENDPROC(call_rwsem_down_read_failed)
29683 @@ -104,6 +105,7 @@ ENTRY(call_rwsem_down_write_failed)
29684 movq %rax,%rdi
29685 call rwsem_down_write_failed
29686 restore_common_regs
29687 + pax_force_retaddr
29688 ret
29689 CFI_ENDPROC
29690 ENDPROC(call_rwsem_down_write_failed)
29691 @@ -117,7 +119,8 @@ ENTRY(call_rwsem_wake)
29692 movq %rax,%rdi
29693 call rwsem_wake
29694 restore_common_regs
29695 -1: ret
29696 +1: pax_force_retaddr
29697 + ret
29698 CFI_ENDPROC
29699 ENDPROC(call_rwsem_wake)
29700
29701 @@ -131,6 +134,7 @@ ENTRY(call_rwsem_downgrade_wake)
29702 __ASM_SIZE(pop,_cfi) %__ASM_REG(dx)
29703 CFI_RESTORE __ASM_REG(dx)
29704 restore_common_regs
29705 + pax_force_retaddr
29706 ret
29707 CFI_ENDPROC
29708 ENDPROC(call_rwsem_downgrade_wake)
29709 diff --git a/arch/x86/lib/thunk_64.S b/arch/x86/lib/thunk_64.S
29710 index a63efd6..8149fbe 100644
29711 --- a/arch/x86/lib/thunk_64.S
29712 +++ b/arch/x86/lib/thunk_64.S
29713 @@ -8,6 +8,7 @@
29714 #include <linux/linkage.h>
29715 #include <asm/dwarf2.h>
29716 #include <asm/calling.h>
29717 +#include <asm/alternative-asm.h>
29718
29719 /* rdi: arg1 ... normal C conventions. rax is saved/restored. */
29720 .macro THUNK name, func, put_ret_addr_in_rdi=0
29721 @@ -15,11 +16,11 @@
29722 \name:
29723 CFI_STARTPROC
29724
29725 - /* this one pushes 9 elems, the next one would be %rIP */
29726 - SAVE_ARGS
29727 + /* this one pushes 15+1 elems, the next one would be %rIP */
29728 + SAVE_ARGS 8
29729
29730 .if \put_ret_addr_in_rdi
29731 - movq_cfi_restore 9*8, rdi
29732 + movq_cfi_restore RIP, rdi
29733 .endif
29734
29735 call \func
29736 @@ -38,8 +39,9 @@
29737
29738 /* SAVE_ARGS below is used only for the .cfi directives it contains. */
29739 CFI_STARTPROC
29740 - SAVE_ARGS
29741 + SAVE_ARGS 8
29742 restore:
29743 - RESTORE_ARGS
29744 + RESTORE_ARGS 1,8
29745 + pax_force_retaddr
29746 ret
29747 CFI_ENDPROC
29748 diff --git a/arch/x86/lib/usercopy_32.c b/arch/x86/lib/usercopy_32.c
29749 index 3eb18ac..4b22130 100644
29750 --- a/arch/x86/lib/usercopy_32.c
29751 +++ b/arch/x86/lib/usercopy_32.c
29752 @@ -42,11 +42,13 @@ do { \
29753 int __d0; \
29754 might_fault(); \
29755 __asm__ __volatile__( \
29756 + __COPYUSER_SET_ES \
29757 ASM_STAC "\n" \
29758 "0: rep; stosl\n" \
29759 " movl %2,%0\n" \
29760 "1: rep; stosb\n" \
29761 "2: " ASM_CLAC "\n" \
29762 + __COPYUSER_RESTORE_ES \
29763 ".section .fixup,\"ax\"\n" \
29764 "3: lea 0(%2,%0,4),%0\n" \
29765 " jmp 2b\n" \
29766 @@ -98,7 +100,7 @@ EXPORT_SYMBOL(__clear_user);
29767
29768 #ifdef CONFIG_X86_INTEL_USERCOPY
29769 static unsigned long
29770 -__copy_user_intel(void __user *to, const void *from, unsigned long size)
29771 +__generic_copy_to_user_intel(void __user *to, const void *from, unsigned long size)
29772 {
29773 int d0, d1;
29774 __asm__ __volatile__(
29775 @@ -110,36 +112,36 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29776 " .align 2,0x90\n"
29777 "3: movl 0(%4), %%eax\n"
29778 "4: movl 4(%4), %%edx\n"
29779 - "5: movl %%eax, 0(%3)\n"
29780 - "6: movl %%edx, 4(%3)\n"
29781 + "5: "__copyuser_seg" movl %%eax, 0(%3)\n"
29782 + "6: "__copyuser_seg" movl %%edx, 4(%3)\n"
29783 "7: movl 8(%4), %%eax\n"
29784 "8: movl 12(%4),%%edx\n"
29785 - "9: movl %%eax, 8(%3)\n"
29786 - "10: movl %%edx, 12(%3)\n"
29787 + "9: "__copyuser_seg" movl %%eax, 8(%3)\n"
29788 + "10: "__copyuser_seg" movl %%edx, 12(%3)\n"
29789 "11: movl 16(%4), %%eax\n"
29790 "12: movl 20(%4), %%edx\n"
29791 - "13: movl %%eax, 16(%3)\n"
29792 - "14: movl %%edx, 20(%3)\n"
29793 + "13: "__copyuser_seg" movl %%eax, 16(%3)\n"
29794 + "14: "__copyuser_seg" movl %%edx, 20(%3)\n"
29795 "15: movl 24(%4), %%eax\n"
29796 "16: movl 28(%4), %%edx\n"
29797 - "17: movl %%eax, 24(%3)\n"
29798 - "18: movl %%edx, 28(%3)\n"
29799 + "17: "__copyuser_seg" movl %%eax, 24(%3)\n"
29800 + "18: "__copyuser_seg" movl %%edx, 28(%3)\n"
29801 "19: movl 32(%4), %%eax\n"
29802 "20: movl 36(%4), %%edx\n"
29803 - "21: movl %%eax, 32(%3)\n"
29804 - "22: movl %%edx, 36(%3)\n"
29805 + "21: "__copyuser_seg" movl %%eax, 32(%3)\n"
29806 + "22: "__copyuser_seg" movl %%edx, 36(%3)\n"
29807 "23: movl 40(%4), %%eax\n"
29808 "24: movl 44(%4), %%edx\n"
29809 - "25: movl %%eax, 40(%3)\n"
29810 - "26: movl %%edx, 44(%3)\n"
29811 + "25: "__copyuser_seg" movl %%eax, 40(%3)\n"
29812 + "26: "__copyuser_seg" movl %%edx, 44(%3)\n"
29813 "27: movl 48(%4), %%eax\n"
29814 "28: movl 52(%4), %%edx\n"
29815 - "29: movl %%eax, 48(%3)\n"
29816 - "30: movl %%edx, 52(%3)\n"
29817 + "29: "__copyuser_seg" movl %%eax, 48(%3)\n"
29818 + "30: "__copyuser_seg" movl %%edx, 52(%3)\n"
29819 "31: movl 56(%4), %%eax\n"
29820 "32: movl 60(%4), %%edx\n"
29821 - "33: movl %%eax, 56(%3)\n"
29822 - "34: movl %%edx, 60(%3)\n"
29823 + "33: "__copyuser_seg" movl %%eax, 56(%3)\n"
29824 + "34: "__copyuser_seg" movl %%edx, 60(%3)\n"
29825 " addl $-64, %0\n"
29826 " addl $64, %4\n"
29827 " addl $64, %3\n"
29828 @@ -149,10 +151,116 @@ __copy_user_intel(void __user *to, const void *from, unsigned long size)
29829 " shrl $2, %0\n"
29830 " andl $3, %%eax\n"
29831 " cld\n"
29832 + __COPYUSER_SET_ES
29833 "99: rep; movsl\n"
29834 "36: movl %%eax, %0\n"
29835 "37: rep; movsb\n"
29836 "100:\n"
29837 + __COPYUSER_RESTORE_ES
29838 + ".section .fixup,\"ax\"\n"
29839 + "101: lea 0(%%eax,%0,4),%0\n"
29840 + " jmp 100b\n"
29841 + ".previous\n"
29842 + _ASM_EXTABLE(1b,100b)
29843 + _ASM_EXTABLE(2b,100b)
29844 + _ASM_EXTABLE(3b,100b)
29845 + _ASM_EXTABLE(4b,100b)
29846 + _ASM_EXTABLE(5b,100b)
29847 + _ASM_EXTABLE(6b,100b)
29848 + _ASM_EXTABLE(7b,100b)
29849 + _ASM_EXTABLE(8b,100b)
29850 + _ASM_EXTABLE(9b,100b)
29851 + _ASM_EXTABLE(10b,100b)
29852 + _ASM_EXTABLE(11b,100b)
29853 + _ASM_EXTABLE(12b,100b)
29854 + _ASM_EXTABLE(13b,100b)
29855 + _ASM_EXTABLE(14b,100b)
29856 + _ASM_EXTABLE(15b,100b)
29857 + _ASM_EXTABLE(16b,100b)
29858 + _ASM_EXTABLE(17b,100b)
29859 + _ASM_EXTABLE(18b,100b)
29860 + _ASM_EXTABLE(19b,100b)
29861 + _ASM_EXTABLE(20b,100b)
29862 + _ASM_EXTABLE(21b,100b)
29863 + _ASM_EXTABLE(22b,100b)
29864 + _ASM_EXTABLE(23b,100b)
29865 + _ASM_EXTABLE(24b,100b)
29866 + _ASM_EXTABLE(25b,100b)
29867 + _ASM_EXTABLE(26b,100b)
29868 + _ASM_EXTABLE(27b,100b)
29869 + _ASM_EXTABLE(28b,100b)
29870 + _ASM_EXTABLE(29b,100b)
29871 + _ASM_EXTABLE(30b,100b)
29872 + _ASM_EXTABLE(31b,100b)
29873 + _ASM_EXTABLE(32b,100b)
29874 + _ASM_EXTABLE(33b,100b)
29875 + _ASM_EXTABLE(34b,100b)
29876 + _ASM_EXTABLE(35b,100b)
29877 + _ASM_EXTABLE(36b,100b)
29878 + _ASM_EXTABLE(37b,100b)
29879 + _ASM_EXTABLE(99b,101b)
29880 + : "=&c"(size), "=&D" (d0), "=&S" (d1)
29881 + : "1"(to), "2"(from), "0"(size)
29882 + : "eax", "edx", "memory");
29883 + return size;
29884 +}
29885 +
29886 +static unsigned long
29887 +__generic_copy_from_user_intel(void *to, const void __user *from, unsigned long size)
29888 +{
29889 + int d0, d1;
29890 + __asm__ __volatile__(
29891 + " .align 2,0x90\n"
29892 + "1: "__copyuser_seg" movl 32(%4), %%eax\n"
29893 + " cmpl $67, %0\n"
29894 + " jbe 3f\n"
29895 + "2: "__copyuser_seg" movl 64(%4), %%eax\n"
29896 + " .align 2,0x90\n"
29897 + "3: "__copyuser_seg" movl 0(%4), %%eax\n"
29898 + "4: "__copyuser_seg" movl 4(%4), %%edx\n"
29899 + "5: movl %%eax, 0(%3)\n"
29900 + "6: movl %%edx, 4(%3)\n"
29901 + "7: "__copyuser_seg" movl 8(%4), %%eax\n"
29902 + "8: "__copyuser_seg" movl 12(%4),%%edx\n"
29903 + "9: movl %%eax, 8(%3)\n"
29904 + "10: movl %%edx, 12(%3)\n"
29905 + "11: "__copyuser_seg" movl 16(%4), %%eax\n"
29906 + "12: "__copyuser_seg" movl 20(%4), %%edx\n"
29907 + "13: movl %%eax, 16(%3)\n"
29908 + "14: movl %%edx, 20(%3)\n"
29909 + "15: "__copyuser_seg" movl 24(%4), %%eax\n"
29910 + "16: "__copyuser_seg" movl 28(%4), %%edx\n"
29911 + "17: movl %%eax, 24(%3)\n"
29912 + "18: movl %%edx, 28(%3)\n"
29913 + "19: "__copyuser_seg" movl 32(%4), %%eax\n"
29914 + "20: "__copyuser_seg" movl 36(%4), %%edx\n"
29915 + "21: movl %%eax, 32(%3)\n"
29916 + "22: movl %%edx, 36(%3)\n"
29917 + "23: "__copyuser_seg" movl 40(%4), %%eax\n"
29918 + "24: "__copyuser_seg" movl 44(%4), %%edx\n"
29919 + "25: movl %%eax, 40(%3)\n"
29920 + "26: movl %%edx, 44(%3)\n"
29921 + "27: "__copyuser_seg" movl 48(%4), %%eax\n"
29922 + "28: "__copyuser_seg" movl 52(%4), %%edx\n"
29923 + "29: movl %%eax, 48(%3)\n"
29924 + "30: movl %%edx, 52(%3)\n"
29925 + "31: "__copyuser_seg" movl 56(%4), %%eax\n"
29926 + "32: "__copyuser_seg" movl 60(%4), %%edx\n"
29927 + "33: movl %%eax, 56(%3)\n"
29928 + "34: movl %%edx, 60(%3)\n"
29929 + " addl $-64, %0\n"
29930 + " addl $64, %4\n"
29931 + " addl $64, %3\n"
29932 + " cmpl $63, %0\n"
29933 + " ja 1b\n"
29934 + "35: movl %0, %%eax\n"
29935 + " shrl $2, %0\n"
29936 + " andl $3, %%eax\n"
29937 + " cld\n"
29938 + "99: rep; "__copyuser_seg" movsl\n"
29939 + "36: movl %%eax, %0\n"
29940 + "37: rep; "__copyuser_seg" movsb\n"
29941 + "100:\n"
29942 ".section .fixup,\"ax\"\n"
29943 "101: lea 0(%%eax,%0,4),%0\n"
29944 " jmp 100b\n"
29945 @@ -207,41 +315,41 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
29946 int d0, d1;
29947 __asm__ __volatile__(
29948 " .align 2,0x90\n"
29949 - "0: movl 32(%4), %%eax\n"
29950 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
29951 " cmpl $67, %0\n"
29952 " jbe 2f\n"
29953 - "1: movl 64(%4), %%eax\n"
29954 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
29955 " .align 2,0x90\n"
29956 - "2: movl 0(%4), %%eax\n"
29957 - "21: movl 4(%4), %%edx\n"
29958 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
29959 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
29960 " movl %%eax, 0(%3)\n"
29961 " movl %%edx, 4(%3)\n"
29962 - "3: movl 8(%4), %%eax\n"
29963 - "31: movl 12(%4),%%edx\n"
29964 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
29965 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
29966 " movl %%eax, 8(%3)\n"
29967 " movl %%edx, 12(%3)\n"
29968 - "4: movl 16(%4), %%eax\n"
29969 - "41: movl 20(%4), %%edx\n"
29970 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
29971 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
29972 " movl %%eax, 16(%3)\n"
29973 " movl %%edx, 20(%3)\n"
29974 - "10: movl 24(%4), %%eax\n"
29975 - "51: movl 28(%4), %%edx\n"
29976 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
29977 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
29978 " movl %%eax, 24(%3)\n"
29979 " movl %%edx, 28(%3)\n"
29980 - "11: movl 32(%4), %%eax\n"
29981 - "61: movl 36(%4), %%edx\n"
29982 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
29983 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
29984 " movl %%eax, 32(%3)\n"
29985 " movl %%edx, 36(%3)\n"
29986 - "12: movl 40(%4), %%eax\n"
29987 - "71: movl 44(%4), %%edx\n"
29988 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
29989 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
29990 " movl %%eax, 40(%3)\n"
29991 " movl %%edx, 44(%3)\n"
29992 - "13: movl 48(%4), %%eax\n"
29993 - "81: movl 52(%4), %%edx\n"
29994 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
29995 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
29996 " movl %%eax, 48(%3)\n"
29997 " movl %%edx, 52(%3)\n"
29998 - "14: movl 56(%4), %%eax\n"
29999 - "91: movl 60(%4), %%edx\n"
30000 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30001 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30002 " movl %%eax, 56(%3)\n"
30003 " movl %%edx, 60(%3)\n"
30004 " addl $-64, %0\n"
30005 @@ -253,9 +361,9 @@ __copy_user_zeroing_intel(void *to, const void __user *from, unsigned long size)
30006 " shrl $2, %0\n"
30007 " andl $3, %%eax\n"
30008 " cld\n"
30009 - "6: rep; movsl\n"
30010 + "6: rep; "__copyuser_seg" movsl\n"
30011 " movl %%eax,%0\n"
30012 - "7: rep; movsb\n"
30013 + "7: rep; "__copyuser_seg" movsb\n"
30014 "8:\n"
30015 ".section .fixup,\"ax\"\n"
30016 "9: lea 0(%%eax,%0,4),%0\n"
30017 @@ -305,41 +413,41 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30018
30019 __asm__ __volatile__(
30020 " .align 2,0x90\n"
30021 - "0: movl 32(%4), %%eax\n"
30022 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30023 " cmpl $67, %0\n"
30024 " jbe 2f\n"
30025 - "1: movl 64(%4), %%eax\n"
30026 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30027 " .align 2,0x90\n"
30028 - "2: movl 0(%4), %%eax\n"
30029 - "21: movl 4(%4), %%edx\n"
30030 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30031 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30032 " movnti %%eax, 0(%3)\n"
30033 " movnti %%edx, 4(%3)\n"
30034 - "3: movl 8(%4), %%eax\n"
30035 - "31: movl 12(%4),%%edx\n"
30036 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30037 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30038 " movnti %%eax, 8(%3)\n"
30039 " movnti %%edx, 12(%3)\n"
30040 - "4: movl 16(%4), %%eax\n"
30041 - "41: movl 20(%4), %%edx\n"
30042 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30043 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30044 " movnti %%eax, 16(%3)\n"
30045 " movnti %%edx, 20(%3)\n"
30046 - "10: movl 24(%4), %%eax\n"
30047 - "51: movl 28(%4), %%edx\n"
30048 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30049 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30050 " movnti %%eax, 24(%3)\n"
30051 " movnti %%edx, 28(%3)\n"
30052 - "11: movl 32(%4), %%eax\n"
30053 - "61: movl 36(%4), %%edx\n"
30054 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30055 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30056 " movnti %%eax, 32(%3)\n"
30057 " movnti %%edx, 36(%3)\n"
30058 - "12: movl 40(%4), %%eax\n"
30059 - "71: movl 44(%4), %%edx\n"
30060 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30061 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30062 " movnti %%eax, 40(%3)\n"
30063 " movnti %%edx, 44(%3)\n"
30064 - "13: movl 48(%4), %%eax\n"
30065 - "81: movl 52(%4), %%edx\n"
30066 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30067 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30068 " movnti %%eax, 48(%3)\n"
30069 " movnti %%edx, 52(%3)\n"
30070 - "14: movl 56(%4), %%eax\n"
30071 - "91: movl 60(%4), %%edx\n"
30072 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30073 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30074 " movnti %%eax, 56(%3)\n"
30075 " movnti %%edx, 60(%3)\n"
30076 " addl $-64, %0\n"
30077 @@ -352,9 +460,9 @@ static unsigned long __copy_user_zeroing_intel_nocache(void *to,
30078 " shrl $2, %0\n"
30079 " andl $3, %%eax\n"
30080 " cld\n"
30081 - "6: rep; movsl\n"
30082 + "6: rep; "__copyuser_seg" movsl\n"
30083 " movl %%eax,%0\n"
30084 - "7: rep; movsb\n"
30085 + "7: rep; "__copyuser_seg" movsb\n"
30086 "8:\n"
30087 ".section .fixup,\"ax\"\n"
30088 "9: lea 0(%%eax,%0,4),%0\n"
30089 @@ -399,41 +507,41 @@ static unsigned long __copy_user_intel_nocache(void *to,
30090
30091 __asm__ __volatile__(
30092 " .align 2,0x90\n"
30093 - "0: movl 32(%4), %%eax\n"
30094 + "0: "__copyuser_seg" movl 32(%4), %%eax\n"
30095 " cmpl $67, %0\n"
30096 " jbe 2f\n"
30097 - "1: movl 64(%4), %%eax\n"
30098 + "1: "__copyuser_seg" movl 64(%4), %%eax\n"
30099 " .align 2,0x90\n"
30100 - "2: movl 0(%4), %%eax\n"
30101 - "21: movl 4(%4), %%edx\n"
30102 + "2: "__copyuser_seg" movl 0(%4), %%eax\n"
30103 + "21: "__copyuser_seg" movl 4(%4), %%edx\n"
30104 " movnti %%eax, 0(%3)\n"
30105 " movnti %%edx, 4(%3)\n"
30106 - "3: movl 8(%4), %%eax\n"
30107 - "31: movl 12(%4),%%edx\n"
30108 + "3: "__copyuser_seg" movl 8(%4), %%eax\n"
30109 + "31: "__copyuser_seg" movl 12(%4),%%edx\n"
30110 " movnti %%eax, 8(%3)\n"
30111 " movnti %%edx, 12(%3)\n"
30112 - "4: movl 16(%4), %%eax\n"
30113 - "41: movl 20(%4), %%edx\n"
30114 + "4: "__copyuser_seg" movl 16(%4), %%eax\n"
30115 + "41: "__copyuser_seg" movl 20(%4), %%edx\n"
30116 " movnti %%eax, 16(%3)\n"
30117 " movnti %%edx, 20(%3)\n"
30118 - "10: movl 24(%4), %%eax\n"
30119 - "51: movl 28(%4), %%edx\n"
30120 + "10: "__copyuser_seg" movl 24(%4), %%eax\n"
30121 + "51: "__copyuser_seg" movl 28(%4), %%edx\n"
30122 " movnti %%eax, 24(%3)\n"
30123 " movnti %%edx, 28(%3)\n"
30124 - "11: movl 32(%4), %%eax\n"
30125 - "61: movl 36(%4), %%edx\n"
30126 + "11: "__copyuser_seg" movl 32(%4), %%eax\n"
30127 + "61: "__copyuser_seg" movl 36(%4), %%edx\n"
30128 " movnti %%eax, 32(%3)\n"
30129 " movnti %%edx, 36(%3)\n"
30130 - "12: movl 40(%4), %%eax\n"
30131 - "71: movl 44(%4), %%edx\n"
30132 + "12: "__copyuser_seg" movl 40(%4), %%eax\n"
30133 + "71: "__copyuser_seg" movl 44(%4), %%edx\n"
30134 " movnti %%eax, 40(%3)\n"
30135 " movnti %%edx, 44(%3)\n"
30136 - "13: movl 48(%4), %%eax\n"
30137 - "81: movl 52(%4), %%edx\n"
30138 + "13: "__copyuser_seg" movl 48(%4), %%eax\n"
30139 + "81: "__copyuser_seg" movl 52(%4), %%edx\n"
30140 " movnti %%eax, 48(%3)\n"
30141 " movnti %%edx, 52(%3)\n"
30142 - "14: movl 56(%4), %%eax\n"
30143 - "91: movl 60(%4), %%edx\n"
30144 + "14: "__copyuser_seg" movl 56(%4), %%eax\n"
30145 + "91: "__copyuser_seg" movl 60(%4), %%edx\n"
30146 " movnti %%eax, 56(%3)\n"
30147 " movnti %%edx, 60(%3)\n"
30148 " addl $-64, %0\n"
30149 @@ -446,9 +554,9 @@ static unsigned long __copy_user_intel_nocache(void *to,
30150 " shrl $2, %0\n"
30151 " andl $3, %%eax\n"
30152 " cld\n"
30153 - "6: rep; movsl\n"
30154 + "6: rep; "__copyuser_seg" movsl\n"
30155 " movl %%eax,%0\n"
30156 - "7: rep; movsb\n"
30157 + "7: rep; "__copyuser_seg" movsb\n"
30158 "8:\n"
30159 ".section .fixup,\"ax\"\n"
30160 "9: lea 0(%%eax,%0,4),%0\n"
30161 @@ -488,32 +596,36 @@ static unsigned long __copy_user_intel_nocache(void *to,
30162 */
30163 unsigned long __copy_user_zeroing_intel(void *to, const void __user *from,
30164 unsigned long size);
30165 -unsigned long __copy_user_intel(void __user *to, const void *from,
30166 +unsigned long __generic_copy_to_user_intel(void __user *to, const void *from,
30167 + unsigned long size);
30168 +unsigned long __generic_copy_from_user_intel(void *to, const void __user *from,
30169 unsigned long size);
30170 unsigned long __copy_user_zeroing_intel_nocache(void *to,
30171 const void __user *from, unsigned long size);
30172 #endif /* CONFIG_X86_INTEL_USERCOPY */
30173
30174 /* Generic arbitrary sized copy. */
30175 -#define __copy_user(to, from, size) \
30176 +#define __copy_user(to, from, size, prefix, set, restore) \
30177 do { \
30178 int __d0, __d1, __d2; \
30179 __asm__ __volatile__( \
30180 + set \
30181 " cmp $7,%0\n" \
30182 " jbe 1f\n" \
30183 " movl %1,%0\n" \
30184 " negl %0\n" \
30185 " andl $7,%0\n" \
30186 " subl %0,%3\n" \
30187 - "4: rep; movsb\n" \
30188 + "4: rep; "prefix"movsb\n" \
30189 " movl %3,%0\n" \
30190 " shrl $2,%0\n" \
30191 " andl $3,%3\n" \
30192 " .align 2,0x90\n" \
30193 - "0: rep; movsl\n" \
30194 + "0: rep; "prefix"movsl\n" \
30195 " movl %3,%0\n" \
30196 - "1: rep; movsb\n" \
30197 + "1: rep; "prefix"movsb\n" \
30198 "2:\n" \
30199 + restore \
30200 ".section .fixup,\"ax\"\n" \
30201 "5: addl %3,%0\n" \
30202 " jmp 2b\n" \
30203 @@ -538,14 +650,14 @@ do { \
30204 " negl %0\n" \
30205 " andl $7,%0\n" \
30206 " subl %0,%3\n" \
30207 - "4: rep; movsb\n" \
30208 + "4: rep; "__copyuser_seg"movsb\n" \
30209 " movl %3,%0\n" \
30210 " shrl $2,%0\n" \
30211 " andl $3,%3\n" \
30212 " .align 2,0x90\n" \
30213 - "0: rep; movsl\n" \
30214 + "0: rep; "__copyuser_seg"movsl\n" \
30215 " movl %3,%0\n" \
30216 - "1: rep; movsb\n" \
30217 + "1: rep; "__copyuser_seg"movsb\n" \
30218 "2:\n" \
30219 ".section .fixup,\"ax\"\n" \
30220 "5: addl %3,%0\n" \
30221 @@ -572,9 +684,9 @@ unsigned long __copy_to_user_ll(void __user *to, const void *from,
30222 {
30223 stac();
30224 if (movsl_is_ok(to, from, n))
30225 - __copy_user(to, from, n);
30226 + __copy_user(to, from, n, "", __COPYUSER_SET_ES, __COPYUSER_RESTORE_ES);
30227 else
30228 - n = __copy_user_intel(to, from, n);
30229 + n = __generic_copy_to_user_intel(to, from, n);
30230 clac();
30231 return n;
30232 }
30233 @@ -598,10 +710,9 @@ unsigned long __copy_from_user_ll_nozero(void *to, const void __user *from,
30234 {
30235 stac();
30236 if (movsl_is_ok(to, from, n))
30237 - __copy_user(to, from, n);
30238 + __copy_user(to, from, n, __copyuser_seg, "", "");
30239 else
30240 - n = __copy_user_intel((void __user *)to,
30241 - (const void *)from, n);
30242 + n = __generic_copy_from_user_intel(to, from, n);
30243 clac();
30244 return n;
30245 }
30246 @@ -632,60 +743,38 @@ unsigned long __copy_from_user_ll_nocache_nozero(void *to, const void __user *fr
30247 if (n > 64 && cpu_has_xmm2)
30248 n = __copy_user_intel_nocache(to, from, n);
30249 else
30250 - __copy_user(to, from, n);
30251 + __copy_user(to, from, n, __copyuser_seg, "", "");
30252 #else
30253 - __copy_user(to, from, n);
30254 + __copy_user(to, from, n, __copyuser_seg, "", "");
30255 #endif
30256 clac();
30257 return n;
30258 }
30259 EXPORT_SYMBOL(__copy_from_user_ll_nocache_nozero);
30260
30261 -/**
30262 - * copy_to_user: - Copy a block of data into user space.
30263 - * @to: Destination address, in user space.
30264 - * @from: Source address, in kernel space.
30265 - * @n: Number of bytes to copy.
30266 - *
30267 - * Context: User context only. This function may sleep.
30268 - *
30269 - * Copy data from kernel space to user space.
30270 - *
30271 - * Returns number of bytes that could not be copied.
30272 - * On success, this will be zero.
30273 - */
30274 -unsigned long
30275 -copy_to_user(void __user *to, const void *from, unsigned long n)
30276 +#ifdef CONFIG_PAX_MEMORY_UDEREF
30277 +void __set_fs(mm_segment_t x)
30278 {
30279 - if (access_ok(VERIFY_WRITE, to, n))
30280 - n = __copy_to_user(to, from, n);
30281 - return n;
30282 + switch (x.seg) {
30283 + case 0:
30284 + loadsegment(gs, 0);
30285 + break;
30286 + case TASK_SIZE_MAX:
30287 + loadsegment(gs, __USER_DS);
30288 + break;
30289 + case -1UL:
30290 + loadsegment(gs, __KERNEL_DS);
30291 + break;
30292 + default:
30293 + BUG();
30294 + }
30295 }
30296 -EXPORT_SYMBOL(copy_to_user);
30297 +EXPORT_SYMBOL(__set_fs);
30298
30299 -/**
30300 - * copy_from_user: - Copy a block of data from user space.
30301 - * @to: Destination address, in kernel space.
30302 - * @from: Source address, in user space.
30303 - * @n: Number of bytes to copy.
30304 - *
30305 - * Context: User context only. This function may sleep.
30306 - *
30307 - * Copy data from user space to kernel space.
30308 - *
30309 - * Returns number of bytes that could not be copied.
30310 - * On success, this will be zero.
30311 - *
30312 - * If some data could not be copied, this function will pad the copied
30313 - * data to the requested size using zero bytes.
30314 - */
30315 -unsigned long
30316 -_copy_from_user(void *to, const void __user *from, unsigned long n)
30317 +void set_fs(mm_segment_t x)
30318 {
30319 - if (access_ok(VERIFY_READ, from, n))
30320 - n = __copy_from_user(to, from, n);
30321 - else
30322 - memset(to, 0, n);
30323 - return n;
30324 + current_thread_info()->addr_limit = x;
30325 + __set_fs(x);
30326 }
30327 -EXPORT_SYMBOL(_copy_from_user);
30328 +EXPORT_SYMBOL(set_fs);
30329 +#endif
30330 diff --git a/arch/x86/lib/usercopy_64.c b/arch/x86/lib/usercopy_64.c
30331 index c905e89..01ab928 100644
30332 --- a/arch/x86/lib/usercopy_64.c
30333 +++ b/arch/x86/lib/usercopy_64.c
30334 @@ -18,6 +18,7 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30335 might_fault();
30336 /* no memory constraint because it doesn't change any memory gcc knows
30337 about */
30338 + pax_open_userland();
30339 stac();
30340 asm volatile(
30341 " testq %[size8],%[size8]\n"
30342 @@ -39,9 +40,10 @@ unsigned long __clear_user(void __user *addr, unsigned long size)
30343 _ASM_EXTABLE(0b,3b)
30344 _ASM_EXTABLE(1b,2b)
30345 : [size8] "=&c"(size), [dst] "=&D" (__d0)
30346 - : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(addr),
30347 + : [size1] "r"(size & 7), "[size8]" (size / 8), "[dst]"(____m(addr)),
30348 [zero] "r" (0UL), [eight] "r" (8UL));
30349 clac();
30350 + pax_close_userland();
30351 return size;
30352 }
30353 EXPORT_SYMBOL(__clear_user);
30354 @@ -54,12 +56,11 @@ unsigned long clear_user(void __user *to, unsigned long n)
30355 }
30356 EXPORT_SYMBOL(clear_user);
30357
30358 -unsigned long copy_in_user(void __user *to, const void __user *from, unsigned len)
30359 +unsigned long copy_in_user(void __user *to, const void __user *from, unsigned long len)
30360 {
30361 - if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len)) {
30362 - return copy_user_generic((__force void *)to, (__force void *)from, len);
30363 - }
30364 - return len;
30365 + if (access_ok(VERIFY_WRITE, to, len) && access_ok(VERIFY_READ, from, len))
30366 + return copy_user_generic((void __force_kernel *)____m(to), (void __force_kernel *)____m(from), len);
30367 + return len;
30368 }
30369 EXPORT_SYMBOL(copy_in_user);
30370
30371 @@ -69,11 +70,13 @@ EXPORT_SYMBOL(copy_in_user);
30372 * it is not necessary to optimize tail handling.
30373 */
30374 __visible unsigned long
30375 -copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30376 +copy_user_handle_tail(char __user *to, char __user *from, unsigned long len, unsigned zerorest)
30377 {
30378 char c;
30379 unsigned zero_len;
30380
30381 + clac();
30382 + pax_close_userland();
30383 for (; len; --len, to++) {
30384 if (__get_user_nocheck(c, from++, sizeof(char)))
30385 break;
30386 @@ -84,6 +87,5 @@ copy_user_handle_tail(char *to, char *from, unsigned len, unsigned zerorest)
30387 for (c = 0, zero_len = len; zerorest && zero_len; --zero_len)
30388 if (__put_user_nocheck(c, to++, sizeof(char)))
30389 break;
30390 - clac();
30391 return len;
30392 }
30393 diff --git a/arch/x86/mm/Makefile b/arch/x86/mm/Makefile
30394 index 23d8e5f..9ccc13a 100644
30395 --- a/arch/x86/mm/Makefile
30396 +++ b/arch/x86/mm/Makefile
30397 @@ -28,3 +28,7 @@ obj-$(CONFIG_ACPI_NUMA) += srat.o
30398 obj-$(CONFIG_NUMA_EMU) += numa_emulation.o
30399
30400 obj-$(CONFIG_MEMTEST) += memtest.o
30401 +
30402 +quote:="
30403 +obj-$(CONFIG_X86_64) += uderef_64.o
30404 +CFLAGS_uderef_64.o := $(subst $(quote),,$(CONFIG_ARCH_HWEIGHT_CFLAGS))
30405 diff --git a/arch/x86/mm/extable.c b/arch/x86/mm/extable.c
30406 index 903ec1e..c4166b2 100644
30407 --- a/arch/x86/mm/extable.c
30408 +++ b/arch/x86/mm/extable.c
30409 @@ -6,12 +6,24 @@
30410 static inline unsigned long
30411 ex_insn_addr(const struct exception_table_entry *x)
30412 {
30413 - return (unsigned long)&x->insn + x->insn;
30414 + unsigned long reloc = 0;
30415 +
30416 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30417 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30418 +#endif
30419 +
30420 + return (unsigned long)&x->insn + x->insn + reloc;
30421 }
30422 static inline unsigned long
30423 ex_fixup_addr(const struct exception_table_entry *x)
30424 {
30425 - return (unsigned long)&x->fixup + x->fixup;
30426 + unsigned long reloc = 0;
30427 +
30428 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30429 + reloc = ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30430 +#endif
30431 +
30432 + return (unsigned long)&x->fixup + x->fixup + reloc;
30433 }
30434
30435 int fixup_exception(struct pt_regs *regs)
30436 @@ -20,7 +32,7 @@ int fixup_exception(struct pt_regs *regs)
30437 unsigned long new_ip;
30438
30439 #ifdef CONFIG_PNPBIOS
30440 - if (unlikely(SEGMENT_IS_PNP_CODE(regs->cs))) {
30441 + if (unlikely(!v8086_mode(regs) && SEGMENT_IS_PNP_CODE(regs->cs))) {
30442 extern u32 pnp_bios_fault_eip, pnp_bios_fault_esp;
30443 extern u32 pnp_bios_is_utter_crap;
30444 pnp_bios_is_utter_crap = 1;
30445 @@ -145,6 +157,13 @@ void sort_extable(struct exception_table_entry *start,
30446 i += 4;
30447 p->fixup -= i;
30448 i += 4;
30449 +
30450 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
30451 + BUILD_BUG_ON(!IS_ENABLED(CONFIG_BUILDTIME_EXTABLE_SORT));
30452 + p->insn -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30453 + p->fixup -= ____LOAD_PHYSICAL_ADDR - LOAD_PHYSICAL_ADDR;
30454 +#endif
30455 +
30456 }
30457 }
30458
30459 diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
30460 index 3aaeffc..42ea9fb 100644
30461 --- a/arch/x86/mm/fault.c
30462 +++ b/arch/x86/mm/fault.c
30463 @@ -14,11 +14,18 @@
30464 #include <linux/hugetlb.h> /* hstate_index_to_shift */
30465 #include <linux/prefetch.h> /* prefetchw */
30466 #include <linux/context_tracking.h> /* exception_enter(), ... */
30467 +#include <linux/unistd.h>
30468 +#include <linux/compiler.h>
30469
30470 #include <asm/traps.h> /* dotraplinkage, ... */
30471 #include <asm/pgalloc.h> /* pgd_*(), ... */
30472 #include <asm/kmemcheck.h> /* kmemcheck_*(), ... */
30473 #include <asm/fixmap.h> /* VSYSCALL_START */
30474 +#include <asm/tlbflush.h>
30475 +
30476 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30477 +#include <asm/stacktrace.h>
30478 +#endif
30479
30480 /*
30481 * Page fault error code bits:
30482 @@ -56,7 +63,7 @@ static inline int __kprobes notify_page_fault(struct pt_regs *regs)
30483 int ret = 0;
30484
30485 /* kprobe_running() needs smp_processor_id() */
30486 - if (kprobes_built_in() && !user_mode_vm(regs)) {
30487 + if (kprobes_built_in() && !user_mode(regs)) {
30488 preempt_disable();
30489 if (kprobe_running() && kprobe_fault_handler(regs, 14))
30490 ret = 1;
30491 @@ -117,7 +124,10 @@ check_prefetch_opcode(struct pt_regs *regs, unsigned char *instr,
30492 return !instr_lo || (instr_lo>>1) == 1;
30493 case 0x00:
30494 /* Prefetch instruction is 0x0F0D or 0x0F18 */
30495 - if (probe_kernel_address(instr, opcode))
30496 + if (user_mode(regs)) {
30497 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30498 + return 0;
30499 + } else if (probe_kernel_address(instr, opcode))
30500 return 0;
30501
30502 *prefetch = (instr_lo == 0xF) &&
30503 @@ -151,7 +161,10 @@ is_prefetch(struct pt_regs *regs, unsigned long error_code, unsigned long addr)
30504 while (instr < max_instr) {
30505 unsigned char opcode;
30506
30507 - if (probe_kernel_address(instr, opcode))
30508 + if (user_mode(regs)) {
30509 + if (__copy_from_user_inatomic(&opcode, (unsigned char __force_user *)(instr), 1))
30510 + break;
30511 + } else if (probe_kernel_address(instr, opcode))
30512 break;
30513
30514 instr++;
30515 @@ -182,6 +195,34 @@ force_sig_info_fault(int si_signo, int si_code, unsigned long address,
30516 force_sig_info(si_signo, &info, tsk);
30517 }
30518
30519 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30520 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address);
30521 +#endif
30522 +
30523 +#ifdef CONFIG_PAX_EMUTRAMP
30524 +static int pax_handle_fetch_fault(struct pt_regs *regs);
30525 +#endif
30526 +
30527 +#ifdef CONFIG_PAX_PAGEEXEC
30528 +static inline pmd_t * pax_get_pmd(struct mm_struct *mm, unsigned long address)
30529 +{
30530 + pgd_t *pgd;
30531 + pud_t *pud;
30532 + pmd_t *pmd;
30533 +
30534 + pgd = pgd_offset(mm, address);
30535 + if (!pgd_present(*pgd))
30536 + return NULL;
30537 + pud = pud_offset(pgd, address);
30538 + if (!pud_present(*pud))
30539 + return NULL;
30540 + pmd = pmd_offset(pud, address);
30541 + if (!pmd_present(*pmd))
30542 + return NULL;
30543 + return pmd;
30544 +}
30545 +#endif
30546 +
30547 DEFINE_SPINLOCK(pgd_lock);
30548 LIST_HEAD(pgd_list);
30549
30550 @@ -232,10 +273,27 @@ void vmalloc_sync_all(void)
30551 for (address = VMALLOC_START & PMD_MASK;
30552 address >= TASK_SIZE && address < FIXADDR_TOP;
30553 address += PMD_SIZE) {
30554 +
30555 +#ifdef CONFIG_PAX_PER_CPU_PGD
30556 + unsigned long cpu;
30557 +#else
30558 struct page *page;
30559 +#endif
30560
30561 spin_lock(&pgd_lock);
30562 +
30563 +#ifdef CONFIG_PAX_PER_CPU_PGD
30564 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
30565 + pgd_t *pgd = get_cpu_pgd(cpu, user);
30566 + pmd_t *ret;
30567 +
30568 + ret = vmalloc_sync_one(pgd, address);
30569 + if (!ret)
30570 + break;
30571 + pgd = get_cpu_pgd(cpu, kernel);
30572 +#else
30573 list_for_each_entry(page, &pgd_list, lru) {
30574 + pgd_t *pgd;
30575 spinlock_t *pgt_lock;
30576 pmd_t *ret;
30577
30578 @@ -243,8 +301,14 @@ void vmalloc_sync_all(void)
30579 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
30580
30581 spin_lock(pgt_lock);
30582 - ret = vmalloc_sync_one(page_address(page), address);
30583 + pgd = page_address(page);
30584 +#endif
30585 +
30586 + ret = vmalloc_sync_one(pgd, address);
30587 +
30588 +#ifndef CONFIG_PAX_PER_CPU_PGD
30589 spin_unlock(pgt_lock);
30590 +#endif
30591
30592 if (!ret)
30593 break;
30594 @@ -278,6 +342,12 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30595 * an interrupt in the middle of a task switch..
30596 */
30597 pgd_paddr = read_cr3();
30598 +
30599 +#ifdef CONFIG_PAX_PER_CPU_PGD
30600 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (pgd_paddr & __PHYSICAL_MASK));
30601 + vmalloc_sync_one(__va(pgd_paddr + PAGE_SIZE), address);
30602 +#endif
30603 +
30604 pmd_k = vmalloc_sync_one(__va(pgd_paddr), address);
30605 if (!pmd_k)
30606 return -1;
30607 @@ -373,11 +443,25 @@ static noinline __kprobes int vmalloc_fault(unsigned long address)
30608 * happen within a race in page table update. In the later
30609 * case just flush:
30610 */
30611 - pgd = pgd_offset(current->active_mm, address);
30612 +
30613 pgd_ref = pgd_offset_k(address);
30614 if (pgd_none(*pgd_ref))
30615 return -1;
30616
30617 +#ifdef CONFIG_PAX_PER_CPU_PGD
30618 + BUG_ON(__pa(get_cpu_pgd(smp_processor_id(), kernel)) != (read_cr3() & __PHYSICAL_MASK));
30619 + pgd = pgd_offset_cpu(smp_processor_id(), user, address);
30620 + if (pgd_none(*pgd)) {
30621 + set_pgd(pgd, *pgd_ref);
30622 + arch_flush_lazy_mmu_mode();
30623 + } else {
30624 + BUG_ON(pgd_page_vaddr(*pgd) != pgd_page_vaddr(*pgd_ref));
30625 + }
30626 + pgd = pgd_offset_cpu(smp_processor_id(), kernel, address);
30627 +#else
30628 + pgd = pgd_offset(current->active_mm, address);
30629 +#endif
30630 +
30631 if (pgd_none(*pgd)) {
30632 set_pgd(pgd, *pgd_ref);
30633 arch_flush_lazy_mmu_mode();
30634 @@ -543,7 +627,7 @@ static int is_errata93(struct pt_regs *regs, unsigned long address)
30635 static int is_errata100(struct pt_regs *regs, unsigned long address)
30636 {
30637 #ifdef CONFIG_X86_64
30638 - if ((regs->cs == __USER32_CS || (regs->cs & (1<<2))) && (address >> 32))
30639 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)) && (address >> 32))
30640 return 1;
30641 #endif
30642 return 0;
30643 @@ -570,7 +654,7 @@ static int is_f00f_bug(struct pt_regs *regs, unsigned long address)
30644 }
30645
30646 static const char nx_warning[] = KERN_CRIT
30647 -"kernel tried to execute NX-protected page - exploit attempt? (uid: %d)\n";
30648 +"kernel tried to execute NX-protected page - exploit attempt? (uid: %d, task: %s, pid: %d)\n";
30649
30650 static void
30651 show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30652 @@ -579,15 +663,27 @@ show_fault_oops(struct pt_regs *regs, unsigned long error_code,
30653 if (!oops_may_print())
30654 return;
30655
30656 - if (error_code & PF_INSTR) {
30657 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR)) {
30658 unsigned int level;
30659
30660 pte_t *pte = lookup_address(address, &level);
30661
30662 if (pte && pte_present(*pte) && !pte_exec(*pte))
30663 - printk(nx_warning, from_kuid(&init_user_ns, current_uid()));
30664 + printk(nx_warning, from_kuid_munged(&init_user_ns, current_uid()), current->comm, task_pid_nr(current));
30665 }
30666
30667 +#ifdef CONFIG_PAX_KERNEXEC
30668 + if (init_mm.start_code <= address && address < init_mm.end_code) {
30669 + if (current->signal->curr_ip)
30670 + printk(KERN_ERR "PAX: From %pI4: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n",
30671 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
30672 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30673 + else
30674 + printk(KERN_ERR "PAX: %s:%d, uid/euid: %u/%u, attempted to modify kernel code\n", current->comm, task_pid_nr(current),
30675 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
30676 + }
30677 +#endif
30678 +
30679 printk(KERN_ALERT "BUG: unable to handle kernel ");
30680 if (address < PAGE_SIZE)
30681 printk(KERN_CONT "NULL pointer dereference");
30682 @@ -750,6 +846,22 @@ __bad_area_nosemaphore(struct pt_regs *regs, unsigned long error_code,
30683 return;
30684 }
30685 #endif
30686 +
30687 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30688 + if (pax_is_fetch_fault(regs, error_code, address)) {
30689 +
30690 +#ifdef CONFIG_PAX_EMUTRAMP
30691 + switch (pax_handle_fetch_fault(regs)) {
30692 + case 2:
30693 + return;
30694 + }
30695 +#endif
30696 +
30697 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30698 + do_group_exit(SIGKILL);
30699 + }
30700 +#endif
30701 +
30702 /* Kernel addresses are always protection faults: */
30703 if (address >= TASK_SIZE)
30704 error_code |= PF_PROT;
30705 @@ -835,7 +947,7 @@ do_sigbus(struct pt_regs *regs, unsigned long error_code, unsigned long address,
30706 if (fault & (VM_FAULT_HWPOISON|VM_FAULT_HWPOISON_LARGE)) {
30707 printk(KERN_ERR
30708 "MCE: Killing %s:%d due to hardware memory corruption fault at %lx\n",
30709 - tsk->comm, tsk->pid, address);
30710 + tsk->comm, task_pid_nr(tsk), address);
30711 code = BUS_MCEERR_AR;
30712 }
30713 #endif
30714 @@ -889,6 +1001,99 @@ static int spurious_fault_check(unsigned long error_code, pte_t *pte)
30715 return 1;
30716 }
30717
30718 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30719 +static int pax_handle_pageexec_fault(struct pt_regs *regs, struct mm_struct *mm, unsigned long address, unsigned long error_code)
30720 +{
30721 + pte_t *pte;
30722 + pmd_t *pmd;
30723 + spinlock_t *ptl;
30724 + unsigned char pte_mask;
30725 +
30726 + if ((__supported_pte_mask & _PAGE_NX) || (error_code & (PF_PROT|PF_USER)) != (PF_PROT|PF_USER) || v8086_mode(regs) ||
30727 + !(mm->pax_flags & MF_PAX_PAGEEXEC))
30728 + return 0;
30729 +
30730 + /* PaX: it's our fault, let's handle it if we can */
30731 +
30732 + /* PaX: take a look at read faults before acquiring any locks */
30733 + if (unlikely(!(error_code & PF_WRITE) && (regs->ip == address))) {
30734 + /* instruction fetch attempt from a protected page in user mode */
30735 + up_read(&mm->mmap_sem);
30736 +
30737 +#ifdef CONFIG_PAX_EMUTRAMP
30738 + switch (pax_handle_fetch_fault(regs)) {
30739 + case 2:
30740 + return 1;
30741 + }
30742 +#endif
30743 +
30744 + pax_report_fault(regs, (void *)regs->ip, (void *)regs->sp);
30745 + do_group_exit(SIGKILL);
30746 + }
30747 +
30748 + pmd = pax_get_pmd(mm, address);
30749 + if (unlikely(!pmd))
30750 + return 0;
30751 +
30752 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
30753 + if (unlikely(!(pte_val(*pte) & _PAGE_PRESENT) || pte_user(*pte))) {
30754 + pte_unmap_unlock(pte, ptl);
30755 + return 0;
30756 + }
30757 +
30758 + if (unlikely((error_code & PF_WRITE) && !pte_write(*pte))) {
30759 + /* write attempt to a protected page in user mode */
30760 + pte_unmap_unlock(pte, ptl);
30761 + return 0;
30762 + }
30763 +
30764 +#ifdef CONFIG_SMP
30765 + if (likely(address > get_limit(regs->cs) && cpu_isset(smp_processor_id(), mm->context.cpu_user_cs_mask)))
30766 +#else
30767 + if (likely(address > get_limit(regs->cs)))
30768 +#endif
30769 + {
30770 + set_pte(pte, pte_mkread(*pte));
30771 + __flush_tlb_one(address);
30772 + pte_unmap_unlock(pte, ptl);
30773 + up_read(&mm->mmap_sem);
30774 + return 1;
30775 + }
30776 +
30777 + pte_mask = _PAGE_ACCESSED | _PAGE_USER | ((error_code & PF_WRITE) << (_PAGE_BIT_DIRTY-1));
30778 +
30779 + /*
30780 + * PaX: fill DTLB with user rights and retry
30781 + */
30782 + __asm__ __volatile__ (
30783 + "orb %2,(%1)\n"
30784 +#if defined(CONFIG_M586) || defined(CONFIG_M586TSC)
30785 +/*
30786 + * PaX: let this uncommented 'invlpg' remind us on the behaviour of Intel's
30787 + * (and AMD's) TLBs. namely, they do not cache PTEs that would raise *any*
30788 + * page fault when examined during a TLB load attempt. this is true not only
30789 + * for PTEs holding a non-present entry but also present entries that will
30790 + * raise a page fault (such as those set up by PaX, or the copy-on-write
30791 + * mechanism). in effect it means that we do *not* need to flush the TLBs
30792 + * for our target pages since their PTEs are simply not in the TLBs at all.
30793 +
30794 + * the best thing in omitting it is that we gain around 15-20% speed in the
30795 + * fast path of the page fault handler and can get rid of tracing since we
30796 + * can no longer flush unintended entries.
30797 + */
30798 + "invlpg (%0)\n"
30799 +#endif
30800 + __copyuser_seg"testb $0,(%0)\n"
30801 + "xorb %3,(%1)\n"
30802 + :
30803 + : "r" (address), "r" (pte), "q" (pte_mask), "i" (_PAGE_USER)
30804 + : "memory", "cc");
30805 + pte_unmap_unlock(pte, ptl);
30806 + up_read(&mm->mmap_sem);
30807 + return 1;
30808 +}
30809 +#endif
30810 +
30811 /*
30812 * Handle a spurious fault caused by a stale TLB entry.
30813 *
30814 @@ -955,6 +1160,9 @@ int show_unhandled_signals = 1;
30815 static inline int
30816 access_error(unsigned long error_code, struct vm_area_struct *vma)
30817 {
30818 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR) && !(vma->vm_flags & VM_EXEC))
30819 + return 1;
30820 +
30821 if (error_code & PF_WRITE) {
30822 /* write, present and write, not present: */
30823 if (unlikely(!(vma->vm_flags & VM_WRITE)))
30824 @@ -983,7 +1191,7 @@ static inline bool smap_violation(int error_code, struct pt_regs *regs)
30825 if (error_code & PF_USER)
30826 return false;
30827
30828 - if (!user_mode_vm(regs) && (regs->flags & X86_EFLAGS_AC))
30829 + if (!user_mode(regs) && (regs->flags & X86_EFLAGS_AC))
30830 return false;
30831
30832 return true;
30833 @@ -1010,6 +1218,22 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30834 /* Get the faulting address: */
30835 address = read_cr2();
30836
30837 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
30838 + if (!user_mode(regs) && address < 2 * pax_user_shadow_base) {
30839 + if (!search_exception_tables(regs->ip)) {
30840 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30841 + bad_area_nosemaphore(regs, error_code, address);
30842 + return;
30843 + }
30844 + if (address < pax_user_shadow_base) {
30845 + printk(KERN_ERR "PAX: please report this to pageexec@freemail.hu\n");
30846 + printk(KERN_ERR "PAX: faulting IP: %pS\n", (void *)regs->ip);
30847 + show_trace_log_lvl(NULL, NULL, (void *)regs->sp, regs->bp, KERN_ERR);
30848 + } else
30849 + address -= pax_user_shadow_base;
30850 + }
30851 +#endif
30852 +
30853 /*
30854 * Detect and handle instructions that would cause a page fault for
30855 * both a tracked kernel page and a userspace page.
30856 @@ -1069,7 +1293,7 @@ __do_page_fault(struct pt_regs *regs, unsigned long error_code)
30857 * User-mode registers count as a user access even for any
30858 * potential system fault or CPU buglet:
30859 */
30860 - if (user_mode_vm(regs)) {
30861 + if (user_mode(regs)) {
30862 local_irq_enable();
30863 error_code |= PF_USER;
30864 flags |= FAULT_FLAG_USER;
30865 @@ -1135,6 +1359,11 @@ retry:
30866 might_sleep();
30867 }
30868
30869 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_PAGEEXEC)
30870 + if (pax_handle_pageexec_fault(regs, mm, address, error_code))
30871 + return;
30872 +#endif
30873 +
30874 vma = find_vma(mm, address);
30875 if (unlikely(!vma)) {
30876 bad_area(regs, error_code, address);
30877 @@ -1146,18 +1375,24 @@ retry:
30878 bad_area(regs, error_code, address);
30879 return;
30880 }
30881 - if (error_code & PF_USER) {
30882 - /*
30883 - * Accessing the stack below %sp is always a bug.
30884 - * The large cushion allows instructions like enter
30885 - * and pusha to work. ("enter $65535, $31" pushes
30886 - * 32 pointers and then decrements %sp by 65535.)
30887 - */
30888 - if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < regs->sp)) {
30889 - bad_area(regs, error_code, address);
30890 - return;
30891 - }
30892 + /*
30893 + * Accessing the stack below %sp is always a bug.
30894 + * The large cushion allows instructions like enter
30895 + * and pusha to work. ("enter $65535, $31" pushes
30896 + * 32 pointers and then decrements %sp by 65535.)
30897 + */
30898 + if (unlikely(address + 65536 + 32 * sizeof(unsigned long) < task_pt_regs(tsk)->sp)) {
30899 + bad_area(regs, error_code, address);
30900 + return;
30901 }
30902 +
30903 +#ifdef CONFIG_PAX_SEGMEXEC
30904 + if (unlikely((mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end - SEGMEXEC_TASK_SIZE - 1 < address - SEGMEXEC_TASK_SIZE - 1)) {
30905 + bad_area(regs, error_code, address);
30906 + return;
30907 + }
30908 +#endif
30909 +
30910 if (unlikely(expand_stack(vma, address))) {
30911 bad_area(regs, error_code, address);
30912 return;
30913 @@ -1231,3 +1466,292 @@ do_page_fault(struct pt_regs *regs, unsigned long error_code)
30914 __do_page_fault(regs, error_code);
30915 exception_exit(prev_state);
30916 }
30917 +
30918 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
30919 +static bool pax_is_fetch_fault(struct pt_regs *regs, unsigned long error_code, unsigned long address)
30920 +{
30921 + struct mm_struct *mm = current->mm;
30922 + unsigned long ip = regs->ip;
30923 +
30924 + if (v8086_mode(regs))
30925 + ip = ((regs->cs & 0xffff) << 4) + (ip & 0xffff);
30926 +
30927 +#ifdef CONFIG_PAX_PAGEEXEC
30928 + if (mm->pax_flags & MF_PAX_PAGEEXEC) {
30929 + if ((__supported_pte_mask & _PAGE_NX) && (error_code & PF_INSTR))
30930 + return true;
30931 + if (!(error_code & (PF_PROT | PF_WRITE)) && ip == address)
30932 + return true;
30933 + return false;
30934 + }
30935 +#endif
30936 +
30937 +#ifdef CONFIG_PAX_SEGMEXEC
30938 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
30939 + if (!(error_code & (PF_PROT | PF_WRITE)) && (ip + SEGMEXEC_TASK_SIZE == address))
30940 + return true;
30941 + return false;
30942 + }
30943 +#endif
30944 +
30945 + return false;
30946 +}
30947 +#endif
30948 +
30949 +#ifdef CONFIG_PAX_EMUTRAMP
30950 +static int pax_handle_fetch_fault_32(struct pt_regs *regs)
30951 +{
30952 + int err;
30953 +
30954 + do { /* PaX: libffi trampoline emulation */
30955 + unsigned char mov, jmp;
30956 + unsigned int addr1, addr2;
30957 +
30958 +#ifdef CONFIG_X86_64
30959 + if ((regs->ip + 9) >> 32)
30960 + break;
30961 +#endif
30962 +
30963 + err = get_user(mov, (unsigned char __user *)regs->ip);
30964 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30965 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
30966 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30967 +
30968 + if (err)
30969 + break;
30970 +
30971 + if (mov == 0xB8 && jmp == 0xE9) {
30972 + regs->ax = addr1;
30973 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
30974 + return 2;
30975 + }
30976 + } while (0);
30977 +
30978 + do { /* PaX: gcc trampoline emulation #1 */
30979 + unsigned char mov1, mov2;
30980 + unsigned short jmp;
30981 + unsigned int addr1, addr2;
30982 +
30983 +#ifdef CONFIG_X86_64
30984 + if ((regs->ip + 11) >> 32)
30985 + break;
30986 +#endif
30987 +
30988 + err = get_user(mov1, (unsigned char __user *)regs->ip);
30989 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
30990 + err |= get_user(mov2, (unsigned char __user *)(regs->ip + 5));
30991 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
30992 + err |= get_user(jmp, (unsigned short __user *)(regs->ip + 10));
30993 +
30994 + if (err)
30995 + break;
30996 +
30997 + if (mov1 == 0xB9 && mov2 == 0xB8 && jmp == 0xE0FF) {
30998 + regs->cx = addr1;
30999 + regs->ax = addr2;
31000 + regs->ip = addr2;
31001 + return 2;
31002 + }
31003 + } while (0);
31004 +
31005 + do { /* PaX: gcc trampoline emulation #2 */
31006 + unsigned char mov, jmp;
31007 + unsigned int addr1, addr2;
31008 +
31009 +#ifdef CONFIG_X86_64
31010 + if ((regs->ip + 9) >> 32)
31011 + break;
31012 +#endif
31013 +
31014 + err = get_user(mov, (unsigned char __user *)regs->ip);
31015 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 1));
31016 + err |= get_user(jmp, (unsigned char __user *)(regs->ip + 5));
31017 + err |= get_user(addr2, (unsigned int __user *)(regs->ip + 6));
31018 +
31019 + if (err)
31020 + break;
31021 +
31022 + if (mov == 0xB9 && jmp == 0xE9) {
31023 + regs->cx = addr1;
31024 + regs->ip = (unsigned int)(regs->ip + addr2 + 10);
31025 + return 2;
31026 + }
31027 + } while (0);
31028 +
31029 + return 1; /* PaX in action */
31030 +}
31031 +
31032 +#ifdef CONFIG_X86_64
31033 +static int pax_handle_fetch_fault_64(struct pt_regs *regs)
31034 +{
31035 + int err;
31036 +
31037 + do { /* PaX: libffi trampoline emulation */
31038 + unsigned short mov1, mov2, jmp1;
31039 + unsigned char stcclc, jmp2;
31040 + unsigned long addr1, addr2;
31041 +
31042 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31043 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31044 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31045 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31046 + err |= get_user(stcclc, (unsigned char __user *)(regs->ip + 20));
31047 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 21));
31048 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 23));
31049 +
31050 + if (err)
31051 + break;
31052 +
31053 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && (stcclc == 0xF8 || stcclc == 0xF9) && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31054 + regs->r11 = addr1;
31055 + regs->r10 = addr2;
31056 + if (stcclc == 0xF8)
31057 + regs->flags &= ~X86_EFLAGS_CF;
31058 + else
31059 + regs->flags |= X86_EFLAGS_CF;
31060 + regs->ip = addr1;
31061 + return 2;
31062 + }
31063 + } while (0);
31064 +
31065 + do { /* PaX: gcc trampoline emulation #1 */
31066 + unsigned short mov1, mov2, jmp1;
31067 + unsigned char jmp2;
31068 + unsigned int addr1;
31069 + unsigned long addr2;
31070 +
31071 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31072 + err |= get_user(addr1, (unsigned int __user *)(regs->ip + 2));
31073 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 6));
31074 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 8));
31075 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 16));
31076 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 18));
31077 +
31078 + if (err)
31079 + break;
31080 +
31081 + if (mov1 == 0xBB41 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31082 + regs->r11 = addr1;
31083 + regs->r10 = addr2;
31084 + regs->ip = addr1;
31085 + return 2;
31086 + }
31087 + } while (0);
31088 +
31089 + do { /* PaX: gcc trampoline emulation #2 */
31090 + unsigned short mov1, mov2, jmp1;
31091 + unsigned char jmp2;
31092 + unsigned long addr1, addr2;
31093 +
31094 + err = get_user(mov1, (unsigned short __user *)regs->ip);
31095 + err |= get_user(addr1, (unsigned long __user *)(regs->ip + 2));
31096 + err |= get_user(mov2, (unsigned short __user *)(regs->ip + 10));
31097 + err |= get_user(addr2, (unsigned long __user *)(regs->ip + 12));
31098 + err |= get_user(jmp1, (unsigned short __user *)(regs->ip + 20));
31099 + err |= get_user(jmp2, (unsigned char __user *)(regs->ip + 22));
31100 +
31101 + if (err)
31102 + break;
31103 +
31104 + if (mov1 == 0xBB49 && mov2 == 0xBA49 && jmp1 == 0xFF49 && jmp2 == 0xE3) {
31105 + regs->r11 = addr1;
31106 + regs->r10 = addr2;
31107 + regs->ip = addr1;
31108 + return 2;
31109 + }
31110 + } while (0);
31111 +
31112 + return 1; /* PaX in action */
31113 +}
31114 +#endif
31115 +
31116 +/*
31117 + * PaX: decide what to do with offenders (regs->ip = fault address)
31118 + *
31119 + * returns 1 when task should be killed
31120 + * 2 when gcc trampoline was detected
31121 + */
31122 +static int pax_handle_fetch_fault(struct pt_regs *regs)
31123 +{
31124 + if (v8086_mode(regs))
31125 + return 1;
31126 +
31127 + if (!(current->mm->pax_flags & MF_PAX_EMUTRAMP))
31128 + return 1;
31129 +
31130 +#ifdef CONFIG_X86_32
31131 + return pax_handle_fetch_fault_32(regs);
31132 +#else
31133 + if (regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))
31134 + return pax_handle_fetch_fault_32(regs);
31135 + else
31136 + return pax_handle_fetch_fault_64(regs);
31137 +#endif
31138 +}
31139 +#endif
31140 +
31141 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31142 +void pax_report_insns(struct pt_regs *regs, void *pc, void *sp)
31143 +{
31144 + long i;
31145 +
31146 + printk(KERN_ERR "PAX: bytes at PC: ");
31147 + for (i = 0; i < 20; i++) {
31148 + unsigned char c;
31149 + if (get_user(c, (unsigned char __force_user *)pc+i))
31150 + printk(KERN_CONT "?? ");
31151 + else
31152 + printk(KERN_CONT "%02x ", c);
31153 + }
31154 + printk("\n");
31155 +
31156 + printk(KERN_ERR "PAX: bytes at SP-%lu: ", (unsigned long)sizeof(long));
31157 + for (i = -1; i < 80 / (long)sizeof(long); i++) {
31158 + unsigned long c;
31159 + if (get_user(c, (unsigned long __force_user *)sp+i)) {
31160 +#ifdef CONFIG_X86_32
31161 + printk(KERN_CONT "???????? ");
31162 +#else
31163 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT)))
31164 + printk(KERN_CONT "???????? ???????? ");
31165 + else
31166 + printk(KERN_CONT "???????????????? ");
31167 +#endif
31168 + } else {
31169 +#ifdef CONFIG_X86_64
31170 + if ((regs->cs == __USER32_CS || (regs->cs & SEGMENT_LDT))) {
31171 + printk(KERN_CONT "%08x ", (unsigned int)c);
31172 + printk(KERN_CONT "%08x ", (unsigned int)(c >> 32));
31173 + } else
31174 +#endif
31175 + printk(KERN_CONT "%0*lx ", 2 * (int)sizeof(long), c);
31176 + }
31177 + }
31178 + printk("\n");
31179 +}
31180 +#endif
31181 +
31182 +/**
31183 + * probe_kernel_write(): safely attempt to write to a location
31184 + * @dst: address to write to
31185 + * @src: pointer to the data that shall be written
31186 + * @size: size of the data chunk
31187 + *
31188 + * Safely write to address @dst from the buffer at @src. If a kernel fault
31189 + * happens, handle that and return -EFAULT.
31190 + */
31191 +long notrace probe_kernel_write(void *dst, const void *src, size_t size)
31192 +{
31193 + long ret;
31194 + mm_segment_t old_fs = get_fs();
31195 +
31196 + set_fs(KERNEL_DS);
31197 + pagefault_disable();
31198 + pax_open_kernel();
31199 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
31200 + pax_close_kernel();
31201 + pagefault_enable();
31202 + set_fs(old_fs);
31203 +
31204 + return ret ? -EFAULT : 0;
31205 +}
31206 diff --git a/arch/x86/mm/gup.c b/arch/x86/mm/gup.c
31207 index 0596e8e..9de0b1c 100644
31208 --- a/arch/x86/mm/gup.c
31209 +++ b/arch/x86/mm/gup.c
31210 @@ -268,7 +268,7 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write,
31211 addr = start;
31212 len = (unsigned long) nr_pages << PAGE_SHIFT;
31213 end = start + len;
31214 - if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31215 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31216 (void __user *)start, len)))
31217 return 0;
31218
31219 @@ -344,6 +344,10 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
31220 goto slow_irqon;
31221 #endif
31222
31223 + if (unlikely(!__access_ok(write ? VERIFY_WRITE : VERIFY_READ,
31224 + (void __user *)start, len)))
31225 + return 0;
31226 +
31227 /*
31228 * XXX: batch / limit 'nr', to avoid large irq off latency
31229 * needs some instrumenting to determine the common sizes used by
31230 diff --git a/arch/x86/mm/highmem_32.c b/arch/x86/mm/highmem_32.c
31231 index 4500142..53a363c 100644
31232 --- a/arch/x86/mm/highmem_32.c
31233 +++ b/arch/x86/mm/highmem_32.c
31234 @@ -45,7 +45,11 @@ void *kmap_atomic_prot(struct page *page, pgprot_t prot)
31235 idx = type + KM_TYPE_NR*smp_processor_id();
31236 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31237 BUG_ON(!pte_none(*(kmap_pte-idx)));
31238 +
31239 + pax_open_kernel();
31240 set_pte(kmap_pte-idx, mk_pte(page, prot));
31241 + pax_close_kernel();
31242 +
31243 arch_flush_lazy_mmu_mode();
31244
31245 return (void *)vaddr;
31246 diff --git a/arch/x86/mm/hugetlbpage.c b/arch/x86/mm/hugetlbpage.c
31247 index 9d980d8..6bbfacb 100644
31248 --- a/arch/x86/mm/hugetlbpage.c
31249 +++ b/arch/x86/mm/hugetlbpage.c
31250 @@ -92,23 +92,30 @@ int pmd_huge_support(void)
31251 #ifdef HAVE_ARCH_HUGETLB_UNMAPPED_AREA
31252 static unsigned long hugetlb_get_unmapped_area_bottomup(struct file *file,
31253 unsigned long addr, unsigned long len,
31254 - unsigned long pgoff, unsigned long flags)
31255 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31256 {
31257 struct hstate *h = hstate_file(file);
31258 struct vm_unmapped_area_info info;
31259 -
31260 +
31261 info.flags = 0;
31262 info.length = len;
31263 info.low_limit = TASK_UNMAPPED_BASE;
31264 +
31265 +#ifdef CONFIG_PAX_RANDMMAP
31266 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31267 + info.low_limit += current->mm->delta_mmap;
31268 +#endif
31269 +
31270 info.high_limit = TASK_SIZE;
31271 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31272 info.align_offset = 0;
31273 + info.threadstack_offset = offset;
31274 return vm_unmapped_area(&info);
31275 }
31276
31277 static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31278 unsigned long addr0, unsigned long len,
31279 - unsigned long pgoff, unsigned long flags)
31280 + unsigned long pgoff, unsigned long flags, unsigned long offset)
31281 {
31282 struct hstate *h = hstate_file(file);
31283 struct vm_unmapped_area_info info;
31284 @@ -120,6 +127,7 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31285 info.high_limit = current->mm->mmap_base;
31286 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
31287 info.align_offset = 0;
31288 + info.threadstack_offset = offset;
31289 addr = vm_unmapped_area(&info);
31290
31291 /*
31292 @@ -132,6 +140,12 @@ static unsigned long hugetlb_get_unmapped_area_topdown(struct file *file,
31293 VM_BUG_ON(addr != -ENOMEM);
31294 info.flags = 0;
31295 info.low_limit = TASK_UNMAPPED_BASE;
31296 +
31297 +#ifdef CONFIG_PAX_RANDMMAP
31298 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
31299 + info.low_limit += current->mm->delta_mmap;
31300 +#endif
31301 +
31302 info.high_limit = TASK_SIZE;
31303 addr = vm_unmapped_area(&info);
31304 }
31305 @@ -146,10 +160,20 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31306 struct hstate *h = hstate_file(file);
31307 struct mm_struct *mm = current->mm;
31308 struct vm_area_struct *vma;
31309 + unsigned long pax_task_size = TASK_SIZE;
31310 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
31311
31312 if (len & ~huge_page_mask(h))
31313 return -EINVAL;
31314 - if (len > TASK_SIZE)
31315 +
31316 +#ifdef CONFIG_PAX_SEGMEXEC
31317 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
31318 + pax_task_size = SEGMEXEC_TASK_SIZE;
31319 +#endif
31320 +
31321 + pax_task_size -= PAGE_SIZE;
31322 +
31323 + if (len > pax_task_size)
31324 return -ENOMEM;
31325
31326 if (flags & MAP_FIXED) {
31327 @@ -158,19 +182,22 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
31328 return addr;
31329 }
31330
31331 +#ifdef CONFIG_PAX_RANDMMAP
31332 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
31333 +#endif
31334 +
31335 if (addr) {
31336 addr = ALIGN(addr, huge_page_size(h));
31337 vma = find_vma(mm, addr);
31338 - if (TASK_SIZE - len >= addr &&
31339 - (!vma || addr + len <= vma->vm_start))
31340 + if (pax_task_size - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
31341 return addr;
31342 }
31343 if (mm->get_unmapped_area == arch_get_unmapped_area)
31344 return hugetlb_get_unmapped_area_bottomup(file, addr, len,
31345 - pgoff, flags);
31346 + pgoff, flags, offset);
31347 else
31348 return hugetlb_get_unmapped_area_topdown(file, addr, len,
31349 - pgoff, flags);
31350 + pgoff, flags, offset);
31351 }
31352
31353 #endif /*HAVE_ARCH_HUGETLB_UNMAPPED_AREA*/
31354 diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
31355 index 04664cd..dae6e5d 100644
31356 --- a/arch/x86/mm/init.c
31357 +++ b/arch/x86/mm/init.c
31358 @@ -4,6 +4,7 @@
31359 #include <linux/swap.h>
31360 #include <linux/memblock.h>
31361 #include <linux/bootmem.h> /* for max_low_pfn */
31362 +#include <linux/tboot.h>
31363
31364 #include <asm/cacheflush.h>
31365 #include <asm/e820.h>
31366 @@ -17,6 +18,8 @@
31367 #include <asm/proto.h>
31368 #include <asm/dma.h> /* for MAX_DMA_PFN */
31369 #include <asm/microcode.h>
31370 +#include <asm/desc.h>
31371 +#include <asm/bios_ebda.h>
31372
31373 #include "mm_internal.h"
31374
31375 @@ -465,7 +468,18 @@ void __init init_mem_mapping(void)
31376 early_ioremap_page_table_range_init();
31377 #endif
31378
31379 +#ifdef CONFIG_PAX_PER_CPU_PGD
31380 + clone_pgd_range(get_cpu_pgd(0, kernel) + KERNEL_PGD_BOUNDARY,
31381 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31382 + KERNEL_PGD_PTRS);
31383 + clone_pgd_range(get_cpu_pgd(0, user) + KERNEL_PGD_BOUNDARY,
31384 + swapper_pg_dir + KERNEL_PGD_BOUNDARY,
31385 + KERNEL_PGD_PTRS);
31386 + load_cr3(get_cpu_pgd(0, kernel));
31387 +#else
31388 load_cr3(swapper_pg_dir);
31389 +#endif
31390 +
31391 __flush_tlb_all();
31392
31393 early_memtest(0, max_pfn_mapped << PAGE_SHIFT);
31394 @@ -481,10 +495,40 @@ void __init init_mem_mapping(void)
31395 * Access has to be given to non-kernel-ram areas as well, these contain the PCI
31396 * mmio resources as well as potential bios/acpi data regions.
31397 */
31398 +
31399 +#ifdef CONFIG_GRKERNSEC_KMEM
31400 +static unsigned int ebda_start __read_only;
31401 +static unsigned int ebda_end __read_only;
31402 +#endif
31403 +
31404 int devmem_is_allowed(unsigned long pagenr)
31405 {
31406 - if (pagenr < 256)
31407 +#ifdef CONFIG_GRKERNSEC_KMEM
31408 + /* allow BDA */
31409 + if (!pagenr)
31410 return 1;
31411 + /* allow EBDA */
31412 + if (pagenr >= ebda_start && pagenr < ebda_end)
31413 + return 1;
31414 + /* if tboot is in use, allow access to its hardcoded serial log range */
31415 + if (tboot_enabled() && ((0x60000 >> PAGE_SHIFT) <= pagenr) && (pagenr < (0x68000 >> PAGE_SHIFT)))
31416 + return 1;
31417 +#else
31418 + if (!pagenr)
31419 + return 1;
31420 +#ifdef CONFIG_VM86
31421 + if (pagenr < (ISA_START_ADDRESS >> PAGE_SHIFT))
31422 + return 1;
31423 +#endif
31424 +#endif
31425 +
31426 + if ((ISA_START_ADDRESS >> PAGE_SHIFT) <= pagenr && pagenr < (ISA_END_ADDRESS >> PAGE_SHIFT))
31427 + return 1;
31428 +#ifdef CONFIG_GRKERNSEC_KMEM
31429 + /* throw out everything else below 1MB */
31430 + if (pagenr <= 256)
31431 + return 0;
31432 +#endif
31433 if (iomem_is_exclusive(pagenr << PAGE_SHIFT))
31434 return 0;
31435 if (!page_is_ram(pagenr))
31436 @@ -530,8 +574,117 @@ void free_init_pages(char *what, unsigned long begin, unsigned long end)
31437 #endif
31438 }
31439
31440 +#ifdef CONFIG_GRKERNSEC_KMEM
31441 +static inline void gr_init_ebda(void)
31442 +{
31443 + unsigned int ebda_addr;
31444 + unsigned int ebda_size = 0;
31445 +
31446 + ebda_addr = get_bios_ebda();
31447 + if (ebda_addr) {
31448 + ebda_size = *(unsigned char *)phys_to_virt(ebda_addr);
31449 + ebda_size <<= 10;
31450 + }
31451 + if (ebda_addr && ebda_size) {
31452 + ebda_start = ebda_addr >> PAGE_SHIFT;
31453 + ebda_end = min((unsigned int)PAGE_ALIGN(ebda_addr + ebda_size), (unsigned int)0xa0000) >> PAGE_SHIFT;
31454 + } else {
31455 + ebda_start = 0x9f000 >> PAGE_SHIFT;
31456 + ebda_end = 0xa0000 >> PAGE_SHIFT;
31457 + }
31458 +}
31459 +#else
31460 +static inline void gr_init_ebda(void) { }
31461 +#endif
31462 +
31463 void free_initmem(void)
31464 {
31465 +#ifdef CONFIG_PAX_KERNEXEC
31466 +#ifdef CONFIG_X86_32
31467 + /* PaX: limit KERNEL_CS to actual size */
31468 + unsigned long addr, limit;
31469 + struct desc_struct d;
31470 + int cpu;
31471 +#else
31472 + pgd_t *pgd;
31473 + pud_t *pud;
31474 + pmd_t *pmd;
31475 + unsigned long addr, end;
31476 +#endif
31477 +#endif
31478 +
31479 + gr_init_ebda();
31480 +
31481 +#ifdef CONFIG_PAX_KERNEXEC
31482 +#ifdef CONFIG_X86_32
31483 + limit = paravirt_enabled() ? ktva_ktla(0xffffffff) : (unsigned long)&_etext;
31484 + limit = (limit - 1UL) >> PAGE_SHIFT;
31485 +
31486 + memset(__LOAD_PHYSICAL_ADDR + PAGE_OFFSET, POISON_FREE_INITMEM, PAGE_SIZE);
31487 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
31488 + pack_descriptor(&d, get_desc_base(&get_cpu_gdt_table(cpu)[GDT_ENTRY_KERNEL_CS]), limit, 0x9B, 0xC);
31489 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEL_CS, &d, DESCTYPE_S);
31490 + write_gdt_entry(get_cpu_gdt_table(cpu), GDT_ENTRY_KERNEXEC_KERNEL_CS, &d, DESCTYPE_S);
31491 + }
31492 +
31493 + /* PaX: make KERNEL_CS read-only */
31494 + addr = PFN_ALIGN(ktla_ktva((unsigned long)&_text));
31495 + if (!paravirt_enabled())
31496 + set_memory_ro(addr, (PFN_ALIGN(_sdata) - addr) >> PAGE_SHIFT);
31497 +/*
31498 + for (addr = ktla_ktva((unsigned long)&_text); addr < (unsigned long)&_sdata; addr += PMD_SIZE) {
31499 + pgd = pgd_offset_k(addr);
31500 + pud = pud_offset(pgd, addr);
31501 + pmd = pmd_offset(pud, addr);
31502 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31503 + }
31504 +*/
31505 +#ifdef CONFIG_X86_PAE
31506 + set_memory_nx(PFN_ALIGN(__init_begin), (PFN_ALIGN(__init_end) - PFN_ALIGN(__init_begin)) >> PAGE_SHIFT);
31507 +/*
31508 + for (addr = (unsigned long)&__init_begin; addr < (unsigned long)&__init_end; addr += PMD_SIZE) {
31509 + pgd = pgd_offset_k(addr);
31510 + pud = pud_offset(pgd, addr);
31511 + pmd = pmd_offset(pud, addr);
31512 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31513 + }
31514 +*/
31515 +#endif
31516 +
31517 +#ifdef CONFIG_MODULES
31518 + set_memory_4k((unsigned long)MODULES_EXEC_VADDR, (MODULES_EXEC_END - MODULES_EXEC_VADDR) >> PAGE_SHIFT);
31519 +#endif
31520 +
31521 +#else
31522 + /* PaX: make kernel code/rodata read-only, rest non-executable */
31523 + for (addr = __START_KERNEL_map; addr < __START_KERNEL_map + KERNEL_IMAGE_SIZE; addr += PMD_SIZE) {
31524 + pgd = pgd_offset_k(addr);
31525 + pud = pud_offset(pgd, addr);
31526 + pmd = pmd_offset(pud, addr);
31527 + if (!pmd_present(*pmd))
31528 + continue;
31529 + if ((unsigned long)_text <= addr && addr < (unsigned long)_sdata)
31530 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31531 + else
31532 + set_pmd(pmd, __pmd(pmd_val(*pmd) | (_PAGE_NX & __supported_pte_mask)));
31533 + }
31534 +
31535 + addr = (unsigned long)__va(__pa(__START_KERNEL_map));
31536 + end = addr + KERNEL_IMAGE_SIZE;
31537 + for (; addr < end; addr += PMD_SIZE) {
31538 + pgd = pgd_offset_k(addr);
31539 + pud = pud_offset(pgd, addr);
31540 + pmd = pmd_offset(pud, addr);
31541 + if (!pmd_present(*pmd))
31542 + continue;
31543 + if ((unsigned long)__va(__pa(_text)) <= addr && addr < (unsigned long)__va(__pa(_sdata)))
31544 + set_pmd(pmd, __pmd(pmd_val(*pmd) & ~_PAGE_RW));
31545 + }
31546 +#endif
31547 +
31548 + flush_tlb_all();
31549 +#endif
31550 +
31551 free_init_pages("unused kernel",
31552 (unsigned long)(&__init_begin),
31553 (unsigned long)(&__init_end));
31554 diff --git a/arch/x86/mm/init_32.c b/arch/x86/mm/init_32.c
31555 index 4287f1f..3b99c71 100644
31556 --- a/arch/x86/mm/init_32.c
31557 +++ b/arch/x86/mm/init_32.c
31558 @@ -62,33 +62,6 @@ static noinline int do_test_wp_bit(void);
31559 bool __read_mostly __vmalloc_start_set = false;
31560
31561 /*
31562 - * Creates a middle page table and puts a pointer to it in the
31563 - * given global directory entry. This only returns the gd entry
31564 - * in non-PAE compilation mode, since the middle layer is folded.
31565 - */
31566 -static pmd_t * __init one_md_table_init(pgd_t *pgd)
31567 -{
31568 - pud_t *pud;
31569 - pmd_t *pmd_table;
31570 -
31571 -#ifdef CONFIG_X86_PAE
31572 - if (!(pgd_val(*pgd) & _PAGE_PRESENT)) {
31573 - pmd_table = (pmd_t *)alloc_low_page();
31574 - paravirt_alloc_pmd(&init_mm, __pa(pmd_table) >> PAGE_SHIFT);
31575 - set_pgd(pgd, __pgd(__pa(pmd_table) | _PAGE_PRESENT));
31576 - pud = pud_offset(pgd, 0);
31577 - BUG_ON(pmd_table != pmd_offset(pud, 0));
31578 -
31579 - return pmd_table;
31580 - }
31581 -#endif
31582 - pud = pud_offset(pgd, 0);
31583 - pmd_table = pmd_offset(pud, 0);
31584 -
31585 - return pmd_table;
31586 -}
31587 -
31588 -/*
31589 * Create a page table and place a pointer to it in a middle page
31590 * directory entry:
31591 */
31592 @@ -98,13 +71,28 @@ static pte_t * __init one_page_table_init(pmd_t *pmd)
31593 pte_t *page_table = (pte_t *)alloc_low_page();
31594
31595 paravirt_alloc_pte(&init_mm, __pa(page_table) >> PAGE_SHIFT);
31596 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
31597 + set_pmd(pmd, __pmd(__pa(page_table) | _KERNPG_TABLE));
31598 +#else
31599 set_pmd(pmd, __pmd(__pa(page_table) | _PAGE_TABLE));
31600 +#endif
31601 BUG_ON(page_table != pte_offset_kernel(pmd, 0));
31602 }
31603
31604 return pte_offset_kernel(pmd, 0);
31605 }
31606
31607 +static pmd_t * __init one_md_table_init(pgd_t *pgd)
31608 +{
31609 + pud_t *pud;
31610 + pmd_t *pmd_table;
31611 +
31612 + pud = pud_offset(pgd, 0);
31613 + pmd_table = pmd_offset(pud, 0);
31614 +
31615 + return pmd_table;
31616 +}
31617 +
31618 pmd_t * __init populate_extra_pmd(unsigned long vaddr)
31619 {
31620 int pgd_idx = pgd_index(vaddr);
31621 @@ -208,6 +196,7 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31622 int pgd_idx, pmd_idx;
31623 unsigned long vaddr;
31624 pgd_t *pgd;
31625 + pud_t *pud;
31626 pmd_t *pmd;
31627 pte_t *pte = NULL;
31628 unsigned long count = page_table_range_init_count(start, end);
31629 @@ -222,8 +211,13 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31630 pgd = pgd_base + pgd_idx;
31631
31632 for ( ; (pgd_idx < PTRS_PER_PGD) && (vaddr != end); pgd++, pgd_idx++) {
31633 - pmd = one_md_table_init(pgd);
31634 - pmd = pmd + pmd_index(vaddr);
31635 + pud = pud_offset(pgd, vaddr);
31636 + pmd = pmd_offset(pud, vaddr);
31637 +
31638 +#ifdef CONFIG_X86_PAE
31639 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31640 +#endif
31641 +
31642 for (; (pmd_idx < PTRS_PER_PMD) && (vaddr != end);
31643 pmd++, pmd_idx++) {
31644 pte = page_table_kmap_check(one_page_table_init(pmd),
31645 @@ -235,11 +229,20 @@ page_table_range_init(unsigned long start, unsigned long end, pgd_t *pgd_base)
31646 }
31647 }
31648
31649 -static inline int is_kernel_text(unsigned long addr)
31650 +static inline int is_kernel_text(unsigned long start, unsigned long end)
31651 {
31652 - if (addr >= (unsigned long)_text && addr <= (unsigned long)__init_end)
31653 - return 1;
31654 - return 0;
31655 + if ((start > ktla_ktva((unsigned long)_etext) ||
31656 + end <= ktla_ktva((unsigned long)_stext)) &&
31657 + (start > ktla_ktva((unsigned long)_einittext) ||
31658 + end <= ktla_ktva((unsigned long)_sinittext)) &&
31659 +
31660 +#ifdef CONFIG_ACPI_SLEEP
31661 + (start > (unsigned long)__va(acpi_wakeup_address) + 0x4000 || end <= (unsigned long)__va(acpi_wakeup_address)) &&
31662 +#endif
31663 +
31664 + (start > (unsigned long)__va(0xfffff) || end <= (unsigned long)__va(0xc0000)))
31665 + return 0;
31666 + return 1;
31667 }
31668
31669 /*
31670 @@ -256,9 +259,10 @@ kernel_physical_mapping_init(unsigned long start,
31671 unsigned long last_map_addr = end;
31672 unsigned long start_pfn, end_pfn;
31673 pgd_t *pgd_base = swapper_pg_dir;
31674 - int pgd_idx, pmd_idx, pte_ofs;
31675 + unsigned int pgd_idx, pmd_idx, pte_ofs;
31676 unsigned long pfn;
31677 pgd_t *pgd;
31678 + pud_t *pud;
31679 pmd_t *pmd;
31680 pte_t *pte;
31681 unsigned pages_2m, pages_4k;
31682 @@ -291,8 +295,13 @@ repeat:
31683 pfn = start_pfn;
31684 pgd_idx = pgd_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31685 pgd = pgd_base + pgd_idx;
31686 - for (; pgd_idx < PTRS_PER_PGD; pgd++, pgd_idx++) {
31687 - pmd = one_md_table_init(pgd);
31688 + for (; pgd_idx < PTRS_PER_PGD && pfn < max_low_pfn; pgd++, pgd_idx++) {
31689 + pud = pud_offset(pgd, 0);
31690 + pmd = pmd_offset(pud, 0);
31691 +
31692 +#ifdef CONFIG_X86_PAE
31693 + paravirt_alloc_pmd(&init_mm, __pa(pmd) >> PAGE_SHIFT);
31694 +#endif
31695
31696 if (pfn >= end_pfn)
31697 continue;
31698 @@ -304,14 +313,13 @@ repeat:
31699 #endif
31700 for (; pmd_idx < PTRS_PER_PMD && pfn < end_pfn;
31701 pmd++, pmd_idx++) {
31702 - unsigned int addr = pfn * PAGE_SIZE + PAGE_OFFSET;
31703 + unsigned long address = pfn * PAGE_SIZE + PAGE_OFFSET;
31704
31705 /*
31706 * Map with big pages if possible, otherwise
31707 * create normal page tables:
31708 */
31709 if (use_pse) {
31710 - unsigned int addr2;
31711 pgprot_t prot = PAGE_KERNEL_LARGE;
31712 /*
31713 * first pass will use the same initial
31714 @@ -322,11 +330,7 @@ repeat:
31715 _PAGE_PSE);
31716
31717 pfn &= PMD_MASK >> PAGE_SHIFT;
31718 - addr2 = (pfn + PTRS_PER_PTE-1) * PAGE_SIZE +
31719 - PAGE_OFFSET + PAGE_SIZE-1;
31720 -
31721 - if (is_kernel_text(addr) ||
31722 - is_kernel_text(addr2))
31723 + if (is_kernel_text(address, address + PMD_SIZE))
31724 prot = PAGE_KERNEL_LARGE_EXEC;
31725
31726 pages_2m++;
31727 @@ -343,7 +347,7 @@ repeat:
31728 pte_ofs = pte_index((pfn<<PAGE_SHIFT) + PAGE_OFFSET);
31729 pte += pte_ofs;
31730 for (; pte_ofs < PTRS_PER_PTE && pfn < end_pfn;
31731 - pte++, pfn++, pte_ofs++, addr += PAGE_SIZE) {
31732 + pte++, pfn++, pte_ofs++, address += PAGE_SIZE) {
31733 pgprot_t prot = PAGE_KERNEL;
31734 /*
31735 * first pass will use the same initial
31736 @@ -351,7 +355,7 @@ repeat:
31737 */
31738 pgprot_t init_prot = __pgprot(PTE_IDENT_ATTR);
31739
31740 - if (is_kernel_text(addr))
31741 + if (is_kernel_text(address, address + PAGE_SIZE))
31742 prot = PAGE_KERNEL_EXEC;
31743
31744 pages_4k++;
31745 @@ -474,7 +478,7 @@ void __init native_pagetable_init(void)
31746
31747 pud = pud_offset(pgd, va);
31748 pmd = pmd_offset(pud, va);
31749 - if (!pmd_present(*pmd))
31750 + if (!pmd_present(*pmd)) // PAX TODO || pmd_large(*pmd))
31751 break;
31752
31753 /* should not be large page here */
31754 @@ -532,12 +536,10 @@ void __init early_ioremap_page_table_range_init(void)
31755
31756 static void __init pagetable_init(void)
31757 {
31758 - pgd_t *pgd_base = swapper_pg_dir;
31759 -
31760 - permanent_kmaps_init(pgd_base);
31761 + permanent_kmaps_init(swapper_pg_dir);
31762 }
31763
31764 -pteval_t __supported_pte_mask __read_mostly = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31765 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_GLOBAL | _PAGE_IOMAP);
31766 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31767
31768 /* user-defined highmem size */
31769 @@ -787,10 +789,10 @@ void __init mem_init(void)
31770 ((unsigned long)&__init_end -
31771 (unsigned long)&__init_begin) >> 10,
31772
31773 - (unsigned long)&_etext, (unsigned long)&_edata,
31774 - ((unsigned long)&_edata - (unsigned long)&_etext) >> 10,
31775 + (unsigned long)&_sdata, (unsigned long)&_edata,
31776 + ((unsigned long)&_edata - (unsigned long)&_sdata) >> 10,
31777
31778 - (unsigned long)&_text, (unsigned long)&_etext,
31779 + ktla_ktva((unsigned long)&_text), ktla_ktva((unsigned long)&_etext),
31780 ((unsigned long)&_etext - (unsigned long)&_text) >> 10);
31781
31782 /*
31783 @@ -880,6 +882,7 @@ void set_kernel_text_rw(void)
31784 if (!kernel_set_to_readonly)
31785 return;
31786
31787 + start = ktla_ktva(start);
31788 pr_debug("Set kernel text: %lx - %lx for read write\n",
31789 start, start+size);
31790
31791 @@ -894,6 +897,7 @@ void set_kernel_text_ro(void)
31792 if (!kernel_set_to_readonly)
31793 return;
31794
31795 + start = ktla_ktva(start);
31796 pr_debug("Set kernel text: %lx - %lx for read only\n",
31797 start, start+size);
31798
31799 @@ -922,6 +926,7 @@ void mark_rodata_ro(void)
31800 unsigned long start = PFN_ALIGN(_text);
31801 unsigned long size = PFN_ALIGN(_etext) - start;
31802
31803 + start = ktla_ktva(start);
31804 set_pages_ro(virt_to_page(start), size >> PAGE_SHIFT);
31805 printk(KERN_INFO "Write protecting the kernel text: %luk\n",
31806 size >> 10);
31807 diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
31808 index 104d56a..62ba13f1 100644
31809 --- a/arch/x86/mm/init_64.c
31810 +++ b/arch/x86/mm/init_64.c
31811 @@ -151,7 +151,7 @@ early_param("gbpages", parse_direct_gbpages_on);
31812 * around without checking the pgd every time.
31813 */
31814
31815 -pteval_t __supported_pte_mask __read_mostly = ~_PAGE_IOMAP;
31816 +pteval_t __supported_pte_mask __read_only = ~(_PAGE_NX | _PAGE_IOMAP);
31817 EXPORT_SYMBOL_GPL(__supported_pte_mask);
31818
31819 int force_personality32;
31820 @@ -184,12 +184,29 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31821
31822 for (address = start; address <= end; address += PGDIR_SIZE) {
31823 const pgd_t *pgd_ref = pgd_offset_k(address);
31824 +
31825 +#ifdef CONFIG_PAX_PER_CPU_PGD
31826 + unsigned long cpu;
31827 +#else
31828 struct page *page;
31829 +#endif
31830
31831 if (pgd_none(*pgd_ref))
31832 continue;
31833
31834 spin_lock(&pgd_lock);
31835 +
31836 +#ifdef CONFIG_PAX_PER_CPU_PGD
31837 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
31838 + pgd_t *pgd = pgd_offset_cpu(cpu, user, address);
31839 +
31840 + if (pgd_none(*pgd))
31841 + set_pgd(pgd, *pgd_ref);
31842 + else
31843 + BUG_ON(pgd_page_vaddr(*pgd)
31844 + != pgd_page_vaddr(*pgd_ref));
31845 + pgd = pgd_offset_cpu(cpu, kernel, address);
31846 +#else
31847 list_for_each_entry(page, &pgd_list, lru) {
31848 pgd_t *pgd;
31849 spinlock_t *pgt_lock;
31850 @@ -198,6 +215,7 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31851 /* the pgt_lock only for Xen */
31852 pgt_lock = &pgd_page_get_mm(page)->page_table_lock;
31853 spin_lock(pgt_lock);
31854 +#endif
31855
31856 if (pgd_none(*pgd))
31857 set_pgd(pgd, *pgd_ref);
31858 @@ -205,7 +223,10 @@ void sync_global_pgds(unsigned long start, unsigned long end)
31859 BUG_ON(pgd_page_vaddr(*pgd)
31860 != pgd_page_vaddr(*pgd_ref));
31861
31862 +#ifndef CONFIG_PAX_PER_CPU_PGD
31863 spin_unlock(pgt_lock);
31864 +#endif
31865 +
31866 }
31867 spin_unlock(&pgd_lock);
31868 }
31869 @@ -238,7 +259,7 @@ static pud_t *fill_pud(pgd_t *pgd, unsigned long vaddr)
31870 {
31871 if (pgd_none(*pgd)) {
31872 pud_t *pud = (pud_t *)spp_getpage();
31873 - pgd_populate(&init_mm, pgd, pud);
31874 + pgd_populate_kernel(&init_mm, pgd, pud);
31875 if (pud != pud_offset(pgd, 0))
31876 printk(KERN_ERR "PAGETABLE BUG #00! %p <-> %p\n",
31877 pud, pud_offset(pgd, 0));
31878 @@ -250,7 +271,7 @@ static pmd_t *fill_pmd(pud_t *pud, unsigned long vaddr)
31879 {
31880 if (pud_none(*pud)) {
31881 pmd_t *pmd = (pmd_t *) spp_getpage();
31882 - pud_populate(&init_mm, pud, pmd);
31883 + pud_populate_kernel(&init_mm, pud, pmd);
31884 if (pmd != pmd_offset(pud, 0))
31885 printk(KERN_ERR "PAGETABLE BUG #01! %p <-> %p\n",
31886 pmd, pmd_offset(pud, 0));
31887 @@ -279,7 +300,9 @@ void set_pte_vaddr_pud(pud_t *pud_page, unsigned long vaddr, pte_t new_pte)
31888 pmd = fill_pmd(pud, vaddr);
31889 pte = fill_pte(pmd, vaddr);
31890
31891 + pax_open_kernel();
31892 set_pte(pte, new_pte);
31893 + pax_close_kernel();
31894
31895 /*
31896 * It's enough to flush this one mapping.
31897 @@ -338,14 +361,12 @@ static void __init __init_extra_mapping(unsigned long phys, unsigned long size,
31898 pgd = pgd_offset_k((unsigned long)__va(phys));
31899 if (pgd_none(*pgd)) {
31900 pud = (pud_t *) spp_getpage();
31901 - set_pgd(pgd, __pgd(__pa(pud) | _KERNPG_TABLE |
31902 - _PAGE_USER));
31903 + set_pgd(pgd, __pgd(__pa(pud) | _PAGE_TABLE));
31904 }
31905 pud = pud_offset(pgd, (unsigned long)__va(phys));
31906 if (pud_none(*pud)) {
31907 pmd = (pmd_t *) spp_getpage();
31908 - set_pud(pud, __pud(__pa(pmd) | _KERNPG_TABLE |
31909 - _PAGE_USER));
31910 + set_pud(pud, __pud(__pa(pmd) | _PAGE_TABLE));
31911 }
31912 pmd = pmd_offset(pud, phys);
31913 BUG_ON(!pmd_none(*pmd));
31914 @@ -586,7 +607,7 @@ phys_pud_init(pud_t *pud_page, unsigned long addr, unsigned long end,
31915 prot);
31916
31917 spin_lock(&init_mm.page_table_lock);
31918 - pud_populate(&init_mm, pud, pmd);
31919 + pud_populate_kernel(&init_mm, pud, pmd);
31920 spin_unlock(&init_mm.page_table_lock);
31921 }
31922 __flush_tlb_all();
31923 @@ -627,7 +648,7 @@ kernel_physical_mapping_init(unsigned long start,
31924 page_size_mask);
31925
31926 spin_lock(&init_mm.page_table_lock);
31927 - pgd_populate(&init_mm, pgd, pud);
31928 + pgd_populate_kernel(&init_mm, pgd, pud);
31929 spin_unlock(&init_mm.page_table_lock);
31930 pgd_changed = true;
31931 }
31932 @@ -1188,8 +1209,8 @@ int kern_addr_valid(unsigned long addr)
31933 static struct vm_area_struct gate_vma = {
31934 .vm_start = VSYSCALL_START,
31935 .vm_end = VSYSCALL_START + (VSYSCALL_MAPPED_PAGES * PAGE_SIZE),
31936 - .vm_page_prot = PAGE_READONLY_EXEC,
31937 - .vm_flags = VM_READ | VM_EXEC
31938 + .vm_page_prot = PAGE_READONLY,
31939 + .vm_flags = VM_READ
31940 };
31941
31942 struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
31943 @@ -1223,7 +1244,7 @@ int in_gate_area_no_mm(unsigned long addr)
31944
31945 const char *arch_vma_name(struct vm_area_struct *vma)
31946 {
31947 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
31948 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
31949 return "[vdso]";
31950 if (vma == &gate_vma)
31951 return "[vsyscall]";
31952 diff --git a/arch/x86/mm/iomap_32.c b/arch/x86/mm/iomap_32.c
31953 index 7b179b4..6bd17777 100644
31954 --- a/arch/x86/mm/iomap_32.c
31955 +++ b/arch/x86/mm/iomap_32.c
31956 @@ -64,7 +64,11 @@ void *kmap_atomic_prot_pfn(unsigned long pfn, pgprot_t prot)
31957 type = kmap_atomic_idx_push();
31958 idx = type + KM_TYPE_NR * smp_processor_id();
31959 vaddr = __fix_to_virt(FIX_KMAP_BEGIN + idx);
31960 +
31961 + pax_open_kernel();
31962 set_pte(kmap_pte - idx, pfn_pte(pfn, prot));
31963 + pax_close_kernel();
31964 +
31965 arch_flush_lazy_mmu_mode();
31966
31967 return (void *)vaddr;
31968 diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
31969 index 799580c..72f9fe0 100644
31970 --- a/arch/x86/mm/ioremap.c
31971 +++ b/arch/x86/mm/ioremap.c
31972 @@ -97,7 +97,7 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
31973 for (pfn = phys_addr >> PAGE_SHIFT; pfn <= last_pfn; pfn++) {
31974 int is_ram = page_is_ram(pfn);
31975
31976 - if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
31977 + if (is_ram && pfn_valid(pfn) && (pfn >= 0x100 || !PageReserved(pfn_to_page(pfn))))
31978 return NULL;
31979 WARN_ON_ONCE(is_ram);
31980 }
31981 @@ -256,7 +256,7 @@ EXPORT_SYMBOL(ioremap_prot);
31982 *
31983 * Caller must ensure there is only one unmapping for the same pointer.
31984 */
31985 -void iounmap(volatile void __iomem *addr)
31986 +void iounmap(const volatile void __iomem *addr)
31987 {
31988 struct vm_struct *p, *o;
31989
31990 @@ -310,6 +310,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
31991
31992 /* If page is RAM, we can use __va. Otherwise ioremap and unmap. */
31993 if (page_is_ram(start >> PAGE_SHIFT))
31994 +#ifdef CONFIG_HIGHMEM
31995 + if ((start >> PAGE_SHIFT) < max_low_pfn)
31996 +#endif
31997 return __va(phys);
31998
31999 addr = (void __force *)ioremap_cache(start, PAGE_SIZE);
32000 @@ -322,6 +325,9 @@ void *xlate_dev_mem_ptr(unsigned long phys)
32001 void unxlate_dev_mem_ptr(unsigned long phys, void *addr)
32002 {
32003 if (page_is_ram(phys >> PAGE_SHIFT))
32004 +#ifdef CONFIG_HIGHMEM
32005 + if ((phys >> PAGE_SHIFT) < max_low_pfn)
32006 +#endif
32007 return;
32008
32009 iounmap((void __iomem *)((unsigned long)addr & PAGE_MASK));
32010 @@ -339,7 +345,7 @@ static int __init early_ioremap_debug_setup(char *str)
32011 early_param("early_ioremap_debug", early_ioremap_debug_setup);
32012
32013 static __initdata int after_paging_init;
32014 -static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __page_aligned_bss;
32015 +static pte_t bm_pte[PAGE_SIZE/sizeof(pte_t)] __read_only __aligned(PAGE_SIZE);
32016
32017 static inline pmd_t * __init early_ioremap_pmd(unsigned long addr)
32018 {
32019 @@ -376,8 +382,7 @@ void __init early_ioremap_init(void)
32020 slot_virt[i] = __fix_to_virt(FIX_BTMAP_BEGIN - NR_FIX_BTMAPS*i);
32021
32022 pmd = early_ioremap_pmd(fix_to_virt(FIX_BTMAP_BEGIN));
32023 - memset(bm_pte, 0, sizeof(bm_pte));
32024 - pmd_populate_kernel(&init_mm, pmd, bm_pte);
32025 + pmd_populate_user(&init_mm, pmd, bm_pte);
32026
32027 /*
32028 * The boot-ioremap range spans multiple pmds, for which
32029 diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c
32030 index d87dd6d..bf3fa66 100644
32031 --- a/arch/x86/mm/kmemcheck/kmemcheck.c
32032 +++ b/arch/x86/mm/kmemcheck/kmemcheck.c
32033 @@ -622,9 +622,9 @@ bool kmemcheck_fault(struct pt_regs *regs, unsigned long address,
32034 * memory (e.g. tracked pages)? For now, we need this to avoid
32035 * invoking kmemcheck for PnP BIOS calls.
32036 */
32037 - if (regs->flags & X86_VM_MASK)
32038 + if (v8086_mode(regs))
32039 return false;
32040 - if (regs->cs != __KERNEL_CS)
32041 + if (regs->cs != __KERNEL_CS && regs->cs != __KERNEXEC_KERNEL_CS)
32042 return false;
32043
32044 pte = kmemcheck_pte_lookup(address);
32045 diff --git a/arch/x86/mm/mmap.c b/arch/x86/mm/mmap.c
32046 index 25e7e13..1964579 100644
32047 --- a/arch/x86/mm/mmap.c
32048 +++ b/arch/x86/mm/mmap.c
32049 @@ -52,7 +52,7 @@ static unsigned int stack_maxrandom_size(void)
32050 * Leave an at least ~128 MB hole with possible stack randomization.
32051 */
32052 #define MIN_GAP (128*1024*1024UL + stack_maxrandom_size())
32053 -#define MAX_GAP (TASK_SIZE/6*5)
32054 +#define MAX_GAP (pax_task_size/6*5)
32055
32056 static int mmap_is_legacy(void)
32057 {
32058 @@ -82,27 +82,40 @@ static unsigned long mmap_rnd(void)
32059 return rnd << PAGE_SHIFT;
32060 }
32061
32062 -static unsigned long mmap_base(void)
32063 +static unsigned long mmap_base(struct mm_struct *mm)
32064 {
32065 unsigned long gap = rlimit(RLIMIT_STACK);
32066 + unsigned long pax_task_size = TASK_SIZE;
32067 +
32068 +#ifdef CONFIG_PAX_SEGMEXEC
32069 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32070 + pax_task_size = SEGMEXEC_TASK_SIZE;
32071 +#endif
32072
32073 if (gap < MIN_GAP)
32074 gap = MIN_GAP;
32075 else if (gap > MAX_GAP)
32076 gap = MAX_GAP;
32077
32078 - return PAGE_ALIGN(TASK_SIZE - gap - mmap_rnd());
32079 + return PAGE_ALIGN(pax_task_size - gap - mmap_rnd());
32080 }
32081
32082 /*
32083 * Bottom-up (legacy) layout on X86_32 did not support randomization, X86_64
32084 * does, but not when emulating X86_32
32085 */
32086 -static unsigned long mmap_legacy_base(void)
32087 +static unsigned long mmap_legacy_base(struct mm_struct *mm)
32088 {
32089 - if (mmap_is_ia32())
32090 + if (mmap_is_ia32()) {
32091 +
32092 +#ifdef CONFIG_PAX_SEGMEXEC
32093 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
32094 + return SEGMEXEC_TASK_UNMAPPED_BASE;
32095 + else
32096 +#endif
32097 +
32098 return TASK_UNMAPPED_BASE;
32099 - else
32100 + } else
32101 return TASK_UNMAPPED_BASE + mmap_rnd();
32102 }
32103
32104 @@ -112,8 +125,15 @@ static unsigned long mmap_legacy_base(void)
32105 */
32106 void arch_pick_mmap_layout(struct mm_struct *mm)
32107 {
32108 - mm->mmap_legacy_base = mmap_legacy_base();
32109 - mm->mmap_base = mmap_base();
32110 + mm->mmap_legacy_base = mmap_legacy_base(mm);
32111 + mm->mmap_base = mmap_base(mm);
32112 +
32113 +#ifdef CONFIG_PAX_RANDMMAP
32114 + if (mm->pax_flags & MF_PAX_RANDMMAP) {
32115 + mm->mmap_legacy_base += mm->delta_mmap;
32116 + mm->mmap_base -= mm->delta_mmap + mm->delta_stack;
32117 + }
32118 +#endif
32119
32120 if (mmap_is_legacy()) {
32121 mm->mmap_base = mm->mmap_legacy_base;
32122 diff --git a/arch/x86/mm/mmio-mod.c b/arch/x86/mm/mmio-mod.c
32123 index 0057a7a..95c7edd 100644
32124 --- a/arch/x86/mm/mmio-mod.c
32125 +++ b/arch/x86/mm/mmio-mod.c
32126 @@ -194,7 +194,7 @@ static void pre(struct kmmio_probe *p, struct pt_regs *regs,
32127 break;
32128 default:
32129 {
32130 - unsigned char *ip = (unsigned char *)instptr;
32131 + unsigned char *ip = (unsigned char *)ktla_ktva(instptr);
32132 my_trace->opcode = MMIO_UNKNOWN_OP;
32133 my_trace->width = 0;
32134 my_trace->value = (*ip) << 16 | *(ip + 1) << 8 |
32135 @@ -234,7 +234,7 @@ static void post(struct kmmio_probe *p, unsigned long condition,
32136 static void ioremap_trace_core(resource_size_t offset, unsigned long size,
32137 void __iomem *addr)
32138 {
32139 - static atomic_t next_id;
32140 + static atomic_unchecked_t next_id;
32141 struct remap_trace *trace = kmalloc(sizeof(*trace), GFP_KERNEL);
32142 /* These are page-unaligned. */
32143 struct mmiotrace_map map = {
32144 @@ -258,7 +258,7 @@ static void ioremap_trace_core(resource_size_t offset, unsigned long size,
32145 .private = trace
32146 },
32147 .phys = offset,
32148 - .id = atomic_inc_return(&next_id)
32149 + .id = atomic_inc_return_unchecked(&next_id)
32150 };
32151 map.map_id = trace->id;
32152
32153 @@ -290,7 +290,7 @@ void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
32154 ioremap_trace_core(offset, size, addr);
32155 }
32156
32157 -static void iounmap_trace_core(volatile void __iomem *addr)
32158 +static void iounmap_trace_core(const volatile void __iomem *addr)
32159 {
32160 struct mmiotrace_map map = {
32161 .phys = 0,
32162 @@ -328,7 +328,7 @@ not_enabled:
32163 }
32164 }
32165
32166 -void mmiotrace_iounmap(volatile void __iomem *addr)
32167 +void mmiotrace_iounmap(const volatile void __iomem *addr)
32168 {
32169 might_sleep();
32170 if (is_enabled()) /* recheck and proper locking in *_core() */
32171 diff --git a/arch/x86/mm/numa.c b/arch/x86/mm/numa.c
32172 index 8bf93ba..dbcd670 100644
32173 --- a/arch/x86/mm/numa.c
32174 +++ b/arch/x86/mm/numa.c
32175 @@ -474,7 +474,7 @@ static bool __init numa_meminfo_cover_memory(const struct numa_meminfo *mi)
32176 return true;
32177 }
32178
32179 -static int __init numa_register_memblks(struct numa_meminfo *mi)
32180 +static int __init __intentional_overflow(-1) numa_register_memblks(struct numa_meminfo *mi)
32181 {
32182 unsigned long uninitialized_var(pfn_align);
32183 int i, nid;
32184 diff --git a/arch/x86/mm/pageattr-test.c b/arch/x86/mm/pageattr-test.c
32185 index d0b1773..4c3327c 100644
32186 --- a/arch/x86/mm/pageattr-test.c
32187 +++ b/arch/x86/mm/pageattr-test.c
32188 @@ -36,7 +36,7 @@ enum {
32189
32190 static int pte_testbit(pte_t pte)
32191 {
32192 - return pte_flags(pte) & _PAGE_UNUSED1;
32193 + return pte_flags(pte) & _PAGE_CPA_TEST;
32194 }
32195
32196 struct split_state {
32197 diff --git a/arch/x86/mm/pageattr.c b/arch/x86/mm/pageattr.c
32198 index bb32480..75f2f5e 100644
32199 --- a/arch/x86/mm/pageattr.c
32200 +++ b/arch/x86/mm/pageattr.c
32201 @@ -261,7 +261,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32202 */
32203 #ifdef CONFIG_PCI_BIOS
32204 if (pcibios_enabled && within(pfn, BIOS_BEGIN >> PAGE_SHIFT, BIOS_END >> PAGE_SHIFT))
32205 - pgprot_val(forbidden) |= _PAGE_NX;
32206 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32207 #endif
32208
32209 /*
32210 @@ -269,9 +269,10 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32211 * Does not cover __inittext since that is gone later on. On
32212 * 64bit we do not enforce !NX on the low mapping
32213 */
32214 - if (within(address, (unsigned long)_text, (unsigned long)_etext))
32215 - pgprot_val(forbidden) |= _PAGE_NX;
32216 + if (within(address, ktla_ktva((unsigned long)_text), ktla_ktva((unsigned long)_etext)))
32217 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32218
32219 +#ifdef CONFIG_DEBUG_RODATA
32220 /*
32221 * The .rodata section needs to be read-only. Using the pfn
32222 * catches all aliases.
32223 @@ -279,6 +280,7 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32224 if (within(pfn, __pa_symbol(__start_rodata) >> PAGE_SHIFT,
32225 __pa_symbol(__end_rodata) >> PAGE_SHIFT))
32226 pgprot_val(forbidden) |= _PAGE_RW;
32227 +#endif
32228
32229 #if defined(CONFIG_X86_64) && defined(CONFIG_DEBUG_RODATA)
32230 /*
32231 @@ -317,6 +319,13 @@ static inline pgprot_t static_protections(pgprot_t prot, unsigned long address,
32232 }
32233 #endif
32234
32235 +#ifdef CONFIG_PAX_KERNEXEC
32236 + if (within(pfn, __pa(ktla_ktva((unsigned long)&_text)), __pa((unsigned long)&_sdata))) {
32237 + pgprot_val(forbidden) |= _PAGE_RW;
32238 + pgprot_val(forbidden) |= _PAGE_NX & __supported_pte_mask;
32239 + }
32240 +#endif
32241 +
32242 prot = __pgprot(pgprot_val(prot) & ~pgprot_val(forbidden));
32243
32244 return prot;
32245 @@ -400,23 +409,37 @@ EXPORT_SYMBOL_GPL(slow_virt_to_phys);
32246 static void __set_pmd_pte(pte_t *kpte, unsigned long address, pte_t pte)
32247 {
32248 /* change init_mm */
32249 + pax_open_kernel();
32250 set_pte_atomic(kpte, pte);
32251 +
32252 #ifdef CONFIG_X86_32
32253 if (!SHARED_KERNEL_PMD) {
32254 +
32255 +#ifdef CONFIG_PAX_PER_CPU_PGD
32256 + unsigned long cpu;
32257 +#else
32258 struct page *page;
32259 +#endif
32260
32261 +#ifdef CONFIG_PAX_PER_CPU_PGD
32262 + for (cpu = 0; cpu < nr_cpu_ids; ++cpu) {
32263 + pgd_t *pgd = get_cpu_pgd(cpu, kernel);
32264 +#else
32265 list_for_each_entry(page, &pgd_list, lru) {
32266 - pgd_t *pgd;
32267 + pgd_t *pgd = (pgd_t *)page_address(page);
32268 +#endif
32269 +
32270 pud_t *pud;
32271 pmd_t *pmd;
32272
32273 - pgd = (pgd_t *)page_address(page) + pgd_index(address);
32274 + pgd += pgd_index(address);
32275 pud = pud_offset(pgd, address);
32276 pmd = pmd_offset(pud, address);
32277 set_pte_atomic((pte_t *)pmd, pte);
32278 }
32279 }
32280 #endif
32281 + pax_close_kernel();
32282 }
32283
32284 static int
32285 diff --git a/arch/x86/mm/pat.c b/arch/x86/mm/pat.c
32286 index 6574388..87e9bef 100644
32287 --- a/arch/x86/mm/pat.c
32288 +++ b/arch/x86/mm/pat.c
32289 @@ -376,7 +376,7 @@ int free_memtype(u64 start, u64 end)
32290
32291 if (!entry) {
32292 printk(KERN_INFO "%s:%d freeing invalid memtype [mem %#010Lx-%#010Lx]\n",
32293 - current->comm, current->pid, start, end - 1);
32294 + current->comm, task_pid_nr(current), start, end - 1);
32295 return -EINVAL;
32296 }
32297
32298 @@ -506,8 +506,8 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
32299
32300 while (cursor < to) {
32301 if (!devmem_is_allowed(pfn)) {
32302 - printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx]\n",
32303 - current->comm, from, to - 1);
32304 + printk(KERN_INFO "Program %s tried to access /dev/mem between [mem %#010Lx-%#010Lx] (%#010Lx)\n",
32305 + current->comm, from, to - 1, cursor);
32306 return 0;
32307 }
32308 cursor += PAGE_SIZE;
32309 @@ -577,7 +577,7 @@ int kernel_map_sync_memtype(u64 base, unsigned long size, unsigned long flags)
32310 if (ioremap_change_attr((unsigned long)__va(base), id_sz, flags) < 0) {
32311 printk(KERN_INFO "%s:%d ioremap_change_attr failed %s "
32312 "for [mem %#010Lx-%#010Lx]\n",
32313 - current->comm, current->pid,
32314 + current->comm, task_pid_nr(current),
32315 cattr_name(flags),
32316 base, (unsigned long long)(base + size-1));
32317 return -EINVAL;
32318 @@ -612,7 +612,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32319 flags = lookup_memtype(paddr);
32320 if (want_flags != flags) {
32321 printk(KERN_WARNING "%s:%d map pfn RAM range req %s for [mem %#010Lx-%#010Lx], got %s\n",
32322 - current->comm, current->pid,
32323 + current->comm, task_pid_nr(current),
32324 cattr_name(want_flags),
32325 (unsigned long long)paddr,
32326 (unsigned long long)(paddr + size - 1),
32327 @@ -634,7 +634,7 @@ static int reserve_pfn_range(u64 paddr, unsigned long size, pgprot_t *vma_prot,
32328 free_memtype(paddr, paddr + size);
32329 printk(KERN_ERR "%s:%d map pfn expected mapping type %s"
32330 " for [mem %#010Lx-%#010Lx], got %s\n",
32331 - current->comm, current->pid,
32332 + current->comm, task_pid_nr(current),
32333 cattr_name(want_flags),
32334 (unsigned long long)paddr,
32335 (unsigned long long)(paddr + size - 1),
32336 diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
32337 index 415f6c4..d319983 100644
32338 --- a/arch/x86/mm/pat_rbtree.c
32339 +++ b/arch/x86/mm/pat_rbtree.c
32340 @@ -160,7 +160,7 @@ success:
32341
32342 failure:
32343 printk(KERN_INFO "%s:%d conflicting memory types "
32344 - "%Lx-%Lx %s<->%s\n", current->comm, current->pid, start,
32345 + "%Lx-%Lx %s<->%s\n", current->comm, task_pid_nr(current), start,
32346 end, cattr_name(found_type), cattr_name(match->type));
32347 return -EBUSY;
32348 }
32349 diff --git a/arch/x86/mm/pf_in.c b/arch/x86/mm/pf_in.c
32350 index 9f0614d..92ae64a 100644
32351 --- a/arch/x86/mm/pf_in.c
32352 +++ b/arch/x86/mm/pf_in.c
32353 @@ -148,7 +148,7 @@ enum reason_type get_ins_type(unsigned long ins_addr)
32354 int i;
32355 enum reason_type rv = OTHERS;
32356
32357 - p = (unsigned char *)ins_addr;
32358 + p = (unsigned char *)ktla_ktva(ins_addr);
32359 p += skip_prefix(p, &prf);
32360 p += get_opcode(p, &opcode);
32361
32362 @@ -168,7 +168,7 @@ static unsigned int get_ins_reg_width(unsigned long ins_addr)
32363 struct prefix_bits prf;
32364 int i;
32365
32366 - p = (unsigned char *)ins_addr;
32367 + p = (unsigned char *)ktla_ktva(ins_addr);
32368 p += skip_prefix(p, &prf);
32369 p += get_opcode(p, &opcode);
32370
32371 @@ -191,7 +191,7 @@ unsigned int get_ins_mem_width(unsigned long ins_addr)
32372 struct prefix_bits prf;
32373 int i;
32374
32375 - p = (unsigned char *)ins_addr;
32376 + p = (unsigned char *)ktla_ktva(ins_addr);
32377 p += skip_prefix(p, &prf);
32378 p += get_opcode(p, &opcode);
32379
32380 @@ -415,7 +415,7 @@ unsigned long get_ins_reg_val(unsigned long ins_addr, struct pt_regs *regs)
32381 struct prefix_bits prf;
32382 int i;
32383
32384 - p = (unsigned char *)ins_addr;
32385 + p = (unsigned char *)ktla_ktva(ins_addr);
32386 p += skip_prefix(p, &prf);
32387 p += get_opcode(p, &opcode);
32388 for (i = 0; i < ARRAY_SIZE(reg_rop); i++)
32389 @@ -470,7 +470,7 @@ unsigned long get_ins_imm_val(unsigned long ins_addr)
32390 struct prefix_bits prf;
32391 int i;
32392
32393 - p = (unsigned char *)ins_addr;
32394 + p = (unsigned char *)ktla_ktva(ins_addr);
32395 p += skip_prefix(p, &prf);
32396 p += get_opcode(p, &opcode);
32397 for (i = 0; i < ARRAY_SIZE(imm_wop); i++)
32398 diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
32399 index dfa537a..fd45c64 100644
32400 --- a/arch/x86/mm/pgtable.c
32401 +++ b/arch/x86/mm/pgtable.c
32402 @@ -91,10 +91,67 @@ static inline void pgd_list_del(pgd_t *pgd)
32403 list_del(&page->lru);
32404 }
32405
32406 -#define UNSHARED_PTRS_PER_PGD \
32407 - (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32408 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32409 +pgdval_t clone_pgd_mask __read_only = ~_PAGE_PRESENT;
32410
32411 +void __shadow_user_pgds(pgd_t *dst, const pgd_t *src)
32412 +{
32413 + unsigned int count = USER_PGD_PTRS;
32414
32415 + if (!pax_user_shadow_base)
32416 + return;
32417 +
32418 + while (count--)
32419 + *dst++ = __pgd((pgd_val(*src++) | (_PAGE_NX & __supported_pte_mask)) & ~_PAGE_USER);
32420 +}
32421 +#endif
32422 +
32423 +#ifdef CONFIG_PAX_PER_CPU_PGD
32424 +void __clone_user_pgds(pgd_t *dst, const pgd_t *src)
32425 +{
32426 + unsigned int count = USER_PGD_PTRS;
32427 +
32428 + while (count--) {
32429 + pgd_t pgd;
32430 +
32431 +#ifdef CONFIG_X86_64
32432 + pgd = __pgd(pgd_val(*src++) | _PAGE_USER);
32433 +#else
32434 + pgd = *src++;
32435 +#endif
32436 +
32437 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
32438 + pgd = __pgd(pgd_val(pgd) & clone_pgd_mask);
32439 +#endif
32440 +
32441 + *dst++ = pgd;
32442 + }
32443 +
32444 +}
32445 +#endif
32446 +
32447 +#ifdef CONFIG_X86_64
32448 +#define pxd_t pud_t
32449 +#define pyd_t pgd_t
32450 +#define paravirt_release_pxd(pfn) paravirt_release_pud(pfn)
32451 +#define pxd_free(mm, pud) pud_free((mm), (pud))
32452 +#define pyd_populate(mm, pgd, pud) pgd_populate((mm), (pgd), (pud))
32453 +#define pyd_offset(mm, address) pgd_offset((mm), (address))
32454 +#define PYD_SIZE PGDIR_SIZE
32455 +#else
32456 +#define pxd_t pmd_t
32457 +#define pyd_t pud_t
32458 +#define paravirt_release_pxd(pfn) paravirt_release_pmd(pfn)
32459 +#define pxd_free(mm, pud) pmd_free((mm), (pud))
32460 +#define pyd_populate(mm, pgd, pud) pud_populate((mm), (pgd), (pud))
32461 +#define pyd_offset(mm, address) pud_offset((mm), (address))
32462 +#define PYD_SIZE PUD_SIZE
32463 +#endif
32464 +
32465 +#ifdef CONFIG_PAX_PER_CPU_PGD
32466 +static inline void pgd_ctor(struct mm_struct *mm, pgd_t *pgd) {}
32467 +static inline void pgd_dtor(pgd_t *pgd) {}
32468 +#else
32469 static void pgd_set_mm(pgd_t *pgd, struct mm_struct *mm)
32470 {
32471 BUILD_BUG_ON(sizeof(virt_to_page(pgd)->index) < sizeof(mm));
32472 @@ -135,6 +192,7 @@ static void pgd_dtor(pgd_t *pgd)
32473 pgd_list_del(pgd);
32474 spin_unlock(&pgd_lock);
32475 }
32476 +#endif
32477
32478 /*
32479 * List of all pgd's needed for non-PAE so it can invalidate entries
32480 @@ -147,7 +205,7 @@ static void pgd_dtor(pgd_t *pgd)
32481 * -- nyc
32482 */
32483
32484 -#ifdef CONFIG_X86_PAE
32485 +#if defined(CONFIG_X86_32) && defined(CONFIG_X86_PAE)
32486 /*
32487 * In PAE mode, we need to do a cr3 reload (=tlb flush) when
32488 * updating the top-level pagetable entries to guarantee the
32489 @@ -159,7 +217,7 @@ static void pgd_dtor(pgd_t *pgd)
32490 * not shared between pagetables (!SHARED_KERNEL_PMDS), we allocate
32491 * and initialize the kernel pmds here.
32492 */
32493 -#define PREALLOCATED_PMDS UNSHARED_PTRS_PER_PGD
32494 +#define PREALLOCATED_PXDS (SHARED_KERNEL_PMD ? KERNEL_PGD_BOUNDARY : PTRS_PER_PGD)
32495
32496 void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32497 {
32498 @@ -177,36 +235,38 @@ void pud_populate(struct mm_struct *mm, pud_t *pudp, pmd_t *pmd)
32499 */
32500 flush_tlb_mm(mm);
32501 }
32502 +#elif defined(CONFIG_X86_64) && defined(CONFIG_PAX_PER_CPU_PGD)
32503 +#define PREALLOCATED_PXDS USER_PGD_PTRS
32504 #else /* !CONFIG_X86_PAE */
32505
32506 /* No need to prepopulate any pagetable entries in non-PAE modes. */
32507 -#define PREALLOCATED_PMDS 0
32508 +#define PREALLOCATED_PXDS 0
32509
32510 #endif /* CONFIG_X86_PAE */
32511
32512 -static void free_pmds(pmd_t *pmds[])
32513 +static void free_pxds(pxd_t *pxds[])
32514 {
32515 int i;
32516
32517 - for(i = 0; i < PREALLOCATED_PMDS; i++)
32518 - if (pmds[i])
32519 - free_page((unsigned long)pmds[i]);
32520 + for(i = 0; i < PREALLOCATED_PXDS; i++)
32521 + if (pxds[i])
32522 + free_page((unsigned long)pxds[i]);
32523 }
32524
32525 -static int preallocate_pmds(pmd_t *pmds[])
32526 +static int preallocate_pxds(pxd_t *pxds[])
32527 {
32528 int i;
32529 bool failed = false;
32530
32531 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32532 - pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
32533 - if (pmd == NULL)
32534 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32535 + pxd_t *pxd = (pxd_t *)__get_free_page(PGALLOC_GFP);
32536 + if (pxd == NULL)
32537 failed = true;
32538 - pmds[i] = pmd;
32539 + pxds[i] = pxd;
32540 }
32541
32542 if (failed) {
32543 - free_pmds(pmds);
32544 + free_pxds(pxds);
32545 return -ENOMEM;
32546 }
32547
32548 @@ -219,49 +279,52 @@ static int preallocate_pmds(pmd_t *pmds[])
32549 * preallocate which never got a corresponding vma will need to be
32550 * freed manually.
32551 */
32552 -static void pgd_mop_up_pmds(struct mm_struct *mm, pgd_t *pgdp)
32553 +static void pgd_mop_up_pxds(struct mm_struct *mm, pgd_t *pgdp)
32554 {
32555 int i;
32556
32557 - for(i = 0; i < PREALLOCATED_PMDS; i++) {
32558 + for(i = 0; i < PREALLOCATED_PXDS; i++) {
32559 pgd_t pgd = pgdp[i];
32560
32561 if (pgd_val(pgd) != 0) {
32562 - pmd_t *pmd = (pmd_t *)pgd_page_vaddr(pgd);
32563 + pxd_t *pxd = (pxd_t *)pgd_page_vaddr(pgd);
32564
32565 - pgdp[i] = native_make_pgd(0);
32566 + set_pgd(pgdp + i, native_make_pgd(0));
32567
32568 - paravirt_release_pmd(pgd_val(pgd) >> PAGE_SHIFT);
32569 - pmd_free(mm, pmd);
32570 + paravirt_release_pxd(pgd_val(pgd) >> PAGE_SHIFT);
32571 + pxd_free(mm, pxd);
32572 }
32573 }
32574 }
32575
32576 -static void pgd_prepopulate_pmd(struct mm_struct *mm, pgd_t *pgd, pmd_t *pmds[])
32577 +static void pgd_prepopulate_pxd(struct mm_struct *mm, pgd_t *pgd, pxd_t *pxds[])
32578 {
32579 - pud_t *pud;
32580 + pyd_t *pyd;
32581 int i;
32582
32583 - if (PREALLOCATED_PMDS == 0) /* Work around gcc-3.4.x bug */
32584 + if (PREALLOCATED_PXDS == 0) /* Work around gcc-3.4.x bug */
32585 return;
32586
32587 - pud = pud_offset(pgd, 0);
32588 -
32589 - for (i = 0; i < PREALLOCATED_PMDS; i++, pud++) {
32590 - pmd_t *pmd = pmds[i];
32591 +#ifdef CONFIG_X86_64
32592 + pyd = pyd_offset(mm, 0L);
32593 +#else
32594 + pyd = pyd_offset(pgd, 0L);
32595 +#endif
32596
32597 + for (i = 0; i < PREALLOCATED_PXDS; i++, pyd++) {
32598 + pxd_t *pxd = pxds[i];
32599 if (i >= KERNEL_PGD_BOUNDARY)
32600 - memcpy(pmd, (pmd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32601 - sizeof(pmd_t) * PTRS_PER_PMD);
32602 + memcpy(pxd, (pxd_t *)pgd_page_vaddr(swapper_pg_dir[i]),
32603 + sizeof(pxd_t) * PTRS_PER_PMD);
32604
32605 - pud_populate(mm, pud, pmd);
32606 + pyd_populate(mm, pyd, pxd);
32607 }
32608 }
32609
32610 pgd_t *pgd_alloc(struct mm_struct *mm)
32611 {
32612 pgd_t *pgd;
32613 - pmd_t *pmds[PREALLOCATED_PMDS];
32614 + pxd_t *pxds[PREALLOCATED_PXDS];
32615
32616 pgd = (pgd_t *)__get_free_page(PGALLOC_GFP);
32617
32618 @@ -270,11 +333,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32619
32620 mm->pgd = pgd;
32621
32622 - if (preallocate_pmds(pmds) != 0)
32623 + if (preallocate_pxds(pxds) != 0)
32624 goto out_free_pgd;
32625
32626 if (paravirt_pgd_alloc(mm) != 0)
32627 - goto out_free_pmds;
32628 + goto out_free_pxds;
32629
32630 /*
32631 * Make sure that pre-populating the pmds is atomic with
32632 @@ -284,14 +347,14 @@ pgd_t *pgd_alloc(struct mm_struct *mm)
32633 spin_lock(&pgd_lock);
32634
32635 pgd_ctor(mm, pgd);
32636 - pgd_prepopulate_pmd(mm, pgd, pmds);
32637 + pgd_prepopulate_pxd(mm, pgd, pxds);
32638
32639 spin_unlock(&pgd_lock);
32640
32641 return pgd;
32642
32643 -out_free_pmds:
32644 - free_pmds(pmds);
32645 +out_free_pxds:
32646 + free_pxds(pxds);
32647 out_free_pgd:
32648 free_page((unsigned long)pgd);
32649 out:
32650 @@ -300,7 +363,7 @@ out:
32651
32652 void pgd_free(struct mm_struct *mm, pgd_t *pgd)
32653 {
32654 - pgd_mop_up_pmds(mm, pgd);
32655 + pgd_mop_up_pxds(mm, pgd);
32656 pgd_dtor(pgd);
32657 paravirt_pgd_free(mm, pgd);
32658 free_page((unsigned long)pgd);
32659 diff --git a/arch/x86/mm/pgtable_32.c b/arch/x86/mm/pgtable_32.c
32660 index a69bcb8..19068ab 100644
32661 --- a/arch/x86/mm/pgtable_32.c
32662 +++ b/arch/x86/mm/pgtable_32.c
32663 @@ -47,10 +47,13 @@ void set_pte_vaddr(unsigned long vaddr, pte_t pteval)
32664 return;
32665 }
32666 pte = pte_offset_kernel(pmd, vaddr);
32667 +
32668 + pax_open_kernel();
32669 if (pte_val(pteval))
32670 set_pte_at(&init_mm, vaddr, pte, pteval);
32671 else
32672 pte_clear(&init_mm, vaddr, pte);
32673 + pax_close_kernel();
32674
32675 /*
32676 * It's enough to flush this one mapping.
32677 diff --git a/arch/x86/mm/physaddr.c b/arch/x86/mm/physaddr.c
32678 index e666cbb..61788c45 100644
32679 --- a/arch/x86/mm/physaddr.c
32680 +++ b/arch/x86/mm/physaddr.c
32681 @@ -10,7 +10,7 @@
32682 #ifdef CONFIG_X86_64
32683
32684 #ifdef CONFIG_DEBUG_VIRTUAL
32685 -unsigned long __phys_addr(unsigned long x)
32686 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32687 {
32688 unsigned long y = x - __START_KERNEL_map;
32689
32690 @@ -67,7 +67,7 @@ EXPORT_SYMBOL(__virt_addr_valid);
32691 #else
32692
32693 #ifdef CONFIG_DEBUG_VIRTUAL
32694 -unsigned long __phys_addr(unsigned long x)
32695 +unsigned long __intentional_overflow(-1) __phys_addr(unsigned long x)
32696 {
32697 unsigned long phys_addr = x - PAGE_OFFSET;
32698 /* VMALLOC_* aren't constants */
32699 diff --git a/arch/x86/mm/setup_nx.c b/arch/x86/mm/setup_nx.c
32700 index 90555bf..f5f1828 100644
32701 --- a/arch/x86/mm/setup_nx.c
32702 +++ b/arch/x86/mm/setup_nx.c
32703 @@ -5,8 +5,10 @@
32704 #include <asm/pgtable.h>
32705 #include <asm/proto.h>
32706
32707 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32708 static int disable_nx;
32709
32710 +#ifndef CONFIG_PAX_PAGEEXEC
32711 /*
32712 * noexec = on|off
32713 *
32714 @@ -28,12 +30,17 @@ static int __init noexec_setup(char *str)
32715 return 0;
32716 }
32717 early_param("noexec", noexec_setup);
32718 +#endif
32719 +
32720 +#endif
32721
32722 void x86_configure_nx(void)
32723 {
32724 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
32725 if (cpu_has_nx && !disable_nx)
32726 __supported_pte_mask |= _PAGE_NX;
32727 else
32728 +#endif
32729 __supported_pte_mask &= ~_PAGE_NX;
32730 }
32731
32732 diff --git a/arch/x86/mm/tlb.c b/arch/x86/mm/tlb.c
32733 index ae699b3..f1b2ad2 100644
32734 --- a/arch/x86/mm/tlb.c
32735 +++ b/arch/x86/mm/tlb.c
32736 @@ -48,7 +48,11 @@ void leave_mm(int cpu)
32737 BUG();
32738 if (cpumask_test_cpu(cpu, mm_cpumask(active_mm))) {
32739 cpumask_clear_cpu(cpu, mm_cpumask(active_mm));
32740 +
32741 +#ifndef CONFIG_PAX_PER_CPU_PGD
32742 load_cr3(swapper_pg_dir);
32743 +#endif
32744 +
32745 }
32746 }
32747 EXPORT_SYMBOL_GPL(leave_mm);
32748 diff --git a/arch/x86/mm/uderef_64.c b/arch/x86/mm/uderef_64.c
32749 new file mode 100644
32750 index 0000000..dace51c
32751 --- /dev/null
32752 +++ b/arch/x86/mm/uderef_64.c
32753 @@ -0,0 +1,37 @@
32754 +#include <linux/mm.h>
32755 +#include <asm/pgtable.h>
32756 +#include <asm/uaccess.h>
32757 +
32758 +#ifdef CONFIG_PAX_MEMORY_UDEREF
32759 +/* PaX: due to the special call convention these functions must
32760 + * - remain leaf functions under all configurations,
32761 + * - never be called directly, only dereferenced from the wrappers.
32762 + */
32763 +void __pax_open_userland(void)
32764 +{
32765 + unsigned int cpu;
32766 +
32767 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32768 + return;
32769 +
32770 + cpu = raw_get_cpu();
32771 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_KERNEL);
32772 + write_cr3(__pa(get_cpu_pgd(cpu, user)) | PCID_USER | PCID_NOFLUSH);
32773 + raw_put_cpu_no_resched();
32774 +}
32775 +EXPORT_SYMBOL(__pax_open_userland);
32776 +
32777 +void __pax_close_userland(void)
32778 +{
32779 + unsigned int cpu;
32780 +
32781 + if (unlikely(!segment_eq(get_fs(), USER_DS)))
32782 + return;
32783 +
32784 + cpu = raw_get_cpu();
32785 + BUG_ON((read_cr3() & ~PAGE_MASK) != PCID_USER);
32786 + write_cr3(__pa(get_cpu_pgd(cpu, kernel)) | PCID_KERNEL | PCID_NOFLUSH);
32787 + raw_put_cpu_no_resched();
32788 +}
32789 +EXPORT_SYMBOL(__pax_close_userland);
32790 +#endif
32791 diff --git a/arch/x86/net/bpf_jit.S b/arch/x86/net/bpf_jit.S
32792 index 877b9a1..a8ecf42 100644
32793 --- a/arch/x86/net/bpf_jit.S
32794 +++ b/arch/x86/net/bpf_jit.S
32795 @@ -9,6 +9,7 @@
32796 */
32797 #include <linux/linkage.h>
32798 #include <asm/dwarf2.h>
32799 +#include <asm/alternative-asm.h>
32800
32801 /*
32802 * Calling convention :
32803 @@ -35,6 +36,7 @@ sk_load_word_positive_offset:
32804 jle bpf_slow_path_word
32805 mov (SKBDATA,%rsi),%eax
32806 bswap %eax /* ntohl() */
32807 + pax_force_retaddr
32808 ret
32809
32810 sk_load_half:
32811 @@ -52,6 +54,7 @@ sk_load_half_positive_offset:
32812 jle bpf_slow_path_half
32813 movzwl (SKBDATA,%rsi),%eax
32814 rol $8,%ax # ntohs()
32815 + pax_force_retaddr
32816 ret
32817
32818 sk_load_byte:
32819 @@ -66,6 +69,7 @@ sk_load_byte_positive_offset:
32820 cmp %esi,%r9d /* if (offset >= hlen) goto bpf_slow_path_byte */
32821 jle bpf_slow_path_byte
32822 movzbl (SKBDATA,%rsi),%eax
32823 + pax_force_retaddr
32824 ret
32825
32826 /**
32827 @@ -87,6 +91,7 @@ sk_load_byte_msh_positive_offset:
32828 movzbl (SKBDATA,%rsi),%ebx
32829 and $15,%bl
32830 shl $2,%bl
32831 + pax_force_retaddr
32832 ret
32833
32834 /* rsi contains offset and can be scratched */
32835 @@ -109,6 +114,7 @@ bpf_slow_path_word:
32836 js bpf_error
32837 mov -12(%rbp),%eax
32838 bswap %eax
32839 + pax_force_retaddr
32840 ret
32841
32842 bpf_slow_path_half:
32843 @@ -117,12 +123,14 @@ bpf_slow_path_half:
32844 mov -12(%rbp),%ax
32845 rol $8,%ax
32846 movzwl %ax,%eax
32847 + pax_force_retaddr
32848 ret
32849
32850 bpf_slow_path_byte:
32851 bpf_slow_path_common(1)
32852 js bpf_error
32853 movzbl -12(%rbp),%eax
32854 + pax_force_retaddr
32855 ret
32856
32857 bpf_slow_path_byte_msh:
32858 @@ -133,6 +141,7 @@ bpf_slow_path_byte_msh:
32859 and $15,%al
32860 shl $2,%al
32861 xchg %eax,%ebx
32862 + pax_force_retaddr
32863 ret
32864
32865 #define sk_negative_common(SIZE) \
32866 @@ -157,6 +166,7 @@ sk_load_word_negative_offset:
32867 sk_negative_common(4)
32868 mov (%rax), %eax
32869 bswap %eax
32870 + pax_force_retaddr
32871 ret
32872
32873 bpf_slow_path_half_neg:
32874 @@ -168,6 +178,7 @@ sk_load_half_negative_offset:
32875 mov (%rax),%ax
32876 rol $8,%ax
32877 movzwl %ax,%eax
32878 + pax_force_retaddr
32879 ret
32880
32881 bpf_slow_path_byte_neg:
32882 @@ -177,6 +188,7 @@ sk_load_byte_negative_offset:
32883 .globl sk_load_byte_negative_offset
32884 sk_negative_common(1)
32885 movzbl (%rax), %eax
32886 + pax_force_retaddr
32887 ret
32888
32889 bpf_slow_path_byte_msh_neg:
32890 @@ -190,6 +202,7 @@ sk_load_byte_msh_negative_offset:
32891 and $15,%al
32892 shl $2,%al
32893 xchg %eax,%ebx
32894 + pax_force_retaddr
32895 ret
32896
32897 bpf_error:
32898 @@ -197,4 +210,5 @@ bpf_error:
32899 xor %eax,%eax
32900 mov -8(%rbp),%rbx
32901 leaveq
32902 + pax_force_retaddr
32903 ret
32904 diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
32905 index 26328e8..5f96c25 100644
32906 --- a/arch/x86/net/bpf_jit_comp.c
32907 +++ b/arch/x86/net/bpf_jit_comp.c
32908 @@ -50,13 +50,90 @@ static inline u8 *emit_code(u8 *ptr, u32 bytes, unsigned int len)
32909 return ptr + len;
32910 }
32911
32912 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32913 +#define MAX_INSTR_CODE_SIZE 96
32914 +#else
32915 +#define MAX_INSTR_CODE_SIZE 64
32916 +#endif
32917 +
32918 #define EMIT(bytes, len) do { prog = emit_code(prog, bytes, len); } while (0)
32919
32920 #define EMIT1(b1) EMIT(b1, 1)
32921 #define EMIT2(b1, b2) EMIT((b1) + ((b2) << 8), 2)
32922 #define EMIT3(b1, b2, b3) EMIT((b1) + ((b2) << 8) + ((b3) << 16), 3)
32923 #define EMIT4(b1, b2, b3, b4) EMIT((b1) + ((b2) << 8) + ((b3) << 16) + ((b4) << 24), 4)
32924 +
32925 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
32926 +/* original constant will appear in ecx */
32927 +#define DILUTE_CONST_SEQUENCE(_off, _key) \
32928 +do { \
32929 + /* mov ecx, randkey */ \
32930 + EMIT1(0xb9); \
32931 + EMIT(_key, 4); \
32932 + /* xor ecx, randkey ^ off */ \
32933 + EMIT2(0x81, 0xf1); \
32934 + EMIT((_key) ^ (_off), 4); \
32935 +} while (0)
32936 +
32937 +#define EMIT1_off32(b1, _off) \
32938 +do { \
32939 + switch (b1) { \
32940 + case 0x05: /* add eax, imm32 */ \
32941 + case 0x2d: /* sub eax, imm32 */ \
32942 + case 0x25: /* and eax, imm32 */ \
32943 + case 0x0d: /* or eax, imm32 */ \
32944 + case 0xb8: /* mov eax, imm32 */ \
32945 + case 0x35: /* xor eax, imm32 */ \
32946 + case 0x3d: /* cmp eax, imm32 */ \
32947 + case 0xa9: /* test eax, imm32 */ \
32948 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32949 + EMIT2((b1) - 4, 0xc8); /* convert imm instruction to eax, ecx */\
32950 + break; \
32951 + case 0xbb: /* mov ebx, imm32 */ \
32952 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32953 + /* mov ebx, ecx */ \
32954 + EMIT2(0x89, 0xcb); \
32955 + break; \
32956 + case 0xbe: /* mov esi, imm32 */ \
32957 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32958 + /* mov esi, ecx */ \
32959 + EMIT2(0x89, 0xce); \
32960 + break; \
32961 + case 0xe8: /* call rel imm32, always to known funcs */ \
32962 + EMIT1(b1); \
32963 + EMIT(_off, 4); \
32964 + break; \
32965 + case 0xe9: /* jmp rel imm32 */ \
32966 + EMIT1(b1); \
32967 + EMIT(_off, 4); \
32968 + /* prevent fall-through, we're not called if off = 0 */ \
32969 + EMIT(0xcccccccc, 4); \
32970 + EMIT(0xcccccccc, 4); \
32971 + break; \
32972 + default: \
32973 + BUILD_BUG(); \
32974 + } \
32975 +} while (0)
32976 +
32977 +#define EMIT2_off32(b1, b2, _off) \
32978 +do { \
32979 + if ((b1) == 0x8d && (b2) == 0xb3) { /* lea esi, [rbx+imm32] */ \
32980 + EMIT2(0x8d, 0xb3); /* lea esi, [rbx+randkey] */ \
32981 + EMIT(randkey, 4); \
32982 + EMIT2(0x8d, 0xb6); /* lea esi, [esi+off-randkey] */ \
32983 + EMIT((_off) - randkey, 4); \
32984 + } else if ((b1) == 0x69 && (b2) == 0xc0) { /* imul eax, imm32 */\
32985 + DILUTE_CONST_SEQUENCE(_off, randkey); \
32986 + /* imul eax, ecx */ \
32987 + EMIT3(0x0f, 0xaf, 0xc1); \
32988 + } else { \
32989 + BUILD_BUG(); \
32990 + } \
32991 +} while (0)
32992 +#else
32993 #define EMIT1_off32(b1, off) do { EMIT1(b1); EMIT(off, 4);} while (0)
32994 +#define EMIT2_off32(b1, b2, off) do { EMIT2(b1, b2); EMIT(off, 4);} while (0)
32995 +#endif
32996
32997 #define CLEAR_A() EMIT2(0x31, 0xc0) /* xor %eax,%eax */
32998 #define CLEAR_X() EMIT2(0x31, 0xdb) /* xor %ebx,%ebx */
32999 @@ -91,6 +168,24 @@ do { \
33000 #define X86_JBE 0x76
33001 #define X86_JA 0x77
33002
33003 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33004 +#define APPEND_FLOW_VERIFY() \
33005 +do { \
33006 + /* mov ecx, randkey */ \
33007 + EMIT1(0xb9); \
33008 + EMIT(randkey, 4); \
33009 + /* cmp ecx, randkey */ \
33010 + EMIT2(0x81, 0xf9); \
33011 + EMIT(randkey, 4); \
33012 + /* jz after 8 int 3s */ \
33013 + EMIT2(0x74, 0x08); \
33014 + EMIT(0xcccccccc, 4); \
33015 + EMIT(0xcccccccc, 4); \
33016 +} while (0)
33017 +#else
33018 +#define APPEND_FLOW_VERIFY() do { } while (0)
33019 +#endif
33020 +
33021 #define EMIT_COND_JMP(op, offset) \
33022 do { \
33023 if (is_near(offset)) \
33024 @@ -98,6 +193,7 @@ do { \
33025 else { \
33026 EMIT2(0x0f, op + 0x10); \
33027 EMIT(offset, 4); /* jxx .+off32 */ \
33028 + APPEND_FLOW_VERIFY(); \
33029 } \
33030 } while (0)
33031
33032 @@ -145,55 +241,54 @@ static int pkt_type_offset(void)
33033 return -1;
33034 }
33035
33036 -struct bpf_binary_header {
33037 - unsigned int pages;
33038 - /* Note : for security reasons, bpf code will follow a randomly
33039 - * sized amount of int3 instructions
33040 - */
33041 - u8 image[];
33042 -};
33043 -
33044 -static struct bpf_binary_header *bpf_alloc_binary(unsigned int proglen,
33045 +/* Note : for security reasons, bpf code will follow a randomly
33046 + * sized amount of int3 instructions
33047 + */
33048 +static u8 *bpf_alloc_binary(unsigned int proglen,
33049 u8 **image_ptr)
33050 {
33051 unsigned int sz, hole;
33052 - struct bpf_binary_header *header;
33053 + u8 *header;
33054
33055 /* Most of BPF filters are really small,
33056 * but if some of them fill a page, allow at least
33057 * 128 extra bytes to insert a random section of int3
33058 */
33059 - sz = round_up(proglen + sizeof(*header) + 128, PAGE_SIZE);
33060 - header = module_alloc(sz);
33061 + sz = round_up(proglen + 128, PAGE_SIZE);
33062 + header = module_alloc_exec(sz);
33063 if (!header)
33064 return NULL;
33065
33066 + pax_open_kernel();
33067 memset(header, 0xcc, sz); /* fill whole space with int3 instructions */
33068 + pax_close_kernel();
33069
33070 - header->pages = sz / PAGE_SIZE;
33071 - hole = sz - (proglen + sizeof(*header));
33072 + hole = PAGE_SIZE - (proglen & ~PAGE_MASK);
33073
33074 /* insert a random number of int3 instructions before BPF code */
33075 - *image_ptr = &header->image[prandom_u32() % hole];
33076 + *image_ptr = &header[prandom_u32() % hole];
33077 return header;
33078 }
33079
33080 void bpf_jit_compile(struct sk_filter *fp)
33081 {
33082 - u8 temp[64];
33083 + u8 temp[MAX_INSTR_CODE_SIZE];
33084 u8 *prog;
33085 unsigned int proglen, oldproglen = 0;
33086 int ilen, i;
33087 int t_offset, f_offset;
33088 u8 t_op, f_op, seen = 0, pass;
33089 u8 *image = NULL;
33090 - struct bpf_binary_header *header = NULL;
33091 + u8 *header = NULL;
33092 u8 *func;
33093 int pc_ret0 = -1; /* bpf index of first RET #0 instruction (if any) */
33094 unsigned int cleanup_addr; /* epilogue code offset */
33095 unsigned int *addrs;
33096 const struct sock_filter *filter = fp->insns;
33097 int flen = fp->len;
33098 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33099 + unsigned int randkey;
33100 +#endif
33101
33102 if (!bpf_jit_enable)
33103 return;
33104 @@ -202,11 +297,15 @@ void bpf_jit_compile(struct sk_filter *fp)
33105 if (addrs == NULL)
33106 return;
33107
33108 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33109 + randkey = get_random_int();
33110 +#endif
33111 +
33112 /* Before first pass, make a rough estimation of addrs[]
33113 - * each bpf instruction is translated to less than 64 bytes
33114 + * each bpf instruction is translated to less than MAX_INSTR_CODE_SIZE bytes
33115 */
33116 for (proglen = 0, i = 0; i < flen; i++) {
33117 - proglen += 64;
33118 + proglen += MAX_INSTR_CODE_SIZE;
33119 addrs[i] = proglen;
33120 }
33121 cleanup_addr = proglen; /* epilogue address */
33122 @@ -317,10 +416,8 @@ void bpf_jit_compile(struct sk_filter *fp)
33123 case BPF_S_ALU_MUL_K: /* A *= K */
33124 if (is_imm8(K))
33125 EMIT3(0x6b, 0xc0, K); /* imul imm8,%eax,%eax */
33126 - else {
33127 - EMIT2(0x69, 0xc0); /* imul imm32,%eax */
33128 - EMIT(K, 4);
33129 - }
33130 + else
33131 + EMIT2_off32(0x69, 0xc0, K); /* imul imm32,%eax */
33132 break;
33133 case BPF_S_ALU_DIV_X: /* A /= X; */
33134 seen |= SEEN_XREG;
33135 @@ -360,13 +457,23 @@ void bpf_jit_compile(struct sk_filter *fp)
33136 break;
33137 case BPF_S_ALU_MOD_K: /* A %= K; */
33138 EMIT2(0x31, 0xd2); /* xor %edx,%edx */
33139 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33140 + DILUTE_CONST_SEQUENCE(K, randkey);
33141 +#else
33142 EMIT1(0xb9);EMIT(K, 4); /* mov imm32,%ecx */
33143 +#endif
33144 EMIT2(0xf7, 0xf1); /* div %ecx */
33145 EMIT2(0x89, 0xd0); /* mov %edx,%eax */
33146 break;
33147 case BPF_S_ALU_DIV_K: /* A = reciprocal_divide(A, K); */
33148 +#ifdef CONFIG_GRKERNSEC_JIT_HARDEN
33149 + DILUTE_CONST_SEQUENCE(K, randkey);
33150 + // imul rax, rcx
33151 + EMIT4(0x48, 0x0f, 0xaf, 0xc1);
33152 +#else
33153 EMIT3(0x48, 0x69, 0xc0); /* imul imm32,%rax,%rax */
33154 EMIT(K, 4);
33155 +#endif
33156 EMIT4(0x48, 0xc1, 0xe8, 0x20); /* shr $0x20,%rax */
33157 break;
33158 case BPF_S_ALU_AND_X:
33159 @@ -637,8 +744,7 @@ common_load_ind: seen |= SEEN_DATAREF | SEEN_XREG;
33160 if (is_imm8(K)) {
33161 EMIT3(0x8d, 0x73, K); /* lea imm8(%rbx), %esi */
33162 } else {
33163 - EMIT2(0x8d, 0xb3); /* lea imm32(%rbx),%esi */
33164 - EMIT(K, 4);
33165 + EMIT2_off32(0x8d, 0xb3, K); /* lea imm32(%rbx),%esi */
33166 }
33167 } else {
33168 EMIT2(0x89,0xde); /* mov %ebx,%esi */
33169 @@ -728,10 +834,12 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
33170 if (unlikely(proglen + ilen > oldproglen)) {
33171 pr_err("bpb_jit_compile fatal error\n");
33172 kfree(addrs);
33173 - module_free(NULL, header);
33174 + module_free_exec(NULL, image);
33175 return;
33176 }
33177 + pax_open_kernel();
33178 memcpy(image + proglen, temp, ilen);
33179 + pax_close_kernel();
33180 }
33181 proglen += ilen;
33182 addrs[i] = proglen;
33183 @@ -764,7 +872,6 @@ cond_branch: f_offset = addrs[i + filter[i].jf] - addrs[i];
33184
33185 if (image) {
33186 bpf_flush_icache(header, image + proglen);
33187 - set_memory_ro((unsigned long)header, header->pages);
33188 fp->bpf_func = (void *)image;
33189 }
33190 out:
33191 @@ -776,10 +883,9 @@ static void bpf_jit_free_deferred(struct work_struct *work)
33192 {
33193 struct sk_filter *fp = container_of(work, struct sk_filter, work);
33194 unsigned long addr = (unsigned long)fp->bpf_func & PAGE_MASK;
33195 - struct bpf_binary_header *header = (void *)addr;
33196
33197 - set_memory_rw(addr, header->pages);
33198 - module_free(NULL, header);
33199 + set_memory_rw(addr, 1);
33200 + module_free_exec(NULL, (void *)addr);
33201 kfree(fp);
33202 }
33203
33204 diff --git a/arch/x86/oprofile/backtrace.c b/arch/x86/oprofile/backtrace.c
33205 index d6aa6e8..266395a 100644
33206 --- a/arch/x86/oprofile/backtrace.c
33207 +++ b/arch/x86/oprofile/backtrace.c
33208 @@ -46,11 +46,11 @@ dump_user_backtrace_32(struct stack_frame_ia32 *head)
33209 struct stack_frame_ia32 *fp;
33210 unsigned long bytes;
33211
33212 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33213 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33214 if (bytes != sizeof(bufhead))
33215 return NULL;
33216
33217 - fp = (struct stack_frame_ia32 *) compat_ptr(bufhead[0].next_frame);
33218 + fp = (struct stack_frame_ia32 __force_kernel *) compat_ptr(bufhead[0].next_frame);
33219
33220 oprofile_add_trace(bufhead[0].return_address);
33221
33222 @@ -92,7 +92,7 @@ static struct stack_frame *dump_user_backtrace(struct stack_frame *head)
33223 struct stack_frame bufhead[2];
33224 unsigned long bytes;
33225
33226 - bytes = copy_from_user_nmi(bufhead, head, sizeof(bufhead));
33227 + bytes = copy_from_user_nmi(bufhead, (const char __force_user *)head, sizeof(bufhead));
33228 if (bytes != sizeof(bufhead))
33229 return NULL;
33230
33231 @@ -111,7 +111,7 @@ x86_backtrace(struct pt_regs * const regs, unsigned int depth)
33232 {
33233 struct stack_frame *head = (struct stack_frame *)frame_pointer(regs);
33234
33235 - if (!user_mode_vm(regs)) {
33236 + if (!user_mode(regs)) {
33237 unsigned long stack = kernel_stack_pointer(regs);
33238 if (depth)
33239 dump_trace(NULL, regs, (unsigned long *)stack, 0,
33240 diff --git a/arch/x86/oprofile/nmi_int.c b/arch/x86/oprofile/nmi_int.c
33241 index 6890d84..1dad1f1 100644
33242 --- a/arch/x86/oprofile/nmi_int.c
33243 +++ b/arch/x86/oprofile/nmi_int.c
33244 @@ -23,6 +23,7 @@
33245 #include <asm/nmi.h>
33246 #include <asm/msr.h>
33247 #include <asm/apic.h>
33248 +#include <asm/pgtable.h>
33249
33250 #include "op_counter.h"
33251 #include "op_x86_model.h"
33252 @@ -774,8 +775,11 @@ int __init op_nmi_init(struct oprofile_operations *ops)
33253 if (ret)
33254 return ret;
33255
33256 - if (!model->num_virt_counters)
33257 - model->num_virt_counters = model->num_counters;
33258 + if (!model->num_virt_counters) {
33259 + pax_open_kernel();
33260 + *(unsigned int *)&model->num_virt_counters = model->num_counters;
33261 + pax_close_kernel();
33262 + }
33263
33264 mux_init(ops);
33265
33266 diff --git a/arch/x86/oprofile/op_model_amd.c b/arch/x86/oprofile/op_model_amd.c
33267 index 50d86c0..7985318 100644
33268 --- a/arch/x86/oprofile/op_model_amd.c
33269 +++ b/arch/x86/oprofile/op_model_amd.c
33270 @@ -519,9 +519,11 @@ static int op_amd_init(struct oprofile_operations *ops)
33271 num_counters = AMD64_NUM_COUNTERS;
33272 }
33273
33274 - op_amd_spec.num_counters = num_counters;
33275 - op_amd_spec.num_controls = num_counters;
33276 - op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33277 + pax_open_kernel();
33278 + *(unsigned int *)&op_amd_spec.num_counters = num_counters;
33279 + *(unsigned int *)&op_amd_spec.num_controls = num_counters;
33280 + *(unsigned int *)&op_amd_spec.num_virt_counters = max(num_counters, NUM_VIRT_COUNTERS);
33281 + pax_close_kernel();
33282
33283 return 0;
33284 }
33285 diff --git a/arch/x86/oprofile/op_model_ppro.c b/arch/x86/oprofile/op_model_ppro.c
33286 index d90528e..0127e2b 100644
33287 --- a/arch/x86/oprofile/op_model_ppro.c
33288 +++ b/arch/x86/oprofile/op_model_ppro.c
33289 @@ -19,6 +19,7 @@
33290 #include <asm/msr.h>
33291 #include <asm/apic.h>
33292 #include <asm/nmi.h>
33293 +#include <asm/pgtable.h>
33294
33295 #include "op_x86_model.h"
33296 #include "op_counter.h"
33297 @@ -221,8 +222,10 @@ static void arch_perfmon_setup_counters(void)
33298
33299 num_counters = min((int)eax.split.num_counters, OP_MAX_COUNTER);
33300
33301 - op_arch_perfmon_spec.num_counters = num_counters;
33302 - op_arch_perfmon_spec.num_controls = num_counters;
33303 + pax_open_kernel();
33304 + *(unsigned int *)&op_arch_perfmon_spec.num_counters = num_counters;
33305 + *(unsigned int *)&op_arch_perfmon_spec.num_controls = num_counters;
33306 + pax_close_kernel();
33307 }
33308
33309 static int arch_perfmon_init(struct oprofile_operations *ignore)
33310 diff --git a/arch/x86/oprofile/op_x86_model.h b/arch/x86/oprofile/op_x86_model.h
33311 index 71e8a67..6a313bb 100644
33312 --- a/arch/x86/oprofile/op_x86_model.h
33313 +++ b/arch/x86/oprofile/op_x86_model.h
33314 @@ -52,7 +52,7 @@ struct op_x86_model_spec {
33315 void (*switch_ctrl)(struct op_x86_model_spec const *model,
33316 struct op_msrs const * const msrs);
33317 #endif
33318 -};
33319 +} __do_const;
33320
33321 struct op_counter_config;
33322
33323 diff --git a/arch/x86/pci/irq.c b/arch/x86/pci/irq.c
33324 index 372e9b8..e775a6c 100644
33325 --- a/arch/x86/pci/irq.c
33326 +++ b/arch/x86/pci/irq.c
33327 @@ -50,7 +50,7 @@ struct irq_router {
33328 struct irq_router_handler {
33329 u16 vendor;
33330 int (*probe)(struct irq_router *r, struct pci_dev *router, u16 device);
33331 -};
33332 +} __do_const;
33333
33334 int (*pcibios_enable_irq)(struct pci_dev *dev) = pirq_enable_irq;
33335 void (*pcibios_disable_irq)(struct pci_dev *dev) = NULL;
33336 @@ -794,7 +794,7 @@ static __init int pico_router_probe(struct irq_router *r, struct pci_dev *router
33337 return 0;
33338 }
33339
33340 -static __initdata struct irq_router_handler pirq_routers[] = {
33341 +static __initconst const struct irq_router_handler pirq_routers[] = {
33342 { PCI_VENDOR_ID_INTEL, intel_router_probe },
33343 { PCI_VENDOR_ID_AL, ali_router_probe },
33344 { PCI_VENDOR_ID_ITE, ite_router_probe },
33345 @@ -821,7 +821,7 @@ static struct pci_dev *pirq_router_dev;
33346 static void __init pirq_find_router(struct irq_router *r)
33347 {
33348 struct irq_routing_table *rt = pirq_table;
33349 - struct irq_router_handler *h;
33350 + const struct irq_router_handler *h;
33351
33352 #ifdef CONFIG_PCI_BIOS
33353 if (!rt->signature) {
33354 @@ -1094,7 +1094,7 @@ static int __init fix_acer_tm360_irqrouting(const struct dmi_system_id *d)
33355 return 0;
33356 }
33357
33358 -static struct dmi_system_id __initdata pciirq_dmi_table[] = {
33359 +static const struct dmi_system_id __initconst pciirq_dmi_table[] = {
33360 {
33361 .callback = fix_broken_hp_bios_irq9,
33362 .ident = "HP Pavilion N5400 Series Laptop",
33363 diff --git a/arch/x86/pci/mrst.c b/arch/x86/pci/mrst.c
33364 index 903fded..94b0d88 100644
33365 --- a/arch/x86/pci/mrst.c
33366 +++ b/arch/x86/pci/mrst.c
33367 @@ -241,7 +241,9 @@ int __init pci_mrst_init(void)
33368 pr_info("Intel MID platform detected, using MID PCI ops\n");
33369 pci_mmcfg_late_init();
33370 pcibios_enable_irq = mrst_pci_irq_enable;
33371 - pci_root_ops = pci_mrst_ops;
33372 + pax_open_kernel();
33373 + memcpy((void *)&pci_root_ops, &pci_mrst_ops, sizeof(pci_mrst_ops));
33374 + pax_close_kernel();
33375 pci_soc_mode = 1;
33376 /* Continue with standard init */
33377 return 1;
33378 diff --git a/arch/x86/pci/pcbios.c b/arch/x86/pci/pcbios.c
33379 index c77b24a..c979855 100644
33380 --- a/arch/x86/pci/pcbios.c
33381 +++ b/arch/x86/pci/pcbios.c
33382 @@ -79,7 +79,7 @@ union bios32 {
33383 static struct {
33384 unsigned long address;
33385 unsigned short segment;
33386 -} bios32_indirect = { 0, __KERNEL_CS };
33387 +} bios32_indirect __read_only = { 0, __PCIBIOS_CS };
33388
33389 /*
33390 * Returns the entry point for the given service, NULL on error
33391 @@ -92,37 +92,80 @@ static unsigned long bios32_service(unsigned long service)
33392 unsigned long length; /* %ecx */
33393 unsigned long entry; /* %edx */
33394 unsigned long flags;
33395 + struct desc_struct d, *gdt;
33396
33397 local_irq_save(flags);
33398 - __asm__("lcall *(%%edi); cld"
33399 +
33400 + gdt = get_cpu_gdt_table(smp_processor_id());
33401 +
33402 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x9B, 0xC);
33403 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33404 + pack_descriptor(&d, 0UL, 0xFFFFFUL, 0x93, 0xC);
33405 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33406 +
33407 + __asm__("movw %w7, %%ds; lcall *(%%edi); push %%ss; pop %%ds; cld"
33408 : "=a" (return_code),
33409 "=b" (address),
33410 "=c" (length),
33411 "=d" (entry)
33412 : "0" (service),
33413 "1" (0),
33414 - "D" (&bios32_indirect));
33415 + "D" (&bios32_indirect),
33416 + "r"(__PCIBIOS_DS)
33417 + : "memory");
33418 +
33419 + pax_open_kernel();
33420 + gdt[GDT_ENTRY_PCIBIOS_CS].a = 0;
33421 + gdt[GDT_ENTRY_PCIBIOS_CS].b = 0;
33422 + gdt[GDT_ENTRY_PCIBIOS_DS].a = 0;
33423 + gdt[GDT_ENTRY_PCIBIOS_DS].b = 0;
33424 + pax_close_kernel();
33425 +
33426 local_irq_restore(flags);
33427
33428 switch (return_code) {
33429 - case 0:
33430 - return address + entry;
33431 - case 0x80: /* Not present */
33432 - printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33433 - return 0;
33434 - default: /* Shouldn't happen */
33435 - printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33436 - service, return_code);
33437 + case 0: {
33438 + int cpu;
33439 + unsigned char flags;
33440 +
33441 + printk(KERN_INFO "bios32_service: base:%08lx length:%08lx entry:%08lx\n", address, length, entry);
33442 + if (address >= 0xFFFF0 || length > 0x100000 - address || length <= entry) {
33443 + printk(KERN_WARNING "bios32_service: not valid\n");
33444 return 0;
33445 + }
33446 + address = address + PAGE_OFFSET;
33447 + length += 16UL; /* some BIOSs underreport this... */
33448 + flags = 4;
33449 + if (length >= 64*1024*1024) {
33450 + length >>= PAGE_SHIFT;
33451 + flags |= 8;
33452 + }
33453 +
33454 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
33455 + gdt = get_cpu_gdt_table(cpu);
33456 + pack_descriptor(&d, address, length, 0x9b, flags);
33457 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_CS, &d, DESCTYPE_S);
33458 + pack_descriptor(&d, address, length, 0x93, flags);
33459 + write_gdt_entry(gdt, GDT_ENTRY_PCIBIOS_DS, &d, DESCTYPE_S);
33460 + }
33461 + return entry;
33462 + }
33463 + case 0x80: /* Not present */
33464 + printk(KERN_WARNING "bios32_service(0x%lx): not present\n", service);
33465 + return 0;
33466 + default: /* Shouldn't happen */
33467 + printk(KERN_WARNING "bios32_service(0x%lx): returned 0x%x -- BIOS bug!\n",
33468 + service, return_code);
33469 + return 0;
33470 }
33471 }
33472
33473 static struct {
33474 unsigned long address;
33475 unsigned short segment;
33476 -} pci_indirect = { 0, __KERNEL_CS };
33477 +} pci_indirect __read_only = { 0, __PCIBIOS_CS };
33478
33479 -static int pci_bios_present;
33480 +static int pci_bios_present __read_only;
33481
33482 static int check_pcibios(void)
33483 {
33484 @@ -131,11 +174,13 @@ static int check_pcibios(void)
33485 unsigned long flags, pcibios_entry;
33486
33487 if ((pcibios_entry = bios32_service(PCI_SERVICE))) {
33488 - pci_indirect.address = pcibios_entry + PAGE_OFFSET;
33489 + pci_indirect.address = pcibios_entry;
33490
33491 local_irq_save(flags);
33492 - __asm__(
33493 - "lcall *(%%edi); cld\n\t"
33494 + __asm__("movw %w6, %%ds\n\t"
33495 + "lcall *%%ss:(%%edi); cld\n\t"
33496 + "push %%ss\n\t"
33497 + "pop %%ds\n\t"
33498 "jc 1f\n\t"
33499 "xor %%ah, %%ah\n"
33500 "1:"
33501 @@ -144,7 +189,8 @@ static int check_pcibios(void)
33502 "=b" (ebx),
33503 "=c" (ecx)
33504 : "1" (PCIBIOS_PCI_BIOS_PRESENT),
33505 - "D" (&pci_indirect)
33506 + "D" (&pci_indirect),
33507 + "r" (__PCIBIOS_DS)
33508 : "memory");
33509 local_irq_restore(flags);
33510
33511 @@ -189,7 +235,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33512
33513 switch (len) {
33514 case 1:
33515 - __asm__("lcall *(%%esi); cld\n\t"
33516 + __asm__("movw %w6, %%ds\n\t"
33517 + "lcall *%%ss:(%%esi); cld\n\t"
33518 + "push %%ss\n\t"
33519 + "pop %%ds\n\t"
33520 "jc 1f\n\t"
33521 "xor %%ah, %%ah\n"
33522 "1:"
33523 @@ -198,7 +247,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33524 : "1" (PCIBIOS_READ_CONFIG_BYTE),
33525 "b" (bx),
33526 "D" ((long)reg),
33527 - "S" (&pci_indirect));
33528 + "S" (&pci_indirect),
33529 + "r" (__PCIBIOS_DS));
33530 /*
33531 * Zero-extend the result beyond 8 bits, do not trust the
33532 * BIOS having done it:
33533 @@ -206,7 +256,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33534 *value &= 0xff;
33535 break;
33536 case 2:
33537 - __asm__("lcall *(%%esi); cld\n\t"
33538 + __asm__("movw %w6, %%ds\n\t"
33539 + "lcall *%%ss:(%%esi); cld\n\t"
33540 + "push %%ss\n\t"
33541 + "pop %%ds\n\t"
33542 "jc 1f\n\t"
33543 "xor %%ah, %%ah\n"
33544 "1:"
33545 @@ -215,7 +268,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33546 : "1" (PCIBIOS_READ_CONFIG_WORD),
33547 "b" (bx),
33548 "D" ((long)reg),
33549 - "S" (&pci_indirect));
33550 + "S" (&pci_indirect),
33551 + "r" (__PCIBIOS_DS));
33552 /*
33553 * Zero-extend the result beyond 16 bits, do not trust the
33554 * BIOS having done it:
33555 @@ -223,7 +277,10 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33556 *value &= 0xffff;
33557 break;
33558 case 4:
33559 - __asm__("lcall *(%%esi); cld\n\t"
33560 + __asm__("movw %w6, %%ds\n\t"
33561 + "lcall *%%ss:(%%esi); cld\n\t"
33562 + "push %%ss\n\t"
33563 + "pop %%ds\n\t"
33564 "jc 1f\n\t"
33565 "xor %%ah, %%ah\n"
33566 "1:"
33567 @@ -232,7 +289,8 @@ static int pci_bios_read(unsigned int seg, unsigned int bus,
33568 : "1" (PCIBIOS_READ_CONFIG_DWORD),
33569 "b" (bx),
33570 "D" ((long)reg),
33571 - "S" (&pci_indirect));
33572 + "S" (&pci_indirect),
33573 + "r" (__PCIBIOS_DS));
33574 break;
33575 }
33576
33577 @@ -256,7 +314,10 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33578
33579 switch (len) {
33580 case 1:
33581 - __asm__("lcall *(%%esi); cld\n\t"
33582 + __asm__("movw %w6, %%ds\n\t"
33583 + "lcall *%%ss:(%%esi); cld\n\t"
33584 + "push %%ss\n\t"
33585 + "pop %%ds\n\t"
33586 "jc 1f\n\t"
33587 "xor %%ah, %%ah\n"
33588 "1:"
33589 @@ -265,10 +326,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33590 "c" (value),
33591 "b" (bx),
33592 "D" ((long)reg),
33593 - "S" (&pci_indirect));
33594 + "S" (&pci_indirect),
33595 + "r" (__PCIBIOS_DS));
33596 break;
33597 case 2:
33598 - __asm__("lcall *(%%esi); cld\n\t"
33599 + __asm__("movw %w6, %%ds\n\t"
33600 + "lcall *%%ss:(%%esi); cld\n\t"
33601 + "push %%ss\n\t"
33602 + "pop %%ds\n\t"
33603 "jc 1f\n\t"
33604 "xor %%ah, %%ah\n"
33605 "1:"
33606 @@ -277,10 +342,14 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33607 "c" (value),
33608 "b" (bx),
33609 "D" ((long)reg),
33610 - "S" (&pci_indirect));
33611 + "S" (&pci_indirect),
33612 + "r" (__PCIBIOS_DS));
33613 break;
33614 case 4:
33615 - __asm__("lcall *(%%esi); cld\n\t"
33616 + __asm__("movw %w6, %%ds\n\t"
33617 + "lcall *%%ss:(%%esi); cld\n\t"
33618 + "push %%ss\n\t"
33619 + "pop %%ds\n\t"
33620 "jc 1f\n\t"
33621 "xor %%ah, %%ah\n"
33622 "1:"
33623 @@ -289,7 +358,8 @@ static int pci_bios_write(unsigned int seg, unsigned int bus,
33624 "c" (value),
33625 "b" (bx),
33626 "D" ((long)reg),
33627 - "S" (&pci_indirect));
33628 + "S" (&pci_indirect),
33629 + "r" (__PCIBIOS_DS));
33630 break;
33631 }
33632
33633 @@ -394,10 +464,13 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33634
33635 DBG("PCI: Fetching IRQ routing table... ");
33636 __asm__("push %%es\n\t"
33637 + "movw %w8, %%ds\n\t"
33638 "push %%ds\n\t"
33639 "pop %%es\n\t"
33640 - "lcall *(%%esi); cld\n\t"
33641 + "lcall *%%ss:(%%esi); cld\n\t"
33642 "pop %%es\n\t"
33643 + "push %%ss\n\t"
33644 + "pop %%ds\n"
33645 "jc 1f\n\t"
33646 "xor %%ah, %%ah\n"
33647 "1:"
33648 @@ -408,7 +481,8 @@ struct irq_routing_table * pcibios_get_irq_routing_table(void)
33649 "1" (0),
33650 "D" ((long) &opt),
33651 "S" (&pci_indirect),
33652 - "m" (opt)
33653 + "m" (opt),
33654 + "r" (__PCIBIOS_DS)
33655 : "memory");
33656 DBG("OK ret=%d, size=%d, map=%x\n", ret, opt.size, map);
33657 if (ret & 0xff00)
33658 @@ -432,7 +506,10 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33659 {
33660 int ret;
33661
33662 - __asm__("lcall *(%%esi); cld\n\t"
33663 + __asm__("movw %w5, %%ds\n\t"
33664 + "lcall *%%ss:(%%esi); cld\n\t"
33665 + "push %%ss\n\t"
33666 + "pop %%ds\n"
33667 "jc 1f\n\t"
33668 "xor %%ah, %%ah\n"
33669 "1:"
33670 @@ -440,7 +517,8 @@ int pcibios_set_irq_routing(struct pci_dev *dev, int pin, int irq)
33671 : "0" (PCIBIOS_SET_PCI_HW_INT),
33672 "b" ((dev->bus->number << 8) | dev->devfn),
33673 "c" ((irq << 8) | (pin + 10)),
33674 - "S" (&pci_indirect));
33675 + "S" (&pci_indirect),
33676 + "r" (__PCIBIOS_DS));
33677 return !(ret & 0xff00);
33678 }
33679 EXPORT_SYMBOL(pcibios_set_irq_routing);
33680 diff --git a/arch/x86/platform/efi/efi_32.c b/arch/x86/platform/efi/efi_32.c
33681 index 40e4469..d915bf9 100644
33682 --- a/arch/x86/platform/efi/efi_32.c
33683 +++ b/arch/x86/platform/efi/efi_32.c
33684 @@ -44,11 +44,22 @@ void efi_call_phys_prelog(void)
33685 {
33686 struct desc_ptr gdt_descr;
33687
33688 +#ifdef CONFIG_PAX_KERNEXEC
33689 + struct desc_struct d;
33690 +#endif
33691 +
33692 local_irq_save(efi_rt_eflags);
33693
33694 load_cr3(initial_page_table);
33695 __flush_tlb_all();
33696
33697 +#ifdef CONFIG_PAX_KERNEXEC
33698 + pack_descriptor(&d, 0, 0xFFFFF, 0x9B, 0xC);
33699 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33700 + pack_descriptor(&d, 0, 0xFFFFF, 0x93, 0xC);
33701 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33702 +#endif
33703 +
33704 gdt_descr.address = __pa(get_cpu_gdt_table(0));
33705 gdt_descr.size = GDT_SIZE - 1;
33706 load_gdt(&gdt_descr);
33707 @@ -58,11 +69,24 @@ void efi_call_phys_epilog(void)
33708 {
33709 struct desc_ptr gdt_descr;
33710
33711 +#ifdef CONFIG_PAX_KERNEXEC
33712 + struct desc_struct d;
33713 +
33714 + memset(&d, 0, sizeof d);
33715 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_CS, &d, DESCTYPE_S);
33716 + write_gdt_entry(get_cpu_gdt_table(0), GDT_ENTRY_KERNEXEC_EFI_DS, &d, DESCTYPE_S);
33717 +#endif
33718 +
33719 gdt_descr.address = (unsigned long)get_cpu_gdt_table(0);
33720 gdt_descr.size = GDT_SIZE - 1;
33721 load_gdt(&gdt_descr);
33722
33723 +#ifdef CONFIG_PAX_PER_CPU_PGD
33724 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33725 +#else
33726 load_cr3(swapper_pg_dir);
33727 +#endif
33728 +
33729 __flush_tlb_all();
33730
33731 local_irq_restore(efi_rt_eflags);
33732 diff --git a/arch/x86/platform/efi/efi_64.c b/arch/x86/platform/efi/efi_64.c
33733 index 39a0e7f1..872396e 100644
33734 --- a/arch/x86/platform/efi/efi_64.c
33735 +++ b/arch/x86/platform/efi/efi_64.c
33736 @@ -76,6 +76,11 @@ void __init efi_call_phys_prelog(void)
33737 vaddress = (unsigned long)__va(pgd * PGDIR_SIZE);
33738 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), *pgd_offset_k(vaddress));
33739 }
33740 +
33741 +#ifdef CONFIG_PAX_PER_CPU_PGD
33742 + load_cr3(swapper_pg_dir);
33743 +#endif
33744 +
33745 __flush_tlb_all();
33746 }
33747
33748 @@ -89,6 +94,11 @@ void __init efi_call_phys_epilog(void)
33749 for (pgd = 0; pgd < n_pgds; pgd++)
33750 set_pgd(pgd_offset_k(pgd * PGDIR_SIZE), save_pgd[pgd]);
33751 kfree(save_pgd);
33752 +
33753 +#ifdef CONFIG_PAX_PER_CPU_PGD
33754 + load_cr3(get_cpu_pgd(smp_processor_id(), kernel));
33755 +#endif
33756 +
33757 __flush_tlb_all();
33758 local_irq_restore(efi_flags);
33759 early_code_mapping_set_exec(0);
33760 diff --git a/arch/x86/platform/efi/efi_stub_32.S b/arch/x86/platform/efi/efi_stub_32.S
33761 index fbe66e6..eae5e38 100644
33762 --- a/arch/x86/platform/efi/efi_stub_32.S
33763 +++ b/arch/x86/platform/efi/efi_stub_32.S
33764 @@ -6,7 +6,9 @@
33765 */
33766
33767 #include <linux/linkage.h>
33768 +#include <linux/init.h>
33769 #include <asm/page_types.h>
33770 +#include <asm/segment.h>
33771
33772 /*
33773 * efi_call_phys(void *, ...) is a function with variable parameters.
33774 @@ -20,7 +22,7 @@
33775 * service functions will comply with gcc calling convention, too.
33776 */
33777
33778 -.text
33779 +__INIT
33780 ENTRY(efi_call_phys)
33781 /*
33782 * 0. The function can only be called in Linux kernel. So CS has been
33783 @@ -36,10 +38,24 @@ ENTRY(efi_call_phys)
33784 * The mapping of lower virtual memory has been created in prelog and
33785 * epilog.
33786 */
33787 - movl $1f, %edx
33788 - subl $__PAGE_OFFSET, %edx
33789 - jmp *%edx
33790 +#ifdef CONFIG_PAX_KERNEXEC
33791 + movl $(__KERNEXEC_EFI_DS), %edx
33792 + mov %edx, %ds
33793 + mov %edx, %es
33794 + mov %edx, %ss
33795 + addl $2f,(1f)
33796 + ljmp *(1f)
33797 +
33798 +__INITDATA
33799 +1: .long __LOAD_PHYSICAL_ADDR, __KERNEXEC_EFI_CS
33800 +.previous
33801 +
33802 +2:
33803 + subl $2b,(1b)
33804 +#else
33805 + jmp 1f-__PAGE_OFFSET
33806 1:
33807 +#endif
33808
33809 /*
33810 * 2. Now on the top of stack is the return
33811 @@ -47,14 +63,8 @@ ENTRY(efi_call_phys)
33812 * parameter 2, ..., param n. To make things easy, we save the return
33813 * address of efi_call_phys in a global variable.
33814 */
33815 - popl %edx
33816 - movl %edx, saved_return_addr
33817 - /* get the function pointer into ECX*/
33818 - popl %ecx
33819 - movl %ecx, efi_rt_function_ptr
33820 - movl $2f, %edx
33821 - subl $__PAGE_OFFSET, %edx
33822 - pushl %edx
33823 + popl (saved_return_addr)
33824 + popl (efi_rt_function_ptr)
33825
33826 /*
33827 * 3. Clear PG bit in %CR0.
33828 @@ -73,9 +83,8 @@ ENTRY(efi_call_phys)
33829 /*
33830 * 5. Call the physical function.
33831 */
33832 - jmp *%ecx
33833 + call *(efi_rt_function_ptr-__PAGE_OFFSET)
33834
33835 -2:
33836 /*
33837 * 6. After EFI runtime service returns, control will return to
33838 * following instruction. We'd better readjust stack pointer first.
33839 @@ -88,35 +97,36 @@ ENTRY(efi_call_phys)
33840 movl %cr0, %edx
33841 orl $0x80000000, %edx
33842 movl %edx, %cr0
33843 - jmp 1f
33844 -1:
33845 +
33846 /*
33847 * 8. Now restore the virtual mode from flat mode by
33848 * adding EIP with PAGE_OFFSET.
33849 */
33850 - movl $1f, %edx
33851 - jmp *%edx
33852 +#ifdef CONFIG_PAX_KERNEXEC
33853 + movl $(__KERNEL_DS), %edx
33854 + mov %edx, %ds
33855 + mov %edx, %es
33856 + mov %edx, %ss
33857 + ljmp $(__KERNEL_CS),$1f
33858 +#else
33859 + jmp 1f+__PAGE_OFFSET
33860 +#endif
33861 1:
33862
33863 /*
33864 * 9. Balance the stack. And because EAX contain the return value,
33865 * we'd better not clobber it.
33866 */
33867 - leal efi_rt_function_ptr, %edx
33868 - movl (%edx), %ecx
33869 - pushl %ecx
33870 + pushl (efi_rt_function_ptr)
33871
33872 /*
33873 - * 10. Push the saved return address onto the stack and return.
33874 + * 10. Return to the saved return address.
33875 */
33876 - leal saved_return_addr, %edx
33877 - movl (%edx), %ecx
33878 - pushl %ecx
33879 - ret
33880 + jmpl *(saved_return_addr)
33881 ENDPROC(efi_call_phys)
33882 .previous
33883
33884 -.data
33885 +__INITDATA
33886 saved_return_addr:
33887 .long 0
33888 efi_rt_function_ptr:
33889 diff --git a/arch/x86/platform/efi/efi_stub_64.S b/arch/x86/platform/efi/efi_stub_64.S
33890 index 4c07cca..2c8427d 100644
33891 --- a/arch/x86/platform/efi/efi_stub_64.S
33892 +++ b/arch/x86/platform/efi/efi_stub_64.S
33893 @@ -7,6 +7,7 @@
33894 */
33895
33896 #include <linux/linkage.h>
33897 +#include <asm/alternative-asm.h>
33898
33899 #define SAVE_XMM \
33900 mov %rsp, %rax; \
33901 @@ -40,6 +41,7 @@ ENTRY(efi_call0)
33902 call *%rdi
33903 addq $32, %rsp
33904 RESTORE_XMM
33905 + pax_force_retaddr 0, 1
33906 ret
33907 ENDPROC(efi_call0)
33908
33909 @@ -50,6 +52,7 @@ ENTRY(efi_call1)
33910 call *%rdi
33911 addq $32, %rsp
33912 RESTORE_XMM
33913 + pax_force_retaddr 0, 1
33914 ret
33915 ENDPROC(efi_call1)
33916
33917 @@ -60,6 +63,7 @@ ENTRY(efi_call2)
33918 call *%rdi
33919 addq $32, %rsp
33920 RESTORE_XMM
33921 + pax_force_retaddr 0, 1
33922 ret
33923 ENDPROC(efi_call2)
33924
33925 @@ -71,6 +75,7 @@ ENTRY(efi_call3)
33926 call *%rdi
33927 addq $32, %rsp
33928 RESTORE_XMM
33929 + pax_force_retaddr 0, 1
33930 ret
33931 ENDPROC(efi_call3)
33932
33933 @@ -83,6 +88,7 @@ ENTRY(efi_call4)
33934 call *%rdi
33935 addq $32, %rsp
33936 RESTORE_XMM
33937 + pax_force_retaddr 0, 1
33938 ret
33939 ENDPROC(efi_call4)
33940
33941 @@ -96,6 +102,7 @@ ENTRY(efi_call5)
33942 call *%rdi
33943 addq $48, %rsp
33944 RESTORE_XMM
33945 + pax_force_retaddr 0, 1
33946 ret
33947 ENDPROC(efi_call5)
33948
33949 @@ -112,5 +119,6 @@ ENTRY(efi_call6)
33950 call *%rdi
33951 addq $48, %rsp
33952 RESTORE_XMM
33953 + pax_force_retaddr 0, 1
33954 ret
33955 ENDPROC(efi_call6)
33956 diff --git a/arch/x86/platform/mrst/mrst.c b/arch/x86/platform/mrst/mrst.c
33957 index 3ca5957..7909c18 100644
33958 --- a/arch/x86/platform/mrst/mrst.c
33959 +++ b/arch/x86/platform/mrst/mrst.c
33960 @@ -78,13 +78,15 @@ struct sfi_rtc_table_entry sfi_mrtc_array[SFI_MRTC_MAX];
33961 EXPORT_SYMBOL_GPL(sfi_mrtc_array);
33962 int sfi_mrtc_num;
33963
33964 -static void mrst_power_off(void)
33965 +static __noreturn void mrst_power_off(void)
33966 {
33967 + BUG();
33968 }
33969
33970 -static void mrst_reboot(void)
33971 +static __noreturn void mrst_reboot(void)
33972 {
33973 intel_scu_ipc_simple_command(IPCMSG_COLD_BOOT, 0);
33974 + BUG();
33975 }
33976
33977 /* parse all the mtimer info to a static mtimer array */
33978 diff --git a/arch/x86/platform/olpc/olpc_dt.c b/arch/x86/platform/olpc/olpc_dt.c
33979 index d6ee929..3637cb5 100644
33980 --- a/arch/x86/platform/olpc/olpc_dt.c
33981 +++ b/arch/x86/platform/olpc/olpc_dt.c
33982 @@ -156,7 +156,7 @@ void * __init prom_early_alloc(unsigned long size)
33983 return res;
33984 }
33985
33986 -static struct of_pdt_ops prom_olpc_ops __initdata = {
33987 +static struct of_pdt_ops prom_olpc_ops __initconst = {
33988 .nextprop = olpc_dt_nextprop,
33989 .getproplen = olpc_dt_getproplen,
33990 .getproperty = olpc_dt_getproperty,
33991 diff --git a/arch/x86/power/cpu.c b/arch/x86/power/cpu.c
33992 index 424f4c9..f2a2988 100644
33993 --- a/arch/x86/power/cpu.c
33994 +++ b/arch/x86/power/cpu.c
33995 @@ -137,11 +137,8 @@ static void do_fpu_end(void)
33996 static void fix_processor_context(void)
33997 {
33998 int cpu = smp_processor_id();
33999 - struct tss_struct *t = &per_cpu(init_tss, cpu);
34000 -#ifdef CONFIG_X86_64
34001 - struct desc_struct *desc = get_cpu_gdt_table(cpu);
34002 - tss_desc tss;
34003 -#endif
34004 + struct tss_struct *t = init_tss + cpu;
34005 +
34006 set_tss_desc(cpu, t); /*
34007 * This just modifies memory; should not be
34008 * necessary. But... This is necessary, because
34009 @@ -150,10 +147,6 @@ static void fix_processor_context(void)
34010 */
34011
34012 #ifdef CONFIG_X86_64
34013 - memcpy(&tss, &desc[GDT_ENTRY_TSS], sizeof(tss_desc));
34014 - tss.type = 0x9; /* The available 64-bit TSS (see AMD vol 2, pg 91 */
34015 - write_gdt_entry(desc, GDT_ENTRY_TSS, &tss, DESC_TSS);
34016 -
34017 syscall_init(); /* This sets MSR_*STAR and related */
34018 #endif
34019 load_TR_desc(); /* This does ltr */
34020 diff --git a/arch/x86/realmode/init.c b/arch/x86/realmode/init.c
34021 index a44f457..9140171 100644
34022 --- a/arch/x86/realmode/init.c
34023 +++ b/arch/x86/realmode/init.c
34024 @@ -70,7 +70,13 @@ void __init setup_real_mode(void)
34025 __va(real_mode_header->trampoline_header);
34026
34027 #ifdef CONFIG_X86_32
34028 - trampoline_header->start = __pa_symbol(startup_32_smp);
34029 + trampoline_header->start = __pa_symbol(ktla_ktva(startup_32_smp));
34030 +
34031 +#ifdef CONFIG_PAX_KERNEXEC
34032 + trampoline_header->start -= LOAD_PHYSICAL_ADDR;
34033 +#endif
34034 +
34035 + trampoline_header->boot_cs = __BOOT_CS;
34036 trampoline_header->gdt_limit = __BOOT_DS + 7;
34037 trampoline_header->gdt_base = __pa_symbol(boot_gdt);
34038 #else
34039 @@ -86,7 +92,7 @@ void __init setup_real_mode(void)
34040 *trampoline_cr4_features = read_cr4();
34041
34042 trampoline_pgd = (u64 *) __va(real_mode_header->trampoline_pgd);
34043 - trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd;
34044 + trampoline_pgd[0] = init_level4_pgt[pgd_index(__PAGE_OFFSET)].pgd & ~_PAGE_NX;
34045 trampoline_pgd[511] = init_level4_pgt[511].pgd;
34046 #endif
34047 }
34048 diff --git a/arch/x86/realmode/rm/Makefile b/arch/x86/realmode/rm/Makefile
34049 index 9cac825..4890b25 100644
34050 --- a/arch/x86/realmode/rm/Makefile
34051 +++ b/arch/x86/realmode/rm/Makefile
34052 @@ -79,5 +79,8 @@ KBUILD_CFLAGS := $(LINUXINCLUDE) -m32 -g -Os -D_SETUP -D__KERNEL__ -D_WAKEUP \
34053 $(call cc-option, -fno-unit-at-a-time)) \
34054 $(call cc-option, -fno-stack-protector) \
34055 $(call cc-option, -mpreferred-stack-boundary=2)
34056 +ifdef CONSTIFY_PLUGIN
34057 +KBUILD_CFLAGS += -fplugin-arg-constify_plugin-no-constify
34058 +endif
34059 KBUILD_AFLAGS := $(KBUILD_CFLAGS) -D__ASSEMBLY__
34060 GCOV_PROFILE := n
34061 diff --git a/arch/x86/realmode/rm/header.S b/arch/x86/realmode/rm/header.S
34062 index a28221d..93c40f1 100644
34063 --- a/arch/x86/realmode/rm/header.S
34064 +++ b/arch/x86/realmode/rm/header.S
34065 @@ -30,7 +30,9 @@ GLOBAL(real_mode_header)
34066 #endif
34067 /* APM/BIOS reboot */
34068 .long pa_machine_real_restart_asm
34069 -#ifdef CONFIG_X86_64
34070 +#ifdef CONFIG_X86_32
34071 + .long __KERNEL_CS
34072 +#else
34073 .long __KERNEL32_CS
34074 #endif
34075 END(real_mode_header)
34076 diff --git a/arch/x86/realmode/rm/trampoline_32.S b/arch/x86/realmode/rm/trampoline_32.S
34077 index c1b2791..f9e31c7 100644
34078 --- a/arch/x86/realmode/rm/trampoline_32.S
34079 +++ b/arch/x86/realmode/rm/trampoline_32.S
34080 @@ -25,6 +25,12 @@
34081 #include <asm/page_types.h>
34082 #include "realmode.h"
34083
34084 +#ifdef CONFIG_PAX_KERNEXEC
34085 +#define ta(X) (X)
34086 +#else
34087 +#define ta(X) (pa_ ## X)
34088 +#endif
34089 +
34090 .text
34091 .code16
34092
34093 @@ -39,8 +45,6 @@ ENTRY(trampoline_start)
34094
34095 cli # We should be safe anyway
34096
34097 - movl tr_start, %eax # where we need to go
34098 -
34099 movl $0xA5A5A5A5, trampoline_status
34100 # write marker for master knows we're running
34101
34102 @@ -56,7 +60,7 @@ ENTRY(trampoline_start)
34103 movw $1, %dx # protected mode (PE) bit
34104 lmsw %dx # into protected mode
34105
34106 - ljmpl $__BOOT_CS, $pa_startup_32
34107 + ljmpl *(trampoline_header)
34108
34109 .section ".text32","ax"
34110 .code32
34111 @@ -67,7 +71,7 @@ ENTRY(startup_32) # note: also used from wakeup_asm.S
34112 .balign 8
34113 GLOBAL(trampoline_header)
34114 tr_start: .space 4
34115 - tr_gdt_pad: .space 2
34116 + tr_boot_cs: .space 2
34117 tr_gdt: .space 6
34118 END(trampoline_header)
34119
34120 diff --git a/arch/x86/realmode/rm/trampoline_64.S b/arch/x86/realmode/rm/trampoline_64.S
34121 index bb360dc..d0fd8f8 100644
34122 --- a/arch/x86/realmode/rm/trampoline_64.S
34123 +++ b/arch/x86/realmode/rm/trampoline_64.S
34124 @@ -94,6 +94,7 @@ ENTRY(startup_32)
34125 movl %edx, %gs
34126
34127 movl pa_tr_cr4, %eax
34128 + andl $~X86_CR4_PCIDE, %eax
34129 movl %eax, %cr4 # Enable PAE mode
34130
34131 # Setup trampoline 4 level pagetables
34132 @@ -107,7 +108,7 @@ ENTRY(startup_32)
34133 wrmsr
34134
34135 # Enable paging and in turn activate Long Mode
34136 - movl $(X86_CR0_PG | X86_CR0_WP | X86_CR0_PE), %eax
34137 + movl $(X86_CR0_PG | X86_CR0_PE), %eax
34138 movl %eax, %cr0
34139
34140 /*
34141 diff --git a/arch/x86/tools/Makefile b/arch/x86/tools/Makefile
34142 index e812034..c747134 100644
34143 --- a/arch/x86/tools/Makefile
34144 +++ b/arch/x86/tools/Makefile
34145 @@ -37,7 +37,7 @@ $(obj)/test_get_len.o: $(srctree)/arch/x86/lib/insn.c $(srctree)/arch/x86/lib/in
34146
34147 $(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
34148
34149 -HOST_EXTRACFLAGS += -I$(srctree)/tools/include
34150 +HOST_EXTRACFLAGS += -I$(srctree)/tools/include -ggdb
34151 hostprogs-y += relocs
34152 relocs-objs := relocs_32.o relocs_64.o relocs_common.o
34153 relocs: $(obj)/relocs
34154 diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
34155 index f7bab68..b6d9886 100644
34156 --- a/arch/x86/tools/relocs.c
34157 +++ b/arch/x86/tools/relocs.c
34158 @@ -1,5 +1,7 @@
34159 /* This is included from relocs_32/64.c */
34160
34161 +#include "../../../include/generated/autoconf.h"
34162 +
34163 #define ElfW(type) _ElfW(ELF_BITS, type)
34164 #define _ElfW(bits, type) __ElfW(bits, type)
34165 #define __ElfW(bits, type) Elf##bits##_##type
34166 @@ -11,6 +13,7 @@
34167 #define Elf_Sym ElfW(Sym)
34168
34169 static Elf_Ehdr ehdr;
34170 +static Elf_Phdr *phdr;
34171
34172 struct relocs {
34173 uint32_t *offset;
34174 @@ -383,9 +386,39 @@ static void read_ehdr(FILE *fp)
34175 }
34176 }
34177
34178 +static void read_phdrs(FILE *fp)
34179 +{
34180 + unsigned int i;
34181 +
34182 + phdr = calloc(ehdr.e_phnum, sizeof(Elf_Phdr));
34183 + if (!phdr) {
34184 + die("Unable to allocate %d program headers\n",
34185 + ehdr.e_phnum);
34186 + }
34187 + if (fseek(fp, ehdr.e_phoff, SEEK_SET) < 0) {
34188 + die("Seek to %d failed: %s\n",
34189 + ehdr.e_phoff, strerror(errno));
34190 + }
34191 + if (fread(phdr, sizeof(*phdr), ehdr.e_phnum, fp) != ehdr.e_phnum) {
34192 + die("Cannot read ELF program headers: %s\n",
34193 + strerror(errno));
34194 + }
34195 + for(i = 0; i < ehdr.e_phnum; i++) {
34196 + phdr[i].p_type = elf_word_to_cpu(phdr[i].p_type);
34197 + phdr[i].p_offset = elf_off_to_cpu(phdr[i].p_offset);
34198 + phdr[i].p_vaddr = elf_addr_to_cpu(phdr[i].p_vaddr);
34199 + phdr[i].p_paddr = elf_addr_to_cpu(phdr[i].p_paddr);
34200 + phdr[i].p_filesz = elf_word_to_cpu(phdr[i].p_filesz);
34201 + phdr[i].p_memsz = elf_word_to_cpu(phdr[i].p_memsz);
34202 + phdr[i].p_flags = elf_word_to_cpu(phdr[i].p_flags);
34203 + phdr[i].p_align = elf_word_to_cpu(phdr[i].p_align);
34204 + }
34205 +
34206 +}
34207 +
34208 static void read_shdrs(FILE *fp)
34209 {
34210 - int i;
34211 + unsigned int i;
34212 Elf_Shdr shdr;
34213
34214 secs = calloc(ehdr.e_shnum, sizeof(struct section));
34215 @@ -420,7 +453,7 @@ static void read_shdrs(FILE *fp)
34216
34217 static void read_strtabs(FILE *fp)
34218 {
34219 - int i;
34220 + unsigned int i;
34221 for (i = 0; i < ehdr.e_shnum; i++) {
34222 struct section *sec = &secs[i];
34223 if (sec->shdr.sh_type != SHT_STRTAB) {
34224 @@ -445,7 +478,7 @@ static void read_strtabs(FILE *fp)
34225
34226 static void read_symtabs(FILE *fp)
34227 {
34228 - int i,j;
34229 + unsigned int i,j;
34230 for (i = 0; i < ehdr.e_shnum; i++) {
34231 struct section *sec = &secs[i];
34232 if (sec->shdr.sh_type != SHT_SYMTAB) {
34233 @@ -476,9 +509,11 @@ static void read_symtabs(FILE *fp)
34234 }
34235
34236
34237 -static void read_relocs(FILE *fp)
34238 +static void read_relocs(FILE *fp, int use_real_mode)
34239 {
34240 - int i,j;
34241 + unsigned int i,j;
34242 + uint32_t base;
34243 +
34244 for (i = 0; i < ehdr.e_shnum; i++) {
34245 struct section *sec = &secs[i];
34246 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34247 @@ -498,9 +533,22 @@ static void read_relocs(FILE *fp)
34248 die("Cannot read symbol table: %s\n",
34249 strerror(errno));
34250 }
34251 + base = 0;
34252 +
34253 +#ifdef CONFIG_X86_32
34254 + for (j = 0; !use_real_mode && j < ehdr.e_phnum; j++) {
34255 + if (phdr[j].p_type != PT_LOAD )
34256 + continue;
34257 + 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)
34258 + continue;
34259 + base = CONFIG_PAGE_OFFSET + phdr[j].p_paddr - phdr[j].p_vaddr;
34260 + break;
34261 + }
34262 +#endif
34263 +
34264 for (j = 0; j < sec->shdr.sh_size/sizeof(Elf_Rel); j++) {
34265 Elf_Rel *rel = &sec->reltab[j];
34266 - rel->r_offset = elf_addr_to_cpu(rel->r_offset);
34267 + rel->r_offset = elf_addr_to_cpu(rel->r_offset) + base;
34268 rel->r_info = elf_xword_to_cpu(rel->r_info);
34269 #if (SHT_REL_TYPE == SHT_RELA)
34270 rel->r_addend = elf_xword_to_cpu(rel->r_addend);
34271 @@ -512,7 +560,7 @@ static void read_relocs(FILE *fp)
34272
34273 static void print_absolute_symbols(void)
34274 {
34275 - int i;
34276 + unsigned int i;
34277 const char *format;
34278
34279 if (ELF_BITS == 64)
34280 @@ -525,7 +573,7 @@ static void print_absolute_symbols(void)
34281 for (i = 0; i < ehdr.e_shnum; i++) {
34282 struct section *sec = &secs[i];
34283 char *sym_strtab;
34284 - int j;
34285 + unsigned int j;
34286
34287 if (sec->shdr.sh_type != SHT_SYMTAB) {
34288 continue;
34289 @@ -552,7 +600,7 @@ static void print_absolute_symbols(void)
34290
34291 static void print_absolute_relocs(void)
34292 {
34293 - int i, printed = 0;
34294 + unsigned int i, printed = 0;
34295 const char *format;
34296
34297 if (ELF_BITS == 64)
34298 @@ -565,7 +613,7 @@ static void print_absolute_relocs(void)
34299 struct section *sec_applies, *sec_symtab;
34300 char *sym_strtab;
34301 Elf_Sym *sh_symtab;
34302 - int j;
34303 + unsigned int j;
34304 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34305 continue;
34306 }
34307 @@ -642,13 +690,13 @@ static void add_reloc(struct relocs *r, uint32_t offset)
34308 static void walk_relocs(int (*process)(struct section *sec, Elf_Rel *rel,
34309 Elf_Sym *sym, const char *symname))
34310 {
34311 - int i;
34312 + unsigned int i;
34313 /* Walk through the relocations */
34314 for (i = 0; i < ehdr.e_shnum; i++) {
34315 char *sym_strtab;
34316 Elf_Sym *sh_symtab;
34317 struct section *sec_applies, *sec_symtab;
34318 - int j;
34319 + unsigned int j;
34320 struct section *sec = &secs[i];
34321
34322 if (sec->shdr.sh_type != SHT_REL_TYPE) {
34323 @@ -812,6 +860,23 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34324 {
34325 unsigned r_type = ELF32_R_TYPE(rel->r_info);
34326 int shn_abs = (sym->st_shndx == SHN_ABS) && !is_reloc(S_REL, symname);
34327 + char *sym_strtab = sec->link->link->strtab;
34328 +
34329 + /* Don't relocate actual per-cpu variables, they are absolute indices, not addresses */
34330 + if (!strcmp(sec_name(sym->st_shndx), ".data..percpu") && strcmp(sym_name(sym_strtab, sym), "__per_cpu_load"))
34331 + return 0;
34332 +
34333 +#ifdef CONFIG_PAX_KERNEXEC
34334 + /* Don't relocate actual code, they are relocated implicitly by the base address of KERNEL_CS */
34335 + if (!strcmp(sec_name(sym->st_shndx), ".text.end") && !strcmp(sym_name(sym_strtab, sym), "_etext"))
34336 + return 0;
34337 + if (!strcmp(sec_name(sym->st_shndx), ".init.text"))
34338 + return 0;
34339 + if (!strcmp(sec_name(sym->st_shndx), ".exit.text"))
34340 + return 0;
34341 + if (!strcmp(sec_name(sym->st_shndx), ".text") && strcmp(sym_name(sym_strtab, sym), "__LOAD_PHYSICAL_ADDR"))
34342 + return 0;
34343 +#endif
34344
34345 switch (r_type) {
34346 case R_386_NONE:
34347 @@ -950,7 +1015,7 @@ static int write32_as_text(uint32_t v, FILE *f)
34348
34349 static void emit_relocs(int as_text, int use_real_mode)
34350 {
34351 - int i;
34352 + unsigned int i;
34353 int (*write_reloc)(uint32_t, FILE *) = write32;
34354 int (*do_reloc)(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
34355 const char *symname);
34356 @@ -1026,10 +1091,11 @@ void process(FILE *fp, int use_real_mode, int as_text,
34357 {
34358 regex_init(use_real_mode);
34359 read_ehdr(fp);
34360 + read_phdrs(fp);
34361 read_shdrs(fp);
34362 read_strtabs(fp);
34363 read_symtabs(fp);
34364 - read_relocs(fp);
34365 + read_relocs(fp, use_real_mode);
34366 if (ELF_BITS == 64)
34367 percpu_init();
34368 if (show_absolute_syms) {
34369 diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
34370 index 80ffa5b..a33bd15 100644
34371 --- a/arch/x86/um/tls_32.c
34372 +++ b/arch/x86/um/tls_32.c
34373 @@ -260,7 +260,7 @@ out:
34374 if (unlikely(task == current &&
34375 !t->arch.tls_array[idx - GDT_ENTRY_TLS_MIN].flushed)) {
34376 printk(KERN_ERR "get_tls_entry: task with pid %d got here "
34377 - "without flushed TLS.", current->pid);
34378 + "without flushed TLS.", task_pid_nr(current));
34379 }
34380
34381 return 0;
34382 diff --git a/arch/x86/vdso/Makefile b/arch/x86/vdso/Makefile
34383 index fd14be1..e3c79c0 100644
34384 --- a/arch/x86/vdso/Makefile
34385 +++ b/arch/x86/vdso/Makefile
34386 @@ -181,7 +181,7 @@ quiet_cmd_vdso = VDSO $@
34387 -Wl,-T,$(filter %.lds,$^) $(filter %.o,$^) && \
34388 sh $(srctree)/$(src)/checkundef.sh '$(NM)' '$@'
34389
34390 -VDSO_LDFLAGS = -fPIC -shared $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34391 +VDSO_LDFLAGS = -fPIC -shared -Wl,--no-undefined $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)
34392 GCOV_PROFILE := n
34393
34394 #
34395 diff --git a/arch/x86/vdso/vdso32-setup.c b/arch/x86/vdso/vdso32-setup.c
34396 index d6bfb87..876ee18 100644
34397 --- a/arch/x86/vdso/vdso32-setup.c
34398 +++ b/arch/x86/vdso/vdso32-setup.c
34399 @@ -25,6 +25,7 @@
34400 #include <asm/tlbflush.h>
34401 #include <asm/vdso.h>
34402 #include <asm/proto.h>
34403 +#include <asm/mman.h>
34404
34405 enum {
34406 VDSO_DISABLED = 0,
34407 @@ -226,7 +227,7 @@ static inline void map_compat_vdso(int map)
34408 void enable_sep_cpu(void)
34409 {
34410 int cpu = get_cpu();
34411 - struct tss_struct *tss = &per_cpu(init_tss, cpu);
34412 + struct tss_struct *tss = init_tss + cpu;
34413
34414 if (!boot_cpu_has(X86_FEATURE_SEP)) {
34415 put_cpu();
34416 @@ -249,7 +250,7 @@ static int __init gate_vma_init(void)
34417 gate_vma.vm_start = FIXADDR_USER_START;
34418 gate_vma.vm_end = FIXADDR_USER_END;
34419 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
34420 - gate_vma.vm_page_prot = __P101;
34421 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
34422
34423 return 0;
34424 }
34425 @@ -330,14 +331,14 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34426 if (compat)
34427 addr = VDSO_HIGH_BASE;
34428 else {
34429 - addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, 0);
34430 + addr = get_unmapped_area(NULL, 0, PAGE_SIZE, 0, MAP_EXECUTABLE);
34431 if (IS_ERR_VALUE(addr)) {
34432 ret = addr;
34433 goto up_fail;
34434 }
34435 }
34436
34437 - current->mm->context.vdso = (void *)addr;
34438 + current->mm->context.vdso = addr;
34439
34440 if (compat_uses_vma || !compat) {
34441 /*
34442 @@ -353,11 +354,11 @@ int arch_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34443 }
34444
34445 current_thread_info()->sysenter_return =
34446 - VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34447 + (__force void __user *)VDSO32_SYMBOL(addr, SYSENTER_RETURN);
34448
34449 up_fail:
34450 if (ret)
34451 - current->mm->context.vdso = NULL;
34452 + current->mm->context.vdso = 0;
34453
34454 up_write(&mm->mmap_sem);
34455
34456 @@ -404,8 +405,14 @@ __initcall(ia32_binfmt_init);
34457
34458 const char *arch_vma_name(struct vm_area_struct *vma)
34459 {
34460 - if (vma->vm_mm && vma->vm_start == (long)vma->vm_mm->context.vdso)
34461 + if (vma->vm_mm && vma->vm_start == vma->vm_mm->context.vdso)
34462 return "[vdso]";
34463 +
34464 +#ifdef CONFIG_PAX_SEGMEXEC
34465 + if (vma->vm_mm && vma->vm_mirror && vma->vm_mirror->vm_start == vma->vm_mm->context.vdso)
34466 + return "[vdso]";
34467 +#endif
34468 +
34469 return NULL;
34470 }
34471
34472 @@ -415,7 +422,7 @@ struct vm_area_struct *get_gate_vma(struct mm_struct *mm)
34473 * Check to see if the corresponding task was created in compat vdso
34474 * mode.
34475 */
34476 - if (mm && mm->context.vdso == (void *)VDSO_HIGH_BASE)
34477 + if (mm && mm->context.vdso == VDSO_HIGH_BASE)
34478 return &gate_vma;
34479 return NULL;
34480 }
34481 diff --git a/arch/x86/vdso/vma.c b/arch/x86/vdso/vma.c
34482 index 431e875..cbb23f3 100644
34483 --- a/arch/x86/vdso/vma.c
34484 +++ b/arch/x86/vdso/vma.c
34485 @@ -16,8 +16,6 @@
34486 #include <asm/vdso.h>
34487 #include <asm/page.h>
34488
34489 -unsigned int __read_mostly vdso_enabled = 1;
34490 -
34491 extern char vdso_start[], vdso_end[];
34492 extern unsigned short vdso_sync_cpuid;
34493
34494 @@ -141,7 +139,6 @@ static unsigned long vdso_addr(unsigned long start, unsigned len)
34495 * unaligned here as a result of stack start randomization.
34496 */
34497 addr = PAGE_ALIGN(addr);
34498 - addr = align_vdso_addr(addr);
34499
34500 return addr;
34501 }
34502 @@ -154,30 +151,31 @@ static int setup_additional_pages(struct linux_binprm *bprm,
34503 unsigned size)
34504 {
34505 struct mm_struct *mm = current->mm;
34506 - unsigned long addr;
34507 + unsigned long addr = 0;
34508 int ret;
34509
34510 - if (!vdso_enabled)
34511 - return 0;
34512 -
34513 down_write(&mm->mmap_sem);
34514 +
34515 +#ifdef CONFIG_PAX_RANDMMAP
34516 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
34517 +#endif
34518 +
34519 addr = vdso_addr(mm->start_stack, size);
34520 + addr = align_vdso_addr(addr);
34521 addr = get_unmapped_area(NULL, addr, size, 0, 0);
34522 if (IS_ERR_VALUE(addr)) {
34523 ret = addr;
34524 goto up_fail;
34525 }
34526
34527 - current->mm->context.vdso = (void *)addr;
34528 + mm->context.vdso = addr;
34529
34530 ret = install_special_mapping(mm, addr, size,
34531 VM_READ|VM_EXEC|
34532 VM_MAYREAD|VM_MAYWRITE|VM_MAYEXEC,
34533 pages);
34534 - if (ret) {
34535 - current->mm->context.vdso = NULL;
34536 - goto up_fail;
34537 - }
34538 + if (ret)
34539 + mm->context.vdso = 0;
34540
34541 up_fail:
34542 up_write(&mm->mmap_sem);
34543 @@ -197,10 +195,3 @@ int x32_setup_additional_pages(struct linux_binprm *bprm, int uses_interp)
34544 vdsox32_size);
34545 }
34546 #endif
34547 -
34548 -static __init int vdso_setup(char *s)
34549 -{
34550 - vdso_enabled = simple_strtoul(s, NULL, 0);
34551 - return 0;
34552 -}
34553 -__setup("vdso=", vdso_setup);
34554 diff --git a/arch/x86/xen/enlighten.c b/arch/x86/xen/enlighten.c
34555 index fa6ade7..73da73a5 100644
34556 --- a/arch/x86/xen/enlighten.c
34557 +++ b/arch/x86/xen/enlighten.c
34558 @@ -123,8 +123,6 @@ EXPORT_SYMBOL_GPL(xen_start_info);
34559
34560 struct shared_info xen_dummy_shared_info;
34561
34562 -void *xen_initial_gdt;
34563 -
34564 RESERVE_BRK(shared_info_page_brk, PAGE_SIZE);
34565 __read_mostly int xen_have_vector_callback;
34566 EXPORT_SYMBOL_GPL(xen_have_vector_callback);
34567 @@ -541,8 +539,7 @@ static void xen_load_gdt(const struct desc_ptr *dtr)
34568 {
34569 unsigned long va = dtr->address;
34570 unsigned int size = dtr->size + 1;
34571 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34572 - unsigned long frames[pages];
34573 + unsigned long frames[65536 / PAGE_SIZE];
34574 int f;
34575
34576 /*
34577 @@ -590,8 +587,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34578 {
34579 unsigned long va = dtr->address;
34580 unsigned int size = dtr->size + 1;
34581 - unsigned pages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
34582 - unsigned long frames[pages];
34583 + unsigned long frames[(GDT_SIZE + PAGE_SIZE - 1) / PAGE_SIZE];
34584 int f;
34585
34586 /*
34587 @@ -599,7 +595,7 @@ static void __init xen_load_gdt_boot(const struct desc_ptr *dtr)
34588 * 8-byte entries, or 16 4k pages..
34589 */
34590
34591 - BUG_ON(size > 65536);
34592 + BUG_ON(size > GDT_SIZE);
34593 BUG_ON(va & ~PAGE_MASK);
34594
34595 for (f = 0; va < dtr->address + size; va += PAGE_SIZE, f++) {
34596 @@ -988,7 +984,7 @@ static u32 xen_safe_apic_wait_icr_idle(void)
34597 return 0;
34598 }
34599
34600 -static void set_xen_basic_apic_ops(void)
34601 +static void __init set_xen_basic_apic_ops(void)
34602 {
34603 apic->read = xen_apic_read;
34604 apic->write = xen_apic_write;
34605 @@ -1293,30 +1289,30 @@ static const struct pv_apic_ops xen_apic_ops __initconst = {
34606 #endif
34607 };
34608
34609 -static void xen_reboot(int reason)
34610 +static __noreturn void xen_reboot(int reason)
34611 {
34612 struct sched_shutdown r = { .reason = reason };
34613
34614 - if (HYPERVISOR_sched_op(SCHEDOP_shutdown, &r))
34615 - BUG();
34616 + HYPERVISOR_sched_op(SCHEDOP_shutdown, &r);
34617 + BUG();
34618 }
34619
34620 -static void xen_restart(char *msg)
34621 +static __noreturn void xen_restart(char *msg)
34622 {
34623 xen_reboot(SHUTDOWN_reboot);
34624 }
34625
34626 -static void xen_emergency_restart(void)
34627 +static __noreturn void xen_emergency_restart(void)
34628 {
34629 xen_reboot(SHUTDOWN_reboot);
34630 }
34631
34632 -static void xen_machine_halt(void)
34633 +static __noreturn void xen_machine_halt(void)
34634 {
34635 xen_reboot(SHUTDOWN_poweroff);
34636 }
34637
34638 -static void xen_machine_power_off(void)
34639 +static __noreturn void xen_machine_power_off(void)
34640 {
34641 if (pm_power_off)
34642 pm_power_off();
34643 @@ -1467,7 +1463,17 @@ asmlinkage void __init xen_start_kernel(void)
34644 __userpte_alloc_gfp &= ~__GFP_HIGHMEM;
34645
34646 /* Work out if we support NX */
34647 - x86_configure_nx();
34648 +#if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
34649 + if ((cpuid_eax(0x80000000) & 0xffff0000) == 0x80000000 &&
34650 + (cpuid_edx(0x80000001) & (1U << (X86_FEATURE_NX & 31)))) {
34651 + unsigned l, h;
34652 +
34653 + __supported_pte_mask |= _PAGE_NX;
34654 + rdmsr(MSR_EFER, l, h);
34655 + l |= EFER_NX;
34656 + wrmsr(MSR_EFER, l, h);
34657 + }
34658 +#endif
34659
34660 xen_setup_features();
34661
34662 @@ -1498,13 +1504,6 @@ asmlinkage void __init xen_start_kernel(void)
34663
34664 machine_ops = xen_machine_ops;
34665
34666 - /*
34667 - * The only reliable way to retain the initial address of the
34668 - * percpu gdt_page is to remember it here, so we can go and
34669 - * mark it RW later, when the initial percpu area is freed.
34670 - */
34671 - xen_initial_gdt = &per_cpu(gdt_page, 0);
34672 -
34673 xen_smp_init();
34674
34675 #ifdef CONFIG_ACPI_NUMA
34676 diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
34677 index fdc3ba2..23cae00 100644
34678 --- a/arch/x86/xen/mmu.c
34679 +++ b/arch/x86/xen/mmu.c
34680 @@ -379,7 +379,7 @@ static pteval_t pte_mfn_to_pfn(pteval_t val)
34681 return val;
34682 }
34683
34684 -static pteval_t pte_pfn_to_mfn(pteval_t val)
34685 +static pteval_t __intentional_overflow(-1) pte_pfn_to_mfn(pteval_t val)
34686 {
34687 if (val & _PAGE_PRESENT) {
34688 unsigned long pfn = (val & PTE_PFN_MASK) >> PAGE_SHIFT;
34689 @@ -1894,6 +1894,9 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34690 /* L3_k[510] -> level2_kernel_pgt
34691 * L3_i[511] -> level2_fixmap_pgt */
34692 convert_pfn_mfn(level3_kernel_pgt);
34693 + convert_pfn_mfn(level3_vmalloc_start_pgt);
34694 + convert_pfn_mfn(level3_vmalloc_end_pgt);
34695 + convert_pfn_mfn(level3_vmemmap_pgt);
34696
34697 /* We get [511][511] and have Xen's version of level2_kernel_pgt */
34698 l3 = m2v(pgd[pgd_index(__START_KERNEL_map)].pgd);
34699 @@ -1923,8 +1926,12 @@ void __init xen_setup_kernel_pagetable(pgd_t *pgd, unsigned long max_pfn)
34700 set_page_prot(init_level4_pgt, PAGE_KERNEL_RO);
34701 set_page_prot(level3_ident_pgt, PAGE_KERNEL_RO);
34702 set_page_prot(level3_kernel_pgt, PAGE_KERNEL_RO);
34703 + set_page_prot(level3_vmalloc_start_pgt, PAGE_KERNEL_RO);
34704 + set_page_prot(level3_vmalloc_end_pgt, PAGE_KERNEL_RO);
34705 + set_page_prot(level3_vmemmap_pgt, PAGE_KERNEL_RO);
34706 set_page_prot(level3_user_vsyscall, PAGE_KERNEL_RO);
34707 set_page_prot(level2_ident_pgt, PAGE_KERNEL_RO);
34708 + set_page_prot(level2_vmemmap_pgt, PAGE_KERNEL_RO);
34709 set_page_prot(level2_kernel_pgt, PAGE_KERNEL_RO);
34710 set_page_prot(level2_fixmap_pgt, PAGE_KERNEL_RO);
34711
34712 @@ -2108,6 +2115,7 @@ static void __init xen_post_allocator_init(void)
34713 pv_mmu_ops.set_pud = xen_set_pud;
34714 #if PAGETABLE_LEVELS == 4
34715 pv_mmu_ops.set_pgd = xen_set_pgd;
34716 + pv_mmu_ops.set_pgd_batched = xen_set_pgd;
34717 #endif
34718
34719 /* This will work as long as patching hasn't happened yet
34720 @@ -2186,6 +2194,7 @@ static const struct pv_mmu_ops xen_mmu_ops __initconst = {
34721 .pud_val = PV_CALLEE_SAVE(xen_pud_val),
34722 .make_pud = PV_CALLEE_SAVE(xen_make_pud),
34723 .set_pgd = xen_set_pgd_hyper,
34724 + .set_pgd_batched = xen_set_pgd_hyper,
34725
34726 .alloc_pud = xen_alloc_pmd_init,
34727 .release_pud = xen_release_pmd_init,
34728 diff --git a/arch/x86/xen/smp.c b/arch/x86/xen/smp.c
34729 index 31d0475..51af671 100644
34730 --- a/arch/x86/xen/smp.c
34731 +++ b/arch/x86/xen/smp.c
34732 @@ -274,17 +274,13 @@ static void __init xen_smp_prepare_boot_cpu(void)
34733 native_smp_prepare_boot_cpu();
34734
34735 if (xen_pv_domain()) {
34736 - /* We've switched to the "real" per-cpu gdt, so make sure the
34737 - old memory can be recycled */
34738 - make_lowmem_page_readwrite(xen_initial_gdt);
34739 -
34740 #ifdef CONFIG_X86_32
34741 /*
34742 * Xen starts us with XEN_FLAT_RING1_DS, but linux code
34743 * expects __USER_DS
34744 */
34745 - loadsegment(ds, __USER_DS);
34746 - loadsegment(es, __USER_DS);
34747 + loadsegment(ds, __KERNEL_DS);
34748 + loadsegment(es, __KERNEL_DS);
34749 #endif
34750
34751 xen_filter_cpu_maps();
34752 @@ -364,7 +360,7 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34753 ctxt->user_regs.ss = __KERNEL_DS;
34754 #ifdef CONFIG_X86_32
34755 ctxt->user_regs.fs = __KERNEL_PERCPU;
34756 - ctxt->user_regs.gs = __KERNEL_STACK_CANARY;
34757 + savesegment(gs, ctxt->user_regs.gs);
34758 #else
34759 ctxt->gs_base_kernel = per_cpu_offset(cpu);
34760 #endif
34761 @@ -374,8 +370,8 @@ cpu_initialize_context(unsigned int cpu, struct task_struct *idle)
34762
34763 {
34764 ctxt->user_regs.eflags = 0x1000; /* IOPL_RING1 */
34765 - ctxt->user_regs.ds = __USER_DS;
34766 - ctxt->user_regs.es = __USER_DS;
34767 + ctxt->user_regs.ds = __KERNEL_DS;
34768 + ctxt->user_regs.es = __KERNEL_DS;
34769
34770 xen_copy_trap_info(ctxt->trap_ctxt);
34771
34772 @@ -420,13 +416,12 @@ static int xen_cpu_up(unsigned int cpu, struct task_struct *idle)
34773 int rc;
34774
34775 per_cpu(current_task, cpu) = idle;
34776 + per_cpu(current_tinfo, cpu) = &idle->tinfo;
34777 #ifdef CONFIG_X86_32
34778 irq_ctx_init(cpu);
34779 #else
34780 clear_tsk_thread_flag(idle, TIF_FORK);
34781 - per_cpu(kernel_stack, cpu) =
34782 - (unsigned long)task_stack_page(idle) -
34783 - KERNEL_STACK_OFFSET + THREAD_SIZE;
34784 + per_cpu(kernel_stack, cpu) = (unsigned long)task_stack_page(idle) - 16 + THREAD_SIZE;
34785 #endif
34786 xen_setup_runstate_info(cpu);
34787 xen_setup_timer(cpu);
34788 @@ -702,7 +697,7 @@ static const struct smp_ops xen_smp_ops __initconst = {
34789
34790 void __init xen_smp_init(void)
34791 {
34792 - smp_ops = xen_smp_ops;
34793 + memcpy((void *)&smp_ops, &xen_smp_ops, sizeof smp_ops);
34794 xen_fill_possible_map();
34795 }
34796
34797 diff --git a/arch/x86/xen/xen-asm_32.S b/arch/x86/xen/xen-asm_32.S
34798 index 33ca6e4..0ded929 100644
34799 --- a/arch/x86/xen/xen-asm_32.S
34800 +++ b/arch/x86/xen/xen-asm_32.S
34801 @@ -84,14 +84,14 @@ ENTRY(xen_iret)
34802 ESP_OFFSET=4 # bytes pushed onto stack
34803
34804 /*
34805 - * Store vcpu_info pointer for easy access. Do it this way to
34806 - * avoid having to reload %fs
34807 + * Store vcpu_info pointer for easy access.
34808 */
34809 #ifdef CONFIG_SMP
34810 - GET_THREAD_INFO(%eax)
34811 - movl %ss:TI_cpu(%eax), %eax
34812 - movl %ss:__per_cpu_offset(,%eax,4), %eax
34813 - mov %ss:xen_vcpu(%eax), %eax
34814 + push %fs
34815 + mov $(__KERNEL_PERCPU), %eax
34816 + mov %eax, %fs
34817 + mov PER_CPU_VAR(xen_vcpu), %eax
34818 + pop %fs
34819 #else
34820 movl %ss:xen_vcpu, %eax
34821 #endif
34822 diff --git a/arch/x86/xen/xen-head.S b/arch/x86/xen/xen-head.S
34823 index 7faed58..ba4427c 100644
34824 --- a/arch/x86/xen/xen-head.S
34825 +++ b/arch/x86/xen/xen-head.S
34826 @@ -19,6 +19,17 @@ ENTRY(startup_xen)
34827 #ifdef CONFIG_X86_32
34828 mov %esi,xen_start_info
34829 mov $init_thread_union+THREAD_SIZE,%esp
34830 +#ifdef CONFIG_SMP
34831 + movl $cpu_gdt_table,%edi
34832 + movl $__per_cpu_load,%eax
34833 + movw %ax,__KERNEL_PERCPU + 2(%edi)
34834 + rorl $16,%eax
34835 + movb %al,__KERNEL_PERCPU + 4(%edi)
34836 + movb %ah,__KERNEL_PERCPU + 7(%edi)
34837 + movl $__per_cpu_end - 1,%eax
34838 + subl $__per_cpu_start,%eax
34839 + movw %ax,__KERNEL_PERCPU + 0(%edi)
34840 +#endif
34841 #else
34842 mov %rsi,xen_start_info
34843 mov $init_thread_union+THREAD_SIZE,%rsp
34844 diff --git a/arch/x86/xen/xen-ops.h b/arch/x86/xen/xen-ops.h
34845 index 95f8c61..611d6e8 100644
34846 --- a/arch/x86/xen/xen-ops.h
34847 +++ b/arch/x86/xen/xen-ops.h
34848 @@ -10,8 +10,6 @@
34849 extern const char xen_hypervisor_callback[];
34850 extern const char xen_failsafe_callback[];
34851
34852 -extern void *xen_initial_gdt;
34853 -
34854 struct trap_info;
34855 void xen_copy_trap_info(struct trap_info *traps);
34856
34857 diff --git a/arch/xtensa/variants/dc232b/include/variant/core.h b/arch/xtensa/variants/dc232b/include/variant/core.h
34858 index 525bd3d..ef888b1 100644
34859 --- a/arch/xtensa/variants/dc232b/include/variant/core.h
34860 +++ b/arch/xtensa/variants/dc232b/include/variant/core.h
34861 @@ -119,9 +119,9 @@
34862 ----------------------------------------------------------------------*/
34863
34864 #define XCHAL_ICACHE_LINESIZE 32 /* I-cache line size in bytes */
34865 -#define XCHAL_DCACHE_LINESIZE 32 /* D-cache line size in bytes */
34866 #define XCHAL_ICACHE_LINEWIDTH 5 /* log2(I line size in bytes) */
34867 #define XCHAL_DCACHE_LINEWIDTH 5 /* log2(D line size in bytes) */
34868 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34869
34870 #define XCHAL_ICACHE_SIZE 16384 /* I-cache size in bytes or 0 */
34871 #define XCHAL_DCACHE_SIZE 16384 /* D-cache size in bytes or 0 */
34872 diff --git a/arch/xtensa/variants/fsf/include/variant/core.h b/arch/xtensa/variants/fsf/include/variant/core.h
34873 index 2f33760..835e50a 100644
34874 --- a/arch/xtensa/variants/fsf/include/variant/core.h
34875 +++ b/arch/xtensa/variants/fsf/include/variant/core.h
34876 @@ -11,6 +11,7 @@
34877 #ifndef _XTENSA_CORE_H
34878 #define _XTENSA_CORE_H
34879
34880 +#include <linux/const.h>
34881
34882 /****************************************************************************
34883 Parameters Useful for Any Code, USER or PRIVILEGED
34884 @@ -112,9 +113,9 @@
34885 ----------------------------------------------------------------------*/
34886
34887 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34888 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34889 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34890 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34891 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34892
34893 #define XCHAL_ICACHE_SIZE 8192 /* I-cache size in bytes or 0 */
34894 #define XCHAL_DCACHE_SIZE 8192 /* D-cache size in bytes or 0 */
34895 diff --git a/arch/xtensa/variants/s6000/include/variant/core.h b/arch/xtensa/variants/s6000/include/variant/core.h
34896 index af00795..2bb8105 100644
34897 --- a/arch/xtensa/variants/s6000/include/variant/core.h
34898 +++ b/arch/xtensa/variants/s6000/include/variant/core.h
34899 @@ -11,6 +11,7 @@
34900 #ifndef _XTENSA_CORE_CONFIGURATION_H
34901 #define _XTENSA_CORE_CONFIGURATION_H
34902
34903 +#include <linux/const.h>
34904
34905 /****************************************************************************
34906 Parameters Useful for Any Code, USER or PRIVILEGED
34907 @@ -118,9 +119,9 @@
34908 ----------------------------------------------------------------------*/
34909
34910 #define XCHAL_ICACHE_LINESIZE 16 /* I-cache line size in bytes */
34911 -#define XCHAL_DCACHE_LINESIZE 16 /* D-cache line size in bytes */
34912 #define XCHAL_ICACHE_LINEWIDTH 4 /* log2(I line size in bytes) */
34913 #define XCHAL_DCACHE_LINEWIDTH 4 /* log2(D line size in bytes) */
34914 +#define XCHAL_DCACHE_LINESIZE (_AC(1,UL) << XCHAL_DCACHE_LINEWIDTH) /* D-cache line size in bytes */
34915
34916 #define XCHAL_ICACHE_SIZE 32768 /* I-cache size in bytes or 0 */
34917 #define XCHAL_DCACHE_SIZE 32768 /* D-cache size in bytes or 0 */
34918 diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
34919 index 4e491d9..c8e18e4 100644
34920 --- a/block/blk-cgroup.c
34921 +++ b/block/blk-cgroup.c
34922 @@ -812,7 +812,7 @@ static void blkcg_css_free(struct cgroup_subsys_state *css)
34923 static struct cgroup_subsys_state *
34924 blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34925 {
34926 - static atomic64_t id_seq = ATOMIC64_INIT(0);
34927 + static atomic64_unchecked_t id_seq = ATOMIC64_INIT(0);
34928 struct blkcg *blkcg;
34929
34930 if (!parent_css) {
34931 @@ -826,7 +826,7 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
34932
34933 blkcg->cfq_weight = CFQ_WEIGHT_DEFAULT;
34934 blkcg->cfq_leaf_weight = CFQ_WEIGHT_DEFAULT;
34935 - blkcg->id = atomic64_inc_return(&id_seq); /* root is 0, start from 1 */
34936 + blkcg->id = atomic64_inc_return_unchecked(&id_seq); /* root is 0, start from 1 */
34937 done:
34938 spin_lock_init(&blkcg->lock);
34939 INIT_RADIX_TREE(&blkcg->blkg_tree, GFP_ATOMIC);
34940 diff --git a/block/blk-iopoll.c b/block/blk-iopoll.c
34941 index 4b8d9b54..a7178c0 100644
34942 --- a/block/blk-iopoll.c
34943 +++ b/block/blk-iopoll.c
34944 @@ -77,7 +77,7 @@ void blk_iopoll_complete(struct blk_iopoll *iopoll)
34945 }
34946 EXPORT_SYMBOL(blk_iopoll_complete);
34947
34948 -static void blk_iopoll_softirq(struct softirq_action *h)
34949 +static __latent_entropy void blk_iopoll_softirq(void)
34950 {
34951 struct list_head *list = &__get_cpu_var(blk_cpu_iopoll);
34952 int rearm = 0, budget = blk_iopoll_budget;
34953 diff --git a/block/blk-map.c b/block/blk-map.c
34954 index 623e1cd..ca1e109 100644
34955 --- a/block/blk-map.c
34956 +++ b/block/blk-map.c
34957 @@ -302,7 +302,7 @@ int blk_rq_map_kern(struct request_queue *q, struct request *rq, void *kbuf,
34958 if (!len || !kbuf)
34959 return -EINVAL;
34960
34961 - do_copy = !blk_rq_aligned(q, addr, len) || object_is_on_stack(kbuf);
34962 + do_copy = !blk_rq_aligned(q, addr, len) || object_starts_on_stack(kbuf);
34963 if (do_copy)
34964 bio = bio_copy_kern(q, kbuf, len, gfp_mask, reading);
34965 else
34966 diff --git a/block/blk-softirq.c b/block/blk-softirq.c
34967 index ec9e606..3f38839 100644
34968 --- a/block/blk-softirq.c
34969 +++ b/block/blk-softirq.c
34970 @@ -18,7 +18,7 @@ static DEFINE_PER_CPU(struct list_head, blk_cpu_done);
34971 * Softirq action handler - move entries to local list and loop over them
34972 * while passing them to the queue registered handler.
34973 */
34974 -static void blk_done_softirq(struct softirq_action *h)
34975 +static __latent_entropy void blk_done_softirq(void)
34976 {
34977 struct list_head *cpu_list, local_list;
34978
34979 diff --git a/block/bsg.c b/block/bsg.c
34980 index 420a5a9..23834aa 100644
34981 --- a/block/bsg.c
34982 +++ b/block/bsg.c
34983 @@ -176,16 +176,24 @@ static int blk_fill_sgv4_hdr_rq(struct request_queue *q, struct request *rq,
34984 struct sg_io_v4 *hdr, struct bsg_device *bd,
34985 fmode_t has_write_perm)
34986 {
34987 + unsigned char tmpcmd[sizeof(rq->__cmd)];
34988 + unsigned char *cmdptr;
34989 +
34990 if (hdr->request_len > BLK_MAX_CDB) {
34991 rq->cmd = kzalloc(hdr->request_len, GFP_KERNEL);
34992 if (!rq->cmd)
34993 return -ENOMEM;
34994 - }
34995 + cmdptr = rq->cmd;
34996 + } else
34997 + cmdptr = tmpcmd;
34998
34999 - if (copy_from_user(rq->cmd, (void __user *)(unsigned long)hdr->request,
35000 + if (copy_from_user(cmdptr, (void __user *)(unsigned long)hdr->request,
35001 hdr->request_len))
35002 return -EFAULT;
35003
35004 + if (cmdptr != rq->cmd)
35005 + memcpy(rq->cmd, cmdptr, hdr->request_len);
35006 +
35007 if (hdr->subprotocol == BSG_SUB_PROTOCOL_SCSI_CMD) {
35008 if (blk_verify_command(rq->cmd, has_write_perm))
35009 return -EPERM;
35010 diff --git a/block/compat_ioctl.c b/block/compat_ioctl.c
35011 index fbd5a67..5d631b5 100644
35012 --- a/block/compat_ioctl.c
35013 +++ b/block/compat_ioctl.c
35014 @@ -341,7 +341,7 @@ static int compat_fd_ioctl(struct block_device *bdev, fmode_t mode,
35015 err |= __get_user(f->spec1, &uf->spec1);
35016 err |= __get_user(f->fmt_gap, &uf->fmt_gap);
35017 err |= __get_user(name, &uf->name);
35018 - f->name = compat_ptr(name);
35019 + f->name = (void __force_kernel *)compat_ptr(name);
35020 if (err) {
35021 err = -EFAULT;
35022 goto out;
35023 diff --git a/block/genhd.c b/block/genhd.c
35024 index 791f419..89f21c4 100644
35025 --- a/block/genhd.c
35026 +++ b/block/genhd.c
35027 @@ -467,21 +467,24 @@ static char *bdevt_str(dev_t devt, char *buf)
35028
35029 /*
35030 * Register device numbers dev..(dev+range-1)
35031 - * range must be nonzero
35032 + * Noop if @range is zero.
35033 * The hash chain is sorted on range, so that subranges can override.
35034 */
35035 void blk_register_region(dev_t devt, unsigned long range, struct module *module,
35036 struct kobject *(*probe)(dev_t, int *, void *),
35037 int (*lock)(dev_t, void *), void *data)
35038 {
35039 - kobj_map(bdev_map, devt, range, module, probe, lock, data);
35040 + if (range)
35041 + kobj_map(bdev_map, devt, range, module, probe, lock, data);
35042 }
35043
35044 EXPORT_SYMBOL(blk_register_region);
35045
35046 +/* undo blk_register_region(), noop if @range is zero */
35047 void blk_unregister_region(dev_t devt, unsigned long range)
35048 {
35049 - kobj_unmap(bdev_map, devt, range);
35050 + if (range)
35051 + kobj_unmap(bdev_map, devt, range);
35052 }
35053
35054 EXPORT_SYMBOL(blk_unregister_region);
35055 diff --git a/block/partitions/efi.c b/block/partitions/efi.c
35056 index a8287b4..241a48e 100644
35057 --- a/block/partitions/efi.c
35058 +++ b/block/partitions/efi.c
35059 @@ -292,14 +292,14 @@ static gpt_entry *alloc_read_gpt_entries(struct parsed_partitions *state,
35060 if (!gpt)
35061 return NULL;
35062
35063 + if (!le32_to_cpu(gpt->num_partition_entries))
35064 + return NULL;
35065 + pte = kcalloc(le32_to_cpu(gpt->num_partition_entries), le32_to_cpu(gpt->sizeof_partition_entry), GFP_KERNEL);
35066 + if (!pte)
35067 + return NULL;
35068 +
35069 count = le32_to_cpu(gpt->num_partition_entries) *
35070 le32_to_cpu(gpt->sizeof_partition_entry);
35071 - if (!count)
35072 - return NULL;
35073 - pte = kmalloc(count, GFP_KERNEL);
35074 - if (!pte)
35075 - return NULL;
35076 -
35077 if (read_lba(state, le64_to_cpu(gpt->partition_entry_lba),
35078 (u8 *) pte, count) < count) {
35079 kfree(pte);
35080 diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
35081 index a5ffcc9..e057498 100644
35082 --- a/block/scsi_ioctl.c
35083 +++ b/block/scsi_ioctl.c
35084 @@ -67,7 +67,7 @@ static int scsi_get_bus(struct request_queue *q, int __user *p)
35085 return put_user(0, p);
35086 }
35087
35088 -static int sg_get_timeout(struct request_queue *q)
35089 +static int __intentional_overflow(-1) sg_get_timeout(struct request_queue *q)
35090 {
35091 return jiffies_to_clock_t(q->sg_timeout);
35092 }
35093 @@ -224,8 +224,20 @@ EXPORT_SYMBOL(blk_verify_command);
35094 static int blk_fill_sghdr_rq(struct request_queue *q, struct request *rq,
35095 struct sg_io_hdr *hdr, fmode_t mode)
35096 {
35097 - if (copy_from_user(rq->cmd, hdr->cmdp, hdr->cmd_len))
35098 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35099 + unsigned char *cmdptr;
35100 +
35101 + if (rq->cmd != rq->__cmd)
35102 + cmdptr = rq->cmd;
35103 + else
35104 + cmdptr = tmpcmd;
35105 +
35106 + if (copy_from_user(cmdptr, hdr->cmdp, hdr->cmd_len))
35107 return -EFAULT;
35108 +
35109 + if (cmdptr != rq->cmd)
35110 + memcpy(rq->cmd, cmdptr, hdr->cmd_len);
35111 +
35112 if (blk_verify_command(rq->cmd, mode & FMODE_WRITE))
35113 return -EPERM;
35114
35115 @@ -434,6 +446,8 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
35116 int err;
35117 unsigned int in_len, out_len, bytes, opcode, cmdlen;
35118 char *buffer = NULL, sense[SCSI_SENSE_BUFFERSIZE];
35119 + unsigned char tmpcmd[sizeof(rq->__cmd)];
35120 + unsigned char *cmdptr;
35121
35122 if (!sic)
35123 return -EINVAL;
35124 @@ -467,9 +481,18 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,
35125 */
35126 err = -EFAULT;
35127 rq->cmd_len = cmdlen;
35128 - if (copy_from_user(rq->cmd, sic->data, cmdlen))
35129 +
35130 + if (rq->cmd != rq->__cmd)
35131 + cmdptr = rq->cmd;
35132 + else
35133 + cmdptr = tmpcmd;
35134 +
35135 + if (copy_from_user(cmdptr, sic->data, cmdlen))
35136 goto error;
35137
35138 + if (rq->cmd != cmdptr)
35139 + memcpy(rq->cmd, cmdptr, cmdlen);
35140 +
35141 if (in_len && copy_from_user(buffer, sic->data + cmdlen, in_len))
35142 goto error;
35143
35144 diff --git a/crypto/cryptd.c b/crypto/cryptd.c
35145 index 7bdd61b..afec999 100644
35146 --- a/crypto/cryptd.c
35147 +++ b/crypto/cryptd.c
35148 @@ -63,7 +63,7 @@ struct cryptd_blkcipher_ctx {
35149
35150 struct cryptd_blkcipher_request_ctx {
35151 crypto_completion_t complete;
35152 -};
35153 +} __no_const;
35154
35155 struct cryptd_hash_ctx {
35156 struct crypto_shash *child;
35157 @@ -80,7 +80,7 @@ struct cryptd_aead_ctx {
35158
35159 struct cryptd_aead_request_ctx {
35160 crypto_completion_t complete;
35161 -};
35162 +} __no_const;
35163
35164 static void cryptd_queue_worker(struct work_struct *work);
35165
35166 diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c
35167 index f8c920c..ab2cb5a 100644
35168 --- a/crypto/pcrypt.c
35169 +++ b/crypto/pcrypt.c
35170 @@ -440,7 +440,7 @@ static int pcrypt_sysfs_add(struct padata_instance *pinst, const char *name)
35171 int ret;
35172
35173 pinst->kobj.kset = pcrypt_kset;
35174 - ret = kobject_add(&pinst->kobj, NULL, name);
35175 + ret = kobject_add(&pinst->kobj, NULL, "%s", name);
35176 if (!ret)
35177 kobject_uevent(&pinst->kobj, KOBJ_ADD);
35178
35179 diff --git a/drivers/acpi/apei/apei-internal.h b/drivers/acpi/apei/apei-internal.h
35180 index f220d64..d359ad6 100644
35181 --- a/drivers/acpi/apei/apei-internal.h
35182 +++ b/drivers/acpi/apei/apei-internal.h
35183 @@ -20,7 +20,7 @@ typedef int (*apei_exec_ins_func_t)(struct apei_exec_context *ctx,
35184 struct apei_exec_ins_type {
35185 u32 flags;
35186 apei_exec_ins_func_t run;
35187 -};
35188 +} __do_const;
35189
35190 struct apei_exec_context {
35191 u32 ip;
35192 diff --git a/drivers/acpi/apei/cper.c b/drivers/acpi/apei/cper.c
35193 index 33dc6a0..4b24b47 100644
35194 --- a/drivers/acpi/apei/cper.c
35195 +++ b/drivers/acpi/apei/cper.c
35196 @@ -39,12 +39,12 @@
35197 */
35198 u64 cper_next_record_id(void)
35199 {
35200 - static atomic64_t seq;
35201 + static atomic64_unchecked_t seq;
35202
35203 - if (!atomic64_read(&seq))
35204 - atomic64_set(&seq, ((u64)get_seconds()) << 32);
35205 + if (!atomic64_read_unchecked(&seq))
35206 + atomic64_set_unchecked(&seq, ((u64)get_seconds()) << 32);
35207
35208 - return atomic64_inc_return(&seq);
35209 + return atomic64_inc_return_unchecked(&seq);
35210 }
35211 EXPORT_SYMBOL_GPL(cper_next_record_id);
35212
35213 diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c
35214 index 8ec37bb..b0716e5 100644
35215 --- a/drivers/acpi/apei/ghes.c
35216 +++ b/drivers/acpi/apei/ghes.c
35217 @@ -498,7 +498,7 @@ static void __ghes_print_estatus(const char *pfx,
35218 const struct acpi_hest_generic *generic,
35219 const struct acpi_hest_generic_status *estatus)
35220 {
35221 - static atomic_t seqno;
35222 + static atomic_unchecked_t seqno;
35223 unsigned int curr_seqno;
35224 char pfx_seq[64];
35225
35226 @@ -509,7 +509,7 @@ static void __ghes_print_estatus(const char *pfx,
35227 else
35228 pfx = KERN_ERR;
35229 }
35230 - curr_seqno = atomic_inc_return(&seqno);
35231 + curr_seqno = atomic_inc_return_unchecked(&seqno);
35232 snprintf(pfx_seq, sizeof(pfx_seq), "%s{%u}" HW_ERR, pfx, curr_seqno);
35233 printk("%s""Hardware error from APEI Generic Hardware Error Source: %d\n",
35234 pfx_seq, generic->header.source_id);
35235 diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c
35236 index a83e3c6..c3d617f 100644
35237 --- a/drivers/acpi/bgrt.c
35238 +++ b/drivers/acpi/bgrt.c
35239 @@ -86,8 +86,10 @@ static int __init bgrt_init(void)
35240 if (!bgrt_image)
35241 return -ENODEV;
35242
35243 - bin_attr_image.private = bgrt_image;
35244 - bin_attr_image.size = bgrt_image_size;
35245 + pax_open_kernel();
35246 + *(void **)&bin_attr_image.private = bgrt_image;
35247 + *(size_t *)&bin_attr_image.size = bgrt_image_size;
35248 + pax_close_kernel();
35249
35250 bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj);
35251 if (!bgrt_kobj)
35252 diff --git a/drivers/acpi/blacklist.c b/drivers/acpi/blacklist.c
35253 index 9515f18..4b149c9 100644
35254 --- a/drivers/acpi/blacklist.c
35255 +++ b/drivers/acpi/blacklist.c
35256 @@ -52,7 +52,7 @@ struct acpi_blacklist_item {
35257 u32 is_critical_error;
35258 };
35259
35260 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata;
35261 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst;
35262
35263 /*
35264 * POLICY: If *anything* doesn't work, put it on the blacklist.
35265 @@ -199,7 +199,7 @@ static int __init dmi_disable_osi_win8(const struct dmi_system_id *d)
35266 return 0;
35267 }
35268
35269 -static struct dmi_system_id acpi_osi_dmi_table[] __initdata = {
35270 +static const struct dmi_system_id acpi_osi_dmi_table[] __initconst = {
35271 {
35272 .callback = dmi_disable_osi_vista,
35273 .ident = "Fujitsu Siemens",
35274 diff --git a/drivers/acpi/custom_method.c b/drivers/acpi/custom_method.c
35275 index 12b62f2..dc2aac8 100644
35276 --- a/drivers/acpi/custom_method.c
35277 +++ b/drivers/acpi/custom_method.c
35278 @@ -29,6 +29,10 @@ static ssize_t cm_write(struct file *file, const char __user * user_buf,
35279 struct acpi_table_header table;
35280 acpi_status status;
35281
35282 +#ifdef CONFIG_GRKERNSEC_KMEM
35283 + return -EPERM;
35284 +#endif
35285 +
35286 if (!(*ppos)) {
35287 /* parse the table header to get the table length */
35288 if (count <= sizeof(struct acpi_table_header))
35289 diff --git a/drivers/acpi/processor_idle.c b/drivers/acpi/processor_idle.c
35290 index c7414a5..d5afd71 100644
35291 --- a/drivers/acpi/processor_idle.c
35292 +++ b/drivers/acpi/processor_idle.c
35293 @@ -966,7 +966,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
35294 {
35295 int i, count = CPUIDLE_DRIVER_STATE_START;
35296 struct acpi_processor_cx *cx;
35297 - struct cpuidle_state *state;
35298 + cpuidle_state_no_const *state;
35299 struct cpuidle_driver *drv = &acpi_idle_driver;
35300
35301 if (!pr->flags.power_setup_done)
35302 diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c
35303 index 05306a5..733d1f0 100644
35304 --- a/drivers/acpi/sysfs.c
35305 +++ b/drivers/acpi/sysfs.c
35306 @@ -423,11 +423,11 @@ static u32 num_counters;
35307 static struct attribute **all_attrs;
35308 static u32 acpi_gpe_count;
35309
35310 -static struct attribute_group interrupt_stats_attr_group = {
35311 +static attribute_group_no_const interrupt_stats_attr_group = {
35312 .name = "interrupts",
35313 };
35314
35315 -static struct kobj_attribute *counter_attrs;
35316 +static kobj_attribute_no_const *counter_attrs;
35317
35318 static void delete_gpe_attr_array(void)
35319 {
35320 diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
35321 index cfb7447..98f2149 100644
35322 --- a/drivers/ata/libahci.c
35323 +++ b/drivers/ata/libahci.c
35324 @@ -1239,7 +1239,7 @@ int ahci_kick_engine(struct ata_port *ap)
35325 }
35326 EXPORT_SYMBOL_GPL(ahci_kick_engine);
35327
35328 -static int ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35329 +static int __intentional_overflow(-1) ahci_exec_polled_cmd(struct ata_port *ap, int pmp,
35330 struct ata_taskfile *tf, int is_cmd, u16 flags,
35331 unsigned long timeout_msec)
35332 {
35333 diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c
35334 index 2c2780a..5ebc310 100644
35335 --- a/drivers/ata/libata-core.c
35336 +++ b/drivers/ata/libata-core.c
35337 @@ -98,7 +98,7 @@ static unsigned int ata_dev_set_xfermode(struct ata_device *dev);
35338 static void ata_dev_xfermask(struct ata_device *dev);
35339 static unsigned long ata_dev_blacklisted(const struct ata_device *dev);
35340
35341 -atomic_t ata_print_id = ATOMIC_INIT(0);
35342 +atomic_unchecked_t ata_print_id = ATOMIC_INIT(0);
35343
35344 struct ata_force_param {
35345 const char *name;
35346 @@ -4823,7 +4823,7 @@ void ata_qc_free(struct ata_queued_cmd *qc)
35347 struct ata_port *ap;
35348 unsigned int tag;
35349
35350 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35351 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35352 ap = qc->ap;
35353
35354 qc->flags = 0;
35355 @@ -4839,7 +4839,7 @@ void __ata_qc_complete(struct ata_queued_cmd *qc)
35356 struct ata_port *ap;
35357 struct ata_link *link;
35358
35359 - WARN_ON_ONCE(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35360 + BUG_ON(qc == NULL); /* ata_qc_from_tag _might_ return NULL */
35361 WARN_ON_ONCE(!(qc->flags & ATA_QCFLAG_ACTIVE));
35362 ap = qc->ap;
35363 link = qc->dev->link;
35364 @@ -5958,6 +5958,7 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35365 return;
35366
35367 spin_lock(&lock);
35368 + pax_open_kernel();
35369
35370 for (cur = ops->inherits; cur; cur = cur->inherits) {
35371 void **inherit = (void **)cur;
35372 @@ -5971,8 +5972,9 @@ static void ata_finalize_port_ops(struct ata_port_operations *ops)
35373 if (IS_ERR(*pp))
35374 *pp = NULL;
35375
35376 - ops->inherits = NULL;
35377 + *(struct ata_port_operations **)&ops->inherits = NULL;
35378
35379 + pax_close_kernel();
35380 spin_unlock(&lock);
35381 }
35382
35383 @@ -6165,7 +6167,7 @@ int ata_host_register(struct ata_host *host, struct scsi_host_template *sht)
35384
35385 /* give ports names and add SCSI hosts */
35386 for (i = 0; i < host->n_ports; i++) {
35387 - host->ports[i]->print_id = atomic_inc_return(&ata_print_id);
35388 + host->ports[i]->print_id = atomic_inc_return_unchecked(&ata_print_id);
35389 host->ports[i]->local_port_no = i + 1;
35390 }
35391
35392 diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
35393 index 377eb88..8591b44 100644
35394 --- a/drivers/ata/libata-scsi.c
35395 +++ b/drivers/ata/libata-scsi.c
35396 @@ -4135,7 +4135,7 @@ int ata_sas_port_init(struct ata_port *ap)
35397
35398 if (rc)
35399 return rc;
35400 - ap->print_id = atomic_inc_return(&ata_print_id);
35401 + ap->print_id = atomic_inc_return_unchecked(&ata_print_id);
35402 return 0;
35403 }
35404 EXPORT_SYMBOL_GPL(ata_sas_port_init);
35405 diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h
35406 index 45b5ab3..98446b8 100644
35407 --- a/drivers/ata/libata.h
35408 +++ b/drivers/ata/libata.h
35409 @@ -53,7 +53,7 @@ enum {
35410 ATA_DNXFER_QUIET = (1 << 31),
35411 };
35412
35413 -extern atomic_t ata_print_id;
35414 +extern atomic_unchecked_t ata_print_id;
35415 extern int atapi_passthru16;
35416 extern int libata_fua;
35417 extern int libata_noacpi;
35418 diff --git a/drivers/ata/pata_arasan_cf.c b/drivers/ata/pata_arasan_cf.c
35419 index 853f610..97d24da 100644
35420 --- a/drivers/ata/pata_arasan_cf.c
35421 +++ b/drivers/ata/pata_arasan_cf.c
35422 @@ -865,7 +865,9 @@ static int arasan_cf_probe(struct platform_device *pdev)
35423 /* Handle platform specific quirks */
35424 if (quirk) {
35425 if (quirk & CF_BROKEN_PIO) {
35426 - ap->ops->set_piomode = NULL;
35427 + pax_open_kernel();
35428 + *(void **)&ap->ops->set_piomode = NULL;
35429 + pax_close_kernel();
35430 ap->pio_mask = 0;
35431 }
35432 if (quirk & CF_BROKEN_MWDMA)
35433 diff --git a/drivers/atm/adummy.c b/drivers/atm/adummy.c
35434 index f9b983a..887b9d8 100644
35435 --- a/drivers/atm/adummy.c
35436 +++ b/drivers/atm/adummy.c
35437 @@ -114,7 +114,7 @@ adummy_send(struct atm_vcc *vcc, struct sk_buff *skb)
35438 vcc->pop(vcc, skb);
35439 else
35440 dev_kfree_skb_any(skb);
35441 - atomic_inc(&vcc->stats->tx);
35442 + atomic_inc_unchecked(&vcc->stats->tx);
35443
35444 return 0;
35445 }
35446 diff --git a/drivers/atm/ambassador.c b/drivers/atm/ambassador.c
35447 index 62a7607..cc4be104 100644
35448 --- a/drivers/atm/ambassador.c
35449 +++ b/drivers/atm/ambassador.c
35450 @@ -454,7 +454,7 @@ static void tx_complete (amb_dev * dev, tx_out * tx) {
35451 PRINTD (DBG_FLOW|DBG_TX, "tx_complete %p %p", dev, tx);
35452
35453 // VC layer stats
35454 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35455 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35456
35457 // free the descriptor
35458 kfree (tx_descr);
35459 @@ -495,7 +495,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35460 dump_skb ("<<<", vc, skb);
35461
35462 // VC layer stats
35463 - atomic_inc(&atm_vcc->stats->rx);
35464 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35465 __net_timestamp(skb);
35466 // end of our responsibility
35467 atm_vcc->push (atm_vcc, skb);
35468 @@ -510,7 +510,7 @@ static void rx_complete (amb_dev * dev, rx_out * rx) {
35469 } else {
35470 PRINTK (KERN_INFO, "dropped over-size frame");
35471 // should we count this?
35472 - atomic_inc(&atm_vcc->stats->rx_drop);
35473 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35474 }
35475
35476 } else {
35477 @@ -1338,7 +1338,7 @@ static int amb_send (struct atm_vcc * atm_vcc, struct sk_buff * skb) {
35478 }
35479
35480 if (check_area (skb->data, skb->len)) {
35481 - atomic_inc(&atm_vcc->stats->tx_err);
35482 + atomic_inc_unchecked(&atm_vcc->stats->tx_err);
35483 return -ENOMEM; // ?
35484 }
35485
35486 diff --git a/drivers/atm/atmtcp.c b/drivers/atm/atmtcp.c
35487 index 0e3f8f9..765a7a5 100644
35488 --- a/drivers/atm/atmtcp.c
35489 +++ b/drivers/atm/atmtcp.c
35490 @@ -206,7 +206,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35491 if (vcc->pop) vcc->pop(vcc,skb);
35492 else dev_kfree_skb(skb);
35493 if (dev_data) return 0;
35494 - atomic_inc(&vcc->stats->tx_err);
35495 + atomic_inc_unchecked(&vcc->stats->tx_err);
35496 return -ENOLINK;
35497 }
35498 size = skb->len+sizeof(struct atmtcp_hdr);
35499 @@ -214,7 +214,7 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35500 if (!new_skb) {
35501 if (vcc->pop) vcc->pop(vcc,skb);
35502 else dev_kfree_skb(skb);
35503 - atomic_inc(&vcc->stats->tx_err);
35504 + atomic_inc_unchecked(&vcc->stats->tx_err);
35505 return -ENOBUFS;
35506 }
35507 hdr = (void *) skb_put(new_skb,sizeof(struct atmtcp_hdr));
35508 @@ -225,8 +225,8 @@ static int atmtcp_v_send(struct atm_vcc *vcc,struct sk_buff *skb)
35509 if (vcc->pop) vcc->pop(vcc,skb);
35510 else dev_kfree_skb(skb);
35511 out_vcc->push(out_vcc,new_skb);
35512 - atomic_inc(&vcc->stats->tx);
35513 - atomic_inc(&out_vcc->stats->rx);
35514 + atomic_inc_unchecked(&vcc->stats->tx);
35515 + atomic_inc_unchecked(&out_vcc->stats->rx);
35516 return 0;
35517 }
35518
35519 @@ -299,7 +299,7 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35520 out_vcc = find_vcc(dev, ntohs(hdr->vpi), ntohs(hdr->vci));
35521 read_unlock(&vcc_sklist_lock);
35522 if (!out_vcc) {
35523 - atomic_inc(&vcc->stats->tx_err);
35524 + atomic_inc_unchecked(&vcc->stats->tx_err);
35525 goto done;
35526 }
35527 skb_pull(skb,sizeof(struct atmtcp_hdr));
35528 @@ -311,8 +311,8 @@ static int atmtcp_c_send(struct atm_vcc *vcc,struct sk_buff *skb)
35529 __net_timestamp(new_skb);
35530 skb_copy_from_linear_data(skb, skb_put(new_skb, skb->len), skb->len);
35531 out_vcc->push(out_vcc,new_skb);
35532 - atomic_inc(&vcc->stats->tx);
35533 - atomic_inc(&out_vcc->stats->rx);
35534 + atomic_inc_unchecked(&vcc->stats->tx);
35535 + atomic_inc_unchecked(&out_vcc->stats->rx);
35536 done:
35537 if (vcc->pop) vcc->pop(vcc,skb);
35538 else dev_kfree_skb(skb);
35539 diff --git a/drivers/atm/eni.c b/drivers/atm/eni.c
35540 index b1955ba..b179940 100644
35541 --- a/drivers/atm/eni.c
35542 +++ b/drivers/atm/eni.c
35543 @@ -522,7 +522,7 @@ static int rx_aal0(struct atm_vcc *vcc)
35544 DPRINTK(DEV_LABEL "(itf %d): trashing empty cell\n",
35545 vcc->dev->number);
35546 length = 0;
35547 - atomic_inc(&vcc->stats->rx_err);
35548 + atomic_inc_unchecked(&vcc->stats->rx_err);
35549 }
35550 else {
35551 length = ATM_CELL_SIZE-1; /* no HEC */
35552 @@ -577,7 +577,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35553 size);
35554 }
35555 eff = length = 0;
35556 - atomic_inc(&vcc->stats->rx_err);
35557 + atomic_inc_unchecked(&vcc->stats->rx_err);
35558 }
35559 else {
35560 size = (descr & MID_RED_COUNT)*(ATM_CELL_PAYLOAD >> 2);
35561 @@ -594,7 +594,7 @@ static int rx_aal5(struct atm_vcc *vcc)
35562 "(VCI=%d,length=%ld,size=%ld (descr 0x%lx))\n",
35563 vcc->dev->number,vcc->vci,length,size << 2,descr);
35564 length = eff = 0;
35565 - atomic_inc(&vcc->stats->rx_err);
35566 + atomic_inc_unchecked(&vcc->stats->rx_err);
35567 }
35568 }
35569 skb = eff ? atm_alloc_charge(vcc,eff << 2,GFP_ATOMIC) : NULL;
35570 @@ -767,7 +767,7 @@ rx_dequeued++;
35571 vcc->push(vcc,skb);
35572 pushed++;
35573 }
35574 - atomic_inc(&vcc->stats->rx);
35575 + atomic_inc_unchecked(&vcc->stats->rx);
35576 }
35577 wake_up(&eni_dev->rx_wait);
35578 }
35579 @@ -1227,7 +1227,7 @@ static void dequeue_tx(struct atm_dev *dev)
35580 PCI_DMA_TODEVICE);
35581 if (vcc->pop) vcc->pop(vcc,skb);
35582 else dev_kfree_skb_irq(skb);
35583 - atomic_inc(&vcc->stats->tx);
35584 + atomic_inc_unchecked(&vcc->stats->tx);
35585 wake_up(&eni_dev->tx_wait);
35586 dma_complete++;
35587 }
35588 diff --git a/drivers/atm/firestream.c b/drivers/atm/firestream.c
35589 index b41c948..a002b17 100644
35590 --- a/drivers/atm/firestream.c
35591 +++ b/drivers/atm/firestream.c
35592 @@ -749,7 +749,7 @@ static void process_txdone_queue (struct fs_dev *dev, struct queue *q)
35593 }
35594 }
35595
35596 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35597 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35598
35599 fs_dprintk (FS_DEBUG_TXMEM, "i");
35600 fs_dprintk (FS_DEBUG_ALLOC, "Free t-skb: %p\n", skb);
35601 @@ -816,7 +816,7 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35602 #endif
35603 skb_put (skb, qe->p1 & 0xffff);
35604 ATM_SKB(skb)->vcc = atm_vcc;
35605 - atomic_inc(&atm_vcc->stats->rx);
35606 + atomic_inc_unchecked(&atm_vcc->stats->rx);
35607 __net_timestamp(skb);
35608 fs_dprintk (FS_DEBUG_ALLOC, "Free rec-skb: %p (pushed)\n", skb);
35609 atm_vcc->push (atm_vcc, skb);
35610 @@ -837,12 +837,12 @@ static void process_incoming (struct fs_dev *dev, struct queue *q)
35611 kfree (pe);
35612 }
35613 if (atm_vcc)
35614 - atomic_inc(&atm_vcc->stats->rx_drop);
35615 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35616 break;
35617 case 0x1f: /* Reassembly abort: no buffers. */
35618 /* Silently increment error counter. */
35619 if (atm_vcc)
35620 - atomic_inc(&atm_vcc->stats->rx_drop);
35621 + atomic_inc_unchecked(&atm_vcc->stats->rx_drop);
35622 break;
35623 default: /* Hmm. Haven't written the code to handle the others yet... -- REW */
35624 printk (KERN_WARNING "Don't know what to do with RX status %x: %s.\n",
35625 diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c
35626 index 204814e..cede831 100644
35627 --- a/drivers/atm/fore200e.c
35628 +++ b/drivers/atm/fore200e.c
35629 @@ -931,9 +931,9 @@ fore200e_tx_irq(struct fore200e* fore200e)
35630 #endif
35631 /* check error condition */
35632 if (*entry->status & STATUS_ERROR)
35633 - atomic_inc(&vcc->stats->tx_err);
35634 + atomic_inc_unchecked(&vcc->stats->tx_err);
35635 else
35636 - atomic_inc(&vcc->stats->tx);
35637 + atomic_inc_unchecked(&vcc->stats->tx);
35638 }
35639 }
35640
35641 @@ -1082,7 +1082,7 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35642 if (skb == NULL) {
35643 DPRINTK(2, "unable to alloc new skb, rx PDU length = %d\n", pdu_len);
35644
35645 - atomic_inc(&vcc->stats->rx_drop);
35646 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35647 return -ENOMEM;
35648 }
35649
35650 @@ -1125,14 +1125,14 @@ fore200e_push_rpd(struct fore200e* fore200e, struct atm_vcc* vcc, struct rpd* rp
35651
35652 dev_kfree_skb_any(skb);
35653
35654 - atomic_inc(&vcc->stats->rx_drop);
35655 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35656 return -ENOMEM;
35657 }
35658
35659 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35660
35661 vcc->push(vcc, skb);
35662 - atomic_inc(&vcc->stats->rx);
35663 + atomic_inc_unchecked(&vcc->stats->rx);
35664
35665 ASSERT(atomic_read(&sk_atm(vcc)->sk_wmem_alloc) >= 0);
35666
35667 @@ -1210,7 +1210,7 @@ fore200e_rx_irq(struct fore200e* fore200e)
35668 DPRINTK(2, "damaged PDU on %d.%d.%d\n",
35669 fore200e->atm_dev->number,
35670 entry->rpd->atm_header.vpi, entry->rpd->atm_header.vci);
35671 - atomic_inc(&vcc->stats->rx_err);
35672 + atomic_inc_unchecked(&vcc->stats->rx_err);
35673 }
35674 }
35675
35676 @@ -1655,7 +1655,7 @@ fore200e_send(struct atm_vcc *vcc, struct sk_buff *skb)
35677 goto retry_here;
35678 }
35679
35680 - atomic_inc(&vcc->stats->tx_err);
35681 + atomic_inc_unchecked(&vcc->stats->tx_err);
35682
35683 fore200e->tx_sat++;
35684 DPRINTK(2, "tx queue of device %s is saturated, PDU dropped - heartbeat is %08x\n",
35685 diff --git a/drivers/atm/he.c b/drivers/atm/he.c
35686 index 8557adc..3fb5d55 100644
35687 --- a/drivers/atm/he.c
35688 +++ b/drivers/atm/he.c
35689 @@ -1691,7 +1691,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35690
35691 if (RBRQ_HBUF_ERR(he_dev->rbrq_head)) {
35692 hprintk("HBUF_ERR! (cid 0x%x)\n", cid);
35693 - atomic_inc(&vcc->stats->rx_drop);
35694 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35695 goto return_host_buffers;
35696 }
35697
35698 @@ -1718,7 +1718,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35699 RBRQ_LEN_ERR(he_dev->rbrq_head)
35700 ? "LEN_ERR" : "",
35701 vcc->vpi, vcc->vci);
35702 - atomic_inc(&vcc->stats->rx_err);
35703 + atomic_inc_unchecked(&vcc->stats->rx_err);
35704 goto return_host_buffers;
35705 }
35706
35707 @@ -1770,7 +1770,7 @@ he_service_rbrq(struct he_dev *he_dev, int group)
35708 vcc->push(vcc, skb);
35709 spin_lock(&he_dev->global_lock);
35710
35711 - atomic_inc(&vcc->stats->rx);
35712 + atomic_inc_unchecked(&vcc->stats->rx);
35713
35714 return_host_buffers:
35715 ++pdus_assembled;
35716 @@ -2096,7 +2096,7 @@ __enqueue_tpd(struct he_dev *he_dev, struct he_tpd *tpd, unsigned cid)
35717 tpd->vcc->pop(tpd->vcc, tpd->skb);
35718 else
35719 dev_kfree_skb_any(tpd->skb);
35720 - atomic_inc(&tpd->vcc->stats->tx_err);
35721 + atomic_inc_unchecked(&tpd->vcc->stats->tx_err);
35722 }
35723 pci_pool_free(he_dev->tpd_pool, tpd, TPD_ADDR(tpd->status));
35724 return;
35725 @@ -2508,7 +2508,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35726 vcc->pop(vcc, skb);
35727 else
35728 dev_kfree_skb_any(skb);
35729 - atomic_inc(&vcc->stats->tx_err);
35730 + atomic_inc_unchecked(&vcc->stats->tx_err);
35731 return -EINVAL;
35732 }
35733
35734 @@ -2519,7 +2519,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35735 vcc->pop(vcc, skb);
35736 else
35737 dev_kfree_skb_any(skb);
35738 - atomic_inc(&vcc->stats->tx_err);
35739 + atomic_inc_unchecked(&vcc->stats->tx_err);
35740 return -EINVAL;
35741 }
35742 #endif
35743 @@ -2531,7 +2531,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35744 vcc->pop(vcc, skb);
35745 else
35746 dev_kfree_skb_any(skb);
35747 - atomic_inc(&vcc->stats->tx_err);
35748 + atomic_inc_unchecked(&vcc->stats->tx_err);
35749 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35750 return -ENOMEM;
35751 }
35752 @@ -2573,7 +2573,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35753 vcc->pop(vcc, skb);
35754 else
35755 dev_kfree_skb_any(skb);
35756 - atomic_inc(&vcc->stats->tx_err);
35757 + atomic_inc_unchecked(&vcc->stats->tx_err);
35758 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35759 return -ENOMEM;
35760 }
35761 @@ -2604,7 +2604,7 @@ he_send(struct atm_vcc *vcc, struct sk_buff *skb)
35762 __enqueue_tpd(he_dev, tpd, cid);
35763 spin_unlock_irqrestore(&he_dev->global_lock, flags);
35764
35765 - atomic_inc(&vcc->stats->tx);
35766 + atomic_inc_unchecked(&vcc->stats->tx);
35767
35768 return 0;
35769 }
35770 diff --git a/drivers/atm/horizon.c b/drivers/atm/horizon.c
35771 index 1dc0519..1aadaf7 100644
35772 --- a/drivers/atm/horizon.c
35773 +++ b/drivers/atm/horizon.c
35774 @@ -1034,7 +1034,7 @@ static void rx_schedule (hrz_dev * dev, int irq) {
35775 {
35776 struct atm_vcc * vcc = ATM_SKB(skb)->vcc;
35777 // VC layer stats
35778 - atomic_inc(&vcc->stats->rx);
35779 + atomic_inc_unchecked(&vcc->stats->rx);
35780 __net_timestamp(skb);
35781 // end of our responsibility
35782 vcc->push (vcc, skb);
35783 @@ -1186,7 +1186,7 @@ static void tx_schedule (hrz_dev * const dev, int irq) {
35784 dev->tx_iovec = NULL;
35785
35786 // VC layer stats
35787 - atomic_inc(&ATM_SKB(skb)->vcc->stats->tx);
35788 + atomic_inc_unchecked(&ATM_SKB(skb)->vcc->stats->tx);
35789
35790 // free the skb
35791 hrz_kfree_skb (skb);
35792 diff --git a/drivers/atm/idt77252.c b/drivers/atm/idt77252.c
35793 index 1bdf104..9dc44b1 100644
35794 --- a/drivers/atm/idt77252.c
35795 +++ b/drivers/atm/idt77252.c
35796 @@ -812,7 +812,7 @@ drain_scq(struct idt77252_dev *card, struct vc_map *vc)
35797 else
35798 dev_kfree_skb(skb);
35799
35800 - atomic_inc(&vcc->stats->tx);
35801 + atomic_inc_unchecked(&vcc->stats->tx);
35802 }
35803
35804 atomic_dec(&scq->used);
35805 @@ -1075,13 +1075,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35806 if ((sb = dev_alloc_skb(64)) == NULL) {
35807 printk("%s: Can't allocate buffers for aal0.\n",
35808 card->name);
35809 - atomic_add(i, &vcc->stats->rx_drop);
35810 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
35811 break;
35812 }
35813 if (!atm_charge(vcc, sb->truesize)) {
35814 RXPRINTK("%s: atm_charge() dropped aal0 packets.\n",
35815 card->name);
35816 - atomic_add(i - 1, &vcc->stats->rx_drop);
35817 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop);
35818 dev_kfree_skb(sb);
35819 break;
35820 }
35821 @@ -1098,7 +1098,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35822 ATM_SKB(sb)->vcc = vcc;
35823 __net_timestamp(sb);
35824 vcc->push(vcc, sb);
35825 - atomic_inc(&vcc->stats->rx);
35826 + atomic_inc_unchecked(&vcc->stats->rx);
35827
35828 cell += ATM_CELL_PAYLOAD;
35829 }
35830 @@ -1135,13 +1135,13 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35831 "(CDC: %08x)\n",
35832 card->name, len, rpp->len, readl(SAR_REG_CDC));
35833 recycle_rx_pool_skb(card, rpp);
35834 - atomic_inc(&vcc->stats->rx_err);
35835 + atomic_inc_unchecked(&vcc->stats->rx_err);
35836 return;
35837 }
35838 if (stat & SAR_RSQE_CRC) {
35839 RXPRINTK("%s: AAL5 CRC error.\n", card->name);
35840 recycle_rx_pool_skb(card, rpp);
35841 - atomic_inc(&vcc->stats->rx_err);
35842 + atomic_inc_unchecked(&vcc->stats->rx_err);
35843 return;
35844 }
35845 if (skb_queue_len(&rpp->queue) > 1) {
35846 @@ -1152,7 +1152,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35847 RXPRINTK("%s: Can't alloc RX skb.\n",
35848 card->name);
35849 recycle_rx_pool_skb(card, rpp);
35850 - atomic_inc(&vcc->stats->rx_err);
35851 + atomic_inc_unchecked(&vcc->stats->rx_err);
35852 return;
35853 }
35854 if (!atm_charge(vcc, skb->truesize)) {
35855 @@ -1171,7 +1171,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35856 __net_timestamp(skb);
35857
35858 vcc->push(vcc, skb);
35859 - atomic_inc(&vcc->stats->rx);
35860 + atomic_inc_unchecked(&vcc->stats->rx);
35861
35862 return;
35863 }
35864 @@ -1193,7 +1193,7 @@ dequeue_rx(struct idt77252_dev *card, struct rsq_entry *rsqe)
35865 __net_timestamp(skb);
35866
35867 vcc->push(vcc, skb);
35868 - atomic_inc(&vcc->stats->rx);
35869 + atomic_inc_unchecked(&vcc->stats->rx);
35870
35871 if (skb->truesize > SAR_FB_SIZE_3)
35872 add_rx_skb(card, 3, SAR_FB_SIZE_3, 1);
35873 @@ -1304,14 +1304,14 @@ idt77252_rx_raw(struct idt77252_dev *card)
35874 if (vcc->qos.aal != ATM_AAL0) {
35875 RPRINTK("%s: raw cell for non AAL0 vc %u.%u\n",
35876 card->name, vpi, vci);
35877 - atomic_inc(&vcc->stats->rx_drop);
35878 + atomic_inc_unchecked(&vcc->stats->rx_drop);
35879 goto drop;
35880 }
35881
35882 if ((sb = dev_alloc_skb(64)) == NULL) {
35883 printk("%s: Can't allocate buffers for AAL0.\n",
35884 card->name);
35885 - atomic_inc(&vcc->stats->rx_err);
35886 + atomic_inc_unchecked(&vcc->stats->rx_err);
35887 goto drop;
35888 }
35889
35890 @@ -1330,7 +1330,7 @@ idt77252_rx_raw(struct idt77252_dev *card)
35891 ATM_SKB(sb)->vcc = vcc;
35892 __net_timestamp(sb);
35893 vcc->push(vcc, sb);
35894 - atomic_inc(&vcc->stats->rx);
35895 + atomic_inc_unchecked(&vcc->stats->rx);
35896
35897 drop:
35898 skb_pull(queue, 64);
35899 @@ -1955,13 +1955,13 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35900
35901 if (vc == NULL) {
35902 printk("%s: NULL connection in send().\n", card->name);
35903 - atomic_inc(&vcc->stats->tx_err);
35904 + atomic_inc_unchecked(&vcc->stats->tx_err);
35905 dev_kfree_skb(skb);
35906 return -EINVAL;
35907 }
35908 if (!test_bit(VCF_TX, &vc->flags)) {
35909 printk("%s: Trying to transmit on a non-tx VC.\n", card->name);
35910 - atomic_inc(&vcc->stats->tx_err);
35911 + atomic_inc_unchecked(&vcc->stats->tx_err);
35912 dev_kfree_skb(skb);
35913 return -EINVAL;
35914 }
35915 @@ -1973,14 +1973,14 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35916 break;
35917 default:
35918 printk("%s: Unsupported AAL: %d\n", card->name, vcc->qos.aal);
35919 - atomic_inc(&vcc->stats->tx_err);
35920 + atomic_inc_unchecked(&vcc->stats->tx_err);
35921 dev_kfree_skb(skb);
35922 return -EINVAL;
35923 }
35924
35925 if (skb_shinfo(skb)->nr_frags != 0) {
35926 printk("%s: No scatter-gather yet.\n", card->name);
35927 - atomic_inc(&vcc->stats->tx_err);
35928 + atomic_inc_unchecked(&vcc->stats->tx_err);
35929 dev_kfree_skb(skb);
35930 return -EINVAL;
35931 }
35932 @@ -1988,7 +1988,7 @@ idt77252_send_skb(struct atm_vcc *vcc, struct sk_buff *skb, int oam)
35933
35934 err = queue_skb(card, vc, skb, oam);
35935 if (err) {
35936 - atomic_inc(&vcc->stats->tx_err);
35937 + atomic_inc_unchecked(&vcc->stats->tx_err);
35938 dev_kfree_skb(skb);
35939 return err;
35940 }
35941 @@ -2011,7 +2011,7 @@ idt77252_send_oam(struct atm_vcc *vcc, void *cell, int flags)
35942 skb = dev_alloc_skb(64);
35943 if (!skb) {
35944 printk("%s: Out of memory in send_oam().\n", card->name);
35945 - atomic_inc(&vcc->stats->tx_err);
35946 + atomic_inc_unchecked(&vcc->stats->tx_err);
35947 return -ENOMEM;
35948 }
35949 atomic_add(skb->truesize, &sk_atm(vcc)->sk_wmem_alloc);
35950 diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c
35951 index 4217f29..88f547a 100644
35952 --- a/drivers/atm/iphase.c
35953 +++ b/drivers/atm/iphase.c
35954 @@ -1145,7 +1145,7 @@ static int rx_pkt(struct atm_dev *dev)
35955 status = (u_short) (buf_desc_ptr->desc_mode);
35956 if (status & (RX_CER | RX_PTE | RX_OFL))
35957 {
35958 - atomic_inc(&vcc->stats->rx_err);
35959 + atomic_inc_unchecked(&vcc->stats->rx_err);
35960 IF_ERR(printk("IA: bad packet, dropping it");)
35961 if (status & RX_CER) {
35962 IF_ERR(printk(" cause: packet CRC error\n");)
35963 @@ -1168,7 +1168,7 @@ static int rx_pkt(struct atm_dev *dev)
35964 len = dma_addr - buf_addr;
35965 if (len > iadev->rx_buf_sz) {
35966 printk("Over %d bytes sdu received, dropped!!!\n", iadev->rx_buf_sz);
35967 - atomic_inc(&vcc->stats->rx_err);
35968 + atomic_inc_unchecked(&vcc->stats->rx_err);
35969 goto out_free_desc;
35970 }
35971
35972 @@ -1318,7 +1318,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35973 ia_vcc = INPH_IA_VCC(vcc);
35974 if (ia_vcc == NULL)
35975 {
35976 - atomic_inc(&vcc->stats->rx_err);
35977 + atomic_inc_unchecked(&vcc->stats->rx_err);
35978 atm_return(vcc, skb->truesize);
35979 dev_kfree_skb_any(skb);
35980 goto INCR_DLE;
35981 @@ -1330,7 +1330,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35982 if ((length > iadev->rx_buf_sz) || (length >
35983 (skb->len - sizeof(struct cpcs_trailer))))
35984 {
35985 - atomic_inc(&vcc->stats->rx_err);
35986 + atomic_inc_unchecked(&vcc->stats->rx_err);
35987 IF_ERR(printk("rx_dle_intr: Bad AAL5 trailer %d (skb len %d)",
35988 length, skb->len);)
35989 atm_return(vcc, skb->truesize);
35990 @@ -1346,7 +1346,7 @@ static void rx_dle_intr(struct atm_dev *dev)
35991
35992 IF_RX(printk("rx_dle_intr: skb push");)
35993 vcc->push(vcc,skb);
35994 - atomic_inc(&vcc->stats->rx);
35995 + atomic_inc_unchecked(&vcc->stats->rx);
35996 iadev->rx_pkt_cnt++;
35997 }
35998 INCR_DLE:
35999 @@ -2826,15 +2826,15 @@ static int ia_ioctl(struct atm_dev *dev, unsigned int cmd, void __user *arg)
36000 {
36001 struct k_sonet_stats *stats;
36002 stats = &PRIV(_ia_dev[board])->sonet_stats;
36003 - printk("section_bip: %d\n", atomic_read(&stats->section_bip));
36004 - printk("line_bip : %d\n", atomic_read(&stats->line_bip));
36005 - printk("path_bip : %d\n", atomic_read(&stats->path_bip));
36006 - printk("line_febe : %d\n", atomic_read(&stats->line_febe));
36007 - printk("path_febe : %d\n", atomic_read(&stats->path_febe));
36008 - printk("corr_hcs : %d\n", atomic_read(&stats->corr_hcs));
36009 - printk("uncorr_hcs : %d\n", atomic_read(&stats->uncorr_hcs));
36010 - printk("tx_cells : %d\n", atomic_read(&stats->tx_cells));
36011 - printk("rx_cells : %d\n", atomic_read(&stats->rx_cells));
36012 + printk("section_bip: %d\n", atomic_read_unchecked(&stats->section_bip));
36013 + printk("line_bip : %d\n", atomic_read_unchecked(&stats->line_bip));
36014 + printk("path_bip : %d\n", atomic_read_unchecked(&stats->path_bip));
36015 + printk("line_febe : %d\n", atomic_read_unchecked(&stats->line_febe));
36016 + printk("path_febe : %d\n", atomic_read_unchecked(&stats->path_febe));
36017 + printk("corr_hcs : %d\n", atomic_read_unchecked(&stats->corr_hcs));
36018 + printk("uncorr_hcs : %d\n", atomic_read_unchecked(&stats->uncorr_hcs));
36019 + printk("tx_cells : %d\n", atomic_read_unchecked(&stats->tx_cells));
36020 + printk("rx_cells : %d\n", atomic_read_unchecked(&stats->rx_cells));
36021 }
36022 ia_cmds.status = 0;
36023 break;
36024 @@ -2939,7 +2939,7 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36025 if ((desc == 0) || (desc > iadev->num_tx_desc))
36026 {
36027 IF_ERR(printk(DEV_LABEL "invalid desc for send: %d\n", desc);)
36028 - atomic_inc(&vcc->stats->tx);
36029 + atomic_inc_unchecked(&vcc->stats->tx);
36030 if (vcc->pop)
36031 vcc->pop(vcc, skb);
36032 else
36033 @@ -3044,14 +3044,14 @@ static int ia_pkt_tx (struct atm_vcc *vcc, struct sk_buff *skb) {
36034 ATM_DESC(skb) = vcc->vci;
36035 skb_queue_tail(&iadev->tx_dma_q, skb);
36036
36037 - atomic_inc(&vcc->stats->tx);
36038 + atomic_inc_unchecked(&vcc->stats->tx);
36039 iadev->tx_pkt_cnt++;
36040 /* Increment transaction counter */
36041 writel(2, iadev->dma+IPHASE5575_TX_COUNTER);
36042
36043 #if 0
36044 /* add flow control logic */
36045 - if (atomic_read(&vcc->stats->tx) % 20 == 0) {
36046 + if (atomic_read_unchecked(&vcc->stats->tx) % 20 == 0) {
36047 if (iavcc->vc_desc_cnt > 10) {
36048 vcc->tx_quota = vcc->tx_quota * 3 / 4;
36049 printk("Tx1: vcc->tx_quota = %d \n", (u32)vcc->tx_quota );
36050 diff --git a/drivers/atm/lanai.c b/drivers/atm/lanai.c
36051 index fa7d701..1e404c7 100644
36052 --- a/drivers/atm/lanai.c
36053 +++ b/drivers/atm/lanai.c
36054 @@ -1303,7 +1303,7 @@ static void lanai_send_one_aal5(struct lanai_dev *lanai,
36055 vcc_tx_add_aal5_trailer(lvcc, skb->len, 0, 0);
36056 lanai_endtx(lanai, lvcc);
36057 lanai_free_skb(lvcc->tx.atmvcc, skb);
36058 - atomic_inc(&lvcc->tx.atmvcc->stats->tx);
36059 + atomic_inc_unchecked(&lvcc->tx.atmvcc->stats->tx);
36060 }
36061
36062 /* Try to fill the buffer - don't call unless there is backlog */
36063 @@ -1426,7 +1426,7 @@ static void vcc_rx_aal5(struct lanai_vcc *lvcc, int endptr)
36064 ATM_SKB(skb)->vcc = lvcc->rx.atmvcc;
36065 __net_timestamp(skb);
36066 lvcc->rx.atmvcc->push(lvcc->rx.atmvcc, skb);
36067 - atomic_inc(&lvcc->rx.atmvcc->stats->rx);
36068 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx);
36069 out:
36070 lvcc->rx.buf.ptr = end;
36071 cardvcc_write(lvcc, endptr, vcc_rxreadptr);
36072 @@ -1667,7 +1667,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36073 DPRINTK("(itf %d) got RX service entry 0x%X for non-AAL5 "
36074 "vcc %d\n", lanai->number, (unsigned int) s, vci);
36075 lanai->stats.service_rxnotaal5++;
36076 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36077 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36078 return 0;
36079 }
36080 if (likely(!(s & (SERVICE_TRASH | SERVICE_STREAM | SERVICE_CRCERR)))) {
36081 @@ -1679,7 +1679,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36082 int bytes;
36083 read_unlock(&vcc_sklist_lock);
36084 DPRINTK("got trashed rx pdu on vci %d\n", vci);
36085 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36086 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36087 lvcc->stats.x.aal5.service_trash++;
36088 bytes = (SERVICE_GET_END(s) * 16) -
36089 (((unsigned long) lvcc->rx.buf.ptr) -
36090 @@ -1691,7 +1691,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36091 }
36092 if (s & SERVICE_STREAM) {
36093 read_unlock(&vcc_sklist_lock);
36094 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36095 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36096 lvcc->stats.x.aal5.service_stream++;
36097 printk(KERN_ERR DEV_LABEL "(itf %d): Got AAL5 stream "
36098 "PDU on VCI %d!\n", lanai->number, vci);
36099 @@ -1699,7 +1699,7 @@ static int handle_service(struct lanai_dev *lanai, u32 s)
36100 return 0;
36101 }
36102 DPRINTK("got rx crc error on vci %d\n", vci);
36103 - atomic_inc(&lvcc->rx.atmvcc->stats->rx_err);
36104 + atomic_inc_unchecked(&lvcc->rx.atmvcc->stats->rx_err);
36105 lvcc->stats.x.aal5.service_rxcrc++;
36106 lvcc->rx.buf.ptr = &lvcc->rx.buf.start[SERVICE_GET_END(s) * 4];
36107 cardvcc_write(lvcc, SERVICE_GET_END(s), vcc_rxreadptr);
36108 diff --git a/drivers/atm/nicstar.c b/drivers/atm/nicstar.c
36109 index 5aca5f4..ce3a6b0 100644
36110 --- a/drivers/atm/nicstar.c
36111 +++ b/drivers/atm/nicstar.c
36112 @@ -1640,7 +1640,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36113 if ((vc = (vc_map *) vcc->dev_data) == NULL) {
36114 printk("nicstar%d: vcc->dev_data == NULL on ns_send().\n",
36115 card->index);
36116 - atomic_inc(&vcc->stats->tx_err);
36117 + atomic_inc_unchecked(&vcc->stats->tx_err);
36118 dev_kfree_skb_any(skb);
36119 return -EINVAL;
36120 }
36121 @@ -1648,7 +1648,7 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36122 if (!vc->tx) {
36123 printk("nicstar%d: Trying to transmit on a non-tx VC.\n",
36124 card->index);
36125 - atomic_inc(&vcc->stats->tx_err);
36126 + atomic_inc_unchecked(&vcc->stats->tx_err);
36127 dev_kfree_skb_any(skb);
36128 return -EINVAL;
36129 }
36130 @@ -1656,14 +1656,14 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36131 if (vcc->qos.aal != ATM_AAL5 && vcc->qos.aal != ATM_AAL0) {
36132 printk("nicstar%d: Only AAL0 and AAL5 are supported.\n",
36133 card->index);
36134 - atomic_inc(&vcc->stats->tx_err);
36135 + atomic_inc_unchecked(&vcc->stats->tx_err);
36136 dev_kfree_skb_any(skb);
36137 return -EINVAL;
36138 }
36139
36140 if (skb_shinfo(skb)->nr_frags != 0) {
36141 printk("nicstar%d: No scatter-gather yet.\n", card->index);
36142 - atomic_inc(&vcc->stats->tx_err);
36143 + atomic_inc_unchecked(&vcc->stats->tx_err);
36144 dev_kfree_skb_any(skb);
36145 return -EINVAL;
36146 }
36147 @@ -1711,11 +1711,11 @@ static int ns_send(struct atm_vcc *vcc, struct sk_buff *skb)
36148 }
36149
36150 if (push_scqe(card, vc, scq, &scqe, skb) != 0) {
36151 - atomic_inc(&vcc->stats->tx_err);
36152 + atomic_inc_unchecked(&vcc->stats->tx_err);
36153 dev_kfree_skb_any(skb);
36154 return -EIO;
36155 }
36156 - atomic_inc(&vcc->stats->tx);
36157 + atomic_inc_unchecked(&vcc->stats->tx);
36158
36159 return 0;
36160 }
36161 @@ -2032,14 +2032,14 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36162 printk
36163 ("nicstar%d: Can't allocate buffers for aal0.\n",
36164 card->index);
36165 - atomic_add(i, &vcc->stats->rx_drop);
36166 + atomic_add_unchecked(i, &vcc->stats->rx_drop);
36167 break;
36168 }
36169 if (!atm_charge(vcc, sb->truesize)) {
36170 RXPRINTK
36171 ("nicstar%d: atm_charge() dropped aal0 packets.\n",
36172 card->index);
36173 - atomic_add(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36174 + atomic_add_unchecked(i - 1, &vcc->stats->rx_drop); /* already increased by 1 */
36175 dev_kfree_skb_any(sb);
36176 break;
36177 }
36178 @@ -2054,7 +2054,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36179 ATM_SKB(sb)->vcc = vcc;
36180 __net_timestamp(sb);
36181 vcc->push(vcc, sb);
36182 - atomic_inc(&vcc->stats->rx);
36183 + atomic_inc_unchecked(&vcc->stats->rx);
36184 cell += ATM_CELL_PAYLOAD;
36185 }
36186
36187 @@ -2071,7 +2071,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36188 if (iovb == NULL) {
36189 printk("nicstar%d: Out of iovec buffers.\n",
36190 card->index);
36191 - atomic_inc(&vcc->stats->rx_drop);
36192 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36193 recycle_rx_buf(card, skb);
36194 return;
36195 }
36196 @@ -2095,7 +2095,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36197 small or large buffer itself. */
36198 } else if (NS_PRV_IOVCNT(iovb) >= NS_MAX_IOVECS) {
36199 printk("nicstar%d: received too big AAL5 SDU.\n", card->index);
36200 - atomic_inc(&vcc->stats->rx_err);
36201 + atomic_inc_unchecked(&vcc->stats->rx_err);
36202 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36203 NS_MAX_IOVECS);
36204 NS_PRV_IOVCNT(iovb) = 0;
36205 @@ -2115,7 +2115,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36206 ("nicstar%d: Expected a small buffer, and this is not one.\n",
36207 card->index);
36208 which_list(card, skb);
36209 - atomic_inc(&vcc->stats->rx_err);
36210 + atomic_inc_unchecked(&vcc->stats->rx_err);
36211 recycle_rx_buf(card, skb);
36212 vc->rx_iov = NULL;
36213 recycle_iov_buf(card, iovb);
36214 @@ -2128,7 +2128,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36215 ("nicstar%d: Expected a large buffer, and this is not one.\n",
36216 card->index);
36217 which_list(card, skb);
36218 - atomic_inc(&vcc->stats->rx_err);
36219 + atomic_inc_unchecked(&vcc->stats->rx_err);
36220 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36221 NS_PRV_IOVCNT(iovb));
36222 vc->rx_iov = NULL;
36223 @@ -2151,7 +2151,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36224 printk(" - PDU size mismatch.\n");
36225 else
36226 printk(".\n");
36227 - atomic_inc(&vcc->stats->rx_err);
36228 + atomic_inc_unchecked(&vcc->stats->rx_err);
36229 recycle_iovec_rx_bufs(card, (struct iovec *)iovb->data,
36230 NS_PRV_IOVCNT(iovb));
36231 vc->rx_iov = NULL;
36232 @@ -2165,7 +2165,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36233 /* skb points to a small buffer */
36234 if (!atm_charge(vcc, skb->truesize)) {
36235 push_rxbufs(card, skb);
36236 - atomic_inc(&vcc->stats->rx_drop);
36237 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36238 } else {
36239 skb_put(skb, len);
36240 dequeue_sm_buf(card, skb);
36241 @@ -2175,7 +2175,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36242 ATM_SKB(skb)->vcc = vcc;
36243 __net_timestamp(skb);
36244 vcc->push(vcc, skb);
36245 - atomic_inc(&vcc->stats->rx);
36246 + atomic_inc_unchecked(&vcc->stats->rx);
36247 }
36248 } else if (NS_PRV_IOVCNT(iovb) == 2) { /* One small plus one large buffer */
36249 struct sk_buff *sb;
36250 @@ -2186,7 +2186,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36251 if (len <= NS_SMBUFSIZE) {
36252 if (!atm_charge(vcc, sb->truesize)) {
36253 push_rxbufs(card, sb);
36254 - atomic_inc(&vcc->stats->rx_drop);
36255 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36256 } else {
36257 skb_put(sb, len);
36258 dequeue_sm_buf(card, sb);
36259 @@ -2196,7 +2196,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36260 ATM_SKB(sb)->vcc = vcc;
36261 __net_timestamp(sb);
36262 vcc->push(vcc, sb);
36263 - atomic_inc(&vcc->stats->rx);
36264 + atomic_inc_unchecked(&vcc->stats->rx);
36265 }
36266
36267 push_rxbufs(card, skb);
36268 @@ -2205,7 +2205,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36269
36270 if (!atm_charge(vcc, skb->truesize)) {
36271 push_rxbufs(card, skb);
36272 - atomic_inc(&vcc->stats->rx_drop);
36273 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36274 } else {
36275 dequeue_lg_buf(card, skb);
36276 #ifdef NS_USE_DESTRUCTORS
36277 @@ -2218,7 +2218,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36278 ATM_SKB(skb)->vcc = vcc;
36279 __net_timestamp(skb);
36280 vcc->push(vcc, skb);
36281 - atomic_inc(&vcc->stats->rx);
36282 + atomic_inc_unchecked(&vcc->stats->rx);
36283 }
36284
36285 push_rxbufs(card, sb);
36286 @@ -2239,7 +2239,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36287 printk
36288 ("nicstar%d: Out of huge buffers.\n",
36289 card->index);
36290 - atomic_inc(&vcc->stats->rx_drop);
36291 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36292 recycle_iovec_rx_bufs(card,
36293 (struct iovec *)
36294 iovb->data,
36295 @@ -2290,7 +2290,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36296 card->hbpool.count++;
36297 } else
36298 dev_kfree_skb_any(hb);
36299 - atomic_inc(&vcc->stats->rx_drop);
36300 + atomic_inc_unchecked(&vcc->stats->rx_drop);
36301 } else {
36302 /* Copy the small buffer to the huge buffer */
36303 sb = (struct sk_buff *)iov->iov_base;
36304 @@ -2327,7 +2327,7 @@ static void dequeue_rx(ns_dev * card, ns_rsqe * rsqe)
36305 #endif /* NS_USE_DESTRUCTORS */
36306 __net_timestamp(hb);
36307 vcc->push(vcc, hb);
36308 - atomic_inc(&vcc->stats->rx);
36309 + atomic_inc_unchecked(&vcc->stats->rx);
36310 }
36311 }
36312
36313 diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c
36314 index 32784d1..4a8434a 100644
36315 --- a/drivers/atm/solos-pci.c
36316 +++ b/drivers/atm/solos-pci.c
36317 @@ -838,7 +838,7 @@ void solos_bh(unsigned long card_arg)
36318 }
36319 atm_charge(vcc, skb->truesize);
36320 vcc->push(vcc, skb);
36321 - atomic_inc(&vcc->stats->rx);
36322 + atomic_inc_unchecked(&vcc->stats->rx);
36323 break;
36324
36325 case PKT_STATUS:
36326 @@ -1116,7 +1116,7 @@ static uint32_t fpga_tx(struct solos_card *card)
36327 vcc = SKB_CB(oldskb)->vcc;
36328
36329 if (vcc) {
36330 - atomic_inc(&vcc->stats->tx);
36331 + atomic_inc_unchecked(&vcc->stats->tx);
36332 solos_pop(vcc, oldskb);
36333 } else {
36334 dev_kfree_skb_irq(oldskb);
36335 diff --git a/drivers/atm/suni.c b/drivers/atm/suni.c
36336 index 0215934..ce9f5b1 100644
36337 --- a/drivers/atm/suni.c
36338 +++ b/drivers/atm/suni.c
36339 @@ -49,8 +49,8 @@ static DEFINE_SPINLOCK(sunis_lock);
36340
36341
36342 #define ADD_LIMITED(s,v) \
36343 - atomic_add((v),&stats->s); \
36344 - if (atomic_read(&stats->s) < 0) atomic_set(&stats->s,INT_MAX);
36345 + atomic_add_unchecked((v),&stats->s); \
36346 + if (atomic_read_unchecked(&stats->s) < 0) atomic_set_unchecked(&stats->s,INT_MAX);
36347
36348
36349 static void suni_hz(unsigned long from_timer)
36350 diff --git a/drivers/atm/uPD98402.c b/drivers/atm/uPD98402.c
36351 index 5120a96..e2572bd 100644
36352 --- a/drivers/atm/uPD98402.c
36353 +++ b/drivers/atm/uPD98402.c
36354 @@ -42,7 +42,7 @@ static int fetch_stats(struct atm_dev *dev,struct sonet_stats __user *arg,int ze
36355 struct sonet_stats tmp;
36356 int error = 0;
36357
36358 - atomic_add(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36359 + atomic_add_unchecked(GET(HECCT),&PRIV(dev)->sonet_stats.uncorr_hcs);
36360 sonet_copy_stats(&PRIV(dev)->sonet_stats,&tmp);
36361 if (arg) error = copy_to_user(arg,&tmp,sizeof(tmp));
36362 if (zero && !error) {
36363 @@ -161,9 +161,9 @@ static int uPD98402_ioctl(struct atm_dev *dev,unsigned int cmd,void __user *arg)
36364
36365
36366 #define ADD_LIMITED(s,v) \
36367 - { atomic_add(GET(v),&PRIV(dev)->sonet_stats.s); \
36368 - if (atomic_read(&PRIV(dev)->sonet_stats.s) < 0) \
36369 - atomic_set(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36370 + { atomic_add_unchecked(GET(v),&PRIV(dev)->sonet_stats.s); \
36371 + if (atomic_read_unchecked(&PRIV(dev)->sonet_stats.s) < 0) \
36372 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.s,INT_MAX); }
36373
36374
36375 static void stat_event(struct atm_dev *dev)
36376 @@ -194,7 +194,7 @@ static void uPD98402_int(struct atm_dev *dev)
36377 if (reason & uPD98402_INT_PFM) stat_event(dev);
36378 if (reason & uPD98402_INT_PCO) {
36379 (void) GET(PCOCR); /* clear interrupt cause */
36380 - atomic_add(GET(HECCT),
36381 + atomic_add_unchecked(GET(HECCT),
36382 &PRIV(dev)->sonet_stats.uncorr_hcs);
36383 }
36384 if ((reason & uPD98402_INT_RFO) &&
36385 @@ -222,9 +222,9 @@ static int uPD98402_start(struct atm_dev *dev)
36386 PUT(~(uPD98402_INT_PFM | uPD98402_INT_ALM | uPD98402_INT_RFO |
36387 uPD98402_INT_LOS),PIMR); /* enable them */
36388 (void) fetch_stats(dev,NULL,1); /* clear kernel counters */
36389 - atomic_set(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36390 - atomic_set(&PRIV(dev)->sonet_stats.tx_cells,-1);
36391 - atomic_set(&PRIV(dev)->sonet_stats.rx_cells,-1);
36392 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.corr_hcs,-1);
36393 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.tx_cells,-1);
36394 + atomic_set_unchecked(&PRIV(dev)->sonet_stats.rx_cells,-1);
36395 return 0;
36396 }
36397
36398 diff --git a/drivers/atm/zatm.c b/drivers/atm/zatm.c
36399 index 969c3c2..9b72956 100644
36400 --- a/drivers/atm/zatm.c
36401 +++ b/drivers/atm/zatm.c
36402 @@ -459,7 +459,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36403 }
36404 if (!size) {
36405 dev_kfree_skb_irq(skb);
36406 - if (vcc) atomic_inc(&vcc->stats->rx_err);
36407 + if (vcc) atomic_inc_unchecked(&vcc->stats->rx_err);
36408 continue;
36409 }
36410 if (!atm_charge(vcc,skb->truesize)) {
36411 @@ -469,7 +469,7 @@ printk("dummy: 0x%08lx, 0x%08lx\n",dummy[0],dummy[1]);
36412 skb->len = size;
36413 ATM_SKB(skb)->vcc = vcc;
36414 vcc->push(vcc,skb);
36415 - atomic_inc(&vcc->stats->rx);
36416 + atomic_inc_unchecked(&vcc->stats->rx);
36417 }
36418 zout(pos & 0xffff,MTA(mbx));
36419 #if 0 /* probably a stupid idea */
36420 @@ -733,7 +733,7 @@ if (*ZATM_PRV_DSC(skb) != (uPD98401_TXPD_V | uPD98401_TXPD_DP |
36421 skb_queue_head(&zatm_vcc->backlog,skb);
36422 break;
36423 }
36424 - atomic_inc(&vcc->stats->tx);
36425 + atomic_inc_unchecked(&vcc->stats->tx);
36426 wake_up(&zatm_vcc->tx_wait);
36427 }
36428
36429 diff --git a/drivers/base/bus.c b/drivers/base/bus.c
36430 index 4c289ab..de1c333 100644
36431 --- a/drivers/base/bus.c
36432 +++ b/drivers/base/bus.c
36433 @@ -1193,7 +1193,7 @@ int subsys_interface_register(struct subsys_interface *sif)
36434 return -EINVAL;
36435
36436 mutex_lock(&subsys->p->mutex);
36437 - list_add_tail(&sif->node, &subsys->p->interfaces);
36438 + pax_list_add_tail((struct list_head *)&sif->node, &subsys->p->interfaces);
36439 if (sif->add_dev) {
36440 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36441 while ((dev = subsys_dev_iter_next(&iter)))
36442 @@ -1218,7 +1218,7 @@ void subsys_interface_unregister(struct subsys_interface *sif)
36443 subsys = sif->subsys;
36444
36445 mutex_lock(&subsys->p->mutex);
36446 - list_del_init(&sif->node);
36447 + pax_list_del_init((struct list_head *)&sif->node);
36448 if (sif->remove_dev) {
36449 subsys_dev_iter_init(&iter, subsys, NULL, NULL);
36450 while ((dev = subsys_dev_iter_next(&iter)))
36451 diff --git a/drivers/base/devtmpfs.c b/drivers/base/devtmpfs.c
36452 index 7413d06..79155fa 100644
36453 --- a/drivers/base/devtmpfs.c
36454 +++ b/drivers/base/devtmpfs.c
36455 @@ -354,7 +354,7 @@ int devtmpfs_mount(const char *mntdir)
36456 if (!thread)
36457 return 0;
36458
36459 - err = sys_mount("devtmpfs", (char *)mntdir, "devtmpfs", MS_SILENT, NULL);
36460 + err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)mntdir, (char __force_user *)"devtmpfs", MS_SILENT, NULL);
36461 if (err)
36462 printk(KERN_INFO "devtmpfs: error mounting %i\n", err);
36463 else
36464 @@ -380,11 +380,11 @@ static int devtmpfsd(void *p)
36465 *err = sys_unshare(CLONE_NEWNS);
36466 if (*err)
36467 goto out;
36468 - *err = sys_mount("devtmpfs", "/", "devtmpfs", MS_SILENT, options);
36469 + *err = sys_mount((char __force_user *)"devtmpfs", (char __force_user *)"/", (char __force_user *)"devtmpfs", MS_SILENT, (char __force_user *)options);
36470 if (*err)
36471 goto out;
36472 - sys_chdir("/.."); /* will traverse into overmounted root */
36473 - sys_chroot(".");
36474 + sys_chdir((char __force_user *)"/.."); /* will traverse into overmounted root */
36475 + sys_chroot((char __force_user *)".");
36476 complete(&setup_done);
36477 while (1) {
36478 spin_lock(&req_lock);
36479 diff --git a/drivers/base/node.c b/drivers/base/node.c
36480 index bc9f43b..29703b8 100644
36481 --- a/drivers/base/node.c
36482 +++ b/drivers/base/node.c
36483 @@ -620,7 +620,7 @@ static ssize_t print_nodes_state(enum node_states state, char *buf)
36484 struct node_attr {
36485 struct device_attribute attr;
36486 enum node_states state;
36487 -};
36488 +} __do_const;
36489
36490 static ssize_t show_node_state(struct device *dev,
36491 struct device_attribute *attr, char *buf)
36492 diff --git a/drivers/base/power/domain.c b/drivers/base/power/domain.c
36493 index bfb8955..42c9b9a 100644
36494 --- a/drivers/base/power/domain.c
36495 +++ b/drivers/base/power/domain.c
36496 @@ -1850,7 +1850,7 @@ int pm_genpd_attach_cpuidle(struct generic_pm_domain *genpd, int state)
36497 {
36498 struct cpuidle_driver *cpuidle_drv;
36499 struct gpd_cpu_data *cpu_data;
36500 - struct cpuidle_state *idle_state;
36501 + cpuidle_state_no_const *idle_state;
36502 int ret = 0;
36503
36504 if (IS_ERR_OR_NULL(genpd) || state < 0)
36505 @@ -1918,7 +1918,7 @@ int pm_genpd_name_attach_cpuidle(const char *name, int state)
36506 int pm_genpd_detach_cpuidle(struct generic_pm_domain *genpd)
36507 {
36508 struct gpd_cpu_data *cpu_data;
36509 - struct cpuidle_state *idle_state;
36510 + cpuidle_state_no_const *idle_state;
36511 int ret = 0;
36512
36513 if (IS_ERR_OR_NULL(genpd))
36514 diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
36515 index 03e089a..0e9560c 100644
36516 --- a/drivers/base/power/sysfs.c
36517 +++ b/drivers/base/power/sysfs.c
36518 @@ -185,7 +185,7 @@ static ssize_t rtpm_status_show(struct device *dev,
36519 return -EIO;
36520 }
36521 }
36522 - return sprintf(buf, p);
36523 + return sprintf(buf, "%s", p);
36524 }
36525
36526 static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
36527 diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
36528 index 2d56f41..8830f19 100644
36529 --- a/drivers/base/power/wakeup.c
36530 +++ b/drivers/base/power/wakeup.c
36531 @@ -29,14 +29,14 @@ bool events_check_enabled __read_mostly;
36532 * They need to be modified together atomically, so it's better to use one
36533 * atomic variable to hold them both.
36534 */
36535 -static atomic_t combined_event_count = ATOMIC_INIT(0);
36536 +static atomic_unchecked_t combined_event_count = ATOMIC_INIT(0);
36537
36538 #define IN_PROGRESS_BITS (sizeof(int) * 4)
36539 #define MAX_IN_PROGRESS ((1 << IN_PROGRESS_BITS) - 1)
36540
36541 static void split_counters(unsigned int *cnt, unsigned int *inpr)
36542 {
36543 - unsigned int comb = atomic_read(&combined_event_count);
36544 + unsigned int comb = atomic_read_unchecked(&combined_event_count);
36545
36546 *cnt = (comb >> IN_PROGRESS_BITS);
36547 *inpr = comb & MAX_IN_PROGRESS;
36548 @@ -395,7 +395,7 @@ static void wakeup_source_activate(struct wakeup_source *ws)
36549 ws->start_prevent_time = ws->last_time;
36550
36551 /* Increment the counter of events in progress. */
36552 - cec = atomic_inc_return(&combined_event_count);
36553 + cec = atomic_inc_return_unchecked(&combined_event_count);
36554
36555 trace_wakeup_source_activate(ws->name, cec);
36556 }
36557 @@ -521,7 +521,7 @@ static void wakeup_source_deactivate(struct wakeup_source *ws)
36558 * Increment the counter of registered wakeup events and decrement the
36559 * couter of wakeup events in progress simultaneously.
36560 */
36561 - cec = atomic_add_return(MAX_IN_PROGRESS, &combined_event_count);
36562 + cec = atomic_add_return_unchecked(MAX_IN_PROGRESS, &combined_event_count);
36563 trace_wakeup_source_deactivate(ws->name, cec);
36564
36565 split_counters(&cnt, &inpr);
36566 diff --git a/drivers/base/syscore.c b/drivers/base/syscore.c
36567 index e8d11b6..7b1b36f 100644
36568 --- a/drivers/base/syscore.c
36569 +++ b/drivers/base/syscore.c
36570 @@ -21,7 +21,7 @@ static DEFINE_MUTEX(syscore_ops_lock);
36571 void register_syscore_ops(struct syscore_ops *ops)
36572 {
36573 mutex_lock(&syscore_ops_lock);
36574 - list_add_tail(&ops->node, &syscore_ops_list);
36575 + pax_list_add_tail((struct list_head *)&ops->node, &syscore_ops_list);
36576 mutex_unlock(&syscore_ops_lock);
36577 }
36578 EXPORT_SYMBOL_GPL(register_syscore_ops);
36579 @@ -33,7 +33,7 @@ EXPORT_SYMBOL_GPL(register_syscore_ops);
36580 void unregister_syscore_ops(struct syscore_ops *ops)
36581 {
36582 mutex_lock(&syscore_ops_lock);
36583 - list_del(&ops->node);
36584 + pax_list_del((struct list_head *)&ops->node);
36585 mutex_unlock(&syscore_ops_lock);
36586 }
36587 EXPORT_SYMBOL_GPL(unregister_syscore_ops);
36588 diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
36589 index edfa251..1734d4d 100644
36590 --- a/drivers/block/cciss.c
36591 +++ b/drivers/block/cciss.c
36592 @@ -3011,7 +3011,7 @@ static void start_io(ctlr_info_t *h)
36593 while (!list_empty(&h->reqQ)) {
36594 c = list_entry(h->reqQ.next, CommandList_struct, list);
36595 /* can't do anything if fifo is full */
36596 - if ((h->access.fifo_full(h))) {
36597 + if ((h->access->fifo_full(h))) {
36598 dev_warn(&h->pdev->dev, "fifo full\n");
36599 break;
36600 }
36601 @@ -3021,7 +3021,7 @@ static void start_io(ctlr_info_t *h)
36602 h->Qdepth--;
36603
36604 /* Tell the controller execute command */
36605 - h->access.submit_command(h, c);
36606 + h->access->submit_command(h, c);
36607
36608 /* Put job onto the completed Q */
36609 addQ(&h->cmpQ, c);
36610 @@ -3447,17 +3447,17 @@ startio:
36611
36612 static inline unsigned long get_next_completion(ctlr_info_t *h)
36613 {
36614 - return h->access.command_completed(h);
36615 + return h->access->command_completed(h);
36616 }
36617
36618 static inline int interrupt_pending(ctlr_info_t *h)
36619 {
36620 - return h->access.intr_pending(h);
36621 + return h->access->intr_pending(h);
36622 }
36623
36624 static inline long interrupt_not_for_us(ctlr_info_t *h)
36625 {
36626 - return ((h->access.intr_pending(h) == 0) ||
36627 + return ((h->access->intr_pending(h) == 0) ||
36628 (h->interrupts_enabled == 0));
36629 }
36630
36631 @@ -3490,7 +3490,7 @@ static inline u32 next_command(ctlr_info_t *h)
36632 u32 a;
36633
36634 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
36635 - return h->access.command_completed(h);
36636 + return h->access->command_completed(h);
36637
36638 if ((*(h->reply_pool_head) & 1) == (h->reply_pool_wraparound)) {
36639 a = *(h->reply_pool_head); /* Next cmd in ring buffer */
36640 @@ -4047,7 +4047,7 @@ static void cciss_put_controller_into_performant_mode(ctlr_info_t *h)
36641 trans_support & CFGTBL_Trans_use_short_tags);
36642
36643 /* Change the access methods to the performant access methods */
36644 - h->access = SA5_performant_access;
36645 + h->access = &SA5_performant_access;
36646 h->transMethod = CFGTBL_Trans_Performant;
36647
36648 return;
36649 @@ -4327,7 +4327,7 @@ static int cciss_pci_init(ctlr_info_t *h)
36650 if (prod_index < 0)
36651 return -ENODEV;
36652 h->product_name = products[prod_index].product_name;
36653 - h->access = *(products[prod_index].access);
36654 + h->access = products[prod_index].access;
36655
36656 if (cciss_board_disabled(h)) {
36657 dev_warn(&h->pdev->dev, "controller appears to be disabled\n");
36658 @@ -5059,7 +5059,7 @@ reinit_after_soft_reset:
36659 }
36660
36661 /* make sure the board interrupts are off */
36662 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36663 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36664 rc = cciss_request_irq(h, do_cciss_msix_intr, do_cciss_intx);
36665 if (rc)
36666 goto clean2;
36667 @@ -5109,7 +5109,7 @@ reinit_after_soft_reset:
36668 * fake ones to scoop up any residual completions.
36669 */
36670 spin_lock_irqsave(&h->lock, flags);
36671 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36672 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36673 spin_unlock_irqrestore(&h->lock, flags);
36674 free_irq(h->intr[h->intr_mode], h);
36675 rc = cciss_request_irq(h, cciss_msix_discard_completions,
36676 @@ -5129,9 +5129,9 @@ reinit_after_soft_reset:
36677 dev_info(&h->pdev->dev, "Board READY.\n");
36678 dev_info(&h->pdev->dev,
36679 "Waiting for stale completions to drain.\n");
36680 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36681 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36682 msleep(10000);
36683 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36684 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36685
36686 rc = controller_reset_failed(h->cfgtable);
36687 if (rc)
36688 @@ -5154,7 +5154,7 @@ reinit_after_soft_reset:
36689 cciss_scsi_setup(h);
36690
36691 /* Turn the interrupts on so we can service requests */
36692 - h->access.set_intr_mask(h, CCISS_INTR_ON);
36693 + h->access->set_intr_mask(h, CCISS_INTR_ON);
36694
36695 /* Get the firmware version */
36696 inq_buff = kzalloc(sizeof(InquiryData_struct), GFP_KERNEL);
36697 @@ -5226,7 +5226,7 @@ static void cciss_shutdown(struct pci_dev *pdev)
36698 kfree(flush_buf);
36699 if (return_code != IO_OK)
36700 dev_warn(&h->pdev->dev, "Error flushing cache\n");
36701 - h->access.set_intr_mask(h, CCISS_INTR_OFF);
36702 + h->access->set_intr_mask(h, CCISS_INTR_OFF);
36703 free_irq(h->intr[h->intr_mode], h);
36704 }
36705
36706 diff --git a/drivers/block/cciss.h b/drivers/block/cciss.h
36707 index 7fda30e..eb5dfe0 100644
36708 --- a/drivers/block/cciss.h
36709 +++ b/drivers/block/cciss.h
36710 @@ -101,7 +101,7 @@ struct ctlr_info
36711 /* information about each logical volume */
36712 drive_info_struct *drv[CISS_MAX_LUN];
36713
36714 - struct access_method access;
36715 + struct access_method *access;
36716
36717 /* queue and queue Info */
36718 struct list_head reqQ;
36719 diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
36720 index 2b94403..fd6ad1f 100644
36721 --- a/drivers/block/cpqarray.c
36722 +++ b/drivers/block/cpqarray.c
36723 @@ -404,7 +404,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36724 if (register_blkdev(COMPAQ_SMART2_MAJOR+i, hba[i]->devname)) {
36725 goto Enomem4;
36726 }
36727 - hba[i]->access.set_intr_mask(hba[i], 0);
36728 + hba[i]->access->set_intr_mask(hba[i], 0);
36729 if (request_irq(hba[i]->intr, do_ida_intr,
36730 IRQF_DISABLED|IRQF_SHARED, hba[i]->devname, hba[i]))
36731 {
36732 @@ -459,7 +459,7 @@ static int cpqarray_register_ctlr(int i, struct pci_dev *pdev)
36733 add_timer(&hba[i]->timer);
36734
36735 /* Enable IRQ now that spinlock and rate limit timer are set up */
36736 - hba[i]->access.set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36737 + hba[i]->access->set_intr_mask(hba[i], FIFO_NOT_EMPTY);
36738
36739 for(j=0; j<NWD; j++) {
36740 struct gendisk *disk = ida_gendisk[i][j];
36741 @@ -694,7 +694,7 @@ DBGINFO(
36742 for(i=0; i<NR_PRODUCTS; i++) {
36743 if (board_id == products[i].board_id) {
36744 c->product_name = products[i].product_name;
36745 - c->access = *(products[i].access);
36746 + c->access = products[i].access;
36747 break;
36748 }
36749 }
36750 @@ -792,7 +792,7 @@ static int cpqarray_eisa_detect(void)
36751 hba[ctlr]->intr = intr;
36752 sprintf(hba[ctlr]->devname, "ida%d", nr_ctlr);
36753 hba[ctlr]->product_name = products[j].product_name;
36754 - hba[ctlr]->access = *(products[j].access);
36755 + hba[ctlr]->access = products[j].access;
36756 hba[ctlr]->ctlr = ctlr;
36757 hba[ctlr]->board_id = board_id;
36758 hba[ctlr]->pci_dev = NULL; /* not PCI */
36759 @@ -978,7 +978,7 @@ static void start_io(ctlr_info_t *h)
36760
36761 while((c = h->reqQ) != NULL) {
36762 /* Can't do anything if we're busy */
36763 - if (h->access.fifo_full(h) == 0)
36764 + if (h->access->fifo_full(h) == 0)
36765 return;
36766
36767 /* Get the first entry from the request Q */
36768 @@ -986,7 +986,7 @@ static void start_io(ctlr_info_t *h)
36769 h->Qdepth--;
36770
36771 /* Tell the controller to do our bidding */
36772 - h->access.submit_command(h, c);
36773 + h->access->submit_command(h, c);
36774
36775 /* Get onto the completion Q */
36776 addQ(&h->cmpQ, c);
36777 @@ -1048,7 +1048,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36778 unsigned long flags;
36779 __u32 a,a1;
36780
36781 - istat = h->access.intr_pending(h);
36782 + istat = h->access->intr_pending(h);
36783 /* Is this interrupt for us? */
36784 if (istat == 0)
36785 return IRQ_NONE;
36786 @@ -1059,7 +1059,7 @@ static irqreturn_t do_ida_intr(int irq, void *dev_id)
36787 */
36788 spin_lock_irqsave(IDA_LOCK(h->ctlr), flags);
36789 if (istat & FIFO_NOT_EMPTY) {
36790 - while((a = h->access.command_completed(h))) {
36791 + while((a = h->access->command_completed(h))) {
36792 a1 = a; a &= ~3;
36793 if ((c = h->cmpQ) == NULL)
36794 {
36795 @@ -1448,11 +1448,11 @@ static int sendcmd(
36796 /*
36797 * Disable interrupt
36798 */
36799 - info_p->access.set_intr_mask(info_p, 0);
36800 + info_p->access->set_intr_mask(info_p, 0);
36801 /* Make sure there is room in the command FIFO */
36802 /* Actually it should be completely empty at this time. */
36803 for (i = 200000; i > 0; i--) {
36804 - temp = info_p->access.fifo_full(info_p);
36805 + temp = info_p->access->fifo_full(info_p);
36806 if (temp != 0) {
36807 break;
36808 }
36809 @@ -1465,7 +1465,7 @@ DBG(
36810 /*
36811 * Send the cmd
36812 */
36813 - info_p->access.submit_command(info_p, c);
36814 + info_p->access->submit_command(info_p, c);
36815 complete = pollcomplete(ctlr);
36816
36817 pci_unmap_single(info_p->pci_dev, (dma_addr_t) c->req.sg[0].addr,
36818 @@ -1548,9 +1548,9 @@ static int revalidate_allvol(ctlr_info_t *host)
36819 * we check the new geometry. Then turn interrupts back on when
36820 * we're done.
36821 */
36822 - host->access.set_intr_mask(host, 0);
36823 + host->access->set_intr_mask(host, 0);
36824 getgeometry(ctlr);
36825 - host->access.set_intr_mask(host, FIFO_NOT_EMPTY);
36826 + host->access->set_intr_mask(host, FIFO_NOT_EMPTY);
36827
36828 for(i=0; i<NWD; i++) {
36829 struct gendisk *disk = ida_gendisk[ctlr][i];
36830 @@ -1590,7 +1590,7 @@ static int pollcomplete(int ctlr)
36831 /* Wait (up to 2 seconds) for a command to complete */
36832
36833 for (i = 200000; i > 0; i--) {
36834 - done = hba[ctlr]->access.command_completed(hba[ctlr]);
36835 + done = hba[ctlr]->access->command_completed(hba[ctlr]);
36836 if (done == 0) {
36837 udelay(10); /* a short fixed delay */
36838 } else
36839 diff --git a/drivers/block/cpqarray.h b/drivers/block/cpqarray.h
36840 index be73e9d..7fbf140 100644
36841 --- a/drivers/block/cpqarray.h
36842 +++ b/drivers/block/cpqarray.h
36843 @@ -99,7 +99,7 @@ struct ctlr_info {
36844 drv_info_t drv[NWD];
36845 struct proc_dir_entry *proc;
36846
36847 - struct access_method access;
36848 + struct access_method *access;
36849
36850 cmdlist_t *reqQ;
36851 cmdlist_t *cmpQ;
36852 diff --git a/drivers/block/drbd/drbd_int.h b/drivers/block/drbd/drbd_int.h
36853 index 2d7f608..11245fe 100644
36854 --- a/drivers/block/drbd/drbd_int.h
36855 +++ b/drivers/block/drbd/drbd_int.h
36856 @@ -582,7 +582,7 @@ struct drbd_epoch {
36857 struct drbd_tconn *tconn;
36858 struct list_head list;
36859 unsigned int barrier_nr;
36860 - atomic_t epoch_size; /* increased on every request added. */
36861 + atomic_unchecked_t epoch_size; /* increased on every request added. */
36862 atomic_t active; /* increased on every req. added, and dec on every finished. */
36863 unsigned long flags;
36864 };
36865 @@ -1022,7 +1022,7 @@ struct drbd_conf {
36866 unsigned int al_tr_number;
36867 int al_tr_cycle;
36868 wait_queue_head_t seq_wait;
36869 - atomic_t packet_seq;
36870 + atomic_unchecked_t packet_seq;
36871 unsigned int peer_seq;
36872 spinlock_t peer_seq_lock;
36873 unsigned int minor;
36874 @@ -1572,7 +1572,7 @@ static inline int drbd_setsockopt(struct socket *sock, int level, int optname,
36875 char __user *uoptval;
36876 int err;
36877
36878 - uoptval = (char __user __force *)optval;
36879 + uoptval = (char __force_user *)optval;
36880
36881 set_fs(KERNEL_DS);
36882 if (level == SOL_SOCKET)
36883 diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c
36884 index 55635ed..40e837c 100644
36885 --- a/drivers/block/drbd/drbd_main.c
36886 +++ b/drivers/block/drbd/drbd_main.c
36887 @@ -1317,7 +1317,7 @@ static int _drbd_send_ack(struct drbd_conf *mdev, enum drbd_packet cmd,
36888 p->sector = sector;
36889 p->block_id = block_id;
36890 p->blksize = blksize;
36891 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36892 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36893 return drbd_send_command(mdev, sock, cmd, sizeof(*p), NULL, 0);
36894 }
36895
36896 @@ -1619,7 +1619,7 @@ int drbd_send_dblock(struct drbd_conf *mdev, struct drbd_request *req)
36897 return -EIO;
36898 p->sector = cpu_to_be64(req->i.sector);
36899 p->block_id = (unsigned long)req;
36900 - p->seq_num = cpu_to_be32(atomic_inc_return(&mdev->packet_seq));
36901 + p->seq_num = cpu_to_be32(atomic_inc_return_unchecked(&mdev->packet_seq));
36902 dp_flags = bio_flags_to_wire(mdev, req->master_bio->bi_rw);
36903 if (mdev->state.conn >= C_SYNC_SOURCE &&
36904 mdev->state.conn <= C_PAUSED_SYNC_T)
36905 @@ -2574,8 +2574,8 @@ void conn_destroy(struct kref *kref)
36906 {
36907 struct drbd_tconn *tconn = container_of(kref, struct drbd_tconn, kref);
36908
36909 - if (atomic_read(&tconn->current_epoch->epoch_size) != 0)
36910 - conn_err(tconn, "epoch_size:%d\n", atomic_read(&tconn->current_epoch->epoch_size));
36911 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size) != 0)
36912 + conn_err(tconn, "epoch_size:%d\n", atomic_read_unchecked(&tconn->current_epoch->epoch_size));
36913 kfree(tconn->current_epoch);
36914
36915 idr_destroy(&tconn->volumes);
36916 diff --git a/drivers/block/drbd/drbd_nl.c b/drivers/block/drbd/drbd_nl.c
36917 index 8cc1e64..ba7ffa9 100644
36918 --- a/drivers/block/drbd/drbd_nl.c
36919 +++ b/drivers/block/drbd/drbd_nl.c
36920 @@ -3440,7 +3440,7 @@ out:
36921
36922 void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36923 {
36924 - static atomic_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36925 + static atomic_unchecked_t drbd_genl_seq = ATOMIC_INIT(2); /* two. */
36926 struct sk_buff *msg;
36927 struct drbd_genlmsghdr *d_out;
36928 unsigned seq;
36929 @@ -3453,7 +3453,7 @@ void drbd_bcast_event(struct drbd_conf *mdev, const struct sib_info *sib)
36930 return;
36931 }
36932
36933 - seq = atomic_inc_return(&drbd_genl_seq);
36934 + seq = atomic_inc_return_unchecked(&drbd_genl_seq);
36935 msg = genlmsg_new(NLMSG_GOODSIZE, GFP_NOIO);
36936 if (!msg)
36937 goto failed;
36938 diff --git a/drivers/block/drbd/drbd_receiver.c b/drivers/block/drbd/drbd_receiver.c
36939 index cc29cd3..d4b058b 100644
36940 --- a/drivers/block/drbd/drbd_receiver.c
36941 +++ b/drivers/block/drbd/drbd_receiver.c
36942 @@ -834,7 +834,7 @@ int drbd_connected(struct drbd_conf *mdev)
36943 {
36944 int err;
36945
36946 - atomic_set(&mdev->packet_seq, 0);
36947 + atomic_set_unchecked(&mdev->packet_seq, 0);
36948 mdev->peer_seq = 0;
36949
36950 mdev->state_mutex = mdev->tconn->agreed_pro_version < 100 ?
36951 @@ -1193,7 +1193,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36952 do {
36953 next_epoch = NULL;
36954
36955 - epoch_size = atomic_read(&epoch->epoch_size);
36956 + epoch_size = atomic_read_unchecked(&epoch->epoch_size);
36957
36958 switch (ev & ~EV_CLEANUP) {
36959 case EV_PUT:
36960 @@ -1233,7 +1233,7 @@ static enum finish_epoch drbd_may_finish_epoch(struct drbd_tconn *tconn,
36961 rv = FE_DESTROYED;
36962 } else {
36963 epoch->flags = 0;
36964 - atomic_set(&epoch->epoch_size, 0);
36965 + atomic_set_unchecked(&epoch->epoch_size, 0);
36966 /* atomic_set(&epoch->active, 0); is already zero */
36967 if (rv == FE_STILL_LIVE)
36968 rv = FE_RECYCLED;
36969 @@ -1451,7 +1451,7 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36970 conn_wait_active_ee_empty(tconn);
36971 drbd_flush(tconn);
36972
36973 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36974 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36975 epoch = kmalloc(sizeof(struct drbd_epoch), GFP_NOIO);
36976 if (epoch)
36977 break;
36978 @@ -1464,11 +1464,11 @@ static int receive_Barrier(struct drbd_tconn *tconn, struct packet_info *pi)
36979 }
36980
36981 epoch->flags = 0;
36982 - atomic_set(&epoch->epoch_size, 0);
36983 + atomic_set_unchecked(&epoch->epoch_size, 0);
36984 atomic_set(&epoch->active, 0);
36985
36986 spin_lock(&tconn->epoch_lock);
36987 - if (atomic_read(&tconn->current_epoch->epoch_size)) {
36988 + if (atomic_read_unchecked(&tconn->current_epoch->epoch_size)) {
36989 list_add(&epoch->list, &tconn->current_epoch->list);
36990 tconn->current_epoch = epoch;
36991 tconn->epochs++;
36992 @@ -2172,7 +2172,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
36993
36994 err = wait_for_and_update_peer_seq(mdev, peer_seq);
36995 drbd_send_ack_dp(mdev, P_NEG_ACK, p, pi->size);
36996 - atomic_inc(&tconn->current_epoch->epoch_size);
36997 + atomic_inc_unchecked(&tconn->current_epoch->epoch_size);
36998 err2 = drbd_drain_block(mdev, pi->size);
36999 if (!err)
37000 err = err2;
37001 @@ -2206,7 +2206,7 @@ static int receive_Data(struct drbd_tconn *tconn, struct packet_info *pi)
37002
37003 spin_lock(&tconn->epoch_lock);
37004 peer_req->epoch = tconn->current_epoch;
37005 - atomic_inc(&peer_req->epoch->epoch_size);
37006 + atomic_inc_unchecked(&peer_req->epoch->epoch_size);
37007 atomic_inc(&peer_req->epoch->active);
37008 spin_unlock(&tconn->epoch_lock);
37009
37010 @@ -4347,7 +4347,7 @@ struct data_cmd {
37011 int expect_payload;
37012 size_t pkt_size;
37013 int (*fn)(struct drbd_tconn *, struct packet_info *);
37014 -};
37015 +} __do_const;
37016
37017 static struct data_cmd drbd_cmd_handler[] = {
37018 [P_DATA] = { 1, sizeof(struct p_data), receive_Data },
37019 @@ -4467,7 +4467,7 @@ static void conn_disconnect(struct drbd_tconn *tconn)
37020 if (!list_empty(&tconn->current_epoch->list))
37021 conn_err(tconn, "ASSERTION FAILED: tconn->current_epoch->list not empty\n");
37022 /* ok, no more ee's on the fly, it is safe to reset the epoch_size */
37023 - atomic_set(&tconn->current_epoch->epoch_size, 0);
37024 + atomic_set_unchecked(&tconn->current_epoch->epoch_size, 0);
37025 tconn->send.seen_any_write_yet = false;
37026
37027 conn_info(tconn, "Connection closed\n");
37028 @@ -5223,7 +5223,7 @@ static int tconn_finish_peer_reqs(struct drbd_tconn *tconn)
37029 struct asender_cmd {
37030 size_t pkt_size;
37031 int (*fn)(struct drbd_tconn *tconn, struct packet_info *);
37032 -};
37033 +} __do_const;
37034
37035 static struct asender_cmd asender_tbl[] = {
37036 [P_PING] = { 0, got_Ping },
37037 diff --git a/drivers/block/loop.c b/drivers/block/loop.c
37038 index c8dac73..1800093 100644
37039 --- a/drivers/block/loop.c
37040 +++ b/drivers/block/loop.c
37041 @@ -232,7 +232,7 @@ static int __do_lo_send_write(struct file *file,
37042
37043 file_start_write(file);
37044 set_fs(get_ds());
37045 - bw = file->f_op->write(file, buf, len, &pos);
37046 + bw = file->f_op->write(file, (const char __force_user *)buf, len, &pos);
37047 set_fs(old_fs);
37048 file_end_write(file);
37049 if (likely(bw == len))
37050 diff --git a/drivers/block/pktcdvd.c b/drivers/block/pktcdvd.c
37051 index 5618847..5a46f3b 100644
37052 --- a/drivers/block/pktcdvd.c
37053 +++ b/drivers/block/pktcdvd.c
37054 @@ -108,7 +108,7 @@ static int pkt_seq_show(struct seq_file *m, void *p);
37055
37056 static sector_t get_zone(sector_t sector, struct pktcdvd_device *pd)
37057 {
37058 - return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1);
37059 + return (sector + pd->offset) & ~(sector_t)(pd->settings.size - 1UL);
37060 }
37061
37062 /*
37063 @@ -1897,7 +1897,7 @@ static noinline_for_stack int pkt_probe_settings(struct pktcdvd_device *pd)
37064 return -EROFS;
37065 }
37066 pd->settings.fp = ti.fp;
37067 - pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1);
37068 + pd->offset = (be32_to_cpu(ti.track_start) << 2) & (pd->settings.size - 1UL);
37069
37070 if (ti.nwa_v) {
37071 pd->nwa = be32_to_cpu(ti.next_writable);
37072 diff --git a/drivers/bluetooth/btwilink.c b/drivers/bluetooth/btwilink.c
37073 index 60abf59..80789e1 100644
37074 --- a/drivers/bluetooth/btwilink.c
37075 +++ b/drivers/bluetooth/btwilink.c
37076 @@ -293,7 +293,7 @@ static int ti_st_send_frame(struct sk_buff *skb)
37077
37078 static int bt_ti_probe(struct platform_device *pdev)
37079 {
37080 - static struct ti_st *hst;
37081 + struct ti_st *hst;
37082 struct hci_dev *hdev;
37083 int err;
37084
37085 diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
37086 index 2009266..7be9ca2 100644
37087 --- a/drivers/bus/arm-cci.c
37088 +++ b/drivers/bus/arm-cci.c
37089 @@ -405,7 +405,7 @@ static int __init cci_probe(void)
37090
37091 nb_cci_ports = cci_config->nb_ace + cci_config->nb_ace_lite;
37092
37093 - ports = kcalloc(sizeof(*ports), nb_cci_ports, GFP_KERNEL);
37094 + ports = kcalloc(nb_cci_ports, sizeof(*ports), GFP_KERNEL);
37095 if (!ports)
37096 return -ENOMEM;
37097
37098 diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
37099 index 8a3aff7..d7538c2 100644
37100 --- a/drivers/cdrom/cdrom.c
37101 +++ b/drivers/cdrom/cdrom.c
37102 @@ -416,7 +416,6 @@ int register_cdrom(struct cdrom_device_info *cdi)
37103 ENSURE(reset, CDC_RESET);
37104 ENSURE(generic_packet, CDC_GENERIC_PACKET);
37105 cdi->mc_flags = 0;
37106 - cdo->n_minors = 0;
37107 cdi->options = CDO_USE_FFLAGS;
37108
37109 if (autoclose==1 && CDROM_CAN(CDC_CLOSE_TRAY))
37110 @@ -436,8 +435,11 @@ int register_cdrom(struct cdrom_device_info *cdi)
37111 else
37112 cdi->cdda_method = CDDA_OLD;
37113
37114 - if (!cdo->generic_packet)
37115 - cdo->generic_packet = cdrom_dummy_generic_packet;
37116 + if (!cdo->generic_packet) {
37117 + pax_open_kernel();
37118 + *(void **)&cdo->generic_packet = cdrom_dummy_generic_packet;
37119 + pax_close_kernel();
37120 + }
37121
37122 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" registered\n", cdi->name);
37123 mutex_lock(&cdrom_mutex);
37124 @@ -458,7 +460,6 @@ void unregister_cdrom(struct cdrom_device_info *cdi)
37125 if (cdi->exit)
37126 cdi->exit(cdi);
37127
37128 - cdi->ops->n_minors--;
37129 cdinfo(CD_REG_UNREG, "drive \"/dev/%s\" unregistered\n", cdi->name);
37130 }
37131
37132 @@ -2107,7 +2108,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
37133 */
37134 nr = nframes;
37135 do {
37136 - cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
37137 + cgc.buffer = kzalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
37138 if (cgc.buffer)
37139 break;
37140
37141 @@ -3429,7 +3430,7 @@ static int cdrom_print_info(const char *header, int val, char *info,
37142 struct cdrom_device_info *cdi;
37143 int ret;
37144
37145 - ret = scnprintf(info + *pos, max_size - *pos, header);
37146 + ret = scnprintf(info + *pos, max_size - *pos, "%s", header);
37147 if (!ret)
37148 return 1;
37149
37150 diff --git a/drivers/cdrom/gdrom.c b/drivers/cdrom/gdrom.c
37151 index 5980cb9..6d7bd7e 100644
37152 --- a/drivers/cdrom/gdrom.c
37153 +++ b/drivers/cdrom/gdrom.c
37154 @@ -491,7 +491,6 @@ static struct cdrom_device_ops gdrom_ops = {
37155 .audio_ioctl = gdrom_audio_ioctl,
37156 .capability = CDC_MULTI_SESSION | CDC_MEDIA_CHANGED |
37157 CDC_RESET | CDC_DRIVE_STATUS | CDC_CD_R,
37158 - .n_minors = 1,
37159 };
37160
37161 static int gdrom_bdops_open(struct block_device *bdev, fmode_t mode)
37162 diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
37163 index 1421997..33f5d6d 100644
37164 --- a/drivers/char/Kconfig
37165 +++ b/drivers/char/Kconfig
37166 @@ -8,7 +8,8 @@ source "drivers/tty/Kconfig"
37167
37168 config DEVKMEM
37169 bool "/dev/kmem virtual device support"
37170 - default y
37171 + default n
37172 + depends on !GRKERNSEC_KMEM
37173 help
37174 Say Y here if you want to support the /dev/kmem device. The
37175 /dev/kmem device is rarely used, but can be used for certain
37176 @@ -570,6 +571,7 @@ config DEVPORT
37177 bool
37178 depends on !M68K
37179 depends on ISA || PCI
37180 + depends on !GRKERNSEC_KMEM
37181 default y
37182
37183 source "drivers/s390/char/Kconfig"
37184 diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
37185 index a48e05b..6bac831 100644
37186 --- a/drivers/char/agp/compat_ioctl.c
37187 +++ b/drivers/char/agp/compat_ioctl.c
37188 @@ -108,7 +108,7 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
37189 return -ENOMEM;
37190 }
37191
37192 - if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
37193 + if (copy_from_user(usegment, (void __force_user *) ureserve.seg_list,
37194 sizeof(*usegment) * ureserve.seg_count)) {
37195 kfree(usegment);
37196 kfree(ksegment);
37197 diff --git a/drivers/char/agp/frontend.c b/drivers/char/agp/frontend.c
37198 index 1b19239..b87b143 100644
37199 --- a/drivers/char/agp/frontend.c
37200 +++ b/drivers/char/agp/frontend.c
37201 @@ -819,7 +819,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37202 if (copy_from_user(&reserve, arg, sizeof(struct agp_region)))
37203 return -EFAULT;
37204
37205 - if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment))
37206 + if ((unsigned) reserve.seg_count >= ~0U/sizeof(struct agp_segment_priv))
37207 return -EFAULT;
37208
37209 client = agp_find_client_by_pid(reserve.pid);
37210 @@ -849,7 +849,7 @@ static int agpioc_reserve_wrap(struct agp_file_private *priv, void __user *arg)
37211 if (segment == NULL)
37212 return -ENOMEM;
37213
37214 - if (copy_from_user(segment, (void __user *) reserve.seg_list,
37215 + if (copy_from_user(segment, (void __force_user *) reserve.seg_list,
37216 sizeof(struct agp_segment) * reserve.seg_count)) {
37217 kfree(segment);
37218 return -EFAULT;
37219 diff --git a/drivers/char/genrtc.c b/drivers/char/genrtc.c
37220 index 4f94375..413694e 100644
37221 --- a/drivers/char/genrtc.c
37222 +++ b/drivers/char/genrtc.c
37223 @@ -273,6 +273,7 @@ static int gen_rtc_ioctl(struct file *file,
37224 switch (cmd) {
37225
37226 case RTC_PLL_GET:
37227 + memset(&pll, 0, sizeof(pll));
37228 if (get_rtc_pll(&pll))
37229 return -EINVAL;
37230 else
37231 diff --git a/drivers/char/hpet.c b/drivers/char/hpet.c
37232 index 448ce5e..3a76625 100644
37233 --- a/drivers/char/hpet.c
37234 +++ b/drivers/char/hpet.c
37235 @@ -559,7 +559,7 @@ static inline unsigned long hpet_time_div(struct hpets *hpets,
37236 }
37237
37238 static int
37239 -hpet_ioctl_common(struct hpet_dev *devp, int cmd, unsigned long arg,
37240 +hpet_ioctl_common(struct hpet_dev *devp, unsigned int cmd, unsigned long arg,
37241 struct hpet_info *info)
37242 {
37243 struct hpet_timer __iomem *timer;
37244 diff --git a/drivers/char/hw_random/intel-rng.c b/drivers/char/hw_random/intel-rng.c
37245 index 86fe45c..c0ea948 100644
37246 --- a/drivers/char/hw_random/intel-rng.c
37247 +++ b/drivers/char/hw_random/intel-rng.c
37248 @@ -314,7 +314,7 @@ PFX "RNG, try using the 'no_fwh_detect' option.\n";
37249
37250 if (no_fwh_detect)
37251 return -ENODEV;
37252 - printk(warning);
37253 + printk("%s", warning);
37254 return -EBUSY;
37255 }
37256
37257 diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
37258 index ec4e10f..f2a763b 100644
37259 --- a/drivers/char/ipmi/ipmi_msghandler.c
37260 +++ b/drivers/char/ipmi/ipmi_msghandler.c
37261 @@ -420,7 +420,7 @@ struct ipmi_smi {
37262 struct proc_dir_entry *proc_dir;
37263 char proc_dir_name[10];
37264
37265 - atomic_t stats[IPMI_NUM_STATS];
37266 + atomic_unchecked_t stats[IPMI_NUM_STATS];
37267
37268 /*
37269 * run_to_completion duplicate of smb_info, smi_info
37270 @@ -453,9 +453,9 @@ static DEFINE_MUTEX(smi_watchers_mutex);
37271
37272
37273 #define ipmi_inc_stat(intf, stat) \
37274 - atomic_inc(&(intf)->stats[IPMI_STAT_ ## stat])
37275 + atomic_inc_unchecked(&(intf)->stats[IPMI_STAT_ ## stat])
37276 #define ipmi_get_stat(intf, stat) \
37277 - ((unsigned int) atomic_read(&(intf)->stats[IPMI_STAT_ ## stat]))
37278 + ((unsigned int) atomic_read_unchecked(&(intf)->stats[IPMI_STAT_ ## stat]))
37279
37280 static int is_lan_addr(struct ipmi_addr *addr)
37281 {
37282 @@ -2883,7 +2883,7 @@ int ipmi_register_smi(struct ipmi_smi_handlers *handlers,
37283 INIT_LIST_HEAD(&intf->cmd_rcvrs);
37284 init_waitqueue_head(&intf->waitq);
37285 for (i = 0; i < IPMI_NUM_STATS; i++)
37286 - atomic_set(&intf->stats[i], 0);
37287 + atomic_set_unchecked(&intf->stats[i], 0);
37288
37289 intf->proc_dir = NULL;
37290
37291 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c
37292 index 15e4a60..b046093 100644
37293 --- a/drivers/char/ipmi/ipmi_si_intf.c
37294 +++ b/drivers/char/ipmi/ipmi_si_intf.c
37295 @@ -280,7 +280,7 @@ struct smi_info {
37296 unsigned char slave_addr;
37297
37298 /* Counters and things for the proc filesystem. */
37299 - atomic_t stats[SI_NUM_STATS];
37300 + atomic_unchecked_t stats[SI_NUM_STATS];
37301
37302 struct task_struct *thread;
37303
37304 @@ -289,9 +289,9 @@ struct smi_info {
37305 };
37306
37307 #define smi_inc_stat(smi, stat) \
37308 - atomic_inc(&(smi)->stats[SI_STAT_ ## stat])
37309 + atomic_inc_unchecked(&(smi)->stats[SI_STAT_ ## stat])
37310 #define smi_get_stat(smi, stat) \
37311 - ((unsigned int) atomic_read(&(smi)->stats[SI_STAT_ ## stat]))
37312 + ((unsigned int) atomic_read_unchecked(&(smi)->stats[SI_STAT_ ## stat]))
37313
37314 #define SI_MAX_PARMS 4
37315
37316 @@ -3324,7 +3324,7 @@ static int try_smi_init(struct smi_info *new_smi)
37317 atomic_set(&new_smi->req_events, 0);
37318 new_smi->run_to_completion = 0;
37319 for (i = 0; i < SI_NUM_STATS; i++)
37320 - atomic_set(&new_smi->stats[i], 0);
37321 + atomic_set_unchecked(&new_smi->stats[i], 0);
37322
37323 new_smi->interrupt_disabled = 1;
37324 atomic_set(&new_smi->stop_operation, 0);
37325 diff --git a/drivers/char/mem.c b/drivers/char/mem.c
37326 index f895a8c..2bc9147 100644
37327 --- a/drivers/char/mem.c
37328 +++ b/drivers/char/mem.c
37329 @@ -18,6 +18,7 @@
37330 #include <linux/raw.h>
37331 #include <linux/tty.h>
37332 #include <linux/capability.h>
37333 +#include <linux/security.h>
37334 #include <linux/ptrace.h>
37335 #include <linux/device.h>
37336 #include <linux/highmem.h>
37337 @@ -37,6 +38,10 @@
37338
37339 #define DEVPORT_MINOR 4
37340
37341 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37342 +extern const struct file_operations grsec_fops;
37343 +#endif
37344 +
37345 static inline unsigned long size_inside_page(unsigned long start,
37346 unsigned long size)
37347 {
37348 @@ -68,9 +73,13 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37349
37350 while (cursor < to) {
37351 if (!devmem_is_allowed(pfn)) {
37352 +#ifdef CONFIG_GRKERNSEC_KMEM
37353 + gr_handle_mem_readwrite(from, to);
37354 +#else
37355 printk(KERN_INFO
37356 "Program %s tried to access /dev/mem between %Lx->%Lx.\n",
37357 current->comm, from, to);
37358 +#endif
37359 return 0;
37360 }
37361 cursor += PAGE_SIZE;
37362 @@ -78,6 +87,11 @@ static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37363 }
37364 return 1;
37365 }
37366 +#elif defined(CONFIG_GRKERNSEC_KMEM)
37367 +static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37368 +{
37369 + return 0;
37370 +}
37371 #else
37372 static inline int range_is_allowed(unsigned long pfn, unsigned long size)
37373 {
37374 @@ -120,6 +134,7 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37375
37376 while (count > 0) {
37377 unsigned long remaining;
37378 + char *temp;
37379
37380 sz = size_inside_page(p, count);
37381
37382 @@ -135,7 +150,23 @@ static ssize_t read_mem(struct file *file, char __user *buf,
37383 if (!ptr)
37384 return -EFAULT;
37385
37386 - remaining = copy_to_user(buf, ptr, sz);
37387 +#ifdef CONFIG_PAX_USERCOPY
37388 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37389 + if (!temp) {
37390 + unxlate_dev_mem_ptr(p, ptr);
37391 + return -ENOMEM;
37392 + }
37393 + memcpy(temp, ptr, sz);
37394 +#else
37395 + temp = ptr;
37396 +#endif
37397 +
37398 + remaining = copy_to_user(buf, temp, sz);
37399 +
37400 +#ifdef CONFIG_PAX_USERCOPY
37401 + kfree(temp);
37402 +#endif
37403 +
37404 unxlate_dev_mem_ptr(p, ptr);
37405 if (remaining)
37406 return -EFAULT;
37407 @@ -364,9 +395,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37408 size_t count, loff_t *ppos)
37409 {
37410 unsigned long p = *ppos;
37411 - ssize_t low_count, read, sz;
37412 + ssize_t low_count, read, sz, err = 0;
37413 char *kbuf; /* k-addr because vread() takes vmlist_lock rwlock */
37414 - int err = 0;
37415
37416 read = 0;
37417 if (p < (unsigned long) high_memory) {
37418 @@ -388,6 +418,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37419 }
37420 #endif
37421 while (low_count > 0) {
37422 + char *temp;
37423 +
37424 sz = size_inside_page(p, low_count);
37425
37426 /*
37427 @@ -397,7 +429,22 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
37428 */
37429 kbuf = xlate_dev_kmem_ptr((char *)p);
37430
37431 - if (copy_to_user(buf, kbuf, sz))
37432 +#ifdef CONFIG_PAX_USERCOPY
37433 + temp = kmalloc(sz, GFP_KERNEL|GFP_USERCOPY);
37434 + if (!temp)
37435 + return -ENOMEM;
37436 + memcpy(temp, kbuf, sz);
37437 +#else
37438 + temp = kbuf;
37439 +#endif
37440 +
37441 + err = copy_to_user(buf, temp, sz);
37442 +
37443 +#ifdef CONFIG_PAX_USERCOPY
37444 + kfree(temp);
37445 +#endif
37446 +
37447 + if (err)
37448 return -EFAULT;
37449 buf += sz;
37450 p += sz;
37451 @@ -822,6 +869,9 @@ static const struct memdev {
37452 #ifdef CONFIG_PRINTK
37453 [11] = { "kmsg", 0644, &kmsg_fops, NULL },
37454 #endif
37455 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
37456 + [13] = { "grsec",S_IRUSR | S_IWUGO, &grsec_fops, NULL },
37457 +#endif
37458 };
37459
37460 static int memory_open(struct inode *inode, struct file *filp)
37461 @@ -893,7 +943,7 @@ static int __init chr_dev_init(void)
37462 continue;
37463
37464 device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor),
37465 - NULL, devlist[minor].name);
37466 + NULL, "%s", devlist[minor].name);
37467 }
37468
37469 return tty_init();
37470 diff --git a/drivers/char/nvram.c b/drivers/char/nvram.c
37471 index 9df78e2..01ba9ae 100644
37472 --- a/drivers/char/nvram.c
37473 +++ b/drivers/char/nvram.c
37474 @@ -247,7 +247,7 @@ static ssize_t nvram_read(struct file *file, char __user *buf,
37475
37476 spin_unlock_irq(&rtc_lock);
37477
37478 - if (copy_to_user(buf, contents, tmp - contents))
37479 + if (tmp - contents > sizeof(contents) || copy_to_user(buf, contents, tmp - contents))
37480 return -EFAULT;
37481
37482 *ppos = i;
37483 diff --git a/drivers/char/pcmcia/synclink_cs.c b/drivers/char/pcmcia/synclink_cs.c
37484 index d39cca6..8c1e269 100644
37485 --- a/drivers/char/pcmcia/synclink_cs.c
37486 +++ b/drivers/char/pcmcia/synclink_cs.c
37487 @@ -2345,9 +2345,9 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37488
37489 if (debug_level >= DEBUG_LEVEL_INFO)
37490 printk("%s(%d):mgslpc_close(%s) entry, count=%d\n",
37491 - __FILE__, __LINE__, info->device_name, port->count);
37492 + __FILE__, __LINE__, info->device_name, atomic_read(&port->count));
37493
37494 - WARN_ON(!port->count);
37495 + WARN_ON(!atomic_read(&port->count));
37496
37497 if (tty_port_close_start(port, tty, filp) == 0)
37498 goto cleanup;
37499 @@ -2365,7 +2365,7 @@ static void mgslpc_close(struct tty_struct *tty, struct file * filp)
37500 cleanup:
37501 if (debug_level >= DEBUG_LEVEL_INFO)
37502 printk("%s(%d):mgslpc_close(%s) exit, count=%d\n", __FILE__, __LINE__,
37503 - tty->driver->name, port->count);
37504 + tty->driver->name, atomic_read(&port->count));
37505 }
37506
37507 /* Wait until the transmitter is empty.
37508 @@ -2507,7 +2507,7 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37509
37510 if (debug_level >= DEBUG_LEVEL_INFO)
37511 printk("%s(%d):mgslpc_open(%s), old ref count = %d\n",
37512 - __FILE__, __LINE__, tty->driver->name, port->count);
37513 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
37514
37515 /* If port is closing, signal caller to try again */
37516 if (tty_hung_up_p(filp) || port->flags & ASYNC_CLOSING){
37517 @@ -2527,11 +2527,11 @@ static int mgslpc_open(struct tty_struct *tty, struct file * filp)
37518 goto cleanup;
37519 }
37520 spin_lock(&port->lock);
37521 - port->count++;
37522 + atomic_inc(&port->count);
37523 spin_unlock(&port->lock);
37524 spin_unlock_irqrestore(&info->netlock, flags);
37525
37526 - if (port->count == 1) {
37527 + if (atomic_read(&port->count) == 1) {
37528 /* 1st open on this device, init hardware */
37529 retval = startup(info, tty);
37530 if (retval < 0)
37531 @@ -3920,7 +3920,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
37532 unsigned short new_crctype;
37533
37534 /* return error if TTY interface open */
37535 - if (info->port.count)
37536 + if (atomic_read(&info->port.count))
37537 return -EBUSY;
37538
37539 switch (encoding)
37540 @@ -4024,7 +4024,7 @@ static int hdlcdev_open(struct net_device *dev)
37541
37542 /* arbitrate between network and tty opens */
37543 spin_lock_irqsave(&info->netlock, flags);
37544 - if (info->port.count != 0 || info->netcount != 0) {
37545 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
37546 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
37547 spin_unlock_irqrestore(&info->netlock, flags);
37548 return -EBUSY;
37549 @@ -4114,7 +4114,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
37550 printk("%s:hdlcdev_ioctl(%s)\n", __FILE__, dev->name);
37551
37552 /* return error if TTY interface open */
37553 - if (info->port.count)
37554 + if (atomic_read(&info->port.count))
37555 return -EBUSY;
37556
37557 if (cmd != SIOCWANDEV)
37558 diff --git a/drivers/char/random.c b/drivers/char/random.c
37559 index 7a744d3..35a177ee 100644
37560 --- a/drivers/char/random.c
37561 +++ b/drivers/char/random.c
37562 @@ -269,8 +269,13 @@
37563 /*
37564 * Configuration information
37565 */
37566 +#ifdef CONFIG_GRKERNSEC_RANDNET
37567 +#define INPUT_POOL_WORDS 512
37568 +#define OUTPUT_POOL_WORDS 128
37569 +#else
37570 #define INPUT_POOL_WORDS 128
37571 #define OUTPUT_POOL_WORDS 32
37572 +#endif
37573 #define SEC_XFER_SIZE 512
37574 #define EXTRACT_SIZE 10
37575
37576 @@ -310,10 +315,17 @@ static struct poolinfo {
37577 int poolwords;
37578 int tap1, tap2, tap3, tap4, tap5;
37579 } poolinfo_table[] = {
37580 +#ifdef CONFIG_GRKERNSEC_RANDNET
37581 + /* x^512 + x^411 + x^308 + x^208 +x^104 + x + 1 -- 225 */
37582 + { 512, 411, 308, 208, 104, 1 },
37583 + /* x^128 + x^103 + x^76 + x^51 + x^25 + x + 1 -- 105 */
37584 + { 128, 103, 76, 51, 25, 1 },
37585 +#else
37586 /* x^128 + x^103 + x^76 + x^51 +x^25 + x + 1 -- 105 */
37587 { 128, 103, 76, 51, 25, 1 },
37588 /* x^32 + x^26 + x^20 + x^14 + x^7 + x + 1 -- 15 */
37589 { 32, 26, 20, 14, 7, 1 },
37590 +#endif
37591 #if 0
37592 /* x^2048 + x^1638 + x^1231 + x^819 + x^411 + x + 1 -- 115 */
37593 { 2048, 1638, 1231, 819, 411, 1 },
37594 @@ -521,8 +533,8 @@ static void _mix_pool_bytes(struct entropy_store *r, const void *in,
37595 input_rotate += i ? 7 : 14;
37596 }
37597
37598 - ACCESS_ONCE(r->input_rotate) = input_rotate;
37599 - ACCESS_ONCE(r->add_ptr) = i;
37600 + ACCESS_ONCE_RW(r->input_rotate) = input_rotate;
37601 + ACCESS_ONCE_RW(r->add_ptr) = i;
37602 smp_wmb();
37603
37604 if (out)
37605 @@ -1029,7 +1041,7 @@ static ssize_t extract_entropy_user(struct entropy_store *r, void __user *buf,
37606
37607 extract_buf(r, tmp);
37608 i = min_t(int, nbytes, EXTRACT_SIZE);
37609 - if (copy_to_user(buf, tmp, i)) {
37610 + if (i > sizeof(tmp) || copy_to_user(buf, tmp, i)) {
37611 ret = -EFAULT;
37612 break;
37613 }
37614 @@ -1365,7 +1377,7 @@ EXPORT_SYMBOL(generate_random_uuid);
37615 #include <linux/sysctl.h>
37616
37617 static int min_read_thresh = 8, min_write_thresh;
37618 -static int max_read_thresh = INPUT_POOL_WORDS * 32;
37619 +static int max_read_thresh = OUTPUT_POOL_WORDS * 32;
37620 static int max_write_thresh = INPUT_POOL_WORDS * 32;
37621 static char sysctl_bootid[16];
37622
37623 @@ -1381,7 +1393,7 @@ static char sysctl_bootid[16];
37624 static int proc_do_uuid(struct ctl_table *table, int write,
37625 void __user *buffer, size_t *lenp, loff_t *ppos)
37626 {
37627 - struct ctl_table fake_table;
37628 + ctl_table_no_const fake_table;
37629 unsigned char buf[64], tmp_uuid[16], *uuid;
37630
37631 uuid = table->data;
37632 diff --git a/drivers/char/sonypi.c b/drivers/char/sonypi.c
37633 index 7cc1fe22..b602d6b 100644
37634 --- a/drivers/char/sonypi.c
37635 +++ b/drivers/char/sonypi.c
37636 @@ -54,6 +54,7 @@
37637
37638 #include <asm/uaccess.h>
37639 #include <asm/io.h>
37640 +#include <asm/local.h>
37641
37642 #include <linux/sonypi.h>
37643
37644 @@ -490,7 +491,7 @@ static struct sonypi_device {
37645 spinlock_t fifo_lock;
37646 wait_queue_head_t fifo_proc_list;
37647 struct fasync_struct *fifo_async;
37648 - int open_count;
37649 + local_t open_count;
37650 int model;
37651 struct input_dev *input_jog_dev;
37652 struct input_dev *input_key_dev;
37653 @@ -892,7 +893,7 @@ static int sonypi_misc_fasync(int fd, struct file *filp, int on)
37654 static int sonypi_misc_release(struct inode *inode, struct file *file)
37655 {
37656 mutex_lock(&sonypi_device.lock);
37657 - sonypi_device.open_count--;
37658 + local_dec(&sonypi_device.open_count);
37659 mutex_unlock(&sonypi_device.lock);
37660 return 0;
37661 }
37662 @@ -901,9 +902,9 @@ static int sonypi_misc_open(struct inode *inode, struct file *file)
37663 {
37664 mutex_lock(&sonypi_device.lock);
37665 /* Flush input queue on first open */
37666 - if (!sonypi_device.open_count)
37667 + if (!local_read(&sonypi_device.open_count))
37668 kfifo_reset(&sonypi_device.fifo);
37669 - sonypi_device.open_count++;
37670 + local_inc(&sonypi_device.open_count);
37671 mutex_unlock(&sonypi_device.lock);
37672
37673 return 0;
37674 diff --git a/drivers/char/tpm/tpm_acpi.c b/drivers/char/tpm/tpm_acpi.c
37675 index 64420b3..5c40b56 100644
37676 --- a/drivers/char/tpm/tpm_acpi.c
37677 +++ b/drivers/char/tpm/tpm_acpi.c
37678 @@ -98,11 +98,12 @@ int read_log(struct tpm_bios_log *log)
37679 virt = acpi_os_map_memory(start, len);
37680 if (!virt) {
37681 kfree(log->bios_event_log);
37682 + log->bios_event_log = NULL;
37683 printk("%s: ERROR - Unable to map memory\n", __func__);
37684 return -EIO;
37685 }
37686
37687 - memcpy_fromio(log->bios_event_log, virt, len);
37688 + memcpy_fromio(log->bios_event_log, (const char __force_kernel *)virt, len);
37689
37690 acpi_os_unmap_memory(virt, len);
37691 return 0;
37692 diff --git a/drivers/char/tpm/tpm_eventlog.c b/drivers/char/tpm/tpm_eventlog.c
37693 index 84ddc55..1d32f1e 100644
37694 --- a/drivers/char/tpm/tpm_eventlog.c
37695 +++ b/drivers/char/tpm/tpm_eventlog.c
37696 @@ -95,7 +95,7 @@ static void *tpm_bios_measurements_start(struct seq_file *m, loff_t *pos)
37697 event = addr;
37698
37699 if ((event->event_type == 0 && event->event_size == 0) ||
37700 - ((addr + sizeof(struct tcpa_event) + event->event_size) >= limit))
37701 + (event->event_size >= limit - addr - sizeof(struct tcpa_event)))
37702 return NULL;
37703
37704 return addr;
37705 @@ -120,7 +120,7 @@ static void *tpm_bios_measurements_next(struct seq_file *m, void *v,
37706 return NULL;
37707
37708 if ((event->event_type == 0 && event->event_size == 0) ||
37709 - ((v + sizeof(struct tcpa_event) + event->event_size) >= limit))
37710 + (event->event_size >= limit - v - sizeof(struct tcpa_event)))
37711 return NULL;
37712
37713 (*pos)++;
37714 @@ -213,7 +213,8 @@ static int tpm_binary_bios_measurements_show(struct seq_file *m, void *v)
37715 int i;
37716
37717 for (i = 0; i < sizeof(struct tcpa_event) + event->event_size; i++)
37718 - seq_putc(m, data[i]);
37719 + if (!seq_putc(m, data[i]))
37720 + return -EFAULT;
37721
37722 return 0;
37723 }
37724 diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c
37725 index b79cf3e..de172d64f 100644
37726 --- a/drivers/char/virtio_console.c
37727 +++ b/drivers/char/virtio_console.c
37728 @@ -682,7 +682,7 @@ static ssize_t fill_readbuf(struct port *port, char *out_buf, size_t out_count,
37729 if (to_user) {
37730 ssize_t ret;
37731
37732 - ret = copy_to_user(out_buf, buf->buf + buf->offset, out_count);
37733 + ret = copy_to_user((char __force_user *)out_buf, buf->buf + buf->offset, out_count);
37734 if (ret)
37735 return -EFAULT;
37736 } else {
37737 @@ -785,7 +785,7 @@ static ssize_t port_fops_read(struct file *filp, char __user *ubuf,
37738 if (!port_has_data(port) && !port->host_connected)
37739 return 0;
37740
37741 - return fill_readbuf(port, ubuf, count, true);
37742 + return fill_readbuf(port, (char __force_kernel *)ubuf, count, true);
37743 }
37744
37745 static int wait_port_writable(struct port *port, bool nonblock)
37746 diff --git a/drivers/clk/clk-composite.c b/drivers/clk/clk-composite.c
37747 index a33f46f..a720eed 100644
37748 --- a/drivers/clk/clk-composite.c
37749 +++ b/drivers/clk/clk-composite.c
37750 @@ -122,7 +122,7 @@ struct clk *clk_register_composite(struct device *dev, const char *name,
37751 struct clk *clk;
37752 struct clk_init_data init;
37753 struct clk_composite *composite;
37754 - struct clk_ops *clk_composite_ops;
37755 + clk_ops_no_const *clk_composite_ops;
37756
37757 composite = kzalloc(sizeof(*composite), GFP_KERNEL);
37758 if (!composite) {
37759 diff --git a/drivers/clk/socfpga/clk.c b/drivers/clk/socfpga/clk.c
37760 index 81dd31a..ef5c542 100644
37761 --- a/drivers/clk/socfpga/clk.c
37762 +++ b/drivers/clk/socfpga/clk.c
37763 @@ -22,6 +22,7 @@
37764 #include <linux/clk-provider.h>
37765 #include <linux/io.h>
37766 #include <linux/of.h>
37767 +#include <asm/pgtable.h>
37768
37769 /* Clock Manager offsets */
37770 #define CLKMGR_CTRL 0x0
37771 @@ -152,8 +153,10 @@ static __init struct clk *socfpga_clk_init(struct device_node *node,
37772 streq(clk_name, "periph_pll") ||
37773 streq(clk_name, "sdram_pll")) {
37774 socfpga_clk->hw.bit_idx = SOCFPGA_PLL_EXT_ENA;
37775 - clk_pll_ops.enable = clk_gate_ops.enable;
37776 - clk_pll_ops.disable = clk_gate_ops.disable;
37777 + pax_open_kernel();
37778 + *(void **)&clk_pll_ops.enable = clk_gate_ops.enable;
37779 + *(void **)&clk_pll_ops.disable = clk_gate_ops.disable;
37780 + pax_close_kernel();
37781 }
37782
37783 clk = clk_register(NULL, &socfpga_clk->hw.hw);
37784 @@ -244,7 +247,7 @@ static unsigned long socfpga_clk_recalc_rate(struct clk_hw *hwclk,
37785 return parent_rate / div;
37786 }
37787
37788 -static struct clk_ops gateclk_ops = {
37789 +static clk_ops_no_const gateclk_ops __read_only = {
37790 .recalc_rate = socfpga_clk_recalc_rate,
37791 .get_parent = socfpga_clk_get_parent,
37792 .set_parent = socfpga_clk_set_parent,
37793 diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
37794 index 506fd23..01a593f 100644
37795 --- a/drivers/cpufreq/acpi-cpufreq.c
37796 +++ b/drivers/cpufreq/acpi-cpufreq.c
37797 @@ -172,7 +172,7 @@ static ssize_t show_global_boost(struct kobject *kobj,
37798 return sprintf(buf, "%u\n", boost_enabled);
37799 }
37800
37801 -static struct global_attr global_boost = __ATTR(boost, 0644,
37802 +static global_attr_no_const global_boost = __ATTR(boost, 0644,
37803 show_global_boost,
37804 store_global_boost);
37805
37806 @@ -721,8 +721,11 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37807 data->acpi_data = per_cpu_ptr(acpi_perf_data, cpu);
37808 per_cpu(acfreq_data, cpu) = data;
37809
37810 - if (cpu_has(c, X86_FEATURE_CONSTANT_TSC))
37811 - acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37812 + if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
37813 + pax_open_kernel();
37814 + *(u8 *)&acpi_cpufreq_driver.flags |= CPUFREQ_CONST_LOOPS;
37815 + pax_close_kernel();
37816 + }
37817
37818 result = acpi_processor_register_performance(data->acpi_data, cpu);
37819 if (result)
37820 @@ -850,7 +853,9 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
37821 policy->cur = acpi_cpufreq_guess_freq(data, policy->cpu);
37822 break;
37823 case ACPI_ADR_SPACE_FIXED_HARDWARE:
37824 - acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37825 + pax_open_kernel();
37826 + *(void **)&acpi_cpufreq_driver.get = get_cur_freq_on_cpu;
37827 + pax_close_kernel();
37828 policy->cur = get_cur_freq_on_cpu(cpu);
37829 break;
37830 default:
37831 diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c
37832 index 04548f7..457a342 100644
37833 --- a/drivers/cpufreq/cpufreq.c
37834 +++ b/drivers/cpufreq/cpufreq.c
37835 @@ -2069,7 +2069,7 @@ static int cpufreq_cpu_callback(struct notifier_block *nfb,
37836 return NOTIFY_OK;
37837 }
37838
37839 -static struct notifier_block __refdata cpufreq_cpu_notifier = {
37840 +static struct notifier_block cpufreq_cpu_notifier = {
37841 .notifier_call = cpufreq_cpu_callback,
37842 };
37843
37844 @@ -2101,8 +2101,11 @@ int cpufreq_register_driver(struct cpufreq_driver *driver_data)
37845
37846 pr_debug("trying to register driver %s\n", driver_data->name);
37847
37848 - if (driver_data->setpolicy)
37849 - driver_data->flags |= CPUFREQ_CONST_LOOPS;
37850 + if (driver_data->setpolicy) {
37851 + pax_open_kernel();
37852 + *(u8 *)&driver_data->flags |= CPUFREQ_CONST_LOOPS;
37853 + pax_close_kernel();
37854 + }
37855
37856 write_lock_irqsave(&cpufreq_driver_lock, flags);
37857 if (cpufreq_driver) {
37858 diff --git a/drivers/cpufreq/cpufreq_governor.c b/drivers/cpufreq/cpufreq_governor.c
37859 index 0806c31..6a73276 100644
37860 --- a/drivers/cpufreq/cpufreq_governor.c
37861 +++ b/drivers/cpufreq/cpufreq_governor.c
37862 @@ -187,7 +187,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37863 struct dbs_data *dbs_data;
37864 struct od_cpu_dbs_info_s *od_dbs_info = NULL;
37865 struct cs_cpu_dbs_info_s *cs_dbs_info = NULL;
37866 - struct od_ops *od_ops = NULL;
37867 + const struct od_ops *od_ops = NULL;
37868 struct od_dbs_tuners *od_tuners = NULL;
37869 struct cs_dbs_tuners *cs_tuners = NULL;
37870 struct cpu_dbs_common_info *cpu_cdbs;
37871 @@ -253,7 +253,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37872
37873 if ((cdata->governor == GOV_CONSERVATIVE) &&
37874 (!policy->governor->initialized)) {
37875 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37876 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37877
37878 cpufreq_register_notifier(cs_ops->notifier_block,
37879 CPUFREQ_TRANSITION_NOTIFIER);
37880 @@ -273,7 +273,7 @@ int cpufreq_governor_dbs(struct cpufreq_policy *policy,
37881
37882 if ((dbs_data->cdata->governor == GOV_CONSERVATIVE) &&
37883 (policy->governor->initialized == 1)) {
37884 - struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37885 + const struct cs_ops *cs_ops = dbs_data->cdata->gov_ops;
37886
37887 cpufreq_unregister_notifier(cs_ops->notifier_block,
37888 CPUFREQ_TRANSITION_NOTIFIER);
37889 diff --git a/drivers/cpufreq/cpufreq_governor.h b/drivers/cpufreq/cpufreq_governor.h
37890 index 88cd39f..87f0393 100644
37891 --- a/drivers/cpufreq/cpufreq_governor.h
37892 +++ b/drivers/cpufreq/cpufreq_governor.h
37893 @@ -202,7 +202,7 @@ struct common_dbs_data {
37894 void (*exit)(struct dbs_data *dbs_data);
37895
37896 /* Governor specific ops, see below */
37897 - void *gov_ops;
37898 + const void *gov_ops;
37899 };
37900
37901 /* Governor Per policy data */
37902 @@ -222,7 +222,7 @@ struct od_ops {
37903 unsigned int (*powersave_bias_target)(struct cpufreq_policy *policy,
37904 unsigned int freq_next, unsigned int relation);
37905 void (*freq_increase)(struct cpufreq_policy *policy, unsigned int freq);
37906 -};
37907 +} __no_const;
37908
37909 struct cs_ops {
37910 struct notifier_block *notifier_block;
37911 diff --git a/drivers/cpufreq/cpufreq_ondemand.c b/drivers/cpufreq/cpufreq_ondemand.c
37912 index 32f26f6..feb657b 100644
37913 --- a/drivers/cpufreq/cpufreq_ondemand.c
37914 +++ b/drivers/cpufreq/cpufreq_ondemand.c
37915 @@ -522,7 +522,7 @@ static void od_exit(struct dbs_data *dbs_data)
37916
37917 define_get_cpu_dbs_routines(od_cpu_dbs_info);
37918
37919 -static struct od_ops od_ops = {
37920 +static struct od_ops od_ops __read_only = {
37921 .powersave_bias_init_cpu = ondemand_powersave_bias_init_cpu,
37922 .powersave_bias_target = generic_powersave_bias_target,
37923 .freq_increase = dbs_freq_increase,
37924 @@ -577,14 +577,18 @@ void od_register_powersave_bias_handler(unsigned int (*f)
37925 (struct cpufreq_policy *, unsigned int, unsigned int),
37926 unsigned int powersave_bias)
37927 {
37928 - od_ops.powersave_bias_target = f;
37929 + pax_open_kernel();
37930 + *(void **)&od_ops.powersave_bias_target = f;
37931 + pax_close_kernel();
37932 od_set_powersave_bias(powersave_bias);
37933 }
37934 EXPORT_SYMBOL_GPL(od_register_powersave_bias_handler);
37935
37936 void od_unregister_powersave_bias_handler(void)
37937 {
37938 - od_ops.powersave_bias_target = generic_powersave_bias_target;
37939 + pax_open_kernel();
37940 + *(void **)&od_ops.powersave_bias_target = generic_powersave_bias_target;
37941 + pax_close_kernel();
37942 od_set_powersave_bias(0);
37943 }
37944 EXPORT_SYMBOL_GPL(od_unregister_powersave_bias_handler);
37945 diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
37946 index 4cf0d28..5830372 100644
37947 --- a/drivers/cpufreq/cpufreq_stats.c
37948 +++ b/drivers/cpufreq/cpufreq_stats.c
37949 @@ -352,7 +352,7 @@ static int cpufreq_stat_cpu_callback(struct notifier_block *nfb,
37950 }
37951
37952 /* priority=1 so this will get called before cpufreq_remove_dev */
37953 -static struct notifier_block cpufreq_stat_cpu_notifier __refdata = {
37954 +static struct notifier_block cpufreq_stat_cpu_notifier = {
37955 .notifier_call = cpufreq_stat_cpu_callback,
37956 .priority = 1,
37957 };
37958 diff --git a/drivers/cpufreq/p4-clockmod.c b/drivers/cpufreq/p4-clockmod.c
37959 index 2f0a2a6..93d728e 100644
37960 --- a/drivers/cpufreq/p4-clockmod.c
37961 +++ b/drivers/cpufreq/p4-clockmod.c
37962 @@ -160,10 +160,14 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37963 case 0x0F: /* Core Duo */
37964 case 0x16: /* Celeron Core */
37965 case 0x1C: /* Atom */
37966 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37967 + pax_open_kernel();
37968 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37969 + pax_close_kernel();
37970 return speedstep_get_frequency(SPEEDSTEP_CPU_PCORE);
37971 case 0x0D: /* Pentium M (Dothan) */
37972 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37973 + pax_open_kernel();
37974 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37975 + pax_close_kernel();
37976 /* fall through */
37977 case 0x09: /* Pentium M (Banias) */
37978 return speedstep_get_frequency(SPEEDSTEP_CPU_PM);
37979 @@ -175,7 +179,9 @@ static unsigned int cpufreq_p4_get_frequency(struct cpuinfo_x86 *c)
37980
37981 /* on P-4s, the TSC runs with constant frequency independent whether
37982 * throttling is active or not. */
37983 - p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37984 + pax_open_kernel();
37985 + *(u8 *)&p4clockmod_driver.flags |= CPUFREQ_CONST_LOOPS;
37986 + pax_close_kernel();
37987
37988 if (speedstep_detect_processor() == SPEEDSTEP_CPU_P4M) {
37989 printk(KERN_WARNING PFX "Warning: Pentium 4-M detected. "
37990 diff --git a/drivers/cpufreq/sparc-us3-cpufreq.c b/drivers/cpufreq/sparc-us3-cpufreq.c
37991 index ac76b48..2445bc6 100644
37992 --- a/drivers/cpufreq/sparc-us3-cpufreq.c
37993 +++ b/drivers/cpufreq/sparc-us3-cpufreq.c
37994 @@ -18,14 +18,12 @@
37995 #include <asm/head.h>
37996 #include <asm/timer.h>
37997
37998 -static struct cpufreq_driver *cpufreq_us3_driver;
37999 -
38000 struct us3_freq_percpu_info {
38001 struct cpufreq_frequency_table table[4];
38002 };
38003
38004 /* Indexed by cpu number. */
38005 -static struct us3_freq_percpu_info *us3_freq_table;
38006 +static struct us3_freq_percpu_info us3_freq_table[NR_CPUS];
38007
38008 /* UltraSPARC-III has three dividers: 1, 2, and 32. These are controlled
38009 * in the Safari config register.
38010 @@ -186,12 +184,25 @@ static int __init us3_freq_cpu_init(struct cpufreq_policy *policy)
38011
38012 static int us3_freq_cpu_exit(struct cpufreq_policy *policy)
38013 {
38014 - if (cpufreq_us3_driver)
38015 - us3_set_cpu_divider_index(policy, 0);
38016 + us3_set_cpu_divider_index(policy->cpu, 0);
38017
38018 return 0;
38019 }
38020
38021 +static int __init us3_freq_init(void);
38022 +static void __exit us3_freq_exit(void);
38023 +
38024 +static struct cpufreq_driver cpufreq_us3_driver = {
38025 + .init = us3_freq_cpu_init,
38026 + .verify = us3_freq_verify,
38027 + .target = us3_freq_target,
38028 + .get = us3_freq_get,
38029 + .exit = us3_freq_cpu_exit,
38030 + .owner = THIS_MODULE,
38031 + .name = "UltraSPARC-III",
38032 +
38033 +};
38034 +
38035 static int __init us3_freq_init(void)
38036 {
38037 unsigned long manuf, impl, ver;
38038 @@ -208,55 +219,15 @@ static int __init us3_freq_init(void)
38039 (impl == CHEETAH_IMPL ||
38040 impl == CHEETAH_PLUS_IMPL ||
38041 impl == JAGUAR_IMPL ||
38042 - impl == PANTHER_IMPL)) {
38043 - struct cpufreq_driver *driver;
38044 -
38045 - ret = -ENOMEM;
38046 - driver = kzalloc(sizeof(*driver), GFP_KERNEL);
38047 - if (!driver)
38048 - goto err_out;
38049 -
38050 - us3_freq_table = kzalloc((NR_CPUS * sizeof(*us3_freq_table)),
38051 - GFP_KERNEL);
38052 - if (!us3_freq_table)
38053 - goto err_out;
38054 -
38055 - driver->init = us3_freq_cpu_init;
38056 - driver->verify = us3_freq_verify;
38057 - driver->target = us3_freq_target;
38058 - driver->get = us3_freq_get;
38059 - driver->exit = us3_freq_cpu_exit;
38060 - strcpy(driver->name, "UltraSPARC-III");
38061 -
38062 - cpufreq_us3_driver = driver;
38063 - ret = cpufreq_register_driver(driver);
38064 - if (ret)
38065 - goto err_out;
38066 -
38067 - return 0;
38068 -
38069 -err_out:
38070 - if (driver) {
38071 - kfree(driver);
38072 - cpufreq_us3_driver = NULL;
38073 - }
38074 - kfree(us3_freq_table);
38075 - us3_freq_table = NULL;
38076 - return ret;
38077 - }
38078 + impl == PANTHER_IMPL))
38079 + return cpufreq_register_driver(&cpufreq_us3_driver);
38080
38081 return -ENODEV;
38082 }
38083
38084 static void __exit us3_freq_exit(void)
38085 {
38086 - if (cpufreq_us3_driver) {
38087 - cpufreq_unregister_driver(cpufreq_us3_driver);
38088 - kfree(cpufreq_us3_driver);
38089 - cpufreq_us3_driver = NULL;
38090 - kfree(us3_freq_table);
38091 - us3_freq_table = NULL;
38092 - }
38093 + cpufreq_unregister_driver(&cpufreq_us3_driver);
38094 }
38095
38096 MODULE_AUTHOR("David S. Miller <davem@redhat.com>");
38097 diff --git a/drivers/cpufreq/speedstep-centrino.c b/drivers/cpufreq/speedstep-centrino.c
38098 index f897d51..15da295 100644
38099 --- a/drivers/cpufreq/speedstep-centrino.c
38100 +++ b/drivers/cpufreq/speedstep-centrino.c
38101 @@ -353,8 +353,11 @@ static int centrino_cpu_init(struct cpufreq_policy *policy)
38102 !cpu_has(cpu, X86_FEATURE_EST))
38103 return -ENODEV;
38104
38105 - if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC))
38106 - centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38107 + if (cpu_has(cpu, X86_FEATURE_CONSTANT_TSC)) {
38108 + pax_open_kernel();
38109 + *(u8 *)&centrino_driver.flags |= CPUFREQ_CONST_LOOPS;
38110 + pax_close_kernel();
38111 + }
38112
38113 if (policy->cpu != 0)
38114 return -ENODEV;
38115 diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
38116 index 22c07fb..9dff5ac 100644
38117 --- a/drivers/cpuidle/cpuidle.c
38118 +++ b/drivers/cpuidle/cpuidle.c
38119 @@ -252,7 +252,7 @@ static int poll_idle(struct cpuidle_device *dev,
38120
38121 static void poll_idle_init(struct cpuidle_driver *drv)
38122 {
38123 - struct cpuidle_state *state = &drv->states[0];
38124 + cpuidle_state_no_const *state = &drv->states[0];
38125
38126 snprintf(state->name, CPUIDLE_NAME_LEN, "POLL");
38127 snprintf(state->desc, CPUIDLE_DESC_LEN, "CPUIDLE CORE POLL IDLE");
38128 diff --git a/drivers/cpuidle/governor.c b/drivers/cpuidle/governor.c
38129 index ea2f8e7..70ac501 100644
38130 --- a/drivers/cpuidle/governor.c
38131 +++ b/drivers/cpuidle/governor.c
38132 @@ -87,7 +87,7 @@ int cpuidle_register_governor(struct cpuidle_governor *gov)
38133 mutex_lock(&cpuidle_lock);
38134 if (__cpuidle_find_governor(gov->name) == NULL) {
38135 ret = 0;
38136 - list_add_tail(&gov->governor_list, &cpuidle_governors);
38137 + pax_list_add_tail((struct list_head *)&gov->governor_list, &cpuidle_governors);
38138 if (!cpuidle_curr_governor ||
38139 cpuidle_curr_governor->rating < gov->rating)
38140 cpuidle_switch_governor(gov);
38141 @@ -135,7 +135,7 @@ void cpuidle_unregister_governor(struct cpuidle_governor *gov)
38142 new_gov = cpuidle_replace_governor(gov->rating);
38143 cpuidle_switch_governor(new_gov);
38144 }
38145 - list_del(&gov->governor_list);
38146 + pax_list_del((struct list_head *)&gov->governor_list);
38147 mutex_unlock(&cpuidle_lock);
38148 }
38149
38150 diff --git a/drivers/cpuidle/sysfs.c b/drivers/cpuidle/sysfs.c
38151 index 8739cc0..dc859d0 100644
38152 --- a/drivers/cpuidle/sysfs.c
38153 +++ b/drivers/cpuidle/sysfs.c
38154 @@ -134,7 +134,7 @@ static struct attribute *cpuidle_switch_attrs[] = {
38155 NULL
38156 };
38157
38158 -static struct attribute_group cpuidle_attr_group = {
38159 +static attribute_group_no_const cpuidle_attr_group = {
38160 .attrs = cpuidle_default_attrs,
38161 .name = "cpuidle",
38162 };
38163 diff --git a/drivers/crypto/hifn_795x.c b/drivers/crypto/hifn_795x.c
38164 index 12fea3e..1e28f47 100644
38165 --- a/drivers/crypto/hifn_795x.c
38166 +++ b/drivers/crypto/hifn_795x.c
38167 @@ -51,7 +51,7 @@ module_param_string(hifn_pll_ref, hifn_pll_ref, sizeof(hifn_pll_ref), 0444);
38168 MODULE_PARM_DESC(hifn_pll_ref,
38169 "PLL reference clock (pci[freq] or ext[freq], default ext)");
38170
38171 -static atomic_t hifn_dev_number;
38172 +static atomic_unchecked_t hifn_dev_number;
38173
38174 #define ACRYPTO_OP_DECRYPT 0
38175 #define ACRYPTO_OP_ENCRYPT 1
38176 @@ -2577,7 +2577,7 @@ static int hifn_probe(struct pci_dev *pdev, const struct pci_device_id *id)
38177 goto err_out_disable_pci_device;
38178
38179 snprintf(name, sizeof(name), "hifn%d",
38180 - atomic_inc_return(&hifn_dev_number)-1);
38181 + atomic_inc_return_unchecked(&hifn_dev_number)-1);
38182
38183 err = pci_request_regions(pdev, name);
38184 if (err)
38185 diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
38186 index c99c00d..990a4b2 100644
38187 --- a/drivers/devfreq/devfreq.c
38188 +++ b/drivers/devfreq/devfreq.c
38189 @@ -607,7 +607,7 @@ int devfreq_add_governor(struct devfreq_governor *governor)
38190 goto err_out;
38191 }
38192
38193 - list_add(&governor->node, &devfreq_governor_list);
38194 + pax_list_add((struct list_head *)&governor->node, &devfreq_governor_list);
38195
38196 list_for_each_entry(devfreq, &devfreq_list, node) {
38197 int ret = 0;
38198 @@ -695,7 +695,7 @@ int devfreq_remove_governor(struct devfreq_governor *governor)
38199 }
38200 }
38201
38202 - list_del(&governor->node);
38203 + pax_list_del((struct list_head *)&governor->node);
38204 err_out:
38205 mutex_unlock(&devfreq_list_lock);
38206
38207 diff --git a/drivers/dma/sh/shdmac.c b/drivers/dma/sh/shdmac.c
38208 index 1069e88..dfcd642 100644
38209 --- a/drivers/dma/sh/shdmac.c
38210 +++ b/drivers/dma/sh/shdmac.c
38211 @@ -511,7 +511,7 @@ static int sh_dmae_nmi_handler(struct notifier_block *self,
38212 return ret;
38213 }
38214
38215 -static struct notifier_block sh_dmae_nmi_notifier __read_mostly = {
38216 +static struct notifier_block sh_dmae_nmi_notifier = {
38217 .notifier_call = sh_dmae_nmi_handler,
38218
38219 /* Run before NMI debug handler and KGDB */
38220 diff --git a/drivers/edac/edac_device.c b/drivers/edac/edac_device.c
38221 index 211021d..201d47f 100644
38222 --- a/drivers/edac/edac_device.c
38223 +++ b/drivers/edac/edac_device.c
38224 @@ -474,9 +474,9 @@ void edac_device_reset_delay_period(struct edac_device_ctl_info *edac_dev,
38225 */
38226 int edac_device_alloc_index(void)
38227 {
38228 - static atomic_t device_indexes = ATOMIC_INIT(0);
38229 + static atomic_unchecked_t device_indexes = ATOMIC_INIT(0);
38230
38231 - return atomic_inc_return(&device_indexes) - 1;
38232 + return atomic_inc_return_unchecked(&device_indexes) - 1;
38233 }
38234 EXPORT_SYMBOL_GPL(edac_device_alloc_index);
38235
38236 diff --git a/drivers/edac/edac_mc_sysfs.c b/drivers/edac/edac_mc_sysfs.c
38237 index 9f7e0e60..348c875 100644
38238 --- a/drivers/edac/edac_mc_sysfs.c
38239 +++ b/drivers/edac/edac_mc_sysfs.c
38240 @@ -150,7 +150,7 @@ static const char * const edac_caps[] = {
38241 struct dev_ch_attribute {
38242 struct device_attribute attr;
38243 int channel;
38244 -};
38245 +} __do_const;
38246
38247 #define DEVICE_CHANNEL(_name, _mode, _show, _store, _var) \
38248 struct dev_ch_attribute dev_attr_legacy_##_name = \
38249 @@ -1007,14 +1007,16 @@ int edac_create_sysfs_mci_device(struct mem_ctl_info *mci)
38250 }
38251
38252 if (mci->set_sdram_scrub_rate || mci->get_sdram_scrub_rate) {
38253 + pax_open_kernel();
38254 if (mci->get_sdram_scrub_rate) {
38255 - dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38256 - dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38257 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IRUGO;
38258 + *(void **)&dev_attr_sdram_scrub_rate.show = &mci_sdram_scrub_rate_show;
38259 }
38260 if (mci->set_sdram_scrub_rate) {
38261 - dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38262 - dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38263 + *(umode_t *)&dev_attr_sdram_scrub_rate.attr.mode |= S_IWUSR;
38264 + *(void **)&dev_attr_sdram_scrub_rate.store = &mci_sdram_scrub_rate_store;
38265 }
38266 + pax_close_kernel();
38267 err = device_create_file(&mci->dev,
38268 &dev_attr_sdram_scrub_rate);
38269 if (err) {
38270 diff --git a/drivers/edac/edac_pci.c b/drivers/edac/edac_pci.c
38271 index dd370f9..0281629 100644
38272 --- a/drivers/edac/edac_pci.c
38273 +++ b/drivers/edac/edac_pci.c
38274 @@ -29,7 +29,7 @@
38275
38276 static DEFINE_MUTEX(edac_pci_ctls_mutex);
38277 static LIST_HEAD(edac_pci_list);
38278 -static atomic_t pci_indexes = ATOMIC_INIT(0);
38279 +static atomic_unchecked_t pci_indexes = ATOMIC_INIT(0);
38280
38281 /*
38282 * edac_pci_alloc_ctl_info
38283 @@ -315,7 +315,7 @@ EXPORT_SYMBOL_GPL(edac_pci_reset_delay_period);
38284 */
38285 int edac_pci_alloc_index(void)
38286 {
38287 - return atomic_inc_return(&pci_indexes) - 1;
38288 + return atomic_inc_return_unchecked(&pci_indexes) - 1;
38289 }
38290 EXPORT_SYMBOL_GPL(edac_pci_alloc_index);
38291
38292 diff --git a/drivers/edac/edac_pci_sysfs.c b/drivers/edac/edac_pci_sysfs.c
38293 index e8658e4..22746d6 100644
38294 --- a/drivers/edac/edac_pci_sysfs.c
38295 +++ b/drivers/edac/edac_pci_sysfs.c
38296 @@ -26,8 +26,8 @@ static int edac_pci_log_pe = 1; /* log PCI parity errors */
38297 static int edac_pci_log_npe = 1; /* log PCI non-parity error errors */
38298 static int edac_pci_poll_msec = 1000; /* one second workq period */
38299
38300 -static atomic_t pci_parity_count = ATOMIC_INIT(0);
38301 -static atomic_t pci_nonparity_count = ATOMIC_INIT(0);
38302 +static atomic_unchecked_t pci_parity_count = ATOMIC_INIT(0);
38303 +static atomic_unchecked_t pci_nonparity_count = ATOMIC_INIT(0);
38304
38305 static struct kobject *edac_pci_top_main_kobj;
38306 static atomic_t edac_pci_sysfs_refcount = ATOMIC_INIT(0);
38307 @@ -235,7 +235,7 @@ struct edac_pci_dev_attribute {
38308 void *value;
38309 ssize_t(*show) (void *, char *);
38310 ssize_t(*store) (void *, const char *, size_t);
38311 -};
38312 +} __do_const;
38313
38314 /* Set of show/store abstract level functions for PCI Parity object */
38315 static ssize_t edac_pci_dev_show(struct kobject *kobj, struct attribute *attr,
38316 @@ -579,7 +579,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38317 edac_printk(KERN_CRIT, EDAC_PCI,
38318 "Signaled System Error on %s\n",
38319 pci_name(dev));
38320 - atomic_inc(&pci_nonparity_count);
38321 + atomic_inc_unchecked(&pci_nonparity_count);
38322 }
38323
38324 if (status & (PCI_STATUS_PARITY)) {
38325 @@ -587,7 +587,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38326 "Master Data Parity Error on %s\n",
38327 pci_name(dev));
38328
38329 - atomic_inc(&pci_parity_count);
38330 + atomic_inc_unchecked(&pci_parity_count);
38331 }
38332
38333 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38334 @@ -595,7 +595,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38335 "Detected Parity Error on %s\n",
38336 pci_name(dev));
38337
38338 - atomic_inc(&pci_parity_count);
38339 + atomic_inc_unchecked(&pci_parity_count);
38340 }
38341 }
38342
38343 @@ -618,7 +618,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38344 edac_printk(KERN_CRIT, EDAC_PCI, "Bridge "
38345 "Signaled System Error on %s\n",
38346 pci_name(dev));
38347 - atomic_inc(&pci_nonparity_count);
38348 + atomic_inc_unchecked(&pci_nonparity_count);
38349 }
38350
38351 if (status & (PCI_STATUS_PARITY)) {
38352 @@ -626,7 +626,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38353 "Master Data Parity Error on "
38354 "%s\n", pci_name(dev));
38355
38356 - atomic_inc(&pci_parity_count);
38357 + atomic_inc_unchecked(&pci_parity_count);
38358 }
38359
38360 if (status & (PCI_STATUS_DETECTED_PARITY)) {
38361 @@ -634,7 +634,7 @@ static void edac_pci_dev_parity_test(struct pci_dev *dev)
38362 "Detected Parity Error on %s\n",
38363 pci_name(dev));
38364
38365 - atomic_inc(&pci_parity_count);
38366 + atomic_inc_unchecked(&pci_parity_count);
38367 }
38368 }
38369 }
38370 @@ -672,7 +672,7 @@ void edac_pci_do_parity_check(void)
38371 if (!check_pci_errors)
38372 return;
38373
38374 - before_count = atomic_read(&pci_parity_count);
38375 + before_count = atomic_read_unchecked(&pci_parity_count);
38376
38377 /* scan all PCI devices looking for a Parity Error on devices and
38378 * bridges.
38379 @@ -684,7 +684,7 @@ void edac_pci_do_parity_check(void)
38380 /* Only if operator has selected panic on PCI Error */
38381 if (edac_pci_get_panic_on_pe()) {
38382 /* If the count is different 'after' from 'before' */
38383 - if (before_count != atomic_read(&pci_parity_count))
38384 + if (before_count != atomic_read_unchecked(&pci_parity_count))
38385 panic("EDAC: PCI Parity Error");
38386 }
38387 }
38388 diff --git a/drivers/edac/mce_amd.h b/drivers/edac/mce_amd.h
38389 index 51b7e3a..aa8a3e8 100644
38390 --- a/drivers/edac/mce_amd.h
38391 +++ b/drivers/edac/mce_amd.h
38392 @@ -77,7 +77,7 @@ struct amd_decoder_ops {
38393 bool (*mc0_mce)(u16, u8);
38394 bool (*mc1_mce)(u16, u8);
38395 bool (*mc2_mce)(u16, u8);
38396 -};
38397 +} __no_const;
38398
38399 void amd_report_gart_errors(bool);
38400 void amd_register_ecc_decoder(void (*f)(int, struct mce *));
38401 diff --git a/drivers/firewire/core-card.c b/drivers/firewire/core-card.c
38402 index 57ea7f4..af06b76 100644
38403 --- a/drivers/firewire/core-card.c
38404 +++ b/drivers/firewire/core-card.c
38405 @@ -528,9 +528,9 @@ void fw_card_initialize(struct fw_card *card,
38406 const struct fw_card_driver *driver,
38407 struct device *device)
38408 {
38409 - static atomic_t index = ATOMIC_INIT(-1);
38410 + static atomic_unchecked_t index = ATOMIC_INIT(-1);
38411
38412 - card->index = atomic_inc_return(&index);
38413 + card->index = atomic_inc_return_unchecked(&index);
38414 card->driver = driver;
38415 card->device = device;
38416 card->current_tlabel = 0;
38417 @@ -680,7 +680,7 @@ EXPORT_SYMBOL_GPL(fw_card_release);
38418
38419 void fw_core_remove_card(struct fw_card *card)
38420 {
38421 - struct fw_card_driver dummy_driver = dummy_driver_template;
38422 + fw_card_driver_no_const dummy_driver = dummy_driver_template;
38423
38424 card->driver->update_phy_reg(card, 4,
38425 PHY_LINK_ACTIVE | PHY_CONTENDER, 0);
38426 diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c
38427 index de4aa40..49ab1f2 100644
38428 --- a/drivers/firewire/core-device.c
38429 +++ b/drivers/firewire/core-device.c
38430 @@ -253,7 +253,7 @@ EXPORT_SYMBOL(fw_device_enable_phys_dma);
38431 struct config_rom_attribute {
38432 struct device_attribute attr;
38433 u32 key;
38434 -};
38435 +} __do_const;
38436
38437 static ssize_t show_immediate(struct device *dev,
38438 struct device_attribute *dattr, char *buf)
38439 diff --git a/drivers/firewire/core-transaction.c b/drivers/firewire/core-transaction.c
38440 index e5af0e3..d318058 100644
38441 --- a/drivers/firewire/core-transaction.c
38442 +++ b/drivers/firewire/core-transaction.c
38443 @@ -38,6 +38,7 @@
38444 #include <linux/timer.h>
38445 #include <linux/types.h>
38446 #include <linux/workqueue.h>
38447 +#include <linux/sched.h>
38448
38449 #include <asm/byteorder.h>
38450
38451 diff --git a/drivers/firewire/core.h b/drivers/firewire/core.h
38452 index 515a42c..5ecf3ba 100644
38453 --- a/drivers/firewire/core.h
38454 +++ b/drivers/firewire/core.h
38455 @@ -111,6 +111,7 @@ struct fw_card_driver {
38456
38457 int (*stop_iso)(struct fw_iso_context *ctx);
38458 };
38459 +typedef struct fw_card_driver __no_const fw_card_driver_no_const;
38460
38461 void fw_card_initialize(struct fw_card *card,
38462 const struct fw_card_driver *driver, struct device *device);
38463 diff --git a/drivers/firmware/dmi-id.c b/drivers/firmware/dmi-id.c
38464 index 94a58a0..f5eba42 100644
38465 --- a/drivers/firmware/dmi-id.c
38466 +++ b/drivers/firmware/dmi-id.c
38467 @@ -16,7 +16,7 @@
38468 struct dmi_device_attribute{
38469 struct device_attribute dev_attr;
38470 int field;
38471 -};
38472 +} __do_const;
38473 #define to_dmi_dev_attr(_dev_attr) \
38474 container_of(_dev_attr, struct dmi_device_attribute, dev_attr)
38475
38476 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
38477 index fa0affb..aa448eb 100644
38478 --- a/drivers/firmware/dmi_scan.c
38479 +++ b/drivers/firmware/dmi_scan.c
38480 @@ -791,7 +791,7 @@ int dmi_walk(void (*decode)(const struct dmi_header *, void *),
38481 if (buf == NULL)
38482 return -1;
38483
38484 - dmi_table(buf, dmi_len, dmi_num, decode, private_data);
38485 + dmi_table((char __force_kernel *)buf, dmi_len, dmi_num, decode, private_data);
38486
38487 iounmap(buf);
38488 return 0;
38489 diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
38490 index 5145fa3..0d3babd 100644
38491 --- a/drivers/firmware/efi/efi.c
38492 +++ b/drivers/firmware/efi/efi.c
38493 @@ -65,14 +65,16 @@ static struct attribute_group efi_subsys_attr_group = {
38494 };
38495
38496 static struct efivars generic_efivars;
38497 -static struct efivar_operations generic_ops;
38498 +static efivar_operations_no_const generic_ops __read_only;
38499
38500 static int generic_ops_register(void)
38501 {
38502 - generic_ops.get_variable = efi.get_variable;
38503 - generic_ops.set_variable = efi.set_variable;
38504 - generic_ops.get_next_variable = efi.get_next_variable;
38505 - generic_ops.query_variable_store = efi_query_variable_store;
38506 + pax_open_kernel();
38507 + *(void **)&generic_ops.get_variable = efi.get_variable;
38508 + *(void **)&generic_ops.set_variable = efi.set_variable;
38509 + *(void **)&generic_ops.get_next_variable = efi.get_next_variable;
38510 + *(void **)&generic_ops.query_variable_store = efi_query_variable_store;
38511 + pax_close_kernel();
38512
38513 return efivars_register(&generic_efivars, &generic_ops, efi_kobj);
38514 }
38515 diff --git a/drivers/firmware/efi/efivars.c b/drivers/firmware/efi/efivars.c
38516 index 8c5a61a..cf07bd0 100644
38517 --- a/drivers/firmware/efi/efivars.c
38518 +++ b/drivers/firmware/efi/efivars.c
38519 @@ -456,7 +456,7 @@ efivar_create_sysfs_entry(struct efivar_entry *new_var)
38520 static int
38521 create_efivars_bin_attributes(void)
38522 {
38523 - struct bin_attribute *attr;
38524 + bin_attribute_no_const *attr;
38525 int error;
38526
38527 /* new_var */
38528 diff --git a/drivers/firmware/google/memconsole.c b/drivers/firmware/google/memconsole.c
38529 index 2a90ba6..07f3733 100644
38530 --- a/drivers/firmware/google/memconsole.c
38531 +++ b/drivers/firmware/google/memconsole.c
38532 @@ -147,7 +147,9 @@ static int __init memconsole_init(void)
38533 if (!found_memconsole())
38534 return -ENODEV;
38535
38536 - memconsole_bin_attr.size = memconsole_length;
38537 + pax_open_kernel();
38538 + *(size_t *)&memconsole_bin_attr.size = memconsole_length;
38539 + pax_close_kernel();
38540
38541 ret = sysfs_create_bin_file(firmware_kobj, &memconsole_bin_attr);
38542
38543 diff --git a/drivers/gpio/gpio-ich.c b/drivers/gpio/gpio-ich.c
38544 index 814addb..0937d7f 100644
38545 --- a/drivers/gpio/gpio-ich.c
38546 +++ b/drivers/gpio/gpio-ich.c
38547 @@ -71,7 +71,7 @@ struct ichx_desc {
38548 /* Some chipsets have quirks, let these use their own request/get */
38549 int (*request)(struct gpio_chip *chip, unsigned offset);
38550 int (*get)(struct gpio_chip *chip, unsigned offset);
38551 -};
38552 +} __do_const;
38553
38554 static struct {
38555 spinlock_t lock;
38556 diff --git a/drivers/gpio/gpio-vr41xx.c b/drivers/gpio/gpio-vr41xx.c
38557 index 9902732..64b62dd 100644
38558 --- a/drivers/gpio/gpio-vr41xx.c
38559 +++ b/drivers/gpio/gpio-vr41xx.c
38560 @@ -204,7 +204,7 @@ static int giu_get_irq(unsigned int irq)
38561 printk(KERN_ERR "spurious GIU interrupt: %04x(%04x),%04x(%04x)\n",
38562 maskl, pendl, maskh, pendh);
38563
38564 - atomic_inc(&irq_err_count);
38565 + atomic_inc_unchecked(&irq_err_count);
38566
38567 return -EINVAL;
38568 }
38569 diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c
38570 index c722c3b..2ec6040 100644
38571 --- a/drivers/gpu/drm/drm_crtc_helper.c
38572 +++ b/drivers/gpu/drm/drm_crtc_helper.c
38573 @@ -328,7 +328,7 @@ static bool drm_encoder_crtc_ok(struct drm_encoder *encoder,
38574 struct drm_crtc *tmp;
38575 int crtc_mask = 1;
38576
38577 - WARN(!crtc, "checking null crtc?\n");
38578 + BUG_ON(!crtc);
38579
38580 dev = crtc->dev;
38581
38582 diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
38583 index fe58d08..07bc38e 100644
38584 --- a/drivers/gpu/drm/drm_drv.c
38585 +++ b/drivers/gpu/drm/drm_drv.c
38586 @@ -186,7 +186,7 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
38587 atomic_set(&dev->vma_count, 0);
38588
38589 for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
38590 - atomic_set(&dev->counts[i], 0);
38591 + atomic_set_unchecked(&dev->counts[i], 0);
38592
38593 dev->sigdata.lock = NULL;
38594
38595 @@ -302,7 +302,7 @@ module_exit(drm_core_exit);
38596 /**
38597 * Copy and IOCTL return string to user space
38598 */
38599 -static int drm_copy_field(char *buf, size_t *buf_len, const char *value)
38600 +static int drm_copy_field(char __user *buf, size_t *buf_len, const char *value)
38601 {
38602 int len;
38603
38604 @@ -372,7 +372,7 @@ long drm_ioctl(struct file *filp,
38605 struct drm_file *file_priv = filp->private_data;
38606 struct drm_device *dev;
38607 const struct drm_ioctl_desc *ioctl = NULL;
38608 - drm_ioctl_t *func;
38609 + drm_ioctl_no_const_t func;
38610 unsigned int nr = DRM_IOCTL_NR(cmd);
38611 int retcode = -EINVAL;
38612 char stack_kdata[128];
38613 @@ -385,7 +385,7 @@ long drm_ioctl(struct file *filp,
38614 return -ENODEV;
38615
38616 atomic_inc(&dev->ioctl_count);
38617 - atomic_inc(&dev->counts[_DRM_STAT_IOCTLS]);
38618 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_IOCTLS]);
38619 ++file_priv->ioctl_count;
38620
38621 if ((nr >= DRM_CORE_IOCTL_COUNT) &&
38622 diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
38623 index 3f84277..c627c54 100644
38624 --- a/drivers/gpu/drm/drm_fops.c
38625 +++ b/drivers/gpu/drm/drm_fops.c
38626 @@ -97,7 +97,7 @@ int drm_open(struct inode *inode, struct file *filp)
38627 if (drm_device_is_unplugged(dev))
38628 return -ENODEV;
38629
38630 - if (!dev->open_count++)
38631 + if (local_inc_return(&dev->open_count) == 1)
38632 need_setup = 1;
38633 mutex_lock(&dev->struct_mutex);
38634 old_imapping = inode->i_mapping;
38635 @@ -113,7 +113,7 @@ int drm_open(struct inode *inode, struct file *filp)
38636 retcode = drm_open_helper(inode, filp, dev);
38637 if (retcode)
38638 goto err_undo;
38639 - atomic_inc(&dev->counts[_DRM_STAT_OPENS]);
38640 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_OPENS]);
38641 if (need_setup) {
38642 retcode = drm_setup(dev);
38643 if (retcode)
38644 @@ -128,7 +128,7 @@ err_undo:
38645 iput(container_of(dev->dev_mapping, struct inode, i_data));
38646 dev->dev_mapping = old_mapping;
38647 mutex_unlock(&dev->struct_mutex);
38648 - dev->open_count--;
38649 + local_dec(&dev->open_count);
38650 return retcode;
38651 }
38652 EXPORT_SYMBOL(drm_open);
38653 @@ -405,7 +405,7 @@ int drm_release(struct inode *inode, struct file *filp)
38654
38655 mutex_lock(&drm_global_mutex);
38656
38657 - DRM_DEBUG("open_count = %d\n", dev->open_count);
38658 + DRM_DEBUG("open_count = %ld\n", local_read(&dev->open_count));
38659
38660 if (dev->driver->preclose)
38661 dev->driver->preclose(dev, file_priv);
38662 @@ -414,10 +414,10 @@ int drm_release(struct inode *inode, struct file *filp)
38663 * Begin inline drm_release
38664 */
38665
38666 - DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
38667 + DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %ld\n",
38668 task_pid_nr(current),
38669 (long)old_encode_dev(file_priv->minor->device),
38670 - dev->open_count);
38671 + local_read(&dev->open_count));
38672
38673 /* Release any auth tokens that might point to this file_priv,
38674 (do that under the drm_global_mutex) */
38675 @@ -516,8 +516,8 @@ int drm_release(struct inode *inode, struct file *filp)
38676 * End inline drm_release
38677 */
38678
38679 - atomic_inc(&dev->counts[_DRM_STAT_CLOSES]);
38680 - if (!--dev->open_count) {
38681 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_CLOSES]);
38682 + if (local_dec_and_test(&dev->open_count)) {
38683 if (atomic_read(&dev->ioctl_count)) {
38684 DRM_ERROR("Device busy: %d\n",
38685 atomic_read(&dev->ioctl_count));
38686 diff --git a/drivers/gpu/drm/drm_global.c b/drivers/gpu/drm/drm_global.c
38687 index f731116..629842c 100644
38688 --- a/drivers/gpu/drm/drm_global.c
38689 +++ b/drivers/gpu/drm/drm_global.c
38690 @@ -36,7 +36,7 @@
38691 struct drm_global_item {
38692 struct mutex mutex;
38693 void *object;
38694 - int refcount;
38695 + atomic_t refcount;
38696 };
38697
38698 static struct drm_global_item glob[DRM_GLOBAL_NUM];
38699 @@ -49,7 +49,7 @@ void drm_global_init(void)
38700 struct drm_global_item *item = &glob[i];
38701 mutex_init(&item->mutex);
38702 item->object = NULL;
38703 - item->refcount = 0;
38704 + atomic_set(&item->refcount, 0);
38705 }
38706 }
38707
38708 @@ -59,7 +59,7 @@ void drm_global_release(void)
38709 for (i = 0; i < DRM_GLOBAL_NUM; ++i) {
38710 struct drm_global_item *item = &glob[i];
38711 BUG_ON(item->object != NULL);
38712 - BUG_ON(item->refcount != 0);
38713 + BUG_ON(atomic_read(&item->refcount) != 0);
38714 }
38715 }
38716
38717 @@ -70,7 +70,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38718 void *object;
38719
38720 mutex_lock(&item->mutex);
38721 - if (item->refcount == 0) {
38722 + if (atomic_read(&item->refcount) == 0) {
38723 item->object = kzalloc(ref->size, GFP_KERNEL);
38724 if (unlikely(item->object == NULL)) {
38725 ret = -ENOMEM;
38726 @@ -83,7 +83,7 @@ int drm_global_item_ref(struct drm_global_reference *ref)
38727 goto out_err;
38728
38729 }
38730 - ++item->refcount;
38731 + atomic_inc(&item->refcount);
38732 ref->object = item->object;
38733 object = item->object;
38734 mutex_unlock(&item->mutex);
38735 @@ -100,9 +100,9 @@ void drm_global_item_unref(struct drm_global_reference *ref)
38736 struct drm_global_item *item = &glob[ref->global_type];
38737
38738 mutex_lock(&item->mutex);
38739 - BUG_ON(item->refcount == 0);
38740 + BUG_ON(atomic_read(&item->refcount) == 0);
38741 BUG_ON(ref->object != item->object);
38742 - if (--item->refcount == 0) {
38743 + if (atomic_dec_and_test(&item->refcount)) {
38744 ref->release(ref);
38745 item->object = NULL;
38746 }
38747 diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
38748 index 5329832..b503f49 100644
38749 --- a/drivers/gpu/drm/drm_info.c
38750 +++ b/drivers/gpu/drm/drm_info.c
38751 @@ -75,10 +75,14 @@ int drm_vm_info(struct seq_file *m, void *data)
38752 struct drm_local_map *map;
38753 struct drm_map_list *r_list;
38754
38755 - /* Hardcoded from _DRM_FRAME_BUFFER,
38756 - _DRM_REGISTERS, _DRM_SHM, _DRM_AGP, and
38757 - _DRM_SCATTER_GATHER and _DRM_CONSISTENT */
38758 - const char *types[] = { "FB", "REG", "SHM", "AGP", "SG", "PCI" };
38759 + static const char * const types[] = {
38760 + [_DRM_FRAME_BUFFER] = "FB",
38761 + [_DRM_REGISTERS] = "REG",
38762 + [_DRM_SHM] = "SHM",
38763 + [_DRM_AGP] = "AGP",
38764 + [_DRM_SCATTER_GATHER] = "SG",
38765 + [_DRM_CONSISTENT] = "PCI",
38766 + [_DRM_GEM] = "GEM" };
38767 const char *type;
38768 int i;
38769
38770 @@ -89,7 +93,7 @@ int drm_vm_info(struct seq_file *m, void *data)
38771 map = r_list->map;
38772 if (!map)
38773 continue;
38774 - if (map->type < 0 || map->type > 5)
38775 + if (map->type >= ARRAY_SIZE(types))
38776 type = "??";
38777 else
38778 type = types[map->type];
38779 @@ -257,7 +261,11 @@ int drm_vma_info(struct seq_file *m, void *data)
38780 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
38781 vma->vm_flags & VM_LOCKED ? 'l' : '-',
38782 vma->vm_flags & VM_IO ? 'i' : '-',
38783 +#ifdef CONFIG_GRKERNSEC_HIDESYM
38784 + 0);
38785 +#else
38786 vma->vm_pgoff);
38787 +#endif
38788
38789 #if defined(__i386__)
38790 pgprot = pgprot_val(vma->vm_page_prot);
38791 diff --git a/drivers/gpu/drm/drm_ioc32.c b/drivers/gpu/drm/drm_ioc32.c
38792 index 2f4c434..dd12cd2 100644
38793 --- a/drivers/gpu/drm/drm_ioc32.c
38794 +++ b/drivers/gpu/drm/drm_ioc32.c
38795 @@ -457,7 +457,7 @@ static int compat_drm_infobufs(struct file *file, unsigned int cmd,
38796 request = compat_alloc_user_space(nbytes);
38797 if (!access_ok(VERIFY_WRITE, request, nbytes))
38798 return -EFAULT;
38799 - list = (struct drm_buf_desc *) (request + 1);
38800 + list = (struct drm_buf_desc __user *) (request + 1);
38801
38802 if (__put_user(count, &request->count)
38803 || __put_user(list, &request->list))
38804 @@ -518,7 +518,7 @@ static int compat_drm_mapbufs(struct file *file, unsigned int cmd,
38805 request = compat_alloc_user_space(nbytes);
38806 if (!access_ok(VERIFY_WRITE, request, nbytes))
38807 return -EFAULT;
38808 - list = (struct drm_buf_pub *) (request + 1);
38809 + list = (struct drm_buf_pub __user *) (request + 1);
38810
38811 if (__put_user(count, &request->count)
38812 || __put_user(list, &request->list))
38813 @@ -1016,7 +1016,7 @@ static int compat_drm_wait_vblank(struct file *file, unsigned int cmd,
38814 return 0;
38815 }
38816
38817 -drm_ioctl_compat_t *drm_compat_ioctls[] = {
38818 +drm_ioctl_compat_t drm_compat_ioctls[] = {
38819 [DRM_IOCTL_NR(DRM_IOCTL_VERSION32)] = compat_drm_version,
38820 [DRM_IOCTL_NR(DRM_IOCTL_GET_UNIQUE32)] = compat_drm_getunique,
38821 [DRM_IOCTL_NR(DRM_IOCTL_GET_MAP32)] = compat_drm_getmap,
38822 @@ -1062,7 +1062,6 @@ drm_ioctl_compat_t *drm_compat_ioctls[] = {
38823 long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38824 {
38825 unsigned int nr = DRM_IOCTL_NR(cmd);
38826 - drm_ioctl_compat_t *fn;
38827 int ret;
38828
38829 /* Assume that ioctls without an explicit compat routine will just
38830 @@ -1072,10 +1071,8 @@ long drm_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
38831 if (nr >= ARRAY_SIZE(drm_compat_ioctls))
38832 return drm_ioctl(filp, cmd, arg);
38833
38834 - fn = drm_compat_ioctls[nr];
38835 -
38836 - if (fn != NULL)
38837 - ret = (*fn) (filp, cmd, arg);
38838 + if (drm_compat_ioctls[nr] != NULL)
38839 + ret = (*drm_compat_ioctls[nr]) (filp, cmd, arg);
38840 else
38841 ret = drm_ioctl(filp, cmd, arg);
38842
38843 diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
38844 index d752c96..fe08455 100644
38845 --- a/drivers/gpu/drm/drm_lock.c
38846 +++ b/drivers/gpu/drm/drm_lock.c
38847 @@ -86,7 +86,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38848 if (drm_lock_take(&master->lock, lock->context)) {
38849 master->lock.file_priv = file_priv;
38850 master->lock.lock_time = jiffies;
38851 - atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
38852 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_LOCKS]);
38853 break; /* Got lock */
38854 }
38855
38856 @@ -157,7 +157,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
38857 return -EINVAL;
38858 }
38859
38860 - atomic_inc(&dev->counts[_DRM_STAT_UNLOCKS]);
38861 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_UNLOCKS]);
38862
38863 if (drm_lock_free(&master->lock, lock->context)) {
38864 /* FIXME: Should really bail out here. */
38865 diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c
38866 index 39d8645..59e06fa 100644
38867 --- a/drivers/gpu/drm/drm_stub.c
38868 +++ b/drivers/gpu/drm/drm_stub.c
38869 @@ -484,7 +484,7 @@ void drm_unplug_dev(struct drm_device *dev)
38870
38871 drm_device_set_unplugged(dev);
38872
38873 - if (dev->open_count == 0) {
38874 + if (local_read(&dev->open_count) == 0) {
38875 drm_put_dev(dev);
38876 }
38877 mutex_unlock(&drm_global_mutex);
38878 diff --git a/drivers/gpu/drm/drm_sysfs.c b/drivers/gpu/drm/drm_sysfs.c
38879 index 2290b3b..22056a1 100644
38880 --- a/drivers/gpu/drm/drm_sysfs.c
38881 +++ b/drivers/gpu/drm/drm_sysfs.c
38882 @@ -524,7 +524,7 @@ EXPORT_SYMBOL(drm_sysfs_hotplug_event);
38883 int drm_sysfs_device_add(struct drm_minor *minor)
38884 {
38885 int err;
38886 - char *minor_str;
38887 + const char *minor_str;
38888
38889 minor->kdev.parent = minor->dev->dev;
38890
38891 diff --git a/drivers/gpu/drm/i810/i810_dma.c b/drivers/gpu/drm/i810/i810_dma.c
38892 index ab1892eb..d7009ca 100644
38893 --- a/drivers/gpu/drm/i810/i810_dma.c
38894 +++ b/drivers/gpu/drm/i810/i810_dma.c
38895 @@ -944,8 +944,8 @@ static int i810_dma_vertex(struct drm_device *dev, void *data,
38896 dma->buflist[vertex->idx],
38897 vertex->discard, vertex->used);
38898
38899 - atomic_add(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38900 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38901 + atomic_add_unchecked(vertex->used, &dev->counts[_DRM_STAT_SECONDARY]);
38902 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38903 sarea_priv->last_enqueue = dev_priv->counter - 1;
38904 sarea_priv->last_dispatch = (int)hw_status[5];
38905
38906 @@ -1105,8 +1105,8 @@ static int i810_dma_mc(struct drm_device *dev, void *data,
38907 i810_dma_dispatch_mc(dev, dma->buflist[mc->idx], mc->used,
38908 mc->last_render);
38909
38910 - atomic_add(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38911 - atomic_inc(&dev->counts[_DRM_STAT_DMA]);
38912 + atomic_add_unchecked(mc->used, &dev->counts[_DRM_STAT_SECONDARY]);
38913 + atomic_inc_unchecked(&dev->counts[_DRM_STAT_DMA]);
38914 sarea_priv->last_enqueue = dev_priv->counter - 1;
38915 sarea_priv->last_dispatch = (int)hw_status[5];
38916
38917 diff --git a/drivers/gpu/drm/i810/i810_drv.h b/drivers/gpu/drm/i810/i810_drv.h
38918 index d4d16ed..8fb0b51 100644
38919 --- a/drivers/gpu/drm/i810/i810_drv.h
38920 +++ b/drivers/gpu/drm/i810/i810_drv.h
38921 @@ -108,8 +108,8 @@ typedef struct drm_i810_private {
38922 int page_flipping;
38923
38924 wait_queue_head_t irq_queue;
38925 - atomic_t irq_received;
38926 - atomic_t irq_emitted;
38927 + atomic_unchecked_t irq_received;
38928 + atomic_unchecked_t irq_emitted;
38929
38930 int front_offset;
38931 } drm_i810_private_t;
38932 diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
38933 index a6f4cb5..6b2beb2 100644
38934 --- a/drivers/gpu/drm/i915/i915_debugfs.c
38935 +++ b/drivers/gpu/drm/i915/i915_debugfs.c
38936 @@ -624,7 +624,7 @@ static int i915_interrupt_info(struct seq_file *m, void *data)
38937 I915_READ(GTIMR));
38938 }
38939 seq_printf(m, "Interrupts received: %d\n",
38940 - atomic_read(&dev_priv->irq_received));
38941 + atomic_read_unchecked(&dev_priv->irq_received));
38942 for_each_ring(ring, dev_priv, i) {
38943 if (IS_GEN6(dev) || IS_GEN7(dev)) {
38944 seq_printf(m,
38945 diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c
38946 index 5a25f24..5af2004 100644
38947 --- a/drivers/gpu/drm/i915/i915_dma.c
38948 +++ b/drivers/gpu/drm/i915/i915_dma.c
38949 @@ -1271,7 +1271,7 @@ static bool i915_switcheroo_can_switch(struct pci_dev *pdev)
38950 bool can_switch;
38951
38952 spin_lock(&dev->count_lock);
38953 - can_switch = (dev->open_count == 0);
38954 + can_switch = (local_read(&dev->open_count) == 0);
38955 spin_unlock(&dev->count_lock);
38956 return can_switch;
38957 }
38958 diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
38959 index ab0f2c0..53c1bda 100644
38960 --- a/drivers/gpu/drm/i915/i915_drv.h
38961 +++ b/drivers/gpu/drm/i915/i915_drv.h
38962 @@ -1181,7 +1181,7 @@ typedef struct drm_i915_private {
38963 drm_dma_handle_t *status_page_dmah;
38964 struct resource mch_res;
38965
38966 - atomic_t irq_received;
38967 + atomic_unchecked_t irq_received;
38968
38969 /* protects the irq masks */
38970 spinlock_t irq_lock;
38971 diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38972 index bf34577..3fd2ffa 100644
38973 --- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38974 +++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
38975 @@ -768,9 +768,9 @@ i915_gem_check_execbuffer(struct drm_i915_gem_execbuffer2 *exec)
38976
38977 static int
38978 validate_exec_list(struct drm_i915_gem_exec_object2 *exec,
38979 - int count)
38980 + unsigned int count)
38981 {
38982 - int i;
38983 + unsigned int i;
38984 int relocs_total = 0;
38985 int relocs_max = INT_MAX / sizeof(struct drm_i915_gem_relocation_entry);
38986
38987 diff --git a/drivers/gpu/drm/i915/i915_ioc32.c b/drivers/gpu/drm/i915/i915_ioc32.c
38988 index 3c59584..500f2e9 100644
38989 --- a/drivers/gpu/drm/i915/i915_ioc32.c
38990 +++ b/drivers/gpu/drm/i915/i915_ioc32.c
38991 @@ -181,7 +181,7 @@ static int compat_i915_alloc(struct file *file, unsigned int cmd,
38992 (unsigned long)request);
38993 }
38994
38995 -static drm_ioctl_compat_t *i915_compat_ioctls[] = {
38996 +static drm_ioctl_compat_t i915_compat_ioctls[] = {
38997 [DRM_I915_BATCHBUFFER] = compat_i915_batchbuffer,
38998 [DRM_I915_CMDBUFFER] = compat_i915_cmdbuffer,
38999 [DRM_I915_GETPARAM] = compat_i915_getparam,
39000 @@ -202,18 +202,15 @@ static drm_ioctl_compat_t *i915_compat_ioctls[] = {
39001 long i915_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39002 {
39003 unsigned int nr = DRM_IOCTL_NR(cmd);
39004 - drm_ioctl_compat_t *fn = NULL;
39005 int ret;
39006
39007 if (nr < DRM_COMMAND_BASE)
39008 return drm_compat_ioctl(filp, cmd, arg);
39009
39010 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls))
39011 - fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
39012 -
39013 - if (fn != NULL)
39014 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(i915_compat_ioctls)) {
39015 + drm_ioctl_compat_t fn = i915_compat_ioctls[nr - DRM_COMMAND_BASE];
39016 ret = (*fn) (filp, cmd, arg);
39017 - else
39018 + } else
39019 ret = drm_ioctl(filp, cmd, arg);
39020
39021 return ret;
39022 diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
39023 index 4b91228..590c643 100644
39024 --- a/drivers/gpu/drm/i915/i915_irq.c
39025 +++ b/drivers/gpu/drm/i915/i915_irq.c
39026 @@ -1085,7 +1085,7 @@ static irqreturn_t valleyview_irq_handler(int irq, void *arg)
39027 int pipe;
39028 u32 pipe_stats[I915_MAX_PIPES];
39029
39030 - atomic_inc(&dev_priv->irq_received);
39031 + atomic_inc_unchecked(&dev_priv->irq_received);
39032
39033 while (true) {
39034 iir = I915_READ(VLV_IIR);
39035 @@ -1390,7 +1390,7 @@ static irqreturn_t ironlake_irq_handler(int irq, void *arg)
39036 irqreturn_t ret = IRQ_NONE;
39037 bool err_int_reenable = false;
39038
39039 - atomic_inc(&dev_priv->irq_received);
39040 + atomic_inc_unchecked(&dev_priv->irq_received);
39041
39042 /* We get interrupts on unclaimed registers, so check for this before we
39043 * do any I915_{READ,WRITE}. */
39044 @@ -2146,7 +2146,7 @@ static void ironlake_irq_preinstall(struct drm_device *dev)
39045 {
39046 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39047
39048 - atomic_set(&dev_priv->irq_received, 0);
39049 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39050
39051 I915_WRITE(HWSTAM, 0xeffe);
39052
39053 @@ -2164,7 +2164,7 @@ static void valleyview_irq_preinstall(struct drm_device *dev)
39054 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39055 int pipe;
39056
39057 - atomic_set(&dev_priv->irq_received, 0);
39058 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39059
39060 /* VLV magic */
39061 I915_WRITE(VLV_IMR, 0);
39062 @@ -2452,7 +2452,7 @@ static void i8xx_irq_preinstall(struct drm_device * dev)
39063 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39064 int pipe;
39065
39066 - atomic_set(&dev_priv->irq_received, 0);
39067 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39068
39069 for_each_pipe(pipe)
39070 I915_WRITE(PIPESTAT(pipe), 0);
39071 @@ -2530,7 +2530,7 @@ static irqreturn_t i8xx_irq_handler(int irq, void *arg)
39072 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39073 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39074
39075 - atomic_inc(&dev_priv->irq_received);
39076 + atomic_inc_unchecked(&dev_priv->irq_received);
39077
39078 iir = I915_READ16(IIR);
39079 if (iir == 0)
39080 @@ -2604,7 +2604,7 @@ static void i915_irq_preinstall(struct drm_device * dev)
39081 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39082 int pipe;
39083
39084 - atomic_set(&dev_priv->irq_received, 0);
39085 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39086
39087 if (I915_HAS_HOTPLUG(dev)) {
39088 I915_WRITE(PORT_HOTPLUG_EN, 0);
39089 @@ -2703,7 +2703,7 @@ static irqreturn_t i915_irq_handler(int irq, void *arg)
39090 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39091 int pipe, ret = IRQ_NONE;
39092
39093 - atomic_inc(&dev_priv->irq_received);
39094 + atomic_inc_unchecked(&dev_priv->irq_received);
39095
39096 iir = I915_READ(IIR);
39097 do {
39098 @@ -2827,7 +2827,7 @@ static void i965_irq_preinstall(struct drm_device * dev)
39099 drm_i915_private_t *dev_priv = (drm_i915_private_t *) dev->dev_private;
39100 int pipe;
39101
39102 - atomic_set(&dev_priv->irq_received, 0);
39103 + atomic_set_unchecked(&dev_priv->irq_received, 0);
39104
39105 I915_WRITE(PORT_HOTPLUG_EN, 0);
39106 I915_WRITE(PORT_HOTPLUG_STAT, I915_READ(PORT_HOTPLUG_STAT));
39107 @@ -2941,7 +2941,7 @@ static irqreturn_t i965_irq_handler(int irq, void *arg)
39108 I915_DISPLAY_PLANE_A_FLIP_PENDING_INTERRUPT |
39109 I915_DISPLAY_PLANE_B_FLIP_PENDING_INTERRUPT;
39110
39111 - atomic_inc(&dev_priv->irq_received);
39112 + atomic_inc_unchecked(&dev_priv->irq_received);
39113
39114 iir = I915_READ(IIR);
39115
39116 diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
39117 index aad6f7b..dcc91447 100644
39118 --- a/drivers/gpu/drm/i915/intel_display.c
39119 +++ b/drivers/gpu/drm/i915/intel_display.c
39120 @@ -10019,13 +10019,13 @@ struct intel_quirk {
39121 int subsystem_vendor;
39122 int subsystem_device;
39123 void (*hook)(struct drm_device *dev);
39124 -};
39125 +} __do_const;
39126
39127 /* For systems that don't have a meaningful PCI subdevice/subvendor ID */
39128 struct intel_dmi_quirk {
39129 void (*hook)(struct drm_device *dev);
39130 const struct dmi_system_id (*dmi_id_list)[];
39131 -};
39132 +} __do_const;
39133
39134 static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39135 {
39136 @@ -10033,18 +10033,20 @@ static int intel_dmi_reverse_brightness(const struct dmi_system_id *id)
39137 return 1;
39138 }
39139
39140 -static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39141 +static const struct dmi_system_id intel_dmi_quirks_table[] = {
39142 {
39143 - .dmi_id_list = &(const struct dmi_system_id[]) {
39144 - {
39145 - .callback = intel_dmi_reverse_brightness,
39146 - .ident = "NCR Corporation",
39147 - .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39148 - DMI_MATCH(DMI_PRODUCT_NAME, ""),
39149 - },
39150 - },
39151 - { } /* terminating entry */
39152 + .callback = intel_dmi_reverse_brightness,
39153 + .ident = "NCR Corporation",
39154 + .matches = {DMI_MATCH(DMI_SYS_VENDOR, "NCR Corporation"),
39155 + DMI_MATCH(DMI_PRODUCT_NAME, ""),
39156 },
39157 + },
39158 + { } /* terminating entry */
39159 +};
39160 +
39161 +static const struct intel_dmi_quirk intel_dmi_quirks[] = {
39162 + {
39163 + .dmi_id_list = &intel_dmi_quirks_table,
39164 .hook = quirk_invert_brightness,
39165 },
39166 };
39167 diff --git a/drivers/gpu/drm/mga/mga_drv.h b/drivers/gpu/drm/mga/mga_drv.h
39168 index ca4bc54..ee598a2 100644
39169 --- a/drivers/gpu/drm/mga/mga_drv.h
39170 +++ b/drivers/gpu/drm/mga/mga_drv.h
39171 @@ -120,9 +120,9 @@ typedef struct drm_mga_private {
39172 u32 clear_cmd;
39173 u32 maccess;
39174
39175 - atomic_t vbl_received; /**< Number of vblanks received. */
39176 + atomic_unchecked_t vbl_received; /**< Number of vblanks received. */
39177 wait_queue_head_t fence_queue;
39178 - atomic_t last_fence_retired;
39179 + atomic_unchecked_t last_fence_retired;
39180 u32 next_fence_to_post;
39181
39182 unsigned int fb_cpp;
39183 diff --git a/drivers/gpu/drm/mga/mga_ioc32.c b/drivers/gpu/drm/mga/mga_ioc32.c
39184 index 709e90d..89a1c0d 100644
39185 --- a/drivers/gpu/drm/mga/mga_ioc32.c
39186 +++ b/drivers/gpu/drm/mga/mga_ioc32.c
39187 @@ -189,7 +189,7 @@ static int compat_mga_dma_bootstrap(struct file *file, unsigned int cmd,
39188 return 0;
39189 }
39190
39191 -drm_ioctl_compat_t *mga_compat_ioctls[] = {
39192 +drm_ioctl_compat_t mga_compat_ioctls[] = {
39193 [DRM_MGA_INIT] = compat_mga_init,
39194 [DRM_MGA_GETPARAM] = compat_mga_getparam,
39195 [DRM_MGA_DMA_BOOTSTRAP] = compat_mga_dma_bootstrap,
39196 @@ -207,18 +207,15 @@ drm_ioctl_compat_t *mga_compat_ioctls[] = {
39197 long mga_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39198 {
39199 unsigned int nr = DRM_IOCTL_NR(cmd);
39200 - drm_ioctl_compat_t *fn = NULL;
39201 int ret;
39202
39203 if (nr < DRM_COMMAND_BASE)
39204 return drm_compat_ioctl(filp, cmd, arg);
39205
39206 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls))
39207 - fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39208 -
39209 - if (fn != NULL)
39210 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(mga_compat_ioctls)) {
39211 + drm_ioctl_compat_t fn = mga_compat_ioctls[nr - DRM_COMMAND_BASE];
39212 ret = (*fn) (filp, cmd, arg);
39213 - else
39214 + } else
39215 ret = drm_ioctl(filp, cmd, arg);
39216
39217 return ret;
39218 diff --git a/drivers/gpu/drm/mga/mga_irq.c b/drivers/gpu/drm/mga/mga_irq.c
39219 index 598c281..60d590e 100644
39220 --- a/drivers/gpu/drm/mga/mga_irq.c
39221 +++ b/drivers/gpu/drm/mga/mga_irq.c
39222 @@ -43,7 +43,7 @@ u32 mga_get_vblank_counter(struct drm_device *dev, int crtc)
39223 if (crtc != 0)
39224 return 0;
39225
39226 - return atomic_read(&dev_priv->vbl_received);
39227 + return atomic_read_unchecked(&dev_priv->vbl_received);
39228 }
39229
39230
39231 @@ -59,7 +59,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39232 /* VBLANK interrupt */
39233 if (status & MGA_VLINEPEN) {
39234 MGA_WRITE(MGA_ICLEAR, MGA_VLINEICLR);
39235 - atomic_inc(&dev_priv->vbl_received);
39236 + atomic_inc_unchecked(&dev_priv->vbl_received);
39237 drm_handle_vblank(dev, 0);
39238 handled = 1;
39239 }
39240 @@ -78,7 +78,7 @@ irqreturn_t mga_driver_irq_handler(DRM_IRQ_ARGS)
39241 if ((prim_start & ~0x03) != (prim_end & ~0x03))
39242 MGA_WRITE(MGA_PRIMEND, prim_end);
39243
39244 - atomic_inc(&dev_priv->last_fence_retired);
39245 + atomic_inc_unchecked(&dev_priv->last_fence_retired);
39246 DRM_WAKEUP(&dev_priv->fence_queue);
39247 handled = 1;
39248 }
39249 @@ -129,7 +129,7 @@ int mga_driver_fence_wait(struct drm_device *dev, unsigned int *sequence)
39250 * using fences.
39251 */
39252 DRM_WAIT_ON(ret, dev_priv->fence_queue, 3 * DRM_HZ,
39253 - (((cur_fence = atomic_read(&dev_priv->last_fence_retired))
39254 + (((cur_fence = atomic_read_unchecked(&dev_priv->last_fence_retired))
39255 - *sequence) <= (1 << 23)));
39256
39257 *sequence = cur_fence;
39258 diff --git a/drivers/gpu/drm/nouveau/nouveau_bios.c b/drivers/gpu/drm/nouveau/nouveau_bios.c
39259 index 3e72876..d1c15ad 100644
39260 --- a/drivers/gpu/drm/nouveau/nouveau_bios.c
39261 +++ b/drivers/gpu/drm/nouveau/nouveau_bios.c
39262 @@ -965,7 +965,7 @@ static int parse_bit_tmds_tbl_entry(struct drm_device *dev, struct nvbios *bios,
39263 struct bit_table {
39264 const char id;
39265 int (* const parse_fn)(struct drm_device *, struct nvbios *, struct bit_entry *);
39266 -};
39267 +} __no_const;
39268
39269 #define BIT_TABLE(id, funcid) ((struct bit_table){ id, parse_bit_##funcid##_tbl_entry })
39270
39271 diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.h b/drivers/gpu/drm/nouveau/nouveau_drm.h
39272 index 994fd6e..6e12565 100644
39273 --- a/drivers/gpu/drm/nouveau/nouveau_drm.h
39274 +++ b/drivers/gpu/drm/nouveau/nouveau_drm.h
39275 @@ -94,7 +94,6 @@ struct nouveau_drm {
39276 struct drm_global_reference mem_global_ref;
39277 struct ttm_bo_global_ref bo_global_ref;
39278 struct ttm_bo_device bdev;
39279 - atomic_t validate_sequence;
39280 int (*move)(struct nouveau_channel *,
39281 struct ttm_buffer_object *,
39282 struct ttm_mem_reg *, struct ttm_mem_reg *);
39283 diff --git a/drivers/gpu/drm/nouveau/nouveau_ioc32.c b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39284 index c1a7e5a..38b8539 100644
39285 --- a/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39286 +++ b/drivers/gpu/drm/nouveau/nouveau_ioc32.c
39287 @@ -50,7 +50,7 @@ long nouveau_compat_ioctl(struct file *filp, unsigned int cmd,
39288 unsigned long arg)
39289 {
39290 unsigned int nr = DRM_IOCTL_NR(cmd);
39291 - drm_ioctl_compat_t *fn = NULL;
39292 + drm_ioctl_compat_t fn = NULL;
39293 int ret;
39294
39295 if (nr < DRM_COMMAND_BASE)
39296 diff --git a/drivers/gpu/drm/nouveau/nouveau_vga.c b/drivers/gpu/drm/nouveau/nouveau_vga.c
39297 index 81638d7..2e45854 100644
39298 --- a/drivers/gpu/drm/nouveau/nouveau_vga.c
39299 +++ b/drivers/gpu/drm/nouveau/nouveau_vga.c
39300 @@ -65,7 +65,7 @@ nouveau_switcheroo_can_switch(struct pci_dev *pdev)
39301 bool can_switch;
39302
39303 spin_lock(&dev->count_lock);
39304 - can_switch = (dev->open_count == 0);
39305 + can_switch = (local_read(&dev->open_count) == 0);
39306 spin_unlock(&dev->count_lock);
39307 return can_switch;
39308 }
39309 diff --git a/drivers/gpu/drm/qxl/qxl_cmd.c b/drivers/gpu/drm/qxl/qxl_cmd.c
39310 index eb89653..613cf71 100644
39311 --- a/drivers/gpu/drm/qxl/qxl_cmd.c
39312 +++ b/drivers/gpu/drm/qxl/qxl_cmd.c
39313 @@ -285,27 +285,27 @@ static int wait_for_io_cmd_user(struct qxl_device *qdev, uint8_t val, long port,
39314 int ret;
39315
39316 mutex_lock(&qdev->async_io_mutex);
39317 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
39318 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
39319 if (qdev->last_sent_io_cmd > irq_num) {
39320 if (intr)
39321 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
39322 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39323 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39324 else
39325 ret = wait_event_timeout(qdev->io_cmd_event,
39326 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39327 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39328 /* 0 is timeout, just bail the "hw" has gone away */
39329 if (ret <= 0)
39330 goto out;
39331 - irq_num = atomic_read(&qdev->irq_received_io_cmd);
39332 + irq_num = atomic_read_unchecked(&qdev->irq_received_io_cmd);
39333 }
39334 outb(val, addr);
39335 qdev->last_sent_io_cmd = irq_num + 1;
39336 if (intr)
39337 ret = wait_event_interruptible_timeout(qdev->io_cmd_event,
39338 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39339 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39340 else
39341 ret = wait_event_timeout(qdev->io_cmd_event,
39342 - atomic_read(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39343 + atomic_read_unchecked(&qdev->irq_received_io_cmd) > irq_num, 5*HZ);
39344 out:
39345 if (ret > 0)
39346 ret = 0;
39347 diff --git a/drivers/gpu/drm/qxl/qxl_debugfs.c b/drivers/gpu/drm/qxl/qxl_debugfs.c
39348 index c3c2bbd..bc3c0fb 100644
39349 --- a/drivers/gpu/drm/qxl/qxl_debugfs.c
39350 +++ b/drivers/gpu/drm/qxl/qxl_debugfs.c
39351 @@ -42,10 +42,10 @@ qxl_debugfs_irq_received(struct seq_file *m, void *data)
39352 struct drm_info_node *node = (struct drm_info_node *) m->private;
39353 struct qxl_device *qdev = node->minor->dev->dev_private;
39354
39355 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received));
39356 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_display));
39357 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_cursor));
39358 - seq_printf(m, "%d\n", atomic_read(&qdev->irq_received_io_cmd));
39359 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received));
39360 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_display));
39361 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_cursor));
39362 + seq_printf(m, "%d\n", atomic_read_unchecked(&qdev->irq_received_io_cmd));
39363 seq_printf(m, "%d\n", qdev->irq_received_error);
39364 return 0;
39365 }
39366 diff --git a/drivers/gpu/drm/qxl/qxl_drv.h b/drivers/gpu/drm/qxl/qxl_drv.h
39367 index f7c9add..fb971d2 100644
39368 --- a/drivers/gpu/drm/qxl/qxl_drv.h
39369 +++ b/drivers/gpu/drm/qxl/qxl_drv.h
39370 @@ -290,10 +290,10 @@ struct qxl_device {
39371 unsigned int last_sent_io_cmd;
39372
39373 /* interrupt handling */
39374 - atomic_t irq_received;
39375 - atomic_t irq_received_display;
39376 - atomic_t irq_received_cursor;
39377 - atomic_t irq_received_io_cmd;
39378 + atomic_unchecked_t irq_received;
39379 + atomic_unchecked_t irq_received_display;
39380 + atomic_unchecked_t irq_received_cursor;
39381 + atomic_unchecked_t irq_received_io_cmd;
39382 unsigned irq_received_error;
39383 wait_queue_head_t display_event;
39384 wait_queue_head_t cursor_event;
39385 diff --git a/drivers/gpu/drm/qxl/qxl_irq.c b/drivers/gpu/drm/qxl/qxl_irq.c
39386 index 21393dc..329f3a9 100644
39387 --- a/drivers/gpu/drm/qxl/qxl_irq.c
39388 +++ b/drivers/gpu/drm/qxl/qxl_irq.c
39389 @@ -33,19 +33,19 @@ irqreturn_t qxl_irq_handler(DRM_IRQ_ARGS)
39390
39391 pending = xchg(&qdev->ram_header->int_pending, 0);
39392
39393 - atomic_inc(&qdev->irq_received);
39394 + atomic_inc_unchecked(&qdev->irq_received);
39395
39396 if (pending & QXL_INTERRUPT_DISPLAY) {
39397 - atomic_inc(&qdev->irq_received_display);
39398 + atomic_inc_unchecked(&qdev->irq_received_display);
39399 wake_up_all(&qdev->display_event);
39400 qxl_queue_garbage_collect(qdev, false);
39401 }
39402 if (pending & QXL_INTERRUPT_CURSOR) {
39403 - atomic_inc(&qdev->irq_received_cursor);
39404 + atomic_inc_unchecked(&qdev->irq_received_cursor);
39405 wake_up_all(&qdev->cursor_event);
39406 }
39407 if (pending & QXL_INTERRUPT_IO_CMD) {
39408 - atomic_inc(&qdev->irq_received_io_cmd);
39409 + atomic_inc_unchecked(&qdev->irq_received_io_cmd);
39410 wake_up_all(&qdev->io_cmd_event);
39411 }
39412 if (pending & QXL_INTERRUPT_ERROR) {
39413 @@ -82,10 +82,10 @@ int qxl_irq_init(struct qxl_device *qdev)
39414 init_waitqueue_head(&qdev->io_cmd_event);
39415 INIT_WORK(&qdev->client_monitors_config_work,
39416 qxl_client_monitors_config_work_func);
39417 - atomic_set(&qdev->irq_received, 0);
39418 - atomic_set(&qdev->irq_received_display, 0);
39419 - atomic_set(&qdev->irq_received_cursor, 0);
39420 - atomic_set(&qdev->irq_received_io_cmd, 0);
39421 + atomic_set_unchecked(&qdev->irq_received, 0);
39422 + atomic_set_unchecked(&qdev->irq_received_display, 0);
39423 + atomic_set_unchecked(&qdev->irq_received_cursor, 0);
39424 + atomic_set_unchecked(&qdev->irq_received_io_cmd, 0);
39425 qdev->irq_received_error = 0;
39426 ret = drm_irq_install(qdev->ddev);
39427 qdev->ram_header->int_mask = QXL_INTERRUPT_MASK;
39428 diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
39429 index 037786d..2a95e33 100644
39430 --- a/drivers/gpu/drm/qxl/qxl_ttm.c
39431 +++ b/drivers/gpu/drm/qxl/qxl_ttm.c
39432 @@ -103,7 +103,7 @@ static void qxl_ttm_global_fini(struct qxl_device *qdev)
39433 }
39434 }
39435
39436 -static struct vm_operations_struct qxl_ttm_vm_ops;
39437 +static vm_operations_struct_no_const qxl_ttm_vm_ops __read_only;
39438 static const struct vm_operations_struct *ttm_vm_ops;
39439
39440 static int qxl_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39441 @@ -147,8 +147,10 @@ int qxl_mmap(struct file *filp, struct vm_area_struct *vma)
39442 return r;
39443 if (unlikely(ttm_vm_ops == NULL)) {
39444 ttm_vm_ops = vma->vm_ops;
39445 + pax_open_kernel();
39446 qxl_ttm_vm_ops = *ttm_vm_ops;
39447 qxl_ttm_vm_ops.fault = &qxl_ttm_fault;
39448 + pax_close_kernel();
39449 }
39450 vma->vm_ops = &qxl_ttm_vm_ops;
39451 return 0;
39452 @@ -558,25 +560,23 @@ static int qxl_mm_dump_table(struct seq_file *m, void *data)
39453 static int qxl_ttm_debugfs_init(struct qxl_device *qdev)
39454 {
39455 #if defined(CONFIG_DEBUG_FS)
39456 - static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES];
39457 - static char qxl_mem_types_names[QXL_DEBUGFS_MEM_TYPES][32];
39458 - unsigned i;
39459 + static struct drm_info_list qxl_mem_types_list[QXL_DEBUGFS_MEM_TYPES] = {
39460 + {
39461 + .name = "qxl_mem_mm",
39462 + .show = &qxl_mm_dump_table,
39463 + },
39464 + {
39465 + .name = "qxl_surf_mm",
39466 + .show = &qxl_mm_dump_table,
39467 + }
39468 + };
39469
39470 - for (i = 0; i < QXL_DEBUGFS_MEM_TYPES; i++) {
39471 - if (i == 0)
39472 - sprintf(qxl_mem_types_names[i], "qxl_mem_mm");
39473 - else
39474 - sprintf(qxl_mem_types_names[i], "qxl_surf_mm");
39475 - qxl_mem_types_list[i].name = qxl_mem_types_names[i];
39476 - qxl_mem_types_list[i].show = &qxl_mm_dump_table;
39477 - qxl_mem_types_list[i].driver_features = 0;
39478 - if (i == 0)
39479 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39480 - else
39481 - qxl_mem_types_list[i].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39482 + pax_open_kernel();
39483 + *(void **)&qxl_mem_types_list[0].data = qdev->mman.bdev.man[TTM_PL_VRAM].priv;
39484 + *(void **)&qxl_mem_types_list[1].data = qdev->mman.bdev.man[TTM_PL_PRIV0].priv;
39485 + pax_close_kernel();
39486
39487 - }
39488 - return qxl_debugfs_add_files(qdev, qxl_mem_types_list, i);
39489 + return qxl_debugfs_add_files(qdev, qxl_mem_types_list, QXL_DEBUGFS_MEM_TYPES);
39490 #else
39491 return 0;
39492 #endif
39493 diff --git a/drivers/gpu/drm/r128/r128_cce.c b/drivers/gpu/drm/r128/r128_cce.c
39494 index c451257..0ad2134 100644
39495 --- a/drivers/gpu/drm/r128/r128_cce.c
39496 +++ b/drivers/gpu/drm/r128/r128_cce.c
39497 @@ -377,7 +377,7 @@ static int r128_do_init_cce(struct drm_device *dev, drm_r128_init_t *init)
39498
39499 /* GH: Simple idle check.
39500 */
39501 - atomic_set(&dev_priv->idle_count, 0);
39502 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39503
39504 /* We don't support anything other than bus-mastering ring mode,
39505 * but the ring can be in either AGP or PCI space for the ring
39506 diff --git a/drivers/gpu/drm/r128/r128_drv.h b/drivers/gpu/drm/r128/r128_drv.h
39507 index 56eb5e3..c4ec43d 100644
39508 --- a/drivers/gpu/drm/r128/r128_drv.h
39509 +++ b/drivers/gpu/drm/r128/r128_drv.h
39510 @@ -90,14 +90,14 @@ typedef struct drm_r128_private {
39511 int is_pci;
39512 unsigned long cce_buffers_offset;
39513
39514 - atomic_t idle_count;
39515 + atomic_unchecked_t idle_count;
39516
39517 int page_flipping;
39518 int current_page;
39519 u32 crtc_offset;
39520 u32 crtc_offset_cntl;
39521
39522 - atomic_t vbl_received;
39523 + atomic_unchecked_t vbl_received;
39524
39525 u32 color_fmt;
39526 unsigned int front_offset;
39527 diff --git a/drivers/gpu/drm/r128/r128_ioc32.c b/drivers/gpu/drm/r128/r128_ioc32.c
39528 index a954c54..9cc595c 100644
39529 --- a/drivers/gpu/drm/r128/r128_ioc32.c
39530 +++ b/drivers/gpu/drm/r128/r128_ioc32.c
39531 @@ -177,7 +177,7 @@ static int compat_r128_getparam(struct file *file, unsigned int cmd,
39532 return drm_ioctl(file, DRM_IOCTL_R128_GETPARAM, (unsigned long)getparam);
39533 }
39534
39535 -drm_ioctl_compat_t *r128_compat_ioctls[] = {
39536 +drm_ioctl_compat_t r128_compat_ioctls[] = {
39537 [DRM_R128_INIT] = compat_r128_init,
39538 [DRM_R128_DEPTH] = compat_r128_depth,
39539 [DRM_R128_STIPPLE] = compat_r128_stipple,
39540 @@ -196,18 +196,15 @@ drm_ioctl_compat_t *r128_compat_ioctls[] = {
39541 long r128_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39542 {
39543 unsigned int nr = DRM_IOCTL_NR(cmd);
39544 - drm_ioctl_compat_t *fn = NULL;
39545 int ret;
39546
39547 if (nr < DRM_COMMAND_BASE)
39548 return drm_compat_ioctl(filp, cmd, arg);
39549
39550 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls))
39551 - fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39552 -
39553 - if (fn != NULL)
39554 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(r128_compat_ioctls)) {
39555 + drm_ioctl_compat_t fn = r128_compat_ioctls[nr - DRM_COMMAND_BASE];
39556 ret = (*fn) (filp, cmd, arg);
39557 - else
39558 + } else
39559 ret = drm_ioctl(filp, cmd, arg);
39560
39561 return ret;
39562 diff --git a/drivers/gpu/drm/r128/r128_irq.c b/drivers/gpu/drm/r128/r128_irq.c
39563 index 2ea4f09..d391371 100644
39564 --- a/drivers/gpu/drm/r128/r128_irq.c
39565 +++ b/drivers/gpu/drm/r128/r128_irq.c
39566 @@ -41,7 +41,7 @@ u32 r128_get_vblank_counter(struct drm_device *dev, int crtc)
39567 if (crtc != 0)
39568 return 0;
39569
39570 - return atomic_read(&dev_priv->vbl_received);
39571 + return atomic_read_unchecked(&dev_priv->vbl_received);
39572 }
39573
39574 irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39575 @@ -55,7 +55,7 @@ irqreturn_t r128_driver_irq_handler(DRM_IRQ_ARGS)
39576 /* VBLANK interrupt */
39577 if (status & R128_CRTC_VBLANK_INT) {
39578 R128_WRITE(R128_GEN_INT_STATUS, R128_CRTC_VBLANK_INT_AK);
39579 - atomic_inc(&dev_priv->vbl_received);
39580 + atomic_inc_unchecked(&dev_priv->vbl_received);
39581 drm_handle_vblank(dev, 0);
39582 return IRQ_HANDLED;
39583 }
39584 diff --git a/drivers/gpu/drm/r128/r128_state.c b/drivers/gpu/drm/r128/r128_state.c
39585 index 01dd9ae..6352f04 100644
39586 --- a/drivers/gpu/drm/r128/r128_state.c
39587 +++ b/drivers/gpu/drm/r128/r128_state.c
39588 @@ -320,10 +320,10 @@ static void r128_clear_box(drm_r128_private_t *dev_priv,
39589
39590 static void r128_cce_performance_boxes(drm_r128_private_t *dev_priv)
39591 {
39592 - if (atomic_read(&dev_priv->idle_count) == 0)
39593 + if (atomic_read_unchecked(&dev_priv->idle_count) == 0)
39594 r128_clear_box(dev_priv, 64, 4, 8, 8, 0, 255, 0);
39595 else
39596 - atomic_set(&dev_priv->idle_count, 0);
39597 + atomic_set_unchecked(&dev_priv->idle_count, 0);
39598 }
39599
39600 #endif
39601 diff --git a/drivers/gpu/drm/radeon/mkregtable.c b/drivers/gpu/drm/radeon/mkregtable.c
39602 index af85299..ed9ac8d 100644
39603 --- a/drivers/gpu/drm/radeon/mkregtable.c
39604 +++ b/drivers/gpu/drm/radeon/mkregtable.c
39605 @@ -624,14 +624,14 @@ static int parser_auth(struct table *t, const char *filename)
39606 regex_t mask_rex;
39607 regmatch_t match[4];
39608 char buf[1024];
39609 - size_t end;
39610 + long end;
39611 int len;
39612 int done = 0;
39613 int r;
39614 unsigned o;
39615 struct offset *offset;
39616 char last_reg_s[10];
39617 - int last_reg;
39618 + unsigned long last_reg;
39619
39620 if (regcomp
39621 (&mask_rex, "(0x[0-9a-fA-F]*) *([_a-zA-Z0-9]*)", REG_EXTENDED)) {
39622 diff --git a/drivers/gpu/drm/radeon/radeon_device.c b/drivers/gpu/drm/radeon/radeon_device.c
39623 index 841d0e0..9eaa268 100644
39624 --- a/drivers/gpu/drm/radeon/radeon_device.c
39625 +++ b/drivers/gpu/drm/radeon/radeon_device.c
39626 @@ -1117,7 +1117,7 @@ static bool radeon_switcheroo_can_switch(struct pci_dev *pdev)
39627 bool can_switch;
39628
39629 spin_lock(&dev->count_lock);
39630 - can_switch = (dev->open_count == 0);
39631 + can_switch = (local_read(&dev->open_count) == 0);
39632 spin_unlock(&dev->count_lock);
39633 return can_switch;
39634 }
39635 diff --git a/drivers/gpu/drm/radeon/radeon_drv.h b/drivers/gpu/drm/radeon/radeon_drv.h
39636 index b369d42..8dd04eb 100644
39637 --- a/drivers/gpu/drm/radeon/radeon_drv.h
39638 +++ b/drivers/gpu/drm/radeon/radeon_drv.h
39639 @@ -258,7 +258,7 @@ typedef struct drm_radeon_private {
39640
39641 /* SW interrupt */
39642 wait_queue_head_t swi_queue;
39643 - atomic_t swi_emitted;
39644 + atomic_unchecked_t swi_emitted;
39645 int vblank_crtc;
39646 uint32_t irq_enable_reg;
39647 uint32_t r500_disp_irq_reg;
39648 diff --git a/drivers/gpu/drm/radeon/radeon_ioc32.c b/drivers/gpu/drm/radeon/radeon_ioc32.c
39649 index c180df8..5fd8186 100644
39650 --- a/drivers/gpu/drm/radeon/radeon_ioc32.c
39651 +++ b/drivers/gpu/drm/radeon/radeon_ioc32.c
39652 @@ -358,7 +358,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39653 request = compat_alloc_user_space(sizeof(*request));
39654 if (!access_ok(VERIFY_WRITE, request, sizeof(*request))
39655 || __put_user(req32.param, &request->param)
39656 - || __put_user((void __user *)(unsigned long)req32.value,
39657 + || __put_user((unsigned long)req32.value,
39658 &request->value))
39659 return -EFAULT;
39660
39661 @@ -368,7 +368,7 @@ static int compat_radeon_cp_setparam(struct file *file, unsigned int cmd,
39662 #define compat_radeon_cp_setparam NULL
39663 #endif /* X86_64 || IA64 */
39664
39665 -static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39666 +static drm_ioctl_compat_t radeon_compat_ioctls[] = {
39667 [DRM_RADEON_CP_INIT] = compat_radeon_cp_init,
39668 [DRM_RADEON_CLEAR] = compat_radeon_cp_clear,
39669 [DRM_RADEON_STIPPLE] = compat_radeon_cp_stipple,
39670 @@ -393,18 +393,15 @@ static drm_ioctl_compat_t *radeon_compat_ioctls[] = {
39671 long radeon_compat_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
39672 {
39673 unsigned int nr = DRM_IOCTL_NR(cmd);
39674 - drm_ioctl_compat_t *fn = NULL;
39675 int ret;
39676
39677 if (nr < DRM_COMMAND_BASE)
39678 return drm_compat_ioctl(filp, cmd, arg);
39679
39680 - if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls))
39681 - fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39682 -
39683 - if (fn != NULL)
39684 + if (nr < DRM_COMMAND_BASE + DRM_ARRAY_SIZE(radeon_compat_ioctls)) {
39685 + drm_ioctl_compat_t fn = radeon_compat_ioctls[nr - DRM_COMMAND_BASE];
39686 ret = (*fn) (filp, cmd, arg);
39687 - else
39688 + } else
39689 ret = drm_ioctl(filp, cmd, arg);
39690
39691 return ret;
39692 diff --git a/drivers/gpu/drm/radeon/radeon_irq.c b/drivers/gpu/drm/radeon/radeon_irq.c
39693 index 8d68e97..9dcfed8 100644
39694 --- a/drivers/gpu/drm/radeon/radeon_irq.c
39695 +++ b/drivers/gpu/drm/radeon/radeon_irq.c
39696 @@ -226,8 +226,8 @@ static int radeon_emit_irq(struct drm_device * dev)
39697 unsigned int ret;
39698 RING_LOCALS;
39699
39700 - atomic_inc(&dev_priv->swi_emitted);
39701 - ret = atomic_read(&dev_priv->swi_emitted);
39702 + atomic_inc_unchecked(&dev_priv->swi_emitted);
39703 + ret = atomic_read_unchecked(&dev_priv->swi_emitted);
39704
39705 BEGIN_RING(4);
39706 OUT_RING_REG(RADEON_LAST_SWI_REG, ret);
39707 @@ -353,7 +353,7 @@ int radeon_driver_irq_postinstall(struct drm_device *dev)
39708 drm_radeon_private_t *dev_priv =
39709 (drm_radeon_private_t *) dev->dev_private;
39710
39711 - atomic_set(&dev_priv->swi_emitted, 0);
39712 + atomic_set_unchecked(&dev_priv->swi_emitted, 0);
39713 DRM_INIT_WAITQUEUE(&dev_priv->swi_queue);
39714
39715 dev->max_vblank_count = 0x001fffff;
39716 diff --git a/drivers/gpu/drm/radeon/radeon_state.c b/drivers/gpu/drm/radeon/radeon_state.c
39717 index 4d20910..6726b6d 100644
39718 --- a/drivers/gpu/drm/radeon/radeon_state.c
39719 +++ b/drivers/gpu/drm/radeon/radeon_state.c
39720 @@ -2168,7 +2168,7 @@ static int radeon_cp_clear(struct drm_device *dev, void *data, struct drm_file *
39721 if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
39722 sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
39723
39724 - if (DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39725 + if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS || DRM_COPY_FROM_USER(&depth_boxes, clear->depth_boxes,
39726 sarea_priv->nbox * sizeof(depth_boxes[0])))
39727 return -EFAULT;
39728
39729 @@ -3031,7 +3031,7 @@ static int radeon_cp_getparam(struct drm_device *dev, void *data, struct drm_fil
39730 {
39731 drm_radeon_private_t *dev_priv = dev->dev_private;
39732 drm_radeon_getparam_t *param = data;
39733 - int value;
39734 + int value = 0;
39735
39736 DRM_DEBUG("pid=%d\n", DRM_CURRENTPID);
39737
39738 diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c b/drivers/gpu/drm/radeon/radeon_ttm.c
39739 index 71245d6..94c556d 100644
39740 --- a/drivers/gpu/drm/radeon/radeon_ttm.c
39741 +++ b/drivers/gpu/drm/radeon/radeon_ttm.c
39742 @@ -784,7 +784,7 @@ void radeon_ttm_set_active_vram_size(struct radeon_device *rdev, u64 size)
39743 man->size = size >> PAGE_SHIFT;
39744 }
39745
39746 -static struct vm_operations_struct radeon_ttm_vm_ops;
39747 +static vm_operations_struct_no_const radeon_ttm_vm_ops __read_only;
39748 static const struct vm_operations_struct *ttm_vm_ops = NULL;
39749
39750 static int radeon_ttm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
39751 @@ -825,8 +825,10 @@ int radeon_mmap(struct file *filp, struct vm_area_struct *vma)
39752 }
39753 if (unlikely(ttm_vm_ops == NULL)) {
39754 ttm_vm_ops = vma->vm_ops;
39755 + pax_open_kernel();
39756 radeon_ttm_vm_ops = *ttm_vm_ops;
39757 radeon_ttm_vm_ops.fault = &radeon_ttm_fault;
39758 + pax_close_kernel();
39759 }
39760 vma->vm_ops = &radeon_ttm_vm_ops;
39761 return 0;
39762 @@ -855,38 +857,33 @@ static int radeon_mm_dump_table(struct seq_file *m, void *data)
39763 static int radeon_ttm_debugfs_init(struct radeon_device *rdev)
39764 {
39765 #if defined(CONFIG_DEBUG_FS)
39766 - static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2];
39767 - static char radeon_mem_types_names[RADEON_DEBUGFS_MEM_TYPES+2][32];
39768 - unsigned i;
39769 + static struct drm_info_list radeon_mem_types_list[RADEON_DEBUGFS_MEM_TYPES+2] = {
39770 + {
39771 + .name = "radeon_vram_mm",
39772 + .show = &radeon_mm_dump_table,
39773 + },
39774 + {
39775 + .name = "radeon_gtt_mm",
39776 + .show = &radeon_mm_dump_table,
39777 + },
39778 + {
39779 + .name = "ttm_page_pool",
39780 + .show = &ttm_page_alloc_debugfs,
39781 + },
39782 + {
39783 + .name = "ttm_dma_page_pool",
39784 + .show = &ttm_dma_page_alloc_debugfs,
39785 + },
39786 + };
39787 + unsigned i = RADEON_DEBUGFS_MEM_TYPES + 1;
39788
39789 - for (i = 0; i < RADEON_DEBUGFS_MEM_TYPES; i++) {
39790 - if (i == 0)
39791 - sprintf(radeon_mem_types_names[i], "radeon_vram_mm");
39792 - else
39793 - sprintf(radeon_mem_types_names[i], "radeon_gtt_mm");
39794 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39795 - radeon_mem_types_list[i].show = &radeon_mm_dump_table;
39796 - radeon_mem_types_list[i].driver_features = 0;
39797 - if (i == 0)
39798 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39799 - else
39800 - radeon_mem_types_list[i].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39801 -
39802 - }
39803 - /* Add ttm page pool to debugfs */
39804 - sprintf(radeon_mem_types_names[i], "ttm_page_pool");
39805 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39806 - radeon_mem_types_list[i].show = &ttm_page_alloc_debugfs;
39807 - radeon_mem_types_list[i].driver_features = 0;
39808 - radeon_mem_types_list[i++].data = NULL;
39809 + pax_open_kernel();
39810 + *(void **)&radeon_mem_types_list[0].data = rdev->mman.bdev.man[TTM_PL_VRAM].priv;
39811 + *(void **)&radeon_mem_types_list[1].data = rdev->mman.bdev.man[TTM_PL_TT].priv;
39812 + pax_close_kernel();
39813 #ifdef CONFIG_SWIOTLB
39814 - if (swiotlb_nr_tbl()) {
39815 - sprintf(radeon_mem_types_names[i], "ttm_dma_page_pool");
39816 - radeon_mem_types_list[i].name = radeon_mem_types_names[i];
39817 - radeon_mem_types_list[i].show = &ttm_dma_page_alloc_debugfs;
39818 - radeon_mem_types_list[i].driver_features = 0;
39819 - radeon_mem_types_list[i++].data = NULL;
39820 - }
39821 + if (swiotlb_nr_tbl())
39822 + i++;
39823 #endif
39824 return radeon_debugfs_add_files(rdev, radeon_mem_types_list, i);
39825
39826 diff --git a/drivers/gpu/drm/radeon/rs690.c b/drivers/gpu/drm/radeon/rs690.c
39827 index 3c38f0a..13816e3 100644
39828 --- a/drivers/gpu/drm/radeon/rs690.c
39829 +++ b/drivers/gpu/drm/radeon/rs690.c
39830 @@ -355,9 +355,11 @@ static void rs690_crtc_bandwidth_compute(struct radeon_device *rdev,
39831 if (max_bandwidth.full > rdev->pm.sideport_bandwidth.full &&
39832 rdev->pm.sideport_bandwidth.full)
39833 max_bandwidth = rdev->pm.sideport_bandwidth;
39834 - read_delay_latency.full = dfixed_const(370 * 800 * 1000);
39835 + read_delay_latency.full = dfixed_const(800 * 1000);
39836 read_delay_latency.full = dfixed_div(read_delay_latency,
39837 rdev->pm.igp_sideport_mclk);
39838 + a.full = dfixed_const(370);
39839 + read_delay_latency.full = dfixed_mul(read_delay_latency, a);
39840 } else {
39841 if (max_bandwidth.full > rdev->pm.k8_bandwidth.full &&
39842 rdev->pm.k8_bandwidth.full)
39843 diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
39844 index dbc2def..0a9f710 100644
39845 --- a/drivers/gpu/drm/ttm/ttm_memory.c
39846 +++ b/drivers/gpu/drm/ttm/ttm_memory.c
39847 @@ -264,7 +264,7 @@ static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
39848 zone->glob = glob;
39849 glob->zone_kernel = zone;
39850 ret = kobject_init_and_add(
39851 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39852 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39853 if (unlikely(ret != 0)) {
39854 kobject_put(&zone->kobj);
39855 return ret;
39856 @@ -347,7 +347,7 @@ static int ttm_mem_init_dma32_zone(struct ttm_mem_global *glob,
39857 zone->glob = glob;
39858 glob->zone_dma32 = zone;
39859 ret = kobject_init_and_add(
39860 - &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, zone->name);
39861 + &zone->kobj, &ttm_mem_zone_kobj_type, &glob->kobj, "%s", zone->name);
39862 if (unlikely(ret != 0)) {
39863 kobject_put(&zone->kobj);
39864 return ret;
39865 diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39866 index 863bef9..cba15cf 100644
39867 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c
39868 +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c
39869 @@ -391,9 +391,9 @@ out:
39870 static unsigned long
39871 ttm_pool_shrink_scan(struct shrinker *shrink, struct shrink_control *sc)
39872 {
39873 - static atomic_t start_pool = ATOMIC_INIT(0);
39874 + static atomic_unchecked_t start_pool = ATOMIC_INIT(0);
39875 unsigned i;
39876 - unsigned pool_offset = atomic_add_return(1, &start_pool);
39877 + unsigned pool_offset = atomic_add_return_unchecked(1, &start_pool);
39878 struct ttm_page_pool *pool;
39879 int shrink_pages = sc->nr_to_scan;
39880 unsigned long freed = 0;
39881 diff --git a/drivers/gpu/drm/udl/udl_fb.c b/drivers/gpu/drm/udl/udl_fb.c
39882 index 97e9d61..bf23c461 100644
39883 --- a/drivers/gpu/drm/udl/udl_fb.c
39884 +++ b/drivers/gpu/drm/udl/udl_fb.c
39885 @@ -367,7 +367,6 @@ static int udl_fb_release(struct fb_info *info, int user)
39886 fb_deferred_io_cleanup(info);
39887 kfree(info->fbdefio);
39888 info->fbdefio = NULL;
39889 - info->fbops->fb_mmap = udl_fb_mmap;
39890 }
39891
39892 pr_warn("released /dev/fb%d user=%d count=%d\n",
39893 diff --git a/drivers/gpu/drm/via/via_drv.h b/drivers/gpu/drm/via/via_drv.h
39894 index a811ef2..ff99b05 100644
39895 --- a/drivers/gpu/drm/via/via_drv.h
39896 +++ b/drivers/gpu/drm/via/via_drv.h
39897 @@ -51,7 +51,7 @@ typedef struct drm_via_ring_buffer {
39898 typedef uint32_t maskarray_t[5];
39899
39900 typedef struct drm_via_irq {
39901 - atomic_t irq_received;
39902 + atomic_unchecked_t irq_received;
39903 uint32_t pending_mask;
39904 uint32_t enable_mask;
39905 wait_queue_head_t irq_queue;
39906 @@ -75,7 +75,7 @@ typedef struct drm_via_private {
39907 struct timeval last_vblank;
39908 int last_vblank_valid;
39909 unsigned usec_per_vblank;
39910 - atomic_t vbl_received;
39911 + atomic_unchecked_t vbl_received;
39912 drm_via_state_t hc_state;
39913 char pci_buf[VIA_PCI_BUF_SIZE];
39914 const uint32_t *fire_offsets[VIA_FIRE_BUF_SIZE];
39915 diff --git a/drivers/gpu/drm/via/via_irq.c b/drivers/gpu/drm/via/via_irq.c
39916 index ac98964..5dbf512 100644
39917 --- a/drivers/gpu/drm/via/via_irq.c
39918 +++ b/drivers/gpu/drm/via/via_irq.c
39919 @@ -101,7 +101,7 @@ u32 via_get_vblank_counter(struct drm_device *dev, int crtc)
39920 if (crtc != 0)
39921 return 0;
39922
39923 - return atomic_read(&dev_priv->vbl_received);
39924 + return atomic_read_unchecked(&dev_priv->vbl_received);
39925 }
39926
39927 irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39928 @@ -116,8 +116,8 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39929
39930 status = VIA_READ(VIA_REG_INTERRUPT);
39931 if (status & VIA_IRQ_VBLANK_PENDING) {
39932 - atomic_inc(&dev_priv->vbl_received);
39933 - if (!(atomic_read(&dev_priv->vbl_received) & 0x0F)) {
39934 + atomic_inc_unchecked(&dev_priv->vbl_received);
39935 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0x0F)) {
39936 do_gettimeofday(&cur_vblank);
39937 if (dev_priv->last_vblank_valid) {
39938 dev_priv->usec_per_vblank =
39939 @@ -127,7 +127,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39940 dev_priv->last_vblank = cur_vblank;
39941 dev_priv->last_vblank_valid = 1;
39942 }
39943 - if (!(atomic_read(&dev_priv->vbl_received) & 0xFF)) {
39944 + if (!(atomic_read_unchecked(&dev_priv->vbl_received) & 0xFF)) {
39945 DRM_DEBUG("US per vblank is: %u\n",
39946 dev_priv->usec_per_vblank);
39947 }
39948 @@ -137,7 +137,7 @@ irqreturn_t via_driver_irq_handler(DRM_IRQ_ARGS)
39949
39950 for (i = 0; i < dev_priv->num_irqs; ++i) {
39951 if (status & cur_irq->pending_mask) {
39952 - atomic_inc(&cur_irq->irq_received);
39953 + atomic_inc_unchecked(&cur_irq->irq_received);
39954 DRM_WAKEUP(&cur_irq->irq_queue);
39955 handled = 1;
39956 if (dev_priv->irq_map[drm_via_irq_dma0_td] == i)
39957 @@ -242,11 +242,11 @@ via_driver_irq_wait(struct drm_device *dev, unsigned int irq, int force_sequence
39958 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39959 ((VIA_READ(masks[irq][2]) & masks[irq][3]) ==
39960 masks[irq][4]));
39961 - cur_irq_sequence = atomic_read(&cur_irq->irq_received);
39962 + cur_irq_sequence = atomic_read_unchecked(&cur_irq->irq_received);
39963 } else {
39964 DRM_WAIT_ON(ret, cur_irq->irq_queue, 3 * DRM_HZ,
39965 (((cur_irq_sequence =
39966 - atomic_read(&cur_irq->irq_received)) -
39967 + atomic_read_unchecked(&cur_irq->irq_received)) -
39968 *sequence) <= (1 << 23)));
39969 }
39970 *sequence = cur_irq_sequence;
39971 @@ -284,7 +284,7 @@ void via_driver_irq_preinstall(struct drm_device *dev)
39972 }
39973
39974 for (i = 0; i < dev_priv->num_irqs; ++i) {
39975 - atomic_set(&cur_irq->irq_received, 0);
39976 + atomic_set_unchecked(&cur_irq->irq_received, 0);
39977 cur_irq->enable_mask = dev_priv->irq_masks[i][0];
39978 cur_irq->pending_mask = dev_priv->irq_masks[i][1];
39979 DRM_INIT_WAITQUEUE(&cur_irq->irq_queue);
39980 @@ -366,7 +366,7 @@ int via_wait_irq(struct drm_device *dev, void *data, struct drm_file *file_priv)
39981 switch (irqwait->request.type & ~VIA_IRQ_FLAGS_MASK) {
39982 case VIA_IRQ_RELATIVE:
39983 irqwait->request.sequence +=
39984 - atomic_read(&cur_irq->irq_received);
39985 + atomic_read_unchecked(&cur_irq->irq_received);
39986 irqwait->request.type &= ~_DRM_VBLANK_RELATIVE;
39987 case VIA_IRQ_ABSOLUTE:
39988 break;
39989 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39990 index 150ec64..f5165f2 100644
39991 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39992 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
39993 @@ -290,7 +290,7 @@ struct vmw_private {
39994 * Fencing and IRQs.
39995 */
39996
39997 - atomic_t marker_seq;
39998 + atomic_unchecked_t marker_seq;
39999 wait_queue_head_t fence_queue;
40000 wait_queue_head_t fifo_queue;
40001 int fence_queue_waiters; /* Protected by hw_mutex */
40002 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40003 index 3eb1486..0a47ee9 100644
40004 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40005 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_fifo.c
40006 @@ -137,7 +137,7 @@ int vmw_fifo_init(struct vmw_private *dev_priv, struct vmw_fifo_state *fifo)
40007 (unsigned int) min,
40008 (unsigned int) fifo->capabilities);
40009
40010 - atomic_set(&dev_priv->marker_seq, dev_priv->last_read_seqno);
40011 + atomic_set_unchecked(&dev_priv->marker_seq, dev_priv->last_read_seqno);
40012 iowrite32(dev_priv->last_read_seqno, fifo_mem + SVGA_FIFO_FENCE);
40013 vmw_marker_queue_init(&fifo->marker_queue);
40014 return vmw_fifo_send_fence(dev_priv, &dummy);
40015 @@ -355,7 +355,7 @@ void *vmw_fifo_reserve(struct vmw_private *dev_priv, uint32_t bytes)
40016 if (reserveable)
40017 iowrite32(bytes, fifo_mem +
40018 SVGA_FIFO_RESERVED);
40019 - return fifo_mem + (next_cmd >> 2);
40020 + return (__le32 __force_kernel *)fifo_mem + (next_cmd >> 2);
40021 } else {
40022 need_bounce = true;
40023 }
40024 @@ -475,7 +475,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
40025
40026 fm = vmw_fifo_reserve(dev_priv, bytes);
40027 if (unlikely(fm == NULL)) {
40028 - *seqno = atomic_read(&dev_priv->marker_seq);
40029 + *seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40030 ret = -ENOMEM;
40031 (void)vmw_fallback_wait(dev_priv, false, true, *seqno,
40032 false, 3*HZ);
40033 @@ -483,7 +483,7 @@ int vmw_fifo_send_fence(struct vmw_private *dev_priv, uint32_t *seqno)
40034 }
40035
40036 do {
40037 - *seqno = atomic_add_return(1, &dev_priv->marker_seq);
40038 + *seqno = atomic_add_return_unchecked(1, &dev_priv->marker_seq);
40039 } while (*seqno == 0);
40040
40041 if (!(fifo_state->capabilities & SVGA_FIFO_CAP_FENCE)) {
40042 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40043 index c509d40..3b640c3 100644
40044 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40045 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_ioctl.c
40046 @@ -138,7 +138,7 @@ int vmw_present_ioctl(struct drm_device *dev, void *data,
40047 int ret;
40048
40049 num_clips = arg->num_clips;
40050 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40051 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40052
40053 if (unlikely(num_clips == 0))
40054 return 0;
40055 @@ -222,7 +222,7 @@ int vmw_present_readback_ioctl(struct drm_device *dev, void *data,
40056 int ret;
40057
40058 num_clips = arg->num_clips;
40059 - clips_ptr = (struct drm_vmw_rect *)(unsigned long)arg->clips_ptr;
40060 + clips_ptr = (struct drm_vmw_rect __user *)(unsigned long)arg->clips_ptr;
40061
40062 if (unlikely(num_clips == 0))
40063 return 0;
40064 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40065 index 4640adb..e1384ed 100644
40066 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40067 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_irq.c
40068 @@ -107,7 +107,7 @@ bool vmw_seqno_passed(struct vmw_private *dev_priv,
40069 * emitted. Then the fence is stale and signaled.
40070 */
40071
40072 - ret = ((atomic_read(&dev_priv->marker_seq) - seqno)
40073 + ret = ((atomic_read_unchecked(&dev_priv->marker_seq) - seqno)
40074 > VMW_FENCE_WRAP);
40075
40076 return ret;
40077 @@ -138,7 +138,7 @@ int vmw_fallback_wait(struct vmw_private *dev_priv,
40078
40079 if (fifo_idle)
40080 down_read(&fifo_state->rwsem);
40081 - signal_seq = atomic_read(&dev_priv->marker_seq);
40082 + signal_seq = atomic_read_unchecked(&dev_priv->marker_seq);
40083 ret = 0;
40084
40085 for (;;) {
40086 diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40087 index 8a8725c2..afed796 100644
40088 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40089 +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_marker.c
40090 @@ -151,7 +151,7 @@ int vmw_wait_lag(struct vmw_private *dev_priv,
40091 while (!vmw_lag_lt(queue, us)) {
40092 spin_lock(&queue->lock);
40093 if (list_empty(&queue->head))
40094 - seqno = atomic_read(&dev_priv->marker_seq);
40095 + seqno = atomic_read_unchecked(&dev_priv->marker_seq);
40096 else {
40097 marker = list_first_entry(&queue->head,
40098 struct vmw_marker, head);
40099 diff --git a/drivers/gpu/host1x/drm/dc.c b/drivers/gpu/host1x/drm/dc.c
40100 index b1a05ad..1c9d899 100644
40101 --- a/drivers/gpu/host1x/drm/dc.c
40102 +++ b/drivers/gpu/host1x/drm/dc.c
40103 @@ -1004,7 +1004,7 @@ static int tegra_dc_debugfs_init(struct tegra_dc *dc, struct drm_minor *minor)
40104 }
40105
40106 for (i = 0; i < ARRAY_SIZE(debugfs_files); i++)
40107 - dc->debugfs_files[i].data = dc;
40108 + *(void **)&dc->debugfs_files[i].data = dc;
40109
40110 err = drm_debugfs_create_files(dc->debugfs_files,
40111 ARRAY_SIZE(debugfs_files),
40112 diff --git a/drivers/gpu/vga/vga_switcheroo.c b/drivers/gpu/vga/vga_switcheroo.c
40113 index ec0ae2d..dc0780b 100644
40114 --- a/drivers/gpu/vga/vga_switcheroo.c
40115 +++ b/drivers/gpu/vga/vga_switcheroo.c
40116 @@ -643,7 +643,7 @@ static int vga_switcheroo_runtime_resume(struct device *dev)
40117
40118 /* this version is for the case where the power switch is separate
40119 to the device being powered down. */
40120 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain)
40121 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain)
40122 {
40123 /* copy over all the bus versions */
40124 if (dev->bus && dev->bus->pm) {
40125 @@ -688,7 +688,7 @@ static int vga_switcheroo_runtime_resume_hdmi_audio(struct device *dev)
40126 return ret;
40127 }
40128
40129 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain)
40130 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain)
40131 {
40132 /* copy over all the bus versions */
40133 if (dev->bus && dev->bus->pm) {
40134 diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
40135 index aedfe50..1dc929b 100644
40136 --- a/drivers/hid/hid-core.c
40137 +++ b/drivers/hid/hid-core.c
40138 @@ -2416,7 +2416,7 @@ EXPORT_SYMBOL_GPL(hid_ignore);
40139
40140 int hid_add_device(struct hid_device *hdev)
40141 {
40142 - static atomic_t id = ATOMIC_INIT(0);
40143 + static atomic_unchecked_t id = ATOMIC_INIT(0);
40144 int ret;
40145
40146 if (WARN_ON(hdev->status & HID_STAT_ADDED))
40147 @@ -2450,7 +2450,7 @@ int hid_add_device(struct hid_device *hdev)
40148 /* XXX hack, any other cleaner solution after the driver core
40149 * is converted to allow more than 20 bytes as the device name? */
40150 dev_set_name(&hdev->dev, "%04X:%04X:%04X.%04X", hdev->bus,
40151 - hdev->vendor, hdev->product, atomic_inc_return(&id));
40152 + hdev->vendor, hdev->product, atomic_inc_return_unchecked(&id));
40153
40154 hid_debug_register(hdev, dev_name(&hdev->dev));
40155 ret = device_add(&hdev->dev);
40156 diff --git a/drivers/hid/hid-wiimote-debug.c b/drivers/hid/hid-wiimote-debug.c
40157 index c13fb5b..55a3802 100644
40158 --- a/drivers/hid/hid-wiimote-debug.c
40159 +++ b/drivers/hid/hid-wiimote-debug.c
40160 @@ -66,7 +66,7 @@ static ssize_t wiidebug_eeprom_read(struct file *f, char __user *u, size_t s,
40161 else if (size == 0)
40162 return -EIO;
40163
40164 - if (copy_to_user(u, buf, size))
40165 + if (size > sizeof(buf) || copy_to_user(u, buf, size))
40166 return -EFAULT;
40167
40168 *off += size;
40169 diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
40170 index cedc6da..2c3da2a 100644
40171 --- a/drivers/hid/uhid.c
40172 +++ b/drivers/hid/uhid.c
40173 @@ -47,7 +47,7 @@ struct uhid_device {
40174 struct mutex report_lock;
40175 wait_queue_head_t report_wait;
40176 atomic_t report_done;
40177 - atomic_t report_id;
40178 + atomic_unchecked_t report_id;
40179 struct uhid_event report_buf;
40180 };
40181
40182 @@ -163,7 +163,7 @@ static int uhid_hid_get_raw(struct hid_device *hid, unsigned char rnum,
40183
40184 spin_lock_irqsave(&uhid->qlock, flags);
40185 ev->type = UHID_FEATURE;
40186 - ev->u.feature.id = atomic_inc_return(&uhid->report_id);
40187 + ev->u.feature.id = atomic_inc_return_unchecked(&uhid->report_id);
40188 ev->u.feature.rnum = rnum;
40189 ev->u.feature.rtype = report_type;
40190
40191 @@ -446,7 +446,7 @@ static int uhid_dev_feature_answer(struct uhid_device *uhid,
40192 spin_lock_irqsave(&uhid->qlock, flags);
40193
40194 /* id for old report; drop it silently */
40195 - if (atomic_read(&uhid->report_id) != ev->u.feature_answer.id)
40196 + if (atomic_read_unchecked(&uhid->report_id) != ev->u.feature_answer.id)
40197 goto unlock;
40198 if (atomic_read(&uhid->report_done))
40199 goto unlock;
40200 diff --git a/drivers/hv/channel.c b/drivers/hv/channel.c
40201 index 6de6c98..18319e9 100644
40202 --- a/drivers/hv/channel.c
40203 +++ b/drivers/hv/channel.c
40204 @@ -406,8 +406,8 @@ int vmbus_establish_gpadl(struct vmbus_channel *channel, void *kbuffer,
40205 int ret = 0;
40206 int t;
40207
40208 - next_gpadl_handle = atomic_read(&vmbus_connection.next_gpadl_handle);
40209 - atomic_inc(&vmbus_connection.next_gpadl_handle);
40210 + next_gpadl_handle = atomic_read_unchecked(&vmbus_connection.next_gpadl_handle);
40211 + atomic_inc_unchecked(&vmbus_connection.next_gpadl_handle);
40212
40213 ret = create_gpadl_header(kbuffer, size, &msginfo, &msgcount);
40214 if (ret)
40215 diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c
40216 index 88f4096..e50452e 100644
40217 --- a/drivers/hv/hv.c
40218 +++ b/drivers/hv/hv.c
40219 @@ -112,7 +112,7 @@ static u64 do_hypercall(u64 control, void *input, void *output)
40220 u64 output_address = (output) ? virt_to_phys(output) : 0;
40221 u32 output_address_hi = output_address >> 32;
40222 u32 output_address_lo = output_address & 0xFFFFFFFF;
40223 - void *hypercall_page = hv_context.hypercall_page;
40224 + void *hypercall_page = ktva_ktla(hv_context.hypercall_page);
40225
40226 __asm__ __volatile__ ("call *%8" : "=d"(hv_status_hi),
40227 "=a"(hv_status_lo) : "d" (control_hi),
40228 diff --git a/drivers/hv/hv_balloon.c b/drivers/hv/hv_balloon.c
40229 index 7e17a54..a50a33d 100644
40230 --- a/drivers/hv/hv_balloon.c
40231 +++ b/drivers/hv/hv_balloon.c
40232 @@ -464,7 +464,7 @@ MODULE_PARM_DESC(hot_add, "If set attempt memory hot_add");
40233
40234 module_param(pressure_report_delay, uint, (S_IRUGO | S_IWUSR));
40235 MODULE_PARM_DESC(pressure_report_delay, "Delay in secs in reporting pressure");
40236 -static atomic_t trans_id = ATOMIC_INIT(0);
40237 +static atomic_unchecked_t trans_id = ATOMIC_INIT(0);
40238
40239 static int dm_ring_size = (5 * PAGE_SIZE);
40240
40241 @@ -886,7 +886,7 @@ static void hot_add_req(struct work_struct *dummy)
40242 pr_info("Memory hot add failed\n");
40243
40244 dm->state = DM_INITIALIZED;
40245 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40246 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40247 vmbus_sendpacket(dm->dev->channel, &resp,
40248 sizeof(struct dm_hot_add_response),
40249 (unsigned long)NULL,
40250 @@ -960,7 +960,7 @@ static void post_status(struct hv_dynmem_device *dm)
40251 memset(&status, 0, sizeof(struct dm_status));
40252 status.hdr.type = DM_STATUS_REPORT;
40253 status.hdr.size = sizeof(struct dm_status);
40254 - status.hdr.trans_id = atomic_inc_return(&trans_id);
40255 + status.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40256
40257 /*
40258 * The host expects the guest to report free memory.
40259 @@ -980,7 +980,7 @@ static void post_status(struct hv_dynmem_device *dm)
40260 * send the status. This can happen if we were interrupted
40261 * after we picked our transaction ID.
40262 */
40263 - if (status.hdr.trans_id != atomic_read(&trans_id))
40264 + if (status.hdr.trans_id != atomic_read_unchecked(&trans_id))
40265 return;
40266
40267 vmbus_sendpacket(dm->dev->channel, &status,
40268 @@ -1108,7 +1108,7 @@ static void balloon_up(struct work_struct *dummy)
40269 */
40270
40271 do {
40272 - bl_resp->hdr.trans_id = atomic_inc_return(&trans_id);
40273 + bl_resp->hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40274 ret = vmbus_sendpacket(dm_device.dev->channel,
40275 bl_resp,
40276 bl_resp->hdr.size,
40277 @@ -1152,7 +1152,7 @@ static void balloon_down(struct hv_dynmem_device *dm,
40278
40279 memset(&resp, 0, sizeof(struct dm_unballoon_response));
40280 resp.hdr.type = DM_UNBALLOON_RESPONSE;
40281 - resp.hdr.trans_id = atomic_inc_return(&trans_id);
40282 + resp.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40283 resp.hdr.size = sizeof(struct dm_unballoon_response);
40284
40285 vmbus_sendpacket(dm_device.dev->channel, &resp,
40286 @@ -1215,7 +1215,7 @@ static void version_resp(struct hv_dynmem_device *dm,
40287 memset(&version_req, 0, sizeof(struct dm_version_request));
40288 version_req.hdr.type = DM_VERSION_REQUEST;
40289 version_req.hdr.size = sizeof(struct dm_version_request);
40290 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40291 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40292 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN7;
40293 version_req.is_last_attempt = 1;
40294
40295 @@ -1385,7 +1385,7 @@ static int balloon_probe(struct hv_device *dev,
40296 memset(&version_req, 0, sizeof(struct dm_version_request));
40297 version_req.hdr.type = DM_VERSION_REQUEST;
40298 version_req.hdr.size = sizeof(struct dm_version_request);
40299 - version_req.hdr.trans_id = atomic_inc_return(&trans_id);
40300 + version_req.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40301 version_req.version.version = DYNMEM_PROTOCOL_VERSION_WIN8;
40302 version_req.is_last_attempt = 0;
40303
40304 @@ -1416,7 +1416,7 @@ static int balloon_probe(struct hv_device *dev,
40305 memset(&cap_msg, 0, sizeof(struct dm_capabilities));
40306 cap_msg.hdr.type = DM_CAPABILITIES_REPORT;
40307 cap_msg.hdr.size = sizeof(struct dm_capabilities);
40308 - cap_msg.hdr.trans_id = atomic_inc_return(&trans_id);
40309 + cap_msg.hdr.trans_id = atomic_inc_return_unchecked(&trans_id);
40310
40311 cap_msg.caps.cap_bits.balloon = 1;
40312 cap_msg.caps.cap_bits.hot_add = 1;
40313 diff --git a/drivers/hv/hyperv_vmbus.h b/drivers/hv/hyperv_vmbus.h
40314 index d84918f..7f38f9f 100644
40315 --- a/drivers/hv/hyperv_vmbus.h
40316 +++ b/drivers/hv/hyperv_vmbus.h
40317 @@ -595,7 +595,7 @@ enum vmbus_connect_state {
40318 struct vmbus_connection {
40319 enum vmbus_connect_state conn_state;
40320
40321 - atomic_t next_gpadl_handle;
40322 + atomic_unchecked_t next_gpadl_handle;
40323
40324 /*
40325 * Represents channel interrupts. Each bit position represents a
40326 diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c
40327 index f9fe46f..356b119 100644
40328 --- a/drivers/hv/vmbus_drv.c
40329 +++ b/drivers/hv/vmbus_drv.c
40330 @@ -672,10 +672,10 @@ int vmbus_device_register(struct hv_device *child_device_obj)
40331 {
40332 int ret = 0;
40333
40334 - static atomic_t device_num = ATOMIC_INIT(0);
40335 + static atomic_unchecked_t device_num = ATOMIC_INIT(0);
40336
40337 dev_set_name(&child_device_obj->device, "vmbus_0_%d",
40338 - atomic_inc_return(&device_num));
40339 + atomic_inc_return_unchecked(&device_num));
40340
40341 child_device_obj->device.bus = &hv_bus;
40342 child_device_obj->device.parent = &hv_acpi_dev->dev;
40343 diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c
40344 index a9e3d01..9dd246e 100644
40345 --- a/drivers/hwmon/acpi_power_meter.c
40346 +++ b/drivers/hwmon/acpi_power_meter.c
40347 @@ -117,7 +117,7 @@ struct sensor_template {
40348 struct device_attribute *devattr,
40349 const char *buf, size_t count);
40350 int index;
40351 -};
40352 +} __do_const;
40353
40354 /* Averaging interval */
40355 static int update_avg_interval(struct acpi_power_meter_resource *resource)
40356 @@ -629,7 +629,7 @@ static int register_attrs(struct acpi_power_meter_resource *resource,
40357 struct sensor_template *attrs)
40358 {
40359 struct device *dev = &resource->acpi_dev->dev;
40360 - struct sensor_device_attribute *sensors =
40361 + sensor_device_attribute_no_const *sensors =
40362 &resource->sensors[resource->num_sensors];
40363 int res = 0;
40364
40365 diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
40366 index 3288f13..71cfb4e 100644
40367 --- a/drivers/hwmon/applesmc.c
40368 +++ b/drivers/hwmon/applesmc.c
40369 @@ -1106,7 +1106,7 @@ static int applesmc_create_nodes(struct applesmc_node_group *groups, int num)
40370 {
40371 struct applesmc_node_group *grp;
40372 struct applesmc_dev_attr *node;
40373 - struct attribute *attr;
40374 + attribute_no_const *attr;
40375 int ret, i;
40376
40377 for (grp = groups; grp->format; grp++) {
40378 diff --git a/drivers/hwmon/asus_atk0110.c b/drivers/hwmon/asus_atk0110.c
40379 index b25c643..a13460d 100644
40380 --- a/drivers/hwmon/asus_atk0110.c
40381 +++ b/drivers/hwmon/asus_atk0110.c
40382 @@ -152,10 +152,10 @@ MODULE_DEVICE_TABLE(acpi, atk_ids);
40383 struct atk_sensor_data {
40384 struct list_head list;
40385 struct atk_data *data;
40386 - struct device_attribute label_attr;
40387 - struct device_attribute input_attr;
40388 - struct device_attribute limit1_attr;
40389 - struct device_attribute limit2_attr;
40390 + device_attribute_no_const label_attr;
40391 + device_attribute_no_const input_attr;
40392 + device_attribute_no_const limit1_attr;
40393 + device_attribute_no_const limit2_attr;
40394 char label_attr_name[ATTR_NAME_SIZE];
40395 char input_attr_name[ATTR_NAME_SIZE];
40396 char limit1_attr_name[ATTR_NAME_SIZE];
40397 @@ -275,7 +275,7 @@ static ssize_t atk_name_show(struct device *dev,
40398 static struct device_attribute atk_name_attr =
40399 __ATTR(name, 0444, atk_name_show, NULL);
40400
40401 -static void atk_init_attribute(struct device_attribute *attr, char *name,
40402 +static void atk_init_attribute(device_attribute_no_const *attr, char *name,
40403 sysfs_show_func show)
40404 {
40405 sysfs_attr_init(&attr->attr);
40406 diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c
40407 index 78be661..4dd032f 100644
40408 --- a/drivers/hwmon/coretemp.c
40409 +++ b/drivers/hwmon/coretemp.c
40410 @@ -797,7 +797,7 @@ static int coretemp_cpu_callback(struct notifier_block *nfb,
40411 return NOTIFY_OK;
40412 }
40413
40414 -static struct notifier_block coretemp_cpu_notifier __refdata = {
40415 +static struct notifier_block coretemp_cpu_notifier = {
40416 .notifier_call = coretemp_cpu_callback,
40417 };
40418
40419 diff --git a/drivers/hwmon/ibmaem.c b/drivers/hwmon/ibmaem.c
40420 index 632f1dc..57e6a58 100644
40421 --- a/drivers/hwmon/ibmaem.c
40422 +++ b/drivers/hwmon/ibmaem.c
40423 @@ -926,7 +926,7 @@ static int aem_register_sensors(struct aem_data *data,
40424 struct aem_rw_sensor_template *rw)
40425 {
40426 struct device *dev = &data->pdev->dev;
40427 - struct sensor_device_attribute *sensors = data->sensors;
40428 + sensor_device_attribute_no_const *sensors = data->sensors;
40429 int err;
40430
40431 /* Set up read-only sensors */
40432 diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c
40433 index 708081b..fe2d4ab 100644
40434 --- a/drivers/hwmon/iio_hwmon.c
40435 +++ b/drivers/hwmon/iio_hwmon.c
40436 @@ -73,7 +73,7 @@ static int iio_hwmon_probe(struct platform_device *pdev)
40437 {
40438 struct device *dev = &pdev->dev;
40439 struct iio_hwmon_state *st;
40440 - struct sensor_device_attribute *a;
40441 + sensor_device_attribute_no_const *a;
40442 int ret, i;
40443 int in_i = 1, temp_i = 1, curr_i = 1;
40444 enum iio_chan_type type;
40445 diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c
40446 index 6eb03ce..bea7e3e 100644
40447 --- a/drivers/hwmon/nct6775.c
40448 +++ b/drivers/hwmon/nct6775.c
40449 @@ -936,10 +936,10 @@ static struct attribute_group *
40450 nct6775_create_attr_group(struct device *dev, struct sensor_template_group *tg,
40451 int repeat)
40452 {
40453 - struct attribute_group *group;
40454 + attribute_group_no_const *group;
40455 struct sensor_device_attr_u *su;
40456 - struct sensor_device_attribute *a;
40457 - struct sensor_device_attribute_2 *a2;
40458 + sensor_device_attribute_no_const *a;
40459 + sensor_device_attribute_2_no_const *a2;
40460 struct attribute **attrs;
40461 struct sensor_device_template **t;
40462 int err, i, j, count;
40463 diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c
40464 index 9319fcf..189ff45 100644
40465 --- a/drivers/hwmon/pmbus/pmbus_core.c
40466 +++ b/drivers/hwmon/pmbus/pmbus_core.c
40467 @@ -781,7 +781,7 @@ static int pmbus_add_attribute(struct pmbus_data *data, struct attribute *attr)
40468 return 0;
40469 }
40470
40471 -static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40472 +static void pmbus_dev_attr_init(device_attribute_no_const *dev_attr,
40473 const char *name,
40474 umode_t mode,
40475 ssize_t (*show)(struct device *dev,
40476 @@ -798,7 +798,7 @@ static void pmbus_dev_attr_init(struct device_attribute *dev_attr,
40477 dev_attr->store = store;
40478 }
40479
40480 -static void pmbus_attr_init(struct sensor_device_attribute *a,
40481 +static void pmbus_attr_init(sensor_device_attribute_no_const *a,
40482 const char *name,
40483 umode_t mode,
40484 ssize_t (*show)(struct device *dev,
40485 @@ -820,7 +820,7 @@ static int pmbus_add_boolean(struct pmbus_data *data,
40486 u16 reg, u8 mask)
40487 {
40488 struct pmbus_boolean *boolean;
40489 - struct sensor_device_attribute *a;
40490 + sensor_device_attribute_no_const *a;
40491
40492 boolean = devm_kzalloc(data->dev, sizeof(*boolean), GFP_KERNEL);
40493 if (!boolean)
40494 @@ -845,7 +845,7 @@ static struct pmbus_sensor *pmbus_add_sensor(struct pmbus_data *data,
40495 bool update, bool readonly)
40496 {
40497 struct pmbus_sensor *sensor;
40498 - struct device_attribute *a;
40499 + device_attribute_no_const *a;
40500
40501 sensor = devm_kzalloc(data->dev, sizeof(*sensor), GFP_KERNEL);
40502 if (!sensor)
40503 @@ -876,7 +876,7 @@ static int pmbus_add_label(struct pmbus_data *data,
40504 const char *lstring, int index)
40505 {
40506 struct pmbus_label *label;
40507 - struct device_attribute *a;
40508 + device_attribute_no_const *a;
40509
40510 label = devm_kzalloc(data->dev, sizeof(*label), GFP_KERNEL);
40511 if (!label)
40512 diff --git a/drivers/hwmon/sht15.c b/drivers/hwmon/sht15.c
40513 index 97cd45a..ac54d8b 100644
40514 --- a/drivers/hwmon/sht15.c
40515 +++ b/drivers/hwmon/sht15.c
40516 @@ -169,7 +169,7 @@ struct sht15_data {
40517 int supply_uv;
40518 bool supply_uv_valid;
40519 struct work_struct update_supply_work;
40520 - atomic_t interrupt_handled;
40521 + atomic_unchecked_t interrupt_handled;
40522 };
40523
40524 /**
40525 @@ -542,13 +542,13 @@ static int sht15_measurement(struct sht15_data *data,
40526 ret = gpio_direction_input(data->pdata->gpio_data);
40527 if (ret)
40528 return ret;
40529 - atomic_set(&data->interrupt_handled, 0);
40530 + atomic_set_unchecked(&data->interrupt_handled, 0);
40531
40532 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40533 if (gpio_get_value(data->pdata->gpio_data) == 0) {
40534 disable_irq_nosync(gpio_to_irq(data->pdata->gpio_data));
40535 /* Only relevant if the interrupt hasn't occurred. */
40536 - if (!atomic_read(&data->interrupt_handled))
40537 + if (!atomic_read_unchecked(&data->interrupt_handled))
40538 schedule_work(&data->read_work);
40539 }
40540 ret = wait_event_timeout(data->wait_queue,
40541 @@ -820,7 +820,7 @@ static irqreturn_t sht15_interrupt_fired(int irq, void *d)
40542
40543 /* First disable the interrupt */
40544 disable_irq_nosync(irq);
40545 - atomic_inc(&data->interrupt_handled);
40546 + atomic_inc_unchecked(&data->interrupt_handled);
40547 /* Then schedule a reading work struct */
40548 if (data->state != SHT15_READING_NOTHING)
40549 schedule_work(&data->read_work);
40550 @@ -842,11 +842,11 @@ static void sht15_bh_read_data(struct work_struct *work_s)
40551 * If not, then start the interrupt again - care here as could
40552 * have gone low in meantime so verify it hasn't!
40553 */
40554 - atomic_set(&data->interrupt_handled, 0);
40555 + atomic_set_unchecked(&data->interrupt_handled, 0);
40556 enable_irq(gpio_to_irq(data->pdata->gpio_data));
40557 /* If still not occurred or another handler was scheduled */
40558 if (gpio_get_value(data->pdata->gpio_data)
40559 - || atomic_read(&data->interrupt_handled))
40560 + || atomic_read_unchecked(&data->interrupt_handled))
40561 return;
40562 }
40563
40564 diff --git a/drivers/hwmon/via-cputemp.c b/drivers/hwmon/via-cputemp.c
40565 index 38944e9..ae9e5ed 100644
40566 --- a/drivers/hwmon/via-cputemp.c
40567 +++ b/drivers/hwmon/via-cputemp.c
40568 @@ -296,7 +296,7 @@ static int via_cputemp_cpu_callback(struct notifier_block *nfb,
40569 return NOTIFY_OK;
40570 }
40571
40572 -static struct notifier_block via_cputemp_cpu_notifier __refdata = {
40573 +static struct notifier_block via_cputemp_cpu_notifier = {
40574 .notifier_call = via_cputemp_cpu_callback,
40575 };
40576
40577 diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c
40578 index 07f01ac..d79ad3d 100644
40579 --- a/drivers/i2c/busses/i2c-amd756-s4882.c
40580 +++ b/drivers/i2c/busses/i2c-amd756-s4882.c
40581 @@ -43,7 +43,7 @@
40582 extern struct i2c_adapter amd756_smbus;
40583
40584 static struct i2c_adapter *s4882_adapter;
40585 -static struct i2c_algorithm *s4882_algo;
40586 +static i2c_algorithm_no_const *s4882_algo;
40587
40588 /* Wrapper access functions for multiplexed SMBus */
40589 static DEFINE_MUTEX(amd756_lock);
40590 diff --git a/drivers/i2c/busses/i2c-diolan-u2c.c b/drivers/i2c/busses/i2c-diolan-u2c.c
40591 index dae3ddf..26e21d1 100644
40592 --- a/drivers/i2c/busses/i2c-diolan-u2c.c
40593 +++ b/drivers/i2c/busses/i2c-diolan-u2c.c
40594 @@ -99,7 +99,7 @@ MODULE_PARM_DESC(frequency, "I2C clock frequency in hertz");
40595 /* usb layer */
40596
40597 /* Send command to device, and get response. */
40598 -static int diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40599 +static int __intentional_overflow(-1) diolan_usb_transfer(struct i2c_diolan_u2c *dev)
40600 {
40601 int ret = 0;
40602 int actual;
40603 diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c
40604 index 2ca268d..c6acbdf 100644
40605 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c
40606 +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c
40607 @@ -41,7 +41,7 @@
40608 extern struct i2c_adapter *nforce2_smbus;
40609
40610 static struct i2c_adapter *s4985_adapter;
40611 -static struct i2c_algorithm *s4985_algo;
40612 +static i2c_algorithm_no_const *s4985_algo;
40613
40614 /* Wrapper access functions for multiplexed SMBus */
40615 static DEFINE_MUTEX(nforce2_lock);
40616 diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c
40617 index c3ccdea..5b3dc1a 100644
40618 --- a/drivers/i2c/i2c-dev.c
40619 +++ b/drivers/i2c/i2c-dev.c
40620 @@ -271,7 +271,7 @@ static noinline int i2cdev_ioctl_rdrw(struct i2c_client *client,
40621 break;
40622 }
40623
40624 - data_ptrs[i] = (u8 __user *)rdwr_pa[i].buf;
40625 + data_ptrs[i] = (u8 __force_user *)rdwr_pa[i].buf;
40626 rdwr_pa[i].buf = memdup_user(data_ptrs[i], rdwr_pa[i].len);
40627 if (IS_ERR(rdwr_pa[i].buf)) {
40628 res = PTR_ERR(rdwr_pa[i].buf);
40629 diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
40630 index 0b510ba..4fbb5085 100644
40631 --- a/drivers/ide/ide-cd.c
40632 +++ b/drivers/ide/ide-cd.c
40633 @@ -768,7 +768,7 @@ static void cdrom_do_block_pc(ide_drive_t *drive, struct request *rq)
40634 alignment = queue_dma_alignment(q) | q->dma_pad_mask;
40635 if ((unsigned long)buf & alignment
40636 || blk_rq_bytes(rq) & q->dma_pad_mask
40637 - || object_is_on_stack(buf))
40638 + || object_starts_on_stack(buf))
40639 drive->dma = 0;
40640 }
40641 }
40642 diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
40643 index f95c697..0a1b05c 100644
40644 --- a/drivers/iio/industrialio-core.c
40645 +++ b/drivers/iio/industrialio-core.c
40646 @@ -506,7 +506,7 @@ static ssize_t iio_write_channel_info(struct device *dev,
40647 }
40648
40649 static
40650 -int __iio_device_attr_init(struct device_attribute *dev_attr,
40651 +int __iio_device_attr_init(device_attribute_no_const *dev_attr,
40652 const char *postfix,
40653 struct iio_chan_spec const *chan,
40654 ssize_t (*readfunc)(struct device *dev,
40655 diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
40656 index 784b97c..c9ceadf 100644
40657 --- a/drivers/infiniband/core/cm.c
40658 +++ b/drivers/infiniband/core/cm.c
40659 @@ -114,7 +114,7 @@ static char const counter_group_names[CM_COUNTER_GROUPS]
40660
40661 struct cm_counter_group {
40662 struct kobject obj;
40663 - atomic_long_t counter[CM_ATTR_COUNT];
40664 + atomic_long_unchecked_t counter[CM_ATTR_COUNT];
40665 };
40666
40667 struct cm_counter_attribute {
40668 @@ -1395,7 +1395,7 @@ static void cm_dup_req_handler(struct cm_work *work,
40669 struct ib_mad_send_buf *msg = NULL;
40670 int ret;
40671
40672 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40673 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40674 counter[CM_REQ_COUNTER]);
40675
40676 /* Quick state check to discard duplicate REQs. */
40677 @@ -1779,7 +1779,7 @@ static void cm_dup_rep_handler(struct cm_work *work)
40678 if (!cm_id_priv)
40679 return;
40680
40681 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40682 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40683 counter[CM_REP_COUNTER]);
40684 ret = cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg);
40685 if (ret)
40686 @@ -1946,7 +1946,7 @@ static int cm_rtu_handler(struct cm_work *work)
40687 if (cm_id_priv->id.state != IB_CM_REP_SENT &&
40688 cm_id_priv->id.state != IB_CM_MRA_REP_RCVD) {
40689 spin_unlock_irq(&cm_id_priv->lock);
40690 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40691 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40692 counter[CM_RTU_COUNTER]);
40693 goto out;
40694 }
40695 @@ -2129,7 +2129,7 @@ static int cm_dreq_handler(struct cm_work *work)
40696 cm_id_priv = cm_acquire_id(dreq_msg->remote_comm_id,
40697 dreq_msg->local_comm_id);
40698 if (!cm_id_priv) {
40699 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40700 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40701 counter[CM_DREQ_COUNTER]);
40702 cm_issue_drep(work->port, work->mad_recv_wc);
40703 return -EINVAL;
40704 @@ -2154,7 +2154,7 @@ static int cm_dreq_handler(struct cm_work *work)
40705 case IB_CM_MRA_REP_RCVD:
40706 break;
40707 case IB_CM_TIMEWAIT:
40708 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40709 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40710 counter[CM_DREQ_COUNTER]);
40711 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40712 goto unlock;
40713 @@ -2168,7 +2168,7 @@ static int cm_dreq_handler(struct cm_work *work)
40714 cm_free_msg(msg);
40715 goto deref;
40716 case IB_CM_DREQ_RCVD:
40717 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40718 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40719 counter[CM_DREQ_COUNTER]);
40720 goto unlock;
40721 default:
40722 @@ -2535,7 +2535,7 @@ static int cm_mra_handler(struct cm_work *work)
40723 ib_modify_mad(cm_id_priv->av.port->mad_agent,
40724 cm_id_priv->msg, timeout)) {
40725 if (cm_id_priv->id.lap_state == IB_CM_MRA_LAP_RCVD)
40726 - atomic_long_inc(&work->port->
40727 + atomic_long_inc_unchecked(&work->port->
40728 counter_group[CM_RECV_DUPLICATES].
40729 counter[CM_MRA_COUNTER]);
40730 goto out;
40731 @@ -2544,7 +2544,7 @@ static int cm_mra_handler(struct cm_work *work)
40732 break;
40733 case IB_CM_MRA_REQ_RCVD:
40734 case IB_CM_MRA_REP_RCVD:
40735 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40736 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40737 counter[CM_MRA_COUNTER]);
40738 /* fall through */
40739 default:
40740 @@ -2706,7 +2706,7 @@ static int cm_lap_handler(struct cm_work *work)
40741 case IB_CM_LAP_IDLE:
40742 break;
40743 case IB_CM_MRA_LAP_SENT:
40744 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40745 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40746 counter[CM_LAP_COUNTER]);
40747 if (cm_alloc_response_msg(work->port, work->mad_recv_wc, &msg))
40748 goto unlock;
40749 @@ -2722,7 +2722,7 @@ static int cm_lap_handler(struct cm_work *work)
40750 cm_free_msg(msg);
40751 goto deref;
40752 case IB_CM_LAP_RCVD:
40753 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40754 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40755 counter[CM_LAP_COUNTER]);
40756 goto unlock;
40757 default:
40758 @@ -3006,7 +3006,7 @@ static int cm_sidr_req_handler(struct cm_work *work)
40759 cur_cm_id_priv = cm_insert_remote_sidr(cm_id_priv);
40760 if (cur_cm_id_priv) {
40761 spin_unlock_irq(&cm.lock);
40762 - atomic_long_inc(&work->port->counter_group[CM_RECV_DUPLICATES].
40763 + atomic_long_inc_unchecked(&work->port->counter_group[CM_RECV_DUPLICATES].
40764 counter[CM_SIDR_REQ_COUNTER]);
40765 goto out; /* Duplicate message. */
40766 }
40767 @@ -3218,10 +3218,10 @@ static void cm_send_handler(struct ib_mad_agent *mad_agent,
40768 if (!msg->context[0] && (attr_index != CM_REJ_COUNTER))
40769 msg->retries = 1;
40770
40771 - atomic_long_add(1 + msg->retries,
40772 + atomic_long_add_unchecked(1 + msg->retries,
40773 &port->counter_group[CM_XMIT].counter[attr_index]);
40774 if (msg->retries)
40775 - atomic_long_add(msg->retries,
40776 + atomic_long_add_unchecked(msg->retries,
40777 &port->counter_group[CM_XMIT_RETRIES].
40778 counter[attr_index]);
40779
40780 @@ -3431,7 +3431,7 @@ static void cm_recv_handler(struct ib_mad_agent *mad_agent,
40781 }
40782
40783 attr_id = be16_to_cpu(mad_recv_wc->recv_buf.mad->mad_hdr.attr_id);
40784 - atomic_long_inc(&port->counter_group[CM_RECV].
40785 + atomic_long_inc_unchecked(&port->counter_group[CM_RECV].
40786 counter[attr_id - CM_ATTR_ID_OFFSET]);
40787
40788 work = kmalloc(sizeof *work + sizeof(struct ib_sa_path_rec) * paths,
40789 @@ -3636,7 +3636,7 @@ static ssize_t cm_show_counter(struct kobject *obj, struct attribute *attr,
40790 cm_attr = container_of(attr, struct cm_counter_attribute, attr);
40791
40792 return sprintf(buf, "%ld\n",
40793 - atomic_long_read(&group->counter[cm_attr->index]));
40794 + atomic_long_read_unchecked(&group->counter[cm_attr->index]));
40795 }
40796
40797 static const struct sysfs_ops cm_counter_ops = {
40798 diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c
40799 index 9f5ad7c..588cd84 100644
40800 --- a/drivers/infiniband/core/fmr_pool.c
40801 +++ b/drivers/infiniband/core/fmr_pool.c
40802 @@ -98,8 +98,8 @@ struct ib_fmr_pool {
40803
40804 struct task_struct *thread;
40805
40806 - atomic_t req_ser;
40807 - atomic_t flush_ser;
40808 + atomic_unchecked_t req_ser;
40809 + atomic_unchecked_t flush_ser;
40810
40811 wait_queue_head_t force_wait;
40812 };
40813 @@ -179,10 +179,10 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40814 struct ib_fmr_pool *pool = pool_ptr;
40815
40816 do {
40817 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) < 0) {
40818 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) < 0) {
40819 ib_fmr_batch_release(pool);
40820
40821 - atomic_inc(&pool->flush_ser);
40822 + atomic_inc_unchecked(&pool->flush_ser);
40823 wake_up_interruptible(&pool->force_wait);
40824
40825 if (pool->flush_function)
40826 @@ -190,7 +190,7 @@ static int ib_fmr_cleanup_thread(void *pool_ptr)
40827 }
40828
40829 set_current_state(TASK_INTERRUPTIBLE);
40830 - if (atomic_read(&pool->flush_ser) - atomic_read(&pool->req_ser) >= 0 &&
40831 + if (atomic_read_unchecked(&pool->flush_ser) - atomic_read_unchecked(&pool->req_ser) >= 0 &&
40832 !kthread_should_stop())
40833 schedule();
40834 __set_current_state(TASK_RUNNING);
40835 @@ -282,8 +282,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
40836 pool->dirty_watermark = params->dirty_watermark;
40837 pool->dirty_len = 0;
40838 spin_lock_init(&pool->pool_lock);
40839 - atomic_set(&pool->req_ser, 0);
40840 - atomic_set(&pool->flush_ser, 0);
40841 + atomic_set_unchecked(&pool->req_ser, 0);
40842 + atomic_set_unchecked(&pool->flush_ser, 0);
40843 init_waitqueue_head(&pool->force_wait);
40844
40845 pool->thread = kthread_run(ib_fmr_cleanup_thread,
40846 @@ -411,11 +411,11 @@ int ib_flush_fmr_pool(struct ib_fmr_pool *pool)
40847 }
40848 spin_unlock_irq(&pool->pool_lock);
40849
40850 - serial = atomic_inc_return(&pool->req_ser);
40851 + serial = atomic_inc_return_unchecked(&pool->req_ser);
40852 wake_up_process(pool->thread);
40853
40854 if (wait_event_interruptible(pool->force_wait,
40855 - atomic_read(&pool->flush_ser) - serial >= 0))
40856 + atomic_read_unchecked(&pool->flush_ser) - serial >= 0))
40857 return -EINTR;
40858
40859 return 0;
40860 @@ -525,7 +525,7 @@ int ib_fmr_pool_unmap(struct ib_pool_fmr *fmr)
40861 } else {
40862 list_add_tail(&fmr->list, &pool->dirty_list);
40863 if (++pool->dirty_len >= pool->dirty_watermark) {
40864 - atomic_inc(&pool->req_ser);
40865 + atomic_inc_unchecked(&pool->req_ser);
40866 wake_up_process(pool->thread);
40867 }
40868 }
40869 diff --git a/drivers/infiniband/hw/cxgb4/mem.c b/drivers/infiniband/hw/cxgb4/mem.c
40870 index 4cb8eb2..146bf60 100644
40871 --- a/drivers/infiniband/hw/cxgb4/mem.c
40872 +++ b/drivers/infiniband/hw/cxgb4/mem.c
40873 @@ -249,7 +249,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40874 int err;
40875 struct fw_ri_tpte tpt;
40876 u32 stag_idx;
40877 - static atomic_t key;
40878 + static atomic_unchecked_t key;
40879
40880 if (c4iw_fatal_error(rdev))
40881 return -EIO;
40882 @@ -266,7 +266,7 @@ static int write_tpt_entry(struct c4iw_rdev *rdev, u32 reset_tpt_entry,
40883 if (rdev->stats.stag.cur > rdev->stats.stag.max)
40884 rdev->stats.stag.max = rdev->stats.stag.cur;
40885 mutex_unlock(&rdev->stats.lock);
40886 - *stag = (stag_idx << 8) | (atomic_inc_return(&key) & 0xff);
40887 + *stag = (stag_idx << 8) | (atomic_inc_return_unchecked(&key) & 0xff);
40888 }
40889 PDBG("%s stag_state 0x%0x type 0x%0x pdid 0x%0x, stag_idx 0x%x\n",
40890 __func__, stag_state, type, pdid, stag_idx);
40891 diff --git a/drivers/infiniband/hw/ipath/ipath_rc.c b/drivers/infiniband/hw/ipath/ipath_rc.c
40892 index 79b3dbc..96e5fcc 100644
40893 --- a/drivers/infiniband/hw/ipath/ipath_rc.c
40894 +++ b/drivers/infiniband/hw/ipath/ipath_rc.c
40895 @@ -1868,7 +1868,7 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40896 struct ib_atomic_eth *ateth;
40897 struct ipath_ack_entry *e;
40898 u64 vaddr;
40899 - atomic64_t *maddr;
40900 + atomic64_unchecked_t *maddr;
40901 u64 sdata;
40902 u32 rkey;
40903 u8 next;
40904 @@ -1903,11 +1903,11 @@ void ipath_rc_rcv(struct ipath_ibdev *dev, struct ipath_ib_header *hdr,
40905 IB_ACCESS_REMOTE_ATOMIC)))
40906 goto nack_acc_unlck;
40907 /* Perform atomic OP and save result. */
40908 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40909 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40910 sdata = be64_to_cpu(ateth->swap_data);
40911 e = &qp->s_ack_queue[qp->r_head_ack_queue];
40912 e->atomic_data = (opcode == OP(FETCH_ADD)) ?
40913 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40914 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40915 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40916 be64_to_cpu(ateth->compare_data),
40917 sdata);
40918 diff --git a/drivers/infiniband/hw/ipath/ipath_ruc.c b/drivers/infiniband/hw/ipath/ipath_ruc.c
40919 index 1f95bba..9530f87 100644
40920 --- a/drivers/infiniband/hw/ipath/ipath_ruc.c
40921 +++ b/drivers/infiniband/hw/ipath/ipath_ruc.c
40922 @@ -266,7 +266,7 @@ static void ipath_ruc_loopback(struct ipath_qp *sqp)
40923 unsigned long flags;
40924 struct ib_wc wc;
40925 u64 sdata;
40926 - atomic64_t *maddr;
40927 + atomic64_unchecked_t *maddr;
40928 enum ib_wc_status send_status;
40929
40930 /*
40931 @@ -382,11 +382,11 @@ again:
40932 IB_ACCESS_REMOTE_ATOMIC)))
40933 goto acc_err;
40934 /* Perform atomic OP and save result. */
40935 - maddr = (atomic64_t *) qp->r_sge.sge.vaddr;
40936 + maddr = (atomic64_unchecked_t *) qp->r_sge.sge.vaddr;
40937 sdata = wqe->wr.wr.atomic.compare_add;
40938 *(u64 *) sqp->s_sge.sge.vaddr =
40939 (wqe->wr.opcode == IB_WR_ATOMIC_FETCH_AND_ADD) ?
40940 - (u64) atomic64_add_return(sdata, maddr) - sdata :
40941 + (u64) atomic64_add_return_unchecked(sdata, maddr) - sdata :
40942 (u64) cmpxchg((u64 *) qp->r_sge.sge.vaddr,
40943 sdata, wqe->wr.wr.atomic.swap);
40944 goto send_comp;
40945 diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c
40946 index f2a3f48..673ec79 100644
40947 --- a/drivers/infiniband/hw/mlx4/mad.c
40948 +++ b/drivers/infiniband/hw/mlx4/mad.c
40949 @@ -98,7 +98,7 @@ __be64 mlx4_ib_gen_node_guid(void)
40950
40951 __be64 mlx4_ib_get_new_demux_tid(struct mlx4_ib_demux_ctx *ctx)
40952 {
40953 - return cpu_to_be64(atomic_inc_return(&ctx->tid)) |
40954 + return cpu_to_be64(atomic_inc_return_unchecked(&ctx->tid)) |
40955 cpu_to_be64(0xff00000000000000LL);
40956 }
40957
40958 diff --git a/drivers/infiniband/hw/mlx4/mcg.c b/drivers/infiniband/hw/mlx4/mcg.c
40959 index 25b2cdf..099ff97 100644
40960 --- a/drivers/infiniband/hw/mlx4/mcg.c
40961 +++ b/drivers/infiniband/hw/mlx4/mcg.c
40962 @@ -1040,7 +1040,7 @@ int mlx4_ib_mcg_port_init(struct mlx4_ib_demux_ctx *ctx)
40963 {
40964 char name[20];
40965
40966 - atomic_set(&ctx->tid, 0);
40967 + atomic_set_unchecked(&ctx->tid, 0);
40968 sprintf(name, "mlx4_ib_mcg%d", ctx->port);
40969 ctx->mcg_wq = create_singlethread_workqueue(name);
40970 if (!ctx->mcg_wq)
40971 diff --git a/drivers/infiniband/hw/mlx4/mlx4_ib.h b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40972 index 036b663..c9a8c73 100644
40973 --- a/drivers/infiniband/hw/mlx4/mlx4_ib.h
40974 +++ b/drivers/infiniband/hw/mlx4/mlx4_ib.h
40975 @@ -404,7 +404,7 @@ struct mlx4_ib_demux_ctx {
40976 struct list_head mcg_mgid0_list;
40977 struct workqueue_struct *mcg_wq;
40978 struct mlx4_ib_demux_pv_ctx **tun;
40979 - atomic_t tid;
40980 + atomic_unchecked_t tid;
40981 int flushing; /* flushing the work queue */
40982 };
40983
40984 diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c
40985 index 9d3e5c1..6f166df 100644
40986 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c
40987 +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c
40988 @@ -772,7 +772,7 @@ static void mthca_setup_cmd_doorbells(struct mthca_dev *dev, u64 base)
40989 mthca_dbg(dev, "Mapped doorbell page for posting FW commands\n");
40990 }
40991
40992 -int mthca_QUERY_FW(struct mthca_dev *dev)
40993 +int __intentional_overflow(-1) mthca_QUERY_FW(struct mthca_dev *dev)
40994 {
40995 struct mthca_mailbox *mailbox;
40996 u32 *outbox;
40997 @@ -1612,7 +1612,7 @@ int mthca_HW2SW_MPT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
40998 CMD_TIME_CLASS_B);
40999 }
41000
41001 -int mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41002 +int __intentional_overflow(-1) mthca_WRITE_MTT(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41003 int num_mtt)
41004 {
41005 return mthca_cmd(dev, mailbox->dma, num_mtt, 0, CMD_WRITE_MTT,
41006 @@ -1634,7 +1634,7 @@ int mthca_MAP_EQ(struct mthca_dev *dev, u64 event_mask, int unmap,
41007 0, CMD_MAP_EQ, CMD_TIME_CLASS_B);
41008 }
41009
41010 -int mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41011 +int __intentional_overflow(-1) mthca_SW2HW_EQ(struct mthca_dev *dev, struct mthca_mailbox *mailbox,
41012 int eq_num)
41013 {
41014 return mthca_cmd(dev, mailbox->dma, eq_num, 0, CMD_SW2HW_EQ,
41015 @@ -1857,7 +1857,7 @@ int mthca_CONF_SPECIAL_QP(struct mthca_dev *dev, int type, u32 qpn)
41016 CMD_TIME_CLASS_B);
41017 }
41018
41019 -int mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
41020 +int __intentional_overflow(-1) mthca_MAD_IFC(struct mthca_dev *dev, int ignore_mkey, int ignore_bkey,
41021 int port, struct ib_wc *in_wc, struct ib_grh *in_grh,
41022 void *in_mad, void *response_mad)
41023 {
41024 diff --git a/drivers/infiniband/hw/mthca/mthca_main.c b/drivers/infiniband/hw/mthca/mthca_main.c
41025 index 87897b9..7e79542 100644
41026 --- a/drivers/infiniband/hw/mthca/mthca_main.c
41027 +++ b/drivers/infiniband/hw/mthca/mthca_main.c
41028 @@ -692,7 +692,7 @@ err_close:
41029 return err;
41030 }
41031
41032 -static int mthca_setup_hca(struct mthca_dev *dev)
41033 +static int __intentional_overflow(-1) mthca_setup_hca(struct mthca_dev *dev)
41034 {
41035 int err;
41036
41037 diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c
41038 index ed9a989..6aa5dc2 100644
41039 --- a/drivers/infiniband/hw/mthca/mthca_mr.c
41040 +++ b/drivers/infiniband/hw/mthca/mthca_mr.c
41041 @@ -81,7 +81,7 @@ struct mthca_mpt_entry {
41042 * through the bitmaps)
41043 */
41044
41045 -static u32 mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
41046 +static u32 __intentional_overflow(-1) mthca_buddy_alloc(struct mthca_buddy *buddy, int order)
41047 {
41048 int o;
41049 int m;
41050 @@ -426,7 +426,7 @@ static inline u32 adjust_key(struct mthca_dev *dev, u32 key)
41051 return key;
41052 }
41053
41054 -int mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41055 +int __intentional_overflow(-1) mthca_mr_alloc(struct mthca_dev *dev, u32 pd, int buffer_size_shift,
41056 u64 iova, u64 total_size, u32 access, struct mthca_mr *mr)
41057 {
41058 struct mthca_mailbox *mailbox;
41059 @@ -516,7 +516,7 @@ int mthca_mr_alloc_notrans(struct mthca_dev *dev, u32 pd,
41060 return mthca_mr_alloc(dev, pd, 12, 0, ~0ULL, access, mr);
41061 }
41062
41063 -int mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
41064 +int __intentional_overflow(-1) mthca_mr_alloc_phys(struct mthca_dev *dev, u32 pd,
41065 u64 *buffer_list, int buffer_size_shift,
41066 int list_len, u64 iova, u64 total_size,
41067 u32 access, struct mthca_mr *mr)
41068 diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c
41069 index 5b71d43..35a9e14 100644
41070 --- a/drivers/infiniband/hw/mthca/mthca_provider.c
41071 +++ b/drivers/infiniband/hw/mthca/mthca_provider.c
41072 @@ -763,7 +763,7 @@ unlock:
41073 return 0;
41074 }
41075
41076 -static int mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
41077 +static int __intentional_overflow(-1) mthca_resize_cq(struct ib_cq *ibcq, int entries, struct ib_udata *udata)
41078 {
41079 struct mthca_dev *dev = to_mdev(ibcq->device);
41080 struct mthca_cq *cq = to_mcq(ibcq);
41081 diff --git a/drivers/infiniband/hw/nes/nes.c b/drivers/infiniband/hw/nes/nes.c
41082 index 4291410..d2ab1fb 100644
41083 --- a/drivers/infiniband/hw/nes/nes.c
41084 +++ b/drivers/infiniband/hw/nes/nes.c
41085 @@ -98,7 +98,7 @@ MODULE_PARM_DESC(limit_maxrdreqsz, "Limit max read request size to 256 Bytes");
41086 LIST_HEAD(nes_adapter_list);
41087 static LIST_HEAD(nes_dev_list);
41088
41089 -atomic_t qps_destroyed;
41090 +atomic_unchecked_t qps_destroyed;
41091
41092 static unsigned int ee_flsh_adapter;
41093 static unsigned int sysfs_nonidx_addr;
41094 @@ -269,7 +269,7 @@ static void nes_cqp_rem_ref_callback(struct nes_device *nesdev, struct nes_cqp_r
41095 struct nes_qp *nesqp = cqp_request->cqp_callback_pointer;
41096 struct nes_adapter *nesadapter = nesdev->nesadapter;
41097
41098 - atomic_inc(&qps_destroyed);
41099 + atomic_inc_unchecked(&qps_destroyed);
41100
41101 /* Free the control structures */
41102
41103 diff --git a/drivers/infiniband/hw/nes/nes.h b/drivers/infiniband/hw/nes/nes.h
41104 index 33cc589..3bd6538 100644
41105 --- a/drivers/infiniband/hw/nes/nes.h
41106 +++ b/drivers/infiniband/hw/nes/nes.h
41107 @@ -177,17 +177,17 @@ extern unsigned int nes_debug_level;
41108 extern unsigned int wqm_quanta;
41109 extern struct list_head nes_adapter_list;
41110
41111 -extern atomic_t cm_connects;
41112 -extern atomic_t cm_accepts;
41113 -extern atomic_t cm_disconnects;
41114 -extern atomic_t cm_closes;
41115 -extern atomic_t cm_connecteds;
41116 -extern atomic_t cm_connect_reqs;
41117 -extern atomic_t cm_rejects;
41118 -extern atomic_t mod_qp_timouts;
41119 -extern atomic_t qps_created;
41120 -extern atomic_t qps_destroyed;
41121 -extern atomic_t sw_qps_destroyed;
41122 +extern atomic_unchecked_t cm_connects;
41123 +extern atomic_unchecked_t cm_accepts;
41124 +extern atomic_unchecked_t cm_disconnects;
41125 +extern atomic_unchecked_t cm_closes;
41126 +extern atomic_unchecked_t cm_connecteds;
41127 +extern atomic_unchecked_t cm_connect_reqs;
41128 +extern atomic_unchecked_t cm_rejects;
41129 +extern atomic_unchecked_t mod_qp_timouts;
41130 +extern atomic_unchecked_t qps_created;
41131 +extern atomic_unchecked_t qps_destroyed;
41132 +extern atomic_unchecked_t sw_qps_destroyed;
41133 extern u32 mh_detected;
41134 extern u32 mh_pauses_sent;
41135 extern u32 cm_packets_sent;
41136 @@ -196,16 +196,16 @@ extern u32 cm_packets_created;
41137 extern u32 cm_packets_received;
41138 extern u32 cm_packets_dropped;
41139 extern u32 cm_packets_retrans;
41140 -extern atomic_t cm_listens_created;
41141 -extern atomic_t cm_listens_destroyed;
41142 +extern atomic_unchecked_t cm_listens_created;
41143 +extern atomic_unchecked_t cm_listens_destroyed;
41144 extern u32 cm_backlog_drops;
41145 -extern atomic_t cm_loopbacks;
41146 -extern atomic_t cm_nodes_created;
41147 -extern atomic_t cm_nodes_destroyed;
41148 -extern atomic_t cm_accel_dropped_pkts;
41149 -extern atomic_t cm_resets_recvd;
41150 -extern atomic_t pau_qps_created;
41151 -extern atomic_t pau_qps_destroyed;
41152 +extern atomic_unchecked_t cm_loopbacks;
41153 +extern atomic_unchecked_t cm_nodes_created;
41154 +extern atomic_unchecked_t cm_nodes_destroyed;
41155 +extern atomic_unchecked_t cm_accel_dropped_pkts;
41156 +extern atomic_unchecked_t cm_resets_recvd;
41157 +extern atomic_unchecked_t pau_qps_created;
41158 +extern atomic_unchecked_t pau_qps_destroyed;
41159
41160 extern u32 int_mod_timer_init;
41161 extern u32 int_mod_cq_depth_256;
41162 diff --git a/drivers/infiniband/hw/nes/nes_cm.c b/drivers/infiniband/hw/nes/nes_cm.c
41163 index 6b29249..57081dd 100644
41164 --- a/drivers/infiniband/hw/nes/nes_cm.c
41165 +++ b/drivers/infiniband/hw/nes/nes_cm.c
41166 @@ -68,14 +68,14 @@ u32 cm_packets_dropped;
41167 u32 cm_packets_retrans;
41168 u32 cm_packets_created;
41169 u32 cm_packets_received;
41170 -atomic_t cm_listens_created;
41171 -atomic_t cm_listens_destroyed;
41172 +atomic_unchecked_t cm_listens_created;
41173 +atomic_unchecked_t cm_listens_destroyed;
41174 u32 cm_backlog_drops;
41175 -atomic_t cm_loopbacks;
41176 -atomic_t cm_nodes_created;
41177 -atomic_t cm_nodes_destroyed;
41178 -atomic_t cm_accel_dropped_pkts;
41179 -atomic_t cm_resets_recvd;
41180 +atomic_unchecked_t cm_loopbacks;
41181 +atomic_unchecked_t cm_nodes_created;
41182 +atomic_unchecked_t cm_nodes_destroyed;
41183 +atomic_unchecked_t cm_accel_dropped_pkts;
41184 +atomic_unchecked_t cm_resets_recvd;
41185
41186 static inline int mini_cm_accelerated(struct nes_cm_core *, struct nes_cm_node *);
41187 static struct nes_cm_listener *mini_cm_listen(struct nes_cm_core *, struct nes_vnic *, struct nes_cm_info *);
41188 @@ -148,13 +148,13 @@ static struct nes_cm_ops nes_cm_api = {
41189
41190 static struct nes_cm_core *g_cm_core;
41191
41192 -atomic_t cm_connects;
41193 -atomic_t cm_accepts;
41194 -atomic_t cm_disconnects;
41195 -atomic_t cm_closes;
41196 -atomic_t cm_connecteds;
41197 -atomic_t cm_connect_reqs;
41198 -atomic_t cm_rejects;
41199 +atomic_unchecked_t cm_connects;
41200 +atomic_unchecked_t cm_accepts;
41201 +atomic_unchecked_t cm_disconnects;
41202 +atomic_unchecked_t cm_closes;
41203 +atomic_unchecked_t cm_connecteds;
41204 +atomic_unchecked_t cm_connect_reqs;
41205 +atomic_unchecked_t cm_rejects;
41206
41207 int nes_add_ref_cm_node(struct nes_cm_node *cm_node)
41208 {
41209 @@ -1272,7 +1272,7 @@ static int mini_cm_dec_refcnt_listen(struct nes_cm_core *cm_core,
41210 kfree(listener);
41211 listener = NULL;
41212 ret = 0;
41213 - atomic_inc(&cm_listens_destroyed);
41214 + atomic_inc_unchecked(&cm_listens_destroyed);
41215 } else {
41216 spin_unlock_irqrestore(&cm_core->listen_list_lock, flags);
41217 }
41218 @@ -1466,7 +1466,7 @@ static struct nes_cm_node *make_cm_node(struct nes_cm_core *cm_core,
41219 cm_node->rem_mac);
41220
41221 add_hte_node(cm_core, cm_node);
41222 - atomic_inc(&cm_nodes_created);
41223 + atomic_inc_unchecked(&cm_nodes_created);
41224
41225 return cm_node;
41226 }
41227 @@ -1524,7 +1524,7 @@ static int rem_ref_cm_node(struct nes_cm_core *cm_core,
41228 }
41229
41230 atomic_dec(&cm_core->node_cnt);
41231 - atomic_inc(&cm_nodes_destroyed);
41232 + atomic_inc_unchecked(&cm_nodes_destroyed);
41233 nesqp = cm_node->nesqp;
41234 if (nesqp) {
41235 nesqp->cm_node = NULL;
41236 @@ -1588,7 +1588,7 @@ static int process_options(struct nes_cm_node *cm_node, u8 *optionsloc,
41237
41238 static void drop_packet(struct sk_buff *skb)
41239 {
41240 - atomic_inc(&cm_accel_dropped_pkts);
41241 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41242 dev_kfree_skb_any(skb);
41243 }
41244
41245 @@ -1651,7 +1651,7 @@ static void handle_rst_pkt(struct nes_cm_node *cm_node, struct sk_buff *skb,
41246 {
41247
41248 int reset = 0; /* whether to send reset in case of err.. */
41249 - atomic_inc(&cm_resets_recvd);
41250 + atomic_inc_unchecked(&cm_resets_recvd);
41251 nes_debug(NES_DBG_CM, "Received Reset, cm_node = %p, state = %u."
41252 " refcnt=%d\n", cm_node, cm_node->state,
41253 atomic_read(&cm_node->ref_count));
41254 @@ -2292,7 +2292,7 @@ static struct nes_cm_node *mini_cm_connect(struct nes_cm_core *cm_core,
41255 rem_ref_cm_node(cm_node->cm_core, cm_node);
41256 return NULL;
41257 }
41258 - atomic_inc(&cm_loopbacks);
41259 + atomic_inc_unchecked(&cm_loopbacks);
41260 loopbackremotenode->loopbackpartner = cm_node;
41261 loopbackremotenode->tcp_cntxt.rcv_wscale =
41262 NES_CM_DEFAULT_RCV_WND_SCALE;
41263 @@ -2567,7 +2567,7 @@ static int mini_cm_recv_pkt(struct nes_cm_core *cm_core,
41264 nes_queue_mgt_skbs(skb, nesvnic, cm_node->nesqp);
41265 else {
41266 rem_ref_cm_node(cm_core, cm_node);
41267 - atomic_inc(&cm_accel_dropped_pkts);
41268 + atomic_inc_unchecked(&cm_accel_dropped_pkts);
41269 dev_kfree_skb_any(skb);
41270 }
41271 break;
41272 @@ -2875,7 +2875,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41273
41274 if ((cm_id) && (cm_id->event_handler)) {
41275 if (issue_disconn) {
41276 - atomic_inc(&cm_disconnects);
41277 + atomic_inc_unchecked(&cm_disconnects);
41278 cm_event.event = IW_CM_EVENT_DISCONNECT;
41279 cm_event.status = disconn_status;
41280 cm_event.local_addr = cm_id->local_addr;
41281 @@ -2897,7 +2897,7 @@ static int nes_cm_disconn_true(struct nes_qp *nesqp)
41282 }
41283
41284 if (issue_close) {
41285 - atomic_inc(&cm_closes);
41286 + atomic_inc_unchecked(&cm_closes);
41287 nes_disconnect(nesqp, 1);
41288
41289 cm_id->provider_data = nesqp;
41290 @@ -3035,7 +3035,7 @@ int nes_accept(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41291
41292 nes_debug(NES_DBG_CM, "QP%u, cm_node=%p, jiffies = %lu listener = %p\n",
41293 nesqp->hwqp.qp_id, cm_node, jiffies, cm_node->listener);
41294 - atomic_inc(&cm_accepts);
41295 + atomic_inc_unchecked(&cm_accepts);
41296
41297 nes_debug(NES_DBG_CM, "netdev refcnt = %u.\n",
41298 netdev_refcnt_read(nesvnic->netdev));
41299 @@ -3224,7 +3224,7 @@ int nes_reject(struct iw_cm_id *cm_id, const void *pdata, u8 pdata_len)
41300 struct nes_cm_core *cm_core;
41301 u8 *start_buff;
41302
41303 - atomic_inc(&cm_rejects);
41304 + atomic_inc_unchecked(&cm_rejects);
41305 cm_node = (struct nes_cm_node *)cm_id->provider_data;
41306 loopback = cm_node->loopbackpartner;
41307 cm_core = cm_node->cm_core;
41308 @@ -3286,7 +3286,7 @@ int nes_connect(struct iw_cm_id *cm_id, struct iw_cm_conn_param *conn_param)
41309 ntohs(raddr->sin_port), ntohl(laddr->sin_addr.s_addr),
41310 ntohs(laddr->sin_port));
41311
41312 - atomic_inc(&cm_connects);
41313 + atomic_inc_unchecked(&cm_connects);
41314 nesqp->active_conn = 1;
41315
41316 /* cache the cm_id in the qp */
41317 @@ -3398,7 +3398,7 @@ int nes_create_listen(struct iw_cm_id *cm_id, int backlog)
41318 g_cm_core->api->stop_listener(g_cm_core, (void *)cm_node);
41319 return err;
41320 }
41321 - atomic_inc(&cm_listens_created);
41322 + atomic_inc_unchecked(&cm_listens_created);
41323 }
41324
41325 cm_id->add_ref(cm_id);
41326 @@ -3505,7 +3505,7 @@ static void cm_event_connected(struct nes_cm_event *event)
41327
41328 if (nesqp->destroyed)
41329 return;
41330 - atomic_inc(&cm_connecteds);
41331 + atomic_inc_unchecked(&cm_connecteds);
41332 nes_debug(NES_DBG_CM, "QP%u attempting to connect to 0x%08X:0x%04X on"
41333 " local port 0x%04X. jiffies = %lu.\n",
41334 nesqp->hwqp.qp_id, ntohl(raddr->sin_addr.s_addr),
41335 @@ -3686,7 +3686,7 @@ static void cm_event_reset(struct nes_cm_event *event)
41336
41337 cm_id->add_ref(cm_id);
41338 ret = cm_id->event_handler(cm_id, &cm_event);
41339 - atomic_inc(&cm_closes);
41340 + atomic_inc_unchecked(&cm_closes);
41341 cm_event.event = IW_CM_EVENT_CLOSE;
41342 cm_event.status = 0;
41343 cm_event.provider_data = cm_id->provider_data;
41344 @@ -3726,7 +3726,7 @@ static void cm_event_mpa_req(struct nes_cm_event *event)
41345 return;
41346 cm_id = cm_node->cm_id;
41347
41348 - atomic_inc(&cm_connect_reqs);
41349 + atomic_inc_unchecked(&cm_connect_reqs);
41350 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41351 cm_node, cm_id, jiffies);
41352
41353 @@ -3770,7 +3770,7 @@ static void cm_event_mpa_reject(struct nes_cm_event *event)
41354 return;
41355 cm_id = cm_node->cm_id;
41356
41357 - atomic_inc(&cm_connect_reqs);
41358 + atomic_inc_unchecked(&cm_connect_reqs);
41359 nes_debug(NES_DBG_CM, "cm_node = %p - cm_id = %p, jiffies = %lu\n",
41360 cm_node, cm_id, jiffies);
41361
41362 diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c
41363 index 4166452..fc952c3 100644
41364 --- a/drivers/infiniband/hw/nes/nes_mgt.c
41365 +++ b/drivers/infiniband/hw/nes/nes_mgt.c
41366 @@ -40,8 +40,8 @@
41367 #include "nes.h"
41368 #include "nes_mgt.h"
41369
41370 -atomic_t pau_qps_created;
41371 -atomic_t pau_qps_destroyed;
41372 +atomic_unchecked_t pau_qps_created;
41373 +atomic_unchecked_t pau_qps_destroyed;
41374
41375 static void nes_replenish_mgt_rq(struct nes_vnic_mgt *mgtvnic)
41376 {
41377 @@ -621,7 +621,7 @@ void nes_destroy_pau_qp(struct nes_device *nesdev, struct nes_qp *nesqp)
41378 {
41379 struct sk_buff *skb;
41380 unsigned long flags;
41381 - atomic_inc(&pau_qps_destroyed);
41382 + atomic_inc_unchecked(&pau_qps_destroyed);
41383
41384 /* Free packets that have not yet been forwarded */
41385 /* Lock is acquired by skb_dequeue when removing the skb */
41386 @@ -810,7 +810,7 @@ static void nes_mgt_ce_handler(struct nes_device *nesdev, struct nes_hw_nic_cq *
41387 cq->cq_vbase[head].cqe_words[NES_NIC_CQE_HASH_RCVNXT]);
41388 skb_queue_head_init(&nesqp->pau_list);
41389 spin_lock_init(&nesqp->pau_lock);
41390 - atomic_inc(&pau_qps_created);
41391 + atomic_inc_unchecked(&pau_qps_created);
41392 nes_change_quad_hash(nesdev, mgtvnic->nesvnic, nesqp);
41393 }
41394
41395 diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c
41396 index 49eb511..a774366 100644
41397 --- a/drivers/infiniband/hw/nes/nes_nic.c
41398 +++ b/drivers/infiniband/hw/nes/nes_nic.c
41399 @@ -1273,39 +1273,39 @@ static void nes_netdev_get_ethtool_stats(struct net_device *netdev,
41400 target_stat_values[++index] = mh_detected;
41401 target_stat_values[++index] = mh_pauses_sent;
41402 target_stat_values[++index] = nesvnic->endnode_ipv4_tcp_retransmits;
41403 - target_stat_values[++index] = atomic_read(&cm_connects);
41404 - target_stat_values[++index] = atomic_read(&cm_accepts);
41405 - target_stat_values[++index] = atomic_read(&cm_disconnects);
41406 - target_stat_values[++index] = atomic_read(&cm_connecteds);
41407 - target_stat_values[++index] = atomic_read(&cm_connect_reqs);
41408 - target_stat_values[++index] = atomic_read(&cm_rejects);
41409 - target_stat_values[++index] = atomic_read(&mod_qp_timouts);
41410 - target_stat_values[++index] = atomic_read(&qps_created);
41411 - target_stat_values[++index] = atomic_read(&sw_qps_destroyed);
41412 - target_stat_values[++index] = atomic_read(&qps_destroyed);
41413 - target_stat_values[++index] = atomic_read(&cm_closes);
41414 + target_stat_values[++index] = atomic_read_unchecked(&cm_connects);
41415 + target_stat_values[++index] = atomic_read_unchecked(&cm_accepts);
41416 + target_stat_values[++index] = atomic_read_unchecked(&cm_disconnects);
41417 + target_stat_values[++index] = atomic_read_unchecked(&cm_connecteds);
41418 + target_stat_values[++index] = atomic_read_unchecked(&cm_connect_reqs);
41419 + target_stat_values[++index] = atomic_read_unchecked(&cm_rejects);
41420 + target_stat_values[++index] = atomic_read_unchecked(&mod_qp_timouts);
41421 + target_stat_values[++index] = atomic_read_unchecked(&qps_created);
41422 + target_stat_values[++index] = atomic_read_unchecked(&sw_qps_destroyed);
41423 + target_stat_values[++index] = atomic_read_unchecked(&qps_destroyed);
41424 + target_stat_values[++index] = atomic_read_unchecked(&cm_closes);
41425 target_stat_values[++index] = cm_packets_sent;
41426 target_stat_values[++index] = cm_packets_bounced;
41427 target_stat_values[++index] = cm_packets_created;
41428 target_stat_values[++index] = cm_packets_received;
41429 target_stat_values[++index] = cm_packets_dropped;
41430 target_stat_values[++index] = cm_packets_retrans;
41431 - target_stat_values[++index] = atomic_read(&cm_listens_created);
41432 - target_stat_values[++index] = atomic_read(&cm_listens_destroyed);
41433 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_created);
41434 + target_stat_values[++index] = atomic_read_unchecked(&cm_listens_destroyed);
41435 target_stat_values[++index] = cm_backlog_drops;
41436 - target_stat_values[++index] = atomic_read(&cm_loopbacks);
41437 - target_stat_values[++index] = atomic_read(&cm_nodes_created);
41438 - target_stat_values[++index] = atomic_read(&cm_nodes_destroyed);
41439 - target_stat_values[++index] = atomic_read(&cm_accel_dropped_pkts);
41440 - target_stat_values[++index] = atomic_read(&cm_resets_recvd);
41441 + target_stat_values[++index] = atomic_read_unchecked(&cm_loopbacks);
41442 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_created);
41443 + target_stat_values[++index] = atomic_read_unchecked(&cm_nodes_destroyed);
41444 + target_stat_values[++index] = atomic_read_unchecked(&cm_accel_dropped_pkts);
41445 + target_stat_values[++index] = atomic_read_unchecked(&cm_resets_recvd);
41446 target_stat_values[++index] = nesadapter->free_4kpbl;
41447 target_stat_values[++index] = nesadapter->free_256pbl;
41448 target_stat_values[++index] = int_mod_timer_init;
41449 target_stat_values[++index] = nesvnic->lro_mgr.stats.aggregated;
41450 target_stat_values[++index] = nesvnic->lro_mgr.stats.flushed;
41451 target_stat_values[++index] = nesvnic->lro_mgr.stats.no_desc;
41452 - target_stat_values[++index] = atomic_read(&pau_qps_created);
41453 - target_stat_values[++index] = atomic_read(&pau_qps_destroyed);
41454 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_created);
41455 + target_stat_values[++index] = atomic_read_unchecked(&pau_qps_destroyed);
41456 }
41457
41458 /**
41459 diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c
41460 index 5b53ca5..443da3c 100644
41461 --- a/drivers/infiniband/hw/nes/nes_verbs.c
41462 +++ b/drivers/infiniband/hw/nes/nes_verbs.c
41463 @@ -46,9 +46,9 @@
41464
41465 #include <rdma/ib_umem.h>
41466
41467 -atomic_t mod_qp_timouts;
41468 -atomic_t qps_created;
41469 -atomic_t sw_qps_destroyed;
41470 +atomic_unchecked_t mod_qp_timouts;
41471 +atomic_unchecked_t qps_created;
41472 +atomic_unchecked_t sw_qps_destroyed;
41473
41474 static void nes_unregister_ofa_device(struct nes_ib_device *nesibdev);
41475
41476 @@ -1134,7 +1134,7 @@ static struct ib_qp *nes_create_qp(struct ib_pd *ibpd,
41477 if (init_attr->create_flags)
41478 return ERR_PTR(-EINVAL);
41479
41480 - atomic_inc(&qps_created);
41481 + atomic_inc_unchecked(&qps_created);
41482 switch (init_attr->qp_type) {
41483 case IB_QPT_RC:
41484 if (nes_drv_opt & NES_DRV_OPT_NO_INLINE_DATA) {
41485 @@ -1466,7 +1466,7 @@ static int nes_destroy_qp(struct ib_qp *ibqp)
41486 struct iw_cm_event cm_event;
41487 int ret = 0;
41488
41489 - atomic_inc(&sw_qps_destroyed);
41490 + atomic_inc_unchecked(&sw_qps_destroyed);
41491 nesqp->destroyed = 1;
41492
41493 /* Blow away the connection if it exists. */
41494 diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h
41495 index 1946101..09766d2 100644
41496 --- a/drivers/infiniband/hw/qib/qib.h
41497 +++ b/drivers/infiniband/hw/qib/qib.h
41498 @@ -52,6 +52,7 @@
41499 #include <linux/kref.h>
41500 #include <linux/sched.h>
41501 #include <linux/kthread.h>
41502 +#include <linux/slab.h>
41503
41504 #include "qib_common.h"
41505 #include "qib_verbs.h"
41506 diff --git a/drivers/input/gameport/gameport.c b/drivers/input/gameport/gameport.c
41507 index 922a7fe..bb035db 100644
41508 --- a/drivers/input/gameport/gameport.c
41509 +++ b/drivers/input/gameport/gameport.c
41510 @@ -487,14 +487,14 @@ EXPORT_SYMBOL(gameport_set_phys);
41511 */
41512 static void gameport_init_port(struct gameport *gameport)
41513 {
41514 - static atomic_t gameport_no = ATOMIC_INIT(0);
41515 + static atomic_unchecked_t gameport_no = ATOMIC_INIT(0);
41516
41517 __module_get(THIS_MODULE);
41518
41519 mutex_init(&gameport->drv_mutex);
41520 device_initialize(&gameport->dev);
41521 dev_set_name(&gameport->dev, "gameport%lu",
41522 - (unsigned long)atomic_inc_return(&gameport_no) - 1);
41523 + (unsigned long)atomic_inc_return_unchecked(&gameport_no) - 1);
41524 gameport->dev.bus = &gameport_bus;
41525 gameport->dev.release = gameport_release_port;
41526 if (gameport->parent)
41527 diff --git a/drivers/input/input.c b/drivers/input/input.c
41528 index 74f4798..d9f7168 100644
41529 --- a/drivers/input/input.c
41530 +++ b/drivers/input/input.c
41531 @@ -1734,7 +1734,7 @@ EXPORT_SYMBOL_GPL(input_class);
41532 */
41533 struct input_dev *input_allocate_device(void)
41534 {
41535 - static atomic_t input_no = ATOMIC_INIT(0);
41536 + static atomic_unchecked_t input_no = ATOMIC_INIT(0);
41537 struct input_dev *dev;
41538
41539 dev = kzalloc(sizeof(struct input_dev), GFP_KERNEL);
41540 @@ -1749,7 +1749,7 @@ struct input_dev *input_allocate_device(void)
41541 INIT_LIST_HEAD(&dev->node);
41542
41543 dev_set_name(&dev->dev, "input%ld",
41544 - (unsigned long) atomic_inc_return(&input_no) - 1);
41545 + (unsigned long) atomic_inc_return_unchecked(&input_no) - 1);
41546
41547 __module_get(THIS_MODULE);
41548 }
41549 diff --git a/drivers/input/joystick/sidewinder.c b/drivers/input/joystick/sidewinder.c
41550 index 04c69af..5f92d00 100644
41551 --- a/drivers/input/joystick/sidewinder.c
41552 +++ b/drivers/input/joystick/sidewinder.c
41553 @@ -30,6 +30,7 @@
41554 #include <linux/kernel.h>
41555 #include <linux/module.h>
41556 #include <linux/slab.h>
41557 +#include <linux/sched.h>
41558 #include <linux/init.h>
41559 #include <linux/input.h>
41560 #include <linux/gameport.h>
41561 diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
41562 index 75e3b10..fb390fd 100644
41563 --- a/drivers/input/joystick/xpad.c
41564 +++ b/drivers/input/joystick/xpad.c
41565 @@ -736,7 +736,7 @@ static void xpad_led_set(struct led_classdev *led_cdev,
41566
41567 static int xpad_led_probe(struct usb_xpad *xpad)
41568 {
41569 - static atomic_t led_seq = ATOMIC_INIT(0);
41570 + static atomic_unchecked_t led_seq = ATOMIC_INIT(0);
41571 long led_no;
41572 struct xpad_led *led;
41573 struct led_classdev *led_cdev;
41574 @@ -749,7 +749,7 @@ static int xpad_led_probe(struct usb_xpad *xpad)
41575 if (!led)
41576 return -ENOMEM;
41577
41578 - led_no = (long)atomic_inc_return(&led_seq) - 1;
41579 + led_no = (long)atomic_inc_return_unchecked(&led_seq) - 1;
41580
41581 snprintf(led->name, sizeof(led->name), "xpad%ld", led_no);
41582 led->xpad = xpad;
41583 diff --git a/drivers/input/misc/ims-pcu.c b/drivers/input/misc/ims-pcu.c
41584 index e204f26..8459f15 100644
41585 --- a/drivers/input/misc/ims-pcu.c
41586 +++ b/drivers/input/misc/ims-pcu.c
41587 @@ -1621,7 +1621,7 @@ static int ims_pcu_identify_type(struct ims_pcu *pcu, u8 *device_id)
41588
41589 static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41590 {
41591 - static atomic_t device_no = ATOMIC_INIT(0);
41592 + static atomic_unchecked_t device_no = ATOMIC_INIT(0);
41593
41594 const struct ims_pcu_device_info *info;
41595 u8 device_id;
41596 @@ -1653,7 +1653,7 @@ static int ims_pcu_init_application_mode(struct ims_pcu *pcu)
41597 }
41598
41599 /* Device appears to be operable, complete initialization */
41600 - pcu->device_no = atomic_inc_return(&device_no) - 1;
41601 + pcu->device_no = atomic_inc_return_unchecked(&device_no) - 1;
41602
41603 error = ims_pcu_setup_backlight(pcu);
41604 if (error)
41605 diff --git a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
41606 index 2f0b39d..7370f13 100644
41607 --- a/drivers/input/mouse/psmouse.h
41608 +++ b/drivers/input/mouse/psmouse.h
41609 @@ -116,7 +116,7 @@ struct psmouse_attribute {
41610 ssize_t (*set)(struct psmouse *psmouse, void *data,
41611 const char *buf, size_t count);
41612 bool protect;
41613 -};
41614 +} __do_const;
41615 #define to_psmouse_attr(a) container_of((a), struct psmouse_attribute, dattr)
41616
41617 ssize_t psmouse_attr_show_helper(struct device *dev, struct device_attribute *attr,
41618 diff --git a/drivers/input/mousedev.c b/drivers/input/mousedev.c
41619 index 4c842c3..590b0bf 100644
41620 --- a/drivers/input/mousedev.c
41621 +++ b/drivers/input/mousedev.c
41622 @@ -738,7 +738,7 @@ static ssize_t mousedev_read(struct file *file, char __user *buffer,
41623
41624 spin_unlock_irq(&client->packet_lock);
41625
41626 - if (copy_to_user(buffer, data, count))
41627 + if (count > sizeof(data) || copy_to_user(buffer, data, count))
41628 return -EFAULT;
41629
41630 return count;
41631 diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
41632 index 2b56855..5a55837 100644
41633 --- a/drivers/input/serio/serio.c
41634 +++ b/drivers/input/serio/serio.c
41635 @@ -496,7 +496,7 @@ static void serio_release_port(struct device *dev)
41636 */
41637 static void serio_init_port(struct serio *serio)
41638 {
41639 - static atomic_t serio_no = ATOMIC_INIT(0);
41640 + static atomic_unchecked_t serio_no = ATOMIC_INIT(0);
41641
41642 __module_get(THIS_MODULE);
41643
41644 @@ -507,7 +507,7 @@ static void serio_init_port(struct serio *serio)
41645 mutex_init(&serio->drv_mutex);
41646 device_initialize(&serio->dev);
41647 dev_set_name(&serio->dev, "serio%ld",
41648 - (long)atomic_inc_return(&serio_no) - 1);
41649 + (long)atomic_inc_return_unchecked(&serio_no) - 1);
41650 serio->dev.bus = &serio_bus;
41651 serio->dev.release = serio_release_port;
41652 serio->dev.groups = serio_device_attr_groups;
41653 diff --git a/drivers/input/serio/serio_raw.c b/drivers/input/serio/serio_raw.c
41654 index 59df2e7..8f1cafb 100644
41655 --- a/drivers/input/serio/serio_raw.c
41656 +++ b/drivers/input/serio/serio_raw.c
41657 @@ -293,7 +293,7 @@ static irqreturn_t serio_raw_interrupt(struct serio *serio, unsigned char data,
41658
41659 static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41660 {
41661 - static atomic_t serio_raw_no = ATOMIC_INIT(0);
41662 + static atomic_unchecked_t serio_raw_no = ATOMIC_INIT(0);
41663 struct serio_raw *serio_raw;
41664 int err;
41665
41666 @@ -304,7 +304,7 @@ static int serio_raw_connect(struct serio *serio, struct serio_driver *drv)
41667 }
41668
41669 snprintf(serio_raw->name, sizeof(serio_raw->name),
41670 - "serio_raw%ld", (long)atomic_inc_return(&serio_raw_no) - 1);
41671 + "serio_raw%ld", (long)atomic_inc_return_unchecked(&serio_raw_no) - 1);
41672 kref_init(&serio_raw->kref);
41673 INIT_LIST_HEAD(&serio_raw->client_list);
41674 init_waitqueue_head(&serio_raw->wait);
41675 diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
41676 index fbe9ca7..dbee61d 100644
41677 --- a/drivers/iommu/iommu.c
41678 +++ b/drivers/iommu/iommu.c
41679 @@ -583,7 +583,7 @@ static struct notifier_block iommu_bus_nb = {
41680 static void iommu_bus_init(struct bus_type *bus, struct iommu_ops *ops)
41681 {
41682 bus_register_notifier(bus, &iommu_bus_nb);
41683 - bus_for_each_dev(bus, NULL, ops, add_iommu_group);
41684 + bus_for_each_dev(bus, NULL, (void *)ops, add_iommu_group);
41685 }
41686
41687 /**
41688 diff --git a/drivers/iommu/irq_remapping.c b/drivers/iommu/irq_remapping.c
41689 index 39f81ae..2660096 100644
41690 --- a/drivers/iommu/irq_remapping.c
41691 +++ b/drivers/iommu/irq_remapping.c
41692 @@ -356,7 +356,7 @@ int setup_hpet_msi_remapped(unsigned int irq, unsigned int id)
41693 void panic_if_irq_remap(const char *msg)
41694 {
41695 if (irq_remapping_enabled)
41696 - panic(msg);
41697 + panic("%s", msg);
41698 }
41699
41700 static void ir_ack_apic_edge(struct irq_data *data)
41701 @@ -377,10 +377,12 @@ static void ir_print_prefix(struct irq_data *data, struct seq_file *p)
41702
41703 void irq_remap_modify_chip_defaults(struct irq_chip *chip)
41704 {
41705 - chip->irq_print_chip = ir_print_prefix;
41706 - chip->irq_ack = ir_ack_apic_edge;
41707 - chip->irq_eoi = ir_ack_apic_level;
41708 - chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41709 + pax_open_kernel();
41710 + *(void **)&chip->irq_print_chip = ir_print_prefix;
41711 + *(void **)&chip->irq_ack = ir_ack_apic_edge;
41712 + *(void **)&chip->irq_eoi = ir_ack_apic_level;
41713 + *(void **)&chip->irq_set_affinity = x86_io_apic_ops.set_affinity;
41714 + pax_close_kernel();
41715 }
41716
41717 bool setup_remapped_irq(int irq, struct irq_cfg *cfg, struct irq_chip *chip)
41718 diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c
41719 index d0e9480..d2b6340 100644
41720 --- a/drivers/irqchip/irq-gic.c
41721 +++ b/drivers/irqchip/irq-gic.c
41722 @@ -84,7 +84,7 @@ static u8 gic_cpu_map[NR_GIC_CPU_IF] __read_mostly;
41723 * Supported arch specific GIC irq extension.
41724 * Default make them NULL.
41725 */
41726 -struct irq_chip gic_arch_extn = {
41727 +irq_chip_no_const gic_arch_extn = {
41728 .irq_eoi = NULL,
41729 .irq_mask = NULL,
41730 .irq_unmask = NULL,
41731 @@ -333,7 +333,7 @@ static void gic_handle_cascade_irq(unsigned int irq, struct irq_desc *desc)
41732 chained_irq_exit(chip, desc);
41733 }
41734
41735 -static struct irq_chip gic_chip = {
41736 +static irq_chip_no_const gic_chip __read_only = {
41737 .name = "GIC",
41738 .irq_mask = gic_mask_irq,
41739 .irq_unmask = gic_unmask_irq,
41740 diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c
41741 index ac6f72b..81150f2 100644
41742 --- a/drivers/isdn/capi/capi.c
41743 +++ b/drivers/isdn/capi/capi.c
41744 @@ -81,8 +81,8 @@ struct capiminor {
41745
41746 struct capi20_appl *ap;
41747 u32 ncci;
41748 - atomic_t datahandle;
41749 - atomic_t msgid;
41750 + atomic_unchecked_t datahandle;
41751 + atomic_unchecked_t msgid;
41752
41753 struct tty_port port;
41754 int ttyinstop;
41755 @@ -391,7 +391,7 @@ gen_data_b3_resp_for(struct capiminor *mp, struct sk_buff *skb)
41756 capimsg_setu16(s, 2, mp->ap->applid);
41757 capimsg_setu8 (s, 4, CAPI_DATA_B3);
41758 capimsg_setu8 (s, 5, CAPI_RESP);
41759 - capimsg_setu16(s, 6, atomic_inc_return(&mp->msgid));
41760 + capimsg_setu16(s, 6, atomic_inc_return_unchecked(&mp->msgid));
41761 capimsg_setu32(s, 8, mp->ncci);
41762 capimsg_setu16(s, 12, datahandle);
41763 }
41764 @@ -512,14 +512,14 @@ static void handle_minor_send(struct capiminor *mp)
41765 mp->outbytes -= len;
41766 spin_unlock_bh(&mp->outlock);
41767
41768 - datahandle = atomic_inc_return(&mp->datahandle);
41769 + datahandle = atomic_inc_return_unchecked(&mp->datahandle);
41770 skb_push(skb, CAPI_DATA_B3_REQ_LEN);
41771 memset(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41772 capimsg_setu16(skb->data, 0, CAPI_DATA_B3_REQ_LEN);
41773 capimsg_setu16(skb->data, 2, mp->ap->applid);
41774 capimsg_setu8 (skb->data, 4, CAPI_DATA_B3);
41775 capimsg_setu8 (skb->data, 5, CAPI_REQ);
41776 - capimsg_setu16(skb->data, 6, atomic_inc_return(&mp->msgid));
41777 + capimsg_setu16(skb->data, 6, atomic_inc_return_unchecked(&mp->msgid));
41778 capimsg_setu32(skb->data, 8, mp->ncci); /* NCCI */
41779 capimsg_setu32(skb->data, 12, (u32)(long)skb->data);/* Data32 */
41780 capimsg_setu16(skb->data, 16, len); /* Data length */
41781 diff --git a/drivers/isdn/gigaset/interface.c b/drivers/isdn/gigaset/interface.c
41782 index 600c79b..3752bab 100644
41783 --- a/drivers/isdn/gigaset/interface.c
41784 +++ b/drivers/isdn/gigaset/interface.c
41785 @@ -130,9 +130,9 @@ static int if_open(struct tty_struct *tty, struct file *filp)
41786 }
41787 tty->driver_data = cs;
41788
41789 - ++cs->port.count;
41790 + atomic_inc(&cs->port.count);
41791
41792 - if (cs->port.count == 1) {
41793 + if (atomic_read(&cs->port.count) == 1) {
41794 tty_port_tty_set(&cs->port, tty);
41795 cs->port.low_latency = 1;
41796 }
41797 @@ -156,9 +156,9 @@ static void if_close(struct tty_struct *tty, struct file *filp)
41798
41799 if (!cs->connected)
41800 gig_dbg(DEBUG_IF, "not connected"); /* nothing to do */
41801 - else if (!cs->port.count)
41802 + else if (!atomic_read(&cs->port.count))
41803 dev_warn(cs->dev, "%s: device not opened\n", __func__);
41804 - else if (!--cs->port.count)
41805 + else if (!atomic_dec_return(&cs->port.count))
41806 tty_port_tty_set(&cs->port, NULL);
41807
41808 mutex_unlock(&cs->mutex);
41809 diff --git a/drivers/isdn/gigaset/usb-gigaset.c b/drivers/isdn/gigaset/usb-gigaset.c
41810 index d0a41cb..f0cdb8c 100644
41811 --- a/drivers/isdn/gigaset/usb-gigaset.c
41812 +++ b/drivers/isdn/gigaset/usb-gigaset.c
41813 @@ -547,7 +547,7 @@ static int gigaset_brkchars(struct cardstate *cs, const unsigned char buf[6])
41814 gigaset_dbg_buffer(DEBUG_USBREQ, "brkchars", 6, buf);
41815 memcpy(cs->hw.usb->bchars, buf, 6);
41816 return usb_control_msg(udev, usb_sndctrlpipe(udev, 0), 0x19, 0x41,
41817 - 0, 0, &buf, 6, 2000);
41818 + 0, 0, buf, 6, 2000);
41819 }
41820
41821 static void gigaset_freebcshw(struct bc_state *bcs)
41822 diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c
41823 index 4d9b195..455075c 100644
41824 --- a/drivers/isdn/hardware/avm/b1.c
41825 +++ b/drivers/isdn/hardware/avm/b1.c
41826 @@ -176,7 +176,7 @@ int b1_load_t4file(avmcard *card, capiloaddatapart *t4file)
41827 }
41828 if (left) {
41829 if (t4file->user) {
41830 - if (copy_from_user(buf, dp, left))
41831 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41832 return -EFAULT;
41833 } else {
41834 memcpy(buf, dp, left);
41835 @@ -224,7 +224,7 @@ int b1_load_config(avmcard *card, capiloaddatapart *config)
41836 }
41837 if (left) {
41838 if (config->user) {
41839 - if (copy_from_user(buf, dp, left))
41840 + if (left > sizeof buf || copy_from_user(buf, dp, left))
41841 return -EFAULT;
41842 } else {
41843 memcpy(buf, dp, left);
41844 diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c
41845 index 9bb12ba..d4262f7 100644
41846 --- a/drivers/isdn/i4l/isdn_common.c
41847 +++ b/drivers/isdn/i4l/isdn_common.c
41848 @@ -1651,6 +1651,8 @@ isdn_ioctl(struct file *file, uint cmd, ulong arg)
41849 } else
41850 return -EINVAL;
41851 case IIOCDBGVAR:
41852 + if (!capable(CAP_SYS_RAWIO))
41853 + return -EPERM;
41854 if (arg) {
41855 if (copy_to_user(argp, &dev, sizeof(ulong)))
41856 return -EFAULT;
41857 diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c
41858 index 3c5f249..5fac4d0 100644
41859 --- a/drivers/isdn/i4l/isdn_tty.c
41860 +++ b/drivers/isdn/i4l/isdn_tty.c
41861 @@ -1508,9 +1508,9 @@ isdn_tty_open(struct tty_struct *tty, struct file *filp)
41862
41863 #ifdef ISDN_DEBUG_MODEM_OPEN
41864 printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name,
41865 - port->count);
41866 + atomic_read(&port->count));
41867 #endif
41868 - port->count++;
41869 + atomic_inc(&port->count);
41870 port->tty = tty;
41871 /*
41872 * Start up serial port
41873 @@ -1554,7 +1554,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41874 #endif
41875 return;
41876 }
41877 - if ((tty->count == 1) && (port->count != 1)) {
41878 + if ((tty->count == 1) && (atomic_read(&port->count) != 1)) {
41879 /*
41880 * Uh, oh. tty->count is 1, which means that the tty
41881 * structure will be freed. Info->count should always
41882 @@ -1563,15 +1563,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp)
41883 * serial port won't be shutdown.
41884 */
41885 printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, "
41886 - "info->count is %d\n", port->count);
41887 - port->count = 1;
41888 + "info->count is %d\n", atomic_read(&port->count));
41889 + atomic_set(&port->count, 1);
41890 }
41891 - if (--port->count < 0) {
41892 + if (atomic_dec_return(&port->count) < 0) {
41893 printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n",
41894 - info->line, port->count);
41895 - port->count = 0;
41896 + info->line, atomic_read(&port->count));
41897 + atomic_set(&port->count, 0);
41898 }
41899 - if (port->count) {
41900 + if (atomic_read(&port->count)) {
41901 #ifdef ISDN_DEBUG_MODEM_OPEN
41902 printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n");
41903 #endif
41904 @@ -1625,7 +1625,7 @@ isdn_tty_hangup(struct tty_struct *tty)
41905 if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup"))
41906 return;
41907 isdn_tty_shutdown(info);
41908 - port->count = 0;
41909 + atomic_set(&port->count, 0);
41910 port->flags &= ~ASYNC_NORMAL_ACTIVE;
41911 port->tty = NULL;
41912 wake_up_interruptible(&port->open_wait);
41913 @@ -1970,7 +1970,7 @@ isdn_tty_find_icall(int di, int ch, setup_parm *setup)
41914 for (i = 0; i < ISDN_MAX_CHANNELS; i++) {
41915 modem_info *info = &dev->mdm.info[i];
41916
41917 - if (info->port.count == 0)
41918 + if (atomic_read(&info->port.count) == 0)
41919 continue;
41920 if ((info->emu.mdmreg[REG_SI1] & si2bit[si1]) && /* SI1 is matching */
41921 (info->emu.mdmreg[REG_SI2] == si2)) { /* SI2 is matching */
41922 diff --git a/drivers/isdn/icn/icn.c b/drivers/isdn/icn/icn.c
41923 index e74df7c..03a03ba 100644
41924 --- a/drivers/isdn/icn/icn.c
41925 +++ b/drivers/isdn/icn/icn.c
41926 @@ -1045,7 +1045,7 @@ icn_writecmd(const u_char *buf, int len, int user, icn_card *card)
41927 if (count > len)
41928 count = len;
41929 if (user) {
41930 - if (copy_from_user(msg, buf, count))
41931 + if (count > sizeof msg || copy_from_user(msg, buf, count))
41932 return -EFAULT;
41933 } else
41934 memcpy(msg, buf, count);
41935 diff --git a/drivers/isdn/mISDN/dsp_cmx.c b/drivers/isdn/mISDN/dsp_cmx.c
41936 index a4f05c5..1433bc5 100644
41937 --- a/drivers/isdn/mISDN/dsp_cmx.c
41938 +++ b/drivers/isdn/mISDN/dsp_cmx.c
41939 @@ -1628,7 +1628,7 @@ unsigned long dsp_spl_jiffies; /* calculate the next time to fire */
41940 static u16 dsp_count; /* last sample count */
41941 static int dsp_count_valid; /* if we have last sample count */
41942
41943 -void
41944 +void __intentional_overflow(-1)
41945 dsp_cmx_send(void *arg)
41946 {
41947 struct dsp_conf *conf;
41948 diff --git a/drivers/leds/leds-clevo-mail.c b/drivers/leds/leds-clevo-mail.c
41949 index d93e245..e7ece6b 100644
41950 --- a/drivers/leds/leds-clevo-mail.c
41951 +++ b/drivers/leds/leds-clevo-mail.c
41952 @@ -40,7 +40,7 @@ static int __init clevo_mail_led_dmi_callback(const struct dmi_system_id *id)
41953 * detected as working, but in reality it is not) as low as
41954 * possible.
41955 */
41956 -static struct dmi_system_id clevo_mail_led_dmi_table[] __initdata = {
41957 +static struct dmi_system_id clevo_mail_led_dmi_table[] __initconst = {
41958 {
41959 .callback = clevo_mail_led_dmi_callback,
41960 .ident = "Clevo D410J",
41961 diff --git a/drivers/leds/leds-ss4200.c b/drivers/leds/leds-ss4200.c
41962 index 5b8f938..b73d657 100644
41963 --- a/drivers/leds/leds-ss4200.c
41964 +++ b/drivers/leds/leds-ss4200.c
41965 @@ -91,7 +91,7 @@ MODULE_PARM_DESC(nodetect, "Skip DMI-based hardware detection");
41966 * detected as working, but in reality it is not) as low as
41967 * possible.
41968 */
41969 -static struct dmi_system_id nas_led_whitelist[] __initdata = {
41970 +static struct dmi_system_id nas_led_whitelist[] __initconst = {
41971 {
41972 .callback = ss4200_led_dmi_callback,
41973 .ident = "Intel SS4200-E",
41974 diff --git a/drivers/lguest/core.c b/drivers/lguest/core.c
41975 index 0bf1e4e..b4bf44e 100644
41976 --- a/drivers/lguest/core.c
41977 +++ b/drivers/lguest/core.c
41978 @@ -97,9 +97,17 @@ static __init int map_switcher(void)
41979 * The end address needs +1 because __get_vm_area allocates an
41980 * extra guard page, so we need space for that.
41981 */
41982 +
41983 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
41984 + switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41985 + VM_ALLOC | VM_KERNEXEC, switcher_addr, switcher_addr
41986 + + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41987 +#else
41988 switcher_vma = __get_vm_area(TOTAL_SWITCHER_PAGES * PAGE_SIZE,
41989 VM_ALLOC, switcher_addr, switcher_addr
41990 + (TOTAL_SWITCHER_PAGES+1) * PAGE_SIZE);
41991 +#endif
41992 +
41993 if (!switcher_vma) {
41994 err = -ENOMEM;
41995 printk("lguest: could not map switcher pages high\n");
41996 @@ -124,7 +132,7 @@ static __init int map_switcher(void)
41997 * Now the Switcher is mapped at the right address, we can't fail!
41998 * Copy in the compiled-in Switcher code (from x86/switcher_32.S).
41999 */
42000 - memcpy(switcher_vma->addr, start_switcher_text,
42001 + memcpy(switcher_vma->addr, ktla_ktva(start_switcher_text),
42002 end_switcher_text - start_switcher_text);
42003
42004 printk(KERN_INFO "lguest: mapped switcher at %p\n",
42005 diff --git a/drivers/lguest/page_tables.c b/drivers/lguest/page_tables.c
42006 index bfb39bb..08a603b 100644
42007 --- a/drivers/lguest/page_tables.c
42008 +++ b/drivers/lguest/page_tables.c
42009 @@ -559,7 +559,7 @@ void pin_page(struct lg_cpu *cpu, unsigned long vaddr)
42010 /*:*/
42011
42012 #ifdef CONFIG_X86_PAE
42013 -static void release_pmd(pmd_t *spmd)
42014 +static void __intentional_overflow(-1) release_pmd(pmd_t *spmd)
42015 {
42016 /* If the entry's not present, there's nothing to release. */
42017 if (pmd_flags(*spmd) & _PAGE_PRESENT) {
42018 diff --git a/drivers/lguest/x86/core.c b/drivers/lguest/x86/core.c
42019 index 5169239..47cb4db 100644
42020 --- a/drivers/lguest/x86/core.c
42021 +++ b/drivers/lguest/x86/core.c
42022 @@ -59,7 +59,7 @@ static struct {
42023 /* Offset from where switcher.S was compiled to where we've copied it */
42024 static unsigned long switcher_offset(void)
42025 {
42026 - return switcher_addr - (unsigned long)start_switcher_text;
42027 + return switcher_addr - (unsigned long)ktla_ktva(start_switcher_text);
42028 }
42029
42030 /* This cpu's struct lguest_pages (after the Switcher text page) */
42031 @@ -99,7 +99,13 @@ static void copy_in_guest_info(struct lg_cpu *cpu, struct lguest_pages *pages)
42032 * These copies are pretty cheap, so we do them unconditionally: */
42033 /* Save the current Host top-level page directory.
42034 */
42035 +
42036 +#ifdef CONFIG_PAX_PER_CPU_PGD
42037 + pages->state.host_cr3 = read_cr3();
42038 +#else
42039 pages->state.host_cr3 = __pa(current->mm->pgd);
42040 +#endif
42041 +
42042 /*
42043 * Set up the Guest's page tables to see this CPU's pages (and no
42044 * other CPU's pages).
42045 @@ -475,7 +481,7 @@ void __init lguest_arch_host_init(void)
42046 * compiled-in switcher code and the high-mapped copy we just made.
42047 */
42048 for (i = 0; i < IDT_ENTRIES; i++)
42049 - default_idt_entries[i] += switcher_offset();
42050 + default_idt_entries[i] = ktla_ktva(default_idt_entries[i]) + switcher_offset();
42051
42052 /*
42053 * Set up the Switcher's per-cpu areas.
42054 @@ -558,7 +564,7 @@ void __init lguest_arch_host_init(void)
42055 * it will be undisturbed when we switch. To change %cs and jump we
42056 * need this structure to feed to Intel's "lcall" instruction.
42057 */
42058 - lguest_entry.offset = (long)switch_to_guest + switcher_offset();
42059 + lguest_entry.offset = (long)ktla_ktva(switch_to_guest) + switcher_offset();
42060 lguest_entry.segment = LGUEST_CS;
42061
42062 /*
42063 diff --git a/drivers/lguest/x86/switcher_32.S b/drivers/lguest/x86/switcher_32.S
42064 index 40634b0..4f5855e 100644
42065 --- a/drivers/lguest/x86/switcher_32.S
42066 +++ b/drivers/lguest/x86/switcher_32.S
42067 @@ -87,6 +87,7 @@
42068 #include <asm/page.h>
42069 #include <asm/segment.h>
42070 #include <asm/lguest.h>
42071 +#include <asm/processor-flags.h>
42072
42073 // We mark the start of the code to copy
42074 // It's placed in .text tho it's never run here
42075 @@ -149,6 +150,13 @@ ENTRY(switch_to_guest)
42076 // Changes type when we load it: damn Intel!
42077 // For after we switch over our page tables
42078 // That entry will be read-only: we'd crash.
42079 +
42080 +#ifdef CONFIG_PAX_KERNEXEC
42081 + mov %cr0, %edx
42082 + xor $X86_CR0_WP, %edx
42083 + mov %edx, %cr0
42084 +#endif
42085 +
42086 movl $(GDT_ENTRY_TSS*8), %edx
42087 ltr %dx
42088
42089 @@ -157,9 +165,15 @@ ENTRY(switch_to_guest)
42090 // Let's clear it again for our return.
42091 // The GDT descriptor of the Host
42092 // Points to the table after two "size" bytes
42093 - movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %edx
42094 + movl (LGUEST_PAGES_host_gdt_desc+2)(%eax), %eax
42095 // Clear "used" from type field (byte 5, bit 2)
42096 - andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%edx)
42097 + andb $0xFD, (GDT_ENTRY_TSS*8 + 5)(%eax)
42098 +
42099 +#ifdef CONFIG_PAX_KERNEXEC
42100 + mov %cr0, %eax
42101 + xor $X86_CR0_WP, %eax
42102 + mov %eax, %cr0
42103 +#endif
42104
42105 // Once our page table's switched, the Guest is live!
42106 // The Host fades as we run this final step.
42107 @@ -295,13 +309,12 @@ deliver_to_host:
42108 // I consulted gcc, and it gave
42109 // These instructions, which I gladly credit:
42110 leal (%edx,%ebx,8), %eax
42111 - movzwl (%eax),%edx
42112 - movl 4(%eax), %eax
42113 - xorw %ax, %ax
42114 - orl %eax, %edx
42115 + movl 4(%eax), %edx
42116 + movw (%eax), %dx
42117 // Now the address of the handler's in %edx
42118 // We call it now: its "iret" drops us home.
42119 - jmp *%edx
42120 + ljmp $__KERNEL_CS, $1f
42121 +1: jmp *%edx
42122
42123 // Every interrupt can come to us here
42124 // But we must truly tell each apart.
42125 diff --git a/drivers/md/bcache/closure.h b/drivers/md/bcache/closure.h
42126 index 0003992..854bbce 100644
42127 --- a/drivers/md/bcache/closure.h
42128 +++ b/drivers/md/bcache/closure.h
42129 @@ -622,7 +622,7 @@ static inline void closure_wake_up(struct closure_waitlist *list)
42130 static inline void set_closure_fn(struct closure *cl, closure_fn *fn,
42131 struct workqueue_struct *wq)
42132 {
42133 - BUG_ON(object_is_on_stack(cl));
42134 + BUG_ON(object_starts_on_stack(cl));
42135 closure_set_ip(cl);
42136 cl->fn = fn;
42137 cl->wq = wq;
42138 diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
42139 index 547c4c5..5be1de4 100644
42140 --- a/drivers/md/bcache/super.c
42141 +++ b/drivers/md/bcache/super.c
42142 @@ -1644,7 +1644,7 @@ err_unlock_gc:
42143 err:
42144 closure_sync(&op.cl);
42145 /* XXX: test this, it's broken */
42146 - bch_cache_set_error(c, err);
42147 + bch_cache_set_error(c, "%s", err);
42148 }
42149
42150 static bool can_attach_cache(struct cache *ca, struct cache_set *c)
42151 diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
42152 index a7fd821..9dcf6c3 100644
42153 --- a/drivers/md/bitmap.c
42154 +++ b/drivers/md/bitmap.c
42155 @@ -1779,7 +1779,7 @@ void bitmap_status(struct seq_file *seq, struct bitmap *bitmap)
42156 chunk_kb ? "KB" : "B");
42157 if (bitmap->storage.file) {
42158 seq_printf(seq, ", file: ");
42159 - seq_path(seq, &bitmap->storage.file->f_path, " \t\n");
42160 + seq_path(seq, &bitmap->storage.file->f_path, " \t\n\\");
42161 }
42162
42163 seq_printf(seq, "\n");
42164 diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c
42165 index afe0814..8cf3794 100644
42166 --- a/drivers/md/dm-ioctl.c
42167 +++ b/drivers/md/dm-ioctl.c
42168 @@ -1745,7 +1745,7 @@ static int validate_params(uint cmd, struct dm_ioctl *param)
42169 cmd == DM_LIST_VERSIONS_CMD)
42170 return 0;
42171
42172 - if ((cmd == DM_DEV_CREATE_CMD)) {
42173 + if (cmd == DM_DEV_CREATE_CMD) {
42174 if (!*param->name) {
42175 DMWARN("name not supplied when creating device");
42176 return -EINVAL;
42177 diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c
42178 index 9584443..9fc9ac9 100644
42179 --- a/drivers/md/dm-raid1.c
42180 +++ b/drivers/md/dm-raid1.c
42181 @@ -40,7 +40,7 @@ enum dm_raid1_error {
42182
42183 struct mirror {
42184 struct mirror_set *ms;
42185 - atomic_t error_count;
42186 + atomic_unchecked_t error_count;
42187 unsigned long error_type;
42188 struct dm_dev *dev;
42189 sector_t offset;
42190 @@ -186,7 +186,7 @@ static struct mirror *get_valid_mirror(struct mirror_set *ms)
42191 struct mirror *m;
42192
42193 for (m = ms->mirror; m < ms->mirror + ms->nr_mirrors; m++)
42194 - if (!atomic_read(&m->error_count))
42195 + if (!atomic_read_unchecked(&m->error_count))
42196 return m;
42197
42198 return NULL;
42199 @@ -218,7 +218,7 @@ static void fail_mirror(struct mirror *m, enum dm_raid1_error error_type)
42200 * simple way to tell if a device has encountered
42201 * errors.
42202 */
42203 - atomic_inc(&m->error_count);
42204 + atomic_inc_unchecked(&m->error_count);
42205
42206 if (test_and_set_bit(error_type, &m->error_type))
42207 return;
42208 @@ -409,7 +409,7 @@ static struct mirror *choose_mirror(struct mirror_set *ms, sector_t sector)
42209 struct mirror *m = get_default_mirror(ms);
42210
42211 do {
42212 - if (likely(!atomic_read(&m->error_count)))
42213 + if (likely(!atomic_read_unchecked(&m->error_count)))
42214 return m;
42215
42216 if (m-- == ms->mirror)
42217 @@ -423,7 +423,7 @@ static int default_ok(struct mirror *m)
42218 {
42219 struct mirror *default_mirror = get_default_mirror(m->ms);
42220
42221 - return !atomic_read(&default_mirror->error_count);
42222 + return !atomic_read_unchecked(&default_mirror->error_count);
42223 }
42224
42225 static int mirror_available(struct mirror_set *ms, struct bio *bio)
42226 @@ -560,7 +560,7 @@ static void do_reads(struct mirror_set *ms, struct bio_list *reads)
42227 */
42228 if (likely(region_in_sync(ms, region, 1)))
42229 m = choose_mirror(ms, bio->bi_sector);
42230 - else if (m && atomic_read(&m->error_count))
42231 + else if (m && atomic_read_unchecked(&m->error_count))
42232 m = NULL;
42233
42234 if (likely(m))
42235 @@ -927,7 +927,7 @@ static int get_mirror(struct mirror_set *ms, struct dm_target *ti,
42236 }
42237
42238 ms->mirror[mirror].ms = ms;
42239 - atomic_set(&(ms->mirror[mirror].error_count), 0);
42240 + atomic_set_unchecked(&(ms->mirror[mirror].error_count), 0);
42241 ms->mirror[mirror].error_type = 0;
42242 ms->mirror[mirror].offset = offset;
42243
42244 @@ -1339,7 +1339,7 @@ static void mirror_resume(struct dm_target *ti)
42245 */
42246 static char device_status_char(struct mirror *m)
42247 {
42248 - if (!atomic_read(&(m->error_count)))
42249 + if (!atomic_read_unchecked(&(m->error_count)))
42250 return 'A';
42251
42252 return (test_bit(DM_RAID1_FLUSH_ERROR, &(m->error_type))) ? 'F' :
42253 diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c
42254 index 28a9012..9c0f6a5 100644
42255 --- a/drivers/md/dm-stats.c
42256 +++ b/drivers/md/dm-stats.c
42257 @@ -382,7 +382,7 @@ do_sync_free:
42258 synchronize_rcu_expedited();
42259 dm_stat_free(&s->rcu_head);
42260 } else {
42261 - ACCESS_ONCE(dm_stat_need_rcu_barrier) = 1;
42262 + ACCESS_ONCE_RW(dm_stat_need_rcu_barrier) = 1;
42263 call_rcu(&s->rcu_head, dm_stat_free);
42264 }
42265 return 0;
42266 @@ -554,8 +554,8 @@ void dm_stats_account_io(struct dm_stats *stats, unsigned long bi_rw,
42267 ((bi_rw & (REQ_WRITE | REQ_DISCARD)) ==
42268 (ACCESS_ONCE(last->last_rw) & (REQ_WRITE | REQ_DISCARD)))
42269 ));
42270 - ACCESS_ONCE(last->last_sector) = end_sector;
42271 - ACCESS_ONCE(last->last_rw) = bi_rw;
42272 + ACCESS_ONCE_RW(last->last_sector) = end_sector;
42273 + ACCESS_ONCE_RW(last->last_rw) = bi_rw;
42274 }
42275
42276 rcu_read_lock();
42277 diff --git a/drivers/md/dm-stripe.c b/drivers/md/dm-stripe.c
42278 index 73c1712..7347292 100644
42279 --- a/drivers/md/dm-stripe.c
42280 +++ b/drivers/md/dm-stripe.c
42281 @@ -21,7 +21,7 @@ struct stripe {
42282 struct dm_dev *dev;
42283 sector_t physical_start;
42284
42285 - atomic_t error_count;
42286 + atomic_unchecked_t error_count;
42287 };
42288
42289 struct stripe_c {
42290 @@ -186,7 +186,7 @@ static int stripe_ctr(struct dm_target *ti, unsigned int argc, char **argv)
42291 kfree(sc);
42292 return r;
42293 }
42294 - atomic_set(&(sc->stripe[i].error_count), 0);
42295 + atomic_set_unchecked(&(sc->stripe[i].error_count), 0);
42296 }
42297
42298 ti->private = sc;
42299 @@ -327,7 +327,7 @@ static void stripe_status(struct dm_target *ti, status_type_t type,
42300 DMEMIT("%d ", sc->stripes);
42301 for (i = 0; i < sc->stripes; i++) {
42302 DMEMIT("%s ", sc->stripe[i].dev->name);
42303 - buffer[i] = atomic_read(&(sc->stripe[i].error_count)) ?
42304 + buffer[i] = atomic_read_unchecked(&(sc->stripe[i].error_count)) ?
42305 'D' : 'A';
42306 }
42307 buffer[i] = '\0';
42308 @@ -372,8 +372,8 @@ static int stripe_end_io(struct dm_target *ti, struct bio *bio, int error)
42309 */
42310 for (i = 0; i < sc->stripes; i++)
42311 if (!strcmp(sc->stripe[i].dev->name, major_minor)) {
42312 - atomic_inc(&(sc->stripe[i].error_count));
42313 - if (atomic_read(&(sc->stripe[i].error_count)) <
42314 + atomic_inc_unchecked(&(sc->stripe[i].error_count));
42315 + if (atomic_read_unchecked(&(sc->stripe[i].error_count)) <
42316 DM_IO_ERROR_THRESHOLD)
42317 schedule_work(&sc->trigger_event);
42318 }
42319 diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c
42320 index 20a8cc0..5447b11 100644
42321 --- a/drivers/md/dm-table.c
42322 +++ b/drivers/md/dm-table.c
42323 @@ -291,7 +291,7 @@ static struct dm_dev_internal *find_device(struct list_head *l, dev_t dev)
42324 static int open_dev(struct dm_dev_internal *d, dev_t dev,
42325 struct mapped_device *md)
42326 {
42327 - static char *_claim_ptr = "I belong to device-mapper";
42328 + static char _claim_ptr[] = "I belong to device-mapper";
42329 struct block_device *bdev;
42330
42331 int r;
42332 @@ -359,7 +359,7 @@ static int device_area_is_invalid(struct dm_target *ti, struct dm_dev *dev,
42333 if (!dev_size)
42334 return 0;
42335
42336 - if ((start >= dev_size) || (start + len > dev_size)) {
42337 + if ((start >= dev_size) || (len > dev_size - start)) {
42338 DMWARN("%s: %s too small for target: "
42339 "start=%llu, len=%llu, dev_size=%llu",
42340 dm_device_name(ti->table->md), bdevname(bdev, b),
42341 diff --git a/drivers/md/dm-thin-metadata.c b/drivers/md/dm-thin-metadata.c
42342 index 8a30ad5..72792d3 100644
42343 --- a/drivers/md/dm-thin-metadata.c
42344 +++ b/drivers/md/dm-thin-metadata.c
42345 @@ -397,7 +397,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42346 {
42347 pmd->info.tm = pmd->tm;
42348 pmd->info.levels = 2;
42349 - pmd->info.value_type.context = pmd->data_sm;
42350 + pmd->info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42351 pmd->info.value_type.size = sizeof(__le64);
42352 pmd->info.value_type.inc = data_block_inc;
42353 pmd->info.value_type.dec = data_block_dec;
42354 @@ -416,7 +416,7 @@ static void __setup_btree_details(struct dm_pool_metadata *pmd)
42355
42356 pmd->bl_info.tm = pmd->tm;
42357 pmd->bl_info.levels = 1;
42358 - pmd->bl_info.value_type.context = pmd->data_sm;
42359 + pmd->bl_info.value_type.context = (dm_space_map_no_const *)pmd->data_sm;
42360 pmd->bl_info.value_type.size = sizeof(__le64);
42361 pmd->bl_info.value_type.inc = data_block_inc;
42362 pmd->bl_info.value_type.dec = data_block_dec;
42363 diff --git a/drivers/md/dm.c b/drivers/md/dm.c
42364 index b3e26c7..1efca94 100644
42365 --- a/drivers/md/dm.c
42366 +++ b/drivers/md/dm.c
42367 @@ -179,9 +179,9 @@ struct mapped_device {
42368 /*
42369 * Event handling.
42370 */
42371 - atomic_t event_nr;
42372 + atomic_unchecked_t event_nr;
42373 wait_queue_head_t eventq;
42374 - atomic_t uevent_seq;
42375 + atomic_unchecked_t uevent_seq;
42376 struct list_head uevent_list;
42377 spinlock_t uevent_lock; /* Protect access to uevent_list */
42378
42379 @@ -1985,8 +1985,8 @@ static struct mapped_device *alloc_dev(int minor)
42380 spin_lock_init(&md->deferred_lock);
42381 atomic_set(&md->holders, 1);
42382 atomic_set(&md->open_count, 0);
42383 - atomic_set(&md->event_nr, 0);
42384 - atomic_set(&md->uevent_seq, 0);
42385 + atomic_set_unchecked(&md->event_nr, 0);
42386 + atomic_set_unchecked(&md->uevent_seq, 0);
42387 INIT_LIST_HEAD(&md->uevent_list);
42388 spin_lock_init(&md->uevent_lock);
42389
42390 @@ -2139,7 +2139,7 @@ static void event_callback(void *context)
42391
42392 dm_send_uevents(&uevents, &disk_to_dev(md->disk)->kobj);
42393
42394 - atomic_inc(&md->event_nr);
42395 + atomic_inc_unchecked(&md->event_nr);
42396 wake_up(&md->eventq);
42397 }
42398
42399 @@ -2832,18 +2832,18 @@ int dm_kobject_uevent(struct mapped_device *md, enum kobject_action action,
42400
42401 uint32_t dm_next_uevent_seq(struct mapped_device *md)
42402 {
42403 - return atomic_add_return(1, &md->uevent_seq);
42404 + return atomic_add_return_unchecked(1, &md->uevent_seq);
42405 }
42406
42407 uint32_t dm_get_event_nr(struct mapped_device *md)
42408 {
42409 - return atomic_read(&md->event_nr);
42410 + return atomic_read_unchecked(&md->event_nr);
42411 }
42412
42413 int dm_wait_event(struct mapped_device *md, int event_nr)
42414 {
42415 return wait_event_interruptible(md->eventq,
42416 - (event_nr != atomic_read(&md->event_nr)));
42417 + (event_nr != atomic_read_unchecked(&md->event_nr)));
42418 }
42419
42420 void dm_uevent_add(struct mapped_device *md, struct list_head *elist)
42421 diff --git a/drivers/md/md.c b/drivers/md/md.c
42422 index ba46d97..f8f5019 100644
42423 --- a/drivers/md/md.c
42424 +++ b/drivers/md/md.c
42425 @@ -234,10 +234,10 @@ EXPORT_SYMBOL_GPL(md_trim_bio);
42426 * start build, activate spare
42427 */
42428 static DECLARE_WAIT_QUEUE_HEAD(md_event_waiters);
42429 -static atomic_t md_event_count;
42430 +static atomic_unchecked_t md_event_count;
42431 void md_new_event(struct mddev *mddev)
42432 {
42433 - atomic_inc(&md_event_count);
42434 + atomic_inc_unchecked(&md_event_count);
42435 wake_up(&md_event_waiters);
42436 }
42437 EXPORT_SYMBOL_GPL(md_new_event);
42438 @@ -247,7 +247,7 @@ EXPORT_SYMBOL_GPL(md_new_event);
42439 */
42440 static void md_new_event_inintr(struct mddev *mddev)
42441 {
42442 - atomic_inc(&md_event_count);
42443 + atomic_inc_unchecked(&md_event_count);
42444 wake_up(&md_event_waiters);
42445 }
42446
42447 @@ -1502,7 +1502,7 @@ static int super_1_load(struct md_rdev *rdev, struct md_rdev *refdev, int minor_
42448 if ((le32_to_cpu(sb->feature_map) & MD_FEATURE_RESHAPE_ACTIVE) &&
42449 (le32_to_cpu(sb->feature_map) & MD_FEATURE_NEW_OFFSET))
42450 rdev->new_data_offset += (s32)le32_to_cpu(sb->new_offset);
42451 - atomic_set(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42452 + atomic_set_unchecked(&rdev->corrected_errors, le32_to_cpu(sb->cnt_corrected_read));
42453
42454 rdev->sb_size = le32_to_cpu(sb->max_dev) * 2 + 256;
42455 bmask = queue_logical_block_size(rdev->bdev->bd_disk->queue)-1;
42456 @@ -1746,7 +1746,7 @@ static void super_1_sync(struct mddev *mddev, struct md_rdev *rdev)
42457 else
42458 sb->resync_offset = cpu_to_le64(0);
42459
42460 - sb->cnt_corrected_read = cpu_to_le32(atomic_read(&rdev->corrected_errors));
42461 + sb->cnt_corrected_read = cpu_to_le32(atomic_read_unchecked(&rdev->corrected_errors));
42462
42463 sb->raid_disks = cpu_to_le32(mddev->raid_disks);
42464 sb->size = cpu_to_le64(mddev->dev_sectors);
42465 @@ -2751,7 +2751,7 @@ __ATTR(state, S_IRUGO|S_IWUSR, state_show, state_store);
42466 static ssize_t
42467 errors_show(struct md_rdev *rdev, char *page)
42468 {
42469 - return sprintf(page, "%d\n", atomic_read(&rdev->corrected_errors));
42470 + return sprintf(page, "%d\n", atomic_read_unchecked(&rdev->corrected_errors));
42471 }
42472
42473 static ssize_t
42474 @@ -2760,7 +2760,7 @@ errors_store(struct md_rdev *rdev, const char *buf, size_t len)
42475 char *e;
42476 unsigned long n = simple_strtoul(buf, &e, 10);
42477 if (*buf && (*e == 0 || *e == '\n')) {
42478 - atomic_set(&rdev->corrected_errors, n);
42479 + atomic_set_unchecked(&rdev->corrected_errors, n);
42480 return len;
42481 }
42482 return -EINVAL;
42483 @@ -3208,8 +3208,8 @@ int md_rdev_init(struct md_rdev *rdev)
42484 rdev->sb_loaded = 0;
42485 rdev->bb_page = NULL;
42486 atomic_set(&rdev->nr_pending, 0);
42487 - atomic_set(&rdev->read_errors, 0);
42488 - atomic_set(&rdev->corrected_errors, 0);
42489 + atomic_set_unchecked(&rdev->read_errors, 0);
42490 + atomic_set_unchecked(&rdev->corrected_errors, 0);
42491
42492 INIT_LIST_HEAD(&rdev->same_set);
42493 init_waitqueue_head(&rdev->blocked_wait);
42494 @@ -7043,7 +7043,7 @@ static int md_seq_show(struct seq_file *seq, void *v)
42495
42496 spin_unlock(&pers_lock);
42497 seq_printf(seq, "\n");
42498 - seq->poll_event = atomic_read(&md_event_count);
42499 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42500 return 0;
42501 }
42502 if (v == (void*)2) {
42503 @@ -7146,7 +7146,7 @@ static int md_seq_open(struct inode *inode, struct file *file)
42504 return error;
42505
42506 seq = file->private_data;
42507 - seq->poll_event = atomic_read(&md_event_count);
42508 + seq->poll_event = atomic_read_unchecked(&md_event_count);
42509 return error;
42510 }
42511
42512 @@ -7160,7 +7160,7 @@ static unsigned int mdstat_poll(struct file *filp, poll_table *wait)
42513 /* always allow read */
42514 mask = POLLIN | POLLRDNORM;
42515
42516 - if (seq->poll_event != atomic_read(&md_event_count))
42517 + if (seq->poll_event != atomic_read_unchecked(&md_event_count))
42518 mask |= POLLERR | POLLPRI;
42519 return mask;
42520 }
42521 @@ -7204,7 +7204,7 @@ static int is_mddev_idle(struct mddev *mddev, int init)
42522 struct gendisk *disk = rdev->bdev->bd_contains->bd_disk;
42523 curr_events = (int)part_stat_read(&disk->part0, sectors[0]) +
42524 (int)part_stat_read(&disk->part0, sectors[1]) -
42525 - atomic_read(&disk->sync_io);
42526 + atomic_read_unchecked(&disk->sync_io);
42527 /* sync IO will cause sync_io to increase before the disk_stats
42528 * as sync_io is counted when a request starts, and
42529 * disk_stats is counted when it completes.
42530 diff --git a/drivers/md/md.h b/drivers/md/md.h
42531 index 608050c..6e77db5d 100644
42532 --- a/drivers/md/md.h
42533 +++ b/drivers/md/md.h
42534 @@ -94,13 +94,13 @@ struct md_rdev {
42535 * only maintained for arrays that
42536 * support hot removal
42537 */
42538 - atomic_t read_errors; /* number of consecutive read errors that
42539 + atomic_unchecked_t read_errors; /* number of consecutive read errors that
42540 * we have tried to ignore.
42541 */
42542 struct timespec last_read_error; /* monotonic time since our
42543 * last read error
42544 */
42545 - atomic_t corrected_errors; /* number of corrected read errors,
42546 + atomic_unchecked_t corrected_errors; /* number of corrected read errors,
42547 * for reporting to userspace and storing
42548 * in superblock.
42549 */
42550 @@ -446,7 +446,7 @@ static inline void rdev_dec_pending(struct md_rdev *rdev, struct mddev *mddev)
42551
42552 static inline void md_sync_acct(struct block_device *bdev, unsigned long nr_sectors)
42553 {
42554 - atomic_add(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42555 + atomic_add_unchecked(nr_sectors, &bdev->bd_contains->bd_disk->sync_io);
42556 }
42557
42558 struct md_personality
42559 diff --git a/drivers/md/persistent-data/dm-space-map.h b/drivers/md/persistent-data/dm-space-map.h
42560 index 3e6d115..ffecdeb 100644
42561 --- a/drivers/md/persistent-data/dm-space-map.h
42562 +++ b/drivers/md/persistent-data/dm-space-map.h
42563 @@ -71,6 +71,7 @@ struct dm_space_map {
42564 dm_sm_threshold_fn fn,
42565 void *context);
42566 };
42567 +typedef struct dm_space_map __no_const dm_space_map_no_const;
42568
42569 /*----------------------------------------------------------------*/
42570
42571 diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
42572 index aacf6bf..67d63f2 100644
42573 --- a/drivers/md/raid1.c
42574 +++ b/drivers/md/raid1.c
42575 @@ -1824,7 +1824,7 @@ static int fix_sync_read_error(struct r1bio *r1_bio)
42576 if (r1_sync_page_io(rdev, sect, s,
42577 bio->bi_io_vec[idx].bv_page,
42578 READ) != 0)
42579 - atomic_add(s, &rdev->corrected_errors);
42580 + atomic_add_unchecked(s, &rdev->corrected_errors);
42581 }
42582 sectors -= s;
42583 sect += s;
42584 @@ -2051,7 +2051,7 @@ static void fix_read_error(struct r1conf *conf, int read_disk,
42585 test_bit(In_sync, &rdev->flags)) {
42586 if (r1_sync_page_io(rdev, sect, s,
42587 conf->tmppage, READ)) {
42588 - atomic_add(s, &rdev->corrected_errors);
42589 + atomic_add_unchecked(s, &rdev->corrected_errors);
42590 printk(KERN_INFO
42591 "md/raid1:%s: read error corrected "
42592 "(%d sectors at %llu on %s)\n",
42593 diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c
42594 index 73dc8a3..bdd515a 100644
42595 --- a/drivers/md/raid10.c
42596 +++ b/drivers/md/raid10.c
42597 @@ -1963,7 +1963,7 @@ static void end_sync_read(struct bio *bio, int error)
42598 /* The write handler will notice the lack of
42599 * R10BIO_Uptodate and record any errors etc
42600 */
42601 - atomic_add(r10_bio->sectors,
42602 + atomic_add_unchecked(r10_bio->sectors,
42603 &conf->mirrors[d].rdev->corrected_errors);
42604
42605 /* for reconstruct, we always reschedule after a read.
42606 @@ -2321,7 +2321,7 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42607 {
42608 struct timespec cur_time_mon;
42609 unsigned long hours_since_last;
42610 - unsigned int read_errors = atomic_read(&rdev->read_errors);
42611 + unsigned int read_errors = atomic_read_unchecked(&rdev->read_errors);
42612
42613 ktime_get_ts(&cur_time_mon);
42614
42615 @@ -2343,9 +2343,9 @@ static void check_decay_read_errors(struct mddev *mddev, struct md_rdev *rdev)
42616 * overflowing the shift of read_errors by hours_since_last.
42617 */
42618 if (hours_since_last >= 8 * sizeof(read_errors))
42619 - atomic_set(&rdev->read_errors, 0);
42620 + atomic_set_unchecked(&rdev->read_errors, 0);
42621 else
42622 - atomic_set(&rdev->read_errors, read_errors >> hours_since_last);
42623 + atomic_set_unchecked(&rdev->read_errors, read_errors >> hours_since_last);
42624 }
42625
42626 static int r10_sync_page_io(struct md_rdev *rdev, sector_t sector,
42627 @@ -2399,8 +2399,8 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42628 return;
42629
42630 check_decay_read_errors(mddev, rdev);
42631 - atomic_inc(&rdev->read_errors);
42632 - if (atomic_read(&rdev->read_errors) > max_read_errors) {
42633 + atomic_inc_unchecked(&rdev->read_errors);
42634 + if (atomic_read_unchecked(&rdev->read_errors) > max_read_errors) {
42635 char b[BDEVNAME_SIZE];
42636 bdevname(rdev->bdev, b);
42637
42638 @@ -2408,7 +2408,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42639 "md/raid10:%s: %s: Raid device exceeded "
42640 "read_error threshold [cur %d:max %d]\n",
42641 mdname(mddev), b,
42642 - atomic_read(&rdev->read_errors), max_read_errors);
42643 + atomic_read_unchecked(&rdev->read_errors), max_read_errors);
42644 printk(KERN_NOTICE
42645 "md/raid10:%s: %s: Failing raid device\n",
42646 mdname(mddev), b);
42647 @@ -2563,7 +2563,7 @@ static void fix_read_error(struct r10conf *conf, struct mddev *mddev, struct r10
42648 sect +
42649 choose_data_offset(r10_bio, rdev)),
42650 bdevname(rdev->bdev, b));
42651 - atomic_add(s, &rdev->corrected_errors);
42652 + atomic_add_unchecked(s, &rdev->corrected_errors);
42653 }
42654
42655 rdev_dec_pending(rdev, mddev);
42656 diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
42657 index 8a0665d..984c46d 100644
42658 --- a/drivers/md/raid5.c
42659 +++ b/drivers/md/raid5.c
42660 @@ -1887,21 +1887,21 @@ static void raid5_end_read_request(struct bio * bi, int error)
42661 mdname(conf->mddev), STRIPE_SECTORS,
42662 (unsigned long long)s,
42663 bdevname(rdev->bdev, b));
42664 - atomic_add(STRIPE_SECTORS, &rdev->corrected_errors);
42665 + atomic_add_unchecked(STRIPE_SECTORS, &rdev->corrected_errors);
42666 clear_bit(R5_ReadError, &sh->dev[i].flags);
42667 clear_bit(R5_ReWrite, &sh->dev[i].flags);
42668 } else if (test_bit(R5_ReadNoMerge, &sh->dev[i].flags))
42669 clear_bit(R5_ReadNoMerge, &sh->dev[i].flags);
42670
42671 - if (atomic_read(&rdev->read_errors))
42672 - atomic_set(&rdev->read_errors, 0);
42673 + if (atomic_read_unchecked(&rdev->read_errors))
42674 + atomic_set_unchecked(&rdev->read_errors, 0);
42675 } else {
42676 const char *bdn = bdevname(rdev->bdev, b);
42677 int retry = 0;
42678 int set_bad = 0;
42679
42680 clear_bit(R5_UPTODATE, &sh->dev[i].flags);
42681 - atomic_inc(&rdev->read_errors);
42682 + atomic_inc_unchecked(&rdev->read_errors);
42683 if (test_bit(R5_ReadRepl, &sh->dev[i].flags))
42684 printk_ratelimited(
42685 KERN_WARNING
42686 @@ -1929,7 +1929,7 @@ static void raid5_end_read_request(struct bio * bi, int error)
42687 mdname(conf->mddev),
42688 (unsigned long long)s,
42689 bdn);
42690 - } else if (atomic_read(&rdev->read_errors)
42691 + } else if (atomic_read_unchecked(&rdev->read_errors)
42692 > conf->max_nr_stripes)
42693 printk(KERN_WARNING
42694 "md/raid:%s: Too many read errors, failing device %s.\n",
42695 diff --git a/drivers/media/dvb-core/dvbdev.c b/drivers/media/dvb-core/dvbdev.c
42696 index 401ef64..836e563 100644
42697 --- a/drivers/media/dvb-core/dvbdev.c
42698 +++ b/drivers/media/dvb-core/dvbdev.c
42699 @@ -192,7 +192,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev,
42700 const struct dvb_device *template, void *priv, int type)
42701 {
42702 struct dvb_device *dvbdev;
42703 - struct file_operations *dvbdevfops;
42704 + file_operations_no_const *dvbdevfops;
42705 struct device *clsdev;
42706 int minor;
42707 int id;
42708 diff --git a/drivers/media/dvb-frontends/dib3000.h b/drivers/media/dvb-frontends/dib3000.h
42709 index 9b6c3bb..baeb5c7 100644
42710 --- a/drivers/media/dvb-frontends/dib3000.h
42711 +++ b/drivers/media/dvb-frontends/dib3000.h
42712 @@ -39,7 +39,7 @@ struct dib_fe_xfer_ops
42713 int (*fifo_ctrl)(struct dvb_frontend *fe, int onoff);
42714 int (*pid_ctrl)(struct dvb_frontend *fe, int index, int pid, int onoff);
42715 int (*tuner_pass_ctrl)(struct dvb_frontend *fe, int onoff, u8 pll_ctrl);
42716 -};
42717 +} __no_const;
42718
42719 #if IS_ENABLED(CONFIG_DVB_DIB3000MB)
42720 extern struct dvb_frontend* dib3000mb_attach(const struct dib3000_config* config,
42721 diff --git a/drivers/media/pci/cx88/cx88-video.c b/drivers/media/pci/cx88/cx88-video.c
42722 index ecf21d9..b992428d 100644
42723 --- a/drivers/media/pci/cx88/cx88-video.c
42724 +++ b/drivers/media/pci/cx88/cx88-video.c
42725 @@ -50,9 +50,9 @@ MODULE_VERSION(CX88_VERSION);
42726
42727 /* ------------------------------------------------------------------ */
42728
42729 -static unsigned int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42730 -static unsigned int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42731 -static unsigned int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42732 +static int video_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42733 +static int vbi_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42734 +static int radio_nr[] = {[0 ... (CX88_MAXBOARDS - 1)] = UNSET };
42735
42736 module_param_array(video_nr, int, NULL, 0444);
42737 module_param_array(vbi_nr, int, NULL, 0444);
42738 diff --git a/drivers/media/pci/ivtv/ivtv-driver.c b/drivers/media/pci/ivtv/ivtv-driver.c
42739 index c08ae3e..eb59af1 100644
42740 --- a/drivers/media/pci/ivtv/ivtv-driver.c
42741 +++ b/drivers/media/pci/ivtv/ivtv-driver.c
42742 @@ -83,7 +83,7 @@ static struct pci_device_id ivtv_pci_tbl[] = {
42743 MODULE_DEVICE_TABLE(pci,ivtv_pci_tbl);
42744
42745 /* ivtv instance counter */
42746 -static atomic_t ivtv_instance = ATOMIC_INIT(0);
42747 +static atomic_unchecked_t ivtv_instance = ATOMIC_INIT(0);
42748
42749 /* Parameter declarations */
42750 static int cardtype[IVTV_MAX_CARDS];
42751 diff --git a/drivers/media/platform/omap/omap_vout.c b/drivers/media/platform/omap/omap_vout.c
42752 index dfd0a21..6bbb465 100644
42753 --- a/drivers/media/platform/omap/omap_vout.c
42754 +++ b/drivers/media/platform/omap/omap_vout.c
42755 @@ -63,7 +63,6 @@ enum omap_vout_channels {
42756 OMAP_VIDEO2,
42757 };
42758
42759 -static struct videobuf_queue_ops video_vbq_ops;
42760 /* Variables configurable through module params*/
42761 static u32 video1_numbuffers = 3;
42762 static u32 video2_numbuffers = 3;
42763 @@ -1014,6 +1013,12 @@ static int omap_vout_open(struct file *file)
42764 {
42765 struct videobuf_queue *q;
42766 struct omap_vout_device *vout = NULL;
42767 + static struct videobuf_queue_ops video_vbq_ops = {
42768 + .buf_setup = omap_vout_buffer_setup,
42769 + .buf_prepare = omap_vout_buffer_prepare,
42770 + .buf_release = omap_vout_buffer_release,
42771 + .buf_queue = omap_vout_buffer_queue,
42772 + };
42773
42774 vout = video_drvdata(file);
42775 v4l2_dbg(1, debug, &vout->vid_dev->v4l2_dev, "Entering %s\n", __func__);
42776 @@ -1031,10 +1036,6 @@ static int omap_vout_open(struct file *file)
42777 vout->type = V4L2_BUF_TYPE_VIDEO_OUTPUT;
42778
42779 q = &vout->vbq;
42780 - video_vbq_ops.buf_setup = omap_vout_buffer_setup;
42781 - video_vbq_ops.buf_prepare = omap_vout_buffer_prepare;
42782 - video_vbq_ops.buf_release = omap_vout_buffer_release;
42783 - video_vbq_ops.buf_queue = omap_vout_buffer_queue;
42784 spin_lock_init(&vout->vbq_lock);
42785
42786 videobuf_queue_dma_contig_init(q, &video_vbq_ops, q->dev,
42787 diff --git a/drivers/media/platform/s5p-tv/mixer.h b/drivers/media/platform/s5p-tv/mixer.h
42788 index 04e6490..2df65bf 100644
42789 --- a/drivers/media/platform/s5p-tv/mixer.h
42790 +++ b/drivers/media/platform/s5p-tv/mixer.h
42791 @@ -156,7 +156,7 @@ struct mxr_layer {
42792 /** layer index (unique identifier) */
42793 int idx;
42794 /** callbacks for layer methods */
42795 - struct mxr_layer_ops ops;
42796 + struct mxr_layer_ops *ops;
42797 /** format array */
42798 const struct mxr_format **fmt_array;
42799 /** size of format array */
42800 diff --git a/drivers/media/platform/s5p-tv/mixer_grp_layer.c b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42801 index b93a21f..2535195 100644
42802 --- a/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42803 +++ b/drivers/media/platform/s5p-tv/mixer_grp_layer.c
42804 @@ -235,7 +235,7 @@ struct mxr_layer *mxr_graph_layer_create(struct mxr_device *mdev, int idx)
42805 {
42806 struct mxr_layer *layer;
42807 int ret;
42808 - struct mxr_layer_ops ops = {
42809 + static struct mxr_layer_ops ops = {
42810 .release = mxr_graph_layer_release,
42811 .buffer_set = mxr_graph_buffer_set,
42812 .stream_set = mxr_graph_stream_set,
42813 diff --git a/drivers/media/platform/s5p-tv/mixer_reg.c b/drivers/media/platform/s5p-tv/mixer_reg.c
42814 index b713403..53cb5ad 100644
42815 --- a/drivers/media/platform/s5p-tv/mixer_reg.c
42816 +++ b/drivers/media/platform/s5p-tv/mixer_reg.c
42817 @@ -276,7 +276,7 @@ static void mxr_irq_layer_handle(struct mxr_layer *layer)
42818 layer->update_buf = next;
42819 }
42820
42821 - layer->ops.buffer_set(layer, layer->update_buf);
42822 + layer->ops->buffer_set(layer, layer->update_buf);
42823
42824 if (done && done != layer->shadow_buf)
42825 vb2_buffer_done(&done->vb, VB2_BUF_STATE_DONE);
42826 diff --git a/drivers/media/platform/s5p-tv/mixer_video.c b/drivers/media/platform/s5p-tv/mixer_video.c
42827 index 641b1f0..49cff30 100644
42828 --- a/drivers/media/platform/s5p-tv/mixer_video.c
42829 +++ b/drivers/media/platform/s5p-tv/mixer_video.c
42830 @@ -210,7 +210,7 @@ static void mxr_layer_default_geo(struct mxr_layer *layer)
42831 layer->geo.src.height = layer->geo.src.full_height;
42832
42833 mxr_geometry_dump(mdev, &layer->geo);
42834 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42835 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42836 mxr_geometry_dump(mdev, &layer->geo);
42837 }
42838
42839 @@ -228,7 +228,7 @@ static void mxr_layer_update_output(struct mxr_layer *layer)
42840 layer->geo.dst.full_width = mbus_fmt.width;
42841 layer->geo.dst.full_height = mbus_fmt.height;
42842 layer->geo.dst.field = mbus_fmt.field;
42843 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42844 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SINK, 0);
42845
42846 mxr_geometry_dump(mdev, &layer->geo);
42847 }
42848 @@ -334,7 +334,7 @@ static int mxr_s_fmt(struct file *file, void *priv,
42849 /* set source size to highest accepted value */
42850 geo->src.full_width = max(geo->dst.full_width, pix->width);
42851 geo->src.full_height = max(geo->dst.full_height, pix->height);
42852 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42853 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42854 mxr_geometry_dump(mdev, &layer->geo);
42855 /* set cropping to total visible screen */
42856 geo->src.width = pix->width;
42857 @@ -342,12 +342,12 @@ static int mxr_s_fmt(struct file *file, void *priv,
42858 geo->src.x_offset = 0;
42859 geo->src.y_offset = 0;
42860 /* assure consistency of geometry */
42861 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42862 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_CROP, MXR_NO_OFFSET);
42863 mxr_geometry_dump(mdev, &layer->geo);
42864 /* set full size to lowest possible value */
42865 geo->src.full_width = 0;
42866 geo->src.full_height = 0;
42867 - layer->ops.fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42868 + layer->ops->fix_geometry(layer, MXR_GEOMETRY_SOURCE, 0);
42869 mxr_geometry_dump(mdev, &layer->geo);
42870
42871 /* returning results */
42872 @@ -474,7 +474,7 @@ static int mxr_s_selection(struct file *file, void *fh,
42873 target->width = s->r.width;
42874 target->height = s->r.height;
42875
42876 - layer->ops.fix_geometry(layer, stage, s->flags);
42877 + layer->ops->fix_geometry(layer, stage, s->flags);
42878
42879 /* retrieve update selection rectangle */
42880 res.left = target->x_offset;
42881 @@ -955,13 +955,13 @@ static int start_streaming(struct vb2_queue *vq, unsigned int count)
42882 mxr_output_get(mdev);
42883
42884 mxr_layer_update_output(layer);
42885 - layer->ops.format_set(layer);
42886 + layer->ops->format_set(layer);
42887 /* enabling layer in hardware */
42888 spin_lock_irqsave(&layer->enq_slock, flags);
42889 layer->state = MXR_LAYER_STREAMING;
42890 spin_unlock_irqrestore(&layer->enq_slock, flags);
42891
42892 - layer->ops.stream_set(layer, MXR_ENABLE);
42893 + layer->ops->stream_set(layer, MXR_ENABLE);
42894 mxr_streamer_get(mdev);
42895
42896 return 0;
42897 @@ -1031,7 +1031,7 @@ static int stop_streaming(struct vb2_queue *vq)
42898 spin_unlock_irqrestore(&layer->enq_slock, flags);
42899
42900 /* disabling layer in hardware */
42901 - layer->ops.stream_set(layer, MXR_DISABLE);
42902 + layer->ops->stream_set(layer, MXR_DISABLE);
42903 /* remove one streamer */
42904 mxr_streamer_put(mdev);
42905 /* allow changes in output configuration */
42906 @@ -1070,8 +1070,8 @@ void mxr_base_layer_unregister(struct mxr_layer *layer)
42907
42908 void mxr_layer_release(struct mxr_layer *layer)
42909 {
42910 - if (layer->ops.release)
42911 - layer->ops.release(layer);
42912 + if (layer->ops->release)
42913 + layer->ops->release(layer);
42914 }
42915
42916 void mxr_base_layer_release(struct mxr_layer *layer)
42917 @@ -1097,7 +1097,7 @@ struct mxr_layer *mxr_base_layer_create(struct mxr_device *mdev,
42918
42919 layer->mdev = mdev;
42920 layer->idx = idx;
42921 - layer->ops = *ops;
42922 + layer->ops = ops;
42923
42924 spin_lock_init(&layer->enq_slock);
42925 INIT_LIST_HEAD(&layer->enq_list);
42926 diff --git a/drivers/media/platform/s5p-tv/mixer_vp_layer.c b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42927 index 3d13a63..da31bf1 100644
42928 --- a/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42929 +++ b/drivers/media/platform/s5p-tv/mixer_vp_layer.c
42930 @@ -206,7 +206,7 @@ struct mxr_layer *mxr_vp_layer_create(struct mxr_device *mdev, int idx)
42931 {
42932 struct mxr_layer *layer;
42933 int ret;
42934 - struct mxr_layer_ops ops = {
42935 + static struct mxr_layer_ops ops = {
42936 .release = mxr_vp_layer_release,
42937 .buffer_set = mxr_vp_buffer_set,
42938 .stream_set = mxr_vp_stream_set,
42939 diff --git a/drivers/media/platform/vivi.c b/drivers/media/platform/vivi.c
42940 index 1d3f119..75f40bb 100644
42941 --- a/drivers/media/platform/vivi.c
42942 +++ b/drivers/media/platform/vivi.c
42943 @@ -58,8 +58,8 @@ MODULE_AUTHOR("Mauro Carvalho Chehab, Ted Walther and John Sokol");
42944 MODULE_LICENSE("Dual BSD/GPL");
42945 MODULE_VERSION(VIVI_VERSION);
42946
42947 -static unsigned video_nr = -1;
42948 -module_param(video_nr, uint, 0644);
42949 +static int video_nr = -1;
42950 +module_param(video_nr, int, 0644);
42951 MODULE_PARM_DESC(video_nr, "videoX start number, -1 is autodetect");
42952
42953 static unsigned n_devs = 1;
42954 diff --git a/drivers/media/radio/radio-cadet.c b/drivers/media/radio/radio-cadet.c
42955 index 545c04c..a14bded 100644
42956 --- a/drivers/media/radio/radio-cadet.c
42957 +++ b/drivers/media/radio/radio-cadet.c
42958 @@ -324,6 +324,8 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42959 unsigned char readbuf[RDS_BUFFER];
42960 int i = 0;
42961
42962 + if (count > RDS_BUFFER)
42963 + return -EFAULT;
42964 mutex_lock(&dev->lock);
42965 if (dev->rdsstat == 0)
42966 cadet_start_rds(dev);
42967 @@ -339,7 +341,7 @@ static ssize_t cadet_read(struct file *file, char __user *data, size_t count, lo
42968 while (i < count && dev->rdsin != dev->rdsout)
42969 readbuf[i++] = dev->rdsbuf[dev->rdsout++];
42970
42971 - if (i && copy_to_user(data, readbuf, i))
42972 + if (i > sizeof(readbuf) || copy_to_user(data, readbuf, i))
42973 i = -EFAULT;
42974 unlock:
42975 mutex_unlock(&dev->lock);
42976 diff --git a/drivers/media/radio/radio-maxiradio.c b/drivers/media/radio/radio-maxiradio.c
42977 index 5236035..c622c74 100644
42978 --- a/drivers/media/radio/radio-maxiradio.c
42979 +++ b/drivers/media/radio/radio-maxiradio.c
42980 @@ -61,7 +61,7 @@ MODULE_PARM_DESC(radio_nr, "Radio device number");
42981 /* TEA5757 pin mappings */
42982 static const int clk = 1, data = 2, wren = 4, mo_st = 8, power = 16;
42983
42984 -static atomic_t maxiradio_instance = ATOMIC_INIT(0);
42985 +static atomic_unchecked_t maxiradio_instance = ATOMIC_INIT(0);
42986
42987 #define PCI_VENDOR_ID_GUILLEMOT 0x5046
42988 #define PCI_DEVICE_ID_GUILLEMOT_MAXIRADIO 0x1001
42989 diff --git a/drivers/media/radio/radio-shark.c b/drivers/media/radio/radio-shark.c
42990 index b914772..7ddbf9b 100644
42991 --- a/drivers/media/radio/radio-shark.c
42992 +++ b/drivers/media/radio/radio-shark.c
42993 @@ -79,7 +79,7 @@ struct shark_device {
42994 u32 last_val;
42995 };
42996
42997 -static atomic_t shark_instance = ATOMIC_INIT(0);
42998 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
42999
43000 static void shark_write_val(struct snd_tea575x *tea, u32 val)
43001 {
43002 diff --git a/drivers/media/radio/radio-shark2.c b/drivers/media/radio/radio-shark2.c
43003 index 9fb6697..f167415 100644
43004 --- a/drivers/media/radio/radio-shark2.c
43005 +++ b/drivers/media/radio/radio-shark2.c
43006 @@ -74,7 +74,7 @@ struct shark_device {
43007 u8 *transfer_buffer;
43008 };
43009
43010 -static atomic_t shark_instance = ATOMIC_INIT(0);
43011 +static atomic_unchecked_t shark_instance = ATOMIC_INIT(0);
43012
43013 static int shark_write_reg(struct radio_tea5777 *tea, u64 reg)
43014 {
43015 diff --git a/drivers/media/radio/radio-si476x.c b/drivers/media/radio/radio-si476x.c
43016 index 9c9084c..a9e8dfb 100644
43017 --- a/drivers/media/radio/radio-si476x.c
43018 +++ b/drivers/media/radio/radio-si476x.c
43019 @@ -1445,7 +1445,7 @@ static int si476x_radio_probe(struct platform_device *pdev)
43020 struct si476x_radio *radio;
43021 struct v4l2_ctrl *ctrl;
43022
43023 - static atomic_t instance = ATOMIC_INIT(0);
43024 + static atomic_unchecked_t instance = ATOMIC_INIT(0);
43025
43026 radio = devm_kzalloc(&pdev->dev, sizeof(*radio), GFP_KERNEL);
43027 if (!radio)
43028 diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
43029 index 46da365..3ba4206 100644
43030 --- a/drivers/media/rc/rc-main.c
43031 +++ b/drivers/media/rc/rc-main.c
43032 @@ -1065,7 +1065,7 @@ EXPORT_SYMBOL_GPL(rc_free_device);
43033 int rc_register_device(struct rc_dev *dev)
43034 {
43035 static bool raw_init = false; /* raw decoders loaded? */
43036 - static atomic_t devno = ATOMIC_INIT(0);
43037 + static atomic_unchecked_t devno = ATOMIC_INIT(0);
43038 struct rc_map *rc_map;
43039 const char *path;
43040 int rc;
43041 @@ -1096,7 +1096,7 @@ int rc_register_device(struct rc_dev *dev)
43042 */
43043 mutex_lock(&dev->lock);
43044
43045 - dev->devno = (unsigned long)(atomic_inc_return(&devno) - 1);
43046 + dev->devno = (unsigned long)(atomic_inc_return_unchecked(&devno) - 1);
43047 dev_set_name(&dev->dev, "rc%ld", dev->devno);
43048 dev_set_drvdata(&dev->dev, dev);
43049 rc = device_add(&dev->dev);
43050 diff --git a/drivers/media/usb/dvb-usb/cxusb.c b/drivers/media/usb/dvb-usb/cxusb.c
43051 index 20e345d..da56fe4 100644
43052 --- a/drivers/media/usb/dvb-usb/cxusb.c
43053 +++ b/drivers/media/usb/dvb-usb/cxusb.c
43054 @@ -1101,7 +1101,7 @@ static struct dib0070_config dib7070p_dib0070_config = {
43055
43056 struct dib0700_adapter_state {
43057 int (*set_param_save) (struct dvb_frontend *);
43058 -};
43059 +} __no_const;
43060
43061 static int dib7070_set_param_override(struct dvb_frontend *fe)
43062 {
43063 diff --git a/drivers/media/usb/dvb-usb/dw2102.c b/drivers/media/usb/dvb-usb/dw2102.c
43064 index 71b22f5..a63b33f 100644
43065 --- a/drivers/media/usb/dvb-usb/dw2102.c
43066 +++ b/drivers/media/usb/dvb-usb/dw2102.c
43067 @@ -121,7 +121,7 @@ struct su3000_state {
43068
43069 struct s6x0_state {
43070 int (*old_set_voltage)(struct dvb_frontend *f, fe_sec_voltage_t v);
43071 -};
43072 +} __no_const;
43073
43074 /* debug */
43075 static int dvb_usb_dw2102_debug;
43076 diff --git a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43077 index 8f7a6a4..59502dd 100644
43078 --- a/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43079 +++ b/drivers/media/v4l2-core/v4l2-compat-ioctl32.c
43080 @@ -326,7 +326,7 @@ struct v4l2_buffer32 {
43081 __u32 reserved;
43082 };
43083
43084 -static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43085 +static int get_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43086 enum v4l2_memory memory)
43087 {
43088 void __user *up_pln;
43089 @@ -355,7 +355,7 @@ static int get_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43090 return 0;
43091 }
43092
43093 -static int put_v4l2_plane32(struct v4l2_plane *up, struct v4l2_plane32 *up32,
43094 +static int put_v4l2_plane32(struct v4l2_plane __user *up, struct v4l2_plane32 __user *up32,
43095 enum v4l2_memory memory)
43096 {
43097 if (copy_in_user(up32, up, 2 * sizeof(__u32)) ||
43098 @@ -772,7 +772,7 @@ static int put_v4l2_subdev_edid32(struct v4l2_subdev_edid *kp, struct v4l2_subde
43099 put_user(kp->start_block, &up->start_block) ||
43100 put_user(kp->blocks, &up->blocks) ||
43101 put_user(tmp, &up->edid) ||
43102 - copy_to_user(kp->reserved, up->reserved, sizeof(kp->reserved)))
43103 + copy_to_user(up->reserved, kp->reserved, sizeof(kp->reserved)))
43104 return -EFAULT;
43105 return 0;
43106 }
43107 diff --git a/drivers/media/v4l2-core/v4l2-device.c b/drivers/media/v4l2-core/v4l2-device.c
43108 index 02d1b63..5fd6b16 100644
43109 --- a/drivers/media/v4l2-core/v4l2-device.c
43110 +++ b/drivers/media/v4l2-core/v4l2-device.c
43111 @@ -75,9 +75,9 @@ int v4l2_device_put(struct v4l2_device *v4l2_dev)
43112 EXPORT_SYMBOL_GPL(v4l2_device_put);
43113
43114 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
43115 - atomic_t *instance)
43116 + atomic_unchecked_t *instance)
43117 {
43118 - int num = atomic_inc_return(instance) - 1;
43119 + int num = atomic_inc_return_unchecked(instance) - 1;
43120 int len = strlen(basename);
43121
43122 if (basename[len - 1] >= '0' && basename[len - 1] <= '9')
43123 diff --git a/drivers/media/v4l2-core/v4l2-ioctl.c b/drivers/media/v4l2-core/v4l2-ioctl.c
43124 index 68e6b5e..d8b923e 100644
43125 --- a/drivers/media/v4l2-core/v4l2-ioctl.c
43126 +++ b/drivers/media/v4l2-core/v4l2-ioctl.c
43127 @@ -1939,7 +1939,8 @@ struct v4l2_ioctl_info {
43128 struct file *file, void *fh, void *p);
43129 } u;
43130 void (*debug)(const void *arg, bool write_only);
43131 -};
43132 +} __do_const;
43133 +typedef struct v4l2_ioctl_info __no_const v4l2_ioctl_info_no_const;
43134
43135 /* This control needs a priority check */
43136 #define INFO_FL_PRIO (1 << 0)
43137 @@ -2120,7 +2121,7 @@ static long __video_do_ioctl(struct file *file,
43138 struct video_device *vfd = video_devdata(file);
43139 const struct v4l2_ioctl_ops *ops = vfd->ioctl_ops;
43140 bool write_only = false;
43141 - struct v4l2_ioctl_info default_info;
43142 + v4l2_ioctl_info_no_const default_info;
43143 const struct v4l2_ioctl_info *info;
43144 void *fh = file->private_data;
43145 struct v4l2_fh *vfh = NULL;
43146 @@ -2194,7 +2195,7 @@ done:
43147 }
43148
43149 static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43150 - void * __user *user_ptr, void ***kernel_ptr)
43151 + void __user **user_ptr, void ***kernel_ptr)
43152 {
43153 int ret = 0;
43154
43155 @@ -2210,7 +2211,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43156 ret = -EINVAL;
43157 break;
43158 }
43159 - *user_ptr = (void __user *)buf->m.planes;
43160 + *user_ptr = (void __force_user *)buf->m.planes;
43161 *kernel_ptr = (void *)&buf->m.planes;
43162 *array_size = sizeof(struct v4l2_plane) * buf->length;
43163 ret = 1;
43164 @@ -2245,7 +2246,7 @@ static int check_array_args(unsigned int cmd, void *parg, size_t *array_size,
43165 ret = -EINVAL;
43166 break;
43167 }
43168 - *user_ptr = (void __user *)ctrls->controls;
43169 + *user_ptr = (void __force_user *)ctrls->controls;
43170 *kernel_ptr = (void *)&ctrls->controls;
43171 *array_size = sizeof(struct v4l2_ext_control)
43172 * ctrls->count;
43173 diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
43174 index 767ff4d..c69d259 100644
43175 --- a/drivers/message/fusion/mptbase.c
43176 +++ b/drivers/message/fusion/mptbase.c
43177 @@ -6755,8 +6755,13 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43178 seq_printf(m, " MaxChainDepth = 0x%02x frames\n", ioc->facts.MaxChainDepth);
43179 seq_printf(m, " MinBlockSize = 0x%02x bytes\n", 4*ioc->facts.BlockSize);
43180
43181 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43182 + seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n", NULL, NULL);
43183 +#else
43184 seq_printf(m, " RequestFrames @ 0x%p (Dma @ 0x%p)\n",
43185 (void *)ioc->req_frames, (void *)(ulong)ioc->req_frames_dma);
43186 +#endif
43187 +
43188 /*
43189 * Rounding UP to nearest 4-kB boundary here...
43190 */
43191 @@ -6769,7 +6774,11 @@ static int mpt_iocinfo_proc_show(struct seq_file *m, void *v)
43192 ioc->facts.GlobalCredits);
43193
43194 seq_printf(m, " Frames @ 0x%p (Dma @ 0x%p)\n",
43195 +#ifdef CONFIG_GRKERNSEC_HIDESYM
43196 + NULL, NULL);
43197 +#else
43198 (void *)ioc->alloc, (void *)(ulong)ioc->alloc_dma);
43199 +#endif
43200 sz = (ioc->reply_sz * ioc->reply_depth) + 128;
43201 seq_printf(m, " {CurRepSz=%d} x {CurRepDepth=%d} = %d bytes ^= 0x%x\n",
43202 ioc->reply_sz, ioc->reply_depth, ioc->reply_sz*ioc->reply_depth, sz);
43203 diff --git a/drivers/message/fusion/mptsas.c b/drivers/message/fusion/mptsas.c
43204 index dd239bd..689c4f7 100644
43205 --- a/drivers/message/fusion/mptsas.c
43206 +++ b/drivers/message/fusion/mptsas.c
43207 @@ -446,6 +446,23 @@ mptsas_is_end_device(struct mptsas_devinfo * attached)
43208 return 0;
43209 }
43210
43211 +static inline void
43212 +mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43213 +{
43214 + if (phy_info->port_details) {
43215 + phy_info->port_details->rphy = rphy;
43216 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43217 + ioc->name, rphy));
43218 + }
43219 +
43220 + if (rphy) {
43221 + dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43222 + &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43223 + dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43224 + ioc->name, rphy, rphy->dev.release));
43225 + }
43226 +}
43227 +
43228 /* no mutex */
43229 static void
43230 mptsas_port_delete(MPT_ADAPTER *ioc, struct mptsas_portinfo_details * port_details)
43231 @@ -484,23 +501,6 @@ mptsas_get_rphy(struct mptsas_phyinfo *phy_info)
43232 return NULL;
43233 }
43234
43235 -static inline void
43236 -mptsas_set_rphy(MPT_ADAPTER *ioc, struct mptsas_phyinfo *phy_info, struct sas_rphy *rphy)
43237 -{
43238 - if (phy_info->port_details) {
43239 - phy_info->port_details->rphy = rphy;
43240 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "sas_rphy_add: rphy=%p\n",
43241 - ioc->name, rphy));
43242 - }
43243 -
43244 - if (rphy) {
43245 - dsaswideprintk(ioc, dev_printk(KERN_DEBUG,
43246 - &rphy->dev, MYIOC_s_FMT "add:", ioc->name));
43247 - dsaswideprintk(ioc, printk(MYIOC_s_DEBUG_FMT "rphy=%p release=%p\n",
43248 - ioc->name, rphy, rphy->dev.release));
43249 - }
43250 -}
43251 -
43252 static inline struct sas_port *
43253 mptsas_get_port(struct mptsas_phyinfo *phy_info)
43254 {
43255 diff --git a/drivers/message/fusion/mptscsih.c b/drivers/message/fusion/mptscsih.c
43256 index 727819c..ad74694 100644
43257 --- a/drivers/message/fusion/mptscsih.c
43258 +++ b/drivers/message/fusion/mptscsih.c
43259 @@ -1271,15 +1271,16 @@ mptscsih_info(struct Scsi_Host *SChost)
43260
43261 h = shost_priv(SChost);
43262
43263 - if (h) {
43264 - if (h->info_kbuf == NULL)
43265 - if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43266 - return h->info_kbuf;
43267 - h->info_kbuf[0] = '\0';
43268 + if (!h)
43269 + return NULL;
43270
43271 - mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43272 - h->info_kbuf[size-1] = '\0';
43273 - }
43274 + if (h->info_kbuf == NULL)
43275 + if ((h->info_kbuf = kmalloc(0x1000 /* 4Kb */, GFP_KERNEL)) == NULL)
43276 + return h->info_kbuf;
43277 + h->info_kbuf[0] = '\0';
43278 +
43279 + mpt_print_ioc_summary(h->ioc, h->info_kbuf, &size, 0, 0);
43280 + h->info_kbuf[size-1] = '\0';
43281
43282 return h->info_kbuf;
43283 }
43284 diff --git a/drivers/message/i2o/i2o_proc.c b/drivers/message/i2o/i2o_proc.c
43285 index b7d87cd..3fb36da 100644
43286 --- a/drivers/message/i2o/i2o_proc.c
43287 +++ b/drivers/message/i2o/i2o_proc.c
43288 @@ -255,12 +255,6 @@ static char *scsi_devices[] = {
43289 "Array Controller Device"
43290 };
43291
43292 -static char *chtostr(char *tmp, u8 *chars, int n)
43293 -{
43294 - tmp[0] = 0;
43295 - return strncat(tmp, (char *)chars, n);
43296 -}
43297 -
43298 static int i2o_report_query_status(struct seq_file *seq, int block_status,
43299 char *group)
43300 {
43301 @@ -707,9 +701,9 @@ static int i2o_seq_show_status(struct seq_file *seq, void *v)
43302 static int i2o_seq_show_hw(struct seq_file *seq, void *v)
43303 {
43304 struct i2o_controller *c = (struct i2o_controller *)seq->private;
43305 - static u32 work32[5];
43306 - static u8 *work8 = (u8 *) work32;
43307 - static u16 *work16 = (u16 *) work32;
43308 + u32 work32[5];
43309 + u8 *work8 = (u8 *) work32;
43310 + u16 *work16 = (u16 *) work32;
43311 int token;
43312 u32 hwcap;
43313
43314 @@ -790,7 +784,6 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43315 } *result;
43316
43317 i2o_exec_execute_ddm_table ddm_table;
43318 - char tmp[28 + 1];
43319
43320 result = kmalloc(sizeof(*result), GFP_KERNEL);
43321 if (!result)
43322 @@ -825,8 +818,7 @@ static int i2o_seq_show_ddm_table(struct seq_file *seq, void *v)
43323
43324 seq_printf(seq, "%-#7x", ddm_table.i2o_vendor_id);
43325 seq_printf(seq, "%-#8x", ddm_table.module_id);
43326 - seq_printf(seq, "%-29s",
43327 - chtostr(tmp, ddm_table.module_name_version, 28));
43328 + seq_printf(seq, "%-.28s", ddm_table.module_name_version);
43329 seq_printf(seq, "%9d ", ddm_table.data_size);
43330 seq_printf(seq, "%8d", ddm_table.code_size);
43331
43332 @@ -893,7 +885,6 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43333
43334 i2o_driver_result_table *result;
43335 i2o_driver_store_table *dst;
43336 - char tmp[28 + 1];
43337
43338 result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);
43339 if (result == NULL)
43340 @@ -928,9 +919,8 @@ static int i2o_seq_show_drivers_stored(struct seq_file *seq, void *v)
43341
43342 seq_printf(seq, "%-#7x", dst->i2o_vendor_id);
43343 seq_printf(seq, "%-#8x", dst->module_id);
43344 - seq_printf(seq, "%-29s",
43345 - chtostr(tmp, dst->module_name_version, 28));
43346 - seq_printf(seq, "%-9s", chtostr(tmp, dst->date, 8));
43347 + seq_printf(seq, "%-.28s", dst->module_name_version);
43348 + seq_printf(seq, "%-.8s", dst->date);
43349 seq_printf(seq, "%8d ", dst->module_size);
43350 seq_printf(seq, "%8d ", dst->mpb_size);
43351 seq_printf(seq, "0x%04x", dst->module_flags);
43352 @@ -1246,11 +1236,10 @@ static int i2o_seq_show_authorized_users(struct seq_file *seq, void *v)
43353 static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43354 {
43355 struct i2o_device *d = (struct i2o_device *)seq->private;
43356 - static u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43357 + u32 work32[128]; // allow for "stuff" + up to 256 byte (max) serial number
43358 // == (allow) 512d bytes (max)
43359 - static u16 *work16 = (u16 *) work32;
43360 + u16 *work16 = (u16 *) work32;
43361 int token;
43362 - char tmp[16 + 1];
43363
43364 token = i2o_parm_field_get(d, 0xF100, -1, &work32, sizeof(work32));
43365
43366 @@ -1262,14 +1251,10 @@ static int i2o_seq_show_dev_identity(struct seq_file *seq, void *v)
43367 seq_printf(seq, "Device Class : %s\n", i2o_get_class_name(work16[0]));
43368 seq_printf(seq, "Owner TID : %0#5x\n", work16[2]);
43369 seq_printf(seq, "Parent TID : %0#5x\n", work16[3]);
43370 - seq_printf(seq, "Vendor info : %s\n",
43371 - chtostr(tmp, (u8 *) (work32 + 2), 16));
43372 - seq_printf(seq, "Product info : %s\n",
43373 - chtostr(tmp, (u8 *) (work32 + 6), 16));
43374 - seq_printf(seq, "Description : %s\n",
43375 - chtostr(tmp, (u8 *) (work32 + 10), 16));
43376 - seq_printf(seq, "Product rev. : %s\n",
43377 - chtostr(tmp, (u8 *) (work32 + 14), 8));
43378 + seq_printf(seq, "Vendor info : %.16s\n", (u8 *) (work32 + 2));
43379 + seq_printf(seq, "Product info : %.16s\n", (u8 *) (work32 + 6));
43380 + seq_printf(seq, "Description : %.16s\n", (u8 *) (work32 + 10));
43381 + seq_printf(seq, "Product rev. : %.8s\n", (u8 *) (work32 + 14));
43382
43383 seq_printf(seq, "Serial number : ");
43384 print_serial_number(seq, (u8 *) (work32 + 16),
43385 @@ -1306,8 +1291,6 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43386 u8 pad[256]; // allow up to 256 byte (max) serial number
43387 } result;
43388
43389 - char tmp[24 + 1];
43390 -
43391 token = i2o_parm_field_get(d, 0xF101, -1, &result, sizeof(result));
43392
43393 if (token < 0) {
43394 @@ -1316,10 +1299,8 @@ static int i2o_seq_show_ddm_identity(struct seq_file *seq, void *v)
43395 }
43396
43397 seq_printf(seq, "Registering DDM TID : 0x%03x\n", result.ddm_tid);
43398 - seq_printf(seq, "Module name : %s\n",
43399 - chtostr(tmp, result.module_name, 24));
43400 - seq_printf(seq, "Module revision : %s\n",
43401 - chtostr(tmp, result.module_rev, 8));
43402 + seq_printf(seq, "Module name : %.24s\n", result.module_name);
43403 + seq_printf(seq, "Module revision : %.8s\n", result.module_rev);
43404
43405 seq_printf(seq, "Serial number : ");
43406 print_serial_number(seq, result.serial_number, sizeof(result) - 36);
43407 @@ -1343,8 +1324,6 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43408 u8 instance_number[4];
43409 } result;
43410
43411 - char tmp[64 + 1];
43412 -
43413 token = i2o_parm_field_get(d, 0xF102, -1, &result, sizeof(result));
43414
43415 if (token < 0) {
43416 @@ -1352,14 +1331,10 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43417 return 0;
43418 }
43419
43420 - seq_printf(seq, "Device name : %s\n",
43421 - chtostr(tmp, result.device_name, 64));
43422 - seq_printf(seq, "Service name : %s\n",
43423 - chtostr(tmp, result.service_name, 64));
43424 - seq_printf(seq, "Physical name : %s\n",
43425 - chtostr(tmp, result.physical_location, 64));
43426 - seq_printf(seq, "Instance number : %s\n",
43427 - chtostr(tmp, result.instance_number, 4));
43428 + seq_printf(seq, "Device name : %.64s\n", result.device_name);
43429 + seq_printf(seq, "Service name : %.64s\n", result.service_name);
43430 + seq_printf(seq, "Physical name : %.64s\n", result.physical_location);
43431 + seq_printf(seq, "Instance number : %.4s\n", result.instance_number);
43432
43433 return 0;
43434 }
43435 @@ -1368,9 +1343,9 @@ static int i2o_seq_show_uinfo(struct seq_file *seq, void *v)
43436 static int i2o_seq_show_sgl_limits(struct seq_file *seq, void *v)
43437 {
43438 struct i2o_device *d = (struct i2o_device *)seq->private;
43439 - static u32 work32[12];
43440 - static u16 *work16 = (u16 *) work32;
43441 - static u8 *work8 = (u8 *) work32;
43442 + u32 work32[12];
43443 + u16 *work16 = (u16 *) work32;
43444 + u8 *work8 = (u8 *) work32;
43445 int token;
43446
43447 token = i2o_parm_field_get(d, 0xF103, -1, &work32, sizeof(work32));
43448 diff --git a/drivers/message/i2o/iop.c b/drivers/message/i2o/iop.c
43449 index a8c08f3..155fe3d 100644
43450 --- a/drivers/message/i2o/iop.c
43451 +++ b/drivers/message/i2o/iop.c
43452 @@ -111,10 +111,10 @@ u32 i2o_cntxt_list_add(struct i2o_controller * c, void *ptr)
43453
43454 spin_lock_irqsave(&c->context_list_lock, flags);
43455
43456 - if (unlikely(atomic_inc_and_test(&c->context_list_counter)))
43457 - atomic_inc(&c->context_list_counter);
43458 + if (unlikely(atomic_inc_and_test_unchecked(&c->context_list_counter)))
43459 + atomic_inc_unchecked(&c->context_list_counter);
43460
43461 - entry->context = atomic_read(&c->context_list_counter);
43462 + entry->context = atomic_read_unchecked(&c->context_list_counter);
43463
43464 list_add(&entry->list, &c->context_list);
43465
43466 @@ -1077,7 +1077,7 @@ struct i2o_controller *i2o_iop_alloc(void)
43467
43468 #if BITS_PER_LONG == 64
43469 spin_lock_init(&c->context_list_lock);
43470 - atomic_set(&c->context_list_counter, 0);
43471 + atomic_set_unchecked(&c->context_list_counter, 0);
43472 INIT_LIST_HEAD(&c->context_list);
43473 #endif
43474
43475 diff --git a/drivers/mfd/janz-cmodio.c b/drivers/mfd/janz-cmodio.c
43476 index fcbb2e9..2635e11 100644
43477 --- a/drivers/mfd/janz-cmodio.c
43478 +++ b/drivers/mfd/janz-cmodio.c
43479 @@ -13,6 +13,7 @@
43480
43481 #include <linux/kernel.h>
43482 #include <linux/module.h>
43483 +#include <linux/slab.h>
43484 #include <linux/init.h>
43485 #include <linux/pci.h>
43486 #include <linux/interrupt.h>
43487 diff --git a/drivers/mfd/max8925-i2c.c b/drivers/mfd/max8925-i2c.c
43488 index de7fb80..7c1b931 100644
43489 --- a/drivers/mfd/max8925-i2c.c
43490 +++ b/drivers/mfd/max8925-i2c.c
43491 @@ -152,7 +152,7 @@ static int max8925_probe(struct i2c_client *client,
43492 const struct i2c_device_id *id)
43493 {
43494 struct max8925_platform_data *pdata = dev_get_platdata(&client->dev);
43495 - static struct max8925_chip *chip;
43496 + struct max8925_chip *chip;
43497 struct device_node *node = client->dev.of_node;
43498
43499 if (node && !pdata) {
43500 diff --git a/drivers/mfd/tps65910.c b/drivers/mfd/tps65910.c
43501 index d792772..cd73ba3 100644
43502 --- a/drivers/mfd/tps65910.c
43503 +++ b/drivers/mfd/tps65910.c
43504 @@ -229,7 +229,7 @@ static int tps65910_irq_init(struct tps65910 *tps65910, int irq,
43505 struct tps65910_platform_data *pdata)
43506 {
43507 int ret = 0;
43508 - static struct regmap_irq_chip *tps6591x_irqs_chip;
43509 + struct regmap_irq_chip *tps6591x_irqs_chip;
43510
43511 if (!irq) {
43512 dev_warn(tps65910->dev, "No interrupt support, no core IRQ\n");
43513 diff --git a/drivers/mfd/twl4030-irq.c b/drivers/mfd/twl4030-irq.c
43514 index 9aa6d1e..1631bfc 100644
43515 --- a/drivers/mfd/twl4030-irq.c
43516 +++ b/drivers/mfd/twl4030-irq.c
43517 @@ -35,6 +35,7 @@
43518 #include <linux/of.h>
43519 #include <linux/irqdomain.h>
43520 #include <linux/i2c/twl.h>
43521 +#include <asm/pgtable.h>
43522
43523 #include "twl-core.h"
43524
43525 @@ -726,10 +727,12 @@ int twl4030_init_irq(struct device *dev, int irq_num)
43526 * Install an irq handler for each of the SIH modules;
43527 * clone dummy irq_chip since PIH can't *do* anything
43528 */
43529 - twl4030_irq_chip = dummy_irq_chip;
43530 - twl4030_irq_chip.name = "twl4030";
43531 + pax_open_kernel();
43532 + memcpy((void *)&twl4030_irq_chip, &dummy_irq_chip, sizeof twl4030_irq_chip);
43533 + *(const char **)&twl4030_irq_chip.name = "twl4030";
43534
43535 - twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43536 + *(void **)&twl4030_sih_irq_chip.irq_ack = dummy_irq_chip.irq_ack;
43537 + pax_close_kernel();
43538
43539 for (i = irq_base; i < irq_end; i++) {
43540 irq_set_chip_and_handler(i, &twl4030_irq_chip,
43541 diff --git a/drivers/misc/c2port/core.c b/drivers/misc/c2port/core.c
43542 index 464419b..64bae8d 100644
43543 --- a/drivers/misc/c2port/core.c
43544 +++ b/drivers/misc/c2port/core.c
43545 @@ -922,7 +922,9 @@ struct c2port_device *c2port_device_register(char *name,
43546 goto error_idr_alloc;
43547 c2dev->id = ret;
43548
43549 - bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43550 + pax_open_kernel();
43551 + *(size_t *)&bin_attr_flash_data.size = ops->blocks_num * ops->block_size;
43552 + pax_close_kernel();
43553
43554 c2dev->dev = device_create(c2port_class, NULL, 0, c2dev,
43555 "c2port%d", c2dev->id);
43556 diff --git a/drivers/misc/kgdbts.c b/drivers/misc/kgdbts.c
43557 index 36f5d52..32311c3 100644
43558 --- a/drivers/misc/kgdbts.c
43559 +++ b/drivers/misc/kgdbts.c
43560 @@ -834,7 +834,7 @@ static void run_plant_and_detach_test(int is_early)
43561 char before[BREAK_INSTR_SIZE];
43562 char after[BREAK_INSTR_SIZE];
43563
43564 - probe_kernel_read(before, (char *)kgdbts_break_test,
43565 + probe_kernel_read(before, ktla_ktva((char *)kgdbts_break_test),
43566 BREAK_INSTR_SIZE);
43567 init_simple_test();
43568 ts.tst = plant_and_detach_test;
43569 @@ -842,7 +842,7 @@ static void run_plant_and_detach_test(int is_early)
43570 /* Activate test with initial breakpoint */
43571 if (!is_early)
43572 kgdb_breakpoint();
43573 - probe_kernel_read(after, (char *)kgdbts_break_test,
43574 + probe_kernel_read(after, ktla_ktva((char *)kgdbts_break_test),
43575 BREAK_INSTR_SIZE);
43576 if (memcmp(before, after, BREAK_INSTR_SIZE)) {
43577 printk(KERN_CRIT "kgdbts: ERROR kgdb corrupted memory\n");
43578 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.c b/drivers/misc/lis3lv02d/lis3lv02d.c
43579 index 036effe..b3a6336 100644
43580 --- a/drivers/misc/lis3lv02d/lis3lv02d.c
43581 +++ b/drivers/misc/lis3lv02d/lis3lv02d.c
43582 @@ -498,7 +498,7 @@ static irqreturn_t lis302dl_interrupt(int irq, void *data)
43583 * the lid is closed. This leads to interrupts as soon as a little move
43584 * is done.
43585 */
43586 - atomic_inc(&lis3->count);
43587 + atomic_inc_unchecked(&lis3->count);
43588
43589 wake_up_interruptible(&lis3->misc_wait);
43590 kill_fasync(&lis3->async_queue, SIGIO, POLL_IN);
43591 @@ -584,7 +584,7 @@ static int lis3lv02d_misc_open(struct inode *inode, struct file *file)
43592 if (lis3->pm_dev)
43593 pm_runtime_get_sync(lis3->pm_dev);
43594
43595 - atomic_set(&lis3->count, 0);
43596 + atomic_set_unchecked(&lis3->count, 0);
43597 return 0;
43598 }
43599
43600 @@ -616,7 +616,7 @@ static ssize_t lis3lv02d_misc_read(struct file *file, char __user *buf,
43601 add_wait_queue(&lis3->misc_wait, &wait);
43602 while (true) {
43603 set_current_state(TASK_INTERRUPTIBLE);
43604 - data = atomic_xchg(&lis3->count, 0);
43605 + data = atomic_xchg_unchecked(&lis3->count, 0);
43606 if (data)
43607 break;
43608
43609 @@ -657,7 +657,7 @@ static unsigned int lis3lv02d_misc_poll(struct file *file, poll_table *wait)
43610 struct lis3lv02d, miscdev);
43611
43612 poll_wait(file, &lis3->misc_wait, wait);
43613 - if (atomic_read(&lis3->count))
43614 + if (atomic_read_unchecked(&lis3->count))
43615 return POLLIN | POLLRDNORM;
43616 return 0;
43617 }
43618 diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
43619 index c439c82..1f20f57 100644
43620 --- a/drivers/misc/lis3lv02d/lis3lv02d.h
43621 +++ b/drivers/misc/lis3lv02d/lis3lv02d.h
43622 @@ -297,7 +297,7 @@ struct lis3lv02d {
43623 struct input_polled_dev *idev; /* input device */
43624 struct platform_device *pdev; /* platform device */
43625 struct regulator_bulk_data regulators[2];
43626 - atomic_t count; /* interrupt count after last read */
43627 + atomic_unchecked_t count; /* interrupt count after last read */
43628 union axis_conversion ac; /* hw -> logical axis */
43629 int mapped_btns[3];
43630
43631 diff --git a/drivers/misc/sgi-gru/gruhandles.c b/drivers/misc/sgi-gru/gruhandles.c
43632 index 2f30bad..c4c13d0 100644
43633 --- a/drivers/misc/sgi-gru/gruhandles.c
43634 +++ b/drivers/misc/sgi-gru/gruhandles.c
43635 @@ -44,8 +44,8 @@ static void update_mcs_stats(enum mcs_op op, unsigned long clks)
43636 unsigned long nsec;
43637
43638 nsec = CLKS2NSEC(clks);
43639 - atomic_long_inc(&mcs_op_statistics[op].count);
43640 - atomic_long_add(nsec, &mcs_op_statistics[op].total);
43641 + atomic_long_inc_unchecked(&mcs_op_statistics[op].count);
43642 + atomic_long_add_unchecked(nsec, &mcs_op_statistics[op].total);
43643 if (mcs_op_statistics[op].max < nsec)
43644 mcs_op_statistics[op].max = nsec;
43645 }
43646 diff --git a/drivers/misc/sgi-gru/gruprocfs.c b/drivers/misc/sgi-gru/gruprocfs.c
43647 index 4f76359..cdfcb2e 100644
43648 --- a/drivers/misc/sgi-gru/gruprocfs.c
43649 +++ b/drivers/misc/sgi-gru/gruprocfs.c
43650 @@ -32,9 +32,9 @@
43651
43652 #define printstat(s, f) printstat_val(s, &gru_stats.f, #f)
43653
43654 -static void printstat_val(struct seq_file *s, atomic_long_t *v, char *id)
43655 +static void printstat_val(struct seq_file *s, atomic_long_unchecked_t *v, char *id)
43656 {
43657 - unsigned long val = atomic_long_read(v);
43658 + unsigned long val = atomic_long_read_unchecked(v);
43659
43660 seq_printf(s, "%16lu %s\n", val, id);
43661 }
43662 @@ -134,8 +134,8 @@ static int mcs_statistics_show(struct seq_file *s, void *p)
43663
43664 seq_printf(s, "%-20s%12s%12s%12s\n", "#id", "count", "aver-clks", "max-clks");
43665 for (op = 0; op < mcsop_last; op++) {
43666 - count = atomic_long_read(&mcs_op_statistics[op].count);
43667 - total = atomic_long_read(&mcs_op_statistics[op].total);
43668 + count = atomic_long_read_unchecked(&mcs_op_statistics[op].count);
43669 + total = atomic_long_read_unchecked(&mcs_op_statistics[op].total);
43670 max = mcs_op_statistics[op].max;
43671 seq_printf(s, "%-20s%12ld%12ld%12ld\n", id[op], count,
43672 count ? total / count : 0, max);
43673 diff --git a/drivers/misc/sgi-gru/grutables.h b/drivers/misc/sgi-gru/grutables.h
43674 index 5c3ce24..4915ccb 100644
43675 --- a/drivers/misc/sgi-gru/grutables.h
43676 +++ b/drivers/misc/sgi-gru/grutables.h
43677 @@ -167,82 +167,82 @@ extern unsigned int gru_max_gids;
43678 * GRU statistics.
43679 */
43680 struct gru_stats_s {
43681 - atomic_long_t vdata_alloc;
43682 - atomic_long_t vdata_free;
43683 - atomic_long_t gts_alloc;
43684 - atomic_long_t gts_free;
43685 - atomic_long_t gms_alloc;
43686 - atomic_long_t gms_free;
43687 - atomic_long_t gts_double_allocate;
43688 - atomic_long_t assign_context;
43689 - atomic_long_t assign_context_failed;
43690 - atomic_long_t free_context;
43691 - atomic_long_t load_user_context;
43692 - atomic_long_t load_kernel_context;
43693 - atomic_long_t lock_kernel_context;
43694 - atomic_long_t unlock_kernel_context;
43695 - atomic_long_t steal_user_context;
43696 - atomic_long_t steal_kernel_context;
43697 - atomic_long_t steal_context_failed;
43698 - atomic_long_t nopfn;
43699 - atomic_long_t asid_new;
43700 - atomic_long_t asid_next;
43701 - atomic_long_t asid_wrap;
43702 - atomic_long_t asid_reuse;
43703 - atomic_long_t intr;
43704 - atomic_long_t intr_cbr;
43705 - atomic_long_t intr_tfh;
43706 - atomic_long_t intr_spurious;
43707 - atomic_long_t intr_mm_lock_failed;
43708 - atomic_long_t call_os;
43709 - atomic_long_t call_os_wait_queue;
43710 - atomic_long_t user_flush_tlb;
43711 - atomic_long_t user_unload_context;
43712 - atomic_long_t user_exception;
43713 - atomic_long_t set_context_option;
43714 - atomic_long_t check_context_retarget_intr;
43715 - atomic_long_t check_context_unload;
43716 - atomic_long_t tlb_dropin;
43717 - atomic_long_t tlb_preload_page;
43718 - atomic_long_t tlb_dropin_fail_no_asid;
43719 - atomic_long_t tlb_dropin_fail_upm;
43720 - atomic_long_t tlb_dropin_fail_invalid;
43721 - atomic_long_t tlb_dropin_fail_range_active;
43722 - atomic_long_t tlb_dropin_fail_idle;
43723 - atomic_long_t tlb_dropin_fail_fmm;
43724 - atomic_long_t tlb_dropin_fail_no_exception;
43725 - atomic_long_t tfh_stale_on_fault;
43726 - atomic_long_t mmu_invalidate_range;
43727 - atomic_long_t mmu_invalidate_page;
43728 - atomic_long_t flush_tlb;
43729 - atomic_long_t flush_tlb_gru;
43730 - atomic_long_t flush_tlb_gru_tgh;
43731 - atomic_long_t flush_tlb_gru_zero_asid;
43732 + atomic_long_unchecked_t vdata_alloc;
43733 + atomic_long_unchecked_t vdata_free;
43734 + atomic_long_unchecked_t gts_alloc;
43735 + atomic_long_unchecked_t gts_free;
43736 + atomic_long_unchecked_t gms_alloc;
43737 + atomic_long_unchecked_t gms_free;
43738 + atomic_long_unchecked_t gts_double_allocate;
43739 + atomic_long_unchecked_t assign_context;
43740 + atomic_long_unchecked_t assign_context_failed;
43741 + atomic_long_unchecked_t free_context;
43742 + atomic_long_unchecked_t load_user_context;
43743 + atomic_long_unchecked_t load_kernel_context;
43744 + atomic_long_unchecked_t lock_kernel_context;
43745 + atomic_long_unchecked_t unlock_kernel_context;
43746 + atomic_long_unchecked_t steal_user_context;
43747 + atomic_long_unchecked_t steal_kernel_context;
43748 + atomic_long_unchecked_t steal_context_failed;
43749 + atomic_long_unchecked_t nopfn;
43750 + atomic_long_unchecked_t asid_new;
43751 + atomic_long_unchecked_t asid_next;
43752 + atomic_long_unchecked_t asid_wrap;
43753 + atomic_long_unchecked_t asid_reuse;
43754 + atomic_long_unchecked_t intr;
43755 + atomic_long_unchecked_t intr_cbr;
43756 + atomic_long_unchecked_t intr_tfh;
43757 + atomic_long_unchecked_t intr_spurious;
43758 + atomic_long_unchecked_t intr_mm_lock_failed;
43759 + atomic_long_unchecked_t call_os;
43760 + atomic_long_unchecked_t call_os_wait_queue;
43761 + atomic_long_unchecked_t user_flush_tlb;
43762 + atomic_long_unchecked_t user_unload_context;
43763 + atomic_long_unchecked_t user_exception;
43764 + atomic_long_unchecked_t set_context_option;
43765 + atomic_long_unchecked_t check_context_retarget_intr;
43766 + atomic_long_unchecked_t check_context_unload;
43767 + atomic_long_unchecked_t tlb_dropin;
43768 + atomic_long_unchecked_t tlb_preload_page;
43769 + atomic_long_unchecked_t tlb_dropin_fail_no_asid;
43770 + atomic_long_unchecked_t tlb_dropin_fail_upm;
43771 + atomic_long_unchecked_t tlb_dropin_fail_invalid;
43772 + atomic_long_unchecked_t tlb_dropin_fail_range_active;
43773 + atomic_long_unchecked_t tlb_dropin_fail_idle;
43774 + atomic_long_unchecked_t tlb_dropin_fail_fmm;
43775 + atomic_long_unchecked_t tlb_dropin_fail_no_exception;
43776 + atomic_long_unchecked_t tfh_stale_on_fault;
43777 + atomic_long_unchecked_t mmu_invalidate_range;
43778 + atomic_long_unchecked_t mmu_invalidate_page;
43779 + atomic_long_unchecked_t flush_tlb;
43780 + atomic_long_unchecked_t flush_tlb_gru;
43781 + atomic_long_unchecked_t flush_tlb_gru_tgh;
43782 + atomic_long_unchecked_t flush_tlb_gru_zero_asid;
43783
43784 - atomic_long_t copy_gpa;
43785 - atomic_long_t read_gpa;
43786 + atomic_long_unchecked_t copy_gpa;
43787 + atomic_long_unchecked_t read_gpa;
43788
43789 - atomic_long_t mesq_receive;
43790 - atomic_long_t mesq_receive_none;
43791 - atomic_long_t mesq_send;
43792 - atomic_long_t mesq_send_failed;
43793 - atomic_long_t mesq_noop;
43794 - atomic_long_t mesq_send_unexpected_error;
43795 - atomic_long_t mesq_send_lb_overflow;
43796 - atomic_long_t mesq_send_qlimit_reached;
43797 - atomic_long_t mesq_send_amo_nacked;
43798 - atomic_long_t mesq_send_put_nacked;
43799 - atomic_long_t mesq_page_overflow;
43800 - atomic_long_t mesq_qf_locked;
43801 - atomic_long_t mesq_qf_noop_not_full;
43802 - atomic_long_t mesq_qf_switch_head_failed;
43803 - atomic_long_t mesq_qf_unexpected_error;
43804 - atomic_long_t mesq_noop_unexpected_error;
43805 - atomic_long_t mesq_noop_lb_overflow;
43806 - atomic_long_t mesq_noop_qlimit_reached;
43807 - atomic_long_t mesq_noop_amo_nacked;
43808 - atomic_long_t mesq_noop_put_nacked;
43809 - atomic_long_t mesq_noop_page_overflow;
43810 + atomic_long_unchecked_t mesq_receive;
43811 + atomic_long_unchecked_t mesq_receive_none;
43812 + atomic_long_unchecked_t mesq_send;
43813 + atomic_long_unchecked_t mesq_send_failed;
43814 + atomic_long_unchecked_t mesq_noop;
43815 + atomic_long_unchecked_t mesq_send_unexpected_error;
43816 + atomic_long_unchecked_t mesq_send_lb_overflow;
43817 + atomic_long_unchecked_t mesq_send_qlimit_reached;
43818 + atomic_long_unchecked_t mesq_send_amo_nacked;
43819 + atomic_long_unchecked_t mesq_send_put_nacked;
43820 + atomic_long_unchecked_t mesq_page_overflow;
43821 + atomic_long_unchecked_t mesq_qf_locked;
43822 + atomic_long_unchecked_t mesq_qf_noop_not_full;
43823 + atomic_long_unchecked_t mesq_qf_switch_head_failed;
43824 + atomic_long_unchecked_t mesq_qf_unexpected_error;
43825 + atomic_long_unchecked_t mesq_noop_unexpected_error;
43826 + atomic_long_unchecked_t mesq_noop_lb_overflow;
43827 + atomic_long_unchecked_t mesq_noop_qlimit_reached;
43828 + atomic_long_unchecked_t mesq_noop_amo_nacked;
43829 + atomic_long_unchecked_t mesq_noop_put_nacked;
43830 + atomic_long_unchecked_t mesq_noop_page_overflow;
43831
43832 };
43833
43834 @@ -251,8 +251,8 @@ enum mcs_op {cchop_allocate, cchop_start, cchop_interrupt, cchop_interrupt_sync,
43835 tghop_invalidate, mcsop_last};
43836
43837 struct mcs_op_statistic {
43838 - atomic_long_t count;
43839 - atomic_long_t total;
43840 + atomic_long_unchecked_t count;
43841 + atomic_long_unchecked_t total;
43842 unsigned long max;
43843 };
43844
43845 @@ -275,7 +275,7 @@ extern struct mcs_op_statistic mcs_op_statistics[mcsop_last];
43846
43847 #define STAT(id) do { \
43848 if (gru_options & OPT_STATS) \
43849 - atomic_long_inc(&gru_stats.id); \
43850 + atomic_long_inc_unchecked(&gru_stats.id); \
43851 } while (0)
43852
43853 #ifdef CONFIG_SGI_GRU_DEBUG
43854 diff --git a/drivers/misc/sgi-xp/xp.h b/drivers/misc/sgi-xp/xp.h
43855 index c862cd4..0d176fe 100644
43856 --- a/drivers/misc/sgi-xp/xp.h
43857 +++ b/drivers/misc/sgi-xp/xp.h
43858 @@ -288,7 +288,7 @@ struct xpc_interface {
43859 xpc_notify_func, void *);
43860 void (*received) (short, int, void *);
43861 enum xp_retval (*partid_to_nasids) (short, void *);
43862 -};
43863 +} __no_const;
43864
43865 extern struct xpc_interface xpc_interface;
43866
43867 diff --git a/drivers/misc/sgi-xp/xpc.h b/drivers/misc/sgi-xp/xpc.h
43868 index b94d5f7..7f494c5 100644
43869 --- a/drivers/misc/sgi-xp/xpc.h
43870 +++ b/drivers/misc/sgi-xp/xpc.h
43871 @@ -835,6 +835,7 @@ struct xpc_arch_operations {
43872 void (*received_payload) (struct xpc_channel *, void *);
43873 void (*notify_senders_of_disconnect) (struct xpc_channel *);
43874 };
43875 +typedef struct xpc_arch_operations __no_const xpc_arch_operations_no_const;
43876
43877 /* struct xpc_partition act_state values (for XPC HB) */
43878
43879 @@ -876,7 +877,7 @@ extern struct xpc_registration xpc_registrations[];
43880 /* found in xpc_main.c */
43881 extern struct device *xpc_part;
43882 extern struct device *xpc_chan;
43883 -extern struct xpc_arch_operations xpc_arch_ops;
43884 +extern xpc_arch_operations_no_const xpc_arch_ops;
43885 extern int xpc_disengage_timelimit;
43886 extern int xpc_disengage_timedout;
43887 extern int xpc_activate_IRQ_rcvd;
43888 diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c
43889 index 82dc574..8539ab2 100644
43890 --- a/drivers/misc/sgi-xp/xpc_main.c
43891 +++ b/drivers/misc/sgi-xp/xpc_main.c
43892 @@ -166,7 +166,7 @@ static struct notifier_block xpc_die_notifier = {
43893 .notifier_call = xpc_system_die,
43894 };
43895
43896 -struct xpc_arch_operations xpc_arch_ops;
43897 +xpc_arch_operations_no_const xpc_arch_ops;
43898
43899 /*
43900 * Timer function to enforce the timelimit on the partition disengage.
43901 @@ -1210,7 +1210,7 @@ xpc_system_die(struct notifier_block *nb, unsigned long event, void *_die_args)
43902
43903 if (((die_args->trapnr == X86_TRAP_MF) ||
43904 (die_args->trapnr == X86_TRAP_XF)) &&
43905 - !user_mode_vm(die_args->regs))
43906 + !user_mode(die_args->regs))
43907 xpc_die_deactivate();
43908
43909 break;
43910 diff --git a/drivers/mmc/core/mmc_ops.c b/drivers/mmc/core/mmc_ops.c
43911 index ef18348..1b53cf0 100644
43912 --- a/drivers/mmc/core/mmc_ops.c
43913 +++ b/drivers/mmc/core/mmc_ops.c
43914 @@ -213,7 +213,7 @@ mmc_send_cxd_data(struct mmc_card *card, struct mmc_host *host,
43915 void *data_buf;
43916 int is_on_stack;
43917
43918 - is_on_stack = object_is_on_stack(buf);
43919 + is_on_stack = object_starts_on_stack(buf);
43920 if (is_on_stack) {
43921 /*
43922 * dma onto stack is unsafe/nonportable, but callers to this
43923 diff --git a/drivers/mmc/host/dw_mmc.h b/drivers/mmc/host/dw_mmc.h
43924 index 81b2994..dce857e 100644
43925 --- a/drivers/mmc/host/dw_mmc.h
43926 +++ b/drivers/mmc/host/dw_mmc.h
43927 @@ -203,5 +203,5 @@ struct dw_mci_drv_data {
43928 void (*prepare_command)(struct dw_mci *host, u32 *cmdr);
43929 void (*set_ios)(struct dw_mci *host, struct mmc_ios *ios);
43930 int (*parse_dt)(struct dw_mci *host);
43931 -};
43932 +} __do_const;
43933 #endif /* _DW_MMC_H_ */
43934 diff --git a/drivers/mmc/host/mmci.c b/drivers/mmc/host/mmci.c
43935 index c3785ed..1984c44 100644
43936 --- a/drivers/mmc/host/mmci.c
43937 +++ b/drivers/mmc/host/mmci.c
43938 @@ -1482,7 +1482,9 @@ static int mmci_probe(struct amba_device *dev,
43939 }
43940
43941 if (variant->busy_detect) {
43942 - mmci_ops.card_busy = mmci_card_busy;
43943 + pax_open_kernel();
43944 + *(void **)&mmci_ops.card_busy = mmci_card_busy;
43945 + pax_close_kernel();
43946 mmci_write_datactrlreg(host, MCI_ST_DPSM_BUSYMODE);
43947 }
43948
43949 diff --git a/drivers/mmc/host/sdhci-s3c.c b/drivers/mmc/host/sdhci-s3c.c
43950 index 6debda9..2ba7427 100644
43951 --- a/drivers/mmc/host/sdhci-s3c.c
43952 +++ b/drivers/mmc/host/sdhci-s3c.c
43953 @@ -668,9 +668,11 @@ static int sdhci_s3c_probe(struct platform_device *pdev)
43954 * we can use overriding functions instead of default.
43955 */
43956 if (host->quirks & SDHCI_QUIRK_NONSTANDARD_CLOCK) {
43957 - sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43958 - sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43959 - sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43960 + pax_open_kernel();
43961 + *(void **)&sdhci_s3c_ops.set_clock = sdhci_cmu_set_clock;
43962 + *(void **)&sdhci_s3c_ops.get_min_clock = sdhci_cmu_get_min_clock;
43963 + *(void **)&sdhci_s3c_ops.get_max_clock = sdhci_cmu_get_max_clock;
43964 + pax_close_kernel();
43965 }
43966
43967 /* It supports additional host capabilities if needed */
43968 diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c
43969 index 096993f..f02c23b 100644
43970 --- a/drivers/mtd/chips/cfi_cmdset_0020.c
43971 +++ b/drivers/mtd/chips/cfi_cmdset_0020.c
43972 @@ -669,7 +669,7 @@ cfi_staa_writev(struct mtd_info *mtd, const struct kvec *vecs,
43973 size_t totlen = 0, thislen;
43974 int ret = 0;
43975 size_t buflen = 0;
43976 - static char *buffer;
43977 + char *buffer;
43978
43979 if (!ECCBUF_SIZE) {
43980 /* We should fall back to a general writev implementation.
43981 diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c
43982 index 2ed2bb3..2d0b82e 100644
43983 --- a/drivers/mtd/nand/denali.c
43984 +++ b/drivers/mtd/nand/denali.c
43985 @@ -24,6 +24,7 @@
43986 #include <linux/slab.h>
43987 #include <linux/mtd/mtd.h>
43988 #include <linux/module.h>
43989 +#include <linux/slab.h>
43990
43991 #include "denali.h"
43992
43993 diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
43994 index 51b9d6a..52af9a7 100644
43995 --- a/drivers/mtd/nftlmount.c
43996 +++ b/drivers/mtd/nftlmount.c
43997 @@ -24,6 +24,7 @@
43998 #include <asm/errno.h>
43999 #include <linux/delay.h>
44000 #include <linux/slab.h>
44001 +#include <linux/sched.h>
44002 #include <linux/mtd/mtd.h>
44003 #include <linux/mtd/nand.h>
44004 #include <linux/mtd/nftl.h>
44005 diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c
44006 index 4b8e895..6b3c498 100644
44007 --- a/drivers/mtd/sm_ftl.c
44008 +++ b/drivers/mtd/sm_ftl.c
44009 @@ -56,7 +56,7 @@ static ssize_t sm_attr_show(struct device *dev, struct device_attribute *attr,
44010 #define SM_CIS_VENDOR_OFFSET 0x59
44011 static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl)
44012 {
44013 - struct attribute_group *attr_group;
44014 + attribute_group_no_const *attr_group;
44015 struct attribute **attributes;
44016 struct sm_sysfs_attribute *vendor_attribute;
44017
44018 diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
44019 index dd8057d..22aaf36 100644
44020 --- a/drivers/net/bonding/bond_main.c
44021 +++ b/drivers/net/bonding/bond_main.c
44022 @@ -4511,7 +4511,7 @@ static unsigned int bond_get_num_tx_queues(void)
44023 return tx_queues;
44024 }
44025
44026 -static struct rtnl_link_ops bond_link_ops __read_mostly = {
44027 +static struct rtnl_link_ops bond_link_ops = {
44028 .kind = "bond",
44029 .priv_size = sizeof(struct bonding),
44030 .setup = bond_setup,
44031 @@ -4636,8 +4636,8 @@ static void __exit bonding_exit(void)
44032
44033 bond_destroy_debugfs();
44034
44035 - rtnl_link_unregister(&bond_link_ops);
44036 unregister_pernet_subsys(&bond_net_ops);
44037 + rtnl_link_unregister(&bond_link_ops);
44038
44039 #ifdef CONFIG_NET_POLL_CONTROLLER
44040 /*
44041 diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
44042 index f92f001..0b2f9bf 100644
44043 --- a/drivers/net/ethernet/8390/ax88796.c
44044 +++ b/drivers/net/ethernet/8390/ax88796.c
44045 @@ -872,9 +872,11 @@ static int ax_probe(struct platform_device *pdev)
44046 if (ax->plat->reg_offsets)
44047 ei_local->reg_offset = ax->plat->reg_offsets;
44048 else {
44049 + resource_size_t _mem_size = mem_size;
44050 + do_div(_mem_size, 0x18);
44051 ei_local->reg_offset = ax->reg_offsets;
44052 for (ret = 0; ret < 0x18; ret++)
44053 - ax->reg_offsets[ret] = (mem_size / 0x18) * ret;
44054 + ax->reg_offsets[ret] = _mem_size * ret;
44055 }
44056
44057 if (!request_mem_region(mem->start, mem_size, pdev->name)) {
44058 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44059 index da8fcaa..f4b5d3b 100644
44060 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44061 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
44062 @@ -1138,7 +1138,7 @@ static inline u8 bnx2x_get_path_func_num(struct bnx2x *bp)
44063 static inline void bnx2x_init_bp_objs(struct bnx2x *bp)
44064 {
44065 /* RX_MODE controlling object */
44066 - bnx2x_init_rx_mode_obj(bp, &bp->rx_mode_obj);
44067 + bnx2x_init_rx_mode_obj(bp);
44068
44069 /* multicast configuration controlling object */
44070 bnx2x_init_mcast_obj(bp, &bp->mcast_obj, bp->fp->cl_id, bp->fp->cid,
44071 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44072 index 9fbeee5..5e3e37a 100644
44073 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44074 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.c
44075 @@ -2590,15 +2590,14 @@ int bnx2x_config_rx_mode(struct bnx2x *bp,
44076 return rc;
44077 }
44078
44079 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44080 - struct bnx2x_rx_mode_obj *o)
44081 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp)
44082 {
44083 if (CHIP_IS_E1x(bp)) {
44084 - o->wait_comp = bnx2x_empty_rx_mode_wait;
44085 - o->config_rx_mode = bnx2x_set_rx_mode_e1x;
44086 + bp->rx_mode_obj.wait_comp = bnx2x_empty_rx_mode_wait;
44087 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e1x;
44088 } else {
44089 - o->wait_comp = bnx2x_wait_rx_mode_comp_e2;
44090 - o->config_rx_mode = bnx2x_set_rx_mode_e2;
44091 + bp->rx_mode_obj.wait_comp = bnx2x_wait_rx_mode_comp_e2;
44092 + bp->rx_mode_obj.config_rx_mode = bnx2x_set_rx_mode_e2;
44093 }
44094 }
44095
44096 diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44097 index 658f4e3..15074a6 100644
44098 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44099 +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sp.h
44100 @@ -1325,8 +1325,7 @@ int bnx2x_vlan_mac_move(struct bnx2x *bp,
44101
44102 /********************* RX MODE ****************/
44103
44104 -void bnx2x_init_rx_mode_obj(struct bnx2x *bp,
44105 - struct bnx2x_rx_mode_obj *o);
44106 +void bnx2x_init_rx_mode_obj(struct bnx2x *bp);
44107
44108 /**
44109 * bnx2x_config_rx_mode - Send and RX_MODE ramrod according to the provided parameters.
44110 diff --git a/drivers/net/ethernet/broadcom/tg3.h b/drivers/net/ethernet/broadcom/tg3.h
44111 index 7025780..e55a71c 100644
44112 --- a/drivers/net/ethernet/broadcom/tg3.h
44113 +++ b/drivers/net/ethernet/broadcom/tg3.h
44114 @@ -147,6 +147,7 @@
44115 #define CHIPREV_ID_5750_A0 0x4000
44116 #define CHIPREV_ID_5750_A1 0x4001
44117 #define CHIPREV_ID_5750_A3 0x4003
44118 +#define CHIPREV_ID_5750_C1 0x4201
44119 #define CHIPREV_ID_5750_C2 0x4202
44120 #define CHIPREV_ID_5752_A0_HW 0x5000
44121 #define CHIPREV_ID_5752_A0 0x6000
44122 diff --git a/drivers/net/ethernet/chelsio/cxgb3/l2t.h b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44123 index 8cffcdf..aadf043 100644
44124 --- a/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44125 +++ b/drivers/net/ethernet/chelsio/cxgb3/l2t.h
44126 @@ -87,7 +87,7 @@ typedef void (*arp_failure_handler_func)(struct t3cdev * dev,
44127 */
44128 struct l2t_skb_cb {
44129 arp_failure_handler_func arp_failure_handler;
44130 -};
44131 +} __no_const;
44132
44133 #define L2T_SKB_CB(skb) ((struct l2t_skb_cb *)(skb)->cb)
44134
44135 diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44136 index c73cabd..cd278b1 100644
44137 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44138 +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
44139 @@ -2186,7 +2186,7 @@ static void get_regs(struct net_device *dev, struct ethtool_regs *regs,
44140
44141 int i;
44142 struct adapter *ap = netdev2adap(dev);
44143 - static const unsigned int *reg_ranges;
44144 + const unsigned int *reg_ranges;
44145 int arr_size = 0, buf_size = 0;
44146
44147 if (is_t4(ap->chip)) {
44148 diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
44149 index 263b92c..f05134b 100644
44150 --- a/drivers/net/ethernet/dec/tulip/de4x5.c
44151 +++ b/drivers/net/ethernet/dec/tulip/de4x5.c
44152 @@ -5388,7 +5388,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44153 for (i=0; i<ETH_ALEN; i++) {
44154 tmp.addr[i] = dev->dev_addr[i];
44155 }
44156 - if (copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44157 + if (ioc->len > sizeof tmp.addr || copy_to_user(ioc->data, tmp.addr, ioc->len)) return -EFAULT;
44158 break;
44159
44160 case DE4X5_SET_HWADDR: /* Set the hardware address */
44161 @@ -5428,7 +5428,7 @@ de4x5_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
44162 spin_lock_irqsave(&lp->lock, flags);
44163 memcpy(&statbuf, &lp->pktStats, ioc->len);
44164 spin_unlock_irqrestore(&lp->lock, flags);
44165 - if (copy_to_user(ioc->data, &statbuf, ioc->len))
44166 + if (ioc->len > sizeof statbuf || copy_to_user(ioc->data, &statbuf, ioc->len))
44167 return -EFAULT;
44168 break;
44169 }
44170 diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
44171 index 2c38cc4..0323f6e 100644
44172 --- a/drivers/net/ethernet/emulex/benet/be_main.c
44173 +++ b/drivers/net/ethernet/emulex/benet/be_main.c
44174 @@ -470,7 +470,7 @@ static void accumulate_16bit_val(u32 *acc, u16 val)
44175
44176 if (wrapped)
44177 newacc += 65536;
44178 - ACCESS_ONCE(*acc) = newacc;
44179 + ACCESS_ONCE_RW(*acc) = newacc;
44180 }
44181
44182 static void populate_erx_stats(struct be_adapter *adapter,
44183 diff --git a/drivers/net/ethernet/faraday/ftgmac100.c b/drivers/net/ethernet/faraday/ftgmac100.c
44184 index 212f44b..fb69959 100644
44185 --- a/drivers/net/ethernet/faraday/ftgmac100.c
44186 +++ b/drivers/net/ethernet/faraday/ftgmac100.c
44187 @@ -31,6 +31,8 @@
44188 #include <linux/netdevice.h>
44189 #include <linux/phy.h>
44190 #include <linux/platform_device.h>
44191 +#include <linux/interrupt.h>
44192 +#include <linux/irqreturn.h>
44193 #include <net/ip.h>
44194
44195 #include "ftgmac100.h"
44196 diff --git a/drivers/net/ethernet/faraday/ftmac100.c b/drivers/net/ethernet/faraday/ftmac100.c
44197 index 8be5b40..081bc1b 100644
44198 --- a/drivers/net/ethernet/faraday/ftmac100.c
44199 +++ b/drivers/net/ethernet/faraday/ftmac100.c
44200 @@ -31,6 +31,8 @@
44201 #include <linux/module.h>
44202 #include <linux/netdevice.h>
44203 #include <linux/platform_device.h>
44204 +#include <linux/interrupt.h>
44205 +#include <linux/irqreturn.h>
44206
44207 #include "ftmac100.h"
44208
44209 diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44210 index 5184e2a..acb28c3 100644
44211 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44212 +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
44213 @@ -776,7 +776,7 @@ void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter)
44214 }
44215
44216 /* update the base incval used to calculate frequency adjustment */
44217 - ACCESS_ONCE(adapter->base_incval) = incval;
44218 + ACCESS_ONCE_RW(adapter->base_incval) = incval;
44219 smp_mb();
44220
44221 /* need lock to prevent incorrect read while modifying cyclecounter */
44222 diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44223 index fbe5363..266b4e3 100644
44224 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c
44225 +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c
44226 @@ -3461,7 +3461,10 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44227 struct __vxge_hw_fifo *fifo;
44228 struct vxge_hw_fifo_config *config;
44229 u32 txdl_size, txdl_per_memblock;
44230 - struct vxge_hw_mempool_cbs fifo_mp_callback;
44231 + static struct vxge_hw_mempool_cbs fifo_mp_callback = {
44232 + .item_func_alloc = __vxge_hw_fifo_mempool_item_alloc,
44233 + };
44234 +
44235 struct __vxge_hw_virtualpath *vpath;
44236
44237 if ((vp == NULL) || (attr == NULL)) {
44238 @@ -3544,8 +3547,6 @@ __vxge_hw_fifo_create(struct __vxge_hw_vpath_handle *vp,
44239 goto exit;
44240 }
44241
44242 - fifo_mp_callback.item_func_alloc = __vxge_hw_fifo_mempool_item_alloc;
44243 -
44244 fifo->mempool =
44245 __vxge_hw_mempool_create(vpath->hldev,
44246 fifo->config->memblock_size,
44247 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44248 index f09e787..f3916a8 100644
44249 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44250 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_init.c
44251 @@ -2055,7 +2055,9 @@ int qlcnic_83xx_configure_opmode(struct qlcnic_adapter *adapter)
44252
44253 } else if (ret == QLC_83XX_DEFAULT_OPMODE) {
44254 ahw->nic_mode = QLC_83XX_DEFAULT_MODE;
44255 - adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44256 + pax_open_kernel();
44257 + *(void **)&adapter->nic_ops->init_driver = qlcnic_83xx_init_default_driver;
44258 + pax_close_kernel();
44259 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44260 } else {
44261 return -EIO;
44262 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44263 index 0248a4c..9648d96 100644
44264 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44265 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_vnic.c
44266 @@ -191,17 +191,23 @@ int qlcnic_83xx_config_vnic_opmode(struct qlcnic_adapter *adapter)
44267 case QLCNIC_NON_PRIV_FUNC:
44268 ahw->op_mode = QLCNIC_NON_PRIV_FUNC;
44269 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44270 - nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44271 + pax_open_kernel();
44272 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_non_privileged_vnic;
44273 + pax_close_kernel();
44274 break;
44275 case QLCNIC_PRIV_FUNC:
44276 ahw->op_mode = QLCNIC_PRIV_FUNC;
44277 ahw->idc.state_entry = qlcnic_83xx_idc_vnic_pf_entry;
44278 - nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44279 + pax_open_kernel();
44280 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_privileged_vnic;
44281 + pax_close_kernel();
44282 break;
44283 case QLCNIC_MGMT_FUNC:
44284 ahw->op_mode = QLCNIC_MGMT_FUNC;
44285 ahw->idc.state_entry = qlcnic_83xx_idc_ready_state_entry;
44286 - nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44287 + pax_open_kernel();
44288 + *(void **)&nic_ops->init_driver = qlcnic_83xx_init_mgmt_vnic;
44289 + pax_close_kernel();
44290 break;
44291 default:
44292 dev_err(&adapter->pdev->dev, "Invalid Virtual NIC opmode\n");
44293 diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44294 index 1551360..ed6510f 100644
44295 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44296 +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_minidump.c
44297 @@ -1108,7 +1108,7 @@ int qlcnic_dump_fw(struct qlcnic_adapter *adapter)
44298 struct qlcnic_dump_entry *entry;
44299 struct qlcnic_fw_dump *fw_dump = &adapter->ahw->fw_dump;
44300 struct qlcnic_dump_template_hdr *tmpl_hdr = fw_dump->tmpl_hdr;
44301 - static const struct qlcnic_dump_operations *fw_dump_ops;
44302 + const struct qlcnic_dump_operations *fw_dump_ops;
44303 struct device *dev = &adapter->pdev->dev;
44304 struct qlcnic_hardware_context *ahw;
44305 void *temp_buffer;
44306 diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
44307 index fb3f8dc..9d2ff38 100644
44308 --- a/drivers/net/ethernet/realtek/r8169.c
44309 +++ b/drivers/net/ethernet/realtek/r8169.c
44310 @@ -759,22 +759,22 @@ struct rtl8169_private {
44311 struct mdio_ops {
44312 void (*write)(struct rtl8169_private *, int, int);
44313 int (*read)(struct rtl8169_private *, int);
44314 - } mdio_ops;
44315 + } __no_const mdio_ops;
44316
44317 struct pll_power_ops {
44318 void (*down)(struct rtl8169_private *);
44319 void (*up)(struct rtl8169_private *);
44320 - } pll_power_ops;
44321 + } __no_const pll_power_ops;
44322
44323 struct jumbo_ops {
44324 void (*enable)(struct rtl8169_private *);
44325 void (*disable)(struct rtl8169_private *);
44326 - } jumbo_ops;
44327 + } __no_const jumbo_ops;
44328
44329 struct csi_ops {
44330 void (*write)(struct rtl8169_private *, int, int);
44331 u32 (*read)(struct rtl8169_private *, int);
44332 - } csi_ops;
44333 + } __no_const csi_ops;
44334
44335 int (*set_speed)(struct net_device *, u8 aneg, u16 sp, u8 dpx, u32 adv);
44336 int (*get_settings)(struct net_device *, struct ethtool_cmd *);
44337 diff --git a/drivers/net/ethernet/sfc/ptp.c b/drivers/net/ethernet/sfc/ptp.c
44338 index 03acf57..e1251ff 100644
44339 --- a/drivers/net/ethernet/sfc/ptp.c
44340 +++ b/drivers/net/ethernet/sfc/ptp.c
44341 @@ -539,7 +539,7 @@ static int efx_ptp_synchronize(struct efx_nic *efx, unsigned int num_readings)
44342 ptp->start.dma_addr);
44343
44344 /* Clear flag that signals MC ready */
44345 - ACCESS_ONCE(*start) = 0;
44346 + ACCESS_ONCE_RW(*start) = 0;
44347 rc = efx_mcdi_rpc_start(efx, MC_CMD_PTP, synch_buf,
44348 MC_CMD_PTP_IN_SYNCHRONIZE_LEN);
44349 EFX_BUG_ON_PARANOID(rc);
44350 diff --git a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44351 index 50617c5..b13724c 100644
44352 --- a/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44353 +++ b/drivers/net/ethernet/stmicro/stmmac/mmc_core.c
44354 @@ -140,8 +140,8 @@ void dwmac_mmc_ctrl(void __iomem *ioaddr, unsigned int mode)
44355
44356 writel(value, ioaddr + MMC_CNTRL);
44357
44358 - pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44359 - MMC_CNTRL, value);
44360 +// pr_debug("stmmac: MMC ctrl register (offset 0x%x): 0x%08x\n",
44361 +// MMC_CNTRL, value);
44362 }
44363
44364 /* To mask all all interrupts.*/
44365 diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c
44366 index 3169252..5d78c1d 100644
44367 --- a/drivers/net/hamradio/hdlcdrv.c
44368 +++ b/drivers/net/hamradio/hdlcdrv.c
44369 @@ -571,6 +571,8 @@ static int hdlcdrv_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44370 case HDLCDRVCTL_CALIBRATE:
44371 if(!capable(CAP_SYS_RAWIO))
44372 return -EPERM;
44373 + if (bi.data.calibrate > INT_MAX / s->par.bitrate)
44374 + return -EINVAL;
44375 s->hdlctx.calibrate = bi.data.calibrate * s->par.bitrate / 16;
44376 return 0;
44377
44378 diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
44379 index e6fe0d8..2b7d752 100644
44380 --- a/drivers/net/hyperv/hyperv_net.h
44381 +++ b/drivers/net/hyperv/hyperv_net.h
44382 @@ -101,7 +101,7 @@ struct rndis_device {
44383
44384 enum rndis_device_state state;
44385 bool link_state;
44386 - atomic_t new_req_id;
44387 + atomic_unchecked_t new_req_id;
44388
44389 spinlock_t request_lock;
44390 struct list_head req_list;
44391 diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c
44392 index 0775f0a..d4fb316 100644
44393 --- a/drivers/net/hyperv/rndis_filter.c
44394 +++ b/drivers/net/hyperv/rndis_filter.c
44395 @@ -104,7 +104,7 @@ static struct rndis_request *get_rndis_request(struct rndis_device *dev,
44396 * template
44397 */
44398 set = &rndis_msg->msg.set_req;
44399 - set->req_id = atomic_inc_return(&dev->new_req_id);
44400 + set->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44401
44402 /* Add to the request list */
44403 spin_lock_irqsave(&dev->request_lock, flags);
44404 @@ -752,7 +752,7 @@ static void rndis_filter_halt_device(struct rndis_device *dev)
44405
44406 /* Setup the rndis set */
44407 halt = &request->request_msg.msg.halt_req;
44408 - halt->req_id = atomic_inc_return(&dev->new_req_id);
44409 + halt->req_id = atomic_inc_return_unchecked(&dev->new_req_id);
44410
44411 /* Ignore return since this msg is optional. */
44412 rndis_filter_send_request(dev, request);
44413 diff --git a/drivers/net/ieee802154/fakehard.c b/drivers/net/ieee802154/fakehard.c
44414 index bf0d55e..82bcfbd1 100644
44415 --- a/drivers/net/ieee802154/fakehard.c
44416 +++ b/drivers/net/ieee802154/fakehard.c
44417 @@ -364,7 +364,7 @@ static int ieee802154fake_probe(struct platform_device *pdev)
44418 phy->transmit_power = 0xbf;
44419
44420 dev->netdev_ops = &fake_ops;
44421 - dev->ml_priv = &fake_mlme;
44422 + dev->ml_priv = (void *)&fake_mlme;
44423
44424 priv = netdev_priv(dev);
44425 priv->phy = phy;
44426 diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
44427 index 9bf46bd..bfdaa84 100644
44428 --- a/drivers/net/macvlan.c
44429 +++ b/drivers/net/macvlan.c
44430 @@ -939,13 +939,15 @@ static const struct nla_policy macvlan_policy[IFLA_MACVLAN_MAX + 1] = {
44431 int macvlan_link_register(struct rtnl_link_ops *ops)
44432 {
44433 /* common fields */
44434 - ops->priv_size = sizeof(struct macvlan_dev);
44435 - ops->validate = macvlan_validate;
44436 - ops->maxtype = IFLA_MACVLAN_MAX;
44437 - ops->policy = macvlan_policy;
44438 - ops->changelink = macvlan_changelink;
44439 - ops->get_size = macvlan_get_size;
44440 - ops->fill_info = macvlan_fill_info;
44441 + pax_open_kernel();
44442 + *(size_t *)&ops->priv_size = sizeof(struct macvlan_dev);
44443 + *(void **)&ops->validate = macvlan_validate;
44444 + *(int *)&ops->maxtype = IFLA_MACVLAN_MAX;
44445 + *(const void **)&ops->policy = macvlan_policy;
44446 + *(void **)&ops->changelink = macvlan_changelink;
44447 + *(void **)&ops->get_size = macvlan_get_size;
44448 + *(void **)&ops->fill_info = macvlan_fill_info;
44449 + pax_close_kernel();
44450
44451 return rtnl_link_register(ops);
44452 };
44453 @@ -1001,7 +1003,7 @@ static int macvlan_device_event(struct notifier_block *unused,
44454 return NOTIFY_DONE;
44455 }
44456
44457 -static struct notifier_block macvlan_notifier_block __read_mostly = {
44458 +static struct notifier_block macvlan_notifier_block = {
44459 .notifier_call = macvlan_device_event,
44460 };
44461
44462 diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
44463 index dc76670..e18f39c 100644
44464 --- a/drivers/net/macvtap.c
44465 +++ b/drivers/net/macvtap.c
44466 @@ -1189,7 +1189,7 @@ static int macvtap_device_event(struct notifier_block *unused,
44467 return NOTIFY_DONE;
44468 }
44469
44470 -static struct notifier_block macvtap_notifier_block __read_mostly = {
44471 +static struct notifier_block macvtap_notifier_block = {
44472 .notifier_call = macvtap_device_event,
44473 };
44474
44475 diff --git a/drivers/net/phy/mdio-bitbang.c b/drivers/net/phy/mdio-bitbang.c
44476 index daec9b0..6428fcb 100644
44477 --- a/drivers/net/phy/mdio-bitbang.c
44478 +++ b/drivers/net/phy/mdio-bitbang.c
44479 @@ -234,6 +234,7 @@ void free_mdio_bitbang(struct mii_bus *bus)
44480 struct mdiobb_ctrl *ctrl = bus->priv;
44481
44482 module_put(ctrl->ops->owner);
44483 + mdiobus_unregister(bus);
44484 mdiobus_free(bus);
44485 }
44486 EXPORT_SYMBOL(free_mdio_bitbang);
44487 diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
44488 index 72ff14b..11d442d 100644
44489 --- a/drivers/net/ppp/ppp_generic.c
44490 +++ b/drivers/net/ppp/ppp_generic.c
44491 @@ -999,7 +999,6 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44492 void __user *addr = (void __user *) ifr->ifr_ifru.ifru_data;
44493 struct ppp_stats stats;
44494 struct ppp_comp_stats cstats;
44495 - char *vers;
44496
44497 switch (cmd) {
44498 case SIOCGPPPSTATS:
44499 @@ -1021,8 +1020,7 @@ ppp_net_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
44500 break;
44501
44502 case SIOCGPPPVER:
44503 - vers = PPP_VERSION;
44504 - if (copy_to_user(addr, vers, strlen(vers) + 1))
44505 + if (copy_to_user(addr, PPP_VERSION, sizeof(PPP_VERSION)))
44506 break;
44507 err = 0;
44508 break;
44509 diff --git a/drivers/net/slip/slhc.c b/drivers/net/slip/slhc.c
44510 index 1252d9c..80e660b 100644
44511 --- a/drivers/net/slip/slhc.c
44512 +++ b/drivers/net/slip/slhc.c
44513 @@ -488,7 +488,7 @@ slhc_uncompress(struct slcompress *comp, unsigned char *icp, int isize)
44514 register struct tcphdr *thp;
44515 register struct iphdr *ip;
44516 register struct cstate *cs;
44517 - int len, hdrlen;
44518 + long len, hdrlen;
44519 unsigned char *cp = icp;
44520
44521 /* We've got a compressed packet; read the change byte */
44522 diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c
44523 index 6327df2..e6e1ebe 100644
44524 --- a/drivers/net/team/team.c
44525 +++ b/drivers/net/team/team.c
44526 @@ -2873,7 +2873,7 @@ static int team_device_event(struct notifier_block *unused,
44527 return NOTIFY_DONE;
44528 }
44529
44530 -static struct notifier_block team_notifier_block __read_mostly = {
44531 +static struct notifier_block team_notifier_block = {
44532 .notifier_call = team_device_event,
44533 };
44534
44535 diff --git a/drivers/net/tun.c b/drivers/net/tun.c
44536 index 782e38b..d076fdc 100644
44537 --- a/drivers/net/tun.c
44538 +++ b/drivers/net/tun.c
44539 @@ -1834,7 +1834,7 @@ unlock:
44540 }
44541
44542 static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44543 - unsigned long arg, int ifreq_len)
44544 + unsigned long arg, size_t ifreq_len)
44545 {
44546 struct tun_file *tfile = file->private_data;
44547 struct tun_struct *tun;
44548 @@ -1847,6 +1847,9 @@ static long __tun_chr_ioctl(struct file *file, unsigned int cmd,
44549 unsigned int ifindex;
44550 int ret;
44551
44552 + if (ifreq_len > sizeof ifr)
44553 + return -EFAULT;
44554 +
44555 if (cmd == TUNSETIFF || cmd == TUNSETQUEUE || _IOC_TYPE(cmd) == 0x89) {
44556 if (copy_from_user(&ifr, argp, ifreq_len))
44557 return -EFAULT;
44558 diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
44559 index 86292e6..8d34433 100644
44560 --- a/drivers/net/usb/hso.c
44561 +++ b/drivers/net/usb/hso.c
44562 @@ -71,7 +71,7 @@
44563 #include <asm/byteorder.h>
44564 #include <linux/serial_core.h>
44565 #include <linux/serial.h>
44566 -
44567 +#include <asm/local.h>
44568
44569 #define MOD_AUTHOR "Option Wireless"
44570 #define MOD_DESCRIPTION "USB High Speed Option driver"
44571 @@ -1180,7 +1180,7 @@ static void put_rxbuf_data_and_resubmit_ctrl_urb(struct hso_serial *serial)
44572 struct urb *urb;
44573
44574 urb = serial->rx_urb[0];
44575 - if (serial->port.count > 0) {
44576 + if (atomic_read(&serial->port.count) > 0) {
44577 count = put_rxbuf_data(urb, serial);
44578 if (count == -1)
44579 return;
44580 @@ -1216,7 +1216,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
44581 DUMP1(urb->transfer_buffer, urb->actual_length);
44582
44583 /* Anyone listening? */
44584 - if (serial->port.count == 0)
44585 + if (atomic_read(&serial->port.count) == 0)
44586 return;
44587
44588 if (status == 0) {
44589 @@ -1298,8 +1298,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44590 tty_port_tty_set(&serial->port, tty);
44591
44592 /* check for port already opened, if not set the termios */
44593 - serial->port.count++;
44594 - if (serial->port.count == 1) {
44595 + if (atomic_inc_return(&serial->port.count) == 1) {
44596 serial->rx_state = RX_IDLE;
44597 /* Force default termio settings */
44598 _hso_serial_set_termios(tty, NULL);
44599 @@ -1311,7 +1310,7 @@ static int hso_serial_open(struct tty_struct *tty, struct file *filp)
44600 result = hso_start_serial_device(serial->parent, GFP_KERNEL);
44601 if (result) {
44602 hso_stop_serial_device(serial->parent);
44603 - serial->port.count--;
44604 + atomic_dec(&serial->port.count);
44605 kref_put(&serial->parent->ref, hso_serial_ref_free);
44606 }
44607 } else {
44608 @@ -1348,10 +1347,10 @@ static void hso_serial_close(struct tty_struct *tty, struct file *filp)
44609
44610 /* reset the rts and dtr */
44611 /* do the actual close */
44612 - serial->port.count--;
44613 + atomic_dec(&serial->port.count);
44614
44615 - if (serial->port.count <= 0) {
44616 - serial->port.count = 0;
44617 + if (atomic_read(&serial->port.count) <= 0) {
44618 + atomic_set(&serial->port.count, 0);
44619 tty_port_tty_set(&serial->port, NULL);
44620 if (!usb_gone)
44621 hso_stop_serial_device(serial->parent);
44622 @@ -1427,7 +1426,7 @@ static void hso_serial_set_termios(struct tty_struct *tty, struct ktermios *old)
44623
44624 /* the actual setup */
44625 spin_lock_irqsave(&serial->serial_lock, flags);
44626 - if (serial->port.count)
44627 + if (atomic_read(&serial->port.count))
44628 _hso_serial_set_termios(tty, old);
44629 else
44630 tty->termios = *old;
44631 @@ -1886,7 +1885,7 @@ static void intr_callback(struct urb *urb)
44632 D1("Pending read interrupt on port %d\n", i);
44633 spin_lock(&serial->serial_lock);
44634 if (serial->rx_state == RX_IDLE &&
44635 - serial->port.count > 0) {
44636 + atomic_read(&serial->port.count) > 0) {
44637 /* Setup and send a ctrl req read on
44638 * port i */
44639 if (!serial->rx_urb_filled[0]) {
44640 @@ -3062,7 +3061,7 @@ static int hso_resume(struct usb_interface *iface)
44641 /* Start all serial ports */
44642 for (i = 0; i < HSO_SERIAL_TTY_MINORS; i++) {
44643 if (serial_table[i] && (serial_table[i]->interface == iface)) {
44644 - if (dev2ser(serial_table[i])->port.count) {
44645 + if (atomic_read(&dev2ser(serial_table[i])->port.count)) {
44646 result =
44647 hso_start_serial_device(serial_table[i], GFP_NOIO);
44648 hso_kick_transmit(dev2ser(serial_table[i]));
44649 diff --git a/drivers/net/usb/sierra_net.c b/drivers/net/usb/sierra_net.c
44650 index a79e9d3..78cd4fa 100644
44651 --- a/drivers/net/usb/sierra_net.c
44652 +++ b/drivers/net/usb/sierra_net.c
44653 @@ -52,7 +52,7 @@ static const char driver_name[] = "sierra_net";
44654 /* atomic counter partially included in MAC address to make sure 2 devices
44655 * do not end up with the same MAC - concept breaks in case of > 255 ifaces
44656 */
44657 -static atomic_t iface_counter = ATOMIC_INIT(0);
44658 +static atomic_unchecked_t iface_counter = ATOMIC_INIT(0);
44659
44660 /*
44661 * SYNC Timer Delay definition used to set the expiry time
44662 @@ -698,7 +698,7 @@ static int sierra_net_bind(struct usbnet *dev, struct usb_interface *intf)
44663 dev->net->netdev_ops = &sierra_net_device_ops;
44664
44665 /* change MAC addr to include, ifacenum, and to be unique */
44666 - dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return(&iface_counter);
44667 + dev->net->dev_addr[ETH_ALEN-2] = atomic_inc_return_unchecked(&iface_counter);
44668 dev->net->dev_addr[ETH_ALEN-1] = ifacenum;
44669
44670 /* we will have to manufacture ethernet headers, prepare template */
44671 diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
44672 index 2ef5b62..6fa0ec3 100644
44673 --- a/drivers/net/vxlan.c
44674 +++ b/drivers/net/vxlan.c
44675 @@ -2615,7 +2615,7 @@ nla_put_failure:
44676 return -EMSGSIZE;
44677 }
44678
44679 -static struct rtnl_link_ops vxlan_link_ops __read_mostly = {
44680 +static struct rtnl_link_ops vxlan_link_ops = {
44681 .kind = "vxlan",
44682 .maxtype = IFLA_VXLAN_MAX,
44683 .policy = vxlan_policy,
44684 diff --git a/drivers/net/wimax/i2400m/rx.c b/drivers/net/wimax/i2400m/rx.c
44685 index 0b60295..b8bfa5b 100644
44686 --- a/drivers/net/wimax/i2400m/rx.c
44687 +++ b/drivers/net/wimax/i2400m/rx.c
44688 @@ -1359,7 +1359,7 @@ int i2400m_rx_setup(struct i2400m *i2400m)
44689 if (i2400m->rx_roq == NULL)
44690 goto error_roq_alloc;
44691
44692 - rd = kcalloc(I2400M_RO_CIN + 1, sizeof(*i2400m->rx_roq[0].log),
44693 + rd = kcalloc(sizeof(*i2400m->rx_roq[0].log), I2400M_RO_CIN + 1,
44694 GFP_KERNEL);
44695 if (rd == NULL) {
44696 result = -ENOMEM;
44697 diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
44698 index 7fe1964..7016de0 100644
44699 --- a/drivers/net/wireless/airo.c
44700 +++ b/drivers/net/wireless/airo.c
44701 @@ -7844,7 +7844,7 @@ static int writerids(struct net_device *dev, aironet_ioctl *comp) {
44702 struct airo_info *ai = dev->ml_priv;
44703 int ridcode;
44704 int enabled;
44705 - static int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44706 + int (* writer)(struct airo_info *, u16 rid, const void *, int, int);
44707 unsigned char *iobuf;
44708
44709 /* Only super-user can write RIDs */
44710 diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c
44711 index 34c8a33..3261fdc 100644
44712 --- a/drivers/net/wireless/at76c50x-usb.c
44713 +++ b/drivers/net/wireless/at76c50x-usb.c
44714 @@ -353,7 +353,7 @@ static int at76_dfu_get_state(struct usb_device *udev, u8 *state)
44715 }
44716
44717 /* Convert timeout from the DFU status to jiffies */
44718 -static inline unsigned long at76_get_timeout(struct dfu_status *s)
44719 +static inline unsigned long __intentional_overflow(-1) at76_get_timeout(struct dfu_status *s)
44720 {
44721 return msecs_to_jiffies((s->poll_timeout[2] << 16)
44722 | (s->poll_timeout[1] << 8)
44723 diff --git a/drivers/net/wireless/ath/ath10k/htc.c b/drivers/net/wireless/ath/ath10k/htc.c
44724 index ef3329e..c28ff5d 100644
44725 --- a/drivers/net/wireless/ath/ath10k/htc.c
44726 +++ b/drivers/net/wireless/ath/ath10k/htc.c
44727 @@ -963,7 +963,10 @@ void ath10k_htc_stop(struct ath10k_htc *htc)
44728 /* registered target arrival callback from the HIF layer */
44729 int ath10k_htc_init(struct ath10k *ar)
44730 {
44731 - struct ath10k_hif_cb htc_callbacks;
44732 + static struct ath10k_hif_cb htc_callbacks = {
44733 + .rx_completion = ath10k_htc_rx_completion_handler,
44734 + .tx_completion = ath10k_htc_tx_completion_handler,
44735 + };
44736 struct ath10k_htc_ep *ep = NULL;
44737 struct ath10k_htc *htc = &ar->htc;
44738
44739 @@ -973,8 +976,6 @@ int ath10k_htc_init(struct ath10k *ar)
44740 ath10k_htc_reset_endpoint_states(htc);
44741
44742 /* setup HIF layer callbacks */
44743 - htc_callbacks.rx_completion = ath10k_htc_rx_completion_handler;
44744 - htc_callbacks.tx_completion = ath10k_htc_tx_completion_handler;
44745 htc->ar = ar;
44746
44747 /* Get HIF default pipe for HTC message exchange */
44748 diff --git a/drivers/net/wireless/ath/ath10k/htc.h b/drivers/net/wireless/ath/ath10k/htc.h
44749 index e1dd8c7..9f91b3f 100644
44750 --- a/drivers/net/wireless/ath/ath10k/htc.h
44751 +++ b/drivers/net/wireless/ath/ath10k/htc.h
44752 @@ -271,12 +271,12 @@ enum ath10k_htc_ep_id {
44753
44754 struct ath10k_htc_ops {
44755 void (*target_send_suspend_complete)(struct ath10k *ar);
44756 -};
44757 +} __no_const;
44758
44759 struct ath10k_htc_ep_ops {
44760 void (*ep_tx_complete)(struct ath10k *, struct sk_buff *);
44761 void (*ep_rx_complete)(struct ath10k *, struct sk_buff *);
44762 -};
44763 +} __no_const;
44764
44765 /* service connection information */
44766 struct ath10k_htc_svc_conn_req {
44767 diff --git a/drivers/net/wireless/ath/ath9k/ar9002_mac.c b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44768 index a366d6b..b6f28f8 100644
44769 --- a/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44770 +++ b/drivers/net/wireless/ath/ath9k/ar9002_mac.c
44771 @@ -218,8 +218,8 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44772 ads->ds_txstatus6 = ads->ds_txstatus7 = 0;
44773 ads->ds_txstatus8 = ads->ds_txstatus9 = 0;
44774
44775 - ACCESS_ONCE(ads->ds_link) = i->link;
44776 - ACCESS_ONCE(ads->ds_data) = i->buf_addr[0];
44777 + ACCESS_ONCE_RW(ads->ds_link) = i->link;
44778 + ACCESS_ONCE_RW(ads->ds_data) = i->buf_addr[0];
44779
44780 ctl1 = i->buf_len[0] | (i->is_last ? 0 : AR_TxMore);
44781 ctl6 = SM(i->keytype, AR_EncrType);
44782 @@ -233,26 +233,26 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44783
44784 if ((i->is_first || i->is_last) &&
44785 i->aggr != AGGR_BUF_MIDDLE && i->aggr != AGGR_BUF_LAST) {
44786 - ACCESS_ONCE(ads->ds_ctl2) = set11nTries(i->rates, 0)
44787 + ACCESS_ONCE_RW(ads->ds_ctl2) = set11nTries(i->rates, 0)
44788 | set11nTries(i->rates, 1)
44789 | set11nTries(i->rates, 2)
44790 | set11nTries(i->rates, 3)
44791 | (i->dur_update ? AR_DurUpdateEna : 0)
44792 | SM(0, AR_BurstDur);
44793
44794 - ACCESS_ONCE(ads->ds_ctl3) = set11nRate(i->rates, 0)
44795 + ACCESS_ONCE_RW(ads->ds_ctl3) = set11nRate(i->rates, 0)
44796 | set11nRate(i->rates, 1)
44797 | set11nRate(i->rates, 2)
44798 | set11nRate(i->rates, 3);
44799 } else {
44800 - ACCESS_ONCE(ads->ds_ctl2) = 0;
44801 - ACCESS_ONCE(ads->ds_ctl3) = 0;
44802 + ACCESS_ONCE_RW(ads->ds_ctl2) = 0;
44803 + ACCESS_ONCE_RW(ads->ds_ctl3) = 0;
44804 }
44805
44806 if (!i->is_first) {
44807 - ACCESS_ONCE(ads->ds_ctl0) = 0;
44808 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44809 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44810 + ACCESS_ONCE_RW(ads->ds_ctl0) = 0;
44811 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44812 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44813 return;
44814 }
44815
44816 @@ -277,7 +277,7 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44817 break;
44818 }
44819
44820 - ACCESS_ONCE(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44821 + ACCESS_ONCE_RW(ads->ds_ctl0) = (i->pkt_len & AR_FrameLen)
44822 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44823 | SM(i->txpower, AR_XmitPower)
44824 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44825 @@ -287,19 +287,19 @@ ar9002_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44826 | (i->flags & ATH9K_TXDESC_RTSENA ? AR_RTSEnable :
44827 (i->flags & ATH9K_TXDESC_CTSENA ? AR_CTSEnable : 0));
44828
44829 - ACCESS_ONCE(ads->ds_ctl1) = ctl1;
44830 - ACCESS_ONCE(ads->ds_ctl6) = ctl6;
44831 + ACCESS_ONCE_RW(ads->ds_ctl1) = ctl1;
44832 + ACCESS_ONCE_RW(ads->ds_ctl6) = ctl6;
44833
44834 if (i->aggr == AGGR_BUF_MIDDLE || i->aggr == AGGR_BUF_LAST)
44835 return;
44836
44837 - ACCESS_ONCE(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44838 + ACCESS_ONCE_RW(ads->ds_ctl4) = set11nPktDurRTSCTS(i->rates, 0)
44839 | set11nPktDurRTSCTS(i->rates, 1);
44840
44841 - ACCESS_ONCE(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44842 + ACCESS_ONCE_RW(ads->ds_ctl5) = set11nPktDurRTSCTS(i->rates, 2)
44843 | set11nPktDurRTSCTS(i->rates, 3);
44844
44845 - ACCESS_ONCE(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44846 + ACCESS_ONCE_RW(ads->ds_ctl7) = set11nRateFlags(i->rates, 0)
44847 | set11nRateFlags(i->rates, 1)
44848 | set11nRateFlags(i->rates, 2)
44849 | set11nRateFlags(i->rates, 3)
44850 diff --git a/drivers/net/wireless/ath/ath9k/ar9003_mac.c b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44851 index f6c5c1b..6058354 100644
44852 --- a/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44853 +++ b/drivers/net/wireless/ath/ath9k/ar9003_mac.c
44854 @@ -39,47 +39,47 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44855 (i->qcu << AR_TxQcuNum_S) | desc_len;
44856
44857 checksum += val;
44858 - ACCESS_ONCE(ads->info) = val;
44859 + ACCESS_ONCE_RW(ads->info) = val;
44860
44861 checksum += i->link;
44862 - ACCESS_ONCE(ads->link) = i->link;
44863 + ACCESS_ONCE_RW(ads->link) = i->link;
44864
44865 checksum += i->buf_addr[0];
44866 - ACCESS_ONCE(ads->data0) = i->buf_addr[0];
44867 + ACCESS_ONCE_RW(ads->data0) = i->buf_addr[0];
44868 checksum += i->buf_addr[1];
44869 - ACCESS_ONCE(ads->data1) = i->buf_addr[1];
44870 + ACCESS_ONCE_RW(ads->data1) = i->buf_addr[1];
44871 checksum += i->buf_addr[2];
44872 - ACCESS_ONCE(ads->data2) = i->buf_addr[2];
44873 + ACCESS_ONCE_RW(ads->data2) = i->buf_addr[2];
44874 checksum += i->buf_addr[3];
44875 - ACCESS_ONCE(ads->data3) = i->buf_addr[3];
44876 + ACCESS_ONCE_RW(ads->data3) = i->buf_addr[3];
44877
44878 checksum += (val = (i->buf_len[0] << AR_BufLen_S) & AR_BufLen);
44879 - ACCESS_ONCE(ads->ctl3) = val;
44880 + ACCESS_ONCE_RW(ads->ctl3) = val;
44881 checksum += (val = (i->buf_len[1] << AR_BufLen_S) & AR_BufLen);
44882 - ACCESS_ONCE(ads->ctl5) = val;
44883 + ACCESS_ONCE_RW(ads->ctl5) = val;
44884 checksum += (val = (i->buf_len[2] << AR_BufLen_S) & AR_BufLen);
44885 - ACCESS_ONCE(ads->ctl7) = val;
44886 + ACCESS_ONCE_RW(ads->ctl7) = val;
44887 checksum += (val = (i->buf_len[3] << AR_BufLen_S) & AR_BufLen);
44888 - ACCESS_ONCE(ads->ctl9) = val;
44889 + ACCESS_ONCE_RW(ads->ctl9) = val;
44890
44891 checksum = (u16) (((checksum & 0xffff) + (checksum >> 16)) & 0xffff);
44892 - ACCESS_ONCE(ads->ctl10) = checksum;
44893 + ACCESS_ONCE_RW(ads->ctl10) = checksum;
44894
44895 if (i->is_first || i->is_last) {
44896 - ACCESS_ONCE(ads->ctl13) = set11nTries(i->rates, 0)
44897 + ACCESS_ONCE_RW(ads->ctl13) = set11nTries(i->rates, 0)
44898 | set11nTries(i->rates, 1)
44899 | set11nTries(i->rates, 2)
44900 | set11nTries(i->rates, 3)
44901 | (i->dur_update ? AR_DurUpdateEna : 0)
44902 | SM(0, AR_BurstDur);
44903
44904 - ACCESS_ONCE(ads->ctl14) = set11nRate(i->rates, 0)
44905 + ACCESS_ONCE_RW(ads->ctl14) = set11nRate(i->rates, 0)
44906 | set11nRate(i->rates, 1)
44907 | set11nRate(i->rates, 2)
44908 | set11nRate(i->rates, 3);
44909 } else {
44910 - ACCESS_ONCE(ads->ctl13) = 0;
44911 - ACCESS_ONCE(ads->ctl14) = 0;
44912 + ACCESS_ONCE_RW(ads->ctl13) = 0;
44913 + ACCESS_ONCE_RW(ads->ctl14) = 0;
44914 }
44915
44916 ads->ctl20 = 0;
44917 @@ -89,17 +89,17 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44918
44919 ctl17 = SM(i->keytype, AR_EncrType);
44920 if (!i->is_first) {
44921 - ACCESS_ONCE(ads->ctl11) = 0;
44922 - ACCESS_ONCE(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44923 - ACCESS_ONCE(ads->ctl15) = 0;
44924 - ACCESS_ONCE(ads->ctl16) = 0;
44925 - ACCESS_ONCE(ads->ctl17) = ctl17;
44926 - ACCESS_ONCE(ads->ctl18) = 0;
44927 - ACCESS_ONCE(ads->ctl19) = 0;
44928 + ACCESS_ONCE_RW(ads->ctl11) = 0;
44929 + ACCESS_ONCE_RW(ads->ctl12) = i->is_last ? 0 : AR_TxMore;
44930 + ACCESS_ONCE_RW(ads->ctl15) = 0;
44931 + ACCESS_ONCE_RW(ads->ctl16) = 0;
44932 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44933 + ACCESS_ONCE_RW(ads->ctl18) = 0;
44934 + ACCESS_ONCE_RW(ads->ctl19) = 0;
44935 return;
44936 }
44937
44938 - ACCESS_ONCE(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44939 + ACCESS_ONCE_RW(ads->ctl11) = (i->pkt_len & AR_FrameLen)
44940 | (i->flags & ATH9K_TXDESC_VMF ? AR_VirtMoreFrag : 0)
44941 | SM(i->txpower, AR_XmitPower)
44942 | (i->flags & ATH9K_TXDESC_VEOL ? AR_VEOL : 0)
44943 @@ -135,22 +135,22 @@ ar9003_set_txdesc(struct ath_hw *ah, void *ds, struct ath_tx_info *i)
44944 val = (i->flags & ATH9K_TXDESC_PAPRD) >> ATH9K_TXDESC_PAPRD_S;
44945 ctl12 |= SM(val, AR_PAPRDChainMask);
44946
44947 - ACCESS_ONCE(ads->ctl12) = ctl12;
44948 - ACCESS_ONCE(ads->ctl17) = ctl17;
44949 + ACCESS_ONCE_RW(ads->ctl12) = ctl12;
44950 + ACCESS_ONCE_RW(ads->ctl17) = ctl17;
44951
44952 - ACCESS_ONCE(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44953 + ACCESS_ONCE_RW(ads->ctl15) = set11nPktDurRTSCTS(i->rates, 0)
44954 | set11nPktDurRTSCTS(i->rates, 1);
44955
44956 - ACCESS_ONCE(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44957 + ACCESS_ONCE_RW(ads->ctl16) = set11nPktDurRTSCTS(i->rates, 2)
44958 | set11nPktDurRTSCTS(i->rates, 3);
44959
44960 - ACCESS_ONCE(ads->ctl18) = set11nRateFlags(i->rates, 0)
44961 + ACCESS_ONCE_RW(ads->ctl18) = set11nRateFlags(i->rates, 0)
44962 | set11nRateFlags(i->rates, 1)
44963 | set11nRateFlags(i->rates, 2)
44964 | set11nRateFlags(i->rates, 3)
44965 | SM(i->rtscts_rate, AR_RTSCTSRate);
44966
44967 - ACCESS_ONCE(ads->ctl19) = AR_Not_Sounding;
44968 + ACCESS_ONCE_RW(ads->ctl19) = AR_Not_Sounding;
44969 }
44970
44971 static u16 ar9003_calc_ptr_chksum(struct ar9003_txc *ads)
44972 diff --git a/drivers/net/wireless/ath/ath9k/hw.h b/drivers/net/wireless/ath/ath9k/hw.h
44973 index 69a907b..91e071c 100644
44974 --- a/drivers/net/wireless/ath/ath9k/hw.h
44975 +++ b/drivers/net/wireless/ath/ath9k/hw.h
44976 @@ -657,7 +657,7 @@ struct ath_hw_private_ops {
44977
44978 /* ANI */
44979 void (*ani_cache_ini_regs)(struct ath_hw *ah);
44980 -};
44981 +} __no_const;
44982
44983 /**
44984 * struct ath_spec_scan - parameters for Atheros spectral scan
44985 @@ -729,7 +729,7 @@ struct ath_hw_ops {
44986 #ifdef CONFIG_ATH9K_BTCOEX_SUPPORT
44987 void (*set_bt_ant_diversity)(struct ath_hw *hw, bool enable);
44988 #endif
44989 -};
44990 +} __no_const;
44991
44992 struct ath_nf_limits {
44993 s16 max;
44994 diff --git a/drivers/net/wireless/b43/phy_lp.c b/drivers/net/wireless/b43/phy_lp.c
44995 index 92190da..f3a4c4c 100644
44996 --- a/drivers/net/wireless/b43/phy_lp.c
44997 +++ b/drivers/net/wireless/b43/phy_lp.c
44998 @@ -2514,7 +2514,7 @@ static int lpphy_b2063_tune(struct b43_wldev *dev,
44999 {
45000 struct ssb_bus *bus = dev->dev->sdev->bus;
45001
45002 - static const struct b206x_channel *chandata = NULL;
45003 + const struct b206x_channel *chandata = NULL;
45004 u32 crystal_freq = bus->chipco.pmu.crystalfreq * 1000;
45005 u32 freqref, vco_freq, val1, val2, val3, timeout, timeoutref, count;
45006 u16 old_comm15, scale;
45007 diff --git a/drivers/net/wireless/iwlegacy/3945-mac.c b/drivers/net/wireless/iwlegacy/3945-mac.c
45008 index 9581d07..84f6a76 100644
45009 --- a/drivers/net/wireless/iwlegacy/3945-mac.c
45010 +++ b/drivers/net/wireless/iwlegacy/3945-mac.c
45011 @@ -3639,7 +3639,9 @@ il3945_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
45012 */
45013 if (il3945_mod_params.disable_hw_scan) {
45014 D_INFO("Disabling hw_scan\n");
45015 - il3945_mac_ops.hw_scan = NULL;
45016 + pax_open_kernel();
45017 + *(void **)&il3945_mac_ops.hw_scan = NULL;
45018 + pax_close_kernel();
45019 }
45020
45021 D_INFO("*** LOAD DRIVER ***\n");
45022 diff --git a/drivers/net/wireless/iwlwifi/dvm/debugfs.c b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45023 index d94f8ab..5b568c8 100644
45024 --- a/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45025 +++ b/drivers/net/wireless/iwlwifi/dvm/debugfs.c
45026 @@ -188,7 +188,7 @@ static ssize_t iwl_dbgfs_sram_write(struct file *file,
45027 {
45028 struct iwl_priv *priv = file->private_data;
45029 char buf[64];
45030 - int buf_size;
45031 + size_t buf_size;
45032 u32 offset, len;
45033
45034 memset(buf, 0, sizeof(buf));
45035 @@ -458,7 +458,7 @@ static ssize_t iwl_dbgfs_rx_handlers_write(struct file *file,
45036 struct iwl_priv *priv = file->private_data;
45037
45038 char buf[8];
45039 - int buf_size;
45040 + size_t buf_size;
45041 u32 reset_flag;
45042
45043 memset(buf, 0, sizeof(buf));
45044 @@ -539,7 +539,7 @@ static ssize_t iwl_dbgfs_disable_ht40_write(struct file *file,
45045 {
45046 struct iwl_priv *priv = file->private_data;
45047 char buf[8];
45048 - int buf_size;
45049 + size_t buf_size;
45050 int ht40;
45051
45052 memset(buf, 0, sizeof(buf));
45053 @@ -591,7 +591,7 @@ static ssize_t iwl_dbgfs_sleep_level_override_write(struct file *file,
45054 {
45055 struct iwl_priv *priv = file->private_data;
45056 char buf[8];
45057 - int buf_size;
45058 + size_t buf_size;
45059 int value;
45060
45061 memset(buf, 0, sizeof(buf));
45062 @@ -683,10 +683,10 @@ DEBUGFS_READ_FILE_OPS(temperature);
45063 DEBUGFS_READ_WRITE_FILE_OPS(sleep_level_override);
45064 DEBUGFS_READ_FILE_OPS(current_sleep_command);
45065
45066 -static const char *fmt_value = " %-30s %10u\n";
45067 -static const char *fmt_hex = " %-30s 0x%02X\n";
45068 -static const char *fmt_table = " %-30s %10u %10u %10u %10u\n";
45069 -static const char *fmt_header =
45070 +static const char fmt_value[] = " %-30s %10u\n";
45071 +static const char fmt_hex[] = " %-30s 0x%02X\n";
45072 +static const char fmt_table[] = " %-30s %10u %10u %10u %10u\n";
45073 +static const char fmt_header[] =
45074 "%-32s current cumulative delta max\n";
45075
45076 static int iwl_statistics_flag(struct iwl_priv *priv, char *buf, int bufsz)
45077 @@ -1856,7 +1856,7 @@ static ssize_t iwl_dbgfs_clear_ucode_statistics_write(struct file *file,
45078 {
45079 struct iwl_priv *priv = file->private_data;
45080 char buf[8];
45081 - int buf_size;
45082 + size_t buf_size;
45083 int clear;
45084
45085 memset(buf, 0, sizeof(buf));
45086 @@ -1901,7 +1901,7 @@ static ssize_t iwl_dbgfs_ucode_tracing_write(struct file *file,
45087 {
45088 struct iwl_priv *priv = file->private_data;
45089 char buf[8];
45090 - int buf_size;
45091 + size_t buf_size;
45092 int trace;
45093
45094 memset(buf, 0, sizeof(buf));
45095 @@ -1972,7 +1972,7 @@ static ssize_t iwl_dbgfs_missed_beacon_write(struct file *file,
45096 {
45097 struct iwl_priv *priv = file->private_data;
45098 char buf[8];
45099 - int buf_size;
45100 + size_t buf_size;
45101 int missed;
45102
45103 memset(buf, 0, sizeof(buf));
45104 @@ -2013,7 +2013,7 @@ static ssize_t iwl_dbgfs_plcp_delta_write(struct file *file,
45105
45106 struct iwl_priv *priv = file->private_data;
45107 char buf[8];
45108 - int buf_size;
45109 + size_t buf_size;
45110 int plcp;
45111
45112 memset(buf, 0, sizeof(buf));
45113 @@ -2073,7 +2073,7 @@ static ssize_t iwl_dbgfs_txfifo_flush_write(struct file *file,
45114
45115 struct iwl_priv *priv = file->private_data;
45116 char buf[8];
45117 - int buf_size;
45118 + size_t buf_size;
45119 int flush;
45120
45121 memset(buf, 0, sizeof(buf));
45122 @@ -2163,7 +2163,7 @@ static ssize_t iwl_dbgfs_protection_mode_write(struct file *file,
45123
45124 struct iwl_priv *priv = file->private_data;
45125 char buf[8];
45126 - int buf_size;
45127 + size_t buf_size;
45128 int rts;
45129
45130 if (!priv->cfg->ht_params)
45131 @@ -2205,7 +2205,7 @@ static ssize_t iwl_dbgfs_echo_test_write(struct file *file,
45132 {
45133 struct iwl_priv *priv = file->private_data;
45134 char buf[8];
45135 - int buf_size;
45136 + size_t buf_size;
45137
45138 memset(buf, 0, sizeof(buf));
45139 buf_size = min(count, sizeof(buf) - 1);
45140 @@ -2239,7 +2239,7 @@ static ssize_t iwl_dbgfs_log_event_write(struct file *file,
45141 struct iwl_priv *priv = file->private_data;
45142 u32 event_log_flag;
45143 char buf[8];
45144 - int buf_size;
45145 + size_t buf_size;
45146
45147 /* check that the interface is up */
45148 if (!iwl_is_ready(priv))
45149 @@ -2293,7 +2293,7 @@ static ssize_t iwl_dbgfs_calib_disabled_write(struct file *file,
45150 struct iwl_priv *priv = file->private_data;
45151 char buf[8];
45152 u32 calib_disabled;
45153 - int buf_size;
45154 + size_t buf_size;
45155
45156 memset(buf, 0, sizeof(buf));
45157 buf_size = min(count, sizeof(buf) - 1);
45158 diff --git a/drivers/net/wireless/iwlwifi/dvm/main.c b/drivers/net/wireless/iwlwifi/dvm/main.c
45159 index 7aad766..06addb4 100644
45160 --- a/drivers/net/wireless/iwlwifi/dvm/main.c
45161 +++ b/drivers/net/wireless/iwlwifi/dvm/main.c
45162 @@ -1123,7 +1123,7 @@ static void iwl_option_config(struct iwl_priv *priv)
45163 static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45164 {
45165 struct iwl_nvm_data *data = priv->nvm_data;
45166 - char *debug_msg;
45167 + static const char debug_msg[] = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45168
45169 if (data->sku_cap_11n_enable &&
45170 !priv->cfg->ht_params) {
45171 @@ -1137,7 +1137,6 @@ static int iwl_eeprom_init_hw_params(struct iwl_priv *priv)
45172 return -EINVAL;
45173 }
45174
45175 - debug_msg = "Device SKU: 24GHz %s %s, 52GHz %s %s, 11.n %s %s\n";
45176 IWL_DEBUG_INFO(priv, debug_msg,
45177 data->sku_cap_band_24GHz_enable ? "" : "NOT", "enabled",
45178 data->sku_cap_band_52GHz_enable ? "" : "NOT", "enabled",
45179 diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
45180 index 6bc3100..dd1b80d 100644
45181 --- a/drivers/net/wireless/iwlwifi/pcie/trans.c
45182 +++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
45183 @@ -1249,7 +1249,7 @@ static ssize_t iwl_dbgfs_interrupt_write(struct file *file,
45184 struct isr_statistics *isr_stats = &trans_pcie->isr_stats;
45185
45186 char buf[8];
45187 - int buf_size;
45188 + size_t buf_size;
45189 u32 reset_flag;
45190
45191 memset(buf, 0, sizeof(buf));
45192 @@ -1270,7 +1270,7 @@ static ssize_t iwl_dbgfs_csr_write(struct file *file,
45193 {
45194 struct iwl_trans *trans = file->private_data;
45195 char buf[8];
45196 - int buf_size;
45197 + size_t buf_size;
45198 int csr;
45199
45200 memset(buf, 0, sizeof(buf));
45201 diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c
45202 index 2cd3f54..e936f90 100644
45203 --- a/drivers/net/wireless/mac80211_hwsim.c
45204 +++ b/drivers/net/wireless/mac80211_hwsim.c
45205 @@ -2196,25 +2196,19 @@ static int __init init_mac80211_hwsim(void)
45206
45207 if (channels > 1) {
45208 hwsim_if_comb.num_different_channels = channels;
45209 - mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45210 - mac80211_hwsim_ops.cancel_hw_scan =
45211 - mac80211_hwsim_cancel_hw_scan;
45212 - mac80211_hwsim_ops.sw_scan_start = NULL;
45213 - mac80211_hwsim_ops.sw_scan_complete = NULL;
45214 - mac80211_hwsim_ops.remain_on_channel =
45215 - mac80211_hwsim_roc;
45216 - mac80211_hwsim_ops.cancel_remain_on_channel =
45217 - mac80211_hwsim_croc;
45218 - mac80211_hwsim_ops.add_chanctx =
45219 - mac80211_hwsim_add_chanctx;
45220 - mac80211_hwsim_ops.remove_chanctx =
45221 - mac80211_hwsim_remove_chanctx;
45222 - mac80211_hwsim_ops.change_chanctx =
45223 - mac80211_hwsim_change_chanctx;
45224 - mac80211_hwsim_ops.assign_vif_chanctx =
45225 - mac80211_hwsim_assign_vif_chanctx;
45226 - mac80211_hwsim_ops.unassign_vif_chanctx =
45227 - mac80211_hwsim_unassign_vif_chanctx;
45228 + pax_open_kernel();
45229 + *(void **)&mac80211_hwsim_ops.hw_scan = mac80211_hwsim_hw_scan;
45230 + *(void **)&mac80211_hwsim_ops.cancel_hw_scan = mac80211_hwsim_cancel_hw_scan;
45231 + *(void **)&mac80211_hwsim_ops.sw_scan_start = NULL;
45232 + *(void **)&mac80211_hwsim_ops.sw_scan_complete = NULL;
45233 + *(void **)&mac80211_hwsim_ops.remain_on_channel = mac80211_hwsim_roc;
45234 + *(void **)&mac80211_hwsim_ops.cancel_remain_on_channel = mac80211_hwsim_croc;
45235 + *(void **)&mac80211_hwsim_ops.add_chanctx = mac80211_hwsim_add_chanctx;
45236 + *(void **)&mac80211_hwsim_ops.remove_chanctx = mac80211_hwsim_remove_chanctx;
45237 + *(void **)&mac80211_hwsim_ops.change_chanctx = mac80211_hwsim_change_chanctx;
45238 + *(void **)&mac80211_hwsim_ops.assign_vif_chanctx = mac80211_hwsim_assign_vif_chanctx;
45239 + *(void **)&mac80211_hwsim_ops.unassign_vif_chanctx = mac80211_hwsim_unassign_vif_chanctx;
45240 + pax_close_kernel();
45241 }
45242
45243 spin_lock_init(&hwsim_radio_lock);
45244 diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
45245 index 8169a85..7fa3b47 100644
45246 --- a/drivers/net/wireless/rndis_wlan.c
45247 +++ b/drivers/net/wireless/rndis_wlan.c
45248 @@ -1238,7 +1238,7 @@ static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold)
45249
45250 netdev_dbg(usbdev->net, "%s(): %i\n", __func__, rts_threshold);
45251
45252 - if (rts_threshold < 0 || rts_threshold > 2347)
45253 + if (rts_threshold > 2347)
45254 rts_threshold = 2347;
45255
45256 tmp = cpu_to_le32(rts_threshold);
45257 diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h
45258 index fe4c572..99dedfa 100644
45259 --- a/drivers/net/wireless/rt2x00/rt2x00.h
45260 +++ b/drivers/net/wireless/rt2x00/rt2x00.h
45261 @@ -387,7 +387,7 @@ struct rt2x00_intf {
45262 * for hardware which doesn't support hardware
45263 * sequence counting.
45264 */
45265 - atomic_t seqno;
45266 + atomic_unchecked_t seqno;
45267 };
45268
45269 static inline struct rt2x00_intf* vif_to_intf(struct ieee80211_vif *vif)
45270 diff --git a/drivers/net/wireless/rt2x00/rt2x00queue.c b/drivers/net/wireless/rt2x00/rt2x00queue.c
45271 index 66a2db8..70cad04 100644
45272 --- a/drivers/net/wireless/rt2x00/rt2x00queue.c
45273 +++ b/drivers/net/wireless/rt2x00/rt2x00queue.c
45274 @@ -252,9 +252,9 @@ static void rt2x00queue_create_tx_descriptor_seq(struct rt2x00_dev *rt2x00dev,
45275 * sequence counter given by mac80211.
45276 */
45277 if (test_bit(ENTRY_TXD_FIRST_FRAGMENT, &txdesc->flags))
45278 - seqno = atomic_add_return(0x10, &intf->seqno);
45279 + seqno = atomic_add_return_unchecked(0x10, &intf->seqno);
45280 else
45281 - seqno = atomic_read(&intf->seqno);
45282 + seqno = atomic_read_unchecked(&intf->seqno);
45283
45284 hdr->seq_ctrl &= cpu_to_le16(IEEE80211_SCTL_FRAG);
45285 hdr->seq_ctrl |= cpu_to_le16(seqno);
45286 diff --git a/drivers/net/wireless/ti/wl1251/sdio.c b/drivers/net/wireless/ti/wl1251/sdio.c
45287 index e2b3d9c..67a5184 100644
45288 --- a/drivers/net/wireless/ti/wl1251/sdio.c
45289 +++ b/drivers/net/wireless/ti/wl1251/sdio.c
45290 @@ -271,13 +271,17 @@ static int wl1251_sdio_probe(struct sdio_func *func,
45291
45292 irq_set_irq_type(wl->irq, IRQ_TYPE_EDGE_RISING);
45293
45294 - wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45295 - wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45296 + pax_open_kernel();
45297 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_enable_line_irq;
45298 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_disable_line_irq;
45299 + pax_close_kernel();
45300
45301 wl1251_info("using dedicated interrupt line");
45302 } else {
45303 - wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45304 - wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45305 + pax_open_kernel();
45306 + *(void **)&wl1251_sdio_ops.enable_irq = wl1251_sdio_enable_irq;
45307 + *(void **)&wl1251_sdio_ops.disable_irq = wl1251_sdio_disable_irq;
45308 + pax_close_kernel();
45309
45310 wl1251_info("using SDIO interrupt");
45311 }
45312 diff --git a/drivers/net/wireless/ti/wl12xx/main.c b/drivers/net/wireless/ti/wl12xx/main.c
45313 index 1c627da..69f7d17 100644
45314 --- a/drivers/net/wireless/ti/wl12xx/main.c
45315 +++ b/drivers/net/wireless/ti/wl12xx/main.c
45316 @@ -656,7 +656,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45317 sizeof(wl->conf.mem));
45318
45319 /* read data preparation is only needed by wl127x */
45320 - wl->ops->prepare_read = wl127x_prepare_read;
45321 + pax_open_kernel();
45322 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45323 + pax_close_kernel();
45324
45325 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45326 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45327 @@ -681,7 +683,9 @@ static int wl12xx_identify_chip(struct wl1271 *wl)
45328 sizeof(wl->conf.mem));
45329
45330 /* read data preparation is only needed by wl127x */
45331 - wl->ops->prepare_read = wl127x_prepare_read;
45332 + pax_open_kernel();
45333 + *(void **)&wl->ops->prepare_read = wl127x_prepare_read;
45334 + pax_close_kernel();
45335
45336 wlcore_set_min_fw_ver(wl, WL127X_CHIP_VER,
45337 WL127X_IFTYPE_SR_VER, WL127X_MAJOR_SR_VER,
45338 diff --git a/drivers/net/wireless/ti/wl18xx/main.c b/drivers/net/wireless/ti/wl18xx/main.c
45339 index 7aa0eb8..5a9ef38 100644
45340 --- a/drivers/net/wireless/ti/wl18xx/main.c
45341 +++ b/drivers/net/wireless/ti/wl18xx/main.c
45342 @@ -1730,8 +1730,10 @@ static int wl18xx_setup(struct wl1271 *wl)
45343 }
45344
45345 if (!checksum_param) {
45346 - wl18xx_ops.set_rx_csum = NULL;
45347 - wl18xx_ops.init_vif = NULL;
45348 + pax_open_kernel();
45349 + *(void **)&wl18xx_ops.set_rx_csum = NULL;
45350 + *(void **)&wl18xx_ops.init_vif = NULL;
45351 + pax_close_kernel();
45352 }
45353
45354 /* Enable 11a Band only if we have 5G antennas */
45355 diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c
45356 index 7ef0b4a..ff65c28 100644
45357 --- a/drivers/net/wireless/zd1211rw/zd_usb.c
45358 +++ b/drivers/net/wireless/zd1211rw/zd_usb.c
45359 @@ -386,7 +386,7 @@ static inline void handle_regs_int(struct urb *urb)
45360 {
45361 struct zd_usb *usb = urb->context;
45362 struct zd_usb_interrupt *intr = &usb->intr;
45363 - int len;
45364 + unsigned int len;
45365 u16 int_num;
45366
45367 ZD_ASSERT(in_interrupt());
45368 diff --git a/drivers/nfc/nfcwilink.c b/drivers/nfc/nfcwilink.c
45369 index 59f95d8..53e0e7f 100644
45370 --- a/drivers/nfc/nfcwilink.c
45371 +++ b/drivers/nfc/nfcwilink.c
45372 @@ -513,7 +513,7 @@ static struct nci_ops nfcwilink_ops = {
45373
45374 static int nfcwilink_probe(struct platform_device *pdev)
45375 {
45376 - static struct nfcwilink *drv;
45377 + struct nfcwilink *drv;
45378 int rc;
45379 __u32 protocols;
45380
45381 diff --git a/drivers/oprofile/buffer_sync.c b/drivers/oprofile/buffer_sync.c
45382 index d93b2b6..ae50401 100644
45383 --- a/drivers/oprofile/buffer_sync.c
45384 +++ b/drivers/oprofile/buffer_sync.c
45385 @@ -332,7 +332,7 @@ static void add_data(struct op_entry *entry, struct mm_struct *mm)
45386 if (cookie == NO_COOKIE)
45387 offset = pc;
45388 if (cookie == INVALID_COOKIE) {
45389 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45390 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45391 offset = pc;
45392 }
45393 if (cookie != last_cookie) {
45394 @@ -376,14 +376,14 @@ add_sample(struct mm_struct *mm, struct op_sample *s, int in_kernel)
45395 /* add userspace sample */
45396
45397 if (!mm) {
45398 - atomic_inc(&oprofile_stats.sample_lost_no_mm);
45399 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mm);
45400 return 0;
45401 }
45402
45403 cookie = lookup_dcookie(mm, s->eip, &offset);
45404
45405 if (cookie == INVALID_COOKIE) {
45406 - atomic_inc(&oprofile_stats.sample_lost_no_mapping);
45407 + atomic_inc_unchecked(&oprofile_stats.sample_lost_no_mapping);
45408 return 0;
45409 }
45410
45411 @@ -552,7 +552,7 @@ void sync_buffer(int cpu)
45412 /* ignore backtraces if failed to add a sample */
45413 if (state == sb_bt_start) {
45414 state = sb_bt_ignore;
45415 - atomic_inc(&oprofile_stats.bt_lost_no_mapping);
45416 + atomic_inc_unchecked(&oprofile_stats.bt_lost_no_mapping);
45417 }
45418 }
45419 release_mm(mm);
45420 diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
45421 index c0cc4e7..44d4e54 100644
45422 --- a/drivers/oprofile/event_buffer.c
45423 +++ b/drivers/oprofile/event_buffer.c
45424 @@ -53,7 +53,7 @@ void add_event_entry(unsigned long value)
45425 }
45426
45427 if (buffer_pos == buffer_size) {
45428 - atomic_inc(&oprofile_stats.event_lost_overflow);
45429 + atomic_inc_unchecked(&oprofile_stats.event_lost_overflow);
45430 return;
45431 }
45432
45433 diff --git a/drivers/oprofile/oprof.c b/drivers/oprofile/oprof.c
45434 index ed2c3ec..deda85a 100644
45435 --- a/drivers/oprofile/oprof.c
45436 +++ b/drivers/oprofile/oprof.c
45437 @@ -110,7 +110,7 @@ static void switch_worker(struct work_struct *work)
45438 if (oprofile_ops.switch_events())
45439 return;
45440
45441 - atomic_inc(&oprofile_stats.multiplex_counter);
45442 + atomic_inc_unchecked(&oprofile_stats.multiplex_counter);
45443 start_switch_worker();
45444 }
45445
45446 diff --git a/drivers/oprofile/oprofile_files.c b/drivers/oprofile/oprofile_files.c
45447 index ee2cfce..7f8f699 100644
45448 --- a/drivers/oprofile/oprofile_files.c
45449 +++ b/drivers/oprofile/oprofile_files.c
45450 @@ -27,7 +27,7 @@ unsigned long oprofile_time_slice;
45451
45452 #ifdef CONFIG_OPROFILE_EVENT_MULTIPLEX
45453
45454 -static ssize_t timeout_read(struct file *file, char __user *buf,
45455 +static ssize_t __intentional_overflow(-1) timeout_read(struct file *file, char __user *buf,
45456 size_t count, loff_t *offset)
45457 {
45458 return oprofilefs_ulong_to_user(jiffies_to_msecs(oprofile_time_slice),
45459 diff --git a/drivers/oprofile/oprofile_stats.c b/drivers/oprofile/oprofile_stats.c
45460 index 59659ce..6c860a0 100644
45461 --- a/drivers/oprofile/oprofile_stats.c
45462 +++ b/drivers/oprofile/oprofile_stats.c
45463 @@ -30,11 +30,11 @@ void oprofile_reset_stats(void)
45464 cpu_buf->sample_invalid_eip = 0;
45465 }
45466
45467 - atomic_set(&oprofile_stats.sample_lost_no_mm, 0);
45468 - atomic_set(&oprofile_stats.sample_lost_no_mapping, 0);
45469 - atomic_set(&oprofile_stats.event_lost_overflow, 0);
45470 - atomic_set(&oprofile_stats.bt_lost_no_mapping, 0);
45471 - atomic_set(&oprofile_stats.multiplex_counter, 0);
45472 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mm, 0);
45473 + atomic_set_unchecked(&oprofile_stats.sample_lost_no_mapping, 0);
45474 + atomic_set_unchecked(&oprofile_stats.event_lost_overflow, 0);
45475 + atomic_set_unchecked(&oprofile_stats.bt_lost_no_mapping, 0);
45476 + atomic_set_unchecked(&oprofile_stats.multiplex_counter, 0);
45477 }
45478
45479
45480 diff --git a/drivers/oprofile/oprofile_stats.h b/drivers/oprofile/oprofile_stats.h
45481 index 1fc622b..8c48fc3 100644
45482 --- a/drivers/oprofile/oprofile_stats.h
45483 +++ b/drivers/oprofile/oprofile_stats.h
45484 @@ -13,11 +13,11 @@
45485 #include <linux/atomic.h>
45486
45487 struct oprofile_stat_struct {
45488 - atomic_t sample_lost_no_mm;
45489 - atomic_t sample_lost_no_mapping;
45490 - atomic_t bt_lost_no_mapping;
45491 - atomic_t event_lost_overflow;
45492 - atomic_t multiplex_counter;
45493 + atomic_unchecked_t sample_lost_no_mm;
45494 + atomic_unchecked_t sample_lost_no_mapping;
45495 + atomic_unchecked_t bt_lost_no_mapping;
45496 + atomic_unchecked_t event_lost_overflow;
45497 + atomic_unchecked_t multiplex_counter;
45498 };
45499
45500 extern struct oprofile_stat_struct oprofile_stats;
45501 diff --git a/drivers/oprofile/oprofilefs.c b/drivers/oprofile/oprofilefs.c
45502 index 3f49345..c750d0b 100644
45503 --- a/drivers/oprofile/oprofilefs.c
45504 +++ b/drivers/oprofile/oprofilefs.c
45505 @@ -176,8 +176,8 @@ int oprofilefs_create_ro_ulong(struct dentry *root,
45506
45507 static ssize_t atomic_read_file(struct file *file, char __user *buf, size_t count, loff_t *offset)
45508 {
45509 - atomic_t *val = file->private_data;
45510 - return oprofilefs_ulong_to_user(atomic_read(val), buf, count, offset);
45511 + atomic_unchecked_t *val = file->private_data;
45512 + return oprofilefs_ulong_to_user(atomic_read_unchecked(val), buf, count, offset);
45513 }
45514
45515
45516 @@ -189,7 +189,7 @@ static const struct file_operations atomic_ro_fops = {
45517
45518
45519 int oprofilefs_create_ro_atomic(struct dentry *root,
45520 - char const *name, atomic_t *val)
45521 + char const *name, atomic_unchecked_t *val)
45522 {
45523 return __oprofilefs_create_file(root, name,
45524 &atomic_ro_fops, 0444, val);
45525 diff --git a/drivers/oprofile/timer_int.c b/drivers/oprofile/timer_int.c
45526 index 61be1d9..dec05d7 100644
45527 --- a/drivers/oprofile/timer_int.c
45528 +++ b/drivers/oprofile/timer_int.c
45529 @@ -93,7 +93,7 @@ static int oprofile_cpu_notify(struct notifier_block *self,
45530 return NOTIFY_OK;
45531 }
45532
45533 -static struct notifier_block __refdata oprofile_cpu_notifier = {
45534 +static struct notifier_block oprofile_cpu_notifier = {
45535 .notifier_call = oprofile_cpu_notify,
45536 };
45537
45538 diff --git a/drivers/parport/procfs.c b/drivers/parport/procfs.c
45539 index 92ed045..62d39bd7 100644
45540 --- a/drivers/parport/procfs.c
45541 +++ b/drivers/parport/procfs.c
45542 @@ -64,7 +64,7 @@ static int do_active_device(ctl_table *table, int write,
45543
45544 *ppos += len;
45545
45546 - return copy_to_user(result, buffer, len) ? -EFAULT : 0;
45547 + return (len > sizeof buffer || copy_to_user(result, buffer, len)) ? -EFAULT : 0;
45548 }
45549
45550 #ifdef CONFIG_PARPORT_1284
45551 @@ -106,7 +106,7 @@ static int do_autoprobe(ctl_table *table, int write,
45552
45553 *ppos += len;
45554
45555 - return copy_to_user (result, buffer, len) ? -EFAULT : 0;
45556 + return (len > sizeof buffer || copy_to_user (result, buffer, len)) ? -EFAULT : 0;
45557 }
45558 #endif /* IEEE1284.3 support. */
45559
45560 diff --git a/drivers/pci/hotplug/acpiphp_ibm.c b/drivers/pci/hotplug/acpiphp_ibm.c
45561 index 2f5786c..61ab4d1 100644
45562 --- a/drivers/pci/hotplug/acpiphp_ibm.c
45563 +++ b/drivers/pci/hotplug/acpiphp_ibm.c
45564 @@ -463,7 +463,9 @@ static int __init ibm_acpiphp_init(void)
45565 goto init_cleanup;
45566 }
45567
45568 - ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45569 + pax_open_kernel();
45570 + *(size_t *)&ibm_apci_table_attr.size = ibm_get_table_from_acpi(NULL);
45571 + pax_close_kernel();
45572 retval = sysfs_create_bin_file(sysdir, &ibm_apci_table_attr);
45573
45574 return retval;
45575 diff --git a/drivers/pci/hotplug/cpcihp_generic.c b/drivers/pci/hotplug/cpcihp_generic.c
45576 index a6a71c4..c91097b 100644
45577 --- a/drivers/pci/hotplug/cpcihp_generic.c
45578 +++ b/drivers/pci/hotplug/cpcihp_generic.c
45579 @@ -73,7 +73,6 @@ static u16 port;
45580 static unsigned int enum_bit;
45581 static u8 enum_mask;
45582
45583 -static struct cpci_hp_controller_ops generic_hpc_ops;
45584 static struct cpci_hp_controller generic_hpc;
45585
45586 static int __init validate_parameters(void)
45587 @@ -139,6 +138,10 @@ static int query_enum(void)
45588 return ((value & enum_mask) == enum_mask);
45589 }
45590
45591 +static struct cpci_hp_controller_ops generic_hpc_ops = {
45592 + .query_enum = query_enum,
45593 +};
45594 +
45595 static int __init cpcihp_generic_init(void)
45596 {
45597 int status;
45598 @@ -165,7 +168,6 @@ static int __init cpcihp_generic_init(void)
45599 pci_dev_put(dev);
45600
45601 memset(&generic_hpc, 0, sizeof (struct cpci_hp_controller));
45602 - generic_hpc_ops.query_enum = query_enum;
45603 generic_hpc.ops = &generic_hpc_ops;
45604
45605 status = cpci_hp_register_controller(&generic_hpc);
45606 diff --git a/drivers/pci/hotplug/cpcihp_zt5550.c b/drivers/pci/hotplug/cpcihp_zt5550.c
45607 index 449b4bb..257e2e8 100644
45608 --- a/drivers/pci/hotplug/cpcihp_zt5550.c
45609 +++ b/drivers/pci/hotplug/cpcihp_zt5550.c
45610 @@ -59,7 +59,6 @@
45611 /* local variables */
45612 static bool debug;
45613 static bool poll;
45614 -static struct cpci_hp_controller_ops zt5550_hpc_ops;
45615 static struct cpci_hp_controller zt5550_hpc;
45616
45617 /* Primary cPCI bus bridge device */
45618 @@ -205,6 +204,10 @@ static int zt5550_hc_disable_irq(void)
45619 return 0;
45620 }
45621
45622 +static struct cpci_hp_controller_ops zt5550_hpc_ops = {
45623 + .query_enum = zt5550_hc_query_enum,
45624 +};
45625 +
45626 static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id *ent)
45627 {
45628 int status;
45629 @@ -216,16 +219,17 @@ static int zt5550_hc_init_one (struct pci_dev *pdev, const struct pci_device_id
45630 dbg("returned from zt5550_hc_config");
45631
45632 memset(&zt5550_hpc, 0, sizeof (struct cpci_hp_controller));
45633 - zt5550_hpc_ops.query_enum = zt5550_hc_query_enum;
45634 zt5550_hpc.ops = &zt5550_hpc_ops;
45635 if(!poll) {
45636 zt5550_hpc.irq = hc_dev->irq;
45637 zt5550_hpc.irq_flags = IRQF_SHARED;
45638 zt5550_hpc.dev_id = hc_dev;
45639
45640 - zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45641 - zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45642 - zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45643 + pax_open_kernel();
45644 + *(void **)&zt5550_hpc_ops.enable_irq = zt5550_hc_enable_irq;
45645 + *(void **)&zt5550_hpc_ops.disable_irq = zt5550_hc_disable_irq;
45646 + *(void **)&zt5550_hpc_ops.check_irq = zt5550_hc_check_irq;
45647 + pax_open_kernel();
45648 } else {
45649 info("using ENUM# polling mode");
45650 }
45651 diff --git a/drivers/pci/hotplug/cpqphp_nvram.c b/drivers/pci/hotplug/cpqphp_nvram.c
45652 index 76ba8a1..20ca857 100644
45653 --- a/drivers/pci/hotplug/cpqphp_nvram.c
45654 +++ b/drivers/pci/hotplug/cpqphp_nvram.c
45655 @@ -428,9 +428,13 @@ static u32 store_HRT (void __iomem *rom_start)
45656
45657 void compaq_nvram_init (void __iomem *rom_start)
45658 {
45659 +
45660 +#ifndef CONFIG_PAX_KERNEXEC
45661 if (rom_start) {
45662 compaq_int15_entry_point = (rom_start + ROM_INT15_PHY_ADDR - ROM_PHY_ADDR);
45663 }
45664 +#endif
45665 +
45666 dbg("int15 entry = %p\n", compaq_int15_entry_point);
45667
45668 /* initialize our int15 lock */
45669 diff --git a/drivers/pci/hotplug/pci_hotplug_core.c b/drivers/pci/hotplug/pci_hotplug_core.c
45670 index ec20f74..c1d961e 100644
45671 --- a/drivers/pci/hotplug/pci_hotplug_core.c
45672 +++ b/drivers/pci/hotplug/pci_hotplug_core.c
45673 @@ -441,8 +441,10 @@ int __pci_hp_register(struct hotplug_slot *slot, struct pci_bus *bus,
45674 return -EINVAL;
45675 }
45676
45677 - slot->ops->owner = owner;
45678 - slot->ops->mod_name = mod_name;
45679 + pax_open_kernel();
45680 + *(struct module **)&slot->ops->owner = owner;
45681 + *(const char **)&slot->ops->mod_name = mod_name;
45682 + pax_close_kernel();
45683
45684 mutex_lock(&pci_hp_mutex);
45685 /*
45686 diff --git a/drivers/pci/hotplug/pciehp_core.c b/drivers/pci/hotplug/pciehp_core.c
45687 index f4a18f5..ff2463c 100644
45688 --- a/drivers/pci/hotplug/pciehp_core.c
45689 +++ b/drivers/pci/hotplug/pciehp_core.c
45690 @@ -92,7 +92,7 @@ static int init_slot(struct controller *ctrl)
45691 struct slot *slot = ctrl->slot;
45692 struct hotplug_slot *hotplug = NULL;
45693 struct hotplug_slot_info *info = NULL;
45694 - struct hotplug_slot_ops *ops = NULL;
45695 + hotplug_slot_ops_no_const *ops = NULL;
45696 char name[SLOT_NAME_SIZE];
45697 int retval = -ENOMEM;
45698
45699 diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
45700 index 7128cfd..a0640d6 100644
45701 --- a/drivers/pci/pci-sysfs.c
45702 +++ b/drivers/pci/pci-sysfs.c
45703 @@ -1083,7 +1083,7 @@ static int pci_create_attr(struct pci_dev *pdev, int num, int write_combine)
45704 {
45705 /* allocate attribute structure, piggyback attribute name */
45706 int name_len = write_combine ? 13 : 10;
45707 - struct bin_attribute *res_attr;
45708 + bin_attribute_no_const *res_attr;
45709 int retval;
45710
45711 res_attr = kzalloc(sizeof(*res_attr) + name_len, GFP_ATOMIC);
45712 @@ -1268,7 +1268,7 @@ static struct device_attribute reset_attr = __ATTR(reset, 0200, NULL, reset_stor
45713 static int pci_create_capabilities_sysfs(struct pci_dev *dev)
45714 {
45715 int retval;
45716 - struct bin_attribute *attr;
45717 + bin_attribute_no_const *attr;
45718
45719 /* If the device has VPD, try to expose it in sysfs. */
45720 if (dev->vpd) {
45721 @@ -1315,7 +1315,7 @@ int __must_check pci_create_sysfs_dev_files (struct pci_dev *pdev)
45722 {
45723 int retval;
45724 int rom_size = 0;
45725 - struct bin_attribute *attr;
45726 + bin_attribute_no_const *attr;
45727
45728 if (!sysfs_initialized)
45729 return -EACCES;
45730 diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h
45731 index 8a00c06..18a9715 100644
45732 --- a/drivers/pci/pci.h
45733 +++ b/drivers/pci/pci.h
45734 @@ -95,7 +95,7 @@ struct pci_vpd_ops {
45735 struct pci_vpd {
45736 unsigned int len;
45737 const struct pci_vpd_ops *ops;
45738 - struct bin_attribute *attr; /* descriptor for sysfs VPD entry */
45739 + bin_attribute_no_const *attr; /* descriptor for sysfs VPD entry */
45740 };
45741
45742 int pci_vpd_pci22_init(struct pci_dev *dev);
45743 diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c
45744 index 403a443..034e050 100644
45745 --- a/drivers/pci/pcie/aspm.c
45746 +++ b/drivers/pci/pcie/aspm.c
45747 @@ -27,9 +27,9 @@
45748 #define MODULE_PARAM_PREFIX "pcie_aspm."
45749
45750 /* Note: those are not register definitions */
45751 -#define ASPM_STATE_L0S_UP (1) /* Upstream direction L0s state */
45752 -#define ASPM_STATE_L0S_DW (2) /* Downstream direction L0s state */
45753 -#define ASPM_STATE_L1 (4) /* L1 state */
45754 +#define ASPM_STATE_L0S_UP (1U) /* Upstream direction L0s state */
45755 +#define ASPM_STATE_L0S_DW (2U) /* Downstream direction L0s state */
45756 +#define ASPM_STATE_L1 (4U) /* L1 state */
45757 #define ASPM_STATE_L0S (ASPM_STATE_L0S_UP | ASPM_STATE_L0S_DW)
45758 #define ASPM_STATE_ALL (ASPM_STATE_L0S | ASPM_STATE_L1)
45759
45760 diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
45761 index 7ef0f86..17b710f 100644
45762 --- a/drivers/pci/probe.c
45763 +++ b/drivers/pci/probe.c
45764 @@ -175,7 +175,7 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
45765 struct pci_bus_region region, inverted_region;
45766 bool bar_too_big = false, bar_disabled = false;
45767
45768 - mask = type ? PCI_ROM_ADDRESS_MASK : ~0;
45769 + mask = type ? (u32)PCI_ROM_ADDRESS_MASK : ~0;
45770
45771 /* No printks while decoding is disabled! */
45772 if (!dev->mmio_always_on) {
45773 diff --git a/drivers/pci/proc.c b/drivers/pci/proc.c
45774 index cdc7836..528635c 100644
45775 --- a/drivers/pci/proc.c
45776 +++ b/drivers/pci/proc.c
45777 @@ -434,7 +434,16 @@ static const struct file_operations proc_bus_pci_dev_operations = {
45778 static int __init pci_proc_init(void)
45779 {
45780 struct pci_dev *dev = NULL;
45781 +
45782 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
45783 +#ifdef CONFIG_GRKERNSEC_PROC_USER
45784 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR, NULL);
45785 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
45786 + proc_bus_pci_dir = proc_mkdir_mode("bus/pci", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
45787 +#endif
45788 +#else
45789 proc_bus_pci_dir = proc_mkdir("bus/pci", NULL);
45790 +#endif
45791 proc_create("devices", 0, proc_bus_pci_dir,
45792 &proc_bus_pci_dev_operations);
45793 proc_initialized = 1;
45794 diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
45795 index 19c313b..ed28b38 100644
45796 --- a/drivers/platform/x86/asus-wmi.c
45797 +++ b/drivers/platform/x86/asus-wmi.c
45798 @@ -1618,6 +1618,10 @@ static int show_dsts(struct seq_file *m, void *data)
45799 int err;
45800 u32 retval = -1;
45801
45802 +#ifdef CONFIG_GRKERNSEC_KMEM
45803 + return -EPERM;
45804 +#endif
45805 +
45806 err = asus_wmi_get_devstate(asus, asus->debug.dev_id, &retval);
45807
45808 if (err < 0)
45809 @@ -1634,6 +1638,10 @@ static int show_devs(struct seq_file *m, void *data)
45810 int err;
45811 u32 retval = -1;
45812
45813 +#ifdef CONFIG_GRKERNSEC_KMEM
45814 + return -EPERM;
45815 +#endif
45816 +
45817 err = asus_wmi_set_devstate(asus->debug.dev_id, asus->debug.ctrl_param,
45818 &retval);
45819
45820 @@ -1658,6 +1666,10 @@ static int show_call(struct seq_file *m, void *data)
45821 union acpi_object *obj;
45822 acpi_status status;
45823
45824 +#ifdef CONFIG_GRKERNSEC_KMEM
45825 + return -EPERM;
45826 +#endif
45827 +
45828 status = wmi_evaluate_method(ASUS_WMI_MGMT_GUID,
45829 1, asus->debug.method_id,
45830 &input, &output);
45831 diff --git a/drivers/platform/x86/chromeos_laptop.c b/drivers/platform/x86/chromeos_laptop.c
45832 index 3e5b4497..dcdfb70 100644
45833 --- a/drivers/platform/x86/chromeos_laptop.c
45834 +++ b/drivers/platform/x86/chromeos_laptop.c
45835 @@ -301,7 +301,7 @@ static int __init setup_tsl2563_als(const struct dmi_system_id *id)
45836 return 0;
45837 }
45838
45839 -static struct dmi_system_id __initdata chromeos_laptop_dmi_table[] = {
45840 +static struct dmi_system_id __initconst chromeos_laptop_dmi_table[] = {
45841 {
45842 .ident = "Samsung Series 5 550 - Touchpad",
45843 .matches = {
45844 diff --git a/drivers/platform/x86/msi-laptop.c b/drivers/platform/x86/msi-laptop.c
45845 index 62f8030..c7f2a45 100644
45846 --- a/drivers/platform/x86/msi-laptop.c
45847 +++ b/drivers/platform/x86/msi-laptop.c
45848 @@ -1000,12 +1000,14 @@ static int __init load_scm_model_init(struct platform_device *sdev)
45849
45850 if (!quirks->ec_read_only) {
45851 /* allow userland write sysfs file */
45852 - dev_attr_bluetooth.store = store_bluetooth;
45853 - dev_attr_wlan.store = store_wlan;
45854 - dev_attr_threeg.store = store_threeg;
45855 - dev_attr_bluetooth.attr.mode |= S_IWUSR;
45856 - dev_attr_wlan.attr.mode |= S_IWUSR;
45857 - dev_attr_threeg.attr.mode |= S_IWUSR;
45858 + pax_open_kernel();
45859 + *(void **)&dev_attr_bluetooth.store = store_bluetooth;
45860 + *(void **)&dev_attr_wlan.store = store_wlan;
45861 + *(void **)&dev_attr_threeg.store = store_threeg;
45862 + *(umode_t *)&dev_attr_bluetooth.attr.mode |= S_IWUSR;
45863 + *(umode_t *)&dev_attr_wlan.attr.mode |= S_IWUSR;
45864 + *(umode_t *)&dev_attr_threeg.attr.mode |= S_IWUSR;
45865 + pax_close_kernel();
45866 }
45867
45868 /* disable hardware control by fn key */
45869 diff --git a/drivers/platform/x86/msi-wmi.c b/drivers/platform/x86/msi-wmi.c
45870 index 70222f2..8c8ce66 100644
45871 --- a/drivers/platform/x86/msi-wmi.c
45872 +++ b/drivers/platform/x86/msi-wmi.c
45873 @@ -183,7 +183,7 @@ static const struct backlight_ops msi_backlight_ops = {
45874 static void msi_wmi_notify(u32 value, void *context)
45875 {
45876 struct acpi_buffer response = { ACPI_ALLOCATE_BUFFER, NULL };
45877 - static struct key_entry *key;
45878 + struct key_entry *key;
45879 union acpi_object *obj;
45880 acpi_status status;
45881
45882 diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
45883 index 3484dd2..13ee730 100644
45884 --- a/drivers/platform/x86/sony-laptop.c
45885 +++ b/drivers/platform/x86/sony-laptop.c
45886 @@ -2448,7 +2448,7 @@ static void sony_nc_gfx_switch_cleanup(struct platform_device *pd)
45887 }
45888
45889 /* High speed charging function */
45890 -static struct device_attribute *hsc_handle;
45891 +static device_attribute_no_const *hsc_handle;
45892
45893 static ssize_t sony_nc_highspeed_charging_store(struct device *dev,
45894 struct device_attribute *attr,
45895 diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c
45896 index 4e86e97..04d50d1 100644
45897 --- a/drivers/platform/x86/thinkpad_acpi.c
45898 +++ b/drivers/platform/x86/thinkpad_acpi.c
45899 @@ -2091,7 +2091,7 @@ static int hotkey_mask_get(void)
45900 return 0;
45901 }
45902
45903 -void static hotkey_mask_warn_incomplete_mask(void)
45904 +static void hotkey_mask_warn_incomplete_mask(void)
45905 {
45906 /* log only what the user can fix... */
45907 const u32 wantedmask = hotkey_driver_mask &
45908 @@ -2318,11 +2318,6 @@ static void hotkey_read_nvram(struct tp_nvram_state *n, const u32 m)
45909 }
45910 }
45911
45912 -static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45913 - struct tp_nvram_state *newn,
45914 - const u32 event_mask)
45915 -{
45916 -
45917 #define TPACPI_COMPARE_KEY(__scancode, __member) \
45918 do { \
45919 if ((event_mask & (1 << __scancode)) && \
45920 @@ -2336,36 +2331,42 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45921 tpacpi_hotkey_send_key(__scancode); \
45922 } while (0)
45923
45924 - void issue_volchange(const unsigned int oldvol,
45925 - const unsigned int newvol)
45926 - {
45927 - unsigned int i = oldvol;
45928 +static void issue_volchange(const unsigned int oldvol,
45929 + const unsigned int newvol,
45930 + const u32 event_mask)
45931 +{
45932 + unsigned int i = oldvol;
45933
45934 - while (i > newvol) {
45935 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45936 - i--;
45937 - }
45938 - while (i < newvol) {
45939 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45940 - i++;
45941 - }
45942 + while (i > newvol) {
45943 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEDOWN);
45944 + i--;
45945 }
45946 + while (i < newvol) {
45947 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45948 + i++;
45949 + }
45950 +}
45951
45952 - void issue_brightnesschange(const unsigned int oldbrt,
45953 - const unsigned int newbrt)
45954 - {
45955 - unsigned int i = oldbrt;
45956 +static void issue_brightnesschange(const unsigned int oldbrt,
45957 + const unsigned int newbrt,
45958 + const u32 event_mask)
45959 +{
45960 + unsigned int i = oldbrt;
45961
45962 - while (i > newbrt) {
45963 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45964 - i--;
45965 - }
45966 - while (i < newbrt) {
45967 - TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45968 - i++;
45969 - }
45970 + while (i > newbrt) {
45971 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNEND);
45972 + i--;
45973 + }
45974 + while (i < newbrt) {
45975 + TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
45976 + i++;
45977 }
45978 +}
45979
45980 +static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45981 + struct tp_nvram_state *newn,
45982 + const u32 event_mask)
45983 +{
45984 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_THINKPAD, thinkpad_toggle);
45985 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNSPACE, zoom_toggle);
45986 TPACPI_COMPARE_KEY(TP_ACPI_HOTKEYSCAN_FNF7, display_toggle);
45987 @@ -2399,7 +2400,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45988 oldn->volume_level != newn->volume_level) {
45989 /* recently muted, or repeated mute keypress, or
45990 * multiple presses ending in mute */
45991 - issue_volchange(oldn->volume_level, newn->volume_level);
45992 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
45993 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_MUTE);
45994 }
45995 } else {
45996 @@ -2409,7 +2410,7 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
45997 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_VOLUMEUP);
45998 }
45999 if (oldn->volume_level != newn->volume_level) {
46000 - issue_volchange(oldn->volume_level, newn->volume_level);
46001 + issue_volchange(oldn->volume_level, newn->volume_level, event_mask);
46002 } else if (oldn->volume_toggle != newn->volume_toggle) {
46003 /* repeated vol up/down keypress at end of scale ? */
46004 if (newn->volume_level == 0)
46005 @@ -2422,7 +2423,8 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46006 /* handle brightness */
46007 if (oldn->brightness_level != newn->brightness_level) {
46008 issue_brightnesschange(oldn->brightness_level,
46009 - newn->brightness_level);
46010 + newn->brightness_level,
46011 + event_mask);
46012 } else if (oldn->brightness_toggle != newn->brightness_toggle) {
46013 /* repeated key presses that didn't change state */
46014 if (newn->brightness_level == 0)
46015 @@ -2431,10 +2433,10 @@ static void hotkey_compare_and_issue_event(struct tp_nvram_state *oldn,
46016 && !tp_features.bright_unkfw)
46017 TPACPI_MAY_SEND_KEY(TP_ACPI_HOTKEYSCAN_FNHOME);
46018 }
46019 +}
46020
46021 #undef TPACPI_COMPARE_KEY
46022 #undef TPACPI_MAY_SEND_KEY
46023 -}
46024
46025 /*
46026 * Polling driver
46027 diff --git a/drivers/pnp/pnpbios/bioscalls.c b/drivers/pnp/pnpbios/bioscalls.c
46028 index 769d265..a3a05ca 100644
46029 --- a/drivers/pnp/pnpbios/bioscalls.c
46030 +++ b/drivers/pnp/pnpbios/bioscalls.c
46031 @@ -58,7 +58,7 @@ do { \
46032 set_desc_limit(&gdt[(selname) >> 3], (size) - 1); \
46033 } while(0)
46034
46035 -static struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4092,
46036 +static const struct desc_struct bad_bios_desc = GDT_ENTRY_INIT(0x4093,
46037 (unsigned long)__va(0x400UL), PAGE_SIZE - 0x400 - 1);
46038
46039 /*
46040 @@ -95,7 +95,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46041
46042 cpu = get_cpu();
46043 save_desc_40 = get_cpu_gdt_table(cpu)[0x40 / 8];
46044 +
46045 + pax_open_kernel();
46046 get_cpu_gdt_table(cpu)[0x40 / 8] = bad_bios_desc;
46047 + pax_close_kernel();
46048
46049 /* On some boxes IRQ's during PnP BIOS calls are deadly. */
46050 spin_lock_irqsave(&pnp_bios_lock, flags);
46051 @@ -133,7 +136,10 @@ static inline u16 call_pnp_bios(u16 func, u16 arg1, u16 arg2, u16 arg3,
46052 :"memory");
46053 spin_unlock_irqrestore(&pnp_bios_lock, flags);
46054
46055 + pax_open_kernel();
46056 get_cpu_gdt_table(cpu)[0x40 / 8] = save_desc_40;
46057 + pax_close_kernel();
46058 +
46059 put_cpu();
46060
46061 /* If we get here and this is set then the PnP BIOS faulted on us. */
46062 @@ -467,7 +473,7 @@ int pnp_bios_read_escd(char *data, u32 nvram_base)
46063 return status;
46064 }
46065
46066 -void pnpbios_calls_init(union pnp_bios_install_struct *header)
46067 +void __init pnpbios_calls_init(union pnp_bios_install_struct *header)
46068 {
46069 int i;
46070
46071 @@ -475,6 +481,8 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46072 pnp_bios_callpoint.offset = header->fields.pm16offset;
46073 pnp_bios_callpoint.segment = PNP_CS16;
46074
46075 + pax_open_kernel();
46076 +
46077 for_each_possible_cpu(i) {
46078 struct desc_struct *gdt = get_cpu_gdt_table(i);
46079 if (!gdt)
46080 @@ -486,4 +494,6 @@ void pnpbios_calls_init(union pnp_bios_install_struct *header)
46081 set_desc_base(&gdt[GDT_ENTRY_PNPBIOS_DS],
46082 (unsigned long)__va(header->fields.pm16dseg));
46083 }
46084 +
46085 + pax_close_kernel();
46086 }
46087 diff --git a/drivers/pnp/resource.c b/drivers/pnp/resource.c
46088 index d95e101..67f0c3f 100644
46089 --- a/drivers/pnp/resource.c
46090 +++ b/drivers/pnp/resource.c
46091 @@ -360,7 +360,7 @@ int pnp_check_irq(struct pnp_dev *dev, struct resource *res)
46092 return 1;
46093
46094 /* check if the resource is valid */
46095 - if (*irq < 0 || *irq > 15)
46096 + if (*irq > 15)
46097 return 0;
46098
46099 /* check if the resource is reserved */
46100 @@ -424,7 +424,7 @@ int pnp_check_dma(struct pnp_dev *dev, struct resource *res)
46101 return 1;
46102
46103 /* check if the resource is valid */
46104 - if (*dma < 0 || *dma == 4 || *dma > 7)
46105 + if (*dma == 4 || *dma > 7)
46106 return 0;
46107
46108 /* check if the resource is reserved */
46109 diff --git a/drivers/power/pda_power.c b/drivers/power/pda_power.c
46110 index 0c52e2a..3421ab7 100644
46111 --- a/drivers/power/pda_power.c
46112 +++ b/drivers/power/pda_power.c
46113 @@ -37,7 +37,11 @@ static int polling;
46114
46115 #if IS_ENABLED(CONFIG_USB_PHY)
46116 static struct usb_phy *transceiver;
46117 -static struct notifier_block otg_nb;
46118 +static int otg_handle_notification(struct notifier_block *nb,
46119 + unsigned long event, void *unused);
46120 +static struct notifier_block otg_nb = {
46121 + .notifier_call = otg_handle_notification
46122 +};
46123 #endif
46124
46125 static struct regulator *ac_draw;
46126 @@ -369,7 +373,6 @@ static int pda_power_probe(struct platform_device *pdev)
46127
46128 #if IS_ENABLED(CONFIG_USB_PHY)
46129 if (!IS_ERR_OR_NULL(transceiver) && pdata->use_otg_notifier) {
46130 - otg_nb.notifier_call = otg_handle_notification;
46131 ret = usb_register_notifier(transceiver, &otg_nb);
46132 if (ret) {
46133 dev_err(dev, "failure to register otg notifier\n");
46134 diff --git a/drivers/power/power_supply.h b/drivers/power/power_supply.h
46135 index cc439fd..8fa30df 100644
46136 --- a/drivers/power/power_supply.h
46137 +++ b/drivers/power/power_supply.h
46138 @@ -16,12 +16,12 @@ struct power_supply;
46139
46140 #ifdef CONFIG_SYSFS
46141
46142 -extern void power_supply_init_attrs(struct device_type *dev_type);
46143 +extern void power_supply_init_attrs(void);
46144 extern int power_supply_uevent(struct device *dev, struct kobj_uevent_env *env);
46145
46146 #else
46147
46148 -static inline void power_supply_init_attrs(struct device_type *dev_type) {}
46149 +static inline void power_supply_init_attrs(void) {}
46150 #define power_supply_uevent NULL
46151
46152 #endif /* CONFIG_SYSFS */
46153 diff --git a/drivers/power/power_supply_core.c b/drivers/power/power_supply_core.c
46154 index 557af94..84dc1fe 100644
46155 --- a/drivers/power/power_supply_core.c
46156 +++ b/drivers/power/power_supply_core.c
46157 @@ -24,7 +24,10 @@
46158 struct class *power_supply_class;
46159 EXPORT_SYMBOL_GPL(power_supply_class);
46160
46161 -static struct device_type power_supply_dev_type;
46162 +extern const struct attribute_group *power_supply_attr_groups[];
46163 +static struct device_type power_supply_dev_type = {
46164 + .groups = power_supply_attr_groups,
46165 +};
46166
46167 static bool __power_supply_is_supplied_by(struct power_supply *supplier,
46168 struct power_supply *supply)
46169 @@ -584,7 +587,7 @@ static int __init power_supply_class_init(void)
46170 return PTR_ERR(power_supply_class);
46171
46172 power_supply_class->dev_uevent = power_supply_uevent;
46173 - power_supply_init_attrs(&power_supply_dev_type);
46174 + power_supply_init_attrs();
46175
46176 return 0;
46177 }
46178 diff --git a/drivers/power/power_supply_sysfs.c b/drivers/power/power_supply_sysfs.c
46179 index 44420d1..967126e 100644
46180 --- a/drivers/power/power_supply_sysfs.c
46181 +++ b/drivers/power/power_supply_sysfs.c
46182 @@ -230,17 +230,15 @@ static struct attribute_group power_supply_attr_group = {
46183 .is_visible = power_supply_attr_is_visible,
46184 };
46185
46186 -static const struct attribute_group *power_supply_attr_groups[] = {
46187 +const struct attribute_group *power_supply_attr_groups[] = {
46188 &power_supply_attr_group,
46189 NULL,
46190 };
46191
46192 -void power_supply_init_attrs(struct device_type *dev_type)
46193 +void power_supply_init_attrs(void)
46194 {
46195 int i;
46196
46197 - dev_type->groups = power_supply_attr_groups;
46198 -
46199 for (i = 0; i < ARRAY_SIZE(power_supply_attrs); i++)
46200 __power_supply_attrs[i] = &power_supply_attrs[i].attr;
46201 }
46202 diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
46203 index a01b8b3..37c2afe 100644
46204 --- a/drivers/regulator/core.c
46205 +++ b/drivers/regulator/core.c
46206 @@ -3307,7 +3307,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46207 {
46208 const struct regulation_constraints *constraints = NULL;
46209 const struct regulator_init_data *init_data;
46210 - static atomic_t regulator_no = ATOMIC_INIT(0);
46211 + static atomic_unchecked_t regulator_no = ATOMIC_INIT(0);
46212 struct regulator_dev *rdev;
46213 struct device *dev;
46214 int ret, i;
46215 @@ -3377,7 +3377,7 @@ regulator_register(const struct regulator_desc *regulator_desc,
46216 rdev->dev.of_node = config->of_node;
46217 rdev->dev.parent = dev;
46218 dev_set_name(&rdev->dev, "regulator.%d",
46219 - atomic_inc_return(&regulator_no) - 1);
46220 + atomic_inc_return_unchecked(&regulator_no) - 1);
46221 ret = device_register(&rdev->dev);
46222 if (ret != 0) {
46223 put_device(&rdev->dev);
46224 diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c
46225 index 144bcac..d20e7db 100644
46226 --- a/drivers/regulator/max8660.c
46227 +++ b/drivers/regulator/max8660.c
46228 @@ -420,8 +420,10 @@ static int max8660_probe(struct i2c_client *client,
46229 max8660->shadow_regs[MAX8660_OVER1] = 5;
46230 } else {
46231 /* Otherwise devices can be toggled via software */
46232 - max8660_dcdc_ops.enable = max8660_dcdc_enable;
46233 - max8660_dcdc_ops.disable = max8660_dcdc_disable;
46234 + pax_open_kernel();
46235 + *(void **)&max8660_dcdc_ops.enable = max8660_dcdc_enable;
46236 + *(void **)&max8660_dcdc_ops.disable = max8660_dcdc_disable;
46237 + pax_close_kernel();
46238 }
46239
46240 /*
46241 diff --git a/drivers/regulator/max8973-regulator.c b/drivers/regulator/max8973-regulator.c
46242 index 5b77ab7..a62f061 100644
46243 --- a/drivers/regulator/max8973-regulator.c
46244 +++ b/drivers/regulator/max8973-regulator.c
46245 @@ -406,9 +406,11 @@ static int max8973_probe(struct i2c_client *client,
46246 if (!pdata || !pdata->enable_ext_control) {
46247 max->desc.enable_reg = MAX8973_VOUT;
46248 max->desc.enable_mask = MAX8973_VOUT_ENABLE;
46249 - max->ops.enable = regulator_enable_regmap;
46250 - max->ops.disable = regulator_disable_regmap;
46251 - max->ops.is_enabled = regulator_is_enabled_regmap;
46252 + pax_open_kernel();
46253 + *(void **)&max->ops.enable = regulator_enable_regmap;
46254 + *(void **)&max->ops.disable = regulator_disable_regmap;
46255 + *(void **)&max->ops.is_enabled = regulator_is_enabled_regmap;
46256 + pax_close_kernel();
46257 }
46258
46259 if (pdata) {
46260 diff --git a/drivers/regulator/mc13892-regulator.c b/drivers/regulator/mc13892-regulator.c
46261 index 1037e07..e64dea1 100644
46262 --- a/drivers/regulator/mc13892-regulator.c
46263 +++ b/drivers/regulator/mc13892-regulator.c
46264 @@ -582,10 +582,12 @@ static int mc13892_regulator_probe(struct platform_device *pdev)
46265 }
46266 mc13xxx_unlock(mc13892);
46267
46268 - mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46269 + pax_open_kernel();
46270 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->set_mode
46271 = mc13892_vcam_set_mode;
46272 - mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46273 + *(void **)&mc13892_regulators[MC13892_VCAM].desc.ops->get_mode
46274 = mc13892_vcam_get_mode;
46275 + pax_close_kernel();
46276
46277 mc13xxx_data = mc13xxx_parse_regulators_dt(pdev, mc13892_regulators,
46278 ARRAY_SIZE(mc13892_regulators));
46279 diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
46280 index 24e733c..bfbaa3e 100644
46281 --- a/drivers/rtc/rtc-cmos.c
46282 +++ b/drivers/rtc/rtc-cmos.c
46283 @@ -731,7 +731,9 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
46284 hpet_rtc_timer_init();
46285
46286 /* export at least the first block of NVRAM */
46287 - nvram.size = address_space - NVRAM_OFFSET;
46288 + pax_open_kernel();
46289 + *(size_t *)&nvram.size = address_space - NVRAM_OFFSET;
46290 + pax_close_kernel();
46291 retval = sysfs_create_bin_file(&dev->kobj, &nvram);
46292 if (retval < 0) {
46293 dev_dbg(dev, "can't create nvram file? %d\n", retval);
46294 diff --git a/drivers/rtc/rtc-dev.c b/drivers/rtc/rtc-dev.c
46295 index d049393..bb20be0 100644
46296 --- a/drivers/rtc/rtc-dev.c
46297 +++ b/drivers/rtc/rtc-dev.c
46298 @@ -16,6 +16,7 @@
46299 #include <linux/module.h>
46300 #include <linux/rtc.h>
46301 #include <linux/sched.h>
46302 +#include <linux/grsecurity.h>
46303 #include "rtc-core.h"
46304
46305 static dev_t rtc_devt;
46306 @@ -347,6 +348,8 @@ static long rtc_dev_ioctl(struct file *file,
46307 if (copy_from_user(&tm, uarg, sizeof(tm)))
46308 return -EFAULT;
46309
46310 + gr_log_timechange();
46311 +
46312 return rtc_set_time(rtc, &tm);
46313
46314 case RTC_PIE_ON:
46315 diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
46316 index ca18fd1..055e42d 100644
46317 --- a/drivers/rtc/rtc-ds1307.c
46318 +++ b/drivers/rtc/rtc-ds1307.c
46319 @@ -107,7 +107,7 @@ struct ds1307 {
46320 u8 offset; /* register's offset */
46321 u8 regs[11];
46322 u16 nvram_offset;
46323 - struct bin_attribute *nvram;
46324 + bin_attribute_no_const *nvram;
46325 enum ds_type type;
46326 unsigned long flags;
46327 #define HAS_NVRAM 0 /* bit 0 == sysfs file active */
46328 diff --git a/drivers/rtc/rtc-m48t59.c b/drivers/rtc/rtc-m48t59.c
46329 index fcb0329..d77b7f2 100644
46330 --- a/drivers/rtc/rtc-m48t59.c
46331 +++ b/drivers/rtc/rtc-m48t59.c
46332 @@ -483,7 +483,9 @@ static int m48t59_rtc_probe(struct platform_device *pdev)
46333 if (IS_ERR(m48t59->rtc))
46334 return PTR_ERR(m48t59->rtc);
46335
46336 - m48t59_nvram_attr.size = pdata->offset;
46337 + pax_open_kernel();
46338 + *(size_t *)&m48t59_nvram_attr.size = pdata->offset;
46339 + pax_close_kernel();
46340
46341 ret = sysfs_create_bin_file(&pdev->dev.kobj, &m48t59_nvram_attr);
46342 if (ret)
46343 diff --git a/drivers/scsi/aic7xxx/aic79xx_pci.c b/drivers/scsi/aic7xxx/aic79xx_pci.c
46344 index 14b5f8d..cc9bd26 100644
46345 --- a/drivers/scsi/aic7xxx/aic79xx_pci.c
46346 +++ b/drivers/scsi/aic7xxx/aic79xx_pci.c
46347 @@ -827,7 +827,7 @@ ahd_pci_intr(struct ahd_softc *ahd)
46348 for (bit = 0; bit < 8; bit++) {
46349
46350 if ((pci_status[i] & (0x1 << bit)) != 0) {
46351 - static const char *s;
46352 + const char *s;
46353
46354 s = pci_status_strings[bit];
46355 if (i == 7/*TARG*/ && bit == 3)
46356 @@ -887,23 +887,15 @@ ahd_pci_split_intr(struct ahd_softc *ahd, u_int intstat)
46357
46358 for (bit = 0; bit < 8; bit++) {
46359
46360 - if ((split_status[i] & (0x1 << bit)) != 0) {
46361 - static const char *s;
46362 -
46363 - s = split_status_strings[bit];
46364 - printk(s, ahd_name(ahd),
46365 + if ((split_status[i] & (0x1 << bit)) != 0)
46366 + printk(split_status_strings[bit], ahd_name(ahd),
46367 split_status_source[i]);
46368 - }
46369
46370 if (i > 1)
46371 continue;
46372
46373 - if ((sg_split_status[i] & (0x1 << bit)) != 0) {
46374 - static const char *s;
46375 -
46376 - s = split_status_strings[bit];
46377 - printk(s, ahd_name(ahd), "SG");
46378 - }
46379 + if ((sg_split_status[i] & (0x1 << bit)) != 0)
46380 + printk(split_status_strings[bit], ahd_name(ahd), "SG");
46381 }
46382 }
46383 /*
46384 diff --git a/drivers/scsi/bfa/bfa_fcpim.h b/drivers/scsi/bfa/bfa_fcpim.h
46385 index e693af6..2e525b6 100644
46386 --- a/drivers/scsi/bfa/bfa_fcpim.h
46387 +++ b/drivers/scsi/bfa/bfa_fcpim.h
46388 @@ -36,7 +36,7 @@ struct bfa_iotag_s {
46389
46390 struct bfa_itn_s {
46391 bfa_isr_func_t isr;
46392 -};
46393 +} __no_const;
46394
46395 void bfa_itn_create(struct bfa_s *bfa, struct bfa_rport_s *rport,
46396 void (*isr)(struct bfa_s *bfa, struct bfi_msg_s *m));
46397 diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h
46398 index 90814fe..4384138 100644
46399 --- a/drivers/scsi/bfa/bfa_ioc.h
46400 +++ b/drivers/scsi/bfa/bfa_ioc.h
46401 @@ -258,7 +258,7 @@ struct bfa_ioc_cbfn_s {
46402 bfa_ioc_disable_cbfn_t disable_cbfn;
46403 bfa_ioc_hbfail_cbfn_t hbfail_cbfn;
46404 bfa_ioc_reset_cbfn_t reset_cbfn;
46405 -};
46406 +} __no_const;
46407
46408 /*
46409 * IOC event notification mechanism.
46410 @@ -352,7 +352,7 @@ struct bfa_ioc_hwif_s {
46411 void (*ioc_set_alt_fwstate) (struct bfa_ioc_s *ioc,
46412 enum bfi_ioc_state fwstate);
46413 enum bfi_ioc_state (*ioc_get_alt_fwstate) (struct bfa_ioc_s *ioc);
46414 -};
46415 +} __no_const;
46416
46417 /*
46418 * Queue element to wait for room in request queue. FIFO order is
46419 diff --git a/drivers/scsi/fcoe/fcoe_sysfs.c b/drivers/scsi/fcoe/fcoe_sysfs.c
46420 index c9382d6..6619864 100644
46421 --- a/drivers/scsi/fcoe/fcoe_sysfs.c
46422 +++ b/drivers/scsi/fcoe/fcoe_sysfs.c
46423 @@ -33,8 +33,8 @@
46424 */
46425 #include "libfcoe.h"
46426
46427 -static atomic_t ctlr_num;
46428 -static atomic_t fcf_num;
46429 +static atomic_unchecked_t ctlr_num;
46430 +static atomic_unchecked_t fcf_num;
46431
46432 /*
46433 * fcoe_fcf_dev_loss_tmo: the default number of seconds that fcoe sysfs
46434 @@ -681,7 +681,7 @@ struct fcoe_ctlr_device *fcoe_ctlr_device_add(struct device *parent,
46435 if (!ctlr)
46436 goto out;
46437
46438 - ctlr->id = atomic_inc_return(&ctlr_num) - 1;
46439 + ctlr->id = atomic_inc_return_unchecked(&ctlr_num) - 1;
46440 ctlr->f = f;
46441 ctlr->mode = FIP_CONN_TYPE_FABRIC;
46442 INIT_LIST_HEAD(&ctlr->fcfs);
46443 @@ -898,7 +898,7 @@ struct fcoe_fcf_device *fcoe_fcf_device_add(struct fcoe_ctlr_device *ctlr,
46444 fcf->dev.parent = &ctlr->dev;
46445 fcf->dev.bus = &fcoe_bus_type;
46446 fcf->dev.type = &fcoe_fcf_device_type;
46447 - fcf->id = atomic_inc_return(&fcf_num) - 1;
46448 + fcf->id = atomic_inc_return_unchecked(&fcf_num) - 1;
46449 fcf->state = FCOE_FCF_STATE_UNKNOWN;
46450
46451 fcf->dev_loss_tmo = ctlr->fcf_dev_loss_tmo;
46452 @@ -934,8 +934,8 @@ int __init fcoe_sysfs_setup(void)
46453 {
46454 int error;
46455
46456 - atomic_set(&ctlr_num, 0);
46457 - atomic_set(&fcf_num, 0);
46458 + atomic_set_unchecked(&ctlr_num, 0);
46459 + atomic_set_unchecked(&fcf_num, 0);
46460
46461 error = bus_register(&fcoe_bus_type);
46462 if (error)
46463 diff --git a/drivers/scsi/hosts.c b/drivers/scsi/hosts.c
46464 index 3cafe0d..f1e87f8 100644
46465 --- a/drivers/scsi/hosts.c
46466 +++ b/drivers/scsi/hosts.c
46467 @@ -42,7 +42,7 @@
46468 #include "scsi_logging.h"
46469
46470
46471 -static atomic_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46472 +static atomic_unchecked_t scsi_host_next_hn = ATOMIC_INIT(0); /* host_no for next new host */
46473
46474
46475 static void scsi_host_cls_release(struct device *dev)
46476 @@ -361,7 +361,7 @@ struct Scsi_Host *scsi_host_alloc(struct scsi_host_template *sht, int privsize)
46477 * subtract one because we increment first then return, but we need to
46478 * know what the next host number was before increment
46479 */
46480 - shost->host_no = atomic_inc_return(&scsi_host_next_hn) - 1;
46481 + shost->host_no = atomic_inc_return_unchecked(&scsi_host_next_hn) - 1;
46482 shost->dma_channel = 0xff;
46483
46484 /* These three are default values which can be overridden */
46485 diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
46486 index 0eb0940..3ca9b79 100644
46487 --- a/drivers/scsi/hpsa.c
46488 +++ b/drivers/scsi/hpsa.c
46489 @@ -579,7 +579,7 @@ static inline u32 next_command(struct ctlr_info *h, u8 q)
46490 unsigned long flags;
46491
46492 if (unlikely(!(h->transMethod & CFGTBL_Trans_Performant)))
46493 - return h->access.command_completed(h, q);
46494 + return h->access->command_completed(h, q);
46495
46496 if ((rq->head[rq->current_entry] & 1) == rq->wraparound) {
46497 a = rq->head[rq->current_entry];
46498 @@ -3445,7 +3445,7 @@ static void start_io(struct ctlr_info *h)
46499 while (!list_empty(&h->reqQ)) {
46500 c = list_entry(h->reqQ.next, struct CommandList, list);
46501 /* can't do anything if fifo is full */
46502 - if ((h->access.fifo_full(h))) {
46503 + if ((h->access->fifo_full(h))) {
46504 dev_warn(&h->pdev->dev, "fifo full\n");
46505 break;
46506 }
46507 @@ -3467,7 +3467,7 @@ static void start_io(struct ctlr_info *h)
46508
46509 /* Tell the controller execute command */
46510 spin_unlock_irqrestore(&h->lock, flags);
46511 - h->access.submit_command(h, c);
46512 + h->access->submit_command(h, c);
46513 spin_lock_irqsave(&h->lock, flags);
46514 }
46515 spin_unlock_irqrestore(&h->lock, flags);
46516 @@ -3475,17 +3475,17 @@ static void start_io(struct ctlr_info *h)
46517
46518 static inline unsigned long get_next_completion(struct ctlr_info *h, u8 q)
46519 {
46520 - return h->access.command_completed(h, q);
46521 + return h->access->command_completed(h, q);
46522 }
46523
46524 static inline bool interrupt_pending(struct ctlr_info *h)
46525 {
46526 - return h->access.intr_pending(h);
46527 + return h->access->intr_pending(h);
46528 }
46529
46530 static inline long interrupt_not_for_us(struct ctlr_info *h)
46531 {
46532 - return (h->access.intr_pending(h) == 0) ||
46533 + return (h->access->intr_pending(h) == 0) ||
46534 (h->interrupts_enabled == 0);
46535 }
46536
46537 @@ -4387,7 +4387,7 @@ static int hpsa_pci_init(struct ctlr_info *h)
46538 if (prod_index < 0)
46539 return -ENODEV;
46540 h->product_name = products[prod_index].product_name;
46541 - h->access = *(products[prod_index].access);
46542 + h->access = products[prod_index].access;
46543
46544 pci_disable_link_state(h->pdev, PCIE_LINK_STATE_L0S |
46545 PCIE_LINK_STATE_L1 | PCIE_LINK_STATE_CLKPM);
46546 @@ -4669,7 +4669,7 @@ static void controller_lockup_detected(struct ctlr_info *h)
46547
46548 assert_spin_locked(&lockup_detector_lock);
46549 remove_ctlr_from_lockup_detector_list(h);
46550 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46551 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46552 spin_lock_irqsave(&h->lock, flags);
46553 h->lockup_detected = readl(h->vaddr + SA5_SCRATCHPAD_OFFSET);
46554 spin_unlock_irqrestore(&h->lock, flags);
46555 @@ -4846,7 +4846,7 @@ reinit_after_soft_reset:
46556 }
46557
46558 /* make sure the board interrupts are off */
46559 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46560 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46561
46562 if (hpsa_request_irq(h, do_hpsa_intr_msi, do_hpsa_intr_intx))
46563 goto clean2;
46564 @@ -4880,7 +4880,7 @@ reinit_after_soft_reset:
46565 * fake ones to scoop up any residual completions.
46566 */
46567 spin_lock_irqsave(&h->lock, flags);
46568 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46569 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46570 spin_unlock_irqrestore(&h->lock, flags);
46571 free_irqs(h);
46572 rc = hpsa_request_irq(h, hpsa_msix_discard_completions,
46573 @@ -4899,9 +4899,9 @@ reinit_after_soft_reset:
46574 dev_info(&h->pdev->dev, "Board READY.\n");
46575 dev_info(&h->pdev->dev,
46576 "Waiting for stale completions to drain.\n");
46577 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46578 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46579 msleep(10000);
46580 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46581 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46582
46583 rc = controller_reset_failed(h->cfgtable);
46584 if (rc)
46585 @@ -4922,7 +4922,7 @@ reinit_after_soft_reset:
46586 }
46587
46588 /* Turn the interrupts on so we can service requests */
46589 - h->access.set_intr_mask(h, HPSA_INTR_ON);
46590 + h->access->set_intr_mask(h, HPSA_INTR_ON);
46591
46592 hpsa_hba_inquiry(h);
46593 hpsa_register_scsi(h); /* hook ourselves into SCSI subsystem */
46594 @@ -4977,7 +4977,7 @@ static void hpsa_shutdown(struct pci_dev *pdev)
46595 * To write all data in the battery backed cache to disks
46596 */
46597 hpsa_flush_cache(h);
46598 - h->access.set_intr_mask(h, HPSA_INTR_OFF);
46599 + h->access->set_intr_mask(h, HPSA_INTR_OFF);
46600 hpsa_free_irqs_and_disable_msix(h);
46601 }
46602
46603 @@ -5145,7 +5145,7 @@ static void hpsa_enter_performant_mode(struct ctlr_info *h, u32 use_short_tags)
46604 return;
46605 }
46606 /* Change the access methods to the performant access methods */
46607 - h->access = SA5_performant_access;
46608 + h->access = &SA5_performant_access;
46609 h->transMethod = CFGTBL_Trans_Performant;
46610 }
46611
46612 diff --git a/drivers/scsi/hpsa.h b/drivers/scsi/hpsa.h
46613 index bc85e72..ae04a39 100644
46614 --- a/drivers/scsi/hpsa.h
46615 +++ b/drivers/scsi/hpsa.h
46616 @@ -79,7 +79,7 @@ struct ctlr_info {
46617 unsigned int msix_vector;
46618 unsigned int msi_vector;
46619 int intr_mode; /* either PERF_MODE_INT or SIMPLE_MODE_INT */
46620 - struct access_method access;
46621 + struct access_method *access;
46622
46623 /* queue and queue Info */
46624 struct list_head reqQ;
46625 diff --git a/drivers/scsi/libfc/fc_exch.c b/drivers/scsi/libfc/fc_exch.c
46626 index 5879929..32b241d 100644
46627 --- a/drivers/scsi/libfc/fc_exch.c
46628 +++ b/drivers/scsi/libfc/fc_exch.c
46629 @@ -100,12 +100,12 @@ struct fc_exch_mgr {
46630 u16 pool_max_index;
46631
46632 struct {
46633 - atomic_t no_free_exch;
46634 - atomic_t no_free_exch_xid;
46635 - atomic_t xid_not_found;
46636 - atomic_t xid_busy;
46637 - atomic_t seq_not_found;
46638 - atomic_t non_bls_resp;
46639 + atomic_unchecked_t no_free_exch;
46640 + atomic_unchecked_t no_free_exch_xid;
46641 + atomic_unchecked_t xid_not_found;
46642 + atomic_unchecked_t xid_busy;
46643 + atomic_unchecked_t seq_not_found;
46644 + atomic_unchecked_t non_bls_resp;
46645 } stats;
46646 };
46647
46648 @@ -736,7 +736,7 @@ static struct fc_exch *fc_exch_em_alloc(struct fc_lport *lport,
46649 /* allocate memory for exchange */
46650 ep = mempool_alloc(mp->ep_pool, GFP_ATOMIC);
46651 if (!ep) {
46652 - atomic_inc(&mp->stats.no_free_exch);
46653 + atomic_inc_unchecked(&mp->stats.no_free_exch);
46654 goto out;
46655 }
46656 memset(ep, 0, sizeof(*ep));
46657 @@ -797,7 +797,7 @@ out:
46658 return ep;
46659 err:
46660 spin_unlock_bh(&pool->lock);
46661 - atomic_inc(&mp->stats.no_free_exch_xid);
46662 + atomic_inc_unchecked(&mp->stats.no_free_exch_xid);
46663 mempool_free(ep, mp->ep_pool);
46664 return NULL;
46665 }
46666 @@ -940,7 +940,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46667 xid = ntohs(fh->fh_ox_id); /* we originated exch */
46668 ep = fc_exch_find(mp, xid);
46669 if (!ep) {
46670 - atomic_inc(&mp->stats.xid_not_found);
46671 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46672 reject = FC_RJT_OX_ID;
46673 goto out;
46674 }
46675 @@ -970,7 +970,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46676 ep = fc_exch_find(mp, xid);
46677 if ((f_ctl & FC_FC_FIRST_SEQ) && fc_sof_is_init(fr_sof(fp))) {
46678 if (ep) {
46679 - atomic_inc(&mp->stats.xid_busy);
46680 + atomic_inc_unchecked(&mp->stats.xid_busy);
46681 reject = FC_RJT_RX_ID;
46682 goto rel;
46683 }
46684 @@ -981,7 +981,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46685 }
46686 xid = ep->xid; /* get our XID */
46687 } else if (!ep) {
46688 - atomic_inc(&mp->stats.xid_not_found);
46689 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46690 reject = FC_RJT_RX_ID; /* XID not found */
46691 goto out;
46692 }
46693 @@ -998,7 +998,7 @@ static enum fc_pf_rjt_reason fc_seq_lookup_recip(struct fc_lport *lport,
46694 } else {
46695 sp = &ep->seq;
46696 if (sp->id != fh->fh_seq_id) {
46697 - atomic_inc(&mp->stats.seq_not_found);
46698 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46699 if (f_ctl & FC_FC_END_SEQ) {
46700 /*
46701 * Update sequence_id based on incoming last
46702 @@ -1448,22 +1448,22 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46703
46704 ep = fc_exch_find(mp, ntohs(fh->fh_ox_id));
46705 if (!ep) {
46706 - atomic_inc(&mp->stats.xid_not_found);
46707 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46708 goto out;
46709 }
46710 if (ep->esb_stat & ESB_ST_COMPLETE) {
46711 - atomic_inc(&mp->stats.xid_not_found);
46712 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46713 goto rel;
46714 }
46715 if (ep->rxid == FC_XID_UNKNOWN)
46716 ep->rxid = ntohs(fh->fh_rx_id);
46717 if (ep->sid != 0 && ep->sid != ntoh24(fh->fh_d_id)) {
46718 - atomic_inc(&mp->stats.xid_not_found);
46719 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46720 goto rel;
46721 }
46722 if (ep->did != ntoh24(fh->fh_s_id) &&
46723 ep->did != FC_FID_FLOGI) {
46724 - atomic_inc(&mp->stats.xid_not_found);
46725 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46726 goto rel;
46727 }
46728 sof = fr_sof(fp);
46729 @@ -1472,7 +1472,7 @@ static void fc_exch_recv_seq_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46730 sp->ssb_stat |= SSB_ST_RESP;
46731 sp->id = fh->fh_seq_id;
46732 } else if (sp->id != fh->fh_seq_id) {
46733 - atomic_inc(&mp->stats.seq_not_found);
46734 + atomic_inc_unchecked(&mp->stats.seq_not_found);
46735 goto rel;
46736 }
46737
46738 @@ -1536,9 +1536,9 @@ static void fc_exch_recv_resp(struct fc_exch_mgr *mp, struct fc_frame *fp)
46739 sp = fc_seq_lookup_orig(mp, fp); /* doesn't hold sequence */
46740
46741 if (!sp)
46742 - atomic_inc(&mp->stats.xid_not_found);
46743 + atomic_inc_unchecked(&mp->stats.xid_not_found);
46744 else
46745 - atomic_inc(&mp->stats.non_bls_resp);
46746 + atomic_inc_unchecked(&mp->stats.non_bls_resp);
46747
46748 fc_frame_free(fp);
46749 }
46750 @@ -2185,13 +2185,13 @@ void fc_exch_update_stats(struct fc_lport *lport)
46751
46752 list_for_each_entry(ema, &lport->ema_list, ema_list) {
46753 mp = ema->mp;
46754 - st->fc_no_free_exch += atomic_read(&mp->stats.no_free_exch);
46755 + st->fc_no_free_exch += atomic_read_unchecked(&mp->stats.no_free_exch);
46756 st->fc_no_free_exch_xid +=
46757 - atomic_read(&mp->stats.no_free_exch_xid);
46758 - st->fc_xid_not_found += atomic_read(&mp->stats.xid_not_found);
46759 - st->fc_xid_busy += atomic_read(&mp->stats.xid_busy);
46760 - st->fc_seq_not_found += atomic_read(&mp->stats.seq_not_found);
46761 - st->fc_non_bls_resp += atomic_read(&mp->stats.non_bls_resp);
46762 + atomic_read_unchecked(&mp->stats.no_free_exch_xid);
46763 + st->fc_xid_not_found += atomic_read_unchecked(&mp->stats.xid_not_found);
46764 + st->fc_xid_busy += atomic_read_unchecked(&mp->stats.xid_busy);
46765 + st->fc_seq_not_found += atomic_read_unchecked(&mp->stats.seq_not_found);
46766 + st->fc_non_bls_resp += atomic_read_unchecked(&mp->stats.non_bls_resp);
46767 }
46768 }
46769 EXPORT_SYMBOL(fc_exch_update_stats);
46770 diff --git a/drivers/scsi/libsas/sas_ata.c b/drivers/scsi/libsas/sas_ata.c
46771 index d289583..b745eec 100644
46772 --- a/drivers/scsi/libsas/sas_ata.c
46773 +++ b/drivers/scsi/libsas/sas_ata.c
46774 @@ -554,7 +554,7 @@ static struct ata_port_operations sas_sata_ops = {
46775 .postreset = ata_std_postreset,
46776 .error_handler = ata_std_error_handler,
46777 .post_internal_cmd = sas_ata_post_internal,
46778 - .qc_defer = ata_std_qc_defer,
46779 + .qc_defer = ata_std_qc_defer,
46780 .qc_prep = ata_noop_qc_prep,
46781 .qc_issue = sas_ata_qc_issue,
46782 .qc_fill_rtf = sas_ata_qc_fill_rtf,
46783 diff --git a/drivers/scsi/lpfc/lpfc.h b/drivers/scsi/lpfc/lpfc.h
46784 index 4e1b75c..0bbdfa9 100644
46785 --- a/drivers/scsi/lpfc/lpfc.h
46786 +++ b/drivers/scsi/lpfc/lpfc.h
46787 @@ -432,7 +432,7 @@ struct lpfc_vport {
46788 struct dentry *debug_nodelist;
46789 struct dentry *vport_debugfs_root;
46790 struct lpfc_debugfs_trc *disc_trc;
46791 - atomic_t disc_trc_cnt;
46792 + atomic_unchecked_t disc_trc_cnt;
46793 #endif
46794 uint8_t stat_data_enabled;
46795 uint8_t stat_data_blocked;
46796 @@ -865,8 +865,8 @@ struct lpfc_hba {
46797 struct timer_list fabric_block_timer;
46798 unsigned long bit_flags;
46799 #define FABRIC_COMANDS_BLOCKED 0
46800 - atomic_t num_rsrc_err;
46801 - atomic_t num_cmd_success;
46802 + atomic_unchecked_t num_rsrc_err;
46803 + atomic_unchecked_t num_cmd_success;
46804 unsigned long last_rsrc_error_time;
46805 unsigned long last_ramp_down_time;
46806 unsigned long last_ramp_up_time;
46807 @@ -902,7 +902,7 @@ struct lpfc_hba {
46808
46809 struct dentry *debug_slow_ring_trc;
46810 struct lpfc_debugfs_trc *slow_ring_trc;
46811 - atomic_t slow_ring_trc_cnt;
46812 + atomic_unchecked_t slow_ring_trc_cnt;
46813 /* iDiag debugfs sub-directory */
46814 struct dentry *idiag_root;
46815 struct dentry *idiag_pci_cfg;
46816 diff --git a/drivers/scsi/lpfc/lpfc_debugfs.c b/drivers/scsi/lpfc/lpfc_debugfs.c
46817 index 60084e6..0e2e700 100644
46818 --- a/drivers/scsi/lpfc/lpfc_debugfs.c
46819 +++ b/drivers/scsi/lpfc/lpfc_debugfs.c
46820 @@ -106,7 +106,7 @@ MODULE_PARM_DESC(lpfc_debugfs_mask_disc_trc,
46821
46822 #include <linux/debugfs.h>
46823
46824 -static atomic_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46825 +static atomic_unchecked_t lpfc_debugfs_seq_trc_cnt = ATOMIC_INIT(0);
46826 static unsigned long lpfc_debugfs_start_time = 0L;
46827
46828 /* iDiag */
46829 @@ -147,7 +147,7 @@ lpfc_debugfs_disc_trc_data(struct lpfc_vport *vport, char *buf, int size)
46830 lpfc_debugfs_enable = 0;
46831
46832 len = 0;
46833 - index = (atomic_read(&vport->disc_trc_cnt) + 1) &
46834 + index = (atomic_read_unchecked(&vport->disc_trc_cnt) + 1) &
46835 (lpfc_debugfs_max_disc_trc - 1);
46836 for (i = index; i < lpfc_debugfs_max_disc_trc; i++) {
46837 dtp = vport->disc_trc + i;
46838 @@ -213,7 +213,7 @@ lpfc_debugfs_slow_ring_trc_data(struct lpfc_hba *phba, char *buf, int size)
46839 lpfc_debugfs_enable = 0;
46840
46841 len = 0;
46842 - index = (atomic_read(&phba->slow_ring_trc_cnt) + 1) &
46843 + index = (atomic_read_unchecked(&phba->slow_ring_trc_cnt) + 1) &
46844 (lpfc_debugfs_max_slow_ring_trc - 1);
46845 for (i = index; i < lpfc_debugfs_max_slow_ring_trc; i++) {
46846 dtp = phba->slow_ring_trc + i;
46847 @@ -646,14 +646,14 @@ lpfc_debugfs_disc_trc(struct lpfc_vport *vport, int mask, char *fmt,
46848 !vport || !vport->disc_trc)
46849 return;
46850
46851 - index = atomic_inc_return(&vport->disc_trc_cnt) &
46852 + index = atomic_inc_return_unchecked(&vport->disc_trc_cnt) &
46853 (lpfc_debugfs_max_disc_trc - 1);
46854 dtp = vport->disc_trc + index;
46855 dtp->fmt = fmt;
46856 dtp->data1 = data1;
46857 dtp->data2 = data2;
46858 dtp->data3 = data3;
46859 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46860 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46861 dtp->jif = jiffies;
46862 #endif
46863 return;
46864 @@ -684,14 +684,14 @@ lpfc_debugfs_slow_ring_trc(struct lpfc_hba *phba, char *fmt,
46865 !phba || !phba->slow_ring_trc)
46866 return;
46867
46868 - index = atomic_inc_return(&phba->slow_ring_trc_cnt) &
46869 + index = atomic_inc_return_unchecked(&phba->slow_ring_trc_cnt) &
46870 (lpfc_debugfs_max_slow_ring_trc - 1);
46871 dtp = phba->slow_ring_trc + index;
46872 dtp->fmt = fmt;
46873 dtp->data1 = data1;
46874 dtp->data2 = data2;
46875 dtp->data3 = data3;
46876 - dtp->seq_cnt = atomic_inc_return(&lpfc_debugfs_seq_trc_cnt);
46877 + dtp->seq_cnt = atomic_inc_return_unchecked(&lpfc_debugfs_seq_trc_cnt);
46878 dtp->jif = jiffies;
46879 #endif
46880 return;
46881 @@ -4168,7 +4168,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46882 "slow_ring buffer\n");
46883 goto debug_failed;
46884 }
46885 - atomic_set(&phba->slow_ring_trc_cnt, 0);
46886 + atomic_set_unchecked(&phba->slow_ring_trc_cnt, 0);
46887 memset(phba->slow_ring_trc, 0,
46888 (sizeof(struct lpfc_debugfs_trc) *
46889 lpfc_debugfs_max_slow_ring_trc));
46890 @@ -4214,7 +4214,7 @@ lpfc_debugfs_initialize(struct lpfc_vport *vport)
46891 "buffer\n");
46892 goto debug_failed;
46893 }
46894 - atomic_set(&vport->disc_trc_cnt, 0);
46895 + atomic_set_unchecked(&vport->disc_trc_cnt, 0);
46896
46897 snprintf(name, sizeof(name), "discovery_trace");
46898 vport->debug_disc_trc =
46899 diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
46900 index 647f5bf..d0068b9 100644
46901 --- a/drivers/scsi/lpfc/lpfc_init.c
46902 +++ b/drivers/scsi/lpfc/lpfc_init.c
46903 @@ -10952,8 +10952,10 @@ lpfc_init(void)
46904 "misc_register returned with status %d", error);
46905
46906 if (lpfc_enable_npiv) {
46907 - lpfc_transport_functions.vport_create = lpfc_vport_create;
46908 - lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46909 + pax_open_kernel();
46910 + *(void **)&lpfc_transport_functions.vport_create = lpfc_vport_create;
46911 + *(void **)&lpfc_transport_functions.vport_delete = lpfc_vport_delete;
46912 + pax_close_kernel();
46913 }
46914 lpfc_transport_template =
46915 fc_attach_transport(&lpfc_transport_functions);
46916 diff --git a/drivers/scsi/lpfc/lpfc_scsi.c b/drivers/scsi/lpfc/lpfc_scsi.c
46917 index c913e8c..d34a119 100644
46918 --- a/drivers/scsi/lpfc/lpfc_scsi.c
46919 +++ b/drivers/scsi/lpfc/lpfc_scsi.c
46920 @@ -353,7 +353,7 @@ lpfc_rampdown_queue_depth(struct lpfc_hba *phba)
46921 uint32_t evt_posted;
46922
46923 spin_lock_irqsave(&phba->hbalock, flags);
46924 - atomic_inc(&phba->num_rsrc_err);
46925 + atomic_inc_unchecked(&phba->num_rsrc_err);
46926 phba->last_rsrc_error_time = jiffies;
46927
46928 if ((phba->last_ramp_down_time + QUEUE_RAMP_DOWN_INTERVAL) > jiffies) {
46929 @@ -394,7 +394,7 @@ lpfc_rampup_queue_depth(struct lpfc_vport *vport,
46930 unsigned long flags;
46931 struct lpfc_hba *phba = vport->phba;
46932 uint32_t evt_posted;
46933 - atomic_inc(&phba->num_cmd_success);
46934 + atomic_inc_unchecked(&phba->num_cmd_success);
46935
46936 if (vport->cfg_lun_queue_depth <= queue_depth)
46937 return;
46938 @@ -438,8 +438,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46939 unsigned long num_rsrc_err, num_cmd_success;
46940 int i;
46941
46942 - num_rsrc_err = atomic_read(&phba->num_rsrc_err);
46943 - num_cmd_success = atomic_read(&phba->num_cmd_success);
46944 + num_rsrc_err = atomic_read_unchecked(&phba->num_rsrc_err);
46945 + num_cmd_success = atomic_read_unchecked(&phba->num_cmd_success);
46946
46947 /*
46948 * The error and success command counters are global per
46949 @@ -467,8 +467,8 @@ lpfc_ramp_down_queue_handler(struct lpfc_hba *phba)
46950 }
46951 }
46952 lpfc_destroy_vport_work_array(phba, vports);
46953 - atomic_set(&phba->num_rsrc_err, 0);
46954 - atomic_set(&phba->num_cmd_success, 0);
46955 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46956 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46957 }
46958
46959 /**
46960 @@ -502,8 +502,8 @@ lpfc_ramp_up_queue_handler(struct lpfc_hba *phba)
46961 }
46962 }
46963 lpfc_destroy_vport_work_array(phba, vports);
46964 - atomic_set(&phba->num_rsrc_err, 0);
46965 - atomic_set(&phba->num_cmd_success, 0);
46966 + atomic_set_unchecked(&phba->num_rsrc_err, 0);
46967 + atomic_set_unchecked(&phba->num_cmd_success, 0);
46968 }
46969
46970 /**
46971 diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46972 index 7f0af4f..193ac3e 100644
46973 --- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46974 +++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
46975 @@ -1557,7 +1557,7 @@ _scsih_get_resync(struct device *dev)
46976 {
46977 struct scsi_device *sdev = to_scsi_device(dev);
46978 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46979 - static struct _raid_device *raid_device;
46980 + struct _raid_device *raid_device;
46981 unsigned long flags;
46982 Mpi2RaidVolPage0_t vol_pg0;
46983 Mpi2ConfigReply_t mpi_reply;
46984 @@ -1609,7 +1609,7 @@ _scsih_get_state(struct device *dev)
46985 {
46986 struct scsi_device *sdev = to_scsi_device(dev);
46987 struct MPT2SAS_ADAPTER *ioc = shost_priv(sdev->host);
46988 - static struct _raid_device *raid_device;
46989 + struct _raid_device *raid_device;
46990 unsigned long flags;
46991 Mpi2RaidVolPage0_t vol_pg0;
46992 Mpi2ConfigReply_t mpi_reply;
46993 @@ -6637,7 +6637,7 @@ _scsih_sas_ir_operation_status_event(struct MPT2SAS_ADAPTER *ioc,
46994 struct fw_event_work *fw_event)
46995 {
46996 Mpi2EventDataIrOperationStatus_t *event_data = fw_event->event_data;
46997 - static struct _raid_device *raid_device;
46998 + struct _raid_device *raid_device;
46999 unsigned long flags;
47000 u16 handle;
47001
47002 @@ -7108,7 +7108,7 @@ _scsih_scan_for_devices_after_reset(struct MPT2SAS_ADAPTER *ioc)
47003 u64 sas_address;
47004 struct _sas_device *sas_device;
47005 struct _sas_node *expander_device;
47006 - static struct _raid_device *raid_device;
47007 + struct _raid_device *raid_device;
47008 u8 retry_count;
47009 unsigned long flags;
47010
47011 diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c
47012 index a38f71b..f3bc572 100644
47013 --- a/drivers/scsi/pmcraid.c
47014 +++ b/drivers/scsi/pmcraid.c
47015 @@ -200,8 +200,8 @@ static int pmcraid_slave_alloc(struct scsi_device *scsi_dev)
47016 res->scsi_dev = scsi_dev;
47017 scsi_dev->hostdata = res;
47018 res->change_detected = 0;
47019 - atomic_set(&res->read_failures, 0);
47020 - atomic_set(&res->write_failures, 0);
47021 + atomic_set_unchecked(&res->read_failures, 0);
47022 + atomic_set_unchecked(&res->write_failures, 0);
47023 rc = 0;
47024 }
47025 spin_unlock_irqrestore(&pinstance->resource_lock, lock_flags);
47026 @@ -2676,9 +2676,9 @@ static int pmcraid_error_handler(struct pmcraid_cmd *cmd)
47027
47028 /* If this was a SCSI read/write command keep count of errors */
47029 if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_READ_CMD)
47030 - atomic_inc(&res->read_failures);
47031 + atomic_inc_unchecked(&res->read_failures);
47032 else if (SCSI_CMD_TYPE(scsi_cmd->cmnd[0]) == SCSI_WRITE_CMD)
47033 - atomic_inc(&res->write_failures);
47034 + atomic_inc_unchecked(&res->write_failures);
47035
47036 if (!RES_IS_GSCSI(res->cfg_entry) &&
47037 masked_ioasc != PMCRAID_IOASC_HW_DEVICE_BUS_STATUS_ERROR) {
47038 @@ -3534,7 +3534,7 @@ static int pmcraid_queuecommand_lck(
47039 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
47040 * hrrq_id assigned here in queuecommand
47041 */
47042 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
47043 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
47044 pinstance->num_hrrq;
47045 cmd->cmd_done = pmcraid_io_done;
47046
47047 @@ -3846,7 +3846,7 @@ static long pmcraid_ioctl_passthrough(
47048 * block of scsi_cmd which is re-used (e.g. cancel/abort), which uses
47049 * hrrq_id assigned here in queuecommand
47050 */
47051 - ioarcb->hrrq_id = atomic_add_return(1, &(pinstance->last_message_id)) %
47052 + ioarcb->hrrq_id = atomic_add_return_unchecked(1, &(pinstance->last_message_id)) %
47053 pinstance->num_hrrq;
47054
47055 if (request_size) {
47056 @@ -4484,7 +4484,7 @@ static void pmcraid_worker_function(struct work_struct *workp)
47057
47058 pinstance = container_of(workp, struct pmcraid_instance, worker_q);
47059 /* add resources only after host is added into system */
47060 - if (!atomic_read(&pinstance->expose_resources))
47061 + if (!atomic_read_unchecked(&pinstance->expose_resources))
47062 return;
47063
47064 fw_version = be16_to_cpu(pinstance->inq_data->fw_version);
47065 @@ -5311,8 +5311,8 @@ static int pmcraid_init_instance(struct pci_dev *pdev, struct Scsi_Host *host,
47066 init_waitqueue_head(&pinstance->reset_wait_q);
47067
47068 atomic_set(&pinstance->outstanding_cmds, 0);
47069 - atomic_set(&pinstance->last_message_id, 0);
47070 - atomic_set(&pinstance->expose_resources, 0);
47071 + atomic_set_unchecked(&pinstance->last_message_id, 0);
47072 + atomic_set_unchecked(&pinstance->expose_resources, 0);
47073
47074 INIT_LIST_HEAD(&pinstance->free_res_q);
47075 INIT_LIST_HEAD(&pinstance->used_res_q);
47076 @@ -6025,7 +6025,7 @@ static int pmcraid_probe(struct pci_dev *pdev,
47077 /* Schedule worker thread to handle CCN and take care of adding and
47078 * removing devices to OS
47079 */
47080 - atomic_set(&pinstance->expose_resources, 1);
47081 + atomic_set_unchecked(&pinstance->expose_resources, 1);
47082 schedule_work(&pinstance->worker_q);
47083 return rc;
47084
47085 diff --git a/drivers/scsi/pmcraid.h b/drivers/scsi/pmcraid.h
47086 index e1d150f..6c6df44 100644
47087 --- a/drivers/scsi/pmcraid.h
47088 +++ b/drivers/scsi/pmcraid.h
47089 @@ -748,7 +748,7 @@ struct pmcraid_instance {
47090 struct pmcraid_isr_param hrrq_vector[PMCRAID_NUM_MSIX_VECTORS];
47091
47092 /* Message id as filled in last fired IOARCB, used to identify HRRQ */
47093 - atomic_t last_message_id;
47094 + atomic_unchecked_t last_message_id;
47095
47096 /* configuration table */
47097 struct pmcraid_config_table *cfg_table;
47098 @@ -777,7 +777,7 @@ struct pmcraid_instance {
47099 atomic_t outstanding_cmds;
47100
47101 /* should add/delete resources to mid-layer now ?*/
47102 - atomic_t expose_resources;
47103 + atomic_unchecked_t expose_resources;
47104
47105
47106
47107 @@ -813,8 +813,8 @@ struct pmcraid_resource_entry {
47108 struct pmcraid_config_table_entry_ext cfg_entry_ext;
47109 };
47110 struct scsi_device *scsi_dev; /* Link scsi_device structure */
47111 - atomic_t read_failures; /* count of failed READ commands */
47112 - atomic_t write_failures; /* count of failed WRITE commands */
47113 + atomic_unchecked_t read_failures; /* count of failed READ commands */
47114 + atomic_unchecked_t write_failures; /* count of failed WRITE commands */
47115
47116 /* To indicate add/delete/modify during CCN */
47117 u8 change_detected;
47118 diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
47119 index 5f174b8..98d32b0 100644
47120 --- a/drivers/scsi/qla2xxx/qla_attr.c
47121 +++ b/drivers/scsi/qla2xxx/qla_attr.c
47122 @@ -2040,7 +2040,7 @@ qla24xx_vport_disable(struct fc_vport *fc_vport, bool disable)
47123 return 0;
47124 }
47125
47126 -struct fc_function_template qla2xxx_transport_functions = {
47127 +fc_function_template_no_const qla2xxx_transport_functions = {
47128
47129 .show_host_node_name = 1,
47130 .show_host_port_name = 1,
47131 @@ -2088,7 +2088,7 @@ struct fc_function_template qla2xxx_transport_functions = {
47132 .bsg_timeout = qla24xx_bsg_timeout,
47133 };
47134
47135 -struct fc_function_template qla2xxx_transport_vport_functions = {
47136 +fc_function_template_no_const qla2xxx_transport_vport_functions = {
47137
47138 .show_host_node_name = 1,
47139 .show_host_port_name = 1,
47140 diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
47141 index 4446bf5..9a3574d 100644
47142 --- a/drivers/scsi/qla2xxx/qla_gbl.h
47143 +++ b/drivers/scsi/qla2xxx/qla_gbl.h
47144 @@ -538,8 +538,8 @@ extern void qla2x00_get_sym_node_name(scsi_qla_host_t *, uint8_t *);
47145 struct device_attribute;
47146 extern struct device_attribute *qla2x00_host_attrs[];
47147 struct fc_function_template;
47148 -extern struct fc_function_template qla2xxx_transport_functions;
47149 -extern struct fc_function_template qla2xxx_transport_vport_functions;
47150 +extern fc_function_template_no_const qla2xxx_transport_functions;
47151 +extern fc_function_template_no_const qla2xxx_transport_vport_functions;
47152 extern void qla2x00_alloc_sysfs_attr(scsi_qla_host_t *);
47153 extern void qla2x00_free_sysfs_attr(scsi_qla_host_t *);
47154 extern void qla2x00_init_host_attr(scsi_qla_host_t *);
47155 diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
47156 index 9f01bbb..5e1dcee 100644
47157 --- a/drivers/scsi/qla2xxx/qla_os.c
47158 +++ b/drivers/scsi/qla2xxx/qla_os.c
47159 @@ -1572,8 +1572,10 @@ qla2x00_config_dma_addressing(struct qla_hw_data *ha)
47160 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
47161 /* Ok, a 64bit DMA mask is applicable. */
47162 ha->flags.enable_64bit_addressing = 1;
47163 - ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47164 - ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47165 + pax_open_kernel();
47166 + *(void **)&ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
47167 + *(void **)&ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
47168 + pax_close_kernel();
47169 return;
47170 }
47171 }
47172 diff --git a/drivers/scsi/qla4xxx/ql4_def.h b/drivers/scsi/qla4xxx/ql4_def.h
47173 index 41327d4..feb03d479 100644
47174 --- a/drivers/scsi/qla4xxx/ql4_def.h
47175 +++ b/drivers/scsi/qla4xxx/ql4_def.h
47176 @@ -296,7 +296,7 @@ struct ddb_entry {
47177 * (4000 only) */
47178 atomic_t relogin_timer; /* Max Time to wait for
47179 * relogin to complete */
47180 - atomic_t relogin_retry_count; /* Num of times relogin has been
47181 + atomic_unchecked_t relogin_retry_count; /* Num of times relogin has been
47182 * retried */
47183 uint32_t default_time2wait; /* Default Min time between
47184 * relogins (+aens) */
47185 diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
47186 index f8a0a26..ec03cee 100644
47187 --- a/drivers/scsi/qla4xxx/ql4_os.c
47188 +++ b/drivers/scsi/qla4xxx/ql4_os.c
47189 @@ -3066,12 +3066,12 @@ static void qla4xxx_check_relogin_flash_ddb(struct iscsi_cls_session *cls_sess)
47190 */
47191 if (!iscsi_is_session_online(cls_sess)) {
47192 /* Reset retry relogin timer */
47193 - atomic_inc(&ddb_entry->relogin_retry_count);
47194 + atomic_inc_unchecked(&ddb_entry->relogin_retry_count);
47195 DEBUG2(ql4_printk(KERN_INFO, ha,
47196 "%s: index[%d] relogin timed out-retrying"
47197 " relogin (%d), retry (%d)\n", __func__,
47198 ddb_entry->fw_ddb_index,
47199 - atomic_read(&ddb_entry->relogin_retry_count),
47200 + atomic_read_unchecked(&ddb_entry->relogin_retry_count),
47201 ddb_entry->default_time2wait + 4));
47202 set_bit(DPC_RELOGIN_DEVICE, &ha->dpc_flags);
47203 atomic_set(&ddb_entry->retry_relogin_timer,
47204 @@ -5209,7 +5209,7 @@ static void qla4xxx_setup_flash_ddb_entry(struct scsi_qla_host *ha,
47205
47206 atomic_set(&ddb_entry->retry_relogin_timer, INVALID_ENTRY);
47207 atomic_set(&ddb_entry->relogin_timer, 0);
47208 - atomic_set(&ddb_entry->relogin_retry_count, 0);
47209 + atomic_set_unchecked(&ddb_entry->relogin_retry_count, 0);
47210 def_timeout = le16_to_cpu(ddb_entry->fw_ddb_entry.def_timeout);
47211 ddb_entry->default_relogin_timeout =
47212 (def_timeout > LOGIN_TOV) && (def_timeout < LOGIN_TOV * 10) ?
47213 diff --git a/drivers/scsi/scsi.c b/drivers/scsi/scsi.c
47214 index eaa808e..95f8841 100644
47215 --- a/drivers/scsi/scsi.c
47216 +++ b/drivers/scsi/scsi.c
47217 @@ -661,7 +661,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
47218 unsigned long timeout;
47219 int rtn = 0;
47220
47221 - atomic_inc(&cmd->device->iorequest_cnt);
47222 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47223
47224 /* check if the device is still usable */
47225 if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
47226 diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
47227 index d1549b7..2f60767 100644
47228 --- a/drivers/scsi/scsi_lib.c
47229 +++ b/drivers/scsi/scsi_lib.c
47230 @@ -1474,7 +1474,7 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
47231 shost = sdev->host;
47232 scsi_init_cmd_errh(cmd);
47233 cmd->result = DID_NO_CONNECT << 16;
47234 - atomic_inc(&cmd->device->iorequest_cnt);
47235 + atomic_inc_unchecked(&cmd->device->iorequest_cnt);
47236
47237 /*
47238 * SCSI request completion path will do scsi_device_unbusy(),
47239 @@ -1500,9 +1500,9 @@ static void scsi_softirq_done(struct request *rq)
47240
47241 INIT_LIST_HEAD(&cmd->eh_entry);
47242
47243 - atomic_inc(&cmd->device->iodone_cnt);
47244 + atomic_inc_unchecked(&cmd->device->iodone_cnt);
47245 if (cmd->result)
47246 - atomic_inc(&cmd->device->ioerr_cnt);
47247 + atomic_inc_unchecked(&cmd->device->ioerr_cnt);
47248
47249 disposition = scsi_decide_disposition(cmd);
47250 if (disposition != SUCCESS &&
47251 diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
47252 index 40c6394..62356c2 100644
47253 --- a/drivers/scsi/scsi_sysfs.c
47254 +++ b/drivers/scsi/scsi_sysfs.c
47255 @@ -687,7 +687,7 @@ show_iostat_##field(struct device *dev, struct device_attribute *attr, \
47256 char *buf) \
47257 { \
47258 struct scsi_device *sdev = to_scsi_device(dev); \
47259 - unsigned long long count = atomic_read(&sdev->field); \
47260 + unsigned long long count = atomic_read_unchecked(&sdev->field); \
47261 return snprintf(buf, 20, "0x%llx\n", count); \
47262 } \
47263 static DEVICE_ATTR(field, S_IRUGO, show_iostat_##field, NULL)
47264 diff --git a/drivers/scsi/scsi_tgt_lib.c b/drivers/scsi/scsi_tgt_lib.c
47265 index 84a1fdf..693b0d6 100644
47266 --- a/drivers/scsi/scsi_tgt_lib.c
47267 +++ b/drivers/scsi/scsi_tgt_lib.c
47268 @@ -362,7 +362,7 @@ static int scsi_map_user_pages(struct scsi_tgt_cmd *tcmd, struct scsi_cmnd *cmd,
47269 int err;
47270
47271 dprintk("%lx %u\n", uaddr, len);
47272 - err = blk_rq_map_user(q, rq, NULL, (void *)uaddr, len, GFP_KERNEL);
47273 + err = blk_rq_map_user(q, rq, NULL, (void __user *)uaddr, len, GFP_KERNEL);
47274 if (err) {
47275 /*
47276 * TODO: need to fixup sg_tablesize, max_segment_size,
47277 diff --git a/drivers/scsi/scsi_transport_fc.c b/drivers/scsi/scsi_transport_fc.c
47278 index 4628fd5..a94a1c2 100644
47279 --- a/drivers/scsi/scsi_transport_fc.c
47280 +++ b/drivers/scsi/scsi_transport_fc.c
47281 @@ -497,7 +497,7 @@ static DECLARE_TRANSPORT_CLASS(fc_vport_class,
47282 * Netlink Infrastructure
47283 */
47284
47285 -static atomic_t fc_event_seq;
47286 +static atomic_unchecked_t fc_event_seq;
47287
47288 /**
47289 * fc_get_event_number - Obtain the next sequential FC event number
47290 @@ -510,7 +510,7 @@ static atomic_t fc_event_seq;
47291 u32
47292 fc_get_event_number(void)
47293 {
47294 - return atomic_add_return(1, &fc_event_seq);
47295 + return atomic_add_return_unchecked(1, &fc_event_seq);
47296 }
47297 EXPORT_SYMBOL(fc_get_event_number);
47298
47299 @@ -654,7 +654,7 @@ static __init int fc_transport_init(void)
47300 {
47301 int error;
47302
47303 - atomic_set(&fc_event_seq, 0);
47304 + atomic_set_unchecked(&fc_event_seq, 0);
47305
47306 error = transport_class_register(&fc_host_class);
47307 if (error)
47308 @@ -844,7 +844,7 @@ static int fc_str_to_dev_loss(const char *buf, unsigned long *val)
47309 char *cp;
47310
47311 *val = simple_strtoul(buf, &cp, 0);
47312 - if ((*cp && (*cp != '\n')) || (*val < 0))
47313 + if (*cp && (*cp != '\n'))
47314 return -EINVAL;
47315 /*
47316 * Check for overflow; dev_loss_tmo is u32
47317 diff --git a/drivers/scsi/scsi_transport_iscsi.c b/drivers/scsi/scsi_transport_iscsi.c
47318 index e4a989f..293090c 100644
47319 --- a/drivers/scsi/scsi_transport_iscsi.c
47320 +++ b/drivers/scsi/scsi_transport_iscsi.c
47321 @@ -79,7 +79,7 @@ struct iscsi_internal {
47322 struct transport_container session_cont;
47323 };
47324
47325 -static atomic_t iscsi_session_nr; /* sysfs session id for next new session */
47326 +static atomic_unchecked_t iscsi_session_nr; /* sysfs session id for next new session */
47327 static struct workqueue_struct *iscsi_eh_timer_workq;
47328
47329 static DEFINE_IDA(iscsi_sess_ida);
47330 @@ -1737,7 +1737,7 @@ int iscsi_add_session(struct iscsi_cls_session *session, unsigned int target_id)
47331 int err;
47332
47333 ihost = shost->shost_data;
47334 - session->sid = atomic_add_return(1, &iscsi_session_nr);
47335 + session->sid = atomic_add_return_unchecked(1, &iscsi_session_nr);
47336
47337 if (target_id == ISCSI_MAX_TARGET) {
47338 id = ida_simple_get(&iscsi_sess_ida, 0, 0, GFP_KERNEL);
47339 @@ -4077,7 +4077,7 @@ static __init int iscsi_transport_init(void)
47340 printk(KERN_INFO "Loading iSCSI transport class v%s.\n",
47341 ISCSI_TRANSPORT_VERSION);
47342
47343 - atomic_set(&iscsi_session_nr, 0);
47344 + atomic_set_unchecked(&iscsi_session_nr, 0);
47345
47346 err = class_register(&iscsi_transport_class);
47347 if (err)
47348 diff --git a/drivers/scsi/scsi_transport_srp.c b/drivers/scsi/scsi_transport_srp.c
47349 index f379c7f..e8fc69c 100644
47350 --- a/drivers/scsi/scsi_transport_srp.c
47351 +++ b/drivers/scsi/scsi_transport_srp.c
47352 @@ -33,7 +33,7 @@
47353 #include "scsi_transport_srp_internal.h"
47354
47355 struct srp_host_attrs {
47356 - atomic_t next_port_id;
47357 + atomic_unchecked_t next_port_id;
47358 };
47359 #define to_srp_host_attrs(host) ((struct srp_host_attrs *)(host)->shost_data)
47360
47361 @@ -61,7 +61,7 @@ static int srp_host_setup(struct transport_container *tc, struct device *dev,
47362 struct Scsi_Host *shost = dev_to_shost(dev);
47363 struct srp_host_attrs *srp_host = to_srp_host_attrs(shost);
47364
47365 - atomic_set(&srp_host->next_port_id, 0);
47366 + atomic_set_unchecked(&srp_host->next_port_id, 0);
47367 return 0;
47368 }
47369
47370 @@ -210,7 +210,7 @@ struct srp_rport *srp_rport_add(struct Scsi_Host *shost,
47371 memcpy(rport->port_id, ids->port_id, sizeof(rport->port_id));
47372 rport->roles = ids->roles;
47373
47374 - id = atomic_inc_return(&to_srp_host_attrs(shost)->next_port_id);
47375 + id = atomic_inc_return_unchecked(&to_srp_host_attrs(shost)->next_port_id);
47376 dev_set_name(&rport->dev, "port-%d:%d", shost->host_no, id);
47377
47378 transport_setup_device(&rport->dev);
47379 diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
47380 index 2634d69..fcf7a81 100644
47381 --- a/drivers/scsi/sd.c
47382 +++ b/drivers/scsi/sd.c
47383 @@ -2940,7 +2940,7 @@ static int sd_probe(struct device *dev)
47384 sdkp->disk = gd;
47385 sdkp->index = index;
47386 atomic_set(&sdkp->openers, 0);
47387 - atomic_set(&sdkp->device->ioerr_cnt, 0);
47388 + atomic_set_unchecked(&sdkp->device->ioerr_cnt, 0);
47389
47390 if (!sdp->request_queue->rq_timeout) {
47391 if (sdp->type != TYPE_MOD)
47392 diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
47393 index df5e961..df6b97f 100644
47394 --- a/drivers/scsi/sg.c
47395 +++ b/drivers/scsi/sg.c
47396 @@ -1102,7 +1102,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg)
47397 sdp->disk->disk_name,
47398 MKDEV(SCSI_GENERIC_MAJOR, sdp->index),
47399 NULL,
47400 - (char *)arg);
47401 + (char __user *)arg);
47402 case BLKTRACESTART:
47403 return blk_trace_startstop(sdp->device->request_queue, 1);
47404 case BLKTRACESTOP:
47405 diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c
47406 index 9e039c6..ae9e800 100644
47407 --- a/drivers/spi/spi.c
47408 +++ b/drivers/spi/spi.c
47409 @@ -1762,7 +1762,7 @@ int spi_bus_unlock(struct spi_master *master)
47410 EXPORT_SYMBOL_GPL(spi_bus_unlock);
47411
47412 /* portable code must never pass more than 32 bytes */
47413 -#define SPI_BUFSIZ max(32,SMP_CACHE_BYTES)
47414 +#define SPI_BUFSIZ max(32UL,SMP_CACHE_BYTES)
47415
47416 static u8 *buf;
47417
47418 diff --git a/drivers/staging/android/timed_output.c b/drivers/staging/android/timed_output.c
47419 index 2c61783..4d49e4e 100644
47420 --- a/drivers/staging/android/timed_output.c
47421 +++ b/drivers/staging/android/timed_output.c
47422 @@ -25,7 +25,7 @@
47423 #include "timed_output.h"
47424
47425 static struct class *timed_output_class;
47426 -static atomic_t device_count;
47427 +static atomic_unchecked_t device_count;
47428
47429 static ssize_t enable_show(struct device *dev, struct device_attribute *attr,
47430 char *buf)
47431 @@ -63,7 +63,7 @@ static int create_timed_output_class(void)
47432 timed_output_class = class_create(THIS_MODULE, "timed_output");
47433 if (IS_ERR(timed_output_class))
47434 return PTR_ERR(timed_output_class);
47435 - atomic_set(&device_count, 0);
47436 + atomic_set_unchecked(&device_count, 0);
47437 timed_output_class->dev_groups = timed_output_groups;
47438 }
47439
47440 @@ -81,7 +81,7 @@ int timed_output_dev_register(struct timed_output_dev *tdev)
47441 if (ret < 0)
47442 return ret;
47443
47444 - tdev->index = atomic_inc_return(&device_count);
47445 + tdev->index = atomic_inc_return_unchecked(&device_count);
47446 tdev->dev = device_create(timed_output_class, NULL,
47447 MKDEV(0, tdev->index), NULL, "%s", tdev->name);
47448 if (IS_ERR(tdev->dev))
47449 diff --git a/drivers/staging/gdm724x/gdm_tty.c b/drivers/staging/gdm724x/gdm_tty.c
47450 index 0247a20..cb9595c 100644
47451 --- a/drivers/staging/gdm724x/gdm_tty.c
47452 +++ b/drivers/staging/gdm724x/gdm_tty.c
47453 @@ -45,7 +45,7 @@
47454 #define gdm_tty_send_control(n, r, v, d, l) (\
47455 n->tty_dev->send_control(n->tty_dev->priv_dev, r, v, d, l))
47456
47457 -#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && gdm->port.count)
47458 +#define GDM_TTY_READY(gdm) (gdm && gdm->tty_dev && atomic_read(&gdm->port.count))
47459
47460 static struct tty_driver *gdm_driver[TTY_MAX_COUNT];
47461 static struct gdm *gdm_table[TTY_MAX_COUNT][GDM_TTY_MINOR];
47462 diff --git a/drivers/staging/lustre/lnet/selftest/brw_test.c b/drivers/staging/lustre/lnet/selftest/brw_test.c
47463 index ef5064e..fce01db 100644
47464 --- a/drivers/staging/lustre/lnet/selftest/brw_test.c
47465 +++ b/drivers/staging/lustre/lnet/selftest/brw_test.c
47466 @@ -478,13 +478,11 @@ brw_server_handle(struct srpc_server_rpc *rpc)
47467 return 0;
47468 }
47469
47470 -sfw_test_client_ops_t brw_test_client;
47471 -void brw_init_test_client(void)
47472 -{
47473 - brw_test_client.tso_init = brw_client_init;
47474 - brw_test_client.tso_fini = brw_client_fini;
47475 - brw_test_client.tso_prep_rpc = brw_client_prep_rpc;
47476 - brw_test_client.tso_done_rpc = brw_client_done_rpc;
47477 +sfw_test_client_ops_t brw_test_client = {
47478 + .tso_init = brw_client_init,
47479 + .tso_fini = brw_client_fini,
47480 + .tso_prep_rpc = brw_client_prep_rpc,
47481 + .tso_done_rpc = brw_client_done_rpc,
47482 };
47483
47484 srpc_service_t brw_test_service;
47485 diff --git a/drivers/staging/lustre/lnet/selftest/framework.c b/drivers/staging/lustre/lnet/selftest/framework.c
47486 index 483c785..e1a2a7b 100644
47487 --- a/drivers/staging/lustre/lnet/selftest/framework.c
47488 +++ b/drivers/staging/lustre/lnet/selftest/framework.c
47489 @@ -1635,12 +1635,10 @@ static srpc_service_t sfw_services[] =
47490
47491 extern sfw_test_client_ops_t ping_test_client;
47492 extern srpc_service_t ping_test_service;
47493 -extern void ping_init_test_client(void);
47494 extern void ping_init_test_service(void);
47495
47496 extern sfw_test_client_ops_t brw_test_client;
47497 extern srpc_service_t brw_test_service;
47498 -extern void brw_init_test_client(void);
47499 extern void brw_init_test_service(void);
47500
47501
47502 @@ -1684,12 +1682,10 @@ sfw_startup (void)
47503 INIT_LIST_HEAD(&sfw_data.fw_zombie_rpcs);
47504 INIT_LIST_HEAD(&sfw_data.fw_zombie_sessions);
47505
47506 - brw_init_test_client();
47507 brw_init_test_service();
47508 rc = sfw_register_test(&brw_test_service, &brw_test_client);
47509 LASSERT (rc == 0);
47510
47511 - ping_init_test_client();
47512 ping_init_test_service();
47513 rc = sfw_register_test(&ping_test_service, &ping_test_client);
47514 LASSERT (rc == 0);
47515 diff --git a/drivers/staging/lustre/lnet/selftest/ping_test.c b/drivers/staging/lustre/lnet/selftest/ping_test.c
47516 index f0f9194..b589047 100644
47517 --- a/drivers/staging/lustre/lnet/selftest/ping_test.c
47518 +++ b/drivers/staging/lustre/lnet/selftest/ping_test.c
47519 @@ -210,14 +210,12 @@ ping_server_handle(struct srpc_server_rpc *rpc)
47520 return 0;
47521 }
47522
47523 -sfw_test_client_ops_t ping_test_client;
47524 -void ping_init_test_client(void)
47525 -{
47526 - ping_test_client.tso_init = ping_client_init;
47527 - ping_test_client.tso_fini = ping_client_fini;
47528 - ping_test_client.tso_prep_rpc = ping_client_prep_rpc;
47529 - ping_test_client.tso_done_rpc = ping_client_done_rpc;
47530 -}
47531 +sfw_test_client_ops_t ping_test_client = {
47532 + .tso_init = ping_client_init,
47533 + .tso_fini = ping_client_fini,
47534 + .tso_prep_rpc = ping_client_prep_rpc,
47535 + .tso_done_rpc = ping_client_done_rpc,
47536 +};
47537
47538 srpc_service_t ping_test_service;
47539 void ping_init_test_service(void)
47540 diff --git a/drivers/staging/lustre/lustre/include/lustre_dlm.h b/drivers/staging/lustre/lustre/include/lustre_dlm.h
47541 index 7020d9c..0d3b580 100644
47542 --- a/drivers/staging/lustre/lustre/include/lustre_dlm.h
47543 +++ b/drivers/staging/lustre/lustre/include/lustre_dlm.h
47544 @@ -1141,7 +1141,7 @@ struct ldlm_callback_suite {
47545 ldlm_completion_callback lcs_completion;
47546 ldlm_blocking_callback lcs_blocking;
47547 ldlm_glimpse_callback lcs_glimpse;
47548 -};
47549 +} __no_const;
47550
47551 /* ldlm_lockd.c */
47552 int ldlm_del_waiting_lock(struct ldlm_lock *lock);
47553 diff --git a/drivers/staging/lustre/lustre/include/obd.h b/drivers/staging/lustre/lustre/include/obd.h
47554 index a612255..9a9e2dd 100644
47555 --- a/drivers/staging/lustre/lustre/include/obd.h
47556 +++ b/drivers/staging/lustre/lustre/include/obd.h
47557 @@ -1417,7 +1417,7 @@ struct md_ops {
47558 * lprocfs_alloc_md_stats() in obdclass/lprocfs_status.c. Also, add a
47559 * wrapper function in include/linux/obd_class.h.
47560 */
47561 -};
47562 +} __no_const;
47563
47564 struct lsm_operations {
47565 void (*lsm_free)(struct lov_stripe_md *);
47566 diff --git a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47567 index fc6c977..df1f956 100644
47568 --- a/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47569 +++ b/drivers/staging/lustre/lustre/libcfs/linux/linux-proc.c
47570 @@ -219,7 +219,7 @@ DECLARE_PROC_HANDLER(proc_debug_mb)
47571 int LL_PROC_PROTO(proc_console_max_delay_cs)
47572 {
47573 int rc, max_delay_cs;
47574 - ctl_table_t dummy = *table;
47575 + ctl_table_no_const dummy = *table;
47576 cfs_duration_t d;
47577
47578 dummy.data = &max_delay_cs;
47579 @@ -250,7 +250,7 @@ int LL_PROC_PROTO(proc_console_max_delay_cs)
47580 int LL_PROC_PROTO(proc_console_min_delay_cs)
47581 {
47582 int rc, min_delay_cs;
47583 - ctl_table_t dummy = *table;
47584 + ctl_table_no_const dummy = *table;
47585 cfs_duration_t d;
47586
47587 dummy.data = &min_delay_cs;
47588 @@ -281,7 +281,7 @@ int LL_PROC_PROTO(proc_console_min_delay_cs)
47589 int LL_PROC_PROTO(proc_console_backoff)
47590 {
47591 int rc, backoff;
47592 - ctl_table_t dummy = *table;
47593 + ctl_table_no_const dummy = *table;
47594
47595 dummy.data = &backoff;
47596 dummy.proc_handler = &proc_dointvec;
47597 diff --git a/drivers/staging/media/solo6x10/solo6x10-core.c b/drivers/staging/media/solo6x10/solo6x10-core.c
47598 index 3675020..e80d92c 100644
47599 --- a/drivers/staging/media/solo6x10/solo6x10-core.c
47600 +++ b/drivers/staging/media/solo6x10/solo6x10-core.c
47601 @@ -434,7 +434,7 @@ static void solo_device_release(struct device *dev)
47602
47603 static int solo_sysfs_init(struct solo_dev *solo_dev)
47604 {
47605 - struct bin_attribute *sdram_attr = &solo_dev->sdram_attr;
47606 + bin_attribute_no_const *sdram_attr = &solo_dev->sdram_attr;
47607 struct device *dev = &solo_dev->dev;
47608 const char *driver;
47609 int i;
47610 diff --git a/drivers/staging/media/solo6x10/solo6x10-p2m.c b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47611 index 3335941..2b26186 100644
47612 --- a/drivers/staging/media/solo6x10/solo6x10-p2m.c
47613 +++ b/drivers/staging/media/solo6x10/solo6x10-p2m.c
47614 @@ -77,7 +77,7 @@ int solo_p2m_dma_desc(struct solo_dev *solo_dev,
47615
47616 /* Get next ID. According to Softlogic, 6110 has problems on !=0 P2M */
47617 if (solo_dev->type != SOLO_DEV_6110 && multi_p2m) {
47618 - p2m_id = atomic_inc_return(&solo_dev->p2m_count) % SOLO_NR_P2M;
47619 + p2m_id = atomic_inc_return_unchecked(&solo_dev->p2m_count) % SOLO_NR_P2M;
47620 if (p2m_id < 0)
47621 p2m_id = -p2m_id;
47622 }
47623 diff --git a/drivers/staging/media/solo6x10/solo6x10.h b/drivers/staging/media/solo6x10/solo6x10.h
47624 index 6f91d2e..3f011d2 100644
47625 --- a/drivers/staging/media/solo6x10/solo6x10.h
47626 +++ b/drivers/staging/media/solo6x10/solo6x10.h
47627 @@ -238,7 +238,7 @@ struct solo_dev {
47628
47629 /* P2M DMA Engine */
47630 struct solo_p2m_dev p2m_dev[SOLO_NR_P2M];
47631 - atomic_t p2m_count;
47632 + atomic_unchecked_t p2m_count;
47633 int p2m_jiffies;
47634 unsigned int p2m_timeouts;
47635
47636 diff --git a/drivers/staging/octeon/ethernet-rx.c b/drivers/staging/octeon/ethernet-rx.c
47637 index e14a1bb..9cb9bbe 100644
47638 --- a/drivers/staging/octeon/ethernet-rx.c
47639 +++ b/drivers/staging/octeon/ethernet-rx.c
47640 @@ -419,11 +419,11 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47641 /* Increment RX stats for virtual ports */
47642 if (work->ipprt >= CVMX_PIP_NUM_INPUT_PORTS) {
47643 #ifdef CONFIG_64BIT
47644 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_packets);
47645 - atomic64_add(skb->len, (atomic64_t *)&priv->stats.rx_bytes);
47646 + atomic64_add_unchecked(1, (atomic64_unchecked_t *)&priv->stats.rx_packets);
47647 + atomic64_add_unchecked(skb->len, (atomic64_unchecked_t *)&priv->stats.rx_bytes);
47648 #else
47649 - atomic_add(1, (atomic_t *)&priv->stats.rx_packets);
47650 - atomic_add(skb->len, (atomic_t *)&priv->stats.rx_bytes);
47651 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_packets);
47652 + atomic_add_unchecked(skb->len, (atomic_unchecked_t *)&priv->stats.rx_bytes);
47653 #endif
47654 }
47655 netif_receive_skb(skb);
47656 @@ -434,9 +434,9 @@ static int cvm_oct_napi_poll(struct napi_struct *napi, int budget)
47657 dev->name);
47658 */
47659 #ifdef CONFIG_64BIT
47660 - atomic64_add(1, (atomic64_t *)&priv->stats.rx_dropped);
47661 + atomic64_unchecked_add(1, (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47662 #else
47663 - atomic_add(1, (atomic_t *)&priv->stats.rx_dropped);
47664 + atomic_add_unchecked(1, (atomic_unchecked_t *)&priv->stats.rx_dropped);
47665 #endif
47666 dev_kfree_skb_irq(skb);
47667 }
47668 diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c
47669 index c3a90e7..023619a 100644
47670 --- a/drivers/staging/octeon/ethernet.c
47671 +++ b/drivers/staging/octeon/ethernet.c
47672 @@ -252,11 +252,11 @@ static struct net_device_stats *cvm_oct_common_get_stats(struct net_device *dev)
47673 * since the RX tasklet also increments it.
47674 */
47675 #ifdef CONFIG_64BIT
47676 - atomic64_add(rx_status.dropped_packets,
47677 - (atomic64_t *)&priv->stats.rx_dropped);
47678 + atomic64_add_unchecked(rx_status.dropped_packets,
47679 + (atomic64_unchecked_t *)&priv->stats.rx_dropped);
47680 #else
47681 - atomic_add(rx_status.dropped_packets,
47682 - (atomic_t *)&priv->stats.rx_dropped);
47683 + atomic_add_unchecked(rx_status.dropped_packets,
47684 + (atomic_unchecked_t *)&priv->stats.rx_dropped);
47685 #endif
47686 }
47687
47688 diff --git a/drivers/staging/rtl8188eu/include/hal_intf.h b/drivers/staging/rtl8188eu/include/hal_intf.h
47689 index 439c3c9..2d74293 100644
47690 --- a/drivers/staging/rtl8188eu/include/hal_intf.h
47691 +++ b/drivers/staging/rtl8188eu/include/hal_intf.h
47692 @@ -271,7 +271,7 @@ struct hal_ops {
47693 s32 (*c2h_handler)(struct adapter *padapter,
47694 struct c2h_evt_hdr *c2h_evt);
47695 c2h_id_filter c2h_id_filter_ccx;
47696 -};
47697 +} __no_const;
47698
47699 enum rt_eeprom_type {
47700 EEPROM_93C46,
47701 diff --git a/drivers/staging/rtl8188eu/include/rtw_io.h b/drivers/staging/rtl8188eu/include/rtw_io.h
47702 index eb6f0e5..e6a0958 100644
47703 --- a/drivers/staging/rtl8188eu/include/rtw_io.h
47704 +++ b/drivers/staging/rtl8188eu/include/rtw_io.h
47705 @@ -126,7 +126,7 @@ struct _io_ops {
47706 u32 (*_write_scsi)(struct intf_hdl *pintfhdl,u32 cnt, u8 *pmem);
47707 void (*_read_port_cancel)(struct intf_hdl *pintfhdl);
47708 void (*_write_port_cancel)(struct intf_hdl *pintfhdl);
47709 -};
47710 +} __no_const;
47711
47712 struct io_req {
47713 struct list_head list;
47714 diff --git a/drivers/staging/rtl8712/rtl871x_io.h b/drivers/staging/rtl8712/rtl871x_io.h
47715 index dc23395..cf7e9b1 100644
47716 --- a/drivers/staging/rtl8712/rtl871x_io.h
47717 +++ b/drivers/staging/rtl8712/rtl871x_io.h
47718 @@ -108,7 +108,7 @@ struct _io_ops {
47719 u8 *pmem);
47720 u32 (*_write_port)(struct intf_hdl *pintfhdl, u32 addr, u32 cnt,
47721 u8 *pmem);
47722 -};
47723 +} __no_const;
47724
47725 struct io_req {
47726 struct list_head list;
47727 diff --git a/drivers/staging/sbe-2t3e3/netdev.c b/drivers/staging/sbe-2t3e3/netdev.c
47728 index 1f5088b..0e59820 100644
47729 --- a/drivers/staging/sbe-2t3e3/netdev.c
47730 +++ b/drivers/staging/sbe-2t3e3/netdev.c
47731 @@ -51,7 +51,7 @@ static int t3e3_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
47732 t3e3_if_config(sc, cmd_2t3e3, (char *)&param, &resp, &rlen);
47733
47734 if (rlen)
47735 - if (copy_to_user(data, &resp, rlen))
47736 + if (rlen > sizeof resp || copy_to_user(data, &resp, rlen))
47737 return -EFAULT;
47738
47739 return 0;
47740 diff --git a/drivers/staging/usbip/vhci.h b/drivers/staging/usbip/vhci.h
47741 index a863a98..d272795 100644
47742 --- a/drivers/staging/usbip/vhci.h
47743 +++ b/drivers/staging/usbip/vhci.h
47744 @@ -83,7 +83,7 @@ struct vhci_hcd {
47745 unsigned resuming:1;
47746 unsigned long re_timeout;
47747
47748 - atomic_t seqnum;
47749 + atomic_unchecked_t seqnum;
47750
47751 /*
47752 * NOTE:
47753 diff --git a/drivers/staging/usbip/vhci_hcd.c b/drivers/staging/usbip/vhci_hcd.c
47754 index d7974cb..d78076b 100644
47755 --- a/drivers/staging/usbip/vhci_hcd.c
47756 +++ b/drivers/staging/usbip/vhci_hcd.c
47757 @@ -441,7 +441,7 @@ static void vhci_tx_urb(struct urb *urb)
47758
47759 spin_lock(&vdev->priv_lock);
47760
47761 - priv->seqnum = atomic_inc_return(&the_controller->seqnum);
47762 + priv->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47763 if (priv->seqnum == 0xffff)
47764 dev_info(&urb->dev->dev, "seqnum max\n");
47765
47766 @@ -687,7 +687,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
47767 return -ENOMEM;
47768 }
47769
47770 - unlink->seqnum = atomic_inc_return(&the_controller->seqnum);
47771 + unlink->seqnum = atomic_inc_return_unchecked(&the_controller->seqnum);
47772 if (unlink->seqnum == 0xffff)
47773 pr_info("seqnum max\n");
47774
47775 @@ -891,7 +891,7 @@ static int vhci_start(struct usb_hcd *hcd)
47776 vdev->rhport = rhport;
47777 }
47778
47779 - atomic_set(&vhci->seqnum, 0);
47780 + atomic_set_unchecked(&vhci->seqnum, 0);
47781 spin_lock_init(&vhci->lock);
47782
47783 hcd->power_budget = 0; /* no limit */
47784 diff --git a/drivers/staging/usbip/vhci_rx.c b/drivers/staging/usbip/vhci_rx.c
47785 index d07fcb5..358e1e1 100644
47786 --- a/drivers/staging/usbip/vhci_rx.c
47787 +++ b/drivers/staging/usbip/vhci_rx.c
47788 @@ -80,7 +80,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
47789 if (!urb) {
47790 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
47791 pr_info("max seqnum %d\n",
47792 - atomic_read(&the_controller->seqnum));
47793 + atomic_read_unchecked(&the_controller->seqnum));
47794 usbip_event_add(ud, VDEV_EVENT_ERROR_TCP);
47795 return;
47796 }
47797 diff --git a/drivers/staging/vt6655/hostap.c b/drivers/staging/vt6655/hostap.c
47798 index 8acff44..bdb2fca 100644
47799 --- a/drivers/staging/vt6655/hostap.c
47800 +++ b/drivers/staging/vt6655/hostap.c
47801 @@ -69,14 +69,13 @@ static int msglevel = MSG_LEVEL_INFO;
47802 *
47803 */
47804
47805 +static net_device_ops_no_const apdev_netdev_ops;
47806 +
47807 static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47808 {
47809 PSDevice apdev_priv;
47810 struct net_device *dev = pDevice->dev;
47811 int ret;
47812 - const struct net_device_ops apdev_netdev_ops = {
47813 - .ndo_start_xmit = pDevice->tx_80211,
47814 - };
47815
47816 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47817
47818 @@ -88,6 +87,8 @@ static int hostap_enable_hostapd(PSDevice pDevice, int rtnl_locked)
47819 *apdev_priv = *pDevice;
47820 eth_hw_addr_inherit(pDevice->apdev, dev);
47821
47822 + /* only half broken now */
47823 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47824 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47825
47826 pDevice->apdev->type = ARPHRD_IEEE80211;
47827 diff --git a/drivers/staging/vt6656/hostap.c b/drivers/staging/vt6656/hostap.c
47828 index c699a30..b90a5fd 100644
47829 --- a/drivers/staging/vt6656/hostap.c
47830 +++ b/drivers/staging/vt6656/hostap.c
47831 @@ -60,14 +60,13 @@ static int msglevel =MSG_LEVEL_INFO;
47832 *
47833 */
47834
47835 +static net_device_ops_no_const apdev_netdev_ops;
47836 +
47837 static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47838 {
47839 struct vnt_private *apdev_priv;
47840 struct net_device *dev = pDevice->dev;
47841 int ret;
47842 - const struct net_device_ops apdev_netdev_ops = {
47843 - .ndo_start_xmit = pDevice->tx_80211,
47844 - };
47845
47846 DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO "%s: Enabling hostapd mode\n", dev->name);
47847
47848 @@ -79,6 +78,8 @@ static int hostap_enable_hostapd(struct vnt_private *pDevice, int rtnl_locked)
47849 *apdev_priv = *pDevice;
47850 memcpy(pDevice->apdev->dev_addr, dev->dev_addr, ETH_ALEN);
47851
47852 + /* only half broken now */
47853 + apdev_netdev_ops.ndo_start_xmit = pDevice->tx_80211;
47854 pDevice->apdev->netdev_ops = &apdev_netdev_ops;
47855
47856 pDevice->apdev->type = ARPHRD_IEEE80211;
47857 diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
47858 index e51b09a..5ebac31 100644
47859 --- a/drivers/target/sbp/sbp_target.c
47860 +++ b/drivers/target/sbp/sbp_target.c
47861 @@ -62,7 +62,7 @@ static const u32 sbp_unit_directory_template[] = {
47862
47863 #define SESSION_MAINTENANCE_INTERVAL HZ
47864
47865 -static atomic_t login_id = ATOMIC_INIT(0);
47866 +static atomic_unchecked_t login_id = ATOMIC_INIT(0);
47867
47868 static void session_maintenance_work(struct work_struct *);
47869 static int sbp_run_transaction(struct fw_card *, int, int, int, int,
47870 @@ -444,7 +444,7 @@ static void sbp_management_request_login(
47871 login->lun = se_lun;
47872 login->status_fifo_addr = sbp2_pointer_to_addr(&req->orb.status_fifo);
47873 login->exclusive = LOGIN_ORB_EXCLUSIVE(be32_to_cpu(req->orb.misc));
47874 - login->login_id = atomic_inc_return(&login_id);
47875 + login->login_id = atomic_inc_return_unchecked(&login_id);
47876
47877 login->tgt_agt = sbp_target_agent_register(login);
47878 if (IS_ERR(login->tgt_agt)) {
47879 diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
47880 index e5e3965..a7b487c 100644
47881 --- a/drivers/target/target_core_device.c
47882 +++ b/drivers/target/target_core_device.c
47883 @@ -1436,7 +1436,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
47884 spin_lock_init(&dev->se_tmr_lock);
47885 spin_lock_init(&dev->qf_cmd_lock);
47886 sema_init(&dev->caw_sem, 1);
47887 - atomic_set(&dev->dev_ordered_id, 0);
47888 + atomic_set_unchecked(&dev->dev_ordered_id, 0);
47889 INIT_LIST_HEAD(&dev->t10_wwn.t10_vpd_list);
47890 spin_lock_init(&dev->t10_wwn.t10_vpd_lock);
47891 INIT_LIST_HEAD(&dev->t10_pr.registration_list);
47892 diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
47893 index 0b0009b..215e88e 100644
47894 --- a/drivers/target/target_core_transport.c
47895 +++ b/drivers/target/target_core_transport.c
47896 @@ -1137,7 +1137,7 @@ transport_check_alloc_task_attr(struct se_cmd *cmd)
47897 * Used to determine when ORDERED commands should go from
47898 * Dormant to Active status.
47899 */
47900 - cmd->se_ordered_id = atomic_inc_return(&dev->dev_ordered_id);
47901 + cmd->se_ordered_id = atomic_inc_return_unchecked(&dev->dev_ordered_id);
47902 smp_mb__after_atomic_inc();
47903 pr_debug("Allocated se_ordered_id: %u for Task Attr: 0x%02x on %s\n",
47904 cmd->se_ordered_id, cmd->sam_task_attr,
47905 diff --git a/drivers/tty/cyclades.c b/drivers/tty/cyclades.c
47906 index 33f83fe..d80f8e1 100644
47907 --- a/drivers/tty/cyclades.c
47908 +++ b/drivers/tty/cyclades.c
47909 @@ -1570,10 +1570,10 @@ static int cy_open(struct tty_struct *tty, struct file *filp)
47910 printk(KERN_DEBUG "cyc:cy_open ttyC%d, count = %d\n", info->line,
47911 info->port.count);
47912 #endif
47913 - info->port.count++;
47914 + atomic_inc(&info->port.count);
47915 #ifdef CY_DEBUG_COUNT
47916 printk(KERN_DEBUG "cyc:cy_open (%d): incrementing count to %d\n",
47917 - current->pid, info->port.count);
47918 + current->pid, atomic_read(&info->port.count));
47919 #endif
47920
47921 /*
47922 @@ -3972,7 +3972,7 @@ static int cyclades_proc_show(struct seq_file *m, void *v)
47923 for (j = 0; j < cy_card[i].nports; j++) {
47924 info = &cy_card[i].ports[j];
47925
47926 - if (info->port.count) {
47927 + if (atomic_read(&info->port.count)) {
47928 /* XXX is the ldisc num worth this? */
47929 struct tty_struct *tty;
47930 struct tty_ldisc *ld;
47931 diff --git a/drivers/tty/hvc/hvc_console.c b/drivers/tty/hvc/hvc_console.c
47932 index 9eba119..5070303 100644
47933 --- a/drivers/tty/hvc/hvc_console.c
47934 +++ b/drivers/tty/hvc/hvc_console.c
47935 @@ -338,7 +338,7 @@ static int hvc_open(struct tty_struct *tty, struct file * filp)
47936
47937 spin_lock_irqsave(&hp->port.lock, flags);
47938 /* Check and then increment for fast path open. */
47939 - if (hp->port.count++ > 0) {
47940 + if (atomic_inc_return(&hp->port.count) > 1) {
47941 spin_unlock_irqrestore(&hp->port.lock, flags);
47942 hvc_kick();
47943 return 0;
47944 @@ -393,7 +393,7 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47945
47946 spin_lock_irqsave(&hp->port.lock, flags);
47947
47948 - if (--hp->port.count == 0) {
47949 + if (atomic_dec_return(&hp->port.count) == 0) {
47950 spin_unlock_irqrestore(&hp->port.lock, flags);
47951 /* We are done with the tty pointer now. */
47952 tty_port_tty_set(&hp->port, NULL);
47953 @@ -415,9 +415,9 @@ static void hvc_close(struct tty_struct *tty, struct file * filp)
47954 */
47955 tty_wait_until_sent_from_close(tty, HVC_CLOSE_WAIT);
47956 } else {
47957 - if (hp->port.count < 0)
47958 + if (atomic_read(&hp->port.count) < 0)
47959 printk(KERN_ERR "hvc_close %X: oops, count is %d\n",
47960 - hp->vtermno, hp->port.count);
47961 + hp->vtermno, atomic_read(&hp->port.count));
47962 spin_unlock_irqrestore(&hp->port.lock, flags);
47963 }
47964 }
47965 @@ -447,12 +447,12 @@ static void hvc_hangup(struct tty_struct *tty)
47966 * open->hangup case this can be called after the final close so prevent
47967 * that from happening for now.
47968 */
47969 - if (hp->port.count <= 0) {
47970 + if (atomic_read(&hp->port.count) <= 0) {
47971 spin_unlock_irqrestore(&hp->port.lock, flags);
47972 return;
47973 }
47974
47975 - hp->port.count = 0;
47976 + atomic_set(&hp->port.count, 0);
47977 spin_unlock_irqrestore(&hp->port.lock, flags);
47978 tty_port_tty_set(&hp->port, NULL);
47979
47980 @@ -500,7 +500,7 @@ static int hvc_write(struct tty_struct *tty, const unsigned char *buf, int count
47981 return -EPIPE;
47982
47983 /* FIXME what's this (unprotected) check for? */
47984 - if (hp->port.count <= 0)
47985 + if (atomic_read(&hp->port.count) <= 0)
47986 return -EIO;
47987
47988 spin_lock_irqsave(&hp->lock, flags);
47989 diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
47990 index 81e939e..95ead10 100644
47991 --- a/drivers/tty/hvc/hvcs.c
47992 +++ b/drivers/tty/hvc/hvcs.c
47993 @@ -83,6 +83,7 @@
47994 #include <asm/hvcserver.h>
47995 #include <asm/uaccess.h>
47996 #include <asm/vio.h>
47997 +#include <asm/local.h>
47998
47999 /*
48000 * 1.3.0 -> 1.3.1 In hvcs_open memset(..,0x00,..) instead of memset(..,0x3F,00).
48001 @@ -416,7 +417,7 @@ static ssize_t hvcs_vterm_state_store(struct device *dev, struct device_attribut
48002
48003 spin_lock_irqsave(&hvcsd->lock, flags);
48004
48005 - if (hvcsd->port.count > 0) {
48006 + if (atomic_read(&hvcsd->port.count) > 0) {
48007 spin_unlock_irqrestore(&hvcsd->lock, flags);
48008 printk(KERN_INFO "HVCS: vterm state unchanged. "
48009 "The hvcs device node is still in use.\n");
48010 @@ -1127,7 +1128,7 @@ static int hvcs_install(struct tty_driver *driver, struct tty_struct *tty)
48011 }
48012 }
48013
48014 - hvcsd->port.count = 0;
48015 + atomic_set(&hvcsd->port.count, 0);
48016 hvcsd->port.tty = tty;
48017 tty->driver_data = hvcsd;
48018
48019 @@ -1180,7 +1181,7 @@ static int hvcs_open(struct tty_struct *tty, struct file *filp)
48020 unsigned long flags;
48021
48022 spin_lock_irqsave(&hvcsd->lock, flags);
48023 - hvcsd->port.count++;
48024 + atomic_inc(&hvcsd->port.count);
48025 hvcsd->todo_mask |= HVCS_SCHED_READ;
48026 spin_unlock_irqrestore(&hvcsd->lock, flags);
48027
48028 @@ -1216,7 +1217,7 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
48029 hvcsd = tty->driver_data;
48030
48031 spin_lock_irqsave(&hvcsd->lock, flags);
48032 - if (--hvcsd->port.count == 0) {
48033 + if (atomic_dec_and_test(&hvcsd->port.count)) {
48034
48035 vio_disable_interrupts(hvcsd->vdev);
48036
48037 @@ -1241,10 +1242,10 @@ static void hvcs_close(struct tty_struct *tty, struct file *filp)
48038
48039 free_irq(irq, hvcsd);
48040 return;
48041 - } else if (hvcsd->port.count < 0) {
48042 + } else if (atomic_read(&hvcsd->port.count) < 0) {
48043 printk(KERN_ERR "HVCS: vty-server@%X open_count: %d"
48044 " is missmanaged.\n",
48045 - hvcsd->vdev->unit_address, hvcsd->port.count);
48046 + hvcsd->vdev->unit_address, atomic_read(&hvcsd->port.count));
48047 }
48048
48049 spin_unlock_irqrestore(&hvcsd->lock, flags);
48050 @@ -1266,7 +1267,7 @@ static void hvcs_hangup(struct tty_struct * tty)
48051
48052 spin_lock_irqsave(&hvcsd->lock, flags);
48053 /* Preserve this so that we know how many kref refs to put */
48054 - temp_open_count = hvcsd->port.count;
48055 + temp_open_count = atomic_read(&hvcsd->port.count);
48056
48057 /*
48058 * Don't kref put inside the spinlock because the destruction
48059 @@ -1281,7 +1282,7 @@ static void hvcs_hangup(struct tty_struct * tty)
48060 tty->driver_data = NULL;
48061 hvcsd->port.tty = NULL;
48062
48063 - hvcsd->port.count = 0;
48064 + atomic_set(&hvcsd->port.count, 0);
48065
48066 /* This will drop any buffered data on the floor which is OK in a hangup
48067 * scenario. */
48068 @@ -1352,7 +1353,7 @@ static int hvcs_write(struct tty_struct *tty,
48069 * the middle of a write operation? This is a crummy place to do this
48070 * but we want to keep it all in the spinlock.
48071 */
48072 - if (hvcsd->port.count <= 0) {
48073 + if (atomic_read(&hvcsd->port.count) <= 0) {
48074 spin_unlock_irqrestore(&hvcsd->lock, flags);
48075 return -ENODEV;
48076 }
48077 @@ -1426,7 +1427,7 @@ static int hvcs_write_room(struct tty_struct *tty)
48078 {
48079 struct hvcs_struct *hvcsd = tty->driver_data;
48080
48081 - if (!hvcsd || hvcsd->port.count <= 0)
48082 + if (!hvcsd || atomic_read(&hvcsd->port.count) <= 0)
48083 return 0;
48084
48085 return HVCS_BUFF_LEN - hvcsd->chars_in_buffer;
48086 diff --git a/drivers/tty/hvc/hvsi.c b/drivers/tty/hvc/hvsi.c
48087 index 4190199..48f2920 100644
48088 --- a/drivers/tty/hvc/hvsi.c
48089 +++ b/drivers/tty/hvc/hvsi.c
48090 @@ -85,7 +85,7 @@ struct hvsi_struct {
48091 int n_outbuf;
48092 uint32_t vtermno;
48093 uint32_t virq;
48094 - atomic_t seqno; /* HVSI packet sequence number */
48095 + atomic_unchecked_t seqno; /* HVSI packet sequence number */
48096 uint16_t mctrl;
48097 uint8_t state; /* HVSI protocol state */
48098 uint8_t flags;
48099 @@ -295,7 +295,7 @@ static int hvsi_version_respond(struct hvsi_struct *hp, uint16_t query_seqno)
48100
48101 packet.hdr.type = VS_QUERY_RESPONSE_PACKET_HEADER;
48102 packet.hdr.len = sizeof(struct hvsi_query_response);
48103 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48104 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48105 packet.verb = VSV_SEND_VERSION_NUMBER;
48106 packet.u.version = HVSI_VERSION;
48107 packet.query_seqno = query_seqno+1;
48108 @@ -555,7 +555,7 @@ static int hvsi_query(struct hvsi_struct *hp, uint16_t verb)
48109
48110 packet.hdr.type = VS_QUERY_PACKET_HEADER;
48111 packet.hdr.len = sizeof(struct hvsi_query);
48112 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48113 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48114 packet.verb = verb;
48115
48116 pr_debug("%s: sending %i bytes\n", __func__, packet.hdr.len);
48117 @@ -597,7 +597,7 @@ static int hvsi_set_mctrl(struct hvsi_struct *hp, uint16_t mctrl)
48118 int wrote;
48119
48120 packet.hdr.type = VS_CONTROL_PACKET_HEADER,
48121 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48122 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48123 packet.hdr.len = sizeof(struct hvsi_control);
48124 packet.verb = VSV_SET_MODEM_CTL;
48125 packet.mask = HVSI_TSDTR;
48126 @@ -680,7 +680,7 @@ static int hvsi_put_chars(struct hvsi_struct *hp, const char *buf, int count)
48127 BUG_ON(count > HVSI_MAX_OUTGOING_DATA);
48128
48129 packet.hdr.type = VS_DATA_PACKET_HEADER;
48130 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48131 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48132 packet.hdr.len = count + sizeof(struct hvsi_header);
48133 memcpy(&packet.data, buf, count);
48134
48135 @@ -697,7 +697,7 @@ static void hvsi_close_protocol(struct hvsi_struct *hp)
48136 struct hvsi_control packet __ALIGNED__;
48137
48138 packet.hdr.type = VS_CONTROL_PACKET_HEADER;
48139 - packet.hdr.seqno = atomic_inc_return(&hp->seqno);
48140 + packet.hdr.seqno = atomic_inc_return_unchecked(&hp->seqno);
48141 packet.hdr.len = 6;
48142 packet.verb = VSV_CLOSE_PROTOCOL;
48143
48144 diff --git a/drivers/tty/hvc/hvsi_lib.c b/drivers/tty/hvc/hvsi_lib.c
48145 index ac27671..0f627ee 100644
48146 --- a/drivers/tty/hvc/hvsi_lib.c
48147 +++ b/drivers/tty/hvc/hvsi_lib.c
48148 @@ -9,7 +9,7 @@
48149
48150 static int hvsi_send_packet(struct hvsi_priv *pv, struct hvsi_header *packet)
48151 {
48152 - packet->seqno = atomic_inc_return(&pv->seqno);
48153 + packet->seqno = atomic_inc_return_unchecked(&pv->seqno);
48154
48155 /* Assumes that always succeeds, works in practice */
48156 return pv->put_chars(pv->termno, (char *)packet, packet->len);
48157 @@ -21,7 +21,7 @@ static void hvsi_start_handshake(struct hvsi_priv *pv)
48158
48159 /* Reset state */
48160 pv->established = 0;
48161 - atomic_set(&pv->seqno, 0);
48162 + atomic_set_unchecked(&pv->seqno, 0);
48163
48164 pr_devel("HVSI@%x: Handshaking started\n", pv->termno);
48165
48166 @@ -265,7 +265,7 @@ int hvsilib_read_mctrl(struct hvsi_priv *pv)
48167 pv->mctrl_update = 0;
48168 q.hdr.type = VS_QUERY_PACKET_HEADER;
48169 q.hdr.len = sizeof(struct hvsi_query);
48170 - q.hdr.seqno = atomic_inc_return(&pv->seqno);
48171 + q.hdr.seqno = atomic_inc_return_unchecked(&pv->seqno);
48172 q.verb = VSV_SEND_MODEM_CTL_STATUS;
48173 rc = hvsi_send_packet(pv, &q.hdr);
48174 if (rc <= 0) {
48175 diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c
48176 index 8fd72ff..34a0bed 100644
48177 --- a/drivers/tty/ipwireless/tty.c
48178 +++ b/drivers/tty/ipwireless/tty.c
48179 @@ -29,6 +29,7 @@
48180 #include <linux/tty_driver.h>
48181 #include <linux/tty_flip.h>
48182 #include <linux/uaccess.h>
48183 +#include <asm/local.h>
48184
48185 #include "tty.h"
48186 #include "network.h"
48187 @@ -99,10 +100,10 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48188 mutex_unlock(&tty->ipw_tty_mutex);
48189 return -ENODEV;
48190 }
48191 - if (tty->port.count == 0)
48192 + if (atomic_read(&tty->port.count) == 0)
48193 tty->tx_bytes_queued = 0;
48194
48195 - tty->port.count++;
48196 + atomic_inc(&tty->port.count);
48197
48198 tty->port.tty = linux_tty;
48199 linux_tty->driver_data = tty;
48200 @@ -118,9 +119,7 @@ static int ipw_open(struct tty_struct *linux_tty, struct file *filp)
48201
48202 static void do_ipw_close(struct ipw_tty *tty)
48203 {
48204 - tty->port.count--;
48205 -
48206 - if (tty->port.count == 0) {
48207 + if (atomic_dec_return(&tty->port.count) == 0) {
48208 struct tty_struct *linux_tty = tty->port.tty;
48209
48210 if (linux_tty != NULL) {
48211 @@ -141,7 +140,7 @@ static void ipw_hangup(struct tty_struct *linux_tty)
48212 return;
48213
48214 mutex_lock(&tty->ipw_tty_mutex);
48215 - if (tty->port.count == 0) {
48216 + if (atomic_read(&tty->port.count) == 0) {
48217 mutex_unlock(&tty->ipw_tty_mutex);
48218 return;
48219 }
48220 @@ -164,7 +163,7 @@ void ipwireless_tty_received(struct ipw_tty *tty, unsigned char *data,
48221
48222 mutex_lock(&tty->ipw_tty_mutex);
48223
48224 - if (!tty->port.count) {
48225 + if (!atomic_read(&tty->port.count)) {
48226 mutex_unlock(&tty->ipw_tty_mutex);
48227 return;
48228 }
48229 @@ -206,7 +205,7 @@ static int ipw_write(struct tty_struct *linux_tty,
48230 return -ENODEV;
48231
48232 mutex_lock(&tty->ipw_tty_mutex);
48233 - if (!tty->port.count) {
48234 + if (!atomic_read(&tty->port.count)) {
48235 mutex_unlock(&tty->ipw_tty_mutex);
48236 return -EINVAL;
48237 }
48238 @@ -246,7 +245,7 @@ static int ipw_write_room(struct tty_struct *linux_tty)
48239 if (!tty)
48240 return -ENODEV;
48241
48242 - if (!tty->port.count)
48243 + if (!atomic_read(&tty->port.count))
48244 return -EINVAL;
48245
48246 room = IPWIRELESS_TX_QUEUE_SIZE - tty->tx_bytes_queued;
48247 @@ -288,7 +287,7 @@ static int ipw_chars_in_buffer(struct tty_struct *linux_tty)
48248 if (!tty)
48249 return 0;
48250
48251 - if (!tty->port.count)
48252 + if (!atomic_read(&tty->port.count))
48253 return 0;
48254
48255 return tty->tx_bytes_queued;
48256 @@ -369,7 +368,7 @@ static int ipw_tiocmget(struct tty_struct *linux_tty)
48257 if (!tty)
48258 return -ENODEV;
48259
48260 - if (!tty->port.count)
48261 + if (!atomic_read(&tty->port.count))
48262 return -EINVAL;
48263
48264 return get_control_lines(tty);
48265 @@ -385,7 +384,7 @@ ipw_tiocmset(struct tty_struct *linux_tty,
48266 if (!tty)
48267 return -ENODEV;
48268
48269 - if (!tty->port.count)
48270 + if (!atomic_read(&tty->port.count))
48271 return -EINVAL;
48272
48273 return set_control_lines(tty, set, clear);
48274 @@ -399,7 +398,7 @@ static int ipw_ioctl(struct tty_struct *linux_tty,
48275 if (!tty)
48276 return -ENODEV;
48277
48278 - if (!tty->port.count)
48279 + if (!atomic_read(&tty->port.count))
48280 return -EINVAL;
48281
48282 /* FIXME: Exactly how is the tty object locked here .. */
48283 @@ -555,7 +554,7 @@ void ipwireless_tty_free(struct ipw_tty *tty)
48284 * are gone */
48285 mutex_lock(&ttyj->ipw_tty_mutex);
48286 }
48287 - while (ttyj->port.count)
48288 + while (atomic_read(&ttyj->port.count))
48289 do_ipw_close(ttyj);
48290 ipwireless_disassociate_network_ttys(network,
48291 ttyj->channel_idx);
48292 diff --git a/drivers/tty/moxa.c b/drivers/tty/moxa.c
48293 index 1deaca4..c8582d4 100644
48294 --- a/drivers/tty/moxa.c
48295 +++ b/drivers/tty/moxa.c
48296 @@ -1189,7 +1189,7 @@ static int moxa_open(struct tty_struct *tty, struct file *filp)
48297 }
48298
48299 ch = &brd->ports[port % MAX_PORTS_PER_BOARD];
48300 - ch->port.count++;
48301 + atomic_inc(&ch->port.count);
48302 tty->driver_data = ch;
48303 tty_port_tty_set(&ch->port, tty);
48304 mutex_lock(&ch->port.mutex);
48305 diff --git a/drivers/tty/n_gsm.c b/drivers/tty/n_gsm.c
48306 index c0f76da..d974c32 100644
48307 --- a/drivers/tty/n_gsm.c
48308 +++ b/drivers/tty/n_gsm.c
48309 @@ -1632,7 +1632,7 @@ static struct gsm_dlci *gsm_dlci_alloc(struct gsm_mux *gsm, int addr)
48310 spin_lock_init(&dlci->lock);
48311 mutex_init(&dlci->mutex);
48312 dlci->fifo = &dlci->_fifo;
48313 - if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL) < 0) {
48314 + if (kfifo_alloc(&dlci->_fifo, 4096, GFP_KERNEL)) {
48315 kfree(dlci);
48316 return NULL;
48317 }
48318 @@ -2935,7 +2935,7 @@ static int gsmtty_open(struct tty_struct *tty, struct file *filp)
48319 struct gsm_dlci *dlci = tty->driver_data;
48320 struct tty_port *port = &dlci->port;
48321
48322 - port->count++;
48323 + atomic_inc(&port->count);
48324 dlci_get(dlci);
48325 dlci_get(dlci->gsm->dlci[0]);
48326 mux_get(dlci->gsm);
48327 diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
48328 index d4a89db..dbe8d8c 100644
48329 --- a/drivers/tty/n_tty.c
48330 +++ b/drivers/tty/n_tty.c
48331 @@ -114,7 +114,7 @@ struct n_tty_data {
48332 int minimum_to_wake;
48333
48334 /* consumer-published */
48335 - size_t read_tail;
48336 + size_t read_tail __intentional_overflow(-1);
48337 size_t line_start;
48338
48339 /* protected by output lock */
48340 @@ -2509,6 +2509,7 @@ void n_tty_inherit_ops(struct tty_ldisc_ops *ops)
48341 {
48342 *ops = tty_ldisc_N_TTY;
48343 ops->owner = NULL;
48344 - ops->refcount = ops->flags = 0;
48345 + atomic_set(&ops->refcount, 0);
48346 + ops->flags = 0;
48347 }
48348 EXPORT_SYMBOL_GPL(n_tty_inherit_ops);
48349 diff --git a/drivers/tty/pty.c b/drivers/tty/pty.c
48350 index 25c9bc7..24077b7 100644
48351 --- a/drivers/tty/pty.c
48352 +++ b/drivers/tty/pty.c
48353 @@ -790,8 +790,10 @@ static void __init unix98_pty_init(void)
48354 panic("Couldn't register Unix98 pts driver");
48355
48356 /* Now create the /dev/ptmx special device */
48357 + pax_open_kernel();
48358 tty_default_fops(&ptmx_fops);
48359 - ptmx_fops.open = ptmx_open;
48360 + *(void **)&ptmx_fops.open = ptmx_open;
48361 + pax_close_kernel();
48362
48363 cdev_init(&ptmx_cdev, &ptmx_fops);
48364 if (cdev_add(&ptmx_cdev, MKDEV(TTYAUX_MAJOR, 2), 1) ||
48365 diff --git a/drivers/tty/rocket.c b/drivers/tty/rocket.c
48366 index 354564e..fe50d9a 100644
48367 --- a/drivers/tty/rocket.c
48368 +++ b/drivers/tty/rocket.c
48369 @@ -914,7 +914,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48370 tty->driver_data = info;
48371 tty_port_tty_set(port, tty);
48372
48373 - if (port->count++ == 0) {
48374 + if (atomic_inc_return(&port->count) == 1) {
48375 atomic_inc(&rp_num_ports_open);
48376
48377 #ifdef ROCKET_DEBUG_OPEN
48378 @@ -923,7 +923,7 @@ static int rp_open(struct tty_struct *tty, struct file *filp)
48379 #endif
48380 }
48381 #ifdef ROCKET_DEBUG_OPEN
48382 - printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, info->port.count);
48383 + printk(KERN_INFO "rp_open ttyR%d, count=%d\n", info->line, atomic-read(&info->port.count));
48384 #endif
48385
48386 /*
48387 @@ -1515,7 +1515,7 @@ static void rp_hangup(struct tty_struct *tty)
48388 spin_unlock_irqrestore(&info->port.lock, flags);
48389 return;
48390 }
48391 - if (info->port.count)
48392 + if (atomic_read(&info->port.count))
48393 atomic_dec(&rp_num_ports_open);
48394 clear_bit((info->aiop * 8) + info->chan, (void *) &xmit_flags[info->board]);
48395 spin_unlock_irqrestore(&info->port.lock, flags);
48396 diff --git a/drivers/tty/serial/ioc4_serial.c b/drivers/tty/serial/ioc4_serial.c
48397 index 1274499..f541382 100644
48398 --- a/drivers/tty/serial/ioc4_serial.c
48399 +++ b/drivers/tty/serial/ioc4_serial.c
48400 @@ -437,7 +437,7 @@ struct ioc4_soft {
48401 } is_intr_info[MAX_IOC4_INTR_ENTS];
48402
48403 /* Number of entries active in the above array */
48404 - atomic_t is_num_intrs;
48405 + atomic_unchecked_t is_num_intrs;
48406 } is_intr_type[IOC4_NUM_INTR_TYPES];
48407
48408 /* is_ir_lock must be held while
48409 @@ -974,7 +974,7 @@ intr_connect(struct ioc4_soft *soft, int type,
48410 BUG_ON(!((type == IOC4_SIO_INTR_TYPE)
48411 || (type == IOC4_OTHER_INTR_TYPE)));
48412
48413 - i = atomic_inc_return(&soft-> is_intr_type[type].is_num_intrs) - 1;
48414 + i = atomic_inc_return_unchecked(&soft-> is_intr_type[type].is_num_intrs) - 1;
48415 BUG_ON(!(i < MAX_IOC4_INTR_ENTS || (printk("i %d\n", i), 0)));
48416
48417 /* Save off the lower level interrupt handler */
48418 @@ -1001,7 +1001,7 @@ static irqreturn_t ioc4_intr(int irq, void *arg)
48419
48420 soft = arg;
48421 for (intr_type = 0; intr_type < IOC4_NUM_INTR_TYPES; intr_type++) {
48422 - num_intrs = (int)atomic_read(
48423 + num_intrs = (int)atomic_read_unchecked(
48424 &soft->is_intr_type[intr_type].is_num_intrs);
48425
48426 this_mir = this_ir = pending_intrs(soft, intr_type);
48427 diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c
48428 index a260cde..6b2b5ce 100644
48429 --- a/drivers/tty/serial/kgdboc.c
48430 +++ b/drivers/tty/serial/kgdboc.c
48431 @@ -24,8 +24,9 @@
48432 #define MAX_CONFIG_LEN 40
48433
48434 static struct kgdb_io kgdboc_io_ops;
48435 +static struct kgdb_io kgdboc_io_ops_console;
48436
48437 -/* -1 = init not run yet, 0 = unconfigured, 1 = configured. */
48438 +/* -1 = init not run yet, 0 = unconfigured, 1/2 = configured. */
48439 static int configured = -1;
48440
48441 static char config[MAX_CONFIG_LEN];
48442 @@ -151,6 +152,8 @@ static void cleanup_kgdboc(void)
48443 kgdboc_unregister_kbd();
48444 if (configured == 1)
48445 kgdb_unregister_io_module(&kgdboc_io_ops);
48446 + else if (configured == 2)
48447 + kgdb_unregister_io_module(&kgdboc_io_ops_console);
48448 }
48449
48450 static int configure_kgdboc(void)
48451 @@ -160,13 +163,13 @@ static int configure_kgdboc(void)
48452 int err;
48453 char *cptr = config;
48454 struct console *cons;
48455 + int is_console = 0;
48456
48457 err = kgdboc_option_setup(config);
48458 if (err || !strlen(config) || isspace(config[0]))
48459 goto noconfig;
48460
48461 err = -ENODEV;
48462 - kgdboc_io_ops.is_console = 0;
48463 kgdb_tty_driver = NULL;
48464
48465 kgdboc_use_kms = 0;
48466 @@ -187,7 +190,7 @@ static int configure_kgdboc(void)
48467 int idx;
48468 if (cons->device && cons->device(cons, &idx) == p &&
48469 idx == tty_line) {
48470 - kgdboc_io_ops.is_console = 1;
48471 + is_console = 1;
48472 break;
48473 }
48474 cons = cons->next;
48475 @@ -197,7 +200,13 @@ static int configure_kgdboc(void)
48476 kgdb_tty_line = tty_line;
48477
48478 do_register:
48479 - err = kgdb_register_io_module(&kgdboc_io_ops);
48480 + if (is_console) {
48481 + err = kgdb_register_io_module(&kgdboc_io_ops_console);
48482 + configured = 2;
48483 + } else {
48484 + err = kgdb_register_io_module(&kgdboc_io_ops);
48485 + configured = 1;
48486 + }
48487 if (err)
48488 goto noconfig;
48489
48490 @@ -205,8 +214,6 @@ do_register:
48491 if (err)
48492 goto nmi_con_failed;
48493
48494 - configured = 1;
48495 -
48496 return 0;
48497
48498 nmi_con_failed:
48499 @@ -223,7 +230,7 @@ noconfig:
48500 static int __init init_kgdboc(void)
48501 {
48502 /* Already configured? */
48503 - if (configured == 1)
48504 + if (configured >= 1)
48505 return 0;
48506
48507 return configure_kgdboc();
48508 @@ -272,7 +279,7 @@ static int param_set_kgdboc_var(const char *kmessage, struct kernel_param *kp)
48509 if (config[len - 1] == '\n')
48510 config[len - 1] = '\0';
48511
48512 - if (configured == 1)
48513 + if (configured >= 1)
48514 cleanup_kgdboc();
48515
48516 /* Go and configure with the new params. */
48517 @@ -312,6 +319,15 @@ static struct kgdb_io kgdboc_io_ops = {
48518 .post_exception = kgdboc_post_exp_handler,
48519 };
48520
48521 +static struct kgdb_io kgdboc_io_ops_console = {
48522 + .name = "kgdboc",
48523 + .read_char = kgdboc_get_char,
48524 + .write_char = kgdboc_put_char,
48525 + .pre_exception = kgdboc_pre_exp_handler,
48526 + .post_exception = kgdboc_post_exp_handler,
48527 + .is_console = 1
48528 +};
48529 +
48530 #ifdef CONFIG_KGDB_SERIAL_CONSOLE
48531 /* This is only available if kgdboc is a built in for early debugging */
48532 static int __init kgdboc_early_init(char *opt)
48533 diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
48534 index b5d779c..3622cfe 100644
48535 --- a/drivers/tty/serial/msm_serial.c
48536 +++ b/drivers/tty/serial/msm_serial.c
48537 @@ -897,7 +897,7 @@ static struct uart_driver msm_uart_driver = {
48538 .cons = MSM_CONSOLE,
48539 };
48540
48541 -static atomic_t msm_uart_next_id = ATOMIC_INIT(0);
48542 +static atomic_unchecked_t msm_uart_next_id = ATOMIC_INIT(0);
48543
48544 static const struct of_device_id msm_uartdm_table[] = {
48545 { .compatible = "qcom,msm-uartdm" },
48546 @@ -912,7 +912,7 @@ static int __init msm_serial_probe(struct platform_device *pdev)
48547 int irq;
48548
48549 if (pdev->id == -1)
48550 - pdev->id = atomic_inc_return(&msm_uart_next_id) - 1;
48551 + pdev->id = atomic_inc_return_unchecked(&msm_uart_next_id) - 1;
48552
48553 if (unlikely(pdev->id < 0 || pdev->id >= UART_NR))
48554 return -ENXIO;
48555 diff --git a/drivers/tty/serial/samsung.c b/drivers/tty/serial/samsung.c
48556 index f3dfa19..342f2ff 100644
48557 --- a/drivers/tty/serial/samsung.c
48558 +++ b/drivers/tty/serial/samsung.c
48559 @@ -456,11 +456,16 @@ static void s3c24xx_serial_shutdown(struct uart_port *port)
48560 }
48561 }
48562
48563 +static int s3c64xx_serial_startup(struct uart_port *port);
48564 static int s3c24xx_serial_startup(struct uart_port *port)
48565 {
48566 struct s3c24xx_uart_port *ourport = to_ourport(port);
48567 int ret;
48568
48569 + /* Startup sequence is different for s3c64xx and higher SoC's */
48570 + if (s3c24xx_serial_has_interrupt_mask(port))
48571 + return s3c64xx_serial_startup(port);
48572 +
48573 dbg("s3c24xx_serial_startup: port=%p (%08lx,%p)\n",
48574 port->mapbase, port->membase);
48575
48576 @@ -1127,10 +1132,6 @@ static int s3c24xx_serial_init_port(struct s3c24xx_uart_port *ourport,
48577 /* setup info for port */
48578 port->dev = &platdev->dev;
48579
48580 - /* Startup sequence is different for s3c64xx and higher SoC's */
48581 - if (s3c24xx_serial_has_interrupt_mask(port))
48582 - s3c24xx_serial_ops.startup = s3c64xx_serial_startup;
48583 -
48584 port->uartclk = 1;
48585
48586 if (cfg->uart_flags & UPF_CONS_FLOW) {
48587 diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
48588 index 0f02351..07c59c5 100644
48589 --- a/drivers/tty/serial/serial_core.c
48590 +++ b/drivers/tty/serial/serial_core.c
48591 @@ -1448,7 +1448,7 @@ static void uart_hangup(struct tty_struct *tty)
48592 uart_flush_buffer(tty);
48593 uart_shutdown(tty, state);
48594 spin_lock_irqsave(&port->lock, flags);
48595 - port->count = 0;
48596 + atomic_set(&port->count, 0);
48597 clear_bit(ASYNCB_NORMAL_ACTIVE, &port->flags);
48598 spin_unlock_irqrestore(&port->lock, flags);
48599 tty_port_tty_set(port, NULL);
48600 @@ -1544,7 +1544,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48601 goto end;
48602 }
48603
48604 - port->count++;
48605 + atomic_inc(&port->count);
48606 if (!state->uart_port || state->uart_port->flags & UPF_DEAD) {
48607 retval = -ENXIO;
48608 goto err_dec_count;
48609 @@ -1572,7 +1572,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48610 /*
48611 * Make sure the device is in D0 state.
48612 */
48613 - if (port->count == 1)
48614 + if (atomic_read(&port->count) == 1)
48615 uart_change_pm(state, UART_PM_STATE_ON);
48616
48617 /*
48618 @@ -1590,7 +1590,7 @@ static int uart_open(struct tty_struct *tty, struct file *filp)
48619 end:
48620 return retval;
48621 err_dec_count:
48622 - port->count--;
48623 + atomic_inc(&port->count);
48624 mutex_unlock(&port->mutex);
48625 goto end;
48626 }
48627 diff --git a/drivers/tty/synclink.c b/drivers/tty/synclink.c
48628 index e1ce141..6d4ed80 100644
48629 --- a/drivers/tty/synclink.c
48630 +++ b/drivers/tty/synclink.c
48631 @@ -3090,7 +3090,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48632
48633 if (debug_level >= DEBUG_LEVEL_INFO)
48634 printk("%s(%d):mgsl_close(%s) entry, count=%d\n",
48635 - __FILE__,__LINE__, info->device_name, info->port.count);
48636 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48637
48638 if (tty_port_close_start(&info->port, tty, filp) == 0)
48639 goto cleanup;
48640 @@ -3108,7 +3108,7 @@ static void mgsl_close(struct tty_struct *tty, struct file * filp)
48641 cleanup:
48642 if (debug_level >= DEBUG_LEVEL_INFO)
48643 printk("%s(%d):mgsl_close(%s) exit, count=%d\n", __FILE__,__LINE__,
48644 - tty->driver->name, info->port.count);
48645 + tty->driver->name, atomic_read(&info->port.count));
48646
48647 } /* end of mgsl_close() */
48648
48649 @@ -3207,8 +3207,8 @@ static void mgsl_hangup(struct tty_struct *tty)
48650
48651 mgsl_flush_buffer(tty);
48652 shutdown(info);
48653 -
48654 - info->port.count = 0;
48655 +
48656 + atomic_set(&info->port.count, 0);
48657 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48658 info->port.tty = NULL;
48659
48660 @@ -3297,12 +3297,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48661
48662 if (debug_level >= DEBUG_LEVEL_INFO)
48663 printk("%s(%d):block_til_ready before block on %s count=%d\n",
48664 - __FILE__,__LINE__, tty->driver->name, port->count );
48665 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48666
48667 spin_lock_irqsave(&info->irq_spinlock, flags);
48668 if (!tty_hung_up_p(filp)) {
48669 extra_count = true;
48670 - port->count--;
48671 + atomic_dec(&port->count);
48672 }
48673 spin_unlock_irqrestore(&info->irq_spinlock, flags);
48674 port->blocked_open++;
48675 @@ -3331,7 +3331,7 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48676
48677 if (debug_level >= DEBUG_LEVEL_INFO)
48678 printk("%s(%d):block_til_ready blocking on %s count=%d\n",
48679 - __FILE__,__LINE__, tty->driver->name, port->count );
48680 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48681
48682 tty_unlock(tty);
48683 schedule();
48684 @@ -3343,12 +3343,12 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
48685
48686 /* FIXME: Racy on hangup during close wait */
48687 if (extra_count)
48688 - port->count++;
48689 + atomic_inc(&port->count);
48690 port->blocked_open--;
48691
48692 if (debug_level >= DEBUG_LEVEL_INFO)
48693 printk("%s(%d):block_til_ready after blocking on %s count=%d\n",
48694 - __FILE__,__LINE__, tty->driver->name, port->count );
48695 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48696
48697 if (!retval)
48698 port->flags |= ASYNC_NORMAL_ACTIVE;
48699 @@ -3400,7 +3400,7 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48700
48701 if (debug_level >= DEBUG_LEVEL_INFO)
48702 printk("%s(%d):mgsl_open(%s), old ref count = %d\n",
48703 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48704 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48705
48706 /* If port is closing, signal caller to try again */
48707 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48708 @@ -3419,10 +3419,10 @@ static int mgsl_open(struct tty_struct *tty, struct file * filp)
48709 spin_unlock_irqrestore(&info->netlock, flags);
48710 goto cleanup;
48711 }
48712 - info->port.count++;
48713 + atomic_inc(&info->port.count);
48714 spin_unlock_irqrestore(&info->netlock, flags);
48715
48716 - if (info->port.count == 1) {
48717 + if (atomic_read(&info->port.count) == 1) {
48718 /* 1st open on this device, init hardware */
48719 retval = startup(info);
48720 if (retval < 0)
48721 @@ -3446,8 +3446,8 @@ cleanup:
48722 if (retval) {
48723 if (tty->count == 1)
48724 info->port.tty = NULL; /* tty layer will release tty struct */
48725 - if(info->port.count)
48726 - info->port.count--;
48727 + if (atomic_read(&info->port.count))
48728 + atomic_dec(&info->port.count);
48729 }
48730
48731 return retval;
48732 @@ -7665,7 +7665,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48733 unsigned short new_crctype;
48734
48735 /* return error if TTY interface open */
48736 - if (info->port.count)
48737 + if (atomic_read(&info->port.count))
48738 return -EBUSY;
48739
48740 switch (encoding)
48741 @@ -7760,7 +7760,7 @@ static int hdlcdev_open(struct net_device *dev)
48742
48743 /* arbitrate between network and tty opens */
48744 spin_lock_irqsave(&info->netlock, flags);
48745 - if (info->port.count != 0 || info->netcount != 0) {
48746 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48747 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48748 spin_unlock_irqrestore(&info->netlock, flags);
48749 return -EBUSY;
48750 @@ -7846,7 +7846,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48751 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48752
48753 /* return error if TTY interface open */
48754 - if (info->port.count)
48755 + if (atomic_read(&info->port.count))
48756 return -EBUSY;
48757
48758 if (cmd != SIOCWANDEV)
48759 diff --git a/drivers/tty/synclink_gt.c b/drivers/tty/synclink_gt.c
48760 index 1abf946..1ee34fc 100644
48761 --- a/drivers/tty/synclink_gt.c
48762 +++ b/drivers/tty/synclink_gt.c
48763 @@ -670,7 +670,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48764 tty->driver_data = info;
48765 info->port.tty = tty;
48766
48767 - DBGINFO(("%s open, old ref count = %d\n", info->device_name, info->port.count));
48768 + DBGINFO(("%s open, old ref count = %d\n", info->device_name, atomic_read(&info->port.count)));
48769
48770 /* If port is closing, signal caller to try again */
48771 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48772 @@ -691,10 +691,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48773 mutex_unlock(&info->port.mutex);
48774 goto cleanup;
48775 }
48776 - info->port.count++;
48777 + atomic_inc(&info->port.count);
48778 spin_unlock_irqrestore(&info->netlock, flags);
48779
48780 - if (info->port.count == 1) {
48781 + if (atomic_read(&info->port.count) == 1) {
48782 /* 1st open on this device, init hardware */
48783 retval = startup(info);
48784 if (retval < 0) {
48785 @@ -715,8 +715,8 @@ cleanup:
48786 if (retval) {
48787 if (tty->count == 1)
48788 info->port.tty = NULL; /* tty layer will release tty struct */
48789 - if(info->port.count)
48790 - info->port.count--;
48791 + if(atomic_read(&info->port.count))
48792 + atomic_dec(&info->port.count);
48793 }
48794
48795 DBGINFO(("%s open rc=%d\n", info->device_name, retval));
48796 @@ -729,7 +729,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48797
48798 if (sanity_check(info, tty->name, "close"))
48799 return;
48800 - DBGINFO(("%s close entry, count=%d\n", info->device_name, info->port.count));
48801 + DBGINFO(("%s close entry, count=%d\n", info->device_name, atomic_read(&info->port.count)));
48802
48803 if (tty_port_close_start(&info->port, tty, filp) == 0)
48804 goto cleanup;
48805 @@ -746,7 +746,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48806 tty_port_close_end(&info->port, tty);
48807 info->port.tty = NULL;
48808 cleanup:
48809 - DBGINFO(("%s close exit, count=%d\n", tty->driver->name, info->port.count));
48810 + DBGINFO(("%s close exit, count=%d\n", tty->driver->name, atomic_read(&info->port.count)));
48811 }
48812
48813 static void hangup(struct tty_struct *tty)
48814 @@ -764,7 +764,7 @@ static void hangup(struct tty_struct *tty)
48815 shutdown(info);
48816
48817 spin_lock_irqsave(&info->port.lock, flags);
48818 - info->port.count = 0;
48819 + atomic_set(&info->port.count, 0);
48820 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48821 info->port.tty = NULL;
48822 spin_unlock_irqrestore(&info->port.lock, flags);
48823 @@ -1449,7 +1449,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48824 unsigned short new_crctype;
48825
48826 /* return error if TTY interface open */
48827 - if (info->port.count)
48828 + if (atomic_read(&info->port.count))
48829 return -EBUSY;
48830
48831 DBGINFO(("%s hdlcdev_attach\n", info->device_name));
48832 @@ -1544,7 +1544,7 @@ static int hdlcdev_open(struct net_device *dev)
48833
48834 /* arbitrate between network and tty opens */
48835 spin_lock_irqsave(&info->netlock, flags);
48836 - if (info->port.count != 0 || info->netcount != 0) {
48837 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48838 DBGINFO(("%s hdlc_open busy\n", dev->name));
48839 spin_unlock_irqrestore(&info->netlock, flags);
48840 return -EBUSY;
48841 @@ -1629,7 +1629,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48842 DBGINFO(("%s hdlcdev_ioctl\n", dev->name));
48843
48844 /* return error if TTY interface open */
48845 - if (info->port.count)
48846 + if (atomic_read(&info->port.count))
48847 return -EBUSY;
48848
48849 if (cmd != SIOCWANDEV)
48850 @@ -2413,7 +2413,7 @@ static irqreturn_t slgt_interrupt(int dummy, void *dev_id)
48851 if (port == NULL)
48852 continue;
48853 spin_lock(&port->lock);
48854 - if ((port->port.count || port->netcount) &&
48855 + if ((atomic_read(&port->port.count) || port->netcount) &&
48856 port->pending_bh && !port->bh_running &&
48857 !port->bh_requested) {
48858 DBGISR(("%s bh queued\n", port->device_name));
48859 @@ -3302,7 +3302,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48860 spin_lock_irqsave(&info->lock, flags);
48861 if (!tty_hung_up_p(filp)) {
48862 extra_count = true;
48863 - port->count--;
48864 + atomic_dec(&port->count);
48865 }
48866 spin_unlock_irqrestore(&info->lock, flags);
48867 port->blocked_open++;
48868 @@ -3339,7 +3339,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48869 remove_wait_queue(&port->open_wait, &wait);
48870
48871 if (extra_count)
48872 - port->count++;
48873 + atomic_inc(&port->count);
48874 port->blocked_open--;
48875
48876 if (!retval)
48877 diff --git a/drivers/tty/synclinkmp.c b/drivers/tty/synclinkmp.c
48878 index dc6e969..5dc8786 100644
48879 --- a/drivers/tty/synclinkmp.c
48880 +++ b/drivers/tty/synclinkmp.c
48881 @@ -750,7 +750,7 @@ static int open(struct tty_struct *tty, struct file *filp)
48882
48883 if (debug_level >= DEBUG_LEVEL_INFO)
48884 printk("%s(%d):%s open(), old ref count = %d\n",
48885 - __FILE__,__LINE__,tty->driver->name, info->port.count);
48886 + __FILE__,__LINE__,tty->driver->name, atomic_read(&info->port.count));
48887
48888 /* If port is closing, signal caller to try again */
48889 if (tty_hung_up_p(filp) || info->port.flags & ASYNC_CLOSING){
48890 @@ -769,10 +769,10 @@ static int open(struct tty_struct *tty, struct file *filp)
48891 spin_unlock_irqrestore(&info->netlock, flags);
48892 goto cleanup;
48893 }
48894 - info->port.count++;
48895 + atomic_inc(&info->port.count);
48896 spin_unlock_irqrestore(&info->netlock, flags);
48897
48898 - if (info->port.count == 1) {
48899 + if (atomic_read(&info->port.count) == 1) {
48900 /* 1st open on this device, init hardware */
48901 retval = startup(info);
48902 if (retval < 0)
48903 @@ -796,8 +796,8 @@ cleanup:
48904 if (retval) {
48905 if (tty->count == 1)
48906 info->port.tty = NULL; /* tty layer will release tty struct */
48907 - if(info->port.count)
48908 - info->port.count--;
48909 + if(atomic_read(&info->port.count))
48910 + atomic_dec(&info->port.count);
48911 }
48912
48913 return retval;
48914 @@ -815,7 +815,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48915
48916 if (debug_level >= DEBUG_LEVEL_INFO)
48917 printk("%s(%d):%s close() entry, count=%d\n",
48918 - __FILE__,__LINE__, info->device_name, info->port.count);
48919 + __FILE__,__LINE__, info->device_name, atomic_read(&info->port.count));
48920
48921 if (tty_port_close_start(&info->port, tty, filp) == 0)
48922 goto cleanup;
48923 @@ -834,7 +834,7 @@ static void close(struct tty_struct *tty, struct file *filp)
48924 cleanup:
48925 if (debug_level >= DEBUG_LEVEL_INFO)
48926 printk("%s(%d):%s close() exit, count=%d\n", __FILE__,__LINE__,
48927 - tty->driver->name, info->port.count);
48928 + tty->driver->name, atomic_read(&info->port.count));
48929 }
48930
48931 /* Called by tty_hangup() when a hangup is signaled.
48932 @@ -857,7 +857,7 @@ static void hangup(struct tty_struct *tty)
48933 shutdown(info);
48934
48935 spin_lock_irqsave(&info->port.lock, flags);
48936 - info->port.count = 0;
48937 + atomic_set(&info->port.count, 0);
48938 info->port.flags &= ~ASYNC_NORMAL_ACTIVE;
48939 info->port.tty = NULL;
48940 spin_unlock_irqrestore(&info->port.lock, flags);
48941 @@ -1565,7 +1565,7 @@ static int hdlcdev_attach(struct net_device *dev, unsigned short encoding,
48942 unsigned short new_crctype;
48943
48944 /* return error if TTY interface open */
48945 - if (info->port.count)
48946 + if (atomic_read(&info->port.count))
48947 return -EBUSY;
48948
48949 switch (encoding)
48950 @@ -1660,7 +1660,7 @@ static int hdlcdev_open(struct net_device *dev)
48951
48952 /* arbitrate between network and tty opens */
48953 spin_lock_irqsave(&info->netlock, flags);
48954 - if (info->port.count != 0 || info->netcount != 0) {
48955 + if (atomic_read(&info->port.count) != 0 || info->netcount != 0) {
48956 printk(KERN_WARNING "%s: hdlc_open returning busy\n", dev->name);
48957 spin_unlock_irqrestore(&info->netlock, flags);
48958 return -EBUSY;
48959 @@ -1746,7 +1746,7 @@ static int hdlcdev_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
48960 printk("%s:hdlcdev_ioctl(%s)\n",__FILE__,dev->name);
48961
48962 /* return error if TTY interface open */
48963 - if (info->port.count)
48964 + if (atomic_read(&info->port.count))
48965 return -EBUSY;
48966
48967 if (cmd != SIOCWANDEV)
48968 @@ -2620,7 +2620,7 @@ static irqreturn_t synclinkmp_interrupt(int dummy, void *dev_id)
48969 * do not request bottom half processing if the
48970 * device is not open in a normal mode.
48971 */
48972 - if ( port && (port->port.count || port->netcount) &&
48973 + if ( port && (atomic_read(&port->port.count) || port->netcount) &&
48974 port->pending_bh && !port->bh_running &&
48975 !port->bh_requested ) {
48976 if ( debug_level >= DEBUG_LEVEL_ISR )
48977 @@ -3318,12 +3318,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48978
48979 if (debug_level >= DEBUG_LEVEL_INFO)
48980 printk("%s(%d):%s block_til_ready() before block, count=%d\n",
48981 - __FILE__,__LINE__, tty->driver->name, port->count );
48982 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48983
48984 spin_lock_irqsave(&info->lock, flags);
48985 if (!tty_hung_up_p(filp)) {
48986 extra_count = true;
48987 - port->count--;
48988 + atomic_dec(&port->count);
48989 }
48990 spin_unlock_irqrestore(&info->lock, flags);
48991 port->blocked_open++;
48992 @@ -3352,7 +3352,7 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
48993
48994 if (debug_level >= DEBUG_LEVEL_INFO)
48995 printk("%s(%d):%s block_til_ready() count=%d\n",
48996 - __FILE__,__LINE__, tty->driver->name, port->count );
48997 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
48998
48999 tty_unlock(tty);
49000 schedule();
49001 @@ -3363,12 +3363,12 @@ static int block_til_ready(struct tty_struct *tty, struct file *filp,
49002 remove_wait_queue(&port->open_wait, &wait);
49003
49004 if (extra_count)
49005 - port->count++;
49006 + atomic_inc(&port->count);
49007 port->blocked_open--;
49008
49009 if (debug_level >= DEBUG_LEVEL_INFO)
49010 printk("%s(%d):%s block_til_ready() after, count=%d\n",
49011 - __FILE__,__LINE__, tty->driver->name, port->count );
49012 + __FILE__,__LINE__, tty->driver->name, atomic_read(&port->count));
49013
49014 if (!retval)
49015 port->flags |= ASYNC_NORMAL_ACTIVE;
49016 diff --git a/drivers/tty/sysrq.c b/drivers/tty/sysrq.c
49017 index 40a9fe9..a3f10cc 100644
49018 --- a/drivers/tty/sysrq.c
49019 +++ b/drivers/tty/sysrq.c
49020 @@ -1075,7 +1075,7 @@ EXPORT_SYMBOL(unregister_sysrq_key);
49021 static ssize_t write_sysrq_trigger(struct file *file, const char __user *buf,
49022 size_t count, loff_t *ppos)
49023 {
49024 - if (count) {
49025 + if (count && capable(CAP_SYS_ADMIN)) {
49026 char c;
49027
49028 if (get_user(c, buf))
49029 diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
49030 index c74a00a..02cf211a 100644
49031 --- a/drivers/tty/tty_io.c
49032 +++ b/drivers/tty/tty_io.c
49033 @@ -3474,7 +3474,7 @@ EXPORT_SYMBOL_GPL(get_current_tty);
49034
49035 void tty_default_fops(struct file_operations *fops)
49036 {
49037 - *fops = tty_fops;
49038 + memcpy((void *)fops, &tty_fops, sizeof(tty_fops));
49039 }
49040
49041 /*
49042 diff --git a/drivers/tty/tty_ldisc.c b/drivers/tty/tty_ldisc.c
49043 index 6458e11..6cfc218 100644
49044 --- a/drivers/tty/tty_ldisc.c
49045 +++ b/drivers/tty/tty_ldisc.c
49046 @@ -72,7 +72,7 @@ int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc)
49047 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49048 tty_ldiscs[disc] = new_ldisc;
49049 new_ldisc->num = disc;
49050 - new_ldisc->refcount = 0;
49051 + atomic_set(&new_ldisc->refcount, 0);
49052 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
49053
49054 return ret;
49055 @@ -100,7 +100,7 @@ int tty_unregister_ldisc(int disc)
49056 return -EINVAL;
49057
49058 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49059 - if (tty_ldiscs[disc]->refcount)
49060 + if (atomic_read(&tty_ldiscs[disc]->refcount))
49061 ret = -EBUSY;
49062 else
49063 tty_ldiscs[disc] = NULL;
49064 @@ -121,7 +121,7 @@ static struct tty_ldisc_ops *get_ldops(int disc)
49065 if (ldops) {
49066 ret = ERR_PTR(-EAGAIN);
49067 if (try_module_get(ldops->owner)) {
49068 - ldops->refcount++;
49069 + atomic_inc(&ldops->refcount);
49070 ret = ldops;
49071 }
49072 }
49073 @@ -134,7 +134,7 @@ static void put_ldops(struct tty_ldisc_ops *ldops)
49074 unsigned long flags;
49075
49076 raw_spin_lock_irqsave(&tty_ldiscs_lock, flags);
49077 - ldops->refcount--;
49078 + atomic_dec(&ldops->refcount);
49079 module_put(ldops->owner);
49080 raw_spin_unlock_irqrestore(&tty_ldiscs_lock, flags);
49081 }
49082 diff --git a/drivers/tty/tty_port.c b/drivers/tty/tty_port.c
49083 index f597e88..b7f68ed 100644
49084 --- a/drivers/tty/tty_port.c
49085 +++ b/drivers/tty/tty_port.c
49086 @@ -232,7 +232,7 @@ void tty_port_hangup(struct tty_port *port)
49087 unsigned long flags;
49088
49089 spin_lock_irqsave(&port->lock, flags);
49090 - port->count = 0;
49091 + atomic_set(&port->count, 0);
49092 port->flags &= ~ASYNC_NORMAL_ACTIVE;
49093 tty = port->tty;
49094 if (tty)
49095 @@ -390,7 +390,7 @@ int tty_port_block_til_ready(struct tty_port *port,
49096 /* The port lock protects the port counts */
49097 spin_lock_irqsave(&port->lock, flags);
49098 if (!tty_hung_up_p(filp))
49099 - port->count--;
49100 + atomic_dec(&port->count);
49101 port->blocked_open++;
49102 spin_unlock_irqrestore(&port->lock, flags);
49103
49104 @@ -432,7 +432,7 @@ int tty_port_block_til_ready(struct tty_port *port,
49105 we must not mess that up further */
49106 spin_lock_irqsave(&port->lock, flags);
49107 if (!tty_hung_up_p(filp))
49108 - port->count++;
49109 + atomic_inc(&port->count);
49110 port->blocked_open--;
49111 if (retval == 0)
49112 port->flags |= ASYNC_NORMAL_ACTIVE;
49113 @@ -466,19 +466,19 @@ int tty_port_close_start(struct tty_port *port,
49114 return 0;
49115 }
49116
49117 - if (tty->count == 1 && port->count != 1) {
49118 + if (tty->count == 1 && atomic_read(&port->count) != 1) {
49119 printk(KERN_WARNING
49120 "tty_port_close_start: tty->count = 1 port count = %d.\n",
49121 - port->count);
49122 - port->count = 1;
49123 + atomic_read(&port->count));
49124 + atomic_set(&port->count, 1);
49125 }
49126 - if (--port->count < 0) {
49127 + if (atomic_dec_return(&port->count) < 0) {
49128 printk(KERN_WARNING "tty_port_close_start: count = %d\n",
49129 - port->count);
49130 - port->count = 0;
49131 + atomic_read(&port->count));
49132 + atomic_set(&port->count, 0);
49133 }
49134
49135 - if (port->count) {
49136 + if (atomic_read(&port->count)) {
49137 spin_unlock_irqrestore(&port->lock, flags);
49138 if (port->ops->drop)
49139 port->ops->drop(port);
49140 @@ -564,7 +564,7 @@ int tty_port_open(struct tty_port *port, struct tty_struct *tty,
49141 {
49142 spin_lock_irq(&port->lock);
49143 if (!tty_hung_up_p(filp))
49144 - ++port->count;
49145 + atomic_inc(&port->count);
49146 spin_unlock_irq(&port->lock);
49147 tty_port_tty_set(port, tty);
49148
49149 diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c
49150 index d0e3a44..5f8b754 100644
49151 --- a/drivers/tty/vt/keyboard.c
49152 +++ b/drivers/tty/vt/keyboard.c
49153 @@ -641,6 +641,16 @@ static void k_spec(struct vc_data *vc, unsigned char value, char up_flag)
49154 kbd->kbdmode == VC_OFF) &&
49155 value != KVAL(K_SAK))
49156 return; /* SAK is allowed even in raw mode */
49157 +
49158 +#if defined(CONFIG_GRKERNSEC_PROC) || defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
49159 + {
49160 + void *func = fn_handler[value];
49161 + if (func == fn_show_state || func == fn_show_ptregs ||
49162 + func == fn_show_mem)
49163 + return;
49164 + }
49165 +#endif
49166 +
49167 fn_handler[value](vc);
49168 }
49169
49170 @@ -1776,9 +1786,6 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49171 if (copy_from_user(&tmp, user_kbe, sizeof(struct kbentry)))
49172 return -EFAULT;
49173
49174 - if (!capable(CAP_SYS_TTY_CONFIG))
49175 - perm = 0;
49176 -
49177 switch (cmd) {
49178 case KDGKBENT:
49179 /* Ensure another thread doesn't free it under us */
49180 @@ -1793,6 +1800,9 @@ int vt_do_kdsk_ioctl(int cmd, struct kbentry __user *user_kbe, int perm,
49181 spin_unlock_irqrestore(&kbd_event_lock, flags);
49182 return put_user(val, &user_kbe->kb_value);
49183 case KDSKBENT:
49184 + if (!capable(CAP_SYS_TTY_CONFIG))
49185 + perm = 0;
49186 +
49187 if (!perm)
49188 return -EPERM;
49189 if (!i && v == K_NOSUCHMAP) {
49190 @@ -1883,9 +1893,6 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49191 int i, j, k;
49192 int ret;
49193
49194 - if (!capable(CAP_SYS_TTY_CONFIG))
49195 - perm = 0;
49196 -
49197 kbs = kmalloc(sizeof(*kbs), GFP_KERNEL);
49198 if (!kbs) {
49199 ret = -ENOMEM;
49200 @@ -1919,6 +1926,9 @@ int vt_do_kdgkb_ioctl(int cmd, struct kbsentry __user *user_kdgkb, int perm)
49201 kfree(kbs);
49202 return ((p && *p) ? -EOVERFLOW : 0);
49203 case KDSKBSENT:
49204 + if (!capable(CAP_SYS_TTY_CONFIG))
49205 + perm = 0;
49206 +
49207 if (!perm) {
49208 ret = -EPERM;
49209 goto reterr;
49210 diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
49211 index 0e808cf..d7d274b 100644
49212 --- a/drivers/uio/uio.c
49213 +++ b/drivers/uio/uio.c
49214 @@ -25,6 +25,7 @@
49215 #include <linux/kobject.h>
49216 #include <linux/cdev.h>
49217 #include <linux/uio_driver.h>
49218 +#include <asm/local.h>
49219
49220 #define UIO_MAX_DEVICES (1U << MINORBITS)
49221
49222 @@ -32,7 +33,7 @@ struct uio_device {
49223 struct module *owner;
49224 struct device *dev;
49225 int minor;
49226 - atomic_t event;
49227 + atomic_unchecked_t event;
49228 struct fasync_struct *async_queue;
49229 wait_queue_head_t wait;
49230 struct uio_info *info;
49231 @@ -243,7 +244,7 @@ static ssize_t event_show(struct device *dev,
49232 struct device_attribute *attr, char *buf)
49233 {
49234 struct uio_device *idev = dev_get_drvdata(dev);
49235 - return sprintf(buf, "%u\n", (unsigned int)atomic_read(&idev->event));
49236 + return sprintf(buf, "%u\n", (unsigned int)atomic_read_unchecked(&idev->event));
49237 }
49238 static DEVICE_ATTR_RO(event);
49239
49240 @@ -401,7 +402,7 @@ void uio_event_notify(struct uio_info *info)
49241 {
49242 struct uio_device *idev = info->uio_dev;
49243
49244 - atomic_inc(&idev->event);
49245 + atomic_inc_unchecked(&idev->event);
49246 wake_up_interruptible(&idev->wait);
49247 kill_fasync(&idev->async_queue, SIGIO, POLL_IN);
49248 }
49249 @@ -454,7 +455,7 @@ static int uio_open(struct inode *inode, struct file *filep)
49250 }
49251
49252 listener->dev = idev;
49253 - listener->event_count = atomic_read(&idev->event);
49254 + listener->event_count = atomic_read_unchecked(&idev->event);
49255 filep->private_data = listener;
49256
49257 if (idev->info->open) {
49258 @@ -505,7 +506,7 @@ static unsigned int uio_poll(struct file *filep, poll_table *wait)
49259 return -EIO;
49260
49261 poll_wait(filep, &idev->wait, wait);
49262 - if (listener->event_count != atomic_read(&idev->event))
49263 + if (listener->event_count != atomic_read_unchecked(&idev->event))
49264 return POLLIN | POLLRDNORM;
49265 return 0;
49266 }
49267 @@ -530,7 +531,7 @@ static ssize_t uio_read(struct file *filep, char __user *buf,
49268 do {
49269 set_current_state(TASK_INTERRUPTIBLE);
49270
49271 - event_count = atomic_read(&idev->event);
49272 + event_count = atomic_read_unchecked(&idev->event);
49273 if (event_count != listener->event_count) {
49274 if (copy_to_user(buf, &event_count, count))
49275 retval = -EFAULT;
49276 @@ -587,9 +588,13 @@ static ssize_t uio_write(struct file *filep, const char __user *buf,
49277 static int uio_find_mem_index(struct vm_area_struct *vma)
49278 {
49279 struct uio_device *idev = vma->vm_private_data;
49280 + unsigned long size;
49281
49282 if (vma->vm_pgoff < MAX_UIO_MAPS) {
49283 - if (idev->info->mem[vma->vm_pgoff].size == 0)
49284 + size = idev->info->mem[vma->vm_pgoff].size;
49285 + if (size == 0)
49286 + return -1;
49287 + if (vma->vm_end - vma->vm_start > size)
49288 return -1;
49289 return (int)vma->vm_pgoff;
49290 }
49291 @@ -647,6 +652,8 @@ static int uio_mmap_physical(struct vm_area_struct *vma)
49292 return -EINVAL;
49293 mem = idev->info->mem + mi;
49294
49295 + if (mem->addr & ~PAGE_MASK)
49296 + return -ENODEV;
49297 if (vma->vm_end - vma->vm_start > mem->size)
49298 return -EINVAL;
49299
49300 @@ -818,7 +825,7 @@ int __uio_register_device(struct module *owner,
49301 idev->owner = owner;
49302 idev->info = info;
49303 init_waitqueue_head(&idev->wait);
49304 - atomic_set(&idev->event, 0);
49305 + atomic_set_unchecked(&idev->event, 0);
49306
49307 ret = uio_get_minor(idev);
49308 if (ret)
49309 diff --git a/drivers/usb/atm/cxacru.c b/drivers/usb/atm/cxacru.c
49310 index 8a7eb77..c00402f 100644
49311 --- a/drivers/usb/atm/cxacru.c
49312 +++ b/drivers/usb/atm/cxacru.c
49313 @@ -473,7 +473,7 @@ static ssize_t cxacru_sysfs_store_adsl_config(struct device *dev,
49314 ret = sscanf(buf + pos, "%x=%x%n", &index, &value, &tmp);
49315 if (ret < 2)
49316 return -EINVAL;
49317 - if (index < 0 || index > 0x7f)
49318 + if (index > 0x7f)
49319 return -EINVAL;
49320 pos += tmp;
49321
49322 diff --git a/drivers/usb/atm/usbatm.c b/drivers/usb/atm/usbatm.c
49323 index 25a7bfc..57f3cf5 100644
49324 --- a/drivers/usb/atm/usbatm.c
49325 +++ b/drivers/usb/atm/usbatm.c
49326 @@ -331,7 +331,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49327 if (printk_ratelimit())
49328 atm_warn(instance, "%s: OAM not supported (vpi %d, vci %d)!\n",
49329 __func__, vpi, vci);
49330 - atomic_inc(&vcc->stats->rx_err);
49331 + atomic_inc_unchecked(&vcc->stats->rx_err);
49332 return;
49333 }
49334
49335 @@ -358,7 +358,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49336 if (length > ATM_MAX_AAL5_PDU) {
49337 atm_rldbg(instance, "%s: bogus length %u (vcc: 0x%p)!\n",
49338 __func__, length, vcc);
49339 - atomic_inc(&vcc->stats->rx_err);
49340 + atomic_inc_unchecked(&vcc->stats->rx_err);
49341 goto out;
49342 }
49343
49344 @@ -367,14 +367,14 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49345 if (sarb->len < pdu_length) {
49346 atm_rldbg(instance, "%s: bogus pdu_length %u (sarb->len: %u, vcc: 0x%p)!\n",
49347 __func__, pdu_length, sarb->len, vcc);
49348 - atomic_inc(&vcc->stats->rx_err);
49349 + atomic_inc_unchecked(&vcc->stats->rx_err);
49350 goto out;
49351 }
49352
49353 if (crc32_be(~0, skb_tail_pointer(sarb) - pdu_length, pdu_length) != 0xc704dd7b) {
49354 atm_rldbg(instance, "%s: packet failed crc check (vcc: 0x%p)!\n",
49355 __func__, vcc);
49356 - atomic_inc(&vcc->stats->rx_err);
49357 + atomic_inc_unchecked(&vcc->stats->rx_err);
49358 goto out;
49359 }
49360
49361 @@ -386,7 +386,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49362 if (printk_ratelimit())
49363 atm_err(instance, "%s: no memory for skb (length: %u)!\n",
49364 __func__, length);
49365 - atomic_inc(&vcc->stats->rx_drop);
49366 + atomic_inc_unchecked(&vcc->stats->rx_drop);
49367 goto out;
49368 }
49369
49370 @@ -414,7 +414,7 @@ static void usbatm_extract_one_cell(struct usbatm_data *instance, unsigned char
49371
49372 vcc->push(vcc, skb);
49373
49374 - atomic_inc(&vcc->stats->rx);
49375 + atomic_inc_unchecked(&vcc->stats->rx);
49376 out:
49377 skb_trim(sarb, 0);
49378 }
49379 @@ -612,7 +612,7 @@ static void usbatm_tx_process(unsigned long data)
49380 struct atm_vcc *vcc = UDSL_SKB(skb)->atm.vcc;
49381
49382 usbatm_pop(vcc, skb);
49383 - atomic_inc(&vcc->stats->tx);
49384 + atomic_inc_unchecked(&vcc->stats->tx);
49385
49386 skb = skb_dequeue(&instance->sndqueue);
49387 }
49388 @@ -756,11 +756,11 @@ static int usbatm_atm_proc_read(struct atm_dev *atm_dev, loff_t * pos, char *pag
49389 if (!left--)
49390 return sprintf(page,
49391 "AAL5: tx %d ( %d err ), rx %d ( %d err, %d drop )\n",
49392 - atomic_read(&atm_dev->stats.aal5.tx),
49393 - atomic_read(&atm_dev->stats.aal5.tx_err),
49394 - atomic_read(&atm_dev->stats.aal5.rx),
49395 - atomic_read(&atm_dev->stats.aal5.rx_err),
49396 - atomic_read(&atm_dev->stats.aal5.rx_drop));
49397 + atomic_read_unchecked(&atm_dev->stats.aal5.tx),
49398 + atomic_read_unchecked(&atm_dev->stats.aal5.tx_err),
49399 + atomic_read_unchecked(&atm_dev->stats.aal5.rx),
49400 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_err),
49401 + atomic_read_unchecked(&atm_dev->stats.aal5.rx_drop));
49402
49403 if (!left--) {
49404 if (instance->disconnected)
49405 diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c
49406 index 2a3bbdf..91d72cf 100644
49407 --- a/drivers/usb/core/devices.c
49408 +++ b/drivers/usb/core/devices.c
49409 @@ -126,7 +126,7 @@ static const char format_endpt[] =
49410 * time it gets called.
49411 */
49412 static struct device_connect_event {
49413 - atomic_t count;
49414 + atomic_unchecked_t count;
49415 wait_queue_head_t wait;
49416 } device_event = {
49417 .count = ATOMIC_INIT(1),
49418 @@ -164,7 +164,7 @@ static const struct class_info clas_info[] = {
49419
49420 void usbfs_conn_disc_event(void)
49421 {
49422 - atomic_add(2, &device_event.count);
49423 + atomic_add_unchecked(2, &device_event.count);
49424 wake_up(&device_event.wait);
49425 }
49426
49427 @@ -652,7 +652,7 @@ static unsigned int usb_device_poll(struct file *file,
49428
49429 poll_wait(file, &device_event.wait, wait);
49430
49431 - event_count = atomic_read(&device_event.count);
49432 + event_count = atomic_read_unchecked(&device_event.count);
49433 if (file->f_version != event_count) {
49434 file->f_version = event_count;
49435 return POLLIN | POLLRDNORM;
49436 diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c
49437 index 71dc5d7..d4c488f 100644
49438 --- a/drivers/usb/core/devio.c
49439 +++ b/drivers/usb/core/devio.c
49440 @@ -187,7 +187,7 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
49441 struct dev_state *ps = file->private_data;
49442 struct usb_device *dev = ps->dev;
49443 ssize_t ret = 0;
49444 - unsigned len;
49445 + size_t len;
49446 loff_t pos;
49447 int i;
49448
49449 @@ -229,22 +229,22 @@ static ssize_t usbdev_read(struct file *file, char __user *buf, size_t nbytes,
49450 for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
49451 struct usb_config_descriptor *config =
49452 (struct usb_config_descriptor *)dev->rawdescriptors[i];
49453 - unsigned int length = le16_to_cpu(config->wTotalLength);
49454 + size_t length = le16_to_cpu(config->wTotalLength);
49455
49456 if (*ppos < pos + length) {
49457
49458 /* The descriptor may claim to be longer than it
49459 * really is. Here is the actual allocated length. */
49460 - unsigned alloclen =
49461 + size_t alloclen =
49462 le16_to_cpu(dev->config[i].desc.wTotalLength);
49463
49464 - len = length - (*ppos - pos);
49465 + len = length + pos - *ppos;
49466 if (len > nbytes)
49467 len = nbytes;
49468
49469 /* Simply don't write (skip over) unallocated parts */
49470 if (alloclen > (*ppos - pos)) {
49471 - alloclen -= (*ppos - pos);
49472 + alloclen = alloclen + pos - *ppos;
49473 if (copy_to_user(buf,
49474 dev->rawdescriptors[i] + (*ppos - pos),
49475 min(len, alloclen))) {
49476 diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
49477 index f20a044..d1059aa 100644
49478 --- a/drivers/usb/core/hcd.c
49479 +++ b/drivers/usb/core/hcd.c
49480 @@ -1552,7 +1552,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49481 */
49482 usb_get_urb(urb);
49483 atomic_inc(&urb->use_count);
49484 - atomic_inc(&urb->dev->urbnum);
49485 + atomic_inc_unchecked(&urb->dev->urbnum);
49486 usbmon_urb_submit(&hcd->self, urb);
49487
49488 /* NOTE requirements on root-hub callers (usbfs and the hub
49489 @@ -1579,7 +1579,7 @@ int usb_hcd_submit_urb (struct urb *urb, gfp_t mem_flags)
49490 urb->hcpriv = NULL;
49491 INIT_LIST_HEAD(&urb->urb_list);
49492 atomic_dec(&urb->use_count);
49493 - atomic_dec(&urb->dev->urbnum);
49494 + atomic_dec_unchecked(&urb->dev->urbnum);
49495 if (atomic_read(&urb->reject))
49496 wake_up(&usb_kill_urb_queue);
49497 usb_put_urb(urb);
49498 diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
49499 index c5c3667..e54e5cd 100644
49500 --- a/drivers/usb/core/hub.c
49501 +++ b/drivers/usb/core/hub.c
49502 @@ -27,6 +27,7 @@
49503 #include <linux/freezer.h>
49504 #include <linux/random.h>
49505 #include <linux/pm_qos.h>
49506 +#include <linux/grsecurity.h>
49507
49508 #include <asm/uaccess.h>
49509 #include <asm/byteorder.h>
49510 @@ -4467,6 +4468,10 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
49511 goto done;
49512 return;
49513 }
49514 +
49515 + if (gr_handle_new_usb())
49516 + goto done;
49517 +
49518 if (hub_is_superspeed(hub->hdev))
49519 unit_load = 150;
49520 else
49521 diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c
49522 index 82927e1..4993dbf 100644
49523 --- a/drivers/usb/core/message.c
49524 +++ b/drivers/usb/core/message.c
49525 @@ -129,7 +129,7 @@ static int usb_internal_control_msg(struct usb_device *usb_dev,
49526 * Return: If successful, the number of bytes transferred. Otherwise, a negative
49527 * error number.
49528 */
49529 -int usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49530 +int __intentional_overflow(-1) usb_control_msg(struct usb_device *dev, unsigned int pipe, __u8 request,
49531 __u8 requesttype, __u16 value, __u16 index, void *data,
49532 __u16 size, int timeout)
49533 {
49534 @@ -181,7 +181,7 @@ EXPORT_SYMBOL_GPL(usb_control_msg);
49535 * If successful, 0. Otherwise a negative error number. The number of actual
49536 * bytes transferred will be stored in the @actual_length paramater.
49537 */
49538 -int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
49539 +int __intentional_overflow(-1) usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
49540 void *data, int len, int *actual_length, int timeout)
49541 {
49542 return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, timeout);
49543 @@ -221,7 +221,7 @@ EXPORT_SYMBOL_GPL(usb_interrupt_msg);
49544 * bytes transferred will be stored in the @actual_length paramater.
49545 *
49546 */
49547 -int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
49548 +int __intentional_overflow(-1) usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
49549 void *data, int len, int *actual_length, int timeout)
49550 {
49551 struct urb *urb;
49552 diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c
49553 index ca516ac..6c36ee4 100644
49554 --- a/drivers/usb/core/sysfs.c
49555 +++ b/drivers/usb/core/sysfs.c
49556 @@ -236,7 +236,7 @@ static ssize_t urbnum_show(struct device *dev, struct device_attribute *attr,
49557 struct usb_device *udev;
49558
49559 udev = to_usb_device(dev);
49560 - return sprintf(buf, "%d\n", atomic_read(&udev->urbnum));
49561 + return sprintf(buf, "%d\n", atomic_read_unchecked(&udev->urbnum));
49562 }
49563 static DEVICE_ATTR_RO(urbnum);
49564
49565 diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
49566 index 0a6ee2e..6f8d7e8 100644
49567 --- a/drivers/usb/core/usb.c
49568 +++ b/drivers/usb/core/usb.c
49569 @@ -433,7 +433,7 @@ struct usb_device *usb_alloc_dev(struct usb_device *parent,
49570 set_dev_node(&dev->dev, dev_to_node(bus->controller));
49571 dev->state = USB_STATE_ATTACHED;
49572 dev->lpm_disable_count = 1;
49573 - atomic_set(&dev->urbnum, 0);
49574 + atomic_set_unchecked(&dev->urbnum, 0);
49575
49576 INIT_LIST_HEAD(&dev->ep0.urb_list);
49577 dev->ep0.desc.bLength = USB_DT_ENDPOINT_SIZE;
49578 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
49579 index 02e44fc..3c4fe64 100644
49580 --- a/drivers/usb/dwc3/gadget.c
49581 +++ b/drivers/usb/dwc3/gadget.c
49582 @@ -532,8 +532,6 @@ static int __dwc3_gadget_ep_enable(struct dwc3_ep *dep,
49583 if (!usb_endpoint_xfer_isoc(desc))
49584 return 0;
49585
49586 - memset(&trb_link, 0, sizeof(trb_link));
49587 -
49588 /* Link TRB for ISOC. The HWO bit is never reset */
49589 trb_st_hw = &dep->trb_pool[0];
49590
49591 diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c
49592 index 5e29dde..eca992f 100644
49593 --- a/drivers/usb/early/ehci-dbgp.c
49594 +++ b/drivers/usb/early/ehci-dbgp.c
49595 @@ -98,7 +98,8 @@ static inline u32 dbgp_len_update(u32 x, u32 len)
49596
49597 #ifdef CONFIG_KGDB
49598 static struct kgdb_io kgdbdbgp_io_ops;
49599 -#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops)
49600 +static struct kgdb_io kgdbdbgp_io_ops_console;
49601 +#define dbgp_kgdb_mode (dbg_io_ops == &kgdbdbgp_io_ops || dbg_io_ops == &kgdbdbgp_io_ops_console)
49602 #else
49603 #define dbgp_kgdb_mode (0)
49604 #endif
49605 @@ -1047,6 +1048,13 @@ static struct kgdb_io kgdbdbgp_io_ops = {
49606 .write_char = kgdbdbgp_write_char,
49607 };
49608
49609 +static struct kgdb_io kgdbdbgp_io_ops_console = {
49610 + .name = "kgdbdbgp",
49611 + .read_char = kgdbdbgp_read_char,
49612 + .write_char = kgdbdbgp_write_char,
49613 + .is_console = 1
49614 +};
49615 +
49616 static int kgdbdbgp_wait_time;
49617
49618 static int __init kgdbdbgp_parse_config(char *str)
49619 @@ -1062,8 +1070,10 @@ static int __init kgdbdbgp_parse_config(char *str)
49620 ptr++;
49621 kgdbdbgp_wait_time = simple_strtoul(ptr, &ptr, 10);
49622 }
49623 - kgdb_register_io_module(&kgdbdbgp_io_ops);
49624 - kgdbdbgp_io_ops.is_console = early_dbgp_console.index != -1;
49625 + if (early_dbgp_console.index != -1)
49626 + kgdb_register_io_module(&kgdbdbgp_io_ops_console);
49627 + else
49628 + kgdb_register_io_module(&kgdbdbgp_io_ops);
49629
49630 return 0;
49631 }
49632 diff --git a/drivers/usb/gadget/u_serial.c b/drivers/usb/gadget/u_serial.c
49633 index b369292..9f3ba40 100644
49634 --- a/drivers/usb/gadget/u_serial.c
49635 +++ b/drivers/usb/gadget/u_serial.c
49636 @@ -733,9 +733,9 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49637 spin_lock_irq(&port->port_lock);
49638
49639 /* already open? Great. */
49640 - if (port->port.count) {
49641 + if (atomic_read(&port->port.count)) {
49642 status = 0;
49643 - port->port.count++;
49644 + atomic_inc(&port->port.count);
49645
49646 /* currently opening/closing? wait ... */
49647 } else if (port->openclose) {
49648 @@ -794,7 +794,7 @@ static int gs_open(struct tty_struct *tty, struct file *file)
49649 tty->driver_data = port;
49650 port->port.tty = tty;
49651
49652 - port->port.count = 1;
49653 + atomic_set(&port->port.count, 1);
49654 port->openclose = false;
49655
49656 /* if connected, start the I/O stream */
49657 @@ -836,11 +836,11 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49658
49659 spin_lock_irq(&port->port_lock);
49660
49661 - if (port->port.count != 1) {
49662 - if (port->port.count == 0)
49663 + if (atomic_read(&port->port.count) != 1) {
49664 + if (atomic_read(&port->port.count) == 0)
49665 WARN_ON(1);
49666 else
49667 - --port->port.count;
49668 + atomic_dec(&port->port.count);
49669 goto exit;
49670 }
49671
49672 @@ -850,7 +850,7 @@ static void gs_close(struct tty_struct *tty, struct file *file)
49673 * and sleep if necessary
49674 */
49675 port->openclose = true;
49676 - port->port.count = 0;
49677 + atomic_set(&port->port.count, 0);
49678
49679 gser = port->port_usb;
49680 if (gser && gser->disconnect)
49681 @@ -1066,7 +1066,7 @@ static int gs_closed(struct gs_port *port)
49682 int cond;
49683
49684 spin_lock_irq(&port->port_lock);
49685 - cond = (port->port.count == 0) && !port->openclose;
49686 + cond = (atomic_read(&port->port.count) == 0) && !port->openclose;
49687 spin_unlock_irq(&port->port_lock);
49688 return cond;
49689 }
49690 @@ -1209,7 +1209,7 @@ int gserial_connect(struct gserial *gser, u8 port_num)
49691 /* if it's already open, start I/O ... and notify the serial
49692 * protocol about open/close status (connect/disconnect).
49693 */
49694 - if (port->port.count) {
49695 + if (atomic_read(&port->port.count)) {
49696 pr_debug("gserial_connect: start ttyGS%d\n", port->port_num);
49697 gs_start_io(port);
49698 if (gser->connect)
49699 @@ -1256,7 +1256,7 @@ void gserial_disconnect(struct gserial *gser)
49700
49701 port->port_usb = NULL;
49702 gser->ioport = NULL;
49703 - if (port->port.count > 0 || port->openclose) {
49704 + if (atomic_read(&port->port.count) > 0 || port->openclose) {
49705 wake_up_interruptible(&port->drain_wait);
49706 if (port->port.tty)
49707 tty_hangup(port->port.tty);
49708 @@ -1272,7 +1272,7 @@ void gserial_disconnect(struct gserial *gser)
49709
49710 /* finally, free any unused/unusable I/O buffers */
49711 spin_lock_irqsave(&port->port_lock, flags);
49712 - if (port->port.count == 0 && !port->openclose)
49713 + if (atomic_read(&port->port.count) == 0 && !port->openclose)
49714 gs_buf_free(&port->port_write_buf);
49715 gs_free_requests(gser->out, &port->read_pool, NULL);
49716 gs_free_requests(gser->out, &port->read_queue, NULL);
49717 diff --git a/drivers/usb/host/ehci-hub.c b/drivers/usb/host/ehci-hub.c
49718 index 835fc08..f8b22bf 100644
49719 --- a/drivers/usb/host/ehci-hub.c
49720 +++ b/drivers/usb/host/ehci-hub.c
49721 @@ -762,7 +762,7 @@ static struct urb *request_single_step_set_feature_urb(
49722 urb->transfer_flags = URB_DIR_IN;
49723 usb_get_urb(urb);
49724 atomic_inc(&urb->use_count);
49725 - atomic_inc(&urb->dev->urbnum);
49726 + atomic_inc_unchecked(&urb->dev->urbnum);
49727 urb->setup_dma = dma_map_single(
49728 hcd->self.controller,
49729 urb->setup_packet,
49730 @@ -829,7 +829,7 @@ static int ehset_single_step_set_feature(struct usb_hcd *hcd, int port)
49731 urb->status = -EINPROGRESS;
49732 usb_get_urb(urb);
49733 atomic_inc(&urb->use_count);
49734 - atomic_inc(&urb->dev->urbnum);
49735 + atomic_inc_unchecked(&urb->dev->urbnum);
49736 retval = submit_single_step_set_feature(hcd, urb, 0);
49737 if (!retval && !wait_for_completion_timeout(&done,
49738 msecs_to_jiffies(2000))) {
49739 diff --git a/drivers/usb/misc/appledisplay.c b/drivers/usb/misc/appledisplay.c
49740 index ba6a5d6..f88f7f3 100644
49741 --- a/drivers/usb/misc/appledisplay.c
49742 +++ b/drivers/usb/misc/appledisplay.c
49743 @@ -83,7 +83,7 @@ struct appledisplay {
49744 spinlock_t lock;
49745 };
49746
49747 -static atomic_t count_displays = ATOMIC_INIT(0);
49748 +static atomic_unchecked_t count_displays = ATOMIC_INIT(0);
49749 static struct workqueue_struct *wq;
49750
49751 static void appledisplay_complete(struct urb *urb)
49752 @@ -281,7 +281,7 @@ static int appledisplay_probe(struct usb_interface *iface,
49753
49754 /* Register backlight device */
49755 snprintf(bl_name, sizeof(bl_name), "appledisplay%d",
49756 - atomic_inc_return(&count_displays) - 1);
49757 + atomic_inc_return_unchecked(&count_displays) - 1);
49758 memset(&props, 0, sizeof(struct backlight_properties));
49759 props.type = BACKLIGHT_RAW;
49760 props.max_brightness = 0xff;
49761 diff --git a/drivers/usb/serial/console.c b/drivers/usb/serial/console.c
49762 index c69bb50..215ef37 100644
49763 --- a/drivers/usb/serial/console.c
49764 +++ b/drivers/usb/serial/console.c
49765 @@ -124,7 +124,7 @@ static int usb_console_setup(struct console *co, char *options)
49766
49767 info->port = port;
49768
49769 - ++port->port.count;
49770 + atomic_inc(&port->port.count);
49771 if (!test_bit(ASYNCB_INITIALIZED, &port->port.flags)) {
49772 if (serial->type->set_termios) {
49773 /*
49774 @@ -170,7 +170,7 @@ static int usb_console_setup(struct console *co, char *options)
49775 }
49776 /* Now that any required fake tty operations are completed restore
49777 * the tty port count */
49778 - --port->port.count;
49779 + atomic_dec(&port->port.count);
49780 /* The console is special in terms of closing the device so
49781 * indicate this port is now acting as a system console. */
49782 port->port.console = 1;
49783 @@ -183,7 +183,7 @@ static int usb_console_setup(struct console *co, char *options)
49784 free_tty:
49785 kfree(tty);
49786 reset_open_count:
49787 - port->port.count = 0;
49788 + atomic_set(&port->port.count, 0);
49789 usb_autopm_put_interface(serial->interface);
49790 error_get_interface:
49791 usb_serial_put(serial);
49792 @@ -194,7 +194,7 @@ static int usb_console_setup(struct console *co, char *options)
49793 static void usb_console_write(struct console *co,
49794 const char *buf, unsigned count)
49795 {
49796 - static struct usbcons_info *info = &usbcons_info;
49797 + struct usbcons_info *info = &usbcons_info;
49798 struct usb_serial_port *port = info->port;
49799 struct usb_serial *serial;
49800 int retval = -ENODEV;
49801 diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
49802 index 75f70f0..d467e1a 100644
49803 --- a/drivers/usb/storage/usb.h
49804 +++ b/drivers/usb/storage/usb.h
49805 @@ -63,7 +63,7 @@ struct us_unusual_dev {
49806 __u8 useProtocol;
49807 __u8 useTransport;
49808 int (*initFunction)(struct us_data *);
49809 -};
49810 +} __do_const;
49811
49812
49813 /* Dynamic bitflag definitions (us->dflags): used in set_bit() etc. */
49814 diff --git a/drivers/usb/wusbcore/wa-hc.h b/drivers/usb/wusbcore/wa-hc.h
49815 index cf250c2..ad9d904 100644
49816 --- a/drivers/usb/wusbcore/wa-hc.h
49817 +++ b/drivers/usb/wusbcore/wa-hc.h
49818 @@ -199,7 +199,7 @@ struct wahc {
49819 spinlock_t xfer_list_lock;
49820 struct work_struct xfer_enqueue_work;
49821 struct work_struct xfer_error_work;
49822 - atomic_t xfer_id_count;
49823 + atomic_unchecked_t xfer_id_count;
49824 };
49825
49826
49827 @@ -255,7 +255,7 @@ static inline void wa_init(struct wahc *wa)
49828 spin_lock_init(&wa->xfer_list_lock);
49829 INIT_WORK(&wa->xfer_enqueue_work, wa_urb_enqueue_run);
49830 INIT_WORK(&wa->xfer_error_work, wa_process_errored_transfers_run);
49831 - atomic_set(&wa->xfer_id_count, 1);
49832 + atomic_set_unchecked(&wa->xfer_id_count, 1);
49833 }
49834
49835 /**
49836 diff --git a/drivers/usb/wusbcore/wa-xfer.c b/drivers/usb/wusbcore/wa-xfer.c
49837 index 3dcf66f..8faaf6e 100644
49838 --- a/drivers/usb/wusbcore/wa-xfer.c
49839 +++ b/drivers/usb/wusbcore/wa-xfer.c
49840 @@ -300,7 +300,7 @@ out:
49841 */
49842 static void wa_xfer_id_init(struct wa_xfer *xfer)
49843 {
49844 - xfer->id = atomic_add_return(1, &xfer->wa->xfer_id_count);
49845 + xfer->id = atomic_add_return_unchecked(1, &xfer->wa->xfer_id_count);
49846 }
49847
49848 /*
49849 diff --git a/drivers/vfio/vfio.c b/drivers/vfio/vfio.c
49850 index 1eab4ac..e21efc9 100644
49851 --- a/drivers/vfio/vfio.c
49852 +++ b/drivers/vfio/vfio.c
49853 @@ -488,7 +488,7 @@ static int vfio_group_nb_add_dev(struct vfio_group *group, struct device *dev)
49854 return 0;
49855
49856 /* TODO Prevent device auto probing */
49857 - WARN("Device %s added to live group %d!\n", dev_name(dev),
49858 + WARN(1, "Device %s added to live group %d!\n", dev_name(dev),
49859 iommu_group_id(group->iommu_group));
49860
49861 return 0;
49862 diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c
49863 index 5174eba..86e764a 100644
49864 --- a/drivers/vhost/vringh.c
49865 +++ b/drivers/vhost/vringh.c
49866 @@ -800,7 +800,7 @@ static inline int getu16_kern(u16 *val, const u16 *p)
49867
49868 static inline int putu16_kern(u16 *p, u16 val)
49869 {
49870 - ACCESS_ONCE(*p) = val;
49871 + ACCESS_ONCE_RW(*p) = val;
49872 return 0;
49873 }
49874
49875 diff --git a/drivers/video/arcfb.c b/drivers/video/arcfb.c
49876 index e43401a..dd49b3f 100644
49877 --- a/drivers/video/arcfb.c
49878 +++ b/drivers/video/arcfb.c
49879 @@ -458,7 +458,7 @@ static ssize_t arcfb_write(struct fb_info *info, const char __user *buf,
49880 return -ENOSPC;
49881
49882 err = 0;
49883 - if ((count + p) > fbmemlength) {
49884 + if (count > (fbmemlength - p)) {
49885 count = fbmemlength - p;
49886 err = -ENOSPC;
49887 }
49888 diff --git a/drivers/video/aty/aty128fb.c b/drivers/video/aty/aty128fb.c
49889 index a4dfe8c..297ddd9 100644
49890 --- a/drivers/video/aty/aty128fb.c
49891 +++ b/drivers/video/aty/aty128fb.c
49892 @@ -149,7 +149,7 @@ enum {
49893 };
49894
49895 /* Must match above enum */
49896 -static char * const r128_family[] = {
49897 +static const char * const r128_family[] = {
49898 "AGP",
49899 "PCI",
49900 "PRO AGP",
49901 diff --git a/drivers/video/aty/atyfb_base.c b/drivers/video/aty/atyfb_base.c
49902 index 9b0f12c..024673d 100644
49903 --- a/drivers/video/aty/atyfb_base.c
49904 +++ b/drivers/video/aty/atyfb_base.c
49905 @@ -1326,10 +1326,14 @@ static int atyfb_set_par(struct fb_info *info)
49906 par->accel_flags = var->accel_flags; /* hack */
49907
49908 if (var->accel_flags) {
49909 - info->fbops->fb_sync = atyfb_sync;
49910 + pax_open_kernel();
49911 + *(void **)&info->fbops->fb_sync = atyfb_sync;
49912 + pax_close_kernel();
49913 info->flags &= ~FBINFO_HWACCEL_DISABLED;
49914 } else {
49915 - info->fbops->fb_sync = NULL;
49916 + pax_open_kernel();
49917 + *(void **)&info->fbops->fb_sync = NULL;
49918 + pax_close_kernel();
49919 info->flags |= FBINFO_HWACCEL_DISABLED;
49920 }
49921
49922 diff --git a/drivers/video/aty/mach64_cursor.c b/drivers/video/aty/mach64_cursor.c
49923 index 95ec042..e6affdd 100644
49924 --- a/drivers/video/aty/mach64_cursor.c
49925 +++ b/drivers/video/aty/mach64_cursor.c
49926 @@ -7,6 +7,7 @@
49927 #include <linux/string.h>
49928
49929 #include <asm/io.h>
49930 +#include <asm/pgtable.h>
49931
49932 #ifdef __sparc__
49933 #include <asm/fbio.h>
49934 @@ -208,7 +209,9 @@ int aty_init_cursor(struct fb_info *info)
49935 info->sprite.buf_align = 16; /* and 64 lines tall. */
49936 info->sprite.flags = FB_PIXMAP_IO;
49937
49938 - info->fbops->fb_cursor = atyfb_cursor;
49939 + pax_open_kernel();
49940 + *(void **)&info->fbops->fb_cursor = atyfb_cursor;
49941 + pax_close_kernel();
49942
49943 return 0;
49944 }
49945 diff --git a/drivers/video/backlight/kb3886_bl.c b/drivers/video/backlight/kb3886_bl.c
49946 index bca6ccc..252107e 100644
49947 --- a/drivers/video/backlight/kb3886_bl.c
49948 +++ b/drivers/video/backlight/kb3886_bl.c
49949 @@ -78,7 +78,7 @@ static struct kb3886bl_machinfo *bl_machinfo;
49950 static unsigned long kb3886bl_flags;
49951 #define KB3886BL_SUSPENDED 0x01
49952
49953 -static struct dmi_system_id __initdata kb3886bl_device_table[] = {
49954 +static const struct dmi_system_id __initconst kb3886bl_device_table[] = {
49955 {
49956 .ident = "Sahara Touch-iT",
49957 .matches = {
49958 diff --git a/drivers/video/fb_defio.c b/drivers/video/fb_defio.c
49959 index 900aa4e..6d49418 100644
49960 --- a/drivers/video/fb_defio.c
49961 +++ b/drivers/video/fb_defio.c
49962 @@ -206,7 +206,9 @@ void fb_deferred_io_init(struct fb_info *info)
49963
49964 BUG_ON(!fbdefio);
49965 mutex_init(&fbdefio->lock);
49966 - info->fbops->fb_mmap = fb_deferred_io_mmap;
49967 + pax_open_kernel();
49968 + *(void **)&info->fbops->fb_mmap = fb_deferred_io_mmap;
49969 + pax_close_kernel();
49970 INIT_DELAYED_WORK(&info->deferred_work, fb_deferred_io_work);
49971 INIT_LIST_HEAD(&fbdefio->pagelist);
49972 if (fbdefio->delay == 0) /* set a default of 1 s */
49973 @@ -237,7 +239,7 @@ void fb_deferred_io_cleanup(struct fb_info *info)
49974 page->mapping = NULL;
49975 }
49976
49977 - info->fbops->fb_mmap = NULL;
49978 + *(void **)&info->fbops->fb_mmap = NULL;
49979 mutex_destroy(&fbdefio->lock);
49980 }
49981 EXPORT_SYMBOL_GPL(fb_deferred_io_cleanup);
49982 diff --git a/drivers/video/fbmem.c b/drivers/video/fbmem.c
49983 index dacaf74..8478a46 100644
49984 --- a/drivers/video/fbmem.c
49985 +++ b/drivers/video/fbmem.c
49986 @@ -433,7 +433,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49987 image->dx += image->width + 8;
49988 }
49989 } else if (rotate == FB_ROTATE_UD) {
49990 - for (x = 0; x < num && image->dx >= 0; x++) {
49991 + for (x = 0; x < num && (__s32)image->dx >= 0; x++) {
49992 info->fbops->fb_imageblit(info, image);
49993 image->dx -= image->width + 8;
49994 }
49995 @@ -445,7 +445,7 @@ static void fb_do_show_logo(struct fb_info *info, struct fb_image *image,
49996 image->dy += image->height + 8;
49997 }
49998 } else if (rotate == FB_ROTATE_CCW) {
49999 - for (x = 0; x < num && image->dy >= 0; x++) {
50000 + for (x = 0; x < num && (__s32)image->dy >= 0; x++) {
50001 info->fbops->fb_imageblit(info, image);
50002 image->dy -= image->height + 8;
50003 }
50004 @@ -1175,7 +1175,7 @@ static long do_fb_ioctl(struct fb_info *info, unsigned int cmd,
50005 return -EFAULT;
50006 if (con2fb.console < 1 || con2fb.console > MAX_NR_CONSOLES)
50007 return -EINVAL;
50008 - if (con2fb.framebuffer < 0 || con2fb.framebuffer >= FB_MAX)
50009 + if (con2fb.framebuffer >= FB_MAX)
50010 return -EINVAL;
50011 if (!registered_fb[con2fb.framebuffer])
50012 request_module("fb%d", con2fb.framebuffer);
50013 diff --git a/drivers/video/hyperv_fb.c b/drivers/video/hyperv_fb.c
50014 index 8d456dc..b4fa44b 100644
50015 --- a/drivers/video/hyperv_fb.c
50016 +++ b/drivers/video/hyperv_fb.c
50017 @@ -233,7 +233,7 @@ static uint screen_fb_size;
50018 static inline int synthvid_send(struct hv_device *hdev,
50019 struct synthvid_msg *msg)
50020 {
50021 - static atomic64_t request_id = ATOMIC64_INIT(0);
50022 + static atomic64_unchecked_t request_id = ATOMIC64_INIT(0);
50023 int ret;
50024
50025 msg->pipe_hdr.type = PIPE_MSG_DATA;
50026 @@ -241,7 +241,7 @@ static inline int synthvid_send(struct hv_device *hdev,
50027
50028 ret = vmbus_sendpacket(hdev->channel, msg,
50029 msg->vid_hdr.size + sizeof(struct pipe_msg_hdr),
50030 - atomic64_inc_return(&request_id),
50031 + atomic64_inc_return_unchecked(&request_id),
50032 VM_PKT_DATA_INBAND, 0);
50033
50034 if (ret)
50035 diff --git a/drivers/video/i810/i810_accel.c b/drivers/video/i810/i810_accel.c
50036 index 7672d2e..b56437f 100644
50037 --- a/drivers/video/i810/i810_accel.c
50038 +++ b/drivers/video/i810/i810_accel.c
50039 @@ -73,6 +73,7 @@ static inline int wait_for_space(struct fb_info *info, u32 space)
50040 }
50041 }
50042 printk("ringbuffer lockup!!!\n");
50043 + printk("head:%u tail:%u iring.size:%u space:%u\n", head, tail, par->iring.size, space);
50044 i810_report_error(mmio);
50045 par->dev_flags |= LOCKUP;
50046 info->pixmap.scan_align = 1;
50047 diff --git a/drivers/video/logo/logo_linux_clut224.ppm b/drivers/video/logo/logo_linux_clut224.ppm
50048 index 3c14e43..2630570 100644
50049 --- a/drivers/video/logo/logo_linux_clut224.ppm
50050 +++ b/drivers/video/logo/logo_linux_clut224.ppm
50051 @@ -2,1603 +2,1123 @@ P3
50052 # Standard 224-color Linux logo
50053 80 80
50054 255
50055 - 0 0 0 0 0 0 0 0 0 0 0 0
50056 - 0 0 0 0 0 0 0 0 0 0 0 0
50057 - 0 0 0 0 0 0 0 0 0 0 0 0
50058 - 0 0 0 0 0 0 0 0 0 0 0 0
50059 - 0 0 0 0 0 0 0 0 0 0 0 0
50060 - 0 0 0 0 0 0 0 0 0 0 0 0
50061 - 0 0 0 0 0 0 0 0 0 0 0 0
50062 - 0 0 0 0 0 0 0 0 0 0 0 0
50063 - 0 0 0 0 0 0 0 0 0 0 0 0
50064 - 6 6 6 6 6 6 10 10 10 10 10 10
50065 - 10 10 10 6 6 6 6 6 6 6 6 6
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 - 0 0 0 0 0 0 0 0 0 0 0 0
50075 - 0 0 0 0 0 0 0 0 0 0 0 0
50076 - 0 0 0 0 0 0 0 0 0 0 0 0
50077 - 0 0 0 0 0 0 0 0 0 0 0 0
50078 - 0 0 0 0 0 0 0 0 0 0 0 0
50079 - 0 0 0 0 0 0 0 0 0 0 0 0
50080 - 0 0 0 0 0 0 0 0 0 0 0 0
50081 - 0 0 0 0 0 0 0 0 0 0 0 0
50082 - 0 0 0 0 0 0 0 0 0 0 0 0
50083 - 0 0 0 6 6 6 10 10 10 14 14 14
50084 - 22 22 22 26 26 26 30 30 30 34 34 34
50085 - 30 30 30 30 30 30 26 26 26 18 18 18
50086 - 14 14 14 10 10 10 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50095 - 0 0 0 0 0 0 0 0 0 0 0 0
50096 - 0 0 0 0 0 1 0 0 1 0 0 0
50097 - 0 0 0 0 0 0 0 0 0 0 0 0
50098 - 0 0 0 0 0 0 0 0 0 0 0 0
50099 - 0 0 0 0 0 0 0 0 0 0 0 0
50100 - 0 0 0 0 0 0 0 0 0 0 0 0
50101 - 0 0 0 0 0 0 0 0 0 0 0 0
50102 - 0 0 0 0 0 0 0 0 0 0 0 0
50103 - 6 6 6 14 14 14 26 26 26 42 42 42
50104 - 54 54 54 66 66 66 78 78 78 78 78 78
50105 - 78 78 78 74 74 74 66 66 66 54 54 54
50106 - 42 42 42 26 26 26 18 18 18 10 10 10
50107 - 6 6 6 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 0 0 0
50114 - 0 0 0 0 0 0 0 0 0 0 0 0
50115 - 0 0 0 0 0 0 0 0 0 0 0 0
50116 - 0 0 1 0 0 0 0 0 0 0 0 0
50117 - 0 0 0 0 0 0 0 0 0 0 0 0
50118 - 0 0 0 0 0 0 0 0 0 0 0 0
50119 - 0 0 0 0 0 0 0 0 0 0 0 0
50120 - 0 0 0 0 0 0 0 0 0 0 0 0
50121 - 0 0 0 0 0 0 0 0 0 0 0 0
50122 - 0 0 0 0 0 0 0 0 0 10 10 10
50123 - 22 22 22 42 42 42 66 66 66 86 86 86
50124 - 66 66 66 38 38 38 38 38 38 22 22 22
50125 - 26 26 26 34 34 34 54 54 54 66 66 66
50126 - 86 86 86 70 70 70 46 46 46 26 26 26
50127 - 14 14 14 6 6 6 0 0 0 0 0 0
50128 - 0 0 0 0 0 0 0 0 0 0 0 0
50129 - 0 0 0 0 0 0 0 0 0 0 0 0
50130 - 0 0 0 0 0 0 0 0 0 0 0 0
50131 - 0 0 0 0 0 0 0 0 0 0 0 0
50132 - 0 0 0 0 0 0 0 0 0 0 0 0
50133 - 0 0 0 0 0 0 0 0 0 0 0 0
50134 - 0 0 0 0 0 0 0 0 0 0 0 0
50135 - 0 0 0 0 0 0 0 0 0 0 0 0
50136 - 0 0 1 0 0 1 0 0 1 0 0 0
50137 - 0 0 0 0 0 0 0 0 0 0 0 0
50138 - 0 0 0 0 0 0 0 0 0 0 0 0
50139 - 0 0 0 0 0 0 0 0 0 0 0 0
50140 - 0 0 0 0 0 0 0 0 0 0 0 0
50141 - 0 0 0 0 0 0 0 0 0 0 0 0
50142 - 0 0 0 0 0 0 10 10 10 26 26 26
50143 - 50 50 50 82 82 82 58 58 58 6 6 6
50144 - 2 2 6 2 2 6 2 2 6 2 2 6
50145 - 2 2 6 2 2 6 2 2 6 2 2 6
50146 - 6 6 6 54 54 54 86 86 86 66 66 66
50147 - 38 38 38 18 18 18 6 6 6 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 0 0 0
50154 - 0 0 0 0 0 0 0 0 0 0 0 0
50155 - 0 0 0 0 0 0 0 0 0 0 0 0
50156 - 0 0 0 0 0 0 0 0 0 0 0 0
50157 - 0 0 0 0 0 0 0 0 0 0 0 0
50158 - 0 0 0 0 0 0 0 0 0 0 0 0
50159 - 0 0 0 0 0 0 0 0 0 0 0 0
50160 - 0 0 0 0 0 0 0 0 0 0 0 0
50161 - 0 0 0 0 0 0 0 0 0 0 0 0
50162 - 0 0 0 6 6 6 22 22 22 50 50 50
50163 - 78 78 78 34 34 34 2 2 6 2 2 6
50164 - 2 2 6 2 2 6 2 2 6 2 2 6
50165 - 2 2 6 2 2 6 2 2 6 2 2 6
50166 - 2 2 6 2 2 6 6 6 6 70 70 70
50167 - 78 78 78 46 46 46 22 22 22 6 6 6
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 0 0 0 0 0 0
50174 - 0 0 0 0 0 0 0 0 0 0 0 0
50175 - 0 0 0 0 0 0 0 0 0 0 0 0
50176 - 0 0 1 0 0 1 0 0 1 0 0 0
50177 - 0 0 0 0 0 0 0 0 0 0 0 0
50178 - 0 0 0 0 0 0 0 0 0 0 0 0
50179 - 0 0 0 0 0 0 0 0 0 0 0 0
50180 - 0 0 0 0 0 0 0 0 0 0 0 0
50181 - 0 0 0 0 0 0 0 0 0 0 0 0
50182 - 6 6 6 18 18 18 42 42 42 82 82 82
50183 - 26 26 26 2 2 6 2 2 6 2 2 6
50184 - 2 2 6 2 2 6 2 2 6 2 2 6
50185 - 2 2 6 2 2 6 2 2 6 14 14 14
50186 - 46 46 46 34 34 34 6 6 6 2 2 6
50187 - 42 42 42 78 78 78 42 42 42 18 18 18
50188 - 6 6 6 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 0 0 0 0 0 0
50194 - 0 0 0 0 0 0 0 0 0 0 0 0
50195 - 0 0 0 0 0 0 0 0 0 0 0 0
50196 - 0 0 1 0 0 0 0 0 1 0 0 0
50197 - 0 0 0 0 0 0 0 0 0 0 0 0
50198 - 0 0 0 0 0 0 0 0 0 0 0 0
50199 - 0 0 0 0 0 0 0 0 0 0 0 0
50200 - 0 0 0 0 0 0 0 0 0 0 0 0
50201 - 0 0 0 0 0 0 0 0 0 0 0 0
50202 - 10 10 10 30 30 30 66 66 66 58 58 58
50203 - 2 2 6 2 2 6 2 2 6 2 2 6
50204 - 2 2 6 2 2 6 2 2 6 2 2 6
50205 - 2 2 6 2 2 6 2 2 6 26 26 26
50206 - 86 86 86 101 101 101 46 46 46 10 10 10
50207 - 2 2 6 58 58 58 70 70 70 34 34 34
50208 - 10 10 10 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 0 0 0 0 0 0 0 0 0
50214 - 0 0 0 0 0 0 0 0 0 0 0 0
50215 - 0 0 0 0 0 0 0 0 0 0 0 0
50216 - 0 0 1 0 0 1 0 0 1 0 0 0
50217 - 0 0 0 0 0 0 0 0 0 0 0 0
50218 - 0 0 0 0 0 0 0 0 0 0 0 0
50219 - 0 0 0 0 0 0 0 0 0 0 0 0
50220 - 0 0 0 0 0 0 0 0 0 0 0 0
50221 - 0 0 0 0 0 0 0 0 0 0 0 0
50222 - 14 14 14 42 42 42 86 86 86 10 10 10
50223 - 2 2 6 2 2 6 2 2 6 2 2 6
50224 - 2 2 6 2 2 6 2 2 6 2 2 6
50225 - 2 2 6 2 2 6 2 2 6 30 30 30
50226 - 94 94 94 94 94 94 58 58 58 26 26 26
50227 - 2 2 6 6 6 6 78 78 78 54 54 54
50228 - 22 22 22 6 6 6 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 0 0 0 0 0 0 0 0 0
50234 - 0 0 0 0 0 0 0 0 0 0 0 0
50235 - 0 0 0 0 0 0 0 0 0 0 0 0
50236 - 0 0 0 0 0 0 0 0 0 0 0 0
50237 - 0 0 0 0 0 0 0 0 0 0 0 0
50238 - 0 0 0 0 0 0 0 0 0 0 0 0
50239 - 0 0 0 0 0 0 0 0 0 0 0 0
50240 - 0 0 0 0 0 0 0 0 0 0 0 0
50241 - 0 0 0 0 0 0 0 0 0 6 6 6
50242 - 22 22 22 62 62 62 62 62 62 2 2 6
50243 - 2 2 6 2 2 6 2 2 6 2 2 6
50244 - 2 2 6 2 2 6 2 2 6 2 2 6
50245 - 2 2 6 2 2 6 2 2 6 26 26 26
50246 - 54 54 54 38 38 38 18 18 18 10 10 10
50247 - 2 2 6 2 2 6 34 34 34 82 82 82
50248 - 38 38 38 14 14 14 0 0 0 0 0 0
50249 - 0 0 0 0 0 0 0 0 0 0 0 0
50250 - 0 0 0 0 0 0 0 0 0 0 0 0
50251 - 0 0 0 0 0 0 0 0 0 0 0 0
50252 - 0 0 0 0 0 0 0 0 0 0 0 0
50253 - 0 0 0 0 0 0 0 0 0 0 0 0
50254 - 0 0 0 0 0 0 0 0 0 0 0 0
50255 - 0 0 0 0 0 0 0 0 0 0 0 0
50256 - 0 0 0 0 0 1 0 0 1 0 0 0
50257 - 0 0 0 0 0 0 0 0 0 0 0 0
50258 - 0 0 0 0 0 0 0 0 0 0 0 0
50259 - 0 0 0 0 0 0 0 0 0 0 0 0
50260 - 0 0 0 0 0 0 0 0 0 0 0 0
50261 - 0 0 0 0 0 0 0 0 0 6 6 6
50262 - 30 30 30 78 78 78 30 30 30 2 2 6
50263 - 2 2 6 2 2 6 2 2 6 2 2 6
50264 - 2 2 6 2 2 6 2 2 6 2 2 6
50265 - 2 2 6 2 2 6 2 2 6 10 10 10
50266 - 10 10 10 2 2 6 2 2 6 2 2 6
50267 - 2 2 6 2 2 6 2 2 6 78 78 78
50268 - 50 50 50 18 18 18 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50274 - 0 0 0 0 0 0 0 0 0 0 0 0
50275 - 0 0 0 0 0 0 0 0 0 0 0 0
50276 - 0 0 1 0 0 0 0 0 0 0 0 0
50277 - 0 0 0 0 0 0 0 0 0 0 0 0
50278 - 0 0 0 0 0 0 0 0 0 0 0 0
50279 - 0 0 0 0 0 0 0 0 0 0 0 0
50280 - 0 0 0 0 0 0 0 0 0 0 0 0
50281 - 0 0 0 0 0 0 0 0 0 10 10 10
50282 - 38 38 38 86 86 86 14 14 14 2 2 6
50283 - 2 2 6 2 2 6 2 2 6 2 2 6
50284 - 2 2 6 2 2 6 2 2 6 2 2 6
50285 - 2 2 6 2 2 6 2 2 6 2 2 6
50286 - 2 2 6 2 2 6 2 2 6 2 2 6
50287 - 2 2 6 2 2 6 2 2 6 54 54 54
50288 - 66 66 66 26 26 26 6 6 6 0 0 0
50289 - 0 0 0 0 0 0 0 0 0 0 0 0
50290 - 0 0 0 0 0 0 0 0 0 0 0 0
50291 - 0 0 0 0 0 0 0 0 0 0 0 0
50292 - 0 0 0 0 0 0 0 0 0 0 0 0
50293 - 0 0 0 0 0 0 0 0 0 0 0 0
50294 - 0 0 0 0 0 0 0 0 0 0 0 0
50295 - 0 0 0 0 0 0 0 0 0 0 0 0
50296 - 0 0 0 0 0 1 0 0 1 0 0 0
50297 - 0 0 0 0 0 0 0 0 0 0 0 0
50298 - 0 0 0 0 0 0 0 0 0 0 0 0
50299 - 0 0 0 0 0 0 0 0 0 0 0 0
50300 - 0 0 0 0 0 0 0 0 0 0 0 0
50301 - 0 0 0 0 0 0 0 0 0 14 14 14
50302 - 42 42 42 82 82 82 2 2 6 2 2 6
50303 - 2 2 6 6 6 6 10 10 10 2 2 6
50304 - 2 2 6 2 2 6 2 2 6 2 2 6
50305 - 2 2 6 2 2 6 2 2 6 6 6 6
50306 - 14 14 14 10 10 10 2 2 6 2 2 6
50307 - 2 2 6 2 2 6 2 2 6 18 18 18
50308 - 82 82 82 34 34 34 10 10 10 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 0 0 0
50313 - 0 0 0 0 0 0 0 0 0 0 0 0
50314 - 0 0 0 0 0 0 0 0 0 0 0 0
50315 - 0 0 0 0 0 0 0 0 0 0 0 0
50316 - 0 0 1 0 0 0 0 0 0 0 0 0
50317 - 0 0 0 0 0 0 0 0 0 0 0 0
50318 - 0 0 0 0 0 0 0 0 0 0 0 0
50319 - 0 0 0 0 0 0 0 0 0 0 0 0
50320 - 0 0 0 0 0 0 0 0 0 0 0 0
50321 - 0 0 0 0 0 0 0 0 0 14 14 14
50322 - 46 46 46 86 86 86 2 2 6 2 2 6
50323 - 6 6 6 6 6 6 22 22 22 34 34 34
50324 - 6 6 6 2 2 6 2 2 6 2 2 6
50325 - 2 2 6 2 2 6 18 18 18 34 34 34
50326 - 10 10 10 50 50 50 22 22 22 2 2 6
50327 - 2 2 6 2 2 6 2 2 6 10 10 10
50328 - 86 86 86 42 42 42 14 14 14 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 0 0 0
50333 - 0 0 0 0 0 0 0 0 0 0 0 0
50334 - 0 0 0 0 0 0 0 0 0 0 0 0
50335 - 0 0 0 0 0 0 0 0 0 0 0 0
50336 - 0 0 1 0 0 1 0 0 1 0 0 0
50337 - 0 0 0 0 0 0 0 0 0 0 0 0
50338 - 0 0 0 0 0 0 0 0 0 0 0 0
50339 - 0 0 0 0 0 0 0 0 0 0 0 0
50340 - 0 0 0 0 0 0 0 0 0 0 0 0
50341 - 0 0 0 0 0 0 0 0 0 14 14 14
50342 - 46 46 46 86 86 86 2 2 6 2 2 6
50343 - 38 38 38 116 116 116 94 94 94 22 22 22
50344 - 22 22 22 2 2 6 2 2 6 2 2 6
50345 - 14 14 14 86 86 86 138 138 138 162 162 162
50346 -154 154 154 38 38 38 26 26 26 6 6 6
50347 - 2 2 6 2 2 6 2 2 6 2 2 6
50348 - 86 86 86 46 46 46 14 14 14 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 0 0 0 0 0 0
50353 - 0 0 0 0 0 0 0 0 0 0 0 0
50354 - 0 0 0 0 0 0 0 0 0 0 0 0
50355 - 0 0 0 0 0 0 0 0 0 0 0 0
50356 - 0 0 0 0 0 0 0 0 0 0 0 0
50357 - 0 0 0 0 0 0 0 0 0 0 0 0
50358 - 0 0 0 0 0 0 0 0 0 0 0 0
50359 - 0 0 0 0 0 0 0 0 0 0 0 0
50360 - 0 0 0 0 0 0 0 0 0 0 0 0
50361 - 0 0 0 0 0 0 0 0 0 14 14 14
50362 - 46 46 46 86 86 86 2 2 6 14 14 14
50363 -134 134 134 198 198 198 195 195 195 116 116 116
50364 - 10 10 10 2 2 6 2 2 6 6 6 6
50365 -101 98 89 187 187 187 210 210 210 218 218 218
50366 -214 214 214 134 134 134 14 14 14 6 6 6
50367 - 2 2 6 2 2 6 2 2 6 2 2 6
50368 - 86 86 86 50 50 50 18 18 18 6 6 6
50369 - 0 0 0 0 0 0 0 0 0 0 0 0
50370 - 0 0 0 0 0 0 0 0 0 0 0 0
50371 - 0 0 0 0 0 0 0 0 0 0 0 0
50372 - 0 0 0 0 0 0 0 0 0 0 0 0
50373 - 0 0 0 0 0 0 0 0 0 0 0 0
50374 - 0 0 0 0 0 0 0 0 0 0 0 0
50375 - 0 0 0 0 0 0 0 0 1 0 0 0
50376 - 0 0 1 0 0 1 0 0 1 0 0 0
50377 - 0 0 0 0 0 0 0 0 0 0 0 0
50378 - 0 0 0 0 0 0 0 0 0 0 0 0
50379 - 0 0 0 0 0 0 0 0 0 0 0 0
50380 - 0 0 0 0 0 0 0 0 0 0 0 0
50381 - 0 0 0 0 0 0 0 0 0 14 14 14
50382 - 46 46 46 86 86 86 2 2 6 54 54 54
50383 -218 218 218 195 195 195 226 226 226 246 246 246
50384 - 58 58 58 2 2 6 2 2 6 30 30 30
50385 -210 210 210 253 253 253 174 174 174 123 123 123
50386 -221 221 221 234 234 234 74 74 74 2 2 6
50387 - 2 2 6 2 2 6 2 2 6 2 2 6
50388 - 70 70 70 58 58 58 22 22 22 6 6 6
50389 - 0 0 0 0 0 0 0 0 0 0 0 0
50390 - 0 0 0 0 0 0 0 0 0 0 0 0
50391 - 0 0 0 0 0 0 0 0 0 0 0 0
50392 - 0 0 0 0 0 0 0 0 0 0 0 0
50393 - 0 0 0 0 0 0 0 0 0 0 0 0
50394 - 0 0 0 0 0 0 0 0 0 0 0 0
50395 - 0 0 0 0 0 0 0 0 0 0 0 0
50396 - 0 0 0 0 0 0 0 0 0 0 0 0
50397 - 0 0 0 0 0 0 0 0 0 0 0 0
50398 - 0 0 0 0 0 0 0 0 0 0 0 0
50399 - 0 0 0 0 0 0 0 0 0 0 0 0
50400 - 0 0 0 0 0 0 0 0 0 0 0 0
50401 - 0 0 0 0 0 0 0 0 0 14 14 14
50402 - 46 46 46 82 82 82 2 2 6 106 106 106
50403 -170 170 170 26 26 26 86 86 86 226 226 226
50404 -123 123 123 10 10 10 14 14 14 46 46 46
50405 -231 231 231 190 190 190 6 6 6 70 70 70
50406 - 90 90 90 238 238 238 158 158 158 2 2 6
50407 - 2 2 6 2 2 6 2 2 6 2 2 6
50408 - 70 70 70 58 58 58 22 22 22 6 6 6
50409 - 0 0 0 0 0 0 0 0 0 0 0 0
50410 - 0 0 0 0 0 0 0 0 0 0 0 0
50411 - 0 0 0 0 0 0 0 0 0 0 0 0
50412 - 0 0 0 0 0 0 0 0 0 0 0 0
50413 - 0 0 0 0 0 0 0 0 0 0 0 0
50414 - 0 0 0 0 0 0 0 0 0 0 0 0
50415 - 0 0 0 0 0 0 0 0 1 0 0 0
50416 - 0 0 1 0 0 1 0 0 1 0 0 0
50417 - 0 0 0 0 0 0 0 0 0 0 0 0
50418 - 0 0 0 0 0 0 0 0 0 0 0 0
50419 - 0 0 0 0 0 0 0 0 0 0 0 0
50420 - 0 0 0 0 0 0 0 0 0 0 0 0
50421 - 0 0 0 0 0 0 0 0 0 14 14 14
50422 - 42 42 42 86 86 86 6 6 6 116 116 116
50423 -106 106 106 6 6 6 70 70 70 149 149 149
50424 -128 128 128 18 18 18 38 38 38 54 54 54
50425 -221 221 221 106 106 106 2 2 6 14 14 14
50426 - 46 46 46 190 190 190 198 198 198 2 2 6
50427 - 2 2 6 2 2 6 2 2 6 2 2 6
50428 - 74 74 74 62 62 62 22 22 22 6 6 6
50429 - 0 0 0 0 0 0 0 0 0 0 0 0
50430 - 0 0 0 0 0 0 0 0 0 0 0 0
50431 - 0 0 0 0 0 0 0 0 0 0 0 0
50432 - 0 0 0 0 0 0 0 0 0 0 0 0
50433 - 0 0 0 0 0 0 0 0 0 0 0 0
50434 - 0 0 0 0 0 0 0 0 0 0 0 0
50435 - 0 0 0 0 0 0 0 0 1 0 0 0
50436 - 0 0 1 0 0 0 0 0 1 0 0 0
50437 - 0 0 0 0 0 0 0 0 0 0 0 0
50438 - 0 0 0 0 0 0 0 0 0 0 0 0
50439 - 0 0 0 0 0 0 0 0 0 0 0 0
50440 - 0 0 0 0 0 0 0 0 0 0 0 0
50441 - 0 0 0 0 0 0 0 0 0 14 14 14
50442 - 42 42 42 94 94 94 14 14 14 101 101 101
50443 -128 128 128 2 2 6 18 18 18 116 116 116
50444 -118 98 46 121 92 8 121 92 8 98 78 10
50445 -162 162 162 106 106 106 2 2 6 2 2 6
50446 - 2 2 6 195 195 195 195 195 195 6 6 6
50447 - 2 2 6 2 2 6 2 2 6 2 2 6
50448 - 74 74 74 62 62 62 22 22 22 6 6 6
50449 - 0 0 0 0 0 0 0 0 0 0 0 0
50450 - 0 0 0 0 0 0 0 0 0 0 0 0
50451 - 0 0 0 0 0 0 0 0 0 0 0 0
50452 - 0 0 0 0 0 0 0 0 0 0 0 0
50453 - 0 0 0 0 0 0 0 0 0 0 0 0
50454 - 0 0 0 0 0 0 0 0 0 0 0 0
50455 - 0 0 0 0 0 0 0 0 1 0 0 1
50456 - 0 0 1 0 0 0 0 0 1 0 0 0
50457 - 0 0 0 0 0 0 0 0 0 0 0 0
50458 - 0 0 0 0 0 0 0 0 0 0 0 0
50459 - 0 0 0 0 0 0 0 0 0 0 0 0
50460 - 0 0 0 0 0 0 0 0 0 0 0 0
50461 - 0 0 0 0 0 0 0 0 0 10 10 10
50462 - 38 38 38 90 90 90 14 14 14 58 58 58
50463 -210 210 210 26 26 26 54 38 6 154 114 10
50464 -226 170 11 236 186 11 225 175 15 184 144 12
50465 -215 174 15 175 146 61 37 26 9 2 2 6
50466 - 70 70 70 246 246 246 138 138 138 2 2 6
50467 - 2 2 6 2 2 6 2 2 6 2 2 6
50468 - 70 70 70 66 66 66 26 26 26 6 6 6
50469 - 0 0 0 0 0 0 0 0 0 0 0 0
50470 - 0 0 0 0 0 0 0 0 0 0 0 0
50471 - 0 0 0 0 0 0 0 0 0 0 0 0
50472 - 0 0 0 0 0 0 0 0 0 0 0 0
50473 - 0 0 0 0 0 0 0 0 0 0 0 0
50474 - 0 0 0 0 0 0 0 0 0 0 0 0
50475 - 0 0 0 0 0 0 0 0 0 0 0 0
50476 - 0 0 0 0 0 0 0 0 0 0 0 0
50477 - 0 0 0 0 0 0 0 0 0 0 0 0
50478 - 0 0 0 0 0 0 0 0 0 0 0 0
50479 - 0 0 0 0 0 0 0 0 0 0 0 0
50480 - 0 0 0 0 0 0 0 0 0 0 0 0
50481 - 0 0 0 0 0 0 0 0 0 10 10 10
50482 - 38 38 38 86 86 86 14 14 14 10 10 10
50483 -195 195 195 188 164 115 192 133 9 225 175 15
50484 -239 182 13 234 190 10 232 195 16 232 200 30
50485 -245 207 45 241 208 19 232 195 16 184 144 12
50486 -218 194 134 211 206 186 42 42 42 2 2 6
50487 - 2 2 6 2 2 6 2 2 6 2 2 6
50488 - 50 50 50 74 74 74 30 30 30 6 6 6
50489 - 0 0 0 0 0 0 0 0 0 0 0 0
50490 - 0 0 0 0 0 0 0 0 0 0 0 0
50491 - 0 0 0 0 0 0 0 0 0 0 0 0
50492 - 0 0 0 0 0 0 0 0 0 0 0 0
50493 - 0 0 0 0 0 0 0 0 0 0 0 0
50494 - 0 0 0 0 0 0 0 0 0 0 0 0
50495 - 0 0 0 0 0 0 0 0 0 0 0 0
50496 - 0 0 0 0 0 0 0 0 0 0 0 0
50497 - 0 0 0 0 0 0 0 0 0 0 0 0
50498 - 0 0 0 0 0 0 0 0 0 0 0 0
50499 - 0 0 0 0 0 0 0 0 0 0 0 0
50500 - 0 0 0 0 0 0 0 0 0 0 0 0
50501 - 0 0 0 0 0 0 0 0 0 10 10 10
50502 - 34 34 34 86 86 86 14 14 14 2 2 6
50503 -121 87 25 192 133 9 219 162 10 239 182 13
50504 -236 186 11 232 195 16 241 208 19 244 214 54
50505 -246 218 60 246 218 38 246 215 20 241 208 19
50506 -241 208 19 226 184 13 121 87 25 2 2 6
50507 - 2 2 6 2 2 6 2 2 6 2 2 6
50508 - 50 50 50 82 82 82 34 34 34 10 10 10
50509 - 0 0 0 0 0 0 0 0 0 0 0 0
50510 - 0 0 0 0 0 0 0 0 0 0 0 0
50511 - 0 0 0 0 0 0 0 0 0 0 0 0
50512 - 0 0 0 0 0 0 0 0 0 0 0 0
50513 - 0 0 0 0 0 0 0 0 0 0 0 0
50514 - 0 0 0 0 0 0 0 0 0 0 0 0
50515 - 0 0 0 0 0 0 0 0 0 0 0 0
50516 - 0 0 0 0 0 0 0 0 0 0 0 0
50517 - 0 0 0 0 0 0 0 0 0 0 0 0
50518 - 0 0 0 0 0 0 0 0 0 0 0 0
50519 - 0 0 0 0 0 0 0 0 0 0 0 0
50520 - 0 0 0 0 0 0 0 0 0 0 0 0
50521 - 0 0 0 0 0 0 0 0 0 10 10 10
50522 - 34 34 34 82 82 82 30 30 30 61 42 6
50523 -180 123 7 206 145 10 230 174 11 239 182 13
50524 -234 190 10 238 202 15 241 208 19 246 218 74
50525 -246 218 38 246 215 20 246 215 20 246 215 20
50526 -226 184 13 215 174 15 184 144 12 6 6 6
50527 - 2 2 6 2 2 6 2 2 6 2 2 6
50528 - 26 26 26 94 94 94 42 42 42 14 14 14
50529 - 0 0 0 0 0 0 0 0 0 0 0 0
50530 - 0 0 0 0 0 0 0 0 0 0 0 0
50531 - 0 0 0 0 0 0 0 0 0 0 0 0
50532 - 0 0 0 0 0 0 0 0 0 0 0 0
50533 - 0 0 0 0 0 0 0 0 0 0 0 0
50534 - 0 0 0 0 0 0 0 0 0 0 0 0
50535 - 0 0 0 0 0 0 0 0 0 0 0 0
50536 - 0 0 0 0 0 0 0 0 0 0 0 0
50537 - 0 0 0 0 0 0 0 0 0 0 0 0
50538 - 0 0 0 0 0 0 0 0 0 0 0 0
50539 - 0 0 0 0 0 0 0 0 0 0 0 0
50540 - 0 0 0 0 0 0 0 0 0 0 0 0
50541 - 0 0 0 0 0 0 0 0 0 10 10 10
50542 - 30 30 30 78 78 78 50 50 50 104 69 6
50543 -192 133 9 216 158 10 236 178 12 236 186 11
50544 -232 195 16 241 208 19 244 214 54 245 215 43
50545 -246 215 20 246 215 20 241 208 19 198 155 10
50546 -200 144 11 216 158 10 156 118 10 2 2 6
50547 - 2 2 6 2 2 6 2 2 6 2 2 6
50548 - 6 6 6 90 90 90 54 54 54 18 18 18
50549 - 6 6 6 0 0 0 0 0 0 0 0 0
50550 - 0 0 0 0 0 0 0 0 0 0 0 0
50551 - 0 0 0 0 0 0 0 0 0 0 0 0
50552 - 0 0 0 0 0 0 0 0 0 0 0 0
50553 - 0 0 0 0 0 0 0 0 0 0 0 0
50554 - 0 0 0 0 0 0 0 0 0 0 0 0
50555 - 0 0 0 0 0 0 0 0 0 0 0 0
50556 - 0 0 0 0 0 0 0 0 0 0 0 0
50557 - 0 0 0 0 0 0 0 0 0 0 0 0
50558 - 0 0 0 0 0 0 0 0 0 0 0 0
50559 - 0 0 0 0 0 0 0 0 0 0 0 0
50560 - 0 0 0 0 0 0 0 0 0 0 0 0
50561 - 0 0 0 0 0 0 0 0 0 10 10 10
50562 - 30 30 30 78 78 78 46 46 46 22 22 22
50563 -137 92 6 210 162 10 239 182 13 238 190 10
50564 -238 202 15 241 208 19 246 215 20 246 215 20
50565 -241 208 19 203 166 17 185 133 11 210 150 10
50566 -216 158 10 210 150 10 102 78 10 2 2 6
50567 - 6 6 6 54 54 54 14 14 14 2 2 6
50568 - 2 2 6 62 62 62 74 74 74 30 30 30
50569 - 10 10 10 0 0 0 0 0 0 0 0 0
50570 - 0 0 0 0 0 0 0 0 0 0 0 0
50571 - 0 0 0 0 0 0 0 0 0 0 0 0
50572 - 0 0 0 0 0 0 0 0 0 0 0 0
50573 - 0 0 0 0 0 0 0 0 0 0 0 0
50574 - 0 0 0 0 0 0 0 0 0 0 0 0
50575 - 0 0 0 0 0 0 0 0 0 0 0 0
50576 - 0 0 0 0 0 0 0 0 0 0 0 0
50577 - 0 0 0 0 0 0 0 0 0 0 0 0
50578 - 0 0 0 0 0 0 0 0 0 0 0 0
50579 - 0 0 0 0 0 0 0 0 0 0 0 0
50580 - 0 0 0 0 0 0 0 0 0 0 0 0
50581 - 0 0 0 0 0 0 0 0 0 10 10 10
50582 - 34 34 34 78 78 78 50 50 50 6 6 6
50583 - 94 70 30 139 102 15 190 146 13 226 184 13
50584 -232 200 30 232 195 16 215 174 15 190 146 13
50585 -168 122 10 192 133 9 210 150 10 213 154 11
50586 -202 150 34 182 157 106 101 98 89 2 2 6
50587 - 2 2 6 78 78 78 116 116 116 58 58 58
50588 - 2 2 6 22 22 22 90 90 90 46 46 46
50589 - 18 18 18 6 6 6 0 0 0 0 0 0
50590 - 0 0 0 0 0 0 0 0 0 0 0 0
50591 - 0 0 0 0 0 0 0 0 0 0 0 0
50592 - 0 0 0 0 0 0 0 0 0 0 0 0
50593 - 0 0 0 0 0 0 0 0 0 0 0 0
50594 - 0 0 0 0 0 0 0 0 0 0 0 0
50595 - 0 0 0 0 0 0 0 0 0 0 0 0
50596 - 0 0 0 0 0 0 0 0 0 0 0 0
50597 - 0 0 0 0 0 0 0 0 0 0 0 0
50598 - 0 0 0 0 0 0 0 0 0 0 0 0
50599 - 0 0 0 0 0 0 0 0 0 0 0 0
50600 - 0 0 0 0 0 0 0 0 0 0 0 0
50601 - 0 0 0 0 0 0 0 0 0 10 10 10
50602 - 38 38 38 86 86 86 50 50 50 6 6 6
50603 -128 128 128 174 154 114 156 107 11 168 122 10
50604 -198 155 10 184 144 12 197 138 11 200 144 11
50605 -206 145 10 206 145 10 197 138 11 188 164 115
50606 -195 195 195 198 198 198 174 174 174 14 14 14
50607 - 2 2 6 22 22 22 116 116 116 116 116 116
50608 - 22 22 22 2 2 6 74 74 74 70 70 70
50609 - 30 30 30 10 10 10 0 0 0 0 0 0
50610 - 0 0 0 0 0 0 0 0 0 0 0 0
50611 - 0 0 0 0 0 0 0 0 0 0 0 0
50612 - 0 0 0 0 0 0 0 0 0 0 0 0
50613 - 0 0 0 0 0 0 0 0 0 0 0 0
50614 - 0 0 0 0 0 0 0 0 0 0 0 0
50615 - 0 0 0 0 0 0 0 0 0 0 0 0
50616 - 0 0 0 0 0 0 0 0 0 0 0 0
50617 - 0 0 0 0 0 0 0 0 0 0 0 0
50618 - 0 0 0 0 0 0 0 0 0 0 0 0
50619 - 0 0 0 0 0 0 0 0 0 0 0 0
50620 - 0 0 0 0 0 0 0 0 0 0 0 0
50621 - 0 0 0 0 0 0 6 6 6 18 18 18
50622 - 50 50 50 101 101 101 26 26 26 10 10 10
50623 -138 138 138 190 190 190 174 154 114 156 107 11
50624 -197 138 11 200 144 11 197 138 11 192 133 9
50625 -180 123 7 190 142 34 190 178 144 187 187 187
50626 -202 202 202 221 221 221 214 214 214 66 66 66
50627 - 2 2 6 2 2 6 50 50 50 62 62 62
50628 - 6 6 6 2 2 6 10 10 10 90 90 90
50629 - 50 50 50 18 18 18 6 6 6 0 0 0
50630 - 0 0 0 0 0 0 0 0 0 0 0 0
50631 - 0 0 0 0 0 0 0 0 0 0 0 0
50632 - 0 0 0 0 0 0 0 0 0 0 0 0
50633 - 0 0 0 0 0 0 0 0 0 0 0 0
50634 - 0 0 0 0 0 0 0 0 0 0 0 0
50635 - 0 0 0 0 0 0 0 0 0 0 0 0
50636 - 0 0 0 0 0 0 0 0 0 0 0 0
50637 - 0 0 0 0 0 0 0 0 0 0 0 0
50638 - 0 0 0 0 0 0 0 0 0 0 0 0
50639 - 0 0 0 0 0 0 0 0 0 0 0 0
50640 - 0 0 0 0 0 0 0 0 0 0 0 0
50641 - 0 0 0 0 0 0 10 10 10 34 34 34
50642 - 74 74 74 74 74 74 2 2 6 6 6 6
50643 -144 144 144 198 198 198 190 190 190 178 166 146
50644 -154 121 60 156 107 11 156 107 11 168 124 44
50645 -174 154 114 187 187 187 190 190 190 210 210 210
50646 -246 246 246 253 253 253 253 253 253 182 182 182
50647 - 6 6 6 2 2 6 2 2 6 2 2 6
50648 - 2 2 6 2 2 6 2 2 6 62 62 62
50649 - 74 74 74 34 34 34 14 14 14 0 0 0
50650 - 0 0 0 0 0 0 0 0 0 0 0 0
50651 - 0 0 0 0 0 0 0 0 0 0 0 0
50652 - 0 0 0 0 0 0 0 0 0 0 0 0
50653 - 0 0 0 0 0 0 0 0 0 0 0 0
50654 - 0 0 0 0 0 0 0 0 0 0 0 0
50655 - 0 0 0 0 0 0 0 0 0 0 0 0
50656 - 0 0 0 0 0 0 0 0 0 0 0 0
50657 - 0 0 0 0 0 0 0 0 0 0 0 0
50658 - 0 0 0 0 0 0 0 0 0 0 0 0
50659 - 0 0 0 0 0 0 0 0 0 0 0 0
50660 - 0 0 0 0 0 0 0 0 0 0 0 0
50661 - 0 0 0 10 10 10 22 22 22 54 54 54
50662 - 94 94 94 18 18 18 2 2 6 46 46 46
50663 -234 234 234 221 221 221 190 190 190 190 190 190
50664 -190 190 190 187 187 187 187 187 187 190 190 190
50665 -190 190 190 195 195 195 214 214 214 242 242 242
50666 -253 253 253 253 253 253 253 253 253 253 253 253
50667 - 82 82 82 2 2 6 2 2 6 2 2 6
50668 - 2 2 6 2 2 6 2 2 6 14 14 14
50669 - 86 86 86 54 54 54 22 22 22 6 6 6
50670 - 0 0 0 0 0 0 0 0 0 0 0 0
50671 - 0 0 0 0 0 0 0 0 0 0 0 0
50672 - 0 0 0 0 0 0 0 0 0 0 0 0
50673 - 0 0 0 0 0 0 0 0 0 0 0 0
50674 - 0 0 0 0 0 0 0 0 0 0 0 0
50675 - 0 0 0 0 0 0 0 0 0 0 0 0
50676 - 0 0 0 0 0 0 0 0 0 0 0 0
50677 - 0 0 0 0 0 0 0 0 0 0 0 0
50678 - 0 0 0 0 0 0 0 0 0 0 0 0
50679 - 0 0 0 0 0 0 0 0 0 0 0 0
50680 - 0 0 0 0 0 0 0 0 0 0 0 0
50681 - 6 6 6 18 18 18 46 46 46 90 90 90
50682 - 46 46 46 18 18 18 6 6 6 182 182 182
50683 -253 253 253 246 246 246 206 206 206 190 190 190
50684 -190 190 190 190 190 190 190 190 190 190 190 190
50685 -206 206 206 231 231 231 250 250 250 253 253 253
50686 -253 253 253 253 253 253 253 253 253 253 253 253
50687 -202 202 202 14 14 14 2 2 6 2 2 6
50688 - 2 2 6 2 2 6 2 2 6 2 2 6
50689 - 42 42 42 86 86 86 42 42 42 18 18 18
50690 - 6 6 6 0 0 0 0 0 0 0 0 0
50691 - 0 0 0 0 0 0 0 0 0 0 0 0
50692 - 0 0 0 0 0 0 0 0 0 0 0 0
50693 - 0 0 0 0 0 0 0 0 0 0 0 0
50694 - 0 0 0 0 0 0 0 0 0 0 0 0
50695 - 0 0 0 0 0 0 0 0 0 0 0 0
50696 - 0 0 0 0 0 0 0 0 0 0 0 0
50697 - 0 0 0 0 0 0 0 0 0 0 0 0
50698 - 0 0 0 0 0 0 0 0 0 0 0 0
50699 - 0 0 0 0 0 0 0 0 0 0 0 0
50700 - 0 0 0 0 0 0 0 0 0 6 6 6
50701 - 14 14 14 38 38 38 74 74 74 66 66 66
50702 - 2 2 6 6 6 6 90 90 90 250 250 250
50703 -253 253 253 253 253 253 238 238 238 198 198 198
50704 -190 190 190 190 190 190 195 195 195 221 221 221
50705 -246 246 246 253 253 253 253 253 253 253 253 253
50706 -253 253 253 253 253 253 253 253 253 253 253 253
50707 -253 253 253 82 82 82 2 2 6 2 2 6
50708 - 2 2 6 2 2 6 2 2 6 2 2 6
50709 - 2 2 6 78 78 78 70 70 70 34 34 34
50710 - 14 14 14 6 6 6 0 0 0 0 0 0
50711 - 0 0 0 0 0 0 0 0 0 0 0 0
50712 - 0 0 0 0 0 0 0 0 0 0 0 0
50713 - 0 0 0 0 0 0 0 0 0 0 0 0
50714 - 0 0 0 0 0 0 0 0 0 0 0 0
50715 - 0 0 0 0 0 0 0 0 0 0 0 0
50716 - 0 0 0 0 0 0 0 0 0 0 0 0
50717 - 0 0 0 0 0 0 0 0 0 0 0 0
50718 - 0 0 0 0 0 0 0 0 0 0 0 0
50719 - 0 0 0 0 0 0 0 0 0 0 0 0
50720 - 0 0 0 0 0 0 0 0 0 14 14 14
50721 - 34 34 34 66 66 66 78 78 78 6 6 6
50722 - 2 2 6 18 18 18 218 218 218 253 253 253
50723 -253 253 253 253 253 253 253 253 253 246 246 246
50724 -226 226 226 231 231 231 246 246 246 253 253 253
50725 -253 253 253 253 253 253 253 253 253 253 253 253
50726 -253 253 253 253 253 253 253 253 253 253 253 253
50727 -253 253 253 178 178 178 2 2 6 2 2 6
50728 - 2 2 6 2 2 6 2 2 6 2 2 6
50729 - 2 2 6 18 18 18 90 90 90 62 62 62
50730 - 30 30 30 10 10 10 0 0 0 0 0 0
50731 - 0 0 0 0 0 0 0 0 0 0 0 0
50732 - 0 0 0 0 0 0 0 0 0 0 0 0
50733 - 0 0 0 0 0 0 0 0 0 0 0 0
50734 - 0 0 0 0 0 0 0 0 0 0 0 0
50735 - 0 0 0 0 0 0 0 0 0 0 0 0
50736 - 0 0 0 0 0 0 0 0 0 0 0 0
50737 - 0 0 0 0 0 0 0 0 0 0 0 0
50738 - 0 0 0 0 0 0 0 0 0 0 0 0
50739 - 0 0 0 0 0 0 0 0 0 0 0 0
50740 - 0 0 0 0 0 0 10 10 10 26 26 26
50741 - 58 58 58 90 90 90 18 18 18 2 2 6
50742 - 2 2 6 110 110 110 253 253 253 253 253 253
50743 -253 253 253 253 253 253 253 253 253 253 253 253
50744 -250 250 250 253 253 253 253 253 253 253 253 253
50745 -253 253 253 253 253 253 253 253 253 253 253 253
50746 -253 253 253 253 253 253 253 253 253 253 253 253
50747 -253 253 253 231 231 231 18 18 18 2 2 6
50748 - 2 2 6 2 2 6 2 2 6 2 2 6
50749 - 2 2 6 2 2 6 18 18 18 94 94 94
50750 - 54 54 54 26 26 26 10 10 10 0 0 0
50751 - 0 0 0 0 0 0 0 0 0 0 0 0
50752 - 0 0 0 0 0 0 0 0 0 0 0 0
50753 - 0 0 0 0 0 0 0 0 0 0 0 0
50754 - 0 0 0 0 0 0 0 0 0 0 0 0
50755 - 0 0 0 0 0 0 0 0 0 0 0 0
50756 - 0 0 0 0 0 0 0 0 0 0 0 0
50757 - 0 0 0 0 0 0 0 0 0 0 0 0
50758 - 0 0 0 0 0 0 0 0 0 0 0 0
50759 - 0 0 0 0 0 0 0 0 0 0 0 0
50760 - 0 0 0 6 6 6 22 22 22 50 50 50
50761 - 90 90 90 26 26 26 2 2 6 2 2 6
50762 - 14 14 14 195 195 195 250 250 250 253 253 253
50763 -253 253 253 253 253 253 253 253 253 253 253 253
50764 -253 253 253 253 253 253 253 253 253 253 253 253
50765 -253 253 253 253 253 253 253 253 253 253 253 253
50766 -253 253 253 253 253 253 253 253 253 253 253 253
50767 -250 250 250 242 242 242 54 54 54 2 2 6
50768 - 2 2 6 2 2 6 2 2 6 2 2 6
50769 - 2 2 6 2 2 6 2 2 6 38 38 38
50770 - 86 86 86 50 50 50 22 22 22 6 6 6
50771 - 0 0 0 0 0 0 0 0 0 0 0 0
50772 - 0 0 0 0 0 0 0 0 0 0 0 0
50773 - 0 0 0 0 0 0 0 0 0 0 0 0
50774 - 0 0 0 0 0 0 0 0 0 0 0 0
50775 - 0 0 0 0 0 0 0 0 0 0 0 0
50776 - 0 0 0 0 0 0 0 0 0 0 0 0
50777 - 0 0 0 0 0 0 0 0 0 0 0 0
50778 - 0 0 0 0 0 0 0 0 0 0 0 0
50779 - 0 0 0 0 0 0 0 0 0 0 0 0
50780 - 6 6 6 14 14 14 38 38 38 82 82 82
50781 - 34 34 34 2 2 6 2 2 6 2 2 6
50782 - 42 42 42 195 195 195 246 246 246 253 253 253
50783 -253 253 253 253 253 253 253 253 253 250 250 250
50784 -242 242 242 242 242 242 250 250 250 253 253 253
50785 -253 253 253 253 253 253 253 253 253 253 253 253
50786 -253 253 253 250 250 250 246 246 246 238 238 238
50787 -226 226 226 231 231 231 101 101 101 6 6 6
50788 - 2 2 6 2 2 6 2 2 6 2 2 6
50789 - 2 2 6 2 2 6 2 2 6 2 2 6
50790 - 38 38 38 82 82 82 42 42 42 14 14 14
50791 - 6 6 6 0 0 0 0 0 0 0 0 0
50792 - 0 0 0 0 0 0 0 0 0 0 0 0
50793 - 0 0 0 0 0 0 0 0 0 0 0 0
50794 - 0 0 0 0 0 0 0 0 0 0 0 0
50795 - 0 0 0 0 0 0 0 0 0 0 0 0
50796 - 0 0 0 0 0 0 0 0 0 0 0 0
50797 - 0 0 0 0 0 0 0 0 0 0 0 0
50798 - 0 0 0 0 0 0 0 0 0 0 0 0
50799 - 0 0 0 0 0 0 0 0 0 0 0 0
50800 - 10 10 10 26 26 26 62 62 62 66 66 66
50801 - 2 2 6 2 2 6 2 2 6 6 6 6
50802 - 70 70 70 170 170 170 206 206 206 234 234 234
50803 -246 246 246 250 250 250 250 250 250 238 238 238
50804 -226 226 226 231 231 231 238 238 238 250 250 250
50805 -250 250 250 250 250 250 246 246 246 231 231 231
50806 -214 214 214 206 206 206 202 202 202 202 202 202
50807 -198 198 198 202 202 202 182 182 182 18 18 18
50808 - 2 2 6 2 2 6 2 2 6 2 2 6
50809 - 2 2 6 2 2 6 2 2 6 2 2 6
50810 - 2 2 6 62 62 62 66 66 66 30 30 30
50811 - 10 10 10 0 0 0 0 0 0 0 0 0
50812 - 0 0 0 0 0 0 0 0 0 0 0 0
50813 - 0 0 0 0 0 0 0 0 0 0 0 0
50814 - 0 0 0 0 0 0 0 0 0 0 0 0
50815 - 0 0 0 0 0 0 0 0 0 0 0 0
50816 - 0 0 0 0 0 0 0 0 0 0 0 0
50817 - 0 0 0 0 0 0 0 0 0 0 0 0
50818 - 0 0 0 0 0 0 0 0 0 0 0 0
50819 - 0 0 0 0 0 0 0 0 0 0 0 0
50820 - 14 14 14 42 42 42 82 82 82 18 18 18
50821 - 2 2 6 2 2 6 2 2 6 10 10 10
50822 - 94 94 94 182 182 182 218 218 218 242 242 242
50823 -250 250 250 253 253 253 253 253 253 250 250 250
50824 -234 234 234 253 253 253 253 253 253 253 253 253
50825 -253 253 253 253 253 253 253 253 253 246 246 246
50826 -238 238 238 226 226 226 210 210 210 202 202 202
50827 -195 195 195 195 195 195 210 210 210 158 158 158
50828 - 6 6 6 14 14 14 50 50 50 14 14 14
50829 - 2 2 6 2 2 6 2 2 6 2 2 6
50830 - 2 2 6 6 6 6 86 86 86 46 46 46
50831 - 18 18 18 6 6 6 0 0 0 0 0 0
50832 - 0 0 0 0 0 0 0 0 0 0 0 0
50833 - 0 0 0 0 0 0 0 0 0 0 0 0
50834 - 0 0 0 0 0 0 0 0 0 0 0 0
50835 - 0 0 0 0 0 0 0 0 0 0 0 0
50836 - 0 0 0 0 0 0 0 0 0 0 0 0
50837 - 0 0 0 0 0 0 0 0 0 0 0 0
50838 - 0 0 0 0 0 0 0 0 0 0 0 0
50839 - 0 0 0 0 0 0 0 0 0 6 6 6
50840 - 22 22 22 54 54 54 70 70 70 2 2 6
50841 - 2 2 6 10 10 10 2 2 6 22 22 22
50842 -166 166 166 231 231 231 250 250 250 253 253 253
50843 -253 253 253 253 253 253 253 253 253 250 250 250
50844 -242 242 242 253 253 253 253 253 253 253 253 253
50845 -253 253 253 253 253 253 253 253 253 253 253 253
50846 -253 253 253 253 253 253 253 253 253 246 246 246
50847 -231 231 231 206 206 206 198 198 198 226 226 226
50848 - 94 94 94 2 2 6 6 6 6 38 38 38
50849 - 30 30 30 2 2 6 2 2 6 2 2 6
50850 - 2 2 6 2 2 6 62 62 62 66 66 66
50851 - 26 26 26 10 10 10 0 0 0 0 0 0
50852 - 0 0 0 0 0 0 0 0 0 0 0 0
50853 - 0 0 0 0 0 0 0 0 0 0 0 0
50854 - 0 0 0 0 0 0 0 0 0 0 0 0
50855 - 0 0 0 0 0 0 0 0 0 0 0 0
50856 - 0 0 0 0 0 0 0 0 0 0 0 0
50857 - 0 0 0 0 0 0 0 0 0 0 0 0
50858 - 0 0 0 0 0 0 0 0 0 0 0 0
50859 - 0 0 0 0 0 0 0 0 0 10 10 10
50860 - 30 30 30 74 74 74 50 50 50 2 2 6
50861 - 26 26 26 26 26 26 2 2 6 106 106 106
50862 -238 238 238 253 253 253 253 253 253 253 253 253
50863 -253 253 253 253 253 253 253 253 253 253 253 253
50864 -253 253 253 253 253 253 253 253 253 253 253 253
50865 -253 253 253 253 253 253 253 253 253 253 253 253
50866 -253 253 253 253 253 253 253 253 253 253 253 253
50867 -253 253 253 246 246 246 218 218 218 202 202 202
50868 -210 210 210 14 14 14 2 2 6 2 2 6
50869 - 30 30 30 22 22 22 2 2 6 2 2 6
50870 - 2 2 6 2 2 6 18 18 18 86 86 86
50871 - 42 42 42 14 14 14 0 0 0 0 0 0
50872 - 0 0 0 0 0 0 0 0 0 0 0 0
50873 - 0 0 0 0 0 0 0 0 0 0 0 0
50874 - 0 0 0 0 0 0 0 0 0 0 0 0
50875 - 0 0 0 0 0 0 0 0 0 0 0 0
50876 - 0 0 0 0 0 0 0 0 0 0 0 0
50877 - 0 0 0 0 0 0 0 0 0 0 0 0
50878 - 0 0 0 0 0 0 0 0 0 0 0 0
50879 - 0 0 0 0 0 0 0 0 0 14 14 14
50880 - 42 42 42 90 90 90 22 22 22 2 2 6
50881 - 42 42 42 2 2 6 18 18 18 218 218 218
50882 -253 253 253 253 253 253 253 253 253 253 253 253
50883 -253 253 253 253 253 253 253 253 253 253 253 253
50884 -253 253 253 253 253 253 253 253 253 253 253 253
50885 -253 253 253 253 253 253 253 253 253 253 253 253
50886 -253 253 253 253 253 253 253 253 253 253 253 253
50887 -253 253 253 253 253 253 250 250 250 221 221 221
50888 -218 218 218 101 101 101 2 2 6 14 14 14
50889 - 18 18 18 38 38 38 10 10 10 2 2 6
50890 - 2 2 6 2 2 6 2 2 6 78 78 78
50891 - 58 58 58 22 22 22 6 6 6 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 - 0 0 0 0 0 0 0 0 0 0 0 0
50895 - 0 0 0 0 0 0 0 0 0 0 0 0
50896 - 0 0 0 0 0 0 0 0 0 0 0 0
50897 - 0 0 0 0 0 0 0 0 0 0 0 0
50898 - 0 0 0 0 0 0 0 0 0 0 0 0
50899 - 0 0 0 0 0 0 6 6 6 18 18 18
50900 - 54 54 54 82 82 82 2 2 6 26 26 26
50901 - 22 22 22 2 2 6 123 123 123 253 253 253
50902 -253 253 253 253 253 253 253 253 253 253 253 253
50903 -253 253 253 253 253 253 253 253 253 253 253 253
50904 -253 253 253 253 253 253 253 253 253 253 253 253
50905 -253 253 253 253 253 253 253 253 253 253 253 253
50906 -253 253 253 253 253 253 253 253 253 253 253 253
50907 -253 253 253 253 253 253 253 253 253 250 250 250
50908 -238 238 238 198 198 198 6 6 6 38 38 38
50909 - 58 58 58 26 26 26 38 38 38 2 2 6
50910 - 2 2 6 2 2 6 2 2 6 46 46 46
50911 - 78 78 78 30 30 30 10 10 10 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 0 0 0
50915 - 0 0 0 0 0 0 0 0 0 0 0 0
50916 - 0 0 0 0 0 0 0 0 0 0 0 0
50917 - 0 0 0 0 0 0 0 0 0 0 0 0
50918 - 0 0 0 0 0 0 0 0 0 0 0 0
50919 - 0 0 0 0 0 0 10 10 10 30 30 30
50920 - 74 74 74 58 58 58 2 2 6 42 42 42
50921 - 2 2 6 22 22 22 231 231 231 253 253 253
50922 -253 253 253 253 253 253 253 253 253 253 253 253
50923 -253 253 253 253 253 253 253 253 253 250 250 250
50924 -253 253 253 253 253 253 253 253 253 253 253 253
50925 -253 253 253 253 253 253 253 253 253 253 253 253
50926 -253 253 253 253 253 253 253 253 253 253 253 253
50927 -253 253 253 253 253 253 253 253 253 253 253 253
50928 -253 253 253 246 246 246 46 46 46 38 38 38
50929 - 42 42 42 14 14 14 38 38 38 14 14 14
50930 - 2 2 6 2 2 6 2 2 6 6 6 6
50931 - 86 86 86 46 46 46 14 14 14 0 0 0
50932 - 0 0 0 0 0 0 0 0 0 0 0 0
50933 - 0 0 0 0 0 0 0 0 0 0 0 0
50934 - 0 0 0 0 0 0 0 0 0 0 0 0
50935 - 0 0 0 0 0 0 0 0 0 0 0 0
50936 - 0 0 0 0 0 0 0 0 0 0 0 0
50937 - 0 0 0 0 0 0 0 0 0 0 0 0
50938 - 0 0 0 0 0 0 0 0 0 0 0 0
50939 - 0 0 0 6 6 6 14 14 14 42 42 42
50940 - 90 90 90 18 18 18 18 18 18 26 26 26
50941 - 2 2 6 116 116 116 253 253 253 253 253 253
50942 -253 253 253 253 253 253 253 253 253 253 253 253
50943 -253 253 253 253 253 253 250 250 250 238 238 238
50944 -253 253 253 253 253 253 253 253 253 253 253 253
50945 -253 253 253 253 253 253 253 253 253 253 253 253
50946 -253 253 253 253 253 253 253 253 253 253 253 253
50947 -253 253 253 253 253 253 253 253 253 253 253 253
50948 -253 253 253 253 253 253 94 94 94 6 6 6
50949 - 2 2 6 2 2 6 10 10 10 34 34 34
50950 - 2 2 6 2 2 6 2 2 6 2 2 6
50951 - 74 74 74 58 58 58 22 22 22 6 6 6
50952 - 0 0 0 0 0 0 0 0 0 0 0 0
50953 - 0 0 0 0 0 0 0 0 0 0 0 0
50954 - 0 0 0 0 0 0 0 0 0 0 0 0
50955 - 0 0 0 0 0 0 0 0 0 0 0 0
50956 - 0 0 0 0 0 0 0 0 0 0 0 0
50957 - 0 0 0 0 0 0 0 0 0 0 0 0
50958 - 0 0 0 0 0 0 0 0 0 0 0 0
50959 - 0 0 0 10 10 10 26 26 26 66 66 66
50960 - 82 82 82 2 2 6 38 38 38 6 6 6
50961 - 14 14 14 210 210 210 253 253 253 253 253 253
50962 -253 253 253 253 253 253 253 253 253 253 253 253
50963 -253 253 253 253 253 253 246 246 246 242 242 242
50964 -253 253 253 253 253 253 253 253 253 253 253 253
50965 -253 253 253 253 253 253 253 253 253 253 253 253
50966 -253 253 253 253 253 253 253 253 253 253 253 253
50967 -253 253 253 253 253 253 253 253 253 253 253 253
50968 -253 253 253 253 253 253 144 144 144 2 2 6
50969 - 2 2 6 2 2 6 2 2 6 46 46 46
50970 - 2 2 6 2 2 6 2 2 6 2 2 6
50971 - 42 42 42 74 74 74 30 30 30 10 10 10
50972 - 0 0 0 0 0 0 0 0 0 0 0 0
50973 - 0 0 0 0 0 0 0 0 0 0 0 0
50974 - 0 0 0 0 0 0 0 0 0 0 0 0
50975 - 0 0 0 0 0 0 0 0 0 0 0 0
50976 - 0 0 0 0 0 0 0 0 0 0 0 0
50977 - 0 0 0 0 0 0 0 0 0 0 0 0
50978 - 0 0 0 0 0 0 0 0 0 0 0 0
50979 - 6 6 6 14 14 14 42 42 42 90 90 90
50980 - 26 26 26 6 6 6 42 42 42 2 2 6
50981 - 74 74 74 250 250 250 253 253 253 253 253 253
50982 -253 253 253 253 253 253 253 253 253 253 253 253
50983 -253 253 253 253 253 253 242 242 242 242 242 242
50984 -253 253 253 253 253 253 253 253 253 253 253 253
50985 -253 253 253 253 253 253 253 253 253 253 253 253
50986 -253 253 253 253 253 253 253 253 253 253 253 253
50987 -253 253 253 253 253 253 253 253 253 253 253 253
50988 -253 253 253 253 253 253 182 182 182 2 2 6
50989 - 2 2 6 2 2 6 2 2 6 46 46 46
50990 - 2 2 6 2 2 6 2 2 6 2 2 6
50991 - 10 10 10 86 86 86 38 38 38 10 10 10
50992 - 0 0 0 0 0 0 0 0 0 0 0 0
50993 - 0 0 0 0 0 0 0 0 0 0 0 0
50994 - 0 0 0 0 0 0 0 0 0 0 0 0
50995 - 0 0 0 0 0 0 0 0 0 0 0 0
50996 - 0 0 0 0 0 0 0 0 0 0 0 0
50997 - 0 0 0 0 0 0 0 0 0 0 0 0
50998 - 0 0 0 0 0 0 0 0 0 0 0 0
50999 - 10 10 10 26 26 26 66 66 66 82 82 82
51000 - 2 2 6 22 22 22 18 18 18 2 2 6
51001 -149 149 149 253 253 253 253 253 253 253 253 253
51002 -253 253 253 253 253 253 253 253 253 253 253 253
51003 -253 253 253 253 253 253 234 234 234 242 242 242
51004 -253 253 253 253 253 253 253 253 253 253 253 253
51005 -253 253 253 253 253 253 253 253 253 253 253 253
51006 -253 253 253 253 253 253 253 253 253 253 253 253
51007 -253 253 253 253 253 253 253 253 253 253 253 253
51008 -253 253 253 253 253 253 206 206 206 2 2 6
51009 - 2 2 6 2 2 6 2 2 6 38 38 38
51010 - 2 2 6 2 2 6 2 2 6 2 2 6
51011 - 6 6 6 86 86 86 46 46 46 14 14 14
51012 - 0 0 0 0 0 0 0 0 0 0 0 0
51013 - 0 0 0 0 0 0 0 0 0 0 0 0
51014 - 0 0 0 0 0 0 0 0 0 0 0 0
51015 - 0 0 0 0 0 0 0 0 0 0 0 0
51016 - 0 0 0 0 0 0 0 0 0 0 0 0
51017 - 0 0 0 0 0 0 0 0 0 0 0 0
51018 - 0 0 0 0 0 0 0 0 0 6 6 6
51019 - 18 18 18 46 46 46 86 86 86 18 18 18
51020 - 2 2 6 34 34 34 10 10 10 6 6 6
51021 -210 210 210 253 253 253 253 253 253 253 253 253
51022 -253 253 253 253 253 253 253 253 253 253 253 253
51023 -253 253 253 253 253 253 234 234 234 242 242 242
51024 -253 253 253 253 253 253 253 253 253 253 253 253
51025 -253 253 253 253 253 253 253 253 253 253 253 253
51026 -253 253 253 253 253 253 253 253 253 253 253 253
51027 -253 253 253 253 253 253 253 253 253 253 253 253
51028 -253 253 253 253 253 253 221 221 221 6 6 6
51029 - 2 2 6 2 2 6 6 6 6 30 30 30
51030 - 2 2 6 2 2 6 2 2 6 2 2 6
51031 - 2 2 6 82 82 82 54 54 54 18 18 18
51032 - 6 6 6 0 0 0 0 0 0 0 0 0
51033 - 0 0 0 0 0 0 0 0 0 0 0 0
51034 - 0 0 0 0 0 0 0 0 0 0 0 0
51035 - 0 0 0 0 0 0 0 0 0 0 0 0
51036 - 0 0 0 0 0 0 0 0 0 0 0 0
51037 - 0 0 0 0 0 0 0 0 0 0 0 0
51038 - 0 0 0 0 0 0 0 0 0 10 10 10
51039 - 26 26 26 66 66 66 62 62 62 2 2 6
51040 - 2 2 6 38 38 38 10 10 10 26 26 26
51041 -238 238 238 253 253 253 253 253 253 253 253 253
51042 -253 253 253 253 253 253 253 253 253 253 253 253
51043 -253 253 253 253 253 253 231 231 231 238 238 238
51044 -253 253 253 253 253 253 253 253 253 253 253 253
51045 -253 253 253 253 253 253 253 253 253 253 253 253
51046 -253 253 253 253 253 253 253 253 253 253 253 253
51047 -253 253 253 253 253 253 253 253 253 253 253 253
51048 -253 253 253 253 253 253 231 231 231 6 6 6
51049 - 2 2 6 2 2 6 10 10 10 30 30 30
51050 - 2 2 6 2 2 6 2 2 6 2 2 6
51051 - 2 2 6 66 66 66 58 58 58 22 22 22
51052 - 6 6 6 0 0 0 0 0 0 0 0 0
51053 - 0 0 0 0 0 0 0 0 0 0 0 0
51054 - 0 0 0 0 0 0 0 0 0 0 0 0
51055 - 0 0 0 0 0 0 0 0 0 0 0 0
51056 - 0 0 0 0 0 0 0 0 0 0 0 0
51057 - 0 0 0 0 0 0 0 0 0 0 0 0
51058 - 0 0 0 0 0 0 0 0 0 10 10 10
51059 - 38 38 38 78 78 78 6 6 6 2 2 6
51060 - 2 2 6 46 46 46 14 14 14 42 42 42
51061 -246 246 246 253 253 253 253 253 253 253 253 253
51062 -253 253 253 253 253 253 253 253 253 253 253 253
51063 -253 253 253 253 253 253 231 231 231 242 242 242
51064 -253 253 253 253 253 253 253 253 253 253 253 253
51065 -253 253 253 253 253 253 253 253 253 253 253 253
51066 -253 253 253 253 253 253 253 253 253 253 253 253
51067 -253 253 253 253 253 253 253 253 253 253 253 253
51068 -253 253 253 253 253 253 234 234 234 10 10 10
51069 - 2 2 6 2 2 6 22 22 22 14 14 14
51070 - 2 2 6 2 2 6 2 2 6 2 2 6
51071 - 2 2 6 66 66 66 62 62 62 22 22 22
51072 - 6 6 6 0 0 0 0 0 0 0 0 0
51073 - 0 0 0 0 0 0 0 0 0 0 0 0
51074 - 0 0 0 0 0 0 0 0 0 0 0 0
51075 - 0 0 0 0 0 0 0 0 0 0 0 0
51076 - 0 0 0 0 0 0 0 0 0 0 0 0
51077 - 0 0 0 0 0 0 0 0 0 0 0 0
51078 - 0 0 0 0 0 0 6 6 6 18 18 18
51079 - 50 50 50 74 74 74 2 2 6 2 2 6
51080 - 14 14 14 70 70 70 34 34 34 62 62 62
51081 -250 250 250 253 253 253 253 253 253 253 253 253
51082 -253 253 253 253 253 253 253 253 253 253 253 253
51083 -253 253 253 253 253 253 231 231 231 246 246 246
51084 -253 253 253 253 253 253 253 253 253 253 253 253
51085 -253 253 253 253 253 253 253 253 253 253 253 253
51086 -253 253 253 253 253 253 253 253 253 253 253 253
51087 -253 253 253 253 253 253 253 253 253 253 253 253
51088 -253 253 253 253 253 253 234 234 234 14 14 14
51089 - 2 2 6 2 2 6 30 30 30 2 2 6
51090 - 2 2 6 2 2 6 2 2 6 2 2 6
51091 - 2 2 6 66 66 66 62 62 62 22 22 22
51092 - 6 6 6 0 0 0 0 0 0 0 0 0
51093 - 0 0 0 0 0 0 0 0 0 0 0 0
51094 - 0 0 0 0 0 0 0 0 0 0 0 0
51095 - 0 0 0 0 0 0 0 0 0 0 0 0
51096 - 0 0 0 0 0 0 0 0 0 0 0 0
51097 - 0 0 0 0 0 0 0 0 0 0 0 0
51098 - 0 0 0 0 0 0 6 6 6 18 18 18
51099 - 54 54 54 62 62 62 2 2 6 2 2 6
51100 - 2 2 6 30 30 30 46 46 46 70 70 70
51101 -250 250 250 253 253 253 253 253 253 253 253 253
51102 -253 253 253 253 253 253 253 253 253 253 253 253
51103 -253 253 253 253 253 253 231 231 231 246 246 246
51104 -253 253 253 253 253 253 253 253 253 253 253 253
51105 -253 253 253 253 253 253 253 253 253 253 253 253
51106 -253 253 253 253 253 253 253 253 253 253 253 253
51107 -253 253 253 253 253 253 253 253 253 253 253 253
51108 -253 253 253 253 253 253 226 226 226 10 10 10
51109 - 2 2 6 6 6 6 30 30 30 2 2 6
51110 - 2 2 6 2 2 6 2 2 6 2 2 6
51111 - 2 2 6 66 66 66 58 58 58 22 22 22
51112 - 6 6 6 0 0 0 0 0 0 0 0 0
51113 - 0 0 0 0 0 0 0 0 0 0 0 0
51114 - 0 0 0 0 0 0 0 0 0 0 0 0
51115 - 0 0 0 0 0 0 0 0 0 0 0 0
51116 - 0 0 0 0 0 0 0 0 0 0 0 0
51117 - 0 0 0 0 0 0 0 0 0 0 0 0
51118 - 0 0 0 0 0 0 6 6 6 22 22 22
51119 - 58 58 58 62 62 62 2 2 6 2 2 6
51120 - 2 2 6 2 2 6 30 30 30 78 78 78
51121 -250 250 250 253 253 253 253 253 253 253 253 253
51122 -253 253 253 253 253 253 253 253 253 253 253 253
51123 -253 253 253 253 253 253 231 231 231 246 246 246
51124 -253 253 253 253 253 253 253 253 253 253 253 253
51125 -253 253 253 253 253 253 253 253 253 253 253 253
51126 -253 253 253 253 253 253 253 253 253 253 253 253
51127 -253 253 253 253 253 253 253 253 253 253 253 253
51128 -253 253 253 253 253 253 206 206 206 2 2 6
51129 - 22 22 22 34 34 34 18 14 6 22 22 22
51130 - 26 26 26 18 18 18 6 6 6 2 2 6
51131 - 2 2 6 82 82 82 54 54 54 18 18 18
51132 - 6 6 6 0 0 0 0 0 0 0 0 0
51133 - 0 0 0 0 0 0 0 0 0 0 0 0
51134 - 0 0 0 0 0 0 0 0 0 0 0 0
51135 - 0 0 0 0 0 0 0 0 0 0 0 0
51136 - 0 0 0 0 0 0 0 0 0 0 0 0
51137 - 0 0 0 0 0 0 0 0 0 0 0 0
51138 - 0 0 0 0 0 0 6 6 6 26 26 26
51139 - 62 62 62 106 106 106 74 54 14 185 133 11
51140 -210 162 10 121 92 8 6 6 6 62 62 62
51141 -238 238 238 253 253 253 253 253 253 253 253 253
51142 -253 253 253 253 253 253 253 253 253 253 253 253
51143 -253 253 253 253 253 253 231 231 231 246 246 246
51144 -253 253 253 253 253 253 253 253 253 253 253 253
51145 -253 253 253 253 253 253 253 253 253 253 253 253
51146 -253 253 253 253 253 253 253 253 253 253 253 253
51147 -253 253 253 253 253 253 253 253 253 253 253 253
51148 -253 253 253 253 253 253 158 158 158 18 18 18
51149 - 14 14 14 2 2 6 2 2 6 2 2 6
51150 - 6 6 6 18 18 18 66 66 66 38 38 38
51151 - 6 6 6 94 94 94 50 50 50 18 18 18
51152 - 6 6 6 0 0 0 0 0 0 0 0 0
51153 - 0 0 0 0 0 0 0 0 0 0 0 0
51154 - 0 0 0 0 0 0 0 0 0 0 0 0
51155 - 0 0 0 0 0 0 0 0 0 0 0 0
51156 - 0 0 0 0 0 0 0 0 0 0 0 0
51157 - 0 0 0 0 0 0 0 0 0 6 6 6
51158 - 10 10 10 10 10 10 18 18 18 38 38 38
51159 - 78 78 78 142 134 106 216 158 10 242 186 14
51160 -246 190 14 246 190 14 156 118 10 10 10 10
51161 - 90 90 90 238 238 238 253 253 253 253 253 253
51162 -253 253 253 253 253 253 253 253 253 253 253 253
51163 -253 253 253 253 253 253 231 231 231 250 250 250
51164 -253 253 253 253 253 253 253 253 253 253 253 253
51165 -253 253 253 253 253 253 253 253 253 253 253 253
51166 -253 253 253 253 253 253 253 253 253 253 253 253
51167 -253 253 253 253 253 253 253 253 253 246 230 190
51168 -238 204 91 238 204 91 181 142 44 37 26 9
51169 - 2 2 6 2 2 6 2 2 6 2 2 6
51170 - 2 2 6 2 2 6 38 38 38 46 46 46
51171 - 26 26 26 106 106 106 54 54 54 18 18 18
51172 - 6 6 6 0 0 0 0 0 0 0 0 0
51173 - 0 0 0 0 0 0 0 0 0 0 0 0
51174 - 0 0 0 0 0 0 0 0 0 0 0 0
51175 - 0 0 0 0 0 0 0 0 0 0 0 0
51176 - 0 0 0 0 0 0 0 0 0 0 0 0
51177 - 0 0 0 6 6 6 14 14 14 22 22 22
51178 - 30 30 30 38 38 38 50 50 50 70 70 70
51179 -106 106 106 190 142 34 226 170 11 242 186 14
51180 -246 190 14 246 190 14 246 190 14 154 114 10
51181 - 6 6 6 74 74 74 226 226 226 253 253 253
51182 -253 253 253 253 253 253 253 253 253 253 253 253
51183 -253 253 253 253 253 253 231 231 231 250 250 250
51184 -253 253 253 253 253 253 253 253 253 253 253 253
51185 -253 253 253 253 253 253 253 253 253 253 253 253
51186 -253 253 253 253 253 253 253 253 253 253 253 253
51187 -253 253 253 253 253 253 253 253 253 228 184 62
51188 -241 196 14 241 208 19 232 195 16 38 30 10
51189 - 2 2 6 2 2 6 2 2 6 2 2 6
51190 - 2 2 6 6 6 6 30 30 30 26 26 26
51191 -203 166 17 154 142 90 66 66 66 26 26 26
51192 - 6 6 6 0 0 0 0 0 0 0 0 0
51193 - 0 0 0 0 0 0 0 0 0 0 0 0
51194 - 0 0 0 0 0 0 0 0 0 0 0 0
51195 - 0 0 0 0 0 0 0 0 0 0 0 0
51196 - 0 0 0 0 0 0 0 0 0 0 0 0
51197 - 6 6 6 18 18 18 38 38 38 58 58 58
51198 - 78 78 78 86 86 86 101 101 101 123 123 123
51199 -175 146 61 210 150 10 234 174 13 246 186 14
51200 -246 190 14 246 190 14 246 190 14 238 190 10
51201 -102 78 10 2 2 6 46 46 46 198 198 198
51202 -253 253 253 253 253 253 253 253 253 253 253 253
51203 -253 253 253 253 253 253 234 234 234 242 242 242
51204 -253 253 253 253 253 253 253 253 253 253 253 253
51205 -253 253 253 253 253 253 253 253 253 253 253 253
51206 -253 253 253 253 253 253 253 253 253 253 253 253
51207 -253 253 253 253 253 253 253 253 253 224 178 62
51208 -242 186 14 241 196 14 210 166 10 22 18 6
51209 - 2 2 6 2 2 6 2 2 6 2 2 6
51210 - 2 2 6 2 2 6 6 6 6 121 92 8
51211 -238 202 15 232 195 16 82 82 82 34 34 34
51212 - 10 10 10 0 0 0 0 0 0 0 0 0
51213 - 0 0 0 0 0 0 0 0 0 0 0 0
51214 - 0 0 0 0 0 0 0 0 0 0 0 0
51215 - 0 0 0 0 0 0 0 0 0 0 0 0
51216 - 0 0 0 0 0 0 0 0 0 0 0 0
51217 - 14 14 14 38 38 38 70 70 70 154 122 46
51218 -190 142 34 200 144 11 197 138 11 197 138 11
51219 -213 154 11 226 170 11 242 186 14 246 190 14
51220 -246 190 14 246 190 14 246 190 14 246 190 14
51221 -225 175 15 46 32 6 2 2 6 22 22 22
51222 -158 158 158 250 250 250 253 253 253 253 253 253
51223 -253 253 253 253 253 253 253 253 253 253 253 253
51224 -253 253 253 253 253 253 253 253 253 253 253 253
51225 -253 253 253 253 253 253 253 253 253 253 253 253
51226 -253 253 253 253 253 253 253 253 253 253 253 253
51227 -253 253 253 250 250 250 242 242 242 224 178 62
51228 -239 182 13 236 186 11 213 154 11 46 32 6
51229 - 2 2 6 2 2 6 2 2 6 2 2 6
51230 - 2 2 6 2 2 6 61 42 6 225 175 15
51231 -238 190 10 236 186 11 112 100 78 42 42 42
51232 - 14 14 14 0 0 0 0 0 0 0 0 0
51233 - 0 0 0 0 0 0 0 0 0 0 0 0
51234 - 0 0 0 0 0 0 0 0 0 0 0 0
51235 - 0 0 0 0 0 0 0 0 0 0 0 0
51236 - 0 0 0 0 0 0 0 0 0 6 6 6
51237 - 22 22 22 54 54 54 154 122 46 213 154 11
51238 -226 170 11 230 174 11 226 170 11 226 170 11
51239 -236 178 12 242 186 14 246 190 14 246 190 14
51240 -246 190 14 246 190 14 246 190 14 246 190 14
51241 -241 196 14 184 144 12 10 10 10 2 2 6
51242 - 6 6 6 116 116 116 242 242 242 253 253 253
51243 -253 253 253 253 253 253 253 253 253 253 253 253
51244 -253 253 253 253 253 253 253 253 253 253 253 253
51245 -253 253 253 253 253 253 253 253 253 253 253 253
51246 -253 253 253 253 253 253 253 253 253 253 253 253
51247 -253 253 253 231 231 231 198 198 198 214 170 54
51248 -236 178 12 236 178 12 210 150 10 137 92 6
51249 - 18 14 6 2 2 6 2 2 6 2 2 6
51250 - 6 6 6 70 47 6 200 144 11 236 178 12
51251 -239 182 13 239 182 13 124 112 88 58 58 58
51252 - 22 22 22 6 6 6 0 0 0 0 0 0
51253 - 0 0 0 0 0 0 0 0 0 0 0 0
51254 - 0 0 0 0 0 0 0 0 0 0 0 0
51255 - 0 0 0 0 0 0 0 0 0 0 0 0
51256 - 0 0 0 0 0 0 0 0 0 10 10 10
51257 - 30 30 30 70 70 70 180 133 36 226 170 11
51258 -239 182 13 242 186 14 242 186 14 246 186 14
51259 -246 190 14 246 190 14 246 190 14 246 190 14
51260 -246 190 14 246 190 14 246 190 14 246 190 14
51261 -246 190 14 232 195 16 98 70 6 2 2 6
51262 - 2 2 6 2 2 6 66 66 66 221 221 221
51263 -253 253 253 253 253 253 253 253 253 253 253 253
51264 -253 253 253 253 253 253 253 253 253 253 253 253
51265 -253 253 253 253 253 253 253 253 253 253 253 253
51266 -253 253 253 253 253 253 253 253 253 253 253 253
51267 -253 253 253 206 206 206 198 198 198 214 166 58
51268 -230 174 11 230 174 11 216 158 10 192 133 9
51269 -163 110 8 116 81 8 102 78 10 116 81 8
51270 -167 114 7 197 138 11 226 170 11 239 182 13
51271 -242 186 14 242 186 14 162 146 94 78 78 78
51272 - 34 34 34 14 14 14 6 6 6 0 0 0
51273 - 0 0 0 0 0 0 0 0 0 0 0 0
51274 - 0 0 0 0 0 0 0 0 0 0 0 0
51275 - 0 0 0 0 0 0 0 0 0 0 0 0
51276 - 0 0 0 0 0 0 0 0 0 6 6 6
51277 - 30 30 30 78 78 78 190 142 34 226 170 11
51278 -239 182 13 246 190 14 246 190 14 246 190 14
51279 -246 190 14 246 190 14 246 190 14 246 190 14
51280 -246 190 14 246 190 14 246 190 14 246 190 14
51281 -246 190 14 241 196 14 203 166 17 22 18 6
51282 - 2 2 6 2 2 6 2 2 6 38 38 38
51283 -218 218 218 253 253 253 253 253 253 253 253 253
51284 -253 253 253 253 253 253 253 253 253 253 253 253
51285 -253 253 253 253 253 253 253 253 253 253 253 253
51286 -253 253 253 253 253 253 253 253 253 253 253 253
51287 -250 250 250 206 206 206 198 198 198 202 162 69
51288 -226 170 11 236 178 12 224 166 10 210 150 10
51289 -200 144 11 197 138 11 192 133 9 197 138 11
51290 -210 150 10 226 170 11 242 186 14 246 190 14
51291 -246 190 14 246 186 14 225 175 15 124 112 88
51292 - 62 62 62 30 30 30 14 14 14 6 6 6
51293 - 0 0 0 0 0 0 0 0 0 0 0 0
51294 - 0 0 0 0 0 0 0 0 0 0 0 0
51295 - 0 0 0 0 0 0 0 0 0 0 0 0
51296 - 0 0 0 0 0 0 0 0 0 10 10 10
51297 - 30 30 30 78 78 78 174 135 50 224 166 10
51298 -239 182 13 246 190 14 246 190 14 246 190 14
51299 -246 190 14 246 190 14 246 190 14 246 190 14
51300 -246 190 14 246 190 14 246 190 14 246 190 14
51301 -246 190 14 246 190 14 241 196 14 139 102 15
51302 - 2 2 6 2 2 6 2 2 6 2 2 6
51303 - 78 78 78 250 250 250 253 253 253 253 253 253
51304 -253 253 253 253 253 253 253 253 253 253 253 253
51305 -253 253 253 253 253 253 253 253 253 253 253 253
51306 -253 253 253 253 253 253 253 253 253 253 253 253
51307 -250 250 250 214 214 214 198 198 198 190 150 46
51308 -219 162 10 236 178 12 234 174 13 224 166 10
51309 -216 158 10 213 154 11 213 154 11 216 158 10
51310 -226 170 11 239 182 13 246 190 14 246 190 14
51311 -246 190 14 246 190 14 242 186 14 206 162 42
51312 -101 101 101 58 58 58 30 30 30 14 14 14
51313 - 6 6 6 0 0 0 0 0 0 0 0 0
51314 - 0 0 0 0 0 0 0 0 0 0 0 0
51315 - 0 0 0 0 0 0 0 0 0 0 0 0
51316 - 0 0 0 0 0 0 0 0 0 10 10 10
51317 - 30 30 30 74 74 74 174 135 50 216 158 10
51318 -236 178 12 246 190 14 246 190 14 246 190 14
51319 -246 190 14 246 190 14 246 190 14 246 190 14
51320 -246 190 14 246 190 14 246 190 14 246 190 14
51321 -246 190 14 246 190 14 241 196 14 226 184 13
51322 - 61 42 6 2 2 6 2 2 6 2 2 6
51323 - 22 22 22 238 238 238 253 253 253 253 253 253
51324 -253 253 253 253 253 253 253 253 253 253 253 253
51325 -253 253 253 253 253 253 253 253 253 253 253 253
51326 -253 253 253 253 253 253 253 253 253 253 253 253
51327 -253 253 253 226 226 226 187 187 187 180 133 36
51328 -216 158 10 236 178 12 239 182 13 236 178 12
51329 -230 174 11 226 170 11 226 170 11 230 174 11
51330 -236 178 12 242 186 14 246 190 14 246 190 14
51331 -246 190 14 246 190 14 246 186 14 239 182 13
51332 -206 162 42 106 106 106 66 66 66 34 34 34
51333 - 14 14 14 6 6 6 0 0 0 0 0 0
51334 - 0 0 0 0 0 0 0 0 0 0 0 0
51335 - 0 0 0 0 0 0 0 0 0 0 0 0
51336 - 0 0 0 0 0 0 0 0 0 6 6 6
51337 - 26 26 26 70 70 70 163 133 67 213 154 11
51338 -236 178 12 246 190 14 246 190 14 246 190 14
51339 -246 190 14 246 190 14 246 190 14 246 190 14
51340 -246 190 14 246 190 14 246 190 14 246 190 14
51341 -246 190 14 246 190 14 246 190 14 241 196 14
51342 -190 146 13 18 14 6 2 2 6 2 2 6
51343 - 46 46 46 246 246 246 253 253 253 253 253 253
51344 -253 253 253 253 253 253 253 253 253 253 253 253
51345 -253 253 253 253 253 253 253 253 253 253 253 253
51346 -253 253 253 253 253 253 253 253 253 253 253 253
51347 -253 253 253 221 221 221 86 86 86 156 107 11
51348 -216 158 10 236 178 12 242 186 14 246 186 14
51349 -242 186 14 239 182 13 239 182 13 242 186 14
51350 -242 186 14 246 186 14 246 190 14 246 190 14
51351 -246 190 14 246 190 14 246 190 14 246 190 14
51352 -242 186 14 225 175 15 142 122 72 66 66 66
51353 - 30 30 30 10 10 10 0 0 0 0 0 0
51354 - 0 0 0 0 0 0 0 0 0 0 0 0
51355 - 0 0 0 0 0 0 0 0 0 0 0 0
51356 - 0 0 0 0 0 0 0 0 0 6 6 6
51357 - 26 26 26 70 70 70 163 133 67 210 150 10
51358 -236 178 12 246 190 14 246 190 14 246 190 14
51359 -246 190 14 246 190 14 246 190 14 246 190 14
51360 -246 190 14 246 190 14 246 190 14 246 190 14
51361 -246 190 14 246 190 14 246 190 14 246 190 14
51362 -232 195 16 121 92 8 34 34 34 106 106 106
51363 -221 221 221 253 253 253 253 253 253 253 253 253
51364 -253 253 253 253 253 253 253 253 253 253 253 253
51365 -253 253 253 253 253 253 253 253 253 253 253 253
51366 -253 253 253 253 253 253 253 253 253 253 253 253
51367 -242 242 242 82 82 82 18 14 6 163 110 8
51368 -216 158 10 236 178 12 242 186 14 246 190 14
51369 -246 190 14 246 190 14 246 190 14 246 190 14
51370 -246 190 14 246 190 14 246 190 14 246 190 14
51371 -246 190 14 246 190 14 246 190 14 246 190 14
51372 -246 190 14 246 190 14 242 186 14 163 133 67
51373 - 46 46 46 18 18 18 6 6 6 0 0 0
51374 - 0 0 0 0 0 0 0 0 0 0 0 0
51375 - 0 0 0 0 0 0 0 0 0 0 0 0
51376 - 0 0 0 0 0 0 0 0 0 10 10 10
51377 - 30 30 30 78 78 78 163 133 67 210 150 10
51378 -236 178 12 246 186 14 246 190 14 246 190 14
51379 -246 190 14 246 190 14 246 190 14 246 190 14
51380 -246 190 14 246 190 14 246 190 14 246 190 14
51381 -246 190 14 246 190 14 246 190 14 246 190 14
51382 -241 196 14 215 174 15 190 178 144 253 253 253
51383 -253 253 253 253 253 253 253 253 253 253 253 253
51384 -253 253 253 253 253 253 253 253 253 253 253 253
51385 -253 253 253 253 253 253 253 253 253 253 253 253
51386 -253 253 253 253 253 253 253 253 253 218 218 218
51387 - 58 58 58 2 2 6 22 18 6 167 114 7
51388 -216 158 10 236 178 12 246 186 14 246 190 14
51389 -246 190 14 246 190 14 246 190 14 246 190 14
51390 -246 190 14 246 190 14 246 190 14 246 190 14
51391 -246 190 14 246 190 14 246 190 14 246 190 14
51392 -246 190 14 246 186 14 242 186 14 190 150 46
51393 - 54 54 54 22 22 22 6 6 6 0 0 0
51394 - 0 0 0 0 0 0 0 0 0 0 0 0
51395 - 0 0 0 0 0 0 0 0 0 0 0 0
51396 - 0 0 0 0 0 0 0 0 0 14 14 14
51397 - 38 38 38 86 86 86 180 133 36 213 154 11
51398 -236 178 12 246 186 14 246 190 14 246 190 14
51399 -246 190 14 246 190 14 246 190 14 246 190 14
51400 -246 190 14 246 190 14 246 190 14 246 190 14
51401 -246 190 14 246 190 14 246 190 14 246 190 14
51402 -246 190 14 232 195 16 190 146 13 214 214 214
51403 -253 253 253 253 253 253 253 253 253 253 253 253
51404 -253 253 253 253 253 253 253 253 253 253 253 253
51405 -253 253 253 253 253 253 253 253 253 253 253 253
51406 -253 253 253 250 250 250 170 170 170 26 26 26
51407 - 2 2 6 2 2 6 37 26 9 163 110 8
51408 -219 162 10 239 182 13 246 186 14 246 190 14
51409 -246 190 14 246 190 14 246 190 14 246 190 14
51410 -246 190 14 246 190 14 246 190 14 246 190 14
51411 -246 190 14 246 190 14 246 190 14 246 190 14
51412 -246 186 14 236 178 12 224 166 10 142 122 72
51413 - 46 46 46 18 18 18 6 6 6 0 0 0
51414 - 0 0 0 0 0 0 0 0 0 0 0 0
51415 - 0 0 0 0 0 0 0 0 0 0 0 0
51416 - 0 0 0 0 0 0 6 6 6 18 18 18
51417 - 50 50 50 109 106 95 192 133 9 224 166 10
51418 -242 186 14 246 190 14 246 190 14 246 190 14
51419 -246 190 14 246 190 14 246 190 14 246 190 14
51420 -246 190 14 246 190 14 246 190 14 246 190 14
51421 -246 190 14 246 190 14 246 190 14 246 190 14
51422 -242 186 14 226 184 13 210 162 10 142 110 46
51423 -226 226 226 253 253 253 253 253 253 253 253 253
51424 -253 253 253 253 253 253 253 253 253 253 253 253
51425 -253 253 253 253 253 253 253 253 253 253 253 253
51426 -198 198 198 66 66 66 2 2 6 2 2 6
51427 - 2 2 6 2 2 6 50 34 6 156 107 11
51428 -219 162 10 239 182 13 246 186 14 246 190 14
51429 -246 190 14 246 190 14 246 190 14 246 190 14
51430 -246 190 14 246 190 14 246 190 14 246 190 14
51431 -246 190 14 246 190 14 246 190 14 242 186 14
51432 -234 174 13 213 154 11 154 122 46 66 66 66
51433 - 30 30 30 10 10 10 0 0 0 0 0 0
51434 - 0 0 0 0 0 0 0 0 0 0 0 0
51435 - 0 0 0 0 0 0 0 0 0 0 0 0
51436 - 0 0 0 0 0 0 6 6 6 22 22 22
51437 - 58 58 58 154 121 60 206 145 10 234 174 13
51438 -242 186 14 246 186 14 246 190 14 246 190 14
51439 -246 190 14 246 190 14 246 190 14 246 190 14
51440 -246 190 14 246 190 14 246 190 14 246 190 14
51441 -246 190 14 246 190 14 246 190 14 246 190 14
51442 -246 186 14 236 178 12 210 162 10 163 110 8
51443 - 61 42 6 138 138 138 218 218 218 250 250 250
51444 -253 253 253 253 253 253 253 253 253 250 250 250
51445 -242 242 242 210 210 210 144 144 144 66 66 66
51446 - 6 6 6 2 2 6 2 2 6 2 2 6
51447 - 2 2 6 2 2 6 61 42 6 163 110 8
51448 -216 158 10 236 178 12 246 190 14 246 190 14
51449 -246 190 14 246 190 14 246 190 14 246 190 14
51450 -246 190 14 246 190 14 246 190 14 246 190 14
51451 -246 190 14 239 182 13 230 174 11 216 158 10
51452 -190 142 34 124 112 88 70 70 70 38 38 38
51453 - 18 18 18 6 6 6 0 0 0 0 0 0
51454 - 0 0 0 0 0 0 0 0 0 0 0 0
51455 - 0 0 0 0 0 0 0 0 0 0 0 0
51456 - 0 0 0 0 0 0 6 6 6 22 22 22
51457 - 62 62 62 168 124 44 206 145 10 224 166 10
51458 -236 178 12 239 182 13 242 186 14 242 186 14
51459 -246 186 14 246 190 14 246 190 14 246 190 14
51460 -246 190 14 246 190 14 246 190 14 246 190 14
51461 -246 190 14 246 190 14 246 190 14 246 190 14
51462 -246 190 14 236 178 12 216 158 10 175 118 6
51463 - 80 54 7 2 2 6 6 6 6 30 30 30
51464 - 54 54 54 62 62 62 50 50 50 38 38 38
51465 - 14 14 14 2 2 6 2 2 6 2 2 6
51466 - 2 2 6 2 2 6 2 2 6 2 2 6
51467 - 2 2 6 6 6 6 80 54 7 167 114 7
51468 -213 154 11 236 178 12 246 190 14 246 190 14
51469 -246 190 14 246 190 14 246 190 14 246 190 14
51470 -246 190 14 242 186 14 239 182 13 239 182 13
51471 -230 174 11 210 150 10 174 135 50 124 112 88
51472 - 82 82 82 54 54 54 34 34 34 18 18 18
51473 - 6 6 6 0 0 0 0 0 0 0 0 0
51474 - 0 0 0 0 0 0 0 0 0 0 0 0
51475 - 0 0 0 0 0 0 0 0 0 0 0 0
51476 - 0 0 0 0 0 0 6 6 6 18 18 18
51477 - 50 50 50 158 118 36 192 133 9 200 144 11
51478 -216 158 10 219 162 10 224 166 10 226 170 11
51479 -230 174 11 236 178 12 239 182 13 239 182 13
51480 -242 186 14 246 186 14 246 190 14 246 190 14
51481 -246 190 14 246 190 14 246 190 14 246 190 14
51482 -246 186 14 230 174 11 210 150 10 163 110 8
51483 -104 69 6 10 10 10 2 2 6 2 2 6
51484 - 2 2 6 2 2 6 2 2 6 2 2 6
51485 - 2 2 6 2 2 6 2 2 6 2 2 6
51486 - 2 2 6 2 2 6 2 2 6 2 2 6
51487 - 2 2 6 6 6 6 91 60 6 167 114 7
51488 -206 145 10 230 174 11 242 186 14 246 190 14
51489 -246 190 14 246 190 14 246 186 14 242 186 14
51490 -239 182 13 230 174 11 224 166 10 213 154 11
51491 -180 133 36 124 112 88 86 86 86 58 58 58
51492 - 38 38 38 22 22 22 10 10 10 6 6 6
51493 - 0 0 0 0 0 0 0 0 0 0 0 0
51494 - 0 0 0 0 0 0 0 0 0 0 0 0
51495 - 0 0 0 0 0 0 0 0 0 0 0 0
51496 - 0 0 0 0 0 0 0 0 0 14 14 14
51497 - 34 34 34 70 70 70 138 110 50 158 118 36
51498 -167 114 7 180 123 7 192 133 9 197 138 11
51499 -200 144 11 206 145 10 213 154 11 219 162 10
51500 -224 166 10 230 174 11 239 182 13 242 186 14
51501 -246 186 14 246 186 14 246 186 14 246 186 14
51502 -239 182 13 216 158 10 185 133 11 152 99 6
51503 -104 69 6 18 14 6 2 2 6 2 2 6
51504 - 2 2 6 2 2 6 2 2 6 2 2 6
51505 - 2 2 6 2 2 6 2 2 6 2 2 6
51506 - 2 2 6 2 2 6 2 2 6 2 2 6
51507 - 2 2 6 6 6 6 80 54 7 152 99 6
51508 -192 133 9 219 162 10 236 178 12 239 182 13
51509 -246 186 14 242 186 14 239 182 13 236 178 12
51510 -224 166 10 206 145 10 192 133 9 154 121 60
51511 - 94 94 94 62 62 62 42 42 42 22 22 22
51512 - 14 14 14 6 6 6 0 0 0 0 0 0
51513 - 0 0 0 0 0 0 0 0 0 0 0 0
51514 - 0 0 0 0 0 0 0 0 0 0 0 0
51515 - 0 0 0 0 0 0 0 0 0 0 0 0
51516 - 0 0 0 0 0 0 0 0 0 6 6 6
51517 - 18 18 18 34 34 34 58 58 58 78 78 78
51518 -101 98 89 124 112 88 142 110 46 156 107 11
51519 -163 110 8 167 114 7 175 118 6 180 123 7
51520 -185 133 11 197 138 11 210 150 10 219 162 10
51521 -226 170 11 236 178 12 236 178 12 234 174 13
51522 -219 162 10 197 138 11 163 110 8 130 83 6
51523 - 91 60 6 10 10 10 2 2 6 2 2 6
51524 - 18 18 18 38 38 38 38 38 38 38 38 38
51525 - 38 38 38 38 38 38 38 38 38 38 38 38
51526 - 38 38 38 38 38 38 26 26 26 2 2 6
51527 - 2 2 6 6 6 6 70 47 6 137 92 6
51528 -175 118 6 200 144 11 219 162 10 230 174 11
51529 -234 174 13 230 174 11 219 162 10 210 150 10
51530 -192 133 9 163 110 8 124 112 88 82 82 82
51531 - 50 50 50 30 30 30 14 14 14 6 6 6
51532 - 0 0 0 0 0 0 0 0 0 0 0 0
51533 - 0 0 0 0 0 0 0 0 0 0 0 0
51534 - 0 0 0 0 0 0 0 0 0 0 0 0
51535 - 0 0 0 0 0 0 0 0 0 0 0 0
51536 - 0 0 0 0 0 0 0 0 0 0 0 0
51537 - 6 6 6 14 14 14 22 22 22 34 34 34
51538 - 42 42 42 58 58 58 74 74 74 86 86 86
51539 -101 98 89 122 102 70 130 98 46 121 87 25
51540 -137 92 6 152 99 6 163 110 8 180 123 7
51541 -185 133 11 197 138 11 206 145 10 200 144 11
51542 -180 123 7 156 107 11 130 83 6 104 69 6
51543 - 50 34 6 54 54 54 110 110 110 101 98 89
51544 - 86 86 86 82 82 82 78 78 78 78 78 78
51545 - 78 78 78 78 78 78 78 78 78 78 78 78
51546 - 78 78 78 82 82 82 86 86 86 94 94 94
51547 -106 106 106 101 101 101 86 66 34 124 80 6
51548 -156 107 11 180 123 7 192 133 9 200 144 11
51549 -206 145 10 200 144 11 192 133 9 175 118 6
51550 -139 102 15 109 106 95 70 70 70 42 42 42
51551 - 22 22 22 10 10 10 0 0 0 0 0 0
51552 - 0 0 0 0 0 0 0 0 0 0 0 0
51553 - 0 0 0 0 0 0 0 0 0 0 0 0
51554 - 0 0 0 0 0 0 0 0 0 0 0 0
51555 - 0 0 0 0 0 0 0 0 0 0 0 0
51556 - 0 0 0 0 0 0 0 0 0 0 0 0
51557 - 0 0 0 0 0 0 6 6 6 10 10 10
51558 - 14 14 14 22 22 22 30 30 30 38 38 38
51559 - 50 50 50 62 62 62 74 74 74 90 90 90
51560 -101 98 89 112 100 78 121 87 25 124 80 6
51561 -137 92 6 152 99 6 152 99 6 152 99 6
51562 -138 86 6 124 80 6 98 70 6 86 66 30
51563 -101 98 89 82 82 82 58 58 58 46 46 46
51564 - 38 38 38 34 34 34 34 34 34 34 34 34
51565 - 34 34 34 34 34 34 34 34 34 34 34 34
51566 - 34 34 34 34 34 34 38 38 38 42 42 42
51567 - 54 54 54 82 82 82 94 86 76 91 60 6
51568 -134 86 6 156 107 11 167 114 7 175 118 6
51569 -175 118 6 167 114 7 152 99 6 121 87 25
51570 -101 98 89 62 62 62 34 34 34 18 18 18
51571 - 6 6 6 0 0 0 0 0 0 0 0 0
51572 - 0 0 0 0 0 0 0 0 0 0 0 0
51573 - 0 0 0 0 0 0 0 0 0 0 0 0
51574 - 0 0 0 0 0 0 0 0 0 0 0 0
51575 - 0 0 0 0 0 0 0 0 0 0 0 0
51576 - 0 0 0 0 0 0 0 0 0 0 0 0
51577 - 0 0 0 0 0 0 0 0 0 0 0 0
51578 - 0 0 0 6 6 6 6 6 6 10 10 10
51579 - 18 18 18 22 22 22 30 30 30 42 42 42
51580 - 50 50 50 66 66 66 86 86 86 101 98 89
51581 -106 86 58 98 70 6 104 69 6 104 69 6
51582 -104 69 6 91 60 6 82 62 34 90 90 90
51583 - 62 62 62 38 38 38 22 22 22 14 14 14
51584 - 10 10 10 10 10 10 10 10 10 10 10 10
51585 - 10 10 10 10 10 10 6 6 6 10 10 10
51586 - 10 10 10 10 10 10 10 10 10 14 14 14
51587 - 22 22 22 42 42 42 70 70 70 89 81 66
51588 - 80 54 7 104 69 6 124 80 6 137 92 6
51589 -134 86 6 116 81 8 100 82 52 86 86 86
51590 - 58 58 58 30 30 30 14 14 14 6 6 6
51591 - 0 0 0 0 0 0 0 0 0 0 0 0
51592 - 0 0 0 0 0 0 0 0 0 0 0 0
51593 - 0 0 0 0 0 0 0 0 0 0 0 0
51594 - 0 0 0 0 0 0 0 0 0 0 0 0
51595 - 0 0 0 0 0 0 0 0 0 0 0 0
51596 - 0 0 0 0 0 0 0 0 0 0 0 0
51597 - 0 0 0 0 0 0 0 0 0 0 0 0
51598 - 0 0 0 0 0 0 0 0 0 0 0 0
51599 - 0 0 0 6 6 6 10 10 10 14 14 14
51600 - 18 18 18 26 26 26 38 38 38 54 54 54
51601 - 70 70 70 86 86 86 94 86 76 89 81 66
51602 - 89 81 66 86 86 86 74 74 74 50 50 50
51603 - 30 30 30 14 14 14 6 6 6 0 0 0
51604 - 0 0 0 0 0 0 0 0 0 0 0 0
51605 - 0 0 0 0 0 0 0 0 0 0 0 0
51606 - 0 0 0 0 0 0 0 0 0 0 0 0
51607 - 6 6 6 18 18 18 34 34 34 58 58 58
51608 - 82 82 82 89 81 66 89 81 66 89 81 66
51609 - 94 86 66 94 86 76 74 74 74 50 50 50
51610 - 26 26 26 14 14 14 6 6 6 0 0 0
51611 - 0 0 0 0 0 0 0 0 0 0 0 0
51612 - 0 0 0 0 0 0 0 0 0 0 0 0
51613 - 0 0 0 0 0 0 0 0 0 0 0 0
51614 - 0 0 0 0 0 0 0 0 0 0 0 0
51615 - 0 0 0 0 0 0 0 0 0 0 0 0
51616 - 0 0 0 0 0 0 0 0 0 0 0 0
51617 - 0 0 0 0 0 0 0 0 0 0 0 0
51618 - 0 0 0 0 0 0 0 0 0 0 0 0
51619 - 0 0 0 0 0 0 0 0 0 0 0 0
51620 - 6 6 6 6 6 6 14 14 14 18 18 18
51621 - 30 30 30 38 38 38 46 46 46 54 54 54
51622 - 50 50 50 42 42 42 30 30 30 18 18 18
51623 - 10 10 10 0 0 0 0 0 0 0 0 0
51624 - 0 0 0 0 0 0 0 0 0 0 0 0
51625 - 0 0 0 0 0 0 0 0 0 0 0 0
51626 - 0 0 0 0 0 0 0 0 0 0 0 0
51627 - 0 0 0 6 6 6 14 14 14 26 26 26
51628 - 38 38 38 50 50 50 58 58 58 58 58 58
51629 - 54 54 54 42 42 42 30 30 30 18 18 18
51630 - 10 10 10 0 0 0 0 0 0 0 0 0
51631 - 0 0 0 0 0 0 0 0 0 0 0 0
51632 - 0 0 0 0 0 0 0 0 0 0 0 0
51633 - 0 0 0 0 0 0 0 0 0 0 0 0
51634 - 0 0 0 0 0 0 0 0 0 0 0 0
51635 - 0 0 0 0 0 0 0 0 0 0 0 0
51636 - 0 0 0 0 0 0 0 0 0 0 0 0
51637 - 0 0 0 0 0 0 0 0 0 0 0 0
51638 - 0 0 0 0 0 0 0 0 0 0 0 0
51639 - 0 0 0 0 0 0 0 0 0 0 0 0
51640 - 0 0 0 0 0 0 0 0 0 6 6 6
51641 - 6 6 6 10 10 10 14 14 14 18 18 18
51642 - 18 18 18 14 14 14 10 10 10 6 6 6
51643 - 0 0 0 0 0 0 0 0 0 0 0 0
51644 - 0 0 0 0 0 0 0 0 0 0 0 0
51645 - 0 0 0 0 0 0 0 0 0 0 0 0
51646 - 0 0 0 0 0 0 0 0 0 0 0 0
51647 - 0 0 0 0 0 0 0 0 0 6 6 6
51648 - 14 14 14 18 18 18 22 22 22 22 22 22
51649 - 18 18 18 14 14 14 10 10 10 6 6 6
51650 - 0 0 0 0 0 0 0 0 0 0 0 0
51651 - 0 0 0 0 0 0 0 0 0 0 0 0
51652 - 0 0 0 0 0 0 0 0 0 0 0 0
51653 - 0 0 0 0 0 0 0 0 0 0 0 0
51654 - 0 0 0 0 0 0 0 0 0 0 0 0
51655 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51662 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51666 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51667 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51668 +4 4 4 4 4 4
51669 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51676 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51680 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51681 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51682 +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 4 4 4 4 4 4 4 4 4 4 4 4
51685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51690 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51694 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51695 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51696 +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 4 4 4 4 4 4 4 4 4 4 4 4
51699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51704 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51709 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51710 +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 4 4 4 4 4 4 4 4 4 4 4 4
51713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51718 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51723 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51724 +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 4 4 4 4 4 4 4 4 4 4 4 4
51727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51732 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51737 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51738 +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 4 4 4 4 4 4 4 4 4 4 4 4
51741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51743 +4 4 4 4 4 4 4 4 4 3 3 3 0 0 0 0 0 0
51744 +0 0 0 0 0 0 0 0 0 0 0 0 3 3 3 4 4 4
51745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51746 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51748 +4 4 4 4 4 4 4 4 4 4 4 4 1 1 1 0 0 0
51749 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51750 +4 4 4 4 4 4 4 4 4 2 1 0 2 1 0 3 2 2
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
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 4 4 4 4 4 4 4 4 4 4 4 4
51755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51757 +4 4 4 4 4 4 2 2 2 0 0 0 3 4 3 26 28 28
51758 +37 38 37 37 38 37 14 17 19 2 2 2 0 0 0 2 2 2
51759 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51760 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51762 +4 4 4 4 4 4 3 3 3 0 0 0 1 1 1 6 6 6
51763 +2 2 2 0 0 0 3 3 3 4 4 4 4 4 4 4 4 4
51764 +4 4 5 3 3 3 1 0 0 0 0 0 1 0 0 0 0 0
51765 +1 1 1 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51766 +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 4 4 4 4 4 4 4 4 4 4 4 4
51769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51771 +2 2 2 0 0 0 0 0 0 14 17 19 60 74 84 137 136 137
51772 +153 152 153 137 136 137 125 124 125 60 73 81 6 6 6 3 1 0
51773 +0 0 0 3 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51774 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51775 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51776 +4 4 4 4 4 4 0 0 0 4 4 4 41 54 63 125 124 125
51777 +60 73 81 6 6 6 4 0 0 3 3 3 4 4 4 4 4 4
51778 +4 4 4 0 0 0 6 9 11 41 54 63 41 65 82 22 30 35
51779 +2 2 2 2 1 0 4 4 4 4 4 4 4 4 4 4 4 4
51780 +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 4 4 4 4 4 4 4 4 4 4 4 4
51783 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51784 +4 4 4 4 4 4 5 5 5 5 5 5 2 2 2 0 0 0
51785 +4 0 0 6 6 6 41 54 63 137 136 137 174 174 174 167 166 167
51786 +165 164 165 165 164 165 163 162 163 163 162 163 125 124 125 41 54 63
51787 +1 1 1 0 0 0 0 0 0 3 3 3 5 5 5 4 4 4
51788 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51789 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51790 +3 3 3 2 0 0 4 0 0 60 73 81 156 155 156 167 166 167
51791 +163 162 163 85 115 134 5 7 8 0 0 0 4 4 4 5 5 5
51792 +0 0 0 2 5 5 55 98 126 90 154 193 90 154 193 72 125 159
51793 +37 51 59 2 0 0 1 1 1 4 5 5 4 4 4 4 4 4
51794 +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 4 4 4 4 4 4 4 4 4 4 4 4
51797 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
51798 +4 4 4 5 5 5 4 4 4 1 1 1 0 0 0 3 3 3
51799 +37 38 37 125 124 125 163 162 163 174 174 174 158 157 158 158 157 158
51800 +156 155 156 156 155 156 158 157 158 165 164 165 174 174 174 166 165 166
51801 +125 124 125 16 19 21 1 0 0 0 0 0 0 0 0 4 4 4
51802 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
51803 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 1 1 1
51804 +0 0 0 0 0 0 37 38 37 153 152 153 174 174 174 158 157 158
51805 +174 174 174 163 162 163 37 38 37 4 3 3 4 0 0 1 1 1
51806 +0 0 0 22 40 52 101 161 196 101 161 196 90 154 193 101 161 196
51807 +64 123 161 14 17 19 0 0 0 4 4 4 4 4 4 4 4 4
51808 +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 4 4 4 4 4 4 4 4 4 4 4 4
51811 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
51812 +5 5 5 2 2 2 0 0 0 4 0 0 24 26 27 85 115 134
51813 +156 155 156 174 174 174 167 166 167 156 155 156 154 153 154 157 156 157
51814 +156 155 156 156 155 156 155 154 155 153 152 153 158 157 158 167 166 167
51815 +174 174 174 156 155 156 60 74 84 16 19 21 0 0 0 0 0 0
51816 +1 1 1 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
51817 +4 4 4 5 5 5 6 6 6 3 3 3 0 0 0 4 0 0
51818 +13 16 17 60 73 81 137 136 137 165 164 165 156 155 156 153 152 153
51819 +174 174 174 177 184 187 60 73 81 3 1 0 0 0 0 1 1 2
51820 +22 30 35 64 123 161 136 185 209 90 154 193 90 154 193 90 154 193
51821 +90 154 193 21 29 34 0 0 0 3 2 2 4 4 5 4 4 4
51822 +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 4 4 4 4 4 4 4 4 4 4 4 4
51825 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 3 3 3
51826 +0 0 0 0 0 0 10 13 16 60 74 84 157 156 157 174 174 174
51827 +174 174 174 158 157 158 153 152 153 154 153 154 156 155 156 155 154 155
51828 +156 155 156 155 154 155 154 153 154 157 156 157 154 153 154 153 152 153
51829 +163 162 163 174 174 174 177 184 187 137 136 137 60 73 81 13 16 17
51830 +4 0 0 0 0 0 3 3 3 5 5 5 4 4 4 4 4 4
51831 +5 5 5 4 4 4 1 1 1 0 0 0 3 3 3 41 54 63
51832 +131 129 131 174 174 174 174 174 174 174 174 174 167 166 167 174 174 174
51833 +190 197 201 137 136 137 24 26 27 4 0 0 16 21 25 50 82 103
51834 +90 154 193 136 185 209 90 154 193 101 161 196 101 161 196 101 161 196
51835 +31 91 132 3 6 7 0 0 0 4 4 4 4 4 4 4 4 4
51836 +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 4 4 4 4 4 4 4 4 4 4 4 4
51839 +4 4 4 4 4 4 4 4 4 2 2 2 0 0 0 4 0 0
51840 +4 0 0 43 57 68 137 136 137 177 184 187 174 174 174 163 162 163
51841 +155 154 155 155 154 155 156 155 156 155 154 155 158 157 158 165 164 165
51842 +167 166 167 166 165 166 163 162 163 157 156 157 155 154 155 155 154 155
51843 +153 152 153 156 155 156 167 166 167 174 174 174 174 174 174 131 129 131
51844 +41 54 63 5 5 5 0 0 0 0 0 0 3 3 3 4 4 4
51845 +1 1 1 0 0 0 1 0 0 26 28 28 125 124 125 174 174 174
51846 +177 184 187 174 174 174 174 174 174 156 155 156 131 129 131 137 136 137
51847 +125 124 125 24 26 27 4 0 0 41 65 82 90 154 193 136 185 209
51848 +136 185 209 101 161 196 53 118 160 37 112 160 90 154 193 34 86 122
51849 +7 12 15 0 0 0 4 4 4 4 4 4 4 4 4 4 4 4
51850 +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 4 4 4 4 4 4 4 4 4 4 4 4
51853 +4 4 4 3 3 3 0 0 0 0 0 0 5 5 5 37 38 37
51854 +125 124 125 167 166 167 174 174 174 167 166 167 158 157 158 155 154 155
51855 +156 155 156 156 155 156 156 155 156 163 162 163 167 166 167 155 154 155
51856 +137 136 137 153 152 153 156 155 156 165 164 165 163 162 163 156 155 156
51857 +156 155 156 156 155 156 155 154 155 158 157 158 166 165 166 174 174 174
51858 +167 166 167 125 124 125 37 38 37 1 0 0 0 0 0 0 0 0
51859 +0 0 0 24 26 27 60 74 84 158 157 158 174 174 174 174 174 174
51860 +166 165 166 158 157 158 125 124 125 41 54 63 13 16 17 6 6 6
51861 +6 6 6 37 38 37 80 127 157 136 185 209 101 161 196 101 161 196
51862 +90 154 193 28 67 93 6 10 14 13 20 25 13 20 25 6 10 14
51863 +1 1 2 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4
51864 +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 4 4 4 4 4 4 4 4 4 4 4 4
51867 +1 1 1 1 0 0 4 3 3 37 38 37 60 74 84 153 152 153
51868 +167 166 167 167 166 167 158 157 158 154 153 154 155 154 155 156 155 156
51869 +157 156 157 158 157 158 167 166 167 167 166 167 131 129 131 43 57 68
51870 +26 28 28 37 38 37 60 73 81 131 129 131 165 164 165 166 165 166
51871 +158 157 158 155 154 155 156 155 156 156 155 156 156 155 156 158 157 158
51872 +165 164 165 174 174 174 163 162 163 60 74 84 16 19 21 13 16 17
51873 +60 73 81 131 129 131 174 174 174 174 174 174 167 166 167 165 164 165
51874 +137 136 137 60 73 81 24 26 27 4 0 0 4 0 0 16 19 21
51875 +52 104 138 101 161 196 136 185 209 136 185 209 90 154 193 27 99 146
51876 +13 20 25 4 5 7 2 5 5 4 5 7 1 1 2 0 0 0
51877 +4 4 4 4 4 4 3 3 3 2 2 2 2 2 2 4 4 4
51878 +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 4 4 4 4 4 4 3 3 3 0 0 0
51881 +0 0 0 13 16 17 60 73 81 137 136 137 174 174 174 166 165 166
51882 +158 157 158 156 155 156 157 156 157 156 155 156 155 154 155 158 157 158
51883 +167 166 167 174 174 174 153 152 153 60 73 81 16 19 21 4 0 0
51884 +4 0 0 4 0 0 6 6 6 26 28 28 60 74 84 158 157 158
51885 +174 174 174 166 165 166 157 156 157 155 154 155 156 155 156 156 155 156
51886 +155 154 155 158 157 158 167 166 167 167 166 167 131 129 131 125 124 125
51887 +137 136 137 167 166 167 167 166 167 174 174 174 158 157 158 125 124 125
51888 +16 19 21 4 0 0 4 0 0 10 13 16 49 76 92 107 159 188
51889 +136 185 209 136 185 209 90 154 193 26 108 161 22 40 52 6 10 14
51890 +2 3 3 1 1 2 1 1 2 4 4 5 4 4 5 4 4 5
51891 +4 4 5 2 2 1 0 0 0 0 0 0 0 0 0 2 2 2
51892 +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 5 5 5 3 3 3 0 0 0 1 0 0 4 0 0
51895 +37 51 59 131 129 131 167 166 167 167 166 167 163 162 163 157 156 157
51896 +157 156 157 155 154 155 153 152 153 157 156 157 167 166 167 174 174 174
51897 +153 152 153 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
51898 +4 3 3 4 3 3 4 0 0 6 6 6 4 0 0 37 38 37
51899 +125 124 125 174 174 174 174 174 174 165 164 165 156 155 156 154 153 154
51900 +156 155 156 156 155 156 155 154 155 163 162 163 158 157 158 163 162 163
51901 +174 174 174 174 174 174 174 174 174 125 124 125 37 38 37 0 0 0
51902 +4 0 0 6 9 11 41 54 63 90 154 193 136 185 209 146 190 211
51903 +136 185 209 37 112 160 22 40 52 6 10 14 3 6 7 1 1 2
51904 +1 1 2 3 3 3 1 1 2 3 3 3 4 4 4 4 4 4
51905 +2 2 2 2 0 0 16 19 21 37 38 37 24 26 27 0 0 0
51906 +0 0 0 4 4 4
51907 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 5 5 5
51908 +4 4 4 0 0 0 0 0 0 0 0 0 26 28 28 120 125 127
51909 +158 157 158 174 174 174 165 164 165 157 156 157 155 154 155 156 155 156
51910 +153 152 153 153 152 153 167 166 167 174 174 174 174 174 174 125 124 125
51911 +37 38 37 4 0 0 0 0 0 4 0 0 4 3 3 4 4 4
51912 +4 4 4 4 4 4 5 5 5 4 0 0 4 0 0 4 0 0
51913 +4 3 3 43 57 68 137 136 137 174 174 174 174 174 174 165 164 165
51914 +154 153 154 153 152 153 153 152 153 153 152 153 163 162 163 174 174 174
51915 +174 174 174 153 152 153 60 73 81 6 6 6 4 0 0 4 3 3
51916 +32 43 50 80 127 157 136 185 209 146 190 211 146 190 211 90 154 193
51917 +28 67 93 28 67 93 40 71 93 3 6 7 1 1 2 2 5 5
51918 +50 82 103 79 117 143 26 37 45 0 0 0 3 3 3 1 1 1
51919 +0 0 0 41 54 63 137 136 137 174 174 174 153 152 153 60 73 81
51920 +2 0 0 0 0 0
51921 +4 4 4 4 4 4 4 4 4 4 4 4 6 6 6 2 2 2
51922 +0 0 0 2 0 0 24 26 27 60 74 84 153 152 153 174 174 174
51923 +174 174 174 157 156 157 154 153 154 156 155 156 154 153 154 153 152 153
51924 +165 164 165 174 174 174 177 184 187 137 136 137 43 57 68 6 6 6
51925 +4 0 0 2 0 0 3 3 3 5 5 5 5 5 5 4 4 4
51926 +4 4 4 4 4 4 4 4 4 5 5 5 6 6 6 4 3 3
51927 +4 0 0 4 0 0 24 26 27 60 73 81 153 152 153 174 174 174
51928 +174 174 174 158 157 158 158 157 158 174 174 174 174 174 174 158 157 158
51929 +60 74 84 24 26 27 4 0 0 4 0 0 17 23 27 59 113 148
51930 +136 185 209 191 222 234 146 190 211 136 185 209 31 91 132 7 11 13
51931 +22 40 52 101 161 196 90 154 193 6 9 11 3 4 4 43 95 132
51932 +136 185 209 172 205 220 55 98 126 0 0 0 0 0 0 2 0 0
51933 +26 28 28 153 152 153 177 184 187 167 166 167 177 184 187 165 164 165
51934 +37 38 37 0 0 0
51935 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
51936 +13 16 17 60 73 81 137 136 137 174 174 174 174 174 174 165 164 165
51937 +153 152 153 153 152 153 155 154 155 154 153 154 158 157 158 174 174 174
51938 +177 184 187 163 162 163 60 73 81 16 19 21 4 0 0 4 0 0
51939 +4 3 3 4 4 4 5 5 5 5 5 5 4 4 4 5 5 5
51940 +5 5 5 5 5 5 5 5 5 4 4 4 4 4 4 5 5 5
51941 +6 6 6 4 0 0 4 0 0 4 0 0 24 26 27 60 74 84
51942 +166 165 166 174 174 174 177 184 187 165 164 165 125 124 125 24 26 27
51943 +4 0 0 4 0 0 5 5 5 50 82 103 136 185 209 172 205 220
51944 +146 190 211 136 185 209 26 108 161 22 40 52 7 12 15 44 81 103
51945 +71 116 144 28 67 93 37 51 59 41 65 82 100 139 164 101 161 196
51946 +90 154 193 90 154 193 28 67 93 0 0 0 0 0 0 26 28 28
51947 +125 124 125 167 166 167 163 162 163 153 152 153 163 162 163 174 174 174
51948 +85 115 134 4 0 0
51949 +4 4 4 5 5 5 4 4 4 1 0 0 4 0 0 34 47 55
51950 +125 124 125 174 174 174 174 174 174 167 166 167 157 156 157 153 152 153
51951 +155 154 155 155 154 155 158 157 158 166 165 166 167 166 167 154 153 154
51952 +125 124 125 26 28 28 4 0 0 4 0 0 4 0 0 5 5 5
51953 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 1 1 1
51954 +0 0 0 0 0 0 1 1 1 4 4 4 4 4 4 4 4 4
51955 +5 5 5 5 5 5 4 3 3 4 0 0 4 0 0 6 6 6
51956 +37 38 37 131 129 131 137 136 137 37 38 37 0 0 0 4 0 0
51957 +4 5 5 43 61 72 90 154 193 172 205 220 146 190 211 136 185 209
51958 +90 154 193 28 67 93 13 20 25 43 61 72 71 116 144 44 81 103
51959 +2 5 5 7 11 13 59 113 148 101 161 196 90 154 193 28 67 93
51960 +13 20 25 6 10 14 0 0 0 13 16 17 60 73 81 137 136 137
51961 +166 165 166 158 157 158 156 155 156 154 153 154 167 166 167 174 174 174
51962 +60 73 81 4 0 0
51963 +4 4 4 4 4 4 0 0 0 3 3 3 60 74 84 174 174 174
51964 +174 174 174 167 166 167 163 162 163 155 154 155 157 156 157 155 154 155
51965 +156 155 156 163 162 163 167 166 167 158 157 158 125 124 125 37 38 37
51966 +4 3 3 4 0 0 4 0 0 6 6 6 6 6 6 5 5 5
51967 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 2 3 3
51968 +10 13 16 7 11 13 1 0 0 0 0 0 2 2 1 4 4 4
51969 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 4 0 0
51970 +4 0 0 7 11 13 13 16 17 4 0 0 3 3 3 34 47 55
51971 +80 127 157 146 190 211 172 205 220 136 185 209 136 185 209 136 185 209
51972 +28 67 93 22 40 52 55 98 126 55 98 126 21 29 34 7 11 13
51973 +50 82 103 101 161 196 101 161 196 35 83 115 13 20 25 2 2 1
51974 +1 1 2 1 1 2 37 51 59 131 129 131 174 174 174 174 174 174
51975 +167 166 167 163 162 163 163 162 163 167 166 167 174 174 174 125 124 125
51976 +16 19 21 4 0 0
51977 +4 4 4 4 0 0 4 0 0 60 74 84 174 174 174 174 174 174
51978 +158 157 158 155 154 155 155 154 155 156 155 156 155 154 155 158 157 158
51979 +167 166 167 165 164 165 131 129 131 60 73 81 13 16 17 4 0 0
51980 +4 0 0 4 3 3 6 6 6 4 3 3 5 5 5 4 4 4
51981 +4 4 4 3 2 2 0 0 0 0 0 0 7 11 13 45 69 86
51982 +80 127 157 71 116 144 43 61 72 7 11 13 0 0 0 1 1 1
51983 +4 3 3 4 4 4 4 4 4 4 4 4 6 6 6 5 5 5
51984 +3 2 2 4 0 0 1 0 0 21 29 34 59 113 148 136 185 209
51985 +146 190 211 136 185 209 136 185 209 136 185 209 136 185 209 136 185 209
51986 +68 124 159 44 81 103 22 40 52 13 16 17 43 61 72 90 154 193
51987 +136 185 209 59 113 148 21 29 34 3 4 3 1 1 1 0 0 0
51988 +24 26 27 125 124 125 163 162 163 174 174 174 166 165 166 165 164 165
51989 +163 162 163 125 124 125 125 124 125 125 124 125 125 124 125 26 28 28
51990 +4 0 0 4 3 3
51991 +3 3 3 0 0 0 24 26 27 153 152 153 177 184 187 158 157 158
51992 +156 155 156 156 155 156 155 154 155 155 154 155 165 164 165 174 174 174
51993 +155 154 155 60 74 84 26 28 28 4 0 0 4 0 0 3 1 0
51994 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3
51995 +2 0 0 0 0 0 0 0 0 32 43 50 72 125 159 101 161 196
51996 +136 185 209 101 161 196 101 161 196 79 117 143 32 43 50 0 0 0
51997 +0 0 0 2 2 2 4 4 4 4 4 4 3 3 3 1 0 0
51998 +0 0 0 4 5 5 49 76 92 101 161 196 146 190 211 146 190 211
51999 +136 185 209 136 185 209 136 185 209 136 185 209 136 185 209 90 154 193
52000 +28 67 93 13 16 17 37 51 59 80 127 157 136 185 209 90 154 193
52001 +22 40 52 6 9 11 3 4 3 2 2 1 16 19 21 60 73 81
52002 +137 136 137 163 162 163 158 157 158 166 165 166 167 166 167 153 152 153
52003 +60 74 84 37 38 37 6 6 6 13 16 17 4 0 0 1 0 0
52004 +3 2 2 4 4 4
52005 +3 2 2 4 0 0 37 38 37 137 136 137 167 166 167 158 157 158
52006 +157 156 157 154 153 154 157 156 157 167 166 167 174 174 174 125 124 125
52007 +37 38 37 4 0 0 4 0 0 4 0 0 4 3 3 4 4 4
52008 +4 4 4 4 4 4 5 5 5 5 5 5 1 1 1 0 0 0
52009 +0 0 0 16 21 25 55 98 126 90 154 193 136 185 209 101 161 196
52010 +101 161 196 101 161 196 136 185 209 136 185 209 101 161 196 55 98 126
52011 +14 17 19 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
52012 +22 40 52 90 154 193 146 190 211 146 190 211 136 185 209 136 185 209
52013 +136 185 209 136 185 209 136 185 209 101 161 196 35 83 115 7 11 13
52014 +17 23 27 59 113 148 136 185 209 101 161 196 34 86 122 7 12 15
52015 +2 5 5 3 4 3 6 6 6 60 73 81 131 129 131 163 162 163
52016 +166 165 166 174 174 174 174 174 174 163 162 163 125 124 125 41 54 63
52017 +13 16 17 4 0 0 4 0 0 4 0 0 1 0 0 2 2 2
52018 +4 4 4 4 4 4
52019 +1 1 1 2 1 0 43 57 68 137 136 137 153 152 153 153 152 153
52020 +163 162 163 156 155 156 165 164 165 167 166 167 60 74 84 6 6 6
52021 +4 0 0 4 0 0 5 5 5 4 4 4 4 4 4 4 4 4
52022 +4 5 5 6 6 6 4 3 3 0 0 0 0 0 0 11 15 18
52023 +40 71 93 100 139 164 101 161 196 101 161 196 101 161 196 101 161 196
52024 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 136 185 209
52025 +101 161 196 45 69 86 6 6 6 0 0 0 17 23 27 55 98 126
52026 +136 185 209 146 190 211 136 185 209 136 185 209 136 185 209 136 185 209
52027 +136 185 209 136 185 209 90 154 193 22 40 52 7 11 13 50 82 103
52028 +136 185 209 136 185 209 53 118 160 22 40 52 7 11 13 2 5 5
52029 +3 4 3 37 38 37 125 124 125 157 156 157 166 165 166 167 166 167
52030 +174 174 174 174 174 174 137 136 137 60 73 81 4 0 0 4 0 0
52031 +4 0 0 4 0 0 5 5 5 3 3 3 3 3 3 4 4 4
52032 +4 4 4 4 4 4
52033 +4 0 0 4 0 0 41 54 63 137 136 137 125 124 125 131 129 131
52034 +155 154 155 167 166 167 174 174 174 60 74 84 6 6 6 4 0 0
52035 +4 3 3 6 6 6 4 4 4 4 4 4 4 4 4 5 5 5
52036 +4 4 4 1 1 1 0 0 0 3 6 7 41 65 82 72 125 159
52037 +101 161 196 101 161 196 101 161 196 90 154 193 90 154 193 101 161 196
52038 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
52039 +136 185 209 136 185 209 80 127 157 55 98 126 101 161 196 146 190 211
52040 +136 185 209 136 185 209 136 185 209 101 161 196 136 185 209 101 161 196
52041 +136 185 209 101 161 196 35 83 115 22 30 35 101 161 196 172 205 220
52042 +90 154 193 28 67 93 7 11 13 2 5 5 3 4 3 13 16 17
52043 +85 115 134 167 166 167 174 174 174 174 174 174 174 174 174 174 174 174
52044 +167 166 167 60 74 84 13 16 17 4 0 0 4 0 0 4 3 3
52045 +6 6 6 5 5 5 4 4 4 5 5 5 4 4 4 5 5 5
52046 +5 5 5 5 5 5
52047 +1 1 1 4 0 0 41 54 63 137 136 137 137 136 137 125 124 125
52048 +131 129 131 167 166 167 157 156 157 37 38 37 6 6 6 4 0 0
52049 +6 6 6 5 5 5 4 4 4 4 4 4 4 5 5 2 2 1
52050 +0 0 0 0 0 0 26 37 45 58 111 146 101 161 196 101 161 196
52051 +101 161 196 90 154 193 90 154 193 90 154 193 101 161 196 101 161 196
52052 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52053 +101 161 196 136 185 209 136 185 209 136 185 209 146 190 211 136 185 209
52054 +136 185 209 101 161 196 136 185 209 136 185 209 101 161 196 136 185 209
52055 +101 161 196 136 185 209 136 185 209 136 185 209 136 185 209 16 89 141
52056 +7 11 13 2 5 5 2 5 5 13 16 17 60 73 81 154 154 154
52057 +174 174 174 174 174 174 174 174 174 174 174 174 163 162 163 125 124 125
52058 +24 26 27 4 0 0 4 0 0 4 0 0 5 5 5 5 5 5
52059 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52060 +5 5 5 4 4 4
52061 +4 0 0 6 6 6 37 38 37 137 136 137 137 136 137 131 129 131
52062 +131 129 131 153 152 153 131 129 131 26 28 28 4 0 0 4 3 3
52063 +6 6 6 4 4 4 4 4 4 4 4 4 0 0 0 0 0 0
52064 +13 20 25 51 88 114 90 154 193 101 161 196 101 161 196 90 154 193
52065 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52066 +101 161 196 101 161 196 101 161 196 101 161 196 136 185 209 101 161 196
52067 +101 161 196 136 185 209 101 161 196 136 185 209 136 185 209 101 161 196
52068 +136 185 209 101 161 196 136 185 209 101 161 196 101 161 196 101 161 196
52069 +136 185 209 136 185 209 136 185 209 37 112 160 21 29 34 5 7 8
52070 +2 5 5 13 16 17 43 57 68 131 129 131 174 174 174 174 174 174
52071 +174 174 174 167 166 167 157 156 157 125 124 125 37 38 37 4 0 0
52072 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
52073 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52074 +4 4 4 4 4 4
52075 +1 1 1 4 0 0 41 54 63 153 152 153 137 136 137 137 136 137
52076 +137 136 137 153 152 153 125 124 125 24 26 27 4 0 0 3 2 2
52077 +4 4 4 4 4 4 4 3 3 4 0 0 3 6 7 43 61 72
52078 +64 123 161 101 161 196 90 154 193 90 154 193 90 154 193 90 154 193
52079 +90 154 193 90 154 193 90 154 193 90 154 193 101 161 196 90 154 193
52080 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52081 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52082 +136 185 209 101 161 196 101 161 196 136 185 209 136 185 209 101 161 196
52083 +101 161 196 90 154 193 28 67 93 13 16 17 7 11 13 3 6 7
52084 +37 51 59 125 124 125 163 162 163 174 174 174 167 166 167 166 165 166
52085 +167 166 167 131 129 131 60 73 81 4 0 0 4 0 0 4 0 0
52086 +3 3 3 5 5 5 6 6 6 4 4 4 4 4 4 4 4 4
52087 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52088 +4 4 4 4 4 4
52089 +4 0 0 4 0 0 41 54 63 137 136 137 153 152 153 137 136 137
52090 +153 152 153 157 156 157 125 124 125 24 26 27 0 0 0 2 2 2
52091 +4 4 4 4 4 4 2 0 0 0 0 0 28 67 93 90 154 193
52092 +90 154 193 90 154 193 90 154 193 90 154 193 64 123 161 90 154 193
52093 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52094 +90 154 193 101 161 196 101 161 196 101 161 196 90 154 193 136 185 209
52095 +101 161 196 101 161 196 136 185 209 101 161 196 136 185 209 101 161 196
52096 +101 161 196 101 161 196 136 185 209 101 161 196 101 161 196 90 154 193
52097 +35 83 115 13 16 17 3 6 7 2 5 5 13 16 17 60 74 84
52098 +154 154 154 166 165 166 165 164 165 158 157 158 163 162 163 157 156 157
52099 +60 74 84 13 16 17 4 0 0 4 0 0 3 2 2 4 4 4
52100 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52101 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52102 +4 4 4 4 4 4
52103 +1 1 1 4 0 0 41 54 63 157 156 157 155 154 155 137 136 137
52104 +153 152 153 158 157 158 137 136 137 26 28 28 2 0 0 2 2 2
52105 +4 4 4 4 4 4 1 0 0 6 10 14 34 86 122 90 154 193
52106 +64 123 161 90 154 193 64 123 161 90 154 193 90 154 193 90 154 193
52107 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52108 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52109 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 101 161 196
52110 +136 185 209 101 161 196 136 185 209 90 154 193 26 108 161 22 40 52
52111 +13 16 17 5 7 8 2 5 5 2 5 5 37 38 37 165 164 165
52112 +174 174 174 163 162 163 154 154 154 165 164 165 167 166 167 60 73 81
52113 +6 6 6 4 0 0 4 0 0 4 4 4 4 4 4 4 4 4
52114 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52115 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52116 +4 4 4 4 4 4
52117 +4 0 0 6 6 6 41 54 63 156 155 156 158 157 158 153 152 153
52118 +156 155 156 165 164 165 137 136 137 26 28 28 0 0 0 2 2 2
52119 +4 4 5 4 4 4 2 0 0 7 12 15 31 96 139 64 123 161
52120 +90 154 193 64 123 161 90 154 193 90 154 193 64 123 161 90 154 193
52121 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52122 +90 154 193 90 154 193 90 154 193 101 161 196 101 161 196 101 161 196
52123 +101 161 196 101 161 196 101 161 196 101 161 196 101 161 196 136 185 209
52124 +101 161 196 136 185 209 26 108 161 22 40 52 7 11 13 5 7 8
52125 +2 5 5 2 5 5 2 5 5 2 2 1 37 38 37 158 157 158
52126 +174 174 174 154 154 154 156 155 156 167 166 167 165 164 165 37 38 37
52127 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52128 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52129 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52130 +4 4 4 4 4 4
52131 +3 1 0 4 0 0 60 73 81 157 156 157 163 162 163 153 152 153
52132 +158 157 158 167 166 167 137 136 137 26 28 28 2 0 0 2 2 2
52133 +4 5 5 4 4 4 4 0 0 7 12 15 24 86 132 26 108 161
52134 +37 112 160 64 123 161 90 154 193 64 123 161 90 154 193 90 154 193
52135 +90 154 193 90 154 193 90 154 193 90 154 193 90 154 193 90 154 193
52136 +90 154 193 101 161 196 90 154 193 101 161 196 101 161 196 101 161 196
52137 +101 161 196 101 161 196 101 161 196 136 185 209 101 161 196 136 185 209
52138 +90 154 193 35 83 115 13 16 17 13 16 17 7 11 13 3 6 7
52139 +5 7 8 6 6 6 3 4 3 2 2 1 30 32 34 154 154 154
52140 +167 166 167 154 154 154 154 154 154 174 174 174 165 164 165 37 38 37
52141 +6 6 6 4 0 0 6 6 6 4 4 4 4 4 4 4 4 4
52142 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52143 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52144 +4 4 4 4 4 4
52145 +4 0 0 4 0 0 41 54 63 163 162 163 166 165 166 154 154 154
52146 +163 162 163 174 174 174 137 136 137 26 28 28 0 0 0 2 2 2
52147 +4 5 5 4 4 5 1 1 2 6 10 14 28 67 93 18 97 151
52148 +18 97 151 18 97 151 26 108 161 37 112 160 37 112 160 90 154 193
52149 +64 123 161 90 154 193 90 154 193 90 154 193 90 154 193 101 161 196
52150 +90 154 193 101 161 196 101 161 196 90 154 193 101 161 196 101 161 196
52151 +101 161 196 101 161 196 101 161 196 136 185 209 90 154 193 16 89 141
52152 +13 20 25 7 11 13 5 7 8 5 7 8 2 5 5 4 5 5
52153 +3 4 3 4 5 5 3 4 3 0 0 0 37 38 37 158 157 158
52154 +174 174 174 158 157 158 158 157 158 167 166 167 174 174 174 41 54 63
52155 +4 0 0 3 2 2 5 5 5 4 4 4 4 4 4 4 4 4
52156 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52157 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52158 +4 4 4 4 4 4
52159 +1 1 1 4 0 0 60 73 81 165 164 165 174 174 174 158 157 158
52160 +167 166 167 174 174 174 153 152 153 26 28 28 2 0 0 2 2 2
52161 +4 5 5 4 4 4 4 0 0 7 12 15 10 87 144 10 87 144
52162 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52163 +26 108 161 37 112 160 53 118 160 90 154 193 90 154 193 90 154 193
52164 +90 154 193 90 154 193 101 161 196 101 161 196 101 161 196 101 161 196
52165 +101 161 196 136 185 209 90 154 193 26 108 161 22 40 52 13 16 17
52166 +7 11 13 3 6 7 5 7 8 5 7 8 2 5 5 4 5 5
52167 +4 5 5 6 6 6 3 4 3 0 0 0 30 32 34 158 157 158
52168 +174 174 174 156 155 156 155 154 155 165 164 165 154 153 154 37 38 37
52169 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52170 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52171 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52172 +4 4 4 4 4 4
52173 +4 0 0 4 0 0 60 73 81 167 166 167 174 174 174 163 162 163
52174 +174 174 174 174 174 174 153 152 153 26 28 28 0 0 0 3 3 3
52175 +5 5 5 4 4 4 1 1 2 7 12 15 28 67 93 18 97 151
52176 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52177 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52178 +90 154 193 26 108 161 90 154 193 90 154 193 90 154 193 101 161 196
52179 +101 161 196 26 108 161 22 40 52 13 16 17 7 11 13 2 5 5
52180 +2 5 5 6 6 6 2 5 5 4 5 5 4 5 5 4 5 5
52181 +3 4 3 5 5 5 3 4 3 2 0 0 30 32 34 137 136 137
52182 +153 152 153 137 136 137 131 129 131 137 136 137 131 129 131 37 38 37
52183 +4 0 0 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52184 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52185 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52186 +4 4 4 4 4 4
52187 +1 1 1 4 0 0 60 73 81 167 166 167 174 174 174 166 165 166
52188 +174 174 174 177 184 187 153 152 153 30 32 34 1 0 0 3 3 3
52189 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52190 +18 97 151 18 97 151 18 97 151 26 108 161 26 108 161 26 108 161
52191 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52192 +26 108 161 26 108 161 26 108 161 90 154 193 90 154 193 26 108 161
52193 +35 83 115 13 16 17 7 11 13 5 7 8 3 6 7 5 7 8
52194 +2 5 5 6 6 6 4 5 5 4 5 5 3 4 3 4 5 5
52195 +3 4 3 6 6 6 3 4 3 0 0 0 26 28 28 125 124 125
52196 +131 129 131 125 124 125 125 124 125 131 129 131 131 129 131 37 38 37
52197 +4 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52198 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52199 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52200 +4 4 4 4 4 4
52201 +3 1 0 4 0 0 60 73 81 174 174 174 177 184 187 167 166 167
52202 +174 174 174 177 184 187 153 152 153 30 32 34 0 0 0 3 3 3
52203 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52204 +18 97 151 18 97 151 18 97 151 18 97 151 18 97 151 26 108 161
52205 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52206 +26 108 161 90 154 193 26 108 161 26 108 161 24 86 132 13 20 25
52207 +7 11 13 13 20 25 22 40 52 5 7 8 3 4 3 3 4 3
52208 +4 5 5 3 4 3 4 5 5 3 4 3 4 5 5 3 4 3
52209 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52210 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52211 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52212 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52213 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52214 +4 4 4 4 4 4
52215 +1 1 1 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52216 +174 174 174 190 197 201 157 156 157 30 32 34 1 0 0 3 3 3
52217 +5 5 5 4 3 3 4 0 0 7 12 15 10 87 144 10 87 144
52218 +18 97 151 19 95 150 19 95 150 18 97 151 18 97 151 26 108 161
52219 +18 97 151 26 108 161 26 108 161 26 108 161 26 108 161 90 154 193
52220 +26 108 161 26 108 161 26 108 161 22 40 52 2 5 5 3 4 3
52221 +28 67 93 37 112 160 34 86 122 2 5 5 3 4 3 3 4 3
52222 +3 4 3 3 4 3 3 4 3 2 2 1 3 4 3 4 4 4
52223 +4 5 5 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52224 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52225 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52226 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52227 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52228 +4 4 4 4 4 4
52229 +4 0 0 4 0 0 60 73 81 174 174 174 177 184 187 174 174 174
52230 +174 174 174 190 197 201 158 157 158 30 32 34 0 0 0 2 2 2
52231 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 18 97 151
52232 +10 87 144 19 95 150 19 95 150 18 97 151 18 97 151 18 97 151
52233 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52234 +18 97 151 22 40 52 2 5 5 2 2 1 22 40 52 26 108 161
52235 +90 154 193 37 112 160 22 40 52 3 4 3 13 20 25 22 30 35
52236 +3 6 7 1 1 1 2 2 2 6 9 11 5 5 5 4 3 3
52237 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52238 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52239 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52240 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52241 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52242 +4 4 4 4 4 4
52243 +1 1 1 4 0 0 60 73 81 177 184 187 193 200 203 174 174 174
52244 +177 184 187 193 200 203 163 162 163 30 32 34 4 0 0 2 2 2
52245 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52246 +10 87 144 10 87 144 19 95 150 19 95 150 19 95 150 18 97 151
52247 +26 108 161 26 108 161 26 108 161 90 154 193 26 108 161 28 67 93
52248 +6 10 14 2 5 5 13 20 25 24 86 132 37 112 160 90 154 193
52249 +10 87 144 7 12 15 2 5 5 28 67 93 37 112 160 28 67 93
52250 +2 2 1 7 12 15 35 83 115 28 67 93 3 6 7 1 0 0
52251 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52252 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52253 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52254 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52255 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52256 +4 4 4 4 4 4
52257 +4 0 0 4 0 0 60 73 81 174 174 174 190 197 201 174 174 174
52258 +177 184 187 193 200 203 163 162 163 30 32 34 0 0 0 2 2 2
52259 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52260 +10 87 144 16 89 141 19 95 150 10 87 144 26 108 161 26 108 161
52261 +26 108 161 26 108 161 26 108 161 28 67 93 6 10 14 1 1 2
52262 +7 12 15 28 67 93 26 108 161 16 89 141 24 86 132 21 29 34
52263 +3 4 3 21 29 34 37 112 160 37 112 160 27 99 146 21 29 34
52264 +21 29 34 26 108 161 90 154 193 35 83 115 1 1 2 2 0 0
52265 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 125 124 125
52266 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52267 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52268 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52269 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52270 +4 4 4 4 4 4
52271 +3 1 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52272 +190 197 201 193 200 203 165 164 165 37 38 37 4 0 0 2 2 2
52273 +5 5 5 4 3 3 4 0 0 6 10 14 24 86 132 10 87 144
52274 +10 87 144 10 87 144 16 89 141 18 97 151 18 97 151 10 87 144
52275 +24 86 132 24 86 132 13 20 25 4 5 7 4 5 7 22 40 52
52276 +18 97 151 37 112 160 26 108 161 7 12 15 1 1 1 0 0 0
52277 +28 67 93 37 112 160 26 108 161 28 67 93 22 40 52 28 67 93
52278 +26 108 161 90 154 193 26 108 161 10 87 144 0 0 0 2 0 0
52279 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52280 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52281 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52282 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52283 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52284 +4 4 4 4 4 4
52285 +4 0 0 6 6 6 60 73 81 174 174 174 193 200 203 174 174 174
52286 +190 197 201 193 200 203 165 164 165 30 32 34 0 0 0 2 2 2
52287 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52288 +10 87 144 10 87 144 10 87 144 18 97 151 28 67 93 6 10 14
52289 +0 0 0 1 1 2 4 5 7 13 20 25 16 89 141 26 108 161
52290 +26 108 161 26 108 161 24 86 132 6 9 11 2 3 3 22 40 52
52291 +37 112 160 16 89 141 22 40 52 28 67 93 26 108 161 26 108 161
52292 +90 154 193 26 108 161 26 108 161 28 67 93 1 1 1 4 0 0
52293 +4 4 4 5 5 5 3 3 3 4 0 0 26 28 28 124 126 130
52294 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52295 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52296 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52297 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52298 +4 4 4 4 4 4
52299 +4 0 0 4 0 0 60 73 81 193 200 203 193 200 203 174 174 174
52300 +193 200 203 193 200 203 167 166 167 37 38 37 4 0 0 2 2 2
52301 +5 5 5 4 4 4 4 0 0 6 10 14 28 67 93 10 87 144
52302 +10 87 144 10 87 144 18 97 151 10 87 144 13 20 25 4 5 7
52303 +1 1 2 1 1 1 22 40 52 26 108 161 26 108 161 26 108 161
52304 +26 108 161 26 108 161 26 108 161 24 86 132 22 40 52 22 40 52
52305 +22 40 52 22 40 52 10 87 144 26 108 161 26 108 161 26 108 161
52306 +26 108 161 26 108 161 90 154 193 10 87 144 0 0 0 4 0 0
52307 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52308 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52309 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52310 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52311 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52312 +4 4 4 4 4 4
52313 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52314 +190 197 201 205 212 215 167 166 167 30 32 34 0 0 0 2 2 2
52315 +5 5 5 4 4 4 1 1 2 6 10 14 28 67 93 10 87 144
52316 +10 87 144 10 87 144 10 87 144 10 87 144 22 40 52 1 1 2
52317 +2 0 0 1 1 2 24 86 132 26 108 161 26 108 161 26 108 161
52318 +26 108 161 19 95 150 16 89 141 10 87 144 22 40 52 22 40 52
52319 +10 87 144 26 108 161 37 112 160 26 108 161 26 108 161 26 108 161
52320 +26 108 161 26 108 161 26 108 161 28 67 93 2 0 0 3 1 0
52321 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52322 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52323 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52324 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52325 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52326 +4 4 4 4 4 4
52327 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52328 +193 200 203 193 200 203 174 174 174 37 38 37 4 0 0 2 2 2
52329 +5 5 5 4 4 4 3 2 2 1 1 2 13 20 25 10 87 144
52330 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 13 20 25
52331 +13 20 25 22 40 52 10 87 144 18 97 151 18 97 151 26 108 161
52332 +10 87 144 13 20 25 6 10 14 21 29 34 24 86 132 18 97 151
52333 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52334 +26 108 161 90 154 193 18 97 151 13 20 25 0 0 0 4 3 3
52335 +4 4 4 5 5 5 3 3 3 0 0 0 26 28 28 131 129 131
52336 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52337 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52338 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52339 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52340 +4 4 4 4 4 4
52341 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52342 +190 197 201 220 221 221 167 166 167 30 32 34 1 0 0 2 2 2
52343 +5 5 5 4 4 4 4 4 5 2 5 5 4 5 7 13 20 25
52344 +28 67 93 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52345 +10 87 144 10 87 144 18 97 151 10 87 144 18 97 151 18 97 151
52346 +28 67 93 2 3 3 0 0 0 28 67 93 26 108 161 26 108 161
52347 +26 108 161 26 108 161 26 108 161 26 108 161 26 108 161 26 108 161
52348 +26 108 161 10 87 144 13 20 25 1 1 2 3 2 2 4 4 4
52349 +4 4 4 5 5 5 3 3 3 2 0 0 26 28 28 131 129 131
52350 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52351 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52352 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52353 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52354 +4 4 4 4 4 4
52355 +4 0 0 4 0 0 60 73 81 220 221 221 190 197 201 174 174 174
52356 +193 200 203 193 200 203 174 174 174 26 28 28 4 0 0 4 3 3
52357 +5 5 5 4 4 4 4 4 4 4 4 5 1 1 2 2 5 5
52358 +4 5 7 22 40 52 10 87 144 10 87 144 18 97 151 10 87 144
52359 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 18 97 151
52360 +10 87 144 28 67 93 22 40 52 10 87 144 26 108 161 18 97 151
52361 +18 97 151 18 97 151 26 108 161 26 108 161 26 108 161 26 108 161
52362 +22 40 52 1 1 2 0 0 0 2 3 3 4 4 4 4 4 4
52363 +4 4 4 5 5 5 4 4 4 0 0 0 26 28 28 131 129 131
52364 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52365 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52366 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52367 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52368 +4 4 4 4 4 4
52369 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52370 +190 197 201 220 221 221 190 197 201 41 54 63 4 0 0 2 2 2
52371 +6 6 6 4 4 4 4 4 4 4 4 5 4 4 5 3 3 3
52372 +1 1 2 1 1 2 6 10 14 22 40 52 10 87 144 18 97 151
52373 +18 97 151 10 87 144 10 87 144 10 87 144 18 97 151 10 87 144
52374 +10 87 144 18 97 151 26 108 161 18 97 151 18 97 151 10 87 144
52375 +26 108 161 26 108 161 26 108 161 10 87 144 28 67 93 6 10 14
52376 +1 1 2 1 1 2 4 3 3 4 4 5 4 4 4 4 4 4
52377 +5 5 5 5 5 5 1 1 1 4 0 0 37 51 59 137 136 137
52378 +137 136 137 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52379 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52380 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52381 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52382 +4 4 4 4 4 4
52383 +4 0 0 4 0 0 60 73 81 220 221 221 193 200 203 174 174 174
52384 +193 200 203 193 200 203 220 221 221 137 136 137 13 16 17 4 0 0
52385 +2 2 2 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5
52386 +4 4 5 4 3 3 1 1 2 4 5 7 13 20 25 28 67 93
52387 +10 87 144 10 87 144 10 87 144 10 87 144 10 87 144 10 87 144
52388 +10 87 144 18 97 151 18 97 151 10 87 144 18 97 151 26 108 161
52389 +26 108 161 18 97 151 28 67 93 6 10 14 0 0 0 0 0 0
52390 +2 3 3 4 5 5 4 4 5 4 4 4 4 4 4 5 5 5
52391 +3 3 3 1 1 1 0 0 0 16 19 21 125 124 125 137 136 137
52392 +131 129 131 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52393 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52394 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52395 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52396 +4 4 4 4 4 4
52397 +4 0 0 6 6 6 60 73 81 174 174 174 220 221 221 174 174 174
52398 +193 200 203 190 197 201 220 221 221 220 221 221 153 152 153 30 32 34
52399 +0 0 0 0 0 0 2 2 2 4 4 4 4 4 4 4 4 4
52400 +4 4 4 4 5 5 4 5 7 1 1 2 1 1 2 4 5 7
52401 +13 20 25 28 67 93 10 87 144 18 97 151 10 87 144 10 87 144
52402 +10 87 144 10 87 144 10 87 144 18 97 151 26 108 161 18 97 151
52403 +28 67 93 7 12 15 0 0 0 0 0 0 2 2 1 4 4 4
52404 +4 5 5 4 5 5 4 4 4 4 4 4 3 3 3 0 0 0
52405 +0 0 0 0 0 0 37 38 37 125 124 125 158 157 158 131 129 131
52406 +125 124 125 125 124 125 125 124 125 137 136 137 131 129 131 37 38 37
52407 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52408 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52409 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52410 +4 4 4 4 4 4
52411 +4 3 3 4 0 0 41 54 63 193 200 203 220 221 221 174 174 174
52412 +193 200 203 193 200 203 193 200 203 220 221 221 244 246 246 193 200 203
52413 +120 125 127 5 5 5 1 0 0 0 0 0 1 1 1 4 4 4
52414 +4 4 4 4 4 4 4 5 5 4 5 5 4 4 5 1 1 2
52415 +4 5 7 4 5 7 22 40 52 10 87 144 10 87 144 10 87 144
52416 +10 87 144 10 87 144 18 97 151 10 87 144 10 87 144 13 20 25
52417 +4 5 7 2 3 3 1 1 2 4 4 4 4 5 5 4 4 4
52418 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 1 2
52419 +24 26 27 60 74 84 153 152 153 163 162 163 137 136 137 125 124 125
52420 +125 124 125 125 124 125 125 124 125 137 136 137 125 124 125 26 28 28
52421 +0 0 0 3 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52422 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52423 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52424 +4 4 4 4 4 4
52425 +4 0 0 6 6 6 26 28 28 156 155 156 220 221 221 220 221 221
52426 +174 174 174 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52427 +220 221 221 167 166 167 60 73 81 7 11 13 0 0 0 0 0 0
52428 +3 3 3 4 4 4 4 4 4 4 4 4 4 4 5 4 4 5
52429 +4 4 5 1 1 2 1 1 2 4 5 7 22 40 52 10 87 144
52430 +10 87 144 10 87 144 10 87 144 22 40 52 4 5 7 1 1 2
52431 +1 1 2 4 4 5 4 4 4 4 4 4 4 4 4 4 4 4
52432 +5 5 5 2 2 2 0 0 0 4 0 0 16 19 21 60 73 81
52433 +137 136 137 167 166 167 158 157 158 137 136 137 131 129 131 131 129 131
52434 +125 124 125 125 124 125 131 129 131 155 154 155 60 74 84 5 7 8
52435 +0 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52436 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52437 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52438 +4 4 4 4 4 4
52439 +5 5 5 4 0 0 4 0 0 60 73 81 193 200 203 220 221 221
52440 +193 200 203 193 200 203 193 200 203 193 200 203 205 212 215 220 221 221
52441 +220 221 221 220 221 221 220 221 221 137 136 137 43 57 68 6 6 6
52442 +4 0 0 1 1 1 4 4 4 4 4 4 4 4 4 4 4 4
52443 +4 4 5 4 4 5 3 2 2 1 1 2 2 5 5 13 20 25
52444 +22 40 52 22 40 52 13 20 25 2 3 3 1 1 2 3 3 3
52445 +4 5 7 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52446 +1 1 1 0 0 0 2 3 3 41 54 63 131 129 131 166 165 166
52447 +166 165 166 155 154 155 153 152 153 137 136 137 137 136 137 125 124 125
52448 +125 124 125 137 136 137 137 136 137 125 124 125 37 38 37 4 3 3
52449 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52450 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52451 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52452 +4 4 4 4 4 4
52453 +4 3 3 6 6 6 6 6 6 13 16 17 60 73 81 167 166 167
52454 +220 221 221 220 221 221 220 221 221 193 200 203 193 200 203 193 200 203
52455 +205 212 215 220 221 221 220 221 221 244 246 246 205 212 215 125 124 125
52456 +24 26 27 0 0 0 0 0 0 2 2 2 5 5 5 5 5 5
52457 +4 4 4 4 4 4 4 4 4 4 4 5 1 1 2 4 5 7
52458 +4 5 7 4 5 7 1 1 2 3 2 2 4 4 5 4 4 4
52459 +4 4 4 4 4 4 5 5 5 4 4 4 0 0 0 0 0 0
52460 +2 0 0 26 28 28 125 124 125 174 174 174 174 174 174 166 165 166
52461 +156 155 156 153 152 153 137 136 137 137 136 137 131 129 131 137 136 137
52462 +137 136 137 137 136 137 60 74 84 30 32 34 4 0 0 4 0 0
52463 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52464 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52465 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52466 +4 4 4 4 4 4
52467 +5 5 5 6 6 6 4 0 0 4 0 0 6 6 6 26 28 28
52468 +125 124 125 174 174 174 220 221 221 220 221 221 220 221 221 193 200 203
52469 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52470 +193 200 203 60 74 84 13 16 17 4 0 0 0 0 0 3 3 3
52471 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 5 3 3 3
52472 +1 1 2 3 3 3 4 4 5 4 4 5 4 4 4 4 4 4
52473 +5 5 5 5 5 5 2 2 2 0 0 0 0 0 0 13 16 17
52474 +60 74 84 174 174 174 193 200 203 174 174 174 167 166 167 163 162 163
52475 +153 152 153 153 152 153 137 136 137 137 136 137 153 152 153 137 136 137
52476 +125 124 125 41 54 63 24 26 27 4 0 0 4 0 0 5 5 5
52477 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52478 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52479 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52480 +4 4 4 4 4 4
52481 +4 3 3 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52482 +6 6 6 37 38 37 131 129 131 220 221 221 220 221 221 220 221 221
52483 +193 200 203 193 200 203 220 221 221 205 212 215 220 221 221 244 246 246
52484 +244 246 246 244 246 246 174 174 174 41 54 63 0 0 0 0 0 0
52485 +0 0 0 4 4 4 5 5 5 5 5 5 4 4 4 4 4 5
52486 +4 4 5 4 4 5 4 4 4 4 4 4 6 6 6 6 6 6
52487 +3 3 3 0 0 0 2 0 0 13 16 17 60 73 81 156 155 156
52488 +220 221 221 193 200 203 174 174 174 165 164 165 163 162 163 154 153 154
52489 +153 152 153 153 152 153 158 157 158 163 162 163 137 136 137 60 73 81
52490 +13 16 17 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52491 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52492 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52493 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52494 +4 4 4 4 4 4
52495 +5 5 5 4 3 3 4 3 3 6 6 6 6 6 6 6 6 6
52496 +6 6 6 6 6 6 6 6 6 37 38 37 167 166 167 244 246 246
52497 +244 246 246 220 221 221 205 212 215 205 212 215 220 221 221 193 200 203
52498 +220 221 221 244 246 246 244 246 246 244 246 246 137 136 137 37 38 37
52499 +3 2 2 0 0 0 1 1 1 5 5 5 5 5 5 4 4 4
52500 +4 4 4 4 4 4 4 4 4 5 5 5 4 4 4 1 1 1
52501 +0 0 0 5 5 5 43 57 68 153 152 153 193 200 203 220 221 221
52502 +177 184 187 174 174 174 167 166 167 166 165 166 158 157 158 157 156 157
52503 +158 157 158 166 165 166 156 155 156 85 115 134 13 16 17 4 0 0
52504 +4 0 0 4 0 0 5 5 5 5 5 5 4 4 4 4 4 4
52505 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52506 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52507 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52508 +4 4 4 4 4 4
52509 +5 5 5 4 3 3 6 6 6 6 6 6 4 0 0 6 6 6
52510 +6 6 6 6 6 6 6 6 6 6 6 6 13 16 17 60 73 81
52511 +177 184 187 220 221 221 220 221 221 220 221 221 205 212 215 220 221 221
52512 +220 221 221 205 212 215 220 221 221 244 246 246 244 246 246 205 212 215
52513 +125 124 125 30 32 34 0 0 0 0 0 0 2 2 2 5 5 5
52514 +4 4 4 4 4 4 4 4 4 1 1 1 0 0 0 1 0 0
52515 +37 38 37 131 129 131 205 212 215 220 221 221 193 200 203 174 174 174
52516 +174 174 174 174 174 174 167 166 167 165 164 165 166 165 166 167 166 167
52517 +158 157 158 125 124 125 37 38 37 4 0 0 4 0 0 4 0 0
52518 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52519 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52520 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52521 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52522 +4 4 4 4 4 4
52523 +4 4 4 5 5 5 4 3 3 4 3 3 6 6 6 6 6 6
52524 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52525 +26 28 28 125 124 125 205 212 215 220 221 221 220 221 221 220 221 221
52526 +205 212 215 220 221 221 205 212 215 220 221 221 220 221 221 244 246 246
52527 +244 246 246 190 197 201 60 74 84 16 19 21 4 0 0 0 0 0
52528 +0 0 0 0 0 0 0 0 0 0 0 0 16 19 21 120 125 127
52529 +177 184 187 220 221 221 205 212 215 177 184 187 174 174 174 177 184 187
52530 +174 174 174 174 174 174 167 166 167 174 174 174 166 165 166 137 136 137
52531 +60 73 81 13 16 17 4 0 0 4 0 0 4 3 3 6 6 6
52532 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52533 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52534 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52535 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52536 +4 4 4 4 4 4
52537 +5 5 5 4 3 3 5 5 5 4 3 3 6 6 6 4 0 0
52538 +6 6 6 6 6 6 4 0 0 6 6 6 4 0 0 6 6 6
52539 +6 6 6 6 6 6 37 38 37 137 136 137 193 200 203 220 221 221
52540 +220 221 221 205 212 215 220 221 221 205 212 215 205 212 215 220 221 221
52541 +220 221 221 220 221 221 244 246 246 166 165 166 43 57 68 2 2 2
52542 +0 0 0 4 0 0 16 19 21 60 73 81 157 156 157 202 210 214
52543 +220 221 221 193 200 203 177 184 187 177 184 187 177 184 187 174 174 174
52544 +174 174 174 174 174 174 174 174 174 157 156 157 60 74 84 24 26 27
52545 +4 0 0 4 0 0 4 0 0 6 6 6 4 4 4 4 4 4
52546 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52547 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52548 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52549 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52550 +4 4 4 4 4 4
52551 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52552 +6 6 6 4 0 0 6 6 6 6 6 6 6 6 6 4 0 0
52553 +4 0 0 4 0 0 6 6 6 24 26 27 60 73 81 167 166 167
52554 +220 221 221 220 221 221 220 221 221 205 212 215 205 212 215 205 212 215
52555 +205 212 215 220 221 221 220 221 221 220 221 221 205 212 215 137 136 137
52556 +60 74 84 125 124 125 137 136 137 190 197 201 220 221 221 193 200 203
52557 +177 184 187 177 184 187 177 184 187 174 174 174 174 174 174 177 184 187
52558 +190 197 201 174 174 174 125 124 125 37 38 37 6 6 6 4 0 0
52559 +4 0 0 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52560 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52561 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52562 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52563 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52564 +4 4 4 4 4 4
52565 +4 4 4 4 4 4 5 5 5 5 5 5 4 3 3 6 6 6
52566 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 6 6 6
52567 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52568 +125 124 125 193 200 203 244 246 246 220 221 221 205 212 215 205 212 215
52569 +205 212 215 193 200 203 205 212 215 205 212 215 220 221 221 220 221 221
52570 +193 200 203 193 200 203 205 212 215 193 200 203 193 200 203 177 184 187
52571 +190 197 201 190 197 201 174 174 174 190 197 201 193 200 203 190 197 201
52572 +153 152 153 60 73 81 4 0 0 4 0 0 4 0 0 3 2 2
52573 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52574 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52575 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52576 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52577 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52578 +4 4 4 4 4 4
52579 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52580 +6 6 6 4 3 3 4 3 3 4 3 3 6 6 6 6 6 6
52581 +4 0 0 6 6 6 6 6 6 6 6 6 4 0 0 4 0 0
52582 +4 0 0 26 28 28 131 129 131 220 221 221 244 246 246 220 221 221
52583 +205 212 215 193 200 203 205 212 215 193 200 203 193 200 203 205 212 215
52584 +220 221 221 193 200 203 193 200 203 193 200 203 190 197 201 174 174 174
52585 +174 174 174 190 197 201 193 200 203 193 200 203 167 166 167 125 124 125
52586 +6 6 6 4 0 0 4 0 0 4 3 3 4 4 4 4 4 4
52587 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52588 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52589 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52590 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52591 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52592 +4 4 4 4 4 4
52593 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52594 +5 5 5 4 3 3 5 5 5 6 6 6 4 3 3 5 5 5
52595 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52596 +4 0 0 4 0 0 6 6 6 41 54 63 158 157 158 220 221 221
52597 +220 221 221 220 221 221 193 200 203 193 200 203 193 200 203 190 197 201
52598 +190 197 201 190 197 201 190 197 201 190 197 201 174 174 174 193 200 203
52599 +193 200 203 220 221 221 174 174 174 125 124 125 37 38 37 4 0 0
52600 +4 0 0 4 3 3 6 6 6 4 4 4 4 4 4 4 4 4
52601 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52602 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52603 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52604 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52605 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52606 +4 4 4 4 4 4
52607 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52608 +4 4 4 5 5 5 4 3 3 4 3 3 4 3 3 5 5 5
52609 +4 3 3 6 6 6 5 5 5 4 3 3 6 6 6 6 6 6
52610 +6 6 6 6 6 6 4 0 0 4 0 0 13 16 17 60 73 81
52611 +174 174 174 220 221 221 220 221 221 205 212 215 190 197 201 174 174 174
52612 +193 200 203 174 174 174 190 197 201 174 174 174 193 200 203 220 221 221
52613 +193 200 203 131 129 131 37 38 37 6 6 6 4 0 0 4 0 0
52614 +6 6 6 6 6 6 4 3 3 5 5 5 4 4 4 4 4 4
52615 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52616 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52617 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52618 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52619 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52620 +4 4 4 4 4 4
52621 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52622 +4 4 4 4 4 4 4 4 4 5 5 5 5 5 5 5 5 5
52623 +5 5 5 4 3 3 4 3 3 5 5 5 4 3 3 4 3 3
52624 +5 5 5 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52625 +6 6 6 125 124 125 174 174 174 220 221 221 220 221 221 193 200 203
52626 +193 200 203 193 200 203 193 200 203 193 200 203 220 221 221 158 157 158
52627 +60 73 81 6 6 6 4 0 0 4 0 0 5 5 5 6 6 6
52628 +5 5 5 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52629 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52630 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52631 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52632 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52633 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52634 +4 4 4 4 4 4
52635 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52636 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52637 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52638 +5 5 5 5 5 5 6 6 6 6 6 6 4 0 0 4 0 0
52639 +4 0 0 4 0 0 26 28 28 125 124 125 174 174 174 193 200 203
52640 +193 200 203 174 174 174 193 200 203 167 166 167 125 124 125 6 6 6
52641 +6 6 6 6 6 6 4 0 0 6 6 6 6 6 6 5 5 5
52642 +4 3 3 5 5 5 4 4 4 4 4 4 4 4 4 4 4 4
52643 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52644 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52645 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52646 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52647 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52648 +4 4 4 4 4 4
52649 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52650 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52651 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52652 +4 3 3 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52653 +6 6 6 4 0 0 4 0 0 6 6 6 37 38 37 125 124 125
52654 +153 152 153 131 129 131 125 124 125 37 38 37 6 6 6 6 6 6
52655 +6 6 6 4 0 0 6 6 6 6 6 6 4 3 3 5 5 5
52656 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52657 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52658 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52659 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52660 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52661 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52662 +4 4 4 4 4 4
52663 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52664 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52665 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52666 +4 4 4 5 5 5 5 5 5 4 3 3 5 5 5 4 3 3
52667 +6 6 6 6 6 6 4 0 0 4 0 0 6 6 6 6 6 6
52668 +24 26 27 24 26 27 6 6 6 6 6 6 6 6 6 4 0 0
52669 +6 6 6 6 6 6 4 0 0 6 6 6 5 5 5 4 3 3
52670 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52671 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52672 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52673 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52674 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52675 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52676 +4 4 4 4 4 4
52677 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52678 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52679 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52680 +4 4 4 4 4 4 5 5 5 4 3 3 5 5 5 6 6 6
52681 +4 0 0 6 6 6 6 6 6 6 6 6 6 6 6 6 6 6
52682 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 6 6 6
52683 +4 0 0 6 6 6 6 6 6 4 3 3 5 5 5 4 4 4
52684 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52685 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52686 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52687 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52688 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52689 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52690 +4 4 4 4 4 4
52691 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52692 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52693 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52694 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 5 5 5
52695 +5 5 5 5 5 5 4 0 0 6 6 6 4 0 0 6 6 6
52696 +6 6 6 6 6 6 6 6 6 4 0 0 6 6 6 4 0 0
52697 +6 6 6 4 3 3 5 5 5 4 3 3 5 5 5 4 4 4
52698 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52699 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52700 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52701 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52702 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52703 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52704 +4 4 4 4 4 4
52705 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52706 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52707 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52708 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 5 5 5
52709 +4 3 3 6 6 6 4 3 3 6 6 6 6 6 6 6 6 6
52710 +4 0 0 6 6 6 4 0 0 6 6 6 6 6 6 6 6 6
52711 +6 6 6 4 3 3 5 5 5 4 4 4 4 4 4 4 4 4
52712 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52713 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52714 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52715 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52716 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52717 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52718 +4 4 4 4 4 4
52719 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52720 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52721 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52722 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52723 +4 4 4 5 5 5 4 3 3 5 5 5 4 0 0 6 6 6
52724 +6 6 6 4 0 0 6 6 6 6 6 6 4 0 0 6 6 6
52725 +4 3 3 5 5 5 5 5 5 4 4 4 4 4 4 4 4 4
52726 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52727 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52728 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52729 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52730 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52731 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52732 +4 4 4 4 4 4
52733 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52734 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52735 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52736 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52737 +4 4 4 5 5 5 4 3 3 5 5 5 6 6 6 4 3 3
52738 +4 3 3 6 6 6 6 6 6 4 3 3 6 6 6 4 3 3
52739 +5 5 5 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52740 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52741 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52742 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52743 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52744 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52745 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52746 +4 4 4 4 4 4
52747 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52748 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52749 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52750 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52751 +4 4 4 4 4 4 4 4 4 5 5 5 4 3 3 6 6 6
52752 +5 5 5 4 3 3 4 3 3 4 3 3 5 5 5 5 5 5
52753 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52754 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52755 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52756 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52757 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52758 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52759 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52760 +4 4 4 4 4 4
52761 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52762 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52763 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52764 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52765 +4 4 4 4 4 4 4 4 4 4 4 4 5 5 5 4 3 3
52766 +5 5 5 4 3 3 5 5 5 5 5 5 4 4 4 4 4 4
52767 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52768 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52769 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52770 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52771 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52772 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52773 +4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
52774 +4 4 4 4 4 4
52775 diff --git a/drivers/video/mb862xx/mb862xxfb_accel.c b/drivers/video/mb862xx/mb862xxfb_accel.c
52776 index fe92eed..106e085 100644
52777 --- a/drivers/video/mb862xx/mb862xxfb_accel.c
52778 +++ b/drivers/video/mb862xx/mb862xxfb_accel.c
52779 @@ -312,14 +312,18 @@ void mb862xxfb_init_accel(struct fb_info *info, int xres)
52780 struct mb862xxfb_par *par = info->par;
52781
52782 if (info->var.bits_per_pixel == 32) {
52783 - info->fbops->fb_fillrect = cfb_fillrect;
52784 - info->fbops->fb_copyarea = cfb_copyarea;
52785 - info->fbops->fb_imageblit = cfb_imageblit;
52786 + pax_open_kernel();
52787 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52788 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52789 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52790 + pax_close_kernel();
52791 } else {
52792 outreg(disp, GC_L0EM, 3);
52793 - info->fbops->fb_fillrect = mb86290fb_fillrect;
52794 - info->fbops->fb_copyarea = mb86290fb_copyarea;
52795 - info->fbops->fb_imageblit = mb86290fb_imageblit;
52796 + pax_open_kernel();
52797 + *(void **)&info->fbops->fb_fillrect = mb86290fb_fillrect;
52798 + *(void **)&info->fbops->fb_copyarea = mb86290fb_copyarea;
52799 + *(void **)&info->fbops->fb_imageblit = mb86290fb_imageblit;
52800 + pax_close_kernel();
52801 }
52802 outreg(draw, GDC_REG_DRAW_BASE, 0);
52803 outreg(draw, GDC_REG_MODE_MISC, 0x8000);
52804 diff --git a/drivers/video/nvidia/nvidia.c b/drivers/video/nvidia/nvidia.c
52805 index ff22871..b129bed 100644
52806 --- a/drivers/video/nvidia/nvidia.c
52807 +++ b/drivers/video/nvidia/nvidia.c
52808 @@ -669,19 +669,23 @@ static int nvidiafb_set_par(struct fb_info *info)
52809 info->fix.line_length = (info->var.xres_virtual *
52810 info->var.bits_per_pixel) >> 3;
52811 if (info->var.accel_flags) {
52812 - info->fbops->fb_imageblit = nvidiafb_imageblit;
52813 - info->fbops->fb_fillrect = nvidiafb_fillrect;
52814 - info->fbops->fb_copyarea = nvidiafb_copyarea;
52815 - info->fbops->fb_sync = nvidiafb_sync;
52816 + pax_open_kernel();
52817 + *(void **)&info->fbops->fb_imageblit = nvidiafb_imageblit;
52818 + *(void **)&info->fbops->fb_fillrect = nvidiafb_fillrect;
52819 + *(void **)&info->fbops->fb_copyarea = nvidiafb_copyarea;
52820 + *(void **)&info->fbops->fb_sync = nvidiafb_sync;
52821 + pax_close_kernel();
52822 info->pixmap.scan_align = 4;
52823 info->flags &= ~FBINFO_HWACCEL_DISABLED;
52824 info->flags |= FBINFO_READS_FAST;
52825 NVResetGraphics(info);
52826 } else {
52827 - info->fbops->fb_imageblit = cfb_imageblit;
52828 - info->fbops->fb_fillrect = cfb_fillrect;
52829 - info->fbops->fb_copyarea = cfb_copyarea;
52830 - info->fbops->fb_sync = NULL;
52831 + pax_open_kernel();
52832 + *(void **)&info->fbops->fb_imageblit = cfb_imageblit;
52833 + *(void **)&info->fbops->fb_fillrect = cfb_fillrect;
52834 + *(void **)&info->fbops->fb_copyarea = cfb_copyarea;
52835 + *(void **)&info->fbops->fb_sync = NULL;
52836 + pax_close_kernel();
52837 info->pixmap.scan_align = 1;
52838 info->flags |= FBINFO_HWACCEL_DISABLED;
52839 info->flags &= ~FBINFO_READS_FAST;
52840 @@ -1173,8 +1177,11 @@ static int nvidia_set_fbinfo(struct fb_info *info)
52841 info->pixmap.size = 8 * 1024;
52842 info->pixmap.flags = FB_PIXMAP_SYSTEM;
52843
52844 - if (!hwcur)
52845 - info->fbops->fb_cursor = NULL;
52846 + if (!hwcur) {
52847 + pax_open_kernel();
52848 + *(void **)&info->fbops->fb_cursor = NULL;
52849 + pax_close_kernel();
52850 + }
52851
52852 info->var.accel_flags = (!noaccel);
52853
52854 diff --git a/drivers/video/omap2/dss/display.c b/drivers/video/omap2/dss/display.c
52855 index fafe7c9..93197b9 100644
52856 --- a/drivers/video/omap2/dss/display.c
52857 +++ b/drivers/video/omap2/dss/display.c
52858 @@ -137,12 +137,14 @@ int omapdss_register_display(struct omap_dss_device *dssdev)
52859 snprintf(dssdev->alias, sizeof(dssdev->alias),
52860 "display%d", disp_num_counter++);
52861
52862 + pax_open_kernel();
52863 if (drv && drv->get_resolution == NULL)
52864 - drv->get_resolution = omapdss_default_get_resolution;
52865 + *(void **)&drv->get_resolution = omapdss_default_get_resolution;
52866 if (drv && drv->get_recommended_bpp == NULL)
52867 - drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52868 + *(void **)&drv->get_recommended_bpp = omapdss_default_get_recommended_bpp;
52869 if (drv && drv->get_timings == NULL)
52870 - drv->get_timings = omapdss_default_get_timings;
52871 + *(void **)&drv->get_timings = omapdss_default_get_timings;
52872 + pax_close_kernel();
52873
52874 mutex_lock(&panel_list_mutex);
52875 list_add_tail(&dssdev->panel_list, &panel_list);
52876 diff --git a/drivers/video/s1d13xxxfb.c b/drivers/video/s1d13xxxfb.c
52877 index 05c2dc3..ea1f391 100644
52878 --- a/drivers/video/s1d13xxxfb.c
52879 +++ b/drivers/video/s1d13xxxfb.c
52880 @@ -881,8 +881,10 @@ static int s1d13xxxfb_probe(struct platform_device *pdev)
52881
52882 switch(prod_id) {
52883 case S1D13506_PROD_ID: /* activate acceleration */
52884 - s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52885 - s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52886 + pax_open_kernel();
52887 + *(void **)&s1d13xxxfb_fbops.fb_fillrect = s1d13xxxfb_bitblt_solidfill;
52888 + *(void **)&s1d13xxxfb_fbops.fb_copyarea = s1d13xxxfb_bitblt_copyarea;
52889 + pax_close_kernel();
52890 info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_YPAN |
52891 FBINFO_HWACCEL_FILLRECT | FBINFO_HWACCEL_COPYAREA;
52892 break;
52893 diff --git a/drivers/video/smscufx.c b/drivers/video/smscufx.c
52894 index e188ada..aac63c8 100644
52895 --- a/drivers/video/smscufx.c
52896 +++ b/drivers/video/smscufx.c
52897 @@ -1175,7 +1175,9 @@ static int ufx_ops_release(struct fb_info *info, int user)
52898 fb_deferred_io_cleanup(info);
52899 kfree(info->fbdefio);
52900 info->fbdefio = NULL;
52901 - info->fbops->fb_mmap = ufx_ops_mmap;
52902 + pax_open_kernel();
52903 + *(void **)&info->fbops->fb_mmap = ufx_ops_mmap;
52904 + pax_close_kernel();
52905 }
52906
52907 pr_debug("released /dev/fb%d user=%d count=%d",
52908 diff --git a/drivers/video/udlfb.c b/drivers/video/udlfb.c
52909 index d2e5bc3..4cb05d1 100644
52910 --- a/drivers/video/udlfb.c
52911 +++ b/drivers/video/udlfb.c
52912 @@ -623,11 +623,11 @@ static int dlfb_handle_damage(struct dlfb_data *dev, int x, int y,
52913 dlfb_urb_completion(urb);
52914
52915 error:
52916 - atomic_add(bytes_sent, &dev->bytes_sent);
52917 - atomic_add(bytes_identical, &dev->bytes_identical);
52918 - atomic_add(width*height*2, &dev->bytes_rendered);
52919 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52920 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52921 + atomic_add_unchecked(width*height*2, &dev->bytes_rendered);
52922 end_cycles = get_cycles();
52923 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52924 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52925 >> 10)), /* Kcycles */
52926 &dev->cpu_kcycles_used);
52927
52928 @@ -748,11 +748,11 @@ static void dlfb_dpy_deferred_io(struct fb_info *info,
52929 dlfb_urb_completion(urb);
52930
52931 error:
52932 - atomic_add(bytes_sent, &dev->bytes_sent);
52933 - atomic_add(bytes_identical, &dev->bytes_identical);
52934 - atomic_add(bytes_rendered, &dev->bytes_rendered);
52935 + atomic_add_unchecked(bytes_sent, &dev->bytes_sent);
52936 + atomic_add_unchecked(bytes_identical, &dev->bytes_identical);
52937 + atomic_add_unchecked(bytes_rendered, &dev->bytes_rendered);
52938 end_cycles = get_cycles();
52939 - atomic_add(((unsigned int) ((end_cycles - start_cycles)
52940 + atomic_add_unchecked(((unsigned int) ((end_cycles - start_cycles)
52941 >> 10)), /* Kcycles */
52942 &dev->cpu_kcycles_used);
52943 }
52944 @@ -993,7 +993,9 @@ static int dlfb_ops_release(struct fb_info *info, int user)
52945 fb_deferred_io_cleanup(info);
52946 kfree(info->fbdefio);
52947 info->fbdefio = NULL;
52948 - info->fbops->fb_mmap = dlfb_ops_mmap;
52949 + pax_open_kernel();
52950 + *(void **)&info->fbops->fb_mmap = dlfb_ops_mmap;
52951 + pax_close_kernel();
52952 }
52953
52954 pr_warn("released /dev/fb%d user=%d count=%d\n",
52955 @@ -1376,7 +1378,7 @@ static ssize_t metrics_bytes_rendered_show(struct device *fbdev,
52956 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52957 struct dlfb_data *dev = fb_info->par;
52958 return snprintf(buf, PAGE_SIZE, "%u\n",
52959 - atomic_read(&dev->bytes_rendered));
52960 + atomic_read_unchecked(&dev->bytes_rendered));
52961 }
52962
52963 static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52964 @@ -1384,7 +1386,7 @@ static ssize_t metrics_bytes_identical_show(struct device *fbdev,
52965 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52966 struct dlfb_data *dev = fb_info->par;
52967 return snprintf(buf, PAGE_SIZE, "%u\n",
52968 - atomic_read(&dev->bytes_identical));
52969 + atomic_read_unchecked(&dev->bytes_identical));
52970 }
52971
52972 static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52973 @@ -1392,7 +1394,7 @@ static ssize_t metrics_bytes_sent_show(struct device *fbdev,
52974 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52975 struct dlfb_data *dev = fb_info->par;
52976 return snprintf(buf, PAGE_SIZE, "%u\n",
52977 - atomic_read(&dev->bytes_sent));
52978 + atomic_read_unchecked(&dev->bytes_sent));
52979 }
52980
52981 static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52982 @@ -1400,7 +1402,7 @@ static ssize_t metrics_cpu_kcycles_used_show(struct device *fbdev,
52983 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52984 struct dlfb_data *dev = fb_info->par;
52985 return snprintf(buf, PAGE_SIZE, "%u\n",
52986 - atomic_read(&dev->cpu_kcycles_used));
52987 + atomic_read_unchecked(&dev->cpu_kcycles_used));
52988 }
52989
52990 static ssize_t edid_show(
52991 @@ -1460,10 +1462,10 @@ static ssize_t metrics_reset_store(struct device *fbdev,
52992 struct fb_info *fb_info = dev_get_drvdata(fbdev);
52993 struct dlfb_data *dev = fb_info->par;
52994
52995 - atomic_set(&dev->bytes_rendered, 0);
52996 - atomic_set(&dev->bytes_identical, 0);
52997 - atomic_set(&dev->bytes_sent, 0);
52998 - atomic_set(&dev->cpu_kcycles_used, 0);
52999 + atomic_set_unchecked(&dev->bytes_rendered, 0);
53000 + atomic_set_unchecked(&dev->bytes_identical, 0);
53001 + atomic_set_unchecked(&dev->bytes_sent, 0);
53002 + atomic_set_unchecked(&dev->cpu_kcycles_used, 0);
53003
53004 return count;
53005 }
53006 diff --git a/drivers/video/uvesafb.c b/drivers/video/uvesafb.c
53007 index 7aec6f3..e3b2d55 100644
53008 --- a/drivers/video/uvesafb.c
53009 +++ b/drivers/video/uvesafb.c
53010 @@ -19,6 +19,7 @@
53011 #include <linux/io.h>
53012 #include <linux/mutex.h>
53013 #include <linux/slab.h>
53014 +#include <linux/moduleloader.h>
53015 #include <video/edid.h>
53016 #include <video/uvesafb.h>
53017 #ifdef CONFIG_X86
53018 @@ -566,10 +567,32 @@ static int uvesafb_vbe_getpmi(struct uvesafb_ktask *task,
53019 if ((task->t.regs.eax & 0xffff) != 0x4f || task->t.regs.es < 0xc000) {
53020 par->pmi_setpal = par->ypan = 0;
53021 } else {
53022 +
53023 +#ifdef CONFIG_PAX_KERNEXEC
53024 +#ifdef CONFIG_MODULES
53025 + par->pmi_code = module_alloc_exec((u16)task->t.regs.ecx);
53026 +#endif
53027 + if (!par->pmi_code) {
53028 + par->pmi_setpal = par->ypan = 0;
53029 + return 0;
53030 + }
53031 +#endif
53032 +
53033 par->pmi_base = (u16 *)phys_to_virt(((u32)task->t.regs.es << 4)
53034 + task->t.regs.edi);
53035 +
53036 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53037 + pax_open_kernel();
53038 + memcpy(par->pmi_code, par->pmi_base, (u16)task->t.regs.ecx);
53039 + pax_close_kernel();
53040 +
53041 + par->pmi_start = ktva_ktla(par->pmi_code + par->pmi_base[1]);
53042 + par->pmi_pal = ktva_ktla(par->pmi_code + par->pmi_base[2]);
53043 +#else
53044 par->pmi_start = (u8 *)par->pmi_base + par->pmi_base[1];
53045 par->pmi_pal = (u8 *)par->pmi_base + par->pmi_base[2];
53046 +#endif
53047 +
53048 printk(KERN_INFO "uvesafb: protected mode interface info at "
53049 "%04x:%04x\n",
53050 (u16)task->t.regs.es, (u16)task->t.regs.edi);
53051 @@ -814,13 +837,14 @@ static int uvesafb_vbe_init(struct fb_info *info)
53052 par->ypan = ypan;
53053
53054 if (par->pmi_setpal || par->ypan) {
53055 +#if !defined(CONFIG_MODULES) || !defined(CONFIG_PAX_KERNEXEC)
53056 if (__supported_pte_mask & _PAGE_NX) {
53057 par->pmi_setpal = par->ypan = 0;
53058 printk(KERN_WARNING "uvesafb: NX protection is active, "
53059 "better not use the PMI.\n");
53060 - } else {
53061 + } else
53062 +#endif
53063 uvesafb_vbe_getpmi(task, par);
53064 - }
53065 }
53066 #else
53067 /* The protected mode interface is not available on non-x86. */
53068 @@ -1454,8 +1478,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
53069 info->fix.ywrapstep = (par->ypan > 1) ? 1 : 0;
53070
53071 /* Disable blanking if the user requested so. */
53072 - if (!blank)
53073 - info->fbops->fb_blank = NULL;
53074 + if (!blank) {
53075 + pax_open_kernel();
53076 + *(void **)&info->fbops->fb_blank = NULL;
53077 + pax_close_kernel();
53078 + }
53079
53080 /*
53081 * Find out how much IO memory is required for the mode with
53082 @@ -1531,8 +1558,11 @@ static void uvesafb_init_info(struct fb_info *info, struct vbe_mode_ib *mode)
53083 info->flags = FBINFO_FLAG_DEFAULT |
53084 (par->ypan ? FBINFO_HWACCEL_YPAN : 0);
53085
53086 - if (!par->ypan)
53087 - info->fbops->fb_pan_display = NULL;
53088 + if (!par->ypan) {
53089 + pax_open_kernel();
53090 + *(void **)&info->fbops->fb_pan_display = NULL;
53091 + pax_close_kernel();
53092 + }
53093 }
53094
53095 static void uvesafb_init_mtrr(struct fb_info *info)
53096 @@ -1796,6 +1826,11 @@ out:
53097 if (par->vbe_modes)
53098 kfree(par->vbe_modes);
53099
53100 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53101 + if (par->pmi_code)
53102 + module_free_exec(NULL, par->pmi_code);
53103 +#endif
53104 +
53105 framebuffer_release(info);
53106 return err;
53107 }
53108 @@ -1823,6 +1858,12 @@ static int uvesafb_remove(struct platform_device *dev)
53109 kfree(par->vbe_state_orig);
53110 if (par->vbe_state_saved)
53111 kfree(par->vbe_state_saved);
53112 +
53113 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53114 + if (par->pmi_code)
53115 + module_free_exec(NULL, par->pmi_code);
53116 +#endif
53117 +
53118 }
53119
53120 framebuffer_release(info);
53121 diff --git a/drivers/video/vesafb.c b/drivers/video/vesafb.c
53122 index bd83233..7d8a5aa 100644
53123 --- a/drivers/video/vesafb.c
53124 +++ b/drivers/video/vesafb.c
53125 @@ -9,6 +9,7 @@
53126 */
53127
53128 #include <linux/module.h>
53129 +#include <linux/moduleloader.h>
53130 #include <linux/kernel.h>
53131 #include <linux/errno.h>
53132 #include <linux/string.h>
53133 @@ -52,8 +53,8 @@ static int vram_remap; /* Set amount of memory to be used */
53134 static int vram_total; /* Set total amount of memory */
53135 static int pmi_setpal __read_mostly = 1; /* pmi for palette changes ??? */
53136 static int ypan __read_mostly; /* 0..nothing, 1..ypan, 2..ywrap */
53137 -static void (*pmi_start)(void) __read_mostly;
53138 -static void (*pmi_pal) (void) __read_mostly;
53139 +static void (*pmi_start)(void) __read_only;
53140 +static void (*pmi_pal) (void) __read_only;
53141 static int depth __read_mostly;
53142 static int vga_compat __read_mostly;
53143 /* --------------------------------------------------------------------- */
53144 @@ -234,6 +235,7 @@ static int vesafb_probe(struct platform_device *dev)
53145 unsigned int size_remap;
53146 unsigned int size_total;
53147 char *option = NULL;
53148 + void *pmi_code = NULL;
53149
53150 /* ignore error return of fb_get_options */
53151 fb_get_options("vesafb", &option);
53152 @@ -280,10 +282,6 @@ static int vesafb_probe(struct platform_device *dev)
53153 size_remap = size_total;
53154 vesafb_fix.smem_len = size_remap;
53155
53156 -#ifndef __i386__
53157 - screen_info.vesapm_seg = 0;
53158 -#endif
53159 -
53160 if (!request_mem_region(vesafb_fix.smem_start, size_total, "vesafb")) {
53161 printk(KERN_WARNING
53162 "vesafb: cannot reserve video memory at 0x%lx\n",
53163 @@ -312,9 +310,21 @@ static int vesafb_probe(struct platform_device *dev)
53164 printk(KERN_INFO "vesafb: mode is %dx%dx%d, linelength=%d, pages=%d\n",
53165 vesafb_defined.xres, vesafb_defined.yres, vesafb_defined.bits_per_pixel, vesafb_fix.line_length, screen_info.pages);
53166
53167 +#ifdef __i386__
53168 +
53169 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53170 + pmi_code = module_alloc_exec(screen_info.vesapm_size);
53171 + if (!pmi_code)
53172 +#elif !defined(CONFIG_PAX_KERNEXEC)
53173 + if (0)
53174 +#endif
53175 +
53176 +#endif
53177 + screen_info.vesapm_seg = 0;
53178 +
53179 if (screen_info.vesapm_seg) {
53180 - printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x\n",
53181 - screen_info.vesapm_seg,screen_info.vesapm_off);
53182 + printk(KERN_INFO "vesafb: protected mode interface info at %04x:%04x %04x bytes\n",
53183 + screen_info.vesapm_seg,screen_info.vesapm_off,screen_info.vesapm_size);
53184 }
53185
53186 if (screen_info.vesapm_seg < 0xc000)
53187 @@ -322,9 +332,25 @@ static int vesafb_probe(struct platform_device *dev)
53188
53189 if (ypan || pmi_setpal) {
53190 unsigned short *pmi_base;
53191 +
53192 pmi_base = (unsigned short*)phys_to_virt(((unsigned long)screen_info.vesapm_seg << 4) + screen_info.vesapm_off);
53193 - pmi_start = (void*)((char*)pmi_base + pmi_base[1]);
53194 - pmi_pal = (void*)((char*)pmi_base + pmi_base[2]);
53195 +
53196 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53197 + pax_open_kernel();
53198 + memcpy(pmi_code, pmi_base, screen_info.vesapm_size);
53199 +#else
53200 + pmi_code = pmi_base;
53201 +#endif
53202 +
53203 + pmi_start = (void*)((char*)pmi_code + pmi_base[1]);
53204 + pmi_pal = (void*)((char*)pmi_code + pmi_base[2]);
53205 +
53206 +#if defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53207 + pmi_start = ktva_ktla(pmi_start);
53208 + pmi_pal = ktva_ktla(pmi_pal);
53209 + pax_close_kernel();
53210 +#endif
53211 +
53212 printk(KERN_INFO "vesafb: pmi: set display start = %p, set palette = %p\n",pmi_start,pmi_pal);
53213 if (pmi_base[3]) {
53214 printk(KERN_INFO "vesafb: pmi: ports = ");
53215 @@ -477,8 +503,11 @@ static int vesafb_probe(struct platform_device *dev)
53216 info->flags = FBINFO_FLAG_DEFAULT | FBINFO_MISC_FIRMWARE |
53217 (ypan ? FBINFO_HWACCEL_YPAN : 0);
53218
53219 - if (!ypan)
53220 - info->fbops->fb_pan_display = NULL;
53221 + if (!ypan) {
53222 + pax_open_kernel();
53223 + *(void **)&info->fbops->fb_pan_display = NULL;
53224 + pax_close_kernel();
53225 + }
53226
53227 if (fb_alloc_cmap(&info->cmap, 256, 0) < 0) {
53228 err = -ENOMEM;
53229 @@ -493,6 +522,11 @@ static int vesafb_probe(struct platform_device *dev)
53230 info->node, info->fix.id);
53231 return 0;
53232 err:
53233 +
53234 +#if defined(__i386__) && defined(CONFIG_MODULES) && defined(CONFIG_PAX_KERNEXEC)
53235 + module_free_exec(NULL, pmi_code);
53236 +#endif
53237 +
53238 if (info->screen_base)
53239 iounmap(info->screen_base);
53240 framebuffer_release(info);
53241 diff --git a/drivers/video/via/via_clock.h b/drivers/video/via/via_clock.h
53242 index 88714ae..16c2e11 100644
53243 --- a/drivers/video/via/via_clock.h
53244 +++ b/drivers/video/via/via_clock.h
53245 @@ -56,7 +56,7 @@ struct via_clock {
53246
53247 void (*set_engine_pll_state)(u8 state);
53248 void (*set_engine_pll)(struct via_pll_config config);
53249 -};
53250 +} __no_const;
53251
53252
53253 static inline u32 get_pll_internal_frequency(u32 ref_freq,
53254 diff --git a/drivers/xen/xenfs/xenstored.c b/drivers/xen/xenfs/xenstored.c
53255 index fef20db..d28b1ab 100644
53256 --- a/drivers/xen/xenfs/xenstored.c
53257 +++ b/drivers/xen/xenfs/xenstored.c
53258 @@ -24,7 +24,12 @@ static int xsd_release(struct inode *inode, struct file *file)
53259 static int xsd_kva_open(struct inode *inode, struct file *file)
53260 {
53261 file->private_data = (void *)kasprintf(GFP_KERNEL, "0x%p",
53262 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53263 + NULL);
53264 +#else
53265 xen_store_interface);
53266 +#endif
53267 +
53268 if (!file->private_data)
53269 return -ENOMEM;
53270 return 0;
53271 diff --git a/fs/9p/vfs_addr.c b/fs/9p/vfs_addr.c
53272 index 9ff073f..05cef23 100644
53273 --- a/fs/9p/vfs_addr.c
53274 +++ b/fs/9p/vfs_addr.c
53275 @@ -187,7 +187,7 @@ static int v9fs_vfs_writepage_locked(struct page *page)
53276
53277 retval = v9fs_file_write_internal(inode,
53278 v9inode->writeback_fid,
53279 - (__force const char __user *)buffer,
53280 + (const char __force_user *)buffer,
53281 len, &offset, 0);
53282 if (retval > 0)
53283 retval = 0;
53284 diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c
53285 index 94de6d1..8d81256 100644
53286 --- a/fs/9p/vfs_inode.c
53287 +++ b/fs/9p/vfs_inode.c
53288 @@ -1312,7 +1312,7 @@ static void *v9fs_vfs_follow_link(struct dentry *dentry, struct nameidata *nd)
53289 void
53290 v9fs_vfs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53291 {
53292 - char *s = nd_get_link(nd);
53293 + const char *s = nd_get_link(nd);
53294
53295 p9_debug(P9_DEBUG_VFS, " %s %s\n",
53296 dentry->d_name.name, IS_ERR(s) ? "<error>" : s);
53297 diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt
53298 index 370b24c..ff0be7b 100644
53299 --- a/fs/Kconfig.binfmt
53300 +++ b/fs/Kconfig.binfmt
53301 @@ -103,7 +103,7 @@ config HAVE_AOUT
53302
53303 config BINFMT_AOUT
53304 tristate "Kernel support for a.out and ECOFF binaries"
53305 - depends on HAVE_AOUT
53306 + depends on HAVE_AOUT && BROKEN
53307 ---help---
53308 A.out (Assembler.OUTput) is a set of formats for libraries and
53309 executables used in the earliest versions of UNIX. Linux used
53310 diff --git a/fs/afs/inode.c b/fs/afs/inode.c
53311 index 789bc25..fafaeea 100644
53312 --- a/fs/afs/inode.c
53313 +++ b/fs/afs/inode.c
53314 @@ -141,7 +141,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53315 struct afs_vnode *vnode;
53316 struct super_block *sb;
53317 struct inode *inode;
53318 - static atomic_t afs_autocell_ino;
53319 + static atomic_unchecked_t afs_autocell_ino;
53320
53321 _enter("{%x:%u},%*.*s,",
53322 AFS_FS_I(dir)->fid.vid, AFS_FS_I(dir)->fid.vnode,
53323 @@ -154,7 +154,7 @@ struct inode *afs_iget_autocell(struct inode *dir, const char *dev_name,
53324 data.fid.unique = 0;
53325 data.fid.vnode = 0;
53326
53327 - inode = iget5_locked(sb, atomic_inc_return(&afs_autocell_ino),
53328 + inode = iget5_locked(sb, atomic_inc_return_unchecked(&afs_autocell_ino),
53329 afs_iget5_autocell_test, afs_iget5_set,
53330 &data);
53331 if (!inode) {
53332 diff --git a/fs/aio.c b/fs/aio.c
53333 index 062a5f6..e5618e0 100644
53334 --- a/fs/aio.c
53335 +++ b/fs/aio.c
53336 @@ -374,7 +374,7 @@ static int aio_setup_ring(struct kioctx *ctx)
53337 size += sizeof(struct io_event) * nr_events;
53338
53339 nr_pages = PFN_UP(size);
53340 - if (nr_pages < 0)
53341 + if (nr_pages <= 0)
53342 return -EINVAL;
53343
53344 file = aio_private_file(ctx, nr_pages);
53345 diff --git a/fs/attr.c b/fs/attr.c
53346 index 1449adb..a2038c2 100644
53347 --- a/fs/attr.c
53348 +++ b/fs/attr.c
53349 @@ -102,6 +102,7 @@ int inode_newsize_ok(const struct inode *inode, loff_t offset)
53350 unsigned long limit;
53351
53352 limit = rlimit(RLIMIT_FSIZE);
53353 + gr_learn_resource(current, RLIMIT_FSIZE, (unsigned long)offset, 1);
53354 if (limit != RLIM_INFINITY && offset > limit)
53355 goto out_sig;
53356 if (offset > inode->i_sb->s_maxbytes)
53357 diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c
53358 index 689e40d..515cac5 100644
53359 --- a/fs/autofs4/waitq.c
53360 +++ b/fs/autofs4/waitq.c
53361 @@ -59,7 +59,7 @@ static int autofs4_write(struct autofs_sb_info *sbi,
53362 {
53363 unsigned long sigpipe, flags;
53364 mm_segment_t fs;
53365 - const char *data = (const char *)addr;
53366 + const char __user *data = (const char __force_user *)addr;
53367 ssize_t wr = 0;
53368
53369 sigpipe = sigismember(&current->pending.signal, SIGPIPE);
53370 @@ -340,6 +340,10 @@ static int validate_request(struct autofs_wait_queue **wait,
53371 return 1;
53372 }
53373
53374 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53375 +static atomic_unchecked_t autofs_dummy_name_id = ATOMIC_INIT(0);
53376 +#endif
53377 +
53378 int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53379 enum autofs_notify notify)
53380 {
53381 @@ -373,7 +377,12 @@ int autofs4_wait(struct autofs_sb_info *sbi, struct dentry *dentry,
53382
53383 /* If this is a direct mount request create a dummy name */
53384 if (IS_ROOT(dentry) && autofs_type_trigger(sbi->type))
53385 +#ifdef CONFIG_GRKERNSEC_HIDESYM
53386 + /* this name does get written to userland via autofs4_write() */
53387 + qstr.len = sprintf(name, "%08x", atomic_inc_return_unchecked(&autofs_dummy_name_id));
53388 +#else
53389 qstr.len = sprintf(name, "%p", dentry);
53390 +#endif
53391 else {
53392 qstr.len = autofs4_getpath(sbi, dentry, &name);
53393 if (!qstr.len) {
53394 diff --git a/fs/befs/endian.h b/fs/befs/endian.h
53395 index 2722387..56059b5 100644
53396 --- a/fs/befs/endian.h
53397 +++ b/fs/befs/endian.h
53398 @@ -11,7 +11,7 @@
53399
53400 #include <asm/byteorder.h>
53401
53402 -static inline u64
53403 +static inline u64 __intentional_overflow(-1)
53404 fs64_to_cpu(const struct super_block *sb, fs64 n)
53405 {
53406 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53407 @@ -29,7 +29,7 @@ cpu_to_fs64(const struct super_block *sb, u64 n)
53408 return (__force fs64)cpu_to_be64(n);
53409 }
53410
53411 -static inline u32
53412 +static inline u32 __intentional_overflow(-1)
53413 fs32_to_cpu(const struct super_block *sb, fs32 n)
53414 {
53415 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53416 @@ -47,7 +47,7 @@ cpu_to_fs32(const struct super_block *sb, u32 n)
53417 return (__force fs32)cpu_to_be32(n);
53418 }
53419
53420 -static inline u16
53421 +static inline u16 __intentional_overflow(-1)
53422 fs16_to_cpu(const struct super_block *sb, fs16 n)
53423 {
53424 if (BEFS_SB(sb)->byte_order == BEFS_BYTESEX_LE)
53425 diff --git a/fs/befs/linuxvfs.c b/fs/befs/linuxvfs.c
53426 index e9c75e2..1baece1 100644
53427 --- a/fs/befs/linuxvfs.c
53428 +++ b/fs/befs/linuxvfs.c
53429 @@ -514,7 +514,7 @@ static void befs_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
53430 {
53431 befs_inode_info *befs_ino = BEFS_I(dentry->d_inode);
53432 if (befs_ino->i_flags & BEFS_LONG_SYMLINK) {
53433 - char *link = nd_get_link(nd);
53434 + const char *link = nd_get_link(nd);
53435 if (!IS_ERR(link))
53436 kfree(link);
53437 }
53438 diff --git a/fs/binfmt_aout.c b/fs/binfmt_aout.c
53439 index 89dec7f..361b0d75 100644
53440 --- a/fs/binfmt_aout.c
53441 +++ b/fs/binfmt_aout.c
53442 @@ -16,6 +16,7 @@
53443 #include <linux/string.h>
53444 #include <linux/fs.h>
53445 #include <linux/file.h>
53446 +#include <linux/security.h>
53447 #include <linux/stat.h>
53448 #include <linux/fcntl.h>
53449 #include <linux/ptrace.h>
53450 @@ -59,6 +60,8 @@ static int aout_core_dump(struct coredump_params *cprm)
53451 #endif
53452 # define START_STACK(u) ((void __user *)u.start_stack)
53453
53454 + memset(&dump, 0, sizeof(dump));
53455 +
53456 fs = get_fs();
53457 set_fs(KERNEL_DS);
53458 has_dumped = 1;
53459 @@ -69,10 +72,12 @@ static int aout_core_dump(struct coredump_params *cprm)
53460
53461 /* If the size of the dump file exceeds the rlimit, then see what would happen
53462 if we wrote the stack, but not the data area. */
53463 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE, 1);
53464 if ((dump.u_dsize + dump.u_ssize+1) * PAGE_SIZE > cprm->limit)
53465 dump.u_dsize = 0;
53466
53467 /* Make sure we have enough room to write the stack and data areas. */
53468 + gr_learn_resource(current, RLIMIT_CORE, (dump.u_ssize + 1) * PAGE_SIZE, 1);
53469 if ((dump.u_ssize + 1) * PAGE_SIZE > cprm->limit)
53470 dump.u_ssize = 0;
53471
53472 @@ -233,6 +238,8 @@ static int load_aout_binary(struct linux_binprm * bprm)
53473 rlim = rlimit(RLIMIT_DATA);
53474 if (rlim >= RLIM_INFINITY)
53475 rlim = ~0;
53476 +
53477 + gr_learn_resource(current, RLIMIT_DATA, ex.a_data + ex.a_bss, 1);
53478 if (ex.a_data + ex.a_bss > rlim)
53479 return -ENOMEM;
53480
53481 @@ -265,6 +272,27 @@ static int load_aout_binary(struct linux_binprm * bprm)
53482
53483 install_exec_creds(bprm);
53484
53485 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53486 + current->mm->pax_flags = 0UL;
53487 +#endif
53488 +
53489 +#ifdef CONFIG_PAX_PAGEEXEC
53490 + if (!(N_FLAGS(ex) & F_PAX_PAGEEXEC)) {
53491 + current->mm->pax_flags |= MF_PAX_PAGEEXEC;
53492 +
53493 +#ifdef CONFIG_PAX_EMUTRAMP
53494 + if (N_FLAGS(ex) & F_PAX_EMUTRAMP)
53495 + current->mm->pax_flags |= MF_PAX_EMUTRAMP;
53496 +#endif
53497 +
53498 +#ifdef CONFIG_PAX_MPROTECT
53499 + if (!(N_FLAGS(ex) & F_PAX_MPROTECT))
53500 + current->mm->pax_flags |= MF_PAX_MPROTECT;
53501 +#endif
53502 +
53503 + }
53504 +#endif
53505 +
53506 if (N_MAGIC(ex) == OMAGIC) {
53507 unsigned long text_addr, map_size;
53508 loff_t pos;
53509 @@ -322,7 +350,7 @@ static int load_aout_binary(struct linux_binprm * bprm)
53510 }
53511
53512 error = vm_mmap(bprm->file, N_DATADDR(ex), ex.a_data,
53513 - PROT_READ | PROT_WRITE | PROT_EXEC,
53514 + PROT_READ | PROT_WRITE,
53515 MAP_FIXED | MAP_PRIVATE | MAP_DENYWRITE | MAP_EXECUTABLE,
53516 fd_offset + ex.a_text);
53517 if (error != N_DATADDR(ex)) {
53518 diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
53519 index 4c94a79..228e9da 100644
53520 --- a/fs/binfmt_elf.c
53521 +++ b/fs/binfmt_elf.c
53522 @@ -34,6 +34,7 @@
53523 #include <linux/utsname.h>
53524 #include <linux/coredump.h>
53525 #include <linux/sched.h>
53526 +#include <linux/xattr.h>
53527 #include <asm/uaccess.h>
53528 #include <asm/param.h>
53529 #include <asm/page.h>
53530 @@ -60,6 +61,14 @@ static int elf_core_dump(struct coredump_params *cprm);
53531 #define elf_core_dump NULL
53532 #endif
53533
53534 +#ifdef CONFIG_PAX_MPROTECT
53535 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags);
53536 +#endif
53537 +
53538 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53539 +static void elf_handle_mmap(struct file *file);
53540 +#endif
53541 +
53542 #if ELF_EXEC_PAGESIZE > PAGE_SIZE
53543 #define ELF_MIN_ALIGN ELF_EXEC_PAGESIZE
53544 #else
53545 @@ -79,6 +88,15 @@ static struct linux_binfmt elf_format = {
53546 .load_binary = load_elf_binary,
53547 .load_shlib = load_elf_library,
53548 .core_dump = elf_core_dump,
53549 +
53550 +#ifdef CONFIG_PAX_MPROTECT
53551 + .handle_mprotect= elf_handle_mprotect,
53552 +#endif
53553 +
53554 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
53555 + .handle_mmap = elf_handle_mmap,
53556 +#endif
53557 +
53558 .min_coredump = ELF_EXEC_PAGESIZE,
53559 };
53560
53561 @@ -86,6 +104,8 @@ static struct linux_binfmt elf_format = {
53562
53563 static int set_brk(unsigned long start, unsigned long end)
53564 {
53565 + unsigned long e = end;
53566 +
53567 start = ELF_PAGEALIGN(start);
53568 end = ELF_PAGEALIGN(end);
53569 if (end > start) {
53570 @@ -94,7 +114,7 @@ static int set_brk(unsigned long start, unsigned long end)
53571 if (BAD_ADDR(addr))
53572 return addr;
53573 }
53574 - current->mm->start_brk = current->mm->brk = end;
53575 + current->mm->start_brk = current->mm->brk = e;
53576 return 0;
53577 }
53578
53579 @@ -155,12 +175,13 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53580 elf_addr_t __user *u_rand_bytes;
53581 const char *k_platform = ELF_PLATFORM;
53582 const char *k_base_platform = ELF_BASE_PLATFORM;
53583 - unsigned char k_rand_bytes[16];
53584 + u32 k_rand_bytes[4];
53585 int items;
53586 elf_addr_t *elf_info;
53587 int ei_index = 0;
53588 const struct cred *cred = current_cred();
53589 struct vm_area_struct *vma;
53590 + unsigned long saved_auxv[AT_VECTOR_SIZE];
53591
53592 /*
53593 * In some cases (e.g. Hyper-Threading), we want to avoid L1
53594 @@ -202,8 +223,12 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53595 * Generate 16 random bytes for userspace PRNG seeding.
53596 */
53597 get_random_bytes(k_rand_bytes, sizeof(k_rand_bytes));
53598 - u_rand_bytes = (elf_addr_t __user *)
53599 - STACK_ALLOC(p, sizeof(k_rand_bytes));
53600 + prandom_seed(k_rand_bytes[0] ^ prandom_u32());
53601 + prandom_seed(k_rand_bytes[1] ^ prandom_u32());
53602 + prandom_seed(k_rand_bytes[2] ^ prandom_u32());
53603 + prandom_seed(k_rand_bytes[3] ^ prandom_u32());
53604 + p = STACK_ROUND(p, sizeof(k_rand_bytes));
53605 + u_rand_bytes = (elf_addr_t __user *) p;
53606 if (__copy_to_user(u_rand_bytes, k_rand_bytes, sizeof(k_rand_bytes)))
53607 return -EFAULT;
53608
53609 @@ -318,9 +343,11 @@ create_elf_tables(struct linux_binprm *bprm, struct elfhdr *exec,
53610 return -EFAULT;
53611 current->mm->env_end = p;
53612
53613 + memcpy(saved_auxv, elf_info, ei_index * sizeof(elf_addr_t));
53614 +
53615 /* Put the elf_info on the stack in the right place. */
53616 sp = (elf_addr_t __user *)envp + 1;
53617 - if (copy_to_user(sp, elf_info, ei_index * sizeof(elf_addr_t)))
53618 + if (copy_to_user(sp, saved_auxv, ei_index * sizeof(elf_addr_t)))
53619 return -EFAULT;
53620 return 0;
53621 }
53622 @@ -388,15 +415,14 @@ static unsigned long total_mapping_size(struct elf_phdr *cmds, int nr)
53623 an ELF header */
53624
53625 static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53626 - struct file *interpreter, unsigned long *interp_map_addr,
53627 - unsigned long no_base)
53628 + struct file *interpreter, unsigned long no_base)
53629 {
53630 struct elf_phdr *elf_phdata;
53631 struct elf_phdr *eppnt;
53632 - unsigned long load_addr = 0;
53633 + unsigned long load_addr = 0, pax_task_size = TASK_SIZE;
53634 int load_addr_set = 0;
53635 unsigned long last_bss = 0, elf_bss = 0;
53636 - unsigned long error = ~0UL;
53637 + unsigned long error = -EINVAL;
53638 unsigned long total_size;
53639 int retval, i, size;
53640
53641 @@ -442,6 +468,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53642 goto out_close;
53643 }
53644
53645 +#ifdef CONFIG_PAX_SEGMEXEC
53646 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC)
53647 + pax_task_size = SEGMEXEC_TASK_SIZE;
53648 +#endif
53649 +
53650 eppnt = elf_phdata;
53651 for (i = 0; i < interp_elf_ex->e_phnum; i++, eppnt++) {
53652 if (eppnt->p_type == PT_LOAD) {
53653 @@ -465,8 +496,6 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53654 map_addr = elf_map(interpreter, load_addr + vaddr,
53655 eppnt, elf_prot, elf_type, total_size);
53656 total_size = 0;
53657 - if (!*interp_map_addr)
53658 - *interp_map_addr = map_addr;
53659 error = map_addr;
53660 if (BAD_ADDR(map_addr))
53661 goto out_close;
53662 @@ -485,8 +514,8 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53663 k = load_addr + eppnt->p_vaddr;
53664 if (BAD_ADDR(k) ||
53665 eppnt->p_filesz > eppnt->p_memsz ||
53666 - eppnt->p_memsz > TASK_SIZE ||
53667 - TASK_SIZE - eppnt->p_memsz < k) {
53668 + eppnt->p_memsz > pax_task_size ||
53669 + pax_task_size - eppnt->p_memsz < k) {
53670 error = -ENOMEM;
53671 goto out_close;
53672 }
53673 @@ -525,9 +554,11 @@ static unsigned long load_elf_interp(struct elfhdr *interp_elf_ex,
53674 elf_bss = ELF_PAGESTART(elf_bss + ELF_MIN_ALIGN - 1);
53675
53676 /* Map the last of the bss segment */
53677 - error = vm_brk(elf_bss, last_bss - elf_bss);
53678 - if (BAD_ADDR(error))
53679 - goto out_close;
53680 + if (last_bss > elf_bss) {
53681 + error = vm_brk(elf_bss, last_bss - elf_bss);
53682 + if (BAD_ADDR(error))
53683 + goto out_close;
53684 + }
53685 }
53686
53687 error = load_addr;
53688 @@ -538,6 +569,322 @@ out:
53689 return error;
53690 }
53691
53692 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53693 +#ifdef CONFIG_PAX_SOFTMODE
53694 +static unsigned long pax_parse_pt_pax_softmode(const struct elf_phdr * const elf_phdata)
53695 +{
53696 + unsigned long pax_flags = 0UL;
53697 +
53698 +#ifdef CONFIG_PAX_PAGEEXEC
53699 + if (elf_phdata->p_flags & PF_PAGEEXEC)
53700 + pax_flags |= MF_PAX_PAGEEXEC;
53701 +#endif
53702 +
53703 +#ifdef CONFIG_PAX_SEGMEXEC
53704 + if (elf_phdata->p_flags & PF_SEGMEXEC)
53705 + pax_flags |= MF_PAX_SEGMEXEC;
53706 +#endif
53707 +
53708 +#ifdef CONFIG_PAX_EMUTRAMP
53709 + if ((elf_phdata->p_flags & PF_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53710 + pax_flags |= MF_PAX_EMUTRAMP;
53711 +#endif
53712 +
53713 +#ifdef CONFIG_PAX_MPROTECT
53714 + if (elf_phdata->p_flags & PF_MPROTECT)
53715 + pax_flags |= MF_PAX_MPROTECT;
53716 +#endif
53717 +
53718 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53719 + if (randomize_va_space && (elf_phdata->p_flags & PF_RANDMMAP))
53720 + pax_flags |= MF_PAX_RANDMMAP;
53721 +#endif
53722 +
53723 + return pax_flags;
53724 +}
53725 +#endif
53726 +
53727 +static unsigned long pax_parse_pt_pax_hardmode(const struct elf_phdr * const elf_phdata)
53728 +{
53729 + unsigned long pax_flags = 0UL;
53730 +
53731 +#ifdef CONFIG_PAX_PAGEEXEC
53732 + if (!(elf_phdata->p_flags & PF_NOPAGEEXEC))
53733 + pax_flags |= MF_PAX_PAGEEXEC;
53734 +#endif
53735 +
53736 +#ifdef CONFIG_PAX_SEGMEXEC
53737 + if (!(elf_phdata->p_flags & PF_NOSEGMEXEC))
53738 + pax_flags |= MF_PAX_SEGMEXEC;
53739 +#endif
53740 +
53741 +#ifdef CONFIG_PAX_EMUTRAMP
53742 + if (!(elf_phdata->p_flags & PF_NOEMUTRAMP))
53743 + pax_flags |= MF_PAX_EMUTRAMP;
53744 +#endif
53745 +
53746 +#ifdef CONFIG_PAX_MPROTECT
53747 + if (!(elf_phdata->p_flags & PF_NOMPROTECT))
53748 + pax_flags |= MF_PAX_MPROTECT;
53749 +#endif
53750 +
53751 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53752 + if (randomize_va_space && !(elf_phdata->p_flags & PF_NORANDMMAP))
53753 + pax_flags |= MF_PAX_RANDMMAP;
53754 +#endif
53755 +
53756 + return pax_flags;
53757 +}
53758 +#endif
53759 +
53760 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53761 +#ifdef CONFIG_PAX_SOFTMODE
53762 +static unsigned long pax_parse_xattr_pax_softmode(unsigned long pax_flags_softmode)
53763 +{
53764 + unsigned long pax_flags = 0UL;
53765 +
53766 +#ifdef CONFIG_PAX_PAGEEXEC
53767 + if (pax_flags_softmode & MF_PAX_PAGEEXEC)
53768 + pax_flags |= MF_PAX_PAGEEXEC;
53769 +#endif
53770 +
53771 +#ifdef CONFIG_PAX_SEGMEXEC
53772 + if (pax_flags_softmode & MF_PAX_SEGMEXEC)
53773 + pax_flags |= MF_PAX_SEGMEXEC;
53774 +#endif
53775 +
53776 +#ifdef CONFIG_PAX_EMUTRAMP
53777 + if ((pax_flags_softmode & MF_PAX_EMUTRAMP) && (pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)))
53778 + pax_flags |= MF_PAX_EMUTRAMP;
53779 +#endif
53780 +
53781 +#ifdef CONFIG_PAX_MPROTECT
53782 + if (pax_flags_softmode & MF_PAX_MPROTECT)
53783 + pax_flags |= MF_PAX_MPROTECT;
53784 +#endif
53785 +
53786 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53787 + if (randomize_va_space && (pax_flags_softmode & MF_PAX_RANDMMAP))
53788 + pax_flags |= MF_PAX_RANDMMAP;
53789 +#endif
53790 +
53791 + return pax_flags;
53792 +}
53793 +#endif
53794 +
53795 +static unsigned long pax_parse_xattr_pax_hardmode(unsigned long pax_flags_hardmode)
53796 +{
53797 + unsigned long pax_flags = 0UL;
53798 +
53799 +#ifdef CONFIG_PAX_PAGEEXEC
53800 + if (!(pax_flags_hardmode & MF_PAX_PAGEEXEC))
53801 + pax_flags |= MF_PAX_PAGEEXEC;
53802 +#endif
53803 +
53804 +#ifdef CONFIG_PAX_SEGMEXEC
53805 + if (!(pax_flags_hardmode & MF_PAX_SEGMEXEC))
53806 + pax_flags |= MF_PAX_SEGMEXEC;
53807 +#endif
53808 +
53809 +#ifdef CONFIG_PAX_EMUTRAMP
53810 + if (!(pax_flags_hardmode & MF_PAX_EMUTRAMP))
53811 + pax_flags |= MF_PAX_EMUTRAMP;
53812 +#endif
53813 +
53814 +#ifdef CONFIG_PAX_MPROTECT
53815 + if (!(pax_flags_hardmode & MF_PAX_MPROTECT))
53816 + pax_flags |= MF_PAX_MPROTECT;
53817 +#endif
53818 +
53819 +#if defined(CONFIG_PAX_RANDMMAP) || defined(CONFIG_PAX_RANDUSTACK)
53820 + if (randomize_va_space && !(pax_flags_hardmode & MF_PAX_RANDMMAP))
53821 + pax_flags |= MF_PAX_RANDMMAP;
53822 +#endif
53823 +
53824 + return pax_flags;
53825 +}
53826 +#endif
53827 +
53828 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
53829 +static unsigned long pax_parse_ei_pax(const struct elfhdr * const elf_ex)
53830 +{
53831 + unsigned long pax_flags = 0UL;
53832 +
53833 +#ifdef CONFIG_PAX_EI_PAX
53834 +
53835 +#ifdef CONFIG_PAX_PAGEEXEC
53836 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_PAGEEXEC))
53837 + pax_flags |= MF_PAX_PAGEEXEC;
53838 +#endif
53839 +
53840 +#ifdef CONFIG_PAX_SEGMEXEC
53841 + if (!(elf_ex->e_ident[EI_PAX] & EF_PAX_SEGMEXEC))
53842 + pax_flags |= MF_PAX_SEGMEXEC;
53843 +#endif
53844 +
53845 +#ifdef CONFIG_PAX_EMUTRAMP
53846 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && (elf_ex->e_ident[EI_PAX] & EF_PAX_EMUTRAMP))
53847 + pax_flags |= MF_PAX_EMUTRAMP;
53848 +#endif
53849 +
53850 +#ifdef CONFIG_PAX_MPROTECT
53851 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) && !(elf_ex->e_ident[EI_PAX] & EF_PAX_MPROTECT))
53852 + pax_flags |= MF_PAX_MPROTECT;
53853 +#endif
53854 +
53855 +#ifdef CONFIG_PAX_ASLR
53856 + if (randomize_va_space && !(elf_ex->e_ident[EI_PAX] & EF_PAX_RANDMMAP))
53857 + pax_flags |= MF_PAX_RANDMMAP;
53858 +#endif
53859 +
53860 +#else
53861 +
53862 +#ifdef CONFIG_PAX_PAGEEXEC
53863 + pax_flags |= MF_PAX_PAGEEXEC;
53864 +#endif
53865 +
53866 +#ifdef CONFIG_PAX_SEGMEXEC
53867 + pax_flags |= MF_PAX_SEGMEXEC;
53868 +#endif
53869 +
53870 +#ifdef CONFIG_PAX_MPROTECT
53871 + pax_flags |= MF_PAX_MPROTECT;
53872 +#endif
53873 +
53874 +#ifdef CONFIG_PAX_RANDMMAP
53875 + if (randomize_va_space)
53876 + pax_flags |= MF_PAX_RANDMMAP;
53877 +#endif
53878 +
53879 +#endif
53880 +
53881 + return pax_flags;
53882 +}
53883 +
53884 +static unsigned long pax_parse_pt_pax(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata)
53885 +{
53886 +
53887 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
53888 + unsigned long i;
53889 +
53890 + for (i = 0UL; i < elf_ex->e_phnum; i++)
53891 + if (elf_phdata[i].p_type == PT_PAX_FLAGS) {
53892 + if (((elf_phdata[i].p_flags & PF_PAGEEXEC) && (elf_phdata[i].p_flags & PF_NOPAGEEXEC)) ||
53893 + ((elf_phdata[i].p_flags & PF_SEGMEXEC) && (elf_phdata[i].p_flags & PF_NOSEGMEXEC)) ||
53894 + ((elf_phdata[i].p_flags & PF_EMUTRAMP) && (elf_phdata[i].p_flags & PF_NOEMUTRAMP)) ||
53895 + ((elf_phdata[i].p_flags & PF_MPROTECT) && (elf_phdata[i].p_flags & PF_NOMPROTECT)) ||
53896 + ((elf_phdata[i].p_flags & PF_RANDMMAP) && (elf_phdata[i].p_flags & PF_NORANDMMAP)))
53897 + return ~0UL;
53898 +
53899 +#ifdef CONFIG_PAX_SOFTMODE
53900 + if (pax_softmode)
53901 + return pax_parse_pt_pax_softmode(&elf_phdata[i]);
53902 + else
53903 +#endif
53904 +
53905 + return pax_parse_pt_pax_hardmode(&elf_phdata[i]);
53906 + break;
53907 + }
53908 +#endif
53909 +
53910 + return ~0UL;
53911 +}
53912 +
53913 +static unsigned long pax_parse_xattr_pax(struct file * const file)
53914 +{
53915 +
53916 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
53917 + ssize_t xattr_size, i;
53918 + unsigned char xattr_value[sizeof("pemrs") - 1];
53919 + unsigned long pax_flags_hardmode = 0UL, pax_flags_softmode = 0UL;
53920 +
53921 + xattr_size = pax_getxattr(file->f_path.dentry, xattr_value, sizeof xattr_value);
53922 + switch (xattr_size) {
53923 + default:
53924 + return ~0UL;
53925 +
53926 + case -ENODATA:
53927 + break;
53928 +
53929 + case 0 ... sizeof xattr_value:
53930 + for (i = 0; i < xattr_size; i++)
53931 + switch (xattr_value[i]) {
53932 + default:
53933 + return ~0UL;
53934 +
53935 +#define parse_flag(option1, option2, flag) \
53936 + case option1: \
53937 + if (pax_flags_hardmode & MF_PAX_##flag) \
53938 + return ~0UL; \
53939 + pax_flags_hardmode |= MF_PAX_##flag; \
53940 + break; \
53941 + case option2: \
53942 + if (pax_flags_softmode & MF_PAX_##flag) \
53943 + return ~0UL; \
53944 + pax_flags_softmode |= MF_PAX_##flag; \
53945 + break;
53946 +
53947 + parse_flag('p', 'P', PAGEEXEC);
53948 + parse_flag('e', 'E', EMUTRAMP);
53949 + parse_flag('m', 'M', MPROTECT);
53950 + parse_flag('r', 'R', RANDMMAP);
53951 + parse_flag('s', 'S', SEGMEXEC);
53952 +
53953 +#undef parse_flag
53954 + }
53955 + break;
53956 + }
53957 +
53958 + if (pax_flags_hardmode & pax_flags_softmode)
53959 + return ~0UL;
53960 +
53961 +#ifdef CONFIG_PAX_SOFTMODE
53962 + if (pax_softmode)
53963 + return pax_parse_xattr_pax_softmode(pax_flags_softmode);
53964 + else
53965 +#endif
53966 +
53967 + return pax_parse_xattr_pax_hardmode(pax_flags_hardmode);
53968 +#else
53969 + return ~0UL;
53970 +#endif
53971 +
53972 +}
53973 +
53974 +static long pax_parse_pax_flags(const struct elfhdr * const elf_ex, const struct elf_phdr * const elf_phdata, struct file * const file)
53975 +{
53976 + unsigned long pax_flags, pt_pax_flags, xattr_pax_flags;
53977 +
53978 + pax_flags = pax_parse_ei_pax(elf_ex);
53979 + pt_pax_flags = pax_parse_pt_pax(elf_ex, elf_phdata);
53980 + xattr_pax_flags = pax_parse_xattr_pax(file);
53981 +
53982 + if (pt_pax_flags == ~0UL)
53983 + pt_pax_flags = xattr_pax_flags;
53984 + else if (xattr_pax_flags == ~0UL)
53985 + xattr_pax_flags = pt_pax_flags;
53986 + if (pt_pax_flags != xattr_pax_flags)
53987 + return -EINVAL;
53988 + if (pt_pax_flags != ~0UL)
53989 + pax_flags = pt_pax_flags;
53990 +
53991 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_PAX_SEGMEXEC)
53992 + if ((pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) == (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
53993 + if ((__supported_pte_mask & _PAGE_NX))
53994 + pax_flags &= ~MF_PAX_SEGMEXEC;
53995 + else
53996 + pax_flags &= ~MF_PAX_PAGEEXEC;
53997 + }
53998 +#endif
53999 +
54000 + if (0 > pax_check_flags(&pax_flags))
54001 + return -EINVAL;
54002 +
54003 + current->mm->pax_flags = pax_flags;
54004 + return 0;
54005 +}
54006 +#endif
54007 +
54008 /*
54009 * These are the functions used to load ELF style executables and shared
54010 * libraries. There is no binary dependent code anywhere else.
54011 @@ -554,6 +901,11 @@ static unsigned long randomize_stack_top(unsigned long stack_top)
54012 {
54013 unsigned int random_variable = 0;
54014
54015 +#ifdef CONFIG_PAX_RANDUSTACK
54016 + if (current->mm->pax_flags & MF_PAX_RANDMMAP)
54017 + return stack_top - current->mm->delta_stack;
54018 +#endif
54019 +
54020 if ((current->flags & PF_RANDOMIZE) &&
54021 !(current->personality & ADDR_NO_RANDOMIZE)) {
54022 random_variable = get_random_int() & STACK_RND_MASK;
54023 @@ -572,7 +924,7 @@ static int load_elf_binary(struct linux_binprm *bprm)
54024 unsigned long load_addr = 0, load_bias = 0;
54025 int load_addr_set = 0;
54026 char * elf_interpreter = NULL;
54027 - unsigned long error;
54028 + unsigned long error = 0;
54029 struct elf_phdr *elf_ppnt, *elf_phdata;
54030 unsigned long elf_bss, elf_brk;
54031 int retval, i;
54032 @@ -582,12 +934,12 @@ static int load_elf_binary(struct linux_binprm *bprm)
54033 unsigned long start_code, end_code, start_data, end_data;
54034 unsigned long reloc_func_desc __maybe_unused = 0;
54035 int executable_stack = EXSTACK_DEFAULT;
54036 - unsigned long def_flags = 0;
54037 struct pt_regs *regs = current_pt_regs();
54038 struct {
54039 struct elfhdr elf_ex;
54040 struct elfhdr interp_elf_ex;
54041 } *loc;
54042 + unsigned long pax_task_size;
54043
54044 loc = kmalloc(sizeof(*loc), GFP_KERNEL);
54045 if (!loc) {
54046 @@ -723,11 +1075,82 @@ static int load_elf_binary(struct linux_binprm *bprm)
54047 goto out_free_dentry;
54048
54049 /* OK, This is the point of no return */
54050 - current->mm->def_flags = def_flags;
54051 + current->mm->def_flags = 0;
54052
54053 /* Do this immediately, since STACK_TOP as used in setup_arg_pages
54054 may depend on the personality. */
54055 SET_PERSONALITY(loc->elf_ex);
54056 +
54057 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54058 + current->mm->pax_flags = 0UL;
54059 +#endif
54060 +
54061 +#ifdef CONFIG_PAX_DLRESOLVE
54062 + current->mm->call_dl_resolve = 0UL;
54063 +#endif
54064 +
54065 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
54066 + current->mm->call_syscall = 0UL;
54067 +#endif
54068 +
54069 +#ifdef CONFIG_PAX_ASLR
54070 + current->mm->delta_mmap = 0UL;
54071 + current->mm->delta_stack = 0UL;
54072 +#endif
54073 +
54074 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
54075 + if (0 > pax_parse_pax_flags(&loc->elf_ex, elf_phdata, bprm->file)) {
54076 + send_sig(SIGKILL, current, 0);
54077 + goto out_free_dentry;
54078 + }
54079 +#endif
54080 +
54081 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
54082 + pax_set_initial_flags(bprm);
54083 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
54084 + if (pax_set_initial_flags_func)
54085 + (pax_set_initial_flags_func)(bprm);
54086 +#endif
54087 +
54088 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
54089 + if ((current->mm->pax_flags & MF_PAX_PAGEEXEC) && !(__supported_pte_mask & _PAGE_NX)) {
54090 + current->mm->context.user_cs_limit = PAGE_SIZE;
54091 + current->mm->def_flags |= VM_PAGEEXEC | VM_NOHUGEPAGE;
54092 + }
54093 +#endif
54094 +
54095 +#ifdef CONFIG_PAX_SEGMEXEC
54096 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
54097 + current->mm->context.user_cs_base = SEGMEXEC_TASK_SIZE;
54098 + current->mm->context.user_cs_limit = TASK_SIZE-SEGMEXEC_TASK_SIZE;
54099 + pax_task_size = SEGMEXEC_TASK_SIZE;
54100 + current->mm->def_flags |= VM_NOHUGEPAGE;
54101 + } else
54102 +#endif
54103 +
54104 + pax_task_size = TASK_SIZE;
54105 +
54106 +#if defined(CONFIG_ARCH_TRACK_EXEC_LIMIT) || defined(CONFIG_PAX_SEGMEXEC)
54107 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54108 + set_user_cs(current->mm->context.user_cs_base, current->mm->context.user_cs_limit, get_cpu());
54109 + put_cpu();
54110 + }
54111 +#endif
54112 +
54113 +#ifdef CONFIG_PAX_ASLR
54114 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54115 + current->mm->delta_mmap = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN)-1)) << PAGE_SHIFT;
54116 + current->mm->delta_stack = (pax_get_random_long() & ((1UL << PAX_DELTA_STACK_LEN)-1)) << PAGE_SHIFT;
54117 + }
54118 +#endif
54119 +
54120 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
54121 + if (current->mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
54122 + executable_stack = EXSTACK_DISABLE_X;
54123 + current->personality &= ~READ_IMPLIES_EXEC;
54124 + } else
54125 +#endif
54126 +
54127 if (elf_read_implies_exec(loc->elf_ex, executable_stack))
54128 current->personality |= READ_IMPLIES_EXEC;
54129
54130 @@ -817,6 +1240,20 @@ static int load_elf_binary(struct linux_binprm *bprm)
54131 #else
54132 load_bias = ELF_PAGESTART(ELF_ET_DYN_BASE - vaddr);
54133 #endif
54134 +
54135 +#ifdef CONFIG_PAX_RANDMMAP
54136 + /* PaX: randomize base address at the default exe base if requested */
54137 + if ((current->mm->pax_flags & MF_PAX_RANDMMAP) && elf_interpreter) {
54138 +#ifdef CONFIG_SPARC64
54139 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << (PAGE_SHIFT+1);
54140 +#else
54141 + load_bias = (pax_get_random_long() & ((1UL << PAX_DELTA_MMAP_LEN) - 1)) << PAGE_SHIFT;
54142 +#endif
54143 + load_bias = ELF_PAGESTART(PAX_ELF_ET_DYN_BASE - vaddr + load_bias);
54144 + elf_flags |= MAP_FIXED;
54145 + }
54146 +#endif
54147 +
54148 }
54149
54150 error = elf_map(bprm->file, load_bias + vaddr, elf_ppnt,
54151 @@ -849,9 +1286,9 @@ static int load_elf_binary(struct linux_binprm *bprm)
54152 * allowed task size. Note that p_filesz must always be
54153 * <= p_memsz so it is only necessary to check p_memsz.
54154 */
54155 - if (BAD_ADDR(k) || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
54156 - elf_ppnt->p_memsz > TASK_SIZE ||
54157 - TASK_SIZE - elf_ppnt->p_memsz < k) {
54158 + if (k >= pax_task_size || elf_ppnt->p_filesz > elf_ppnt->p_memsz ||
54159 + elf_ppnt->p_memsz > pax_task_size ||
54160 + pax_task_size - elf_ppnt->p_memsz < k) {
54161 /* set_brk can never work. Avoid overflows. */
54162 send_sig(SIGKILL, current, 0);
54163 retval = -EINVAL;
54164 @@ -890,17 +1327,45 @@ static int load_elf_binary(struct linux_binprm *bprm)
54165 goto out_free_dentry;
54166 }
54167 if (likely(elf_bss != elf_brk) && unlikely(padzero(elf_bss))) {
54168 - send_sig(SIGSEGV, current, 0);
54169 - retval = -EFAULT; /* Nobody gets to see this, but.. */
54170 - goto out_free_dentry;
54171 + /*
54172 + * This bss-zeroing can fail if the ELF
54173 + * file specifies odd protections. So
54174 + * we don't check the return value
54175 + */
54176 }
54177
54178 +#ifdef CONFIG_PAX_RANDMMAP
54179 + if (current->mm->pax_flags & MF_PAX_RANDMMAP) {
54180 + unsigned long start, size, flags;
54181 + vm_flags_t vm_flags;
54182 +
54183 + start = ELF_PAGEALIGN(elf_brk);
54184 + size = PAGE_SIZE + ((pax_get_random_long() & ((1UL << 22) - 1UL)) << 4);
54185 + flags = MAP_FIXED | MAP_PRIVATE;
54186 + vm_flags = VM_DONTEXPAND | VM_DONTDUMP;
54187 +
54188 + down_write(&current->mm->mmap_sem);
54189 + start = get_unmapped_area(NULL, start, PAGE_ALIGN(size), 0, flags);
54190 + retval = -ENOMEM;
54191 + if (!IS_ERR_VALUE(start) && !find_vma_intersection(current->mm, start, start + size + PAGE_SIZE)) {
54192 +// if (current->personality & ADDR_NO_RANDOMIZE)
54193 +// vm_flags |= VM_READ | VM_MAYREAD;
54194 + start = mmap_region(NULL, start, PAGE_ALIGN(size), vm_flags, 0);
54195 + retval = IS_ERR_VALUE(start) ? start : 0;
54196 + }
54197 + up_write(&current->mm->mmap_sem);
54198 + if (retval == 0)
54199 + retval = set_brk(start + size, start + size + PAGE_SIZE);
54200 + if (retval < 0) {
54201 + send_sig(SIGKILL, current, 0);
54202 + goto out_free_dentry;
54203 + }
54204 + }
54205 +#endif
54206 +
54207 if (elf_interpreter) {
54208 - unsigned long interp_map_addr = 0;
54209 -
54210 elf_entry = load_elf_interp(&loc->interp_elf_ex,
54211 interpreter,
54212 - &interp_map_addr,
54213 load_bias);
54214 if (!IS_ERR((void *)elf_entry)) {
54215 /*
54216 @@ -1122,7 +1587,7 @@ static bool always_dump_vma(struct vm_area_struct *vma)
54217 * Decide what to dump of a segment, part, all or none.
54218 */
54219 static unsigned long vma_dump_size(struct vm_area_struct *vma,
54220 - unsigned long mm_flags)
54221 + unsigned long mm_flags, long signr)
54222 {
54223 #define FILTER(type) (mm_flags & (1UL << MMF_DUMP_##type))
54224
54225 @@ -1160,7 +1625,7 @@ static unsigned long vma_dump_size(struct vm_area_struct *vma,
54226 if (vma->vm_file == NULL)
54227 return 0;
54228
54229 - if (FILTER(MAPPED_PRIVATE))
54230 + if (signr == SIGKILL || FILTER(MAPPED_PRIVATE))
54231 goto whole;
54232
54233 /*
54234 @@ -1385,9 +1850,9 @@ static void fill_auxv_note(struct memelfnote *note, struct mm_struct *mm)
54235 {
54236 elf_addr_t *auxv = (elf_addr_t *) mm->saved_auxv;
54237 int i = 0;
54238 - do
54239 + do {
54240 i += 2;
54241 - while (auxv[i - 2] != AT_NULL);
54242 + } while (auxv[i - 2] != AT_NULL);
54243 fill_note(note, "CORE", NT_AUXV, i * sizeof(elf_addr_t), auxv);
54244 }
54245
54246 @@ -1396,7 +1861,7 @@ static void fill_siginfo_note(struct memelfnote *note, user_siginfo_t *csigdata,
54247 {
54248 mm_segment_t old_fs = get_fs();
54249 set_fs(KERNEL_DS);
54250 - copy_siginfo_to_user((user_siginfo_t __user *) csigdata, siginfo);
54251 + copy_siginfo_to_user((user_siginfo_t __force_user *) csigdata, siginfo);
54252 set_fs(old_fs);
54253 fill_note(note, "CORE", NT_SIGINFO, sizeof(*csigdata), csigdata);
54254 }
54255 @@ -2023,14 +2488,14 @@ static void fill_extnum_info(struct elfhdr *elf, struct elf_shdr *shdr4extnum,
54256 }
54257
54258 static size_t elf_core_vma_data_size(struct vm_area_struct *gate_vma,
54259 - unsigned long mm_flags)
54260 + struct coredump_params *cprm)
54261 {
54262 struct vm_area_struct *vma;
54263 size_t size = 0;
54264
54265 for (vma = first_vma(current, gate_vma); vma != NULL;
54266 vma = next_vma(vma, gate_vma))
54267 - size += vma_dump_size(vma, mm_flags);
54268 + size += vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54269 return size;
54270 }
54271
54272 @@ -2123,7 +2588,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54273
54274 dataoff = offset = roundup(offset, ELF_EXEC_PAGESIZE);
54275
54276 - offset += elf_core_vma_data_size(gate_vma, cprm->mm_flags);
54277 + offset += elf_core_vma_data_size(gate_vma, cprm);
54278 offset += elf_core_extra_data_size();
54279 e_shoff = offset;
54280
54281 @@ -2137,10 +2602,12 @@ static int elf_core_dump(struct coredump_params *cprm)
54282 offset = dataoff;
54283
54284 size += sizeof(*elf);
54285 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54286 if (size > cprm->limit || !dump_write(cprm->file, elf, sizeof(*elf)))
54287 goto end_coredump;
54288
54289 size += sizeof(*phdr4note);
54290 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54291 if (size > cprm->limit
54292 || !dump_write(cprm->file, phdr4note, sizeof(*phdr4note)))
54293 goto end_coredump;
54294 @@ -2154,7 +2621,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54295 phdr.p_offset = offset;
54296 phdr.p_vaddr = vma->vm_start;
54297 phdr.p_paddr = 0;
54298 - phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags);
54299 + phdr.p_filesz = vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54300 phdr.p_memsz = vma->vm_end - vma->vm_start;
54301 offset += phdr.p_filesz;
54302 phdr.p_flags = vma->vm_flags & VM_READ ? PF_R : 0;
54303 @@ -2165,6 +2632,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54304 phdr.p_align = ELF_EXEC_PAGESIZE;
54305
54306 size += sizeof(phdr);
54307 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54308 if (size > cprm->limit
54309 || !dump_write(cprm->file, &phdr, sizeof(phdr)))
54310 goto end_coredump;
54311 @@ -2189,7 +2657,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54312 unsigned long addr;
54313 unsigned long end;
54314
54315 - end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags);
54316 + end = vma->vm_start + vma_dump_size(vma, cprm->mm_flags, cprm->siginfo->si_signo);
54317
54318 for (addr = vma->vm_start; addr < end; addr += PAGE_SIZE) {
54319 struct page *page;
54320 @@ -2198,6 +2666,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54321 page = get_dump_page(addr);
54322 if (page) {
54323 void *kaddr = kmap(page);
54324 + gr_learn_resource(current, RLIMIT_CORE, size + PAGE_SIZE, 1);
54325 stop = ((size += PAGE_SIZE) > cprm->limit) ||
54326 !dump_write(cprm->file, kaddr,
54327 PAGE_SIZE);
54328 @@ -2215,6 +2684,7 @@ static int elf_core_dump(struct coredump_params *cprm)
54329
54330 if (e_phnum == PN_XNUM) {
54331 size += sizeof(*shdr4extnum);
54332 + gr_learn_resource(current, RLIMIT_CORE, size, 1);
54333 if (size > cprm->limit
54334 || !dump_write(cprm->file, shdr4extnum,
54335 sizeof(*shdr4extnum)))
54336 @@ -2235,6 +2705,167 @@ out:
54337
54338 #endif /* CONFIG_ELF_CORE */
54339
54340 +#ifdef CONFIG_PAX_MPROTECT
54341 +/* PaX: non-PIC ELF libraries need relocations on their executable segments
54342 + * therefore we'll grant them VM_MAYWRITE once during their life. Similarly
54343 + * we'll remove VM_MAYWRITE for good on RELRO segments.
54344 + *
54345 + * The checks favour ld-linux.so behaviour which operates on a per ELF segment
54346 + * basis because we want to allow the common case and not the special ones.
54347 + */
54348 +static void elf_handle_mprotect(struct vm_area_struct *vma, unsigned long newflags)
54349 +{
54350 + struct elfhdr elf_h;
54351 + struct elf_phdr elf_p;
54352 + unsigned long i;
54353 + unsigned long oldflags;
54354 + bool is_textrel_rw, is_textrel_rx, is_relro;
54355 +
54356 + if (!(vma->vm_mm->pax_flags & MF_PAX_MPROTECT) || !vma->vm_file)
54357 + return;
54358 +
54359 + oldflags = vma->vm_flags & (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ);
54360 + newflags &= VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_EXEC | VM_WRITE | VM_READ;
54361 +
54362 +#ifdef CONFIG_PAX_ELFRELOCS
54363 + /* possible TEXTREL */
54364 + is_textrel_rw = !vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYREAD | VM_EXEC | VM_READ) && newflags == (VM_WRITE | VM_READ);
54365 + is_textrel_rx = vma->anon_vma && oldflags == (VM_MAYEXEC | VM_MAYWRITE | VM_MAYREAD | VM_WRITE | VM_READ) && newflags == (VM_EXEC | VM_READ);
54366 +#else
54367 + is_textrel_rw = false;
54368 + is_textrel_rx = false;
54369 +#endif
54370 +
54371 + /* possible RELRO */
54372 + is_relro = vma->anon_vma && oldflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ) && newflags == (VM_MAYWRITE | VM_MAYREAD | VM_READ);
54373 +
54374 + if (!is_textrel_rw && !is_textrel_rx && !is_relro)
54375 + return;
54376 +
54377 + if (sizeof(elf_h) != kernel_read(vma->vm_file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54378 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54379 +
54380 +#ifdef CONFIG_PAX_ETEXECRELOCS
54381 + ((is_textrel_rw || is_textrel_rx) && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54382 +#else
54383 + ((is_textrel_rw || is_textrel_rx) && elf_h.e_type != ET_DYN) ||
54384 +#endif
54385 +
54386 + (is_relro && (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC)) ||
54387 + !elf_check_arch(&elf_h) ||
54388 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54389 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54390 + return;
54391 +
54392 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54393 + if (sizeof(elf_p) != kernel_read(vma->vm_file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54394 + return;
54395 + switch (elf_p.p_type) {
54396 + case PT_DYNAMIC:
54397 + if (!is_textrel_rw && !is_textrel_rx)
54398 + continue;
54399 + i = 0UL;
54400 + while ((i+1) * sizeof(elf_dyn) <= elf_p.p_filesz) {
54401 + elf_dyn dyn;
54402 +
54403 + if (sizeof(dyn) != kernel_read(vma->vm_file, elf_p.p_offset + i*sizeof(dyn), (char *)&dyn, sizeof(dyn)))
54404 + break;
54405 + if (dyn.d_tag == DT_NULL)
54406 + break;
54407 + if (dyn.d_tag == DT_TEXTREL || (dyn.d_tag == DT_FLAGS && (dyn.d_un.d_val & DF_TEXTREL))) {
54408 + gr_log_textrel(vma);
54409 + if (is_textrel_rw)
54410 + vma->vm_flags |= VM_MAYWRITE;
54411 + else
54412 + /* PaX: disallow write access after relocs are done, hopefully noone else needs it... */
54413 + vma->vm_flags &= ~VM_MAYWRITE;
54414 + break;
54415 + }
54416 + i++;
54417 + }
54418 + is_textrel_rw = false;
54419 + is_textrel_rx = false;
54420 + continue;
54421 +
54422 + case PT_GNU_RELRO:
54423 + if (!is_relro)
54424 + continue;
54425 + if ((elf_p.p_offset >> PAGE_SHIFT) == vma->vm_pgoff && ELF_PAGEALIGN(elf_p.p_memsz) == vma->vm_end - vma->vm_start)
54426 + vma->vm_flags &= ~VM_MAYWRITE;
54427 + is_relro = false;
54428 + continue;
54429 +
54430 +#ifdef CONFIG_PAX_PT_PAX_FLAGS
54431 + case PT_PAX_FLAGS: {
54432 + const char *msg_mprotect = "", *msg_emutramp = "";
54433 + char *buffer_lib, *buffer_exe;
54434 +
54435 + if (elf_p.p_flags & PF_NOMPROTECT)
54436 + msg_mprotect = "MPROTECT disabled";
54437 +
54438 +#ifdef CONFIG_PAX_EMUTRAMP
54439 + if (!(vma->vm_mm->pax_flags & MF_PAX_EMUTRAMP) && !(elf_p.p_flags & PF_NOEMUTRAMP))
54440 + msg_emutramp = "EMUTRAMP enabled";
54441 +#endif
54442 +
54443 + if (!msg_mprotect[0] && !msg_emutramp[0])
54444 + continue;
54445 +
54446 + if (!printk_ratelimit())
54447 + continue;
54448 +
54449 + buffer_lib = (char *)__get_free_page(GFP_KERNEL);
54450 + buffer_exe = (char *)__get_free_page(GFP_KERNEL);
54451 + if (buffer_lib && buffer_exe) {
54452 + char *path_lib, *path_exe;
54453 +
54454 + path_lib = pax_get_path(&vma->vm_file->f_path, buffer_lib, PAGE_SIZE);
54455 + path_exe = pax_get_path(&vma->vm_mm->exe_file->f_path, buffer_exe, PAGE_SIZE);
54456 +
54457 + pr_info("PAX: %s wants %s%s%s on %s\n", path_lib, msg_mprotect,
54458 + (msg_mprotect[0] && msg_emutramp[0] ? " and " : ""), msg_emutramp, path_exe);
54459 +
54460 + }
54461 + free_page((unsigned long)buffer_exe);
54462 + free_page((unsigned long)buffer_lib);
54463 + continue;
54464 + }
54465 +#endif
54466 +
54467 + }
54468 + }
54469 +}
54470 +#endif
54471 +
54472 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
54473 +
54474 +extern int grsec_enable_log_rwxmaps;
54475 +
54476 +static void elf_handle_mmap(struct file *file)
54477 +{
54478 + struct elfhdr elf_h;
54479 + struct elf_phdr elf_p;
54480 + unsigned long i;
54481 +
54482 + if (!grsec_enable_log_rwxmaps)
54483 + return;
54484 +
54485 + if (sizeof(elf_h) != kernel_read(file, 0UL, (char *)&elf_h, sizeof(elf_h)) ||
54486 + memcmp(elf_h.e_ident, ELFMAG, SELFMAG) ||
54487 + (elf_h.e_type != ET_DYN && elf_h.e_type != ET_EXEC) || !elf_check_arch(&elf_h) ||
54488 + elf_h.e_phentsize != sizeof(struct elf_phdr) ||
54489 + elf_h.e_phnum > 65536UL / sizeof(struct elf_phdr))
54490 + return;
54491 +
54492 + for (i = 0UL; i < elf_h.e_phnum; i++) {
54493 + if (sizeof(elf_p) != kernel_read(file, elf_h.e_phoff + i*sizeof(elf_p), (char *)&elf_p, sizeof(elf_p)))
54494 + return;
54495 + if (elf_p.p_type == PT_GNU_STACK && (elf_p.p_flags & PF_X))
54496 + gr_log_ptgnustack(file);
54497 + }
54498 +}
54499 +#endif
54500 +
54501 static int __init init_elf_binfmt(void)
54502 {
54503 register_binfmt(&elf_format);
54504 diff --git a/fs/binfmt_flat.c b/fs/binfmt_flat.c
54505 index d50bbe5..af3b649 100644
54506 --- a/fs/binfmt_flat.c
54507 +++ b/fs/binfmt_flat.c
54508 @@ -566,7 +566,9 @@ static int load_flat_file(struct linux_binprm * bprm,
54509 realdatastart = (unsigned long) -ENOMEM;
54510 printk("Unable to allocate RAM for process data, errno %d\n",
54511 (int)-realdatastart);
54512 + down_write(&current->mm->mmap_sem);
54513 vm_munmap(textpos, text_len);
54514 + up_write(&current->mm->mmap_sem);
54515 ret = realdatastart;
54516 goto err;
54517 }
54518 @@ -590,8 +592,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54519 }
54520 if (IS_ERR_VALUE(result)) {
54521 printk("Unable to read data+bss, errno %d\n", (int)-result);
54522 + down_write(&current->mm->mmap_sem);
54523 vm_munmap(textpos, text_len);
54524 vm_munmap(realdatastart, len);
54525 + up_write(&current->mm->mmap_sem);
54526 ret = result;
54527 goto err;
54528 }
54529 @@ -653,8 +657,10 @@ static int load_flat_file(struct linux_binprm * bprm,
54530 }
54531 if (IS_ERR_VALUE(result)) {
54532 printk("Unable to read code+data+bss, errno %d\n",(int)-result);
54533 + down_write(&current->mm->mmap_sem);
54534 vm_munmap(textpos, text_len + data_len + extra +
54535 MAX_SHARED_LIBS * sizeof(unsigned long));
54536 + up_write(&current->mm->mmap_sem);
54537 ret = result;
54538 goto err;
54539 }
54540 diff --git a/fs/bio.c b/fs/bio.c
54541 index ea5035d..a2932eb 100644
54542 --- a/fs/bio.c
54543 +++ b/fs/bio.c
54544 @@ -1106,7 +1106,7 @@ struct bio *bio_copy_user_iov(struct request_queue *q,
54545 /*
54546 * Overflow, abort
54547 */
54548 - if (end < start)
54549 + if (end < start || end - start > INT_MAX - nr_pages)
54550 return ERR_PTR(-EINVAL);
54551
54552 nr_pages += end - start;
54553 @@ -1240,7 +1240,7 @@ static struct bio *__bio_map_user_iov(struct request_queue *q,
54554 /*
54555 * Overflow, abort
54556 */
54557 - if (end < start)
54558 + if (end < start || end - start > INT_MAX - nr_pages)
54559 return ERR_PTR(-EINVAL);
54560
54561 nr_pages += end - start;
54562 @@ -1502,7 +1502,7 @@ static void bio_copy_kern_endio(struct bio *bio, int err)
54563 const int read = bio_data_dir(bio) == READ;
54564 struct bio_map_data *bmd = bio->bi_private;
54565 int i;
54566 - char *p = bmd->sgvecs[0].iov_base;
54567 + char *p = (char __force_kernel *)bmd->sgvecs[0].iov_base;
54568
54569 bio_for_each_segment_all(bvec, bio, i) {
54570 char *addr = page_address(bvec->bv_page);
54571 diff --git a/fs/block_dev.c b/fs/block_dev.c
54572 index 1e86823..8e34695 100644
54573 --- a/fs/block_dev.c
54574 +++ b/fs/block_dev.c
54575 @@ -637,7 +637,7 @@ static bool bd_may_claim(struct block_device *bdev, struct block_device *whole,
54576 else if (bdev->bd_contains == bdev)
54577 return true; /* is a whole device which isn't held */
54578
54579 - else if (whole->bd_holder == bd_may_claim)
54580 + else if (whole->bd_holder == (void *)bd_may_claim)
54581 return true; /* is a partition of a device that is being partitioned */
54582 else if (whole->bd_holder != NULL)
54583 return false; /* is a partition of a held device */
54584 diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
54585 index b544a44..f3fb987 100644
54586 --- a/fs/btrfs/ctree.c
54587 +++ b/fs/btrfs/ctree.c
54588 @@ -1028,9 +1028,12 @@ static noinline int __btrfs_cow_block(struct btrfs_trans_handle *trans,
54589 free_extent_buffer(buf);
54590 add_root_to_dirty_list(root);
54591 } else {
54592 - if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID)
54593 - parent_start = parent->start;
54594 - else
54595 + if (root->root_key.objectid == BTRFS_TREE_RELOC_OBJECTID) {
54596 + if (parent)
54597 + parent_start = parent->start;
54598 + else
54599 + parent_start = 0;
54600 + } else
54601 parent_start = 0;
54602
54603 WARN_ON(trans->transid != btrfs_header_generation(parent));
54604 diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
54605 index cbd9523..5cca781 100644
54606 --- a/fs/btrfs/delayed-inode.c
54607 +++ b/fs/btrfs/delayed-inode.c
54608 @@ -459,7 +459,7 @@ static int __btrfs_add_delayed_deletion_item(struct btrfs_delayed_node *node,
54609
54610 static void finish_one_item(struct btrfs_delayed_root *delayed_root)
54611 {
54612 - int seq = atomic_inc_return(&delayed_root->items_seq);
54613 + int seq = atomic_inc_return_unchecked(&delayed_root->items_seq);
54614 if ((atomic_dec_return(&delayed_root->items) <
54615 BTRFS_DELAYED_BACKGROUND || seq % BTRFS_DELAYED_BATCH == 0) &&
54616 waitqueue_active(&delayed_root->wait))
54617 @@ -1378,7 +1378,7 @@ void btrfs_assert_delayed_root_empty(struct btrfs_root *root)
54618 static int refs_newer(struct btrfs_delayed_root *delayed_root,
54619 int seq, int count)
54620 {
54621 - int val = atomic_read(&delayed_root->items_seq);
54622 + int val = atomic_read_unchecked(&delayed_root->items_seq);
54623
54624 if (val < seq || val >= seq + count)
54625 return 1;
54626 @@ -1395,7 +1395,7 @@ void btrfs_balance_delayed_items(struct btrfs_root *root)
54627 if (atomic_read(&delayed_root->items) < BTRFS_DELAYED_BACKGROUND)
54628 return;
54629
54630 - seq = atomic_read(&delayed_root->items_seq);
54631 + seq = atomic_read_unchecked(&delayed_root->items_seq);
54632
54633 if (atomic_read(&delayed_root->items) >= BTRFS_DELAYED_WRITEBACK) {
54634 int ret;
54635 diff --git a/fs/btrfs/delayed-inode.h b/fs/btrfs/delayed-inode.h
54636 index a4b38f9..f86a509 100644
54637 --- a/fs/btrfs/delayed-inode.h
54638 +++ b/fs/btrfs/delayed-inode.h
54639 @@ -43,7 +43,7 @@ struct btrfs_delayed_root {
54640 */
54641 struct list_head prepare_list;
54642 atomic_t items; /* for delayed items */
54643 - atomic_t items_seq; /* for delayed items */
54644 + atomic_unchecked_t items_seq; /* for delayed items */
54645 int nodes; /* for delayed nodes */
54646 wait_queue_head_t wait;
54647 };
54648 @@ -87,7 +87,7 @@ static inline void btrfs_init_delayed_root(
54649 struct btrfs_delayed_root *delayed_root)
54650 {
54651 atomic_set(&delayed_root->items, 0);
54652 - atomic_set(&delayed_root->items_seq, 0);
54653 + atomic_set_unchecked(&delayed_root->items_seq, 0);
54654 delayed_root->nodes = 0;
54655 spin_lock_init(&delayed_root->lock);
54656 init_waitqueue_head(&delayed_root->wait);
54657 diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
54658 index 8747feb..ad1655c 100644
54659 --- a/fs/btrfs/ioctl.c
54660 +++ b/fs/btrfs/ioctl.c
54661 @@ -3465,9 +3465,12 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54662 for (i = 0; i < num_types; i++) {
54663 struct btrfs_space_info *tmp;
54664
54665 + /* Don't copy in more than we allocated */
54666 if (!slot_count)
54667 break;
54668
54669 + slot_count--;
54670 +
54671 info = NULL;
54672 rcu_read_lock();
54673 list_for_each_entry_rcu(tmp, &root->fs_info->space_info,
54674 @@ -3489,10 +3492,7 @@ static long btrfs_ioctl_space_info(struct btrfs_root *root, void __user *arg)
54675 memcpy(dest, &space, sizeof(space));
54676 dest++;
54677 space_args.total_spaces++;
54678 - slot_count--;
54679 }
54680 - if (!slot_count)
54681 - break;
54682 }
54683 up_read(&info->groups_sem);
54684 }
54685 diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
54686 index e913328..a34fb36 100644
54687 --- a/fs/btrfs/super.c
54688 +++ b/fs/btrfs/super.c
54689 @@ -266,7 +266,7 @@ void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
54690 function, line, errstr);
54691 return;
54692 }
54693 - ACCESS_ONCE(trans->transaction->aborted) = errno;
54694 + ACCESS_ONCE_RW(trans->transaction->aborted) = errno;
54695 /* Wake up anybody who may be waiting on this transaction */
54696 wake_up(&root->fs_info->transaction_wait);
54697 wake_up(&root->fs_info->transaction_blocked_wait);
54698 diff --git a/fs/buffer.c b/fs/buffer.c
54699 index 6024877..7bd000a 100644
54700 --- a/fs/buffer.c
54701 +++ b/fs/buffer.c
54702 @@ -3426,7 +3426,7 @@ void __init buffer_init(void)
54703 bh_cachep = kmem_cache_create("buffer_head",
54704 sizeof(struct buffer_head), 0,
54705 (SLAB_RECLAIM_ACCOUNT|SLAB_PANIC|
54706 - SLAB_MEM_SPREAD),
54707 + SLAB_MEM_SPREAD|SLAB_NO_SANITIZE),
54708 NULL);
54709
54710 /*
54711 diff --git a/fs/cachefiles/bind.c b/fs/cachefiles/bind.c
54712 index 622f469..e8d2d55 100644
54713 --- a/fs/cachefiles/bind.c
54714 +++ b/fs/cachefiles/bind.c
54715 @@ -39,13 +39,11 @@ int cachefiles_daemon_bind(struct cachefiles_cache *cache, char *args)
54716 args);
54717
54718 /* start by checking things over */
54719 - ASSERT(cache->fstop_percent >= 0 &&
54720 - cache->fstop_percent < cache->fcull_percent &&
54721 + ASSERT(cache->fstop_percent < cache->fcull_percent &&
54722 cache->fcull_percent < cache->frun_percent &&
54723 cache->frun_percent < 100);
54724
54725 - ASSERT(cache->bstop_percent >= 0 &&
54726 - cache->bstop_percent < cache->bcull_percent &&
54727 + ASSERT(cache->bstop_percent < cache->bcull_percent &&
54728 cache->bcull_percent < cache->brun_percent &&
54729 cache->brun_percent < 100);
54730
54731 diff --git a/fs/cachefiles/daemon.c b/fs/cachefiles/daemon.c
54732 index 0a1467b..6a53245 100644
54733 --- a/fs/cachefiles/daemon.c
54734 +++ b/fs/cachefiles/daemon.c
54735 @@ -196,7 +196,7 @@ static ssize_t cachefiles_daemon_read(struct file *file, char __user *_buffer,
54736 if (n > buflen)
54737 return -EMSGSIZE;
54738
54739 - if (copy_to_user(_buffer, buffer, n) != 0)
54740 + if (n > sizeof(buffer) || copy_to_user(_buffer, buffer, n) != 0)
54741 return -EFAULT;
54742
54743 return n;
54744 @@ -222,7 +222,7 @@ static ssize_t cachefiles_daemon_write(struct file *file,
54745 if (test_bit(CACHEFILES_DEAD, &cache->flags))
54746 return -EIO;
54747
54748 - if (datalen < 0 || datalen > PAGE_SIZE - 1)
54749 + if (datalen > PAGE_SIZE - 1)
54750 return -EOPNOTSUPP;
54751
54752 /* drag the command string into the kernel so we can parse it */
54753 @@ -386,7 +386,7 @@ static int cachefiles_daemon_fstop(struct cachefiles_cache *cache, char *args)
54754 if (args[0] != '%' || args[1] != '\0')
54755 return -EINVAL;
54756
54757 - if (fstop < 0 || fstop >= cache->fcull_percent)
54758 + if (fstop >= cache->fcull_percent)
54759 return cachefiles_daemon_range_error(cache, args);
54760
54761 cache->fstop_percent = fstop;
54762 @@ -458,7 +458,7 @@ static int cachefiles_daemon_bstop(struct cachefiles_cache *cache, char *args)
54763 if (args[0] != '%' || args[1] != '\0')
54764 return -EINVAL;
54765
54766 - if (bstop < 0 || bstop >= cache->bcull_percent)
54767 + if (bstop >= cache->bcull_percent)
54768 return cachefiles_daemon_range_error(cache, args);
54769
54770 cache->bstop_percent = bstop;
54771 diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h
54772 index 5349473..d6c0b93 100644
54773 --- a/fs/cachefiles/internal.h
54774 +++ b/fs/cachefiles/internal.h
54775 @@ -59,7 +59,7 @@ struct cachefiles_cache {
54776 wait_queue_head_t daemon_pollwq; /* poll waitqueue for daemon */
54777 struct rb_root active_nodes; /* active nodes (can't be culled) */
54778 rwlock_t active_lock; /* lock for active_nodes */
54779 - atomic_t gravecounter; /* graveyard uniquifier */
54780 + atomic_unchecked_t gravecounter; /* graveyard uniquifier */
54781 unsigned frun_percent; /* when to stop culling (% files) */
54782 unsigned fcull_percent; /* when to start culling (% files) */
54783 unsigned fstop_percent; /* when to stop allocating (% files) */
54784 @@ -171,19 +171,19 @@ extern int cachefiles_check_in_use(struct cachefiles_cache *cache,
54785 * proc.c
54786 */
54787 #ifdef CONFIG_CACHEFILES_HISTOGRAM
54788 -extern atomic_t cachefiles_lookup_histogram[HZ];
54789 -extern atomic_t cachefiles_mkdir_histogram[HZ];
54790 -extern atomic_t cachefiles_create_histogram[HZ];
54791 +extern atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54792 +extern atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54793 +extern atomic_unchecked_t cachefiles_create_histogram[HZ];
54794
54795 extern int __init cachefiles_proc_init(void);
54796 extern void cachefiles_proc_cleanup(void);
54797 static inline
54798 -void cachefiles_hist(atomic_t histogram[], unsigned long start_jif)
54799 +void cachefiles_hist(atomic_unchecked_t histogram[], unsigned long start_jif)
54800 {
54801 unsigned long jif = jiffies - start_jif;
54802 if (jif >= HZ)
54803 jif = HZ - 1;
54804 - atomic_inc(&histogram[jif]);
54805 + atomic_inc_unchecked(&histogram[jif]);
54806 }
54807
54808 #else
54809 diff --git a/fs/cachefiles/namei.c b/fs/cachefiles/namei.c
54810 index f4a08d7..5aa4599 100644
54811 --- a/fs/cachefiles/namei.c
54812 +++ b/fs/cachefiles/namei.c
54813 @@ -317,7 +317,7 @@ try_again:
54814 /* first step is to make up a grave dentry in the graveyard */
54815 sprintf(nbuffer, "%08x%08x",
54816 (uint32_t) get_seconds(),
54817 - (uint32_t) atomic_inc_return(&cache->gravecounter));
54818 + (uint32_t) atomic_inc_return_unchecked(&cache->gravecounter));
54819
54820 /* do the multiway lock magic */
54821 trap = lock_rename(cache->graveyard, dir);
54822 diff --git a/fs/cachefiles/proc.c b/fs/cachefiles/proc.c
54823 index eccd339..4c1d995 100644
54824 --- a/fs/cachefiles/proc.c
54825 +++ b/fs/cachefiles/proc.c
54826 @@ -14,9 +14,9 @@
54827 #include <linux/seq_file.h>
54828 #include "internal.h"
54829
54830 -atomic_t cachefiles_lookup_histogram[HZ];
54831 -atomic_t cachefiles_mkdir_histogram[HZ];
54832 -atomic_t cachefiles_create_histogram[HZ];
54833 +atomic_unchecked_t cachefiles_lookup_histogram[HZ];
54834 +atomic_unchecked_t cachefiles_mkdir_histogram[HZ];
54835 +atomic_unchecked_t cachefiles_create_histogram[HZ];
54836
54837 /*
54838 * display the latency histogram
54839 @@ -35,9 +35,9 @@ static int cachefiles_histogram_show(struct seq_file *m, void *v)
54840 return 0;
54841 default:
54842 index = (unsigned long) v - 3;
54843 - x = atomic_read(&cachefiles_lookup_histogram[index]);
54844 - y = atomic_read(&cachefiles_mkdir_histogram[index]);
54845 - z = atomic_read(&cachefiles_create_histogram[index]);
54846 + x = atomic_read_unchecked(&cachefiles_lookup_histogram[index]);
54847 + y = atomic_read_unchecked(&cachefiles_mkdir_histogram[index]);
54848 + z = atomic_read_unchecked(&cachefiles_create_histogram[index]);
54849 if (x == 0 && y == 0 && z == 0)
54850 return 0;
54851
54852 diff --git a/fs/cachefiles/rdwr.c b/fs/cachefiles/rdwr.c
54853 index ebaff36..7e3ea26 100644
54854 --- a/fs/cachefiles/rdwr.c
54855 +++ b/fs/cachefiles/rdwr.c
54856 @@ -950,7 +950,7 @@ int cachefiles_write_page(struct fscache_storage *op, struct page *page)
54857 old_fs = get_fs();
54858 set_fs(KERNEL_DS);
54859 ret = file->f_op->write(
54860 - file, (const void __user *) data, len, &pos);
54861 + file, (const void __force_user *) data, len, &pos);
54862 set_fs(old_fs);
54863 kunmap(page);
54864 file_end_write(file);
54865 diff --git a/fs/ceph/dir.c b/fs/ceph/dir.c
54866 index 868b61d..58835a5 100644
54867 --- a/fs/ceph/dir.c
54868 +++ b/fs/ceph/dir.c
54869 @@ -240,7 +240,7 @@ static int ceph_readdir(struct file *file, struct dir_context *ctx)
54870 struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
54871 struct ceph_mds_client *mdsc = fsc->mdsc;
54872 unsigned frag = fpos_frag(ctx->pos);
54873 - int off = fpos_off(ctx->pos);
54874 + unsigned int off = fpos_off(ctx->pos);
54875 int err;
54876 u32 ftype;
54877 struct ceph_mds_reply_info_parsed *rinfo;
54878 diff --git a/fs/ceph/super.c b/fs/ceph/super.c
54879 index 6a0951e..03fac6d 100644
54880 --- a/fs/ceph/super.c
54881 +++ b/fs/ceph/super.c
54882 @@ -870,7 +870,7 @@ static int ceph_compare_super(struct super_block *sb, void *data)
54883 /*
54884 * construct our own bdi so we can control readahead, etc.
54885 */
54886 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
54887 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
54888
54889 static int ceph_register_bdi(struct super_block *sb,
54890 struct ceph_fs_client *fsc)
54891 @@ -887,7 +887,7 @@ static int ceph_register_bdi(struct super_block *sb,
54892 default_backing_dev_info.ra_pages;
54893
54894 err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
54895 - atomic_long_inc_return(&bdi_seq));
54896 + atomic_long_inc_return_unchecked(&bdi_seq));
54897 if (!err)
54898 sb->s_bdi = &fsc->backing_dev_info;
54899 return err;
54900 diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c
54901 index f3ac415..3d2420c 100644
54902 --- a/fs/cifs/cifs_debug.c
54903 +++ b/fs/cifs/cifs_debug.c
54904 @@ -286,8 +286,8 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54905
54906 if (c == '1' || c == 'y' || c == 'Y' || c == '0') {
54907 #ifdef CONFIG_CIFS_STATS2
54908 - atomic_set(&totBufAllocCount, 0);
54909 - atomic_set(&totSmBufAllocCount, 0);
54910 + atomic_set_unchecked(&totBufAllocCount, 0);
54911 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54912 #endif /* CONFIG_CIFS_STATS2 */
54913 spin_lock(&cifs_tcp_ses_lock);
54914 list_for_each(tmp1, &cifs_tcp_ses_list) {
54915 @@ -300,7 +300,7 @@ static ssize_t cifs_stats_proc_write(struct file *file,
54916 tcon = list_entry(tmp3,
54917 struct cifs_tcon,
54918 tcon_list);
54919 - atomic_set(&tcon->num_smbs_sent, 0);
54920 + atomic_set_unchecked(&tcon->num_smbs_sent, 0);
54921 if (server->ops->clear_stats)
54922 server->ops->clear_stats(tcon);
54923 }
54924 @@ -332,8 +332,8 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54925 smBufAllocCount.counter, cifs_min_small);
54926 #ifdef CONFIG_CIFS_STATS2
54927 seq_printf(m, "Total Large %d Small %d Allocations\n",
54928 - atomic_read(&totBufAllocCount),
54929 - atomic_read(&totSmBufAllocCount));
54930 + atomic_read_unchecked(&totBufAllocCount),
54931 + atomic_read_unchecked(&totSmBufAllocCount));
54932 #endif /* CONFIG_CIFS_STATS2 */
54933
54934 seq_printf(m, "Operations (MIDs): %d\n", atomic_read(&midCount));
54935 @@ -362,7 +362,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v)
54936 if (tcon->need_reconnect)
54937 seq_puts(m, "\tDISCONNECTED ");
54938 seq_printf(m, "\nSMBs: %d",
54939 - atomic_read(&tcon->num_smbs_sent));
54940 + atomic_read_unchecked(&tcon->num_smbs_sent));
54941 if (server->ops->print_stats)
54942 server->ops->print_stats(m, tcon);
54943 }
54944 diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
54945 index 77fc5e1..e3d13e6 100644
54946 --- a/fs/cifs/cifsfs.c
54947 +++ b/fs/cifs/cifsfs.c
54948 @@ -1056,7 +1056,7 @@ cifs_init_request_bufs(void)
54949 */
54950 cifs_req_cachep = kmem_cache_create("cifs_request",
54951 CIFSMaxBufSize + max_hdr_size, 0,
54952 - SLAB_HWCACHE_ALIGN, NULL);
54953 + SLAB_HWCACHE_ALIGN | SLAB_USERCOPY, NULL);
54954 if (cifs_req_cachep == NULL)
54955 return -ENOMEM;
54956
54957 @@ -1083,7 +1083,7 @@ cifs_init_request_bufs(void)
54958 efficient to alloc 1 per page off the slab compared to 17K (5page)
54959 alloc of large cifs buffers even when page debugging is on */
54960 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
54961 - MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
54962 + MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN | SLAB_USERCOPY,
54963 NULL);
54964 if (cifs_sm_req_cachep == NULL) {
54965 mempool_destroy(cifs_req_poolp);
54966 @@ -1168,8 +1168,8 @@ init_cifs(void)
54967 atomic_set(&bufAllocCount, 0);
54968 atomic_set(&smBufAllocCount, 0);
54969 #ifdef CONFIG_CIFS_STATS2
54970 - atomic_set(&totBufAllocCount, 0);
54971 - atomic_set(&totSmBufAllocCount, 0);
54972 + atomic_set_unchecked(&totBufAllocCount, 0);
54973 + atomic_set_unchecked(&totSmBufAllocCount, 0);
54974 #endif /* CONFIG_CIFS_STATS2 */
54975
54976 atomic_set(&midCount, 0);
54977 diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h
54978 index c8e03f8..75362f6 100644
54979 --- a/fs/cifs/cifsglob.h
54980 +++ b/fs/cifs/cifsglob.h
54981 @@ -758,35 +758,35 @@ struct cifs_tcon {
54982 __u16 Flags; /* optional support bits */
54983 enum statusEnum tidStatus;
54984 #ifdef CONFIG_CIFS_STATS
54985 - atomic_t num_smbs_sent;
54986 + atomic_unchecked_t num_smbs_sent;
54987 union {
54988 struct {
54989 - atomic_t num_writes;
54990 - atomic_t num_reads;
54991 - atomic_t num_flushes;
54992 - atomic_t num_oplock_brks;
54993 - atomic_t num_opens;
54994 - atomic_t num_closes;
54995 - atomic_t num_deletes;
54996 - atomic_t num_mkdirs;
54997 - atomic_t num_posixopens;
54998 - atomic_t num_posixmkdirs;
54999 - atomic_t num_rmdirs;
55000 - atomic_t num_renames;
55001 - atomic_t num_t2renames;
55002 - atomic_t num_ffirst;
55003 - atomic_t num_fnext;
55004 - atomic_t num_fclose;
55005 - atomic_t num_hardlinks;
55006 - atomic_t num_symlinks;
55007 - atomic_t num_locks;
55008 - atomic_t num_acl_get;
55009 - atomic_t num_acl_set;
55010 + atomic_unchecked_t num_writes;
55011 + atomic_unchecked_t num_reads;
55012 + atomic_unchecked_t num_flushes;
55013 + atomic_unchecked_t num_oplock_brks;
55014 + atomic_unchecked_t num_opens;
55015 + atomic_unchecked_t num_closes;
55016 + atomic_unchecked_t num_deletes;
55017 + atomic_unchecked_t num_mkdirs;
55018 + atomic_unchecked_t num_posixopens;
55019 + atomic_unchecked_t num_posixmkdirs;
55020 + atomic_unchecked_t num_rmdirs;
55021 + atomic_unchecked_t num_renames;
55022 + atomic_unchecked_t num_t2renames;
55023 + atomic_unchecked_t num_ffirst;
55024 + atomic_unchecked_t num_fnext;
55025 + atomic_unchecked_t num_fclose;
55026 + atomic_unchecked_t num_hardlinks;
55027 + atomic_unchecked_t num_symlinks;
55028 + atomic_unchecked_t num_locks;
55029 + atomic_unchecked_t num_acl_get;
55030 + atomic_unchecked_t num_acl_set;
55031 } cifs_stats;
55032 #ifdef CONFIG_CIFS_SMB2
55033 struct {
55034 - atomic_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
55035 - atomic_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
55036 + atomic_unchecked_t smb2_com_sent[NUMBER_OF_SMB2_COMMANDS];
55037 + atomic_unchecked_t smb2_com_failed[NUMBER_OF_SMB2_COMMANDS];
55038 } smb2_stats;
55039 #endif /* CONFIG_CIFS_SMB2 */
55040 } stats;
55041 @@ -1111,7 +1111,7 @@ convert_delimiter(char *path, char delim)
55042 }
55043
55044 #ifdef CONFIG_CIFS_STATS
55045 -#define cifs_stats_inc atomic_inc
55046 +#define cifs_stats_inc atomic_inc_unchecked
55047
55048 static inline void cifs_stats_bytes_written(struct cifs_tcon *tcon,
55049 unsigned int bytes)
55050 @@ -1477,8 +1477,8 @@ GLOBAL_EXTERN atomic_t tconInfoReconnectCount;
55051 /* Various Debug counters */
55052 GLOBAL_EXTERN atomic_t bufAllocCount; /* current number allocated */
55053 #ifdef CONFIG_CIFS_STATS2
55054 -GLOBAL_EXTERN atomic_t totBufAllocCount; /* total allocated over all time */
55055 -GLOBAL_EXTERN atomic_t totSmBufAllocCount;
55056 +GLOBAL_EXTERN atomic_unchecked_t totBufAllocCount; /* total allocated over all time */
55057 +GLOBAL_EXTERN atomic_unchecked_t totSmBufAllocCount;
55058 #endif
55059 GLOBAL_EXTERN atomic_t smBufAllocCount;
55060 GLOBAL_EXTERN atomic_t midCount;
55061 diff --git a/fs/cifs/file.c b/fs/cifs/file.c
55062 index 7ddddf2..2e12dbc 100644
55063 --- a/fs/cifs/file.c
55064 +++ b/fs/cifs/file.c
55065 @@ -1900,10 +1900,14 @@ static int cifs_writepages(struct address_space *mapping,
55066 index = mapping->writeback_index; /* Start from prev offset */
55067 end = -1;
55068 } else {
55069 - index = wbc->range_start >> PAGE_CACHE_SHIFT;
55070 - end = wbc->range_end >> PAGE_CACHE_SHIFT;
55071 - if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX)
55072 + if (wbc->range_start == 0 && wbc->range_end == LLONG_MAX) {
55073 range_whole = true;
55074 + index = 0;
55075 + end = ULONG_MAX;
55076 + } else {
55077 + index = wbc->range_start >> PAGE_CACHE_SHIFT;
55078 + end = wbc->range_end >> PAGE_CACHE_SHIFT;
55079 + }
55080 scanned = true;
55081 }
55082 retry:
55083 diff --git a/fs/cifs/link.c b/fs/cifs/link.c
55084 index 477e53b..7a32216 100644
55085 --- a/fs/cifs/link.c
55086 +++ b/fs/cifs/link.c
55087 @@ -620,7 +620,7 @@ symlink_exit:
55088
55089 void cifs_put_link(struct dentry *direntry, struct nameidata *nd, void *cookie)
55090 {
55091 - char *p = nd_get_link(nd);
55092 + const char *p = nd_get_link(nd);
55093 if (!IS_ERR(p))
55094 kfree(p);
55095 }
55096 diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
55097 index 138a011..cf9e13a 100644
55098 --- a/fs/cifs/misc.c
55099 +++ b/fs/cifs/misc.c
55100 @@ -170,7 +170,7 @@ cifs_buf_get(void)
55101 memset(ret_buf, 0, buf_size + 3);
55102 atomic_inc(&bufAllocCount);
55103 #ifdef CONFIG_CIFS_STATS2
55104 - atomic_inc(&totBufAllocCount);
55105 + atomic_inc_unchecked(&totBufAllocCount);
55106 #endif /* CONFIG_CIFS_STATS2 */
55107 }
55108
55109 @@ -205,7 +205,7 @@ cifs_small_buf_get(void)
55110 /* memset(ret_buf, 0, sizeof(struct smb_hdr) + 27);*/
55111 atomic_inc(&smBufAllocCount);
55112 #ifdef CONFIG_CIFS_STATS2
55113 - atomic_inc(&totSmBufAllocCount);
55114 + atomic_inc_unchecked(&totSmBufAllocCount);
55115 #endif /* CONFIG_CIFS_STATS2 */
55116
55117 }
55118 diff --git a/fs/cifs/smb1ops.c b/fs/cifs/smb1ops.c
55119 index e50554b..c011413 100644
55120 --- a/fs/cifs/smb1ops.c
55121 +++ b/fs/cifs/smb1ops.c
55122 @@ -609,27 +609,27 @@ static void
55123 cifs_clear_stats(struct cifs_tcon *tcon)
55124 {
55125 #ifdef CONFIG_CIFS_STATS
55126 - atomic_set(&tcon->stats.cifs_stats.num_writes, 0);
55127 - atomic_set(&tcon->stats.cifs_stats.num_reads, 0);
55128 - atomic_set(&tcon->stats.cifs_stats.num_flushes, 0);
55129 - atomic_set(&tcon->stats.cifs_stats.num_oplock_brks, 0);
55130 - atomic_set(&tcon->stats.cifs_stats.num_opens, 0);
55131 - atomic_set(&tcon->stats.cifs_stats.num_posixopens, 0);
55132 - atomic_set(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
55133 - atomic_set(&tcon->stats.cifs_stats.num_closes, 0);
55134 - atomic_set(&tcon->stats.cifs_stats.num_deletes, 0);
55135 - atomic_set(&tcon->stats.cifs_stats.num_mkdirs, 0);
55136 - atomic_set(&tcon->stats.cifs_stats.num_rmdirs, 0);
55137 - atomic_set(&tcon->stats.cifs_stats.num_renames, 0);
55138 - atomic_set(&tcon->stats.cifs_stats.num_t2renames, 0);
55139 - atomic_set(&tcon->stats.cifs_stats.num_ffirst, 0);
55140 - atomic_set(&tcon->stats.cifs_stats.num_fnext, 0);
55141 - atomic_set(&tcon->stats.cifs_stats.num_fclose, 0);
55142 - atomic_set(&tcon->stats.cifs_stats.num_hardlinks, 0);
55143 - atomic_set(&tcon->stats.cifs_stats.num_symlinks, 0);
55144 - atomic_set(&tcon->stats.cifs_stats.num_locks, 0);
55145 - atomic_set(&tcon->stats.cifs_stats.num_acl_get, 0);
55146 - atomic_set(&tcon->stats.cifs_stats.num_acl_set, 0);
55147 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_writes, 0);
55148 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_reads, 0);
55149 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_flushes, 0);
55150 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_oplock_brks, 0);
55151 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_opens, 0);
55152 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixopens, 0);
55153 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs, 0);
55154 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_closes, 0);
55155 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_deletes, 0);
55156 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_mkdirs, 0);
55157 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_rmdirs, 0);
55158 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_renames, 0);
55159 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_t2renames, 0);
55160 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_ffirst, 0);
55161 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fnext, 0);
55162 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_fclose, 0);
55163 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_hardlinks, 0);
55164 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_symlinks, 0);
55165 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_locks, 0);
55166 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_get, 0);
55167 + atomic_set_unchecked(&tcon->stats.cifs_stats.num_acl_set, 0);
55168 #endif
55169 }
55170
55171 @@ -638,36 +638,36 @@ cifs_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55172 {
55173 #ifdef CONFIG_CIFS_STATS
55174 seq_printf(m, " Oplocks breaks: %d",
55175 - atomic_read(&tcon->stats.cifs_stats.num_oplock_brks));
55176 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_oplock_brks));
55177 seq_printf(m, "\nReads: %d Bytes: %llu",
55178 - atomic_read(&tcon->stats.cifs_stats.num_reads),
55179 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_reads),
55180 (long long)(tcon->bytes_read));
55181 seq_printf(m, "\nWrites: %d Bytes: %llu",
55182 - atomic_read(&tcon->stats.cifs_stats.num_writes),
55183 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_writes),
55184 (long long)(tcon->bytes_written));
55185 seq_printf(m, "\nFlushes: %d",
55186 - atomic_read(&tcon->stats.cifs_stats.num_flushes));
55187 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_flushes));
55188 seq_printf(m, "\nLocks: %d HardLinks: %d Symlinks: %d",
55189 - atomic_read(&tcon->stats.cifs_stats.num_locks),
55190 - atomic_read(&tcon->stats.cifs_stats.num_hardlinks),
55191 - atomic_read(&tcon->stats.cifs_stats.num_symlinks));
55192 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_locks),
55193 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_hardlinks),
55194 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_symlinks));
55195 seq_printf(m, "\nOpens: %d Closes: %d Deletes: %d",
55196 - atomic_read(&tcon->stats.cifs_stats.num_opens),
55197 - atomic_read(&tcon->stats.cifs_stats.num_closes),
55198 - atomic_read(&tcon->stats.cifs_stats.num_deletes));
55199 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_opens),
55200 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_closes),
55201 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_deletes));
55202 seq_printf(m, "\nPosix Opens: %d Posix Mkdirs: %d",
55203 - atomic_read(&tcon->stats.cifs_stats.num_posixopens),
55204 - atomic_read(&tcon->stats.cifs_stats.num_posixmkdirs));
55205 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixopens),
55206 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_posixmkdirs));
55207 seq_printf(m, "\nMkdirs: %d Rmdirs: %d",
55208 - atomic_read(&tcon->stats.cifs_stats.num_mkdirs),
55209 - atomic_read(&tcon->stats.cifs_stats.num_rmdirs));
55210 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_mkdirs),
55211 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_rmdirs));
55212 seq_printf(m, "\nRenames: %d T2 Renames %d",
55213 - atomic_read(&tcon->stats.cifs_stats.num_renames),
55214 - atomic_read(&tcon->stats.cifs_stats.num_t2renames));
55215 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_renames),
55216 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_t2renames));
55217 seq_printf(m, "\nFindFirst: %d FNext %d FClose %d",
55218 - atomic_read(&tcon->stats.cifs_stats.num_ffirst),
55219 - atomic_read(&tcon->stats.cifs_stats.num_fnext),
55220 - atomic_read(&tcon->stats.cifs_stats.num_fclose));
55221 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_ffirst),
55222 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fnext),
55223 + atomic_read_unchecked(&tcon->stats.cifs_stats.num_fclose));
55224 #endif
55225 }
55226
55227 diff --git a/fs/cifs/smb2ops.c b/fs/cifs/smb2ops.c
55228 index 861b332..5506392 100644
55229 --- a/fs/cifs/smb2ops.c
55230 +++ b/fs/cifs/smb2ops.c
55231 @@ -282,8 +282,8 @@ smb2_clear_stats(struct cifs_tcon *tcon)
55232 #ifdef CONFIG_CIFS_STATS
55233 int i;
55234 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
55235 - atomic_set(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55236 - atomic_set(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55237 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_sent[i], 0);
55238 + atomic_set_unchecked(&tcon->stats.smb2_stats.smb2_com_failed[i], 0);
55239 }
55240 #endif
55241 }
55242 @@ -311,65 +311,65 @@ static void
55243 smb2_print_stats(struct seq_file *m, struct cifs_tcon *tcon)
55244 {
55245 #ifdef CONFIG_CIFS_STATS
55246 - atomic_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55247 - atomic_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55248 + atomic_unchecked_t *sent = tcon->stats.smb2_stats.smb2_com_sent;
55249 + atomic_unchecked_t *failed = tcon->stats.smb2_stats.smb2_com_failed;
55250 seq_printf(m, "\nNegotiates: %d sent %d failed",
55251 - atomic_read(&sent[SMB2_NEGOTIATE_HE]),
55252 - atomic_read(&failed[SMB2_NEGOTIATE_HE]));
55253 + atomic_read_unchecked(&sent[SMB2_NEGOTIATE_HE]),
55254 + atomic_read_unchecked(&failed[SMB2_NEGOTIATE_HE]));
55255 seq_printf(m, "\nSessionSetups: %d sent %d failed",
55256 - atomic_read(&sent[SMB2_SESSION_SETUP_HE]),
55257 - atomic_read(&failed[SMB2_SESSION_SETUP_HE]));
55258 + atomic_read_unchecked(&sent[SMB2_SESSION_SETUP_HE]),
55259 + atomic_read_unchecked(&failed[SMB2_SESSION_SETUP_HE]));
55260 seq_printf(m, "\nLogoffs: %d sent %d failed",
55261 - atomic_read(&sent[SMB2_LOGOFF_HE]),
55262 - atomic_read(&failed[SMB2_LOGOFF_HE]));
55263 + atomic_read_unchecked(&sent[SMB2_LOGOFF_HE]),
55264 + atomic_read_unchecked(&failed[SMB2_LOGOFF_HE]));
55265 seq_printf(m, "\nTreeConnects: %d sent %d failed",
55266 - atomic_read(&sent[SMB2_TREE_CONNECT_HE]),
55267 - atomic_read(&failed[SMB2_TREE_CONNECT_HE]));
55268 + atomic_read_unchecked(&sent[SMB2_TREE_CONNECT_HE]),
55269 + atomic_read_unchecked(&failed[SMB2_TREE_CONNECT_HE]));
55270 seq_printf(m, "\nTreeDisconnects: %d sent %d failed",
55271 - atomic_read(&sent[SMB2_TREE_DISCONNECT_HE]),
55272 - atomic_read(&failed[SMB2_TREE_DISCONNECT_HE]));
55273 + atomic_read_unchecked(&sent[SMB2_TREE_DISCONNECT_HE]),
55274 + atomic_read_unchecked(&failed[SMB2_TREE_DISCONNECT_HE]));
55275 seq_printf(m, "\nCreates: %d sent %d failed",
55276 - atomic_read(&sent[SMB2_CREATE_HE]),
55277 - atomic_read(&failed[SMB2_CREATE_HE]));
55278 + atomic_read_unchecked(&sent[SMB2_CREATE_HE]),
55279 + atomic_read_unchecked(&failed[SMB2_CREATE_HE]));
55280 seq_printf(m, "\nCloses: %d sent %d failed",
55281 - atomic_read(&sent[SMB2_CLOSE_HE]),
55282 - atomic_read(&failed[SMB2_CLOSE_HE]));
55283 + atomic_read_unchecked(&sent[SMB2_CLOSE_HE]),
55284 + atomic_read_unchecked(&failed[SMB2_CLOSE_HE]));
55285 seq_printf(m, "\nFlushes: %d sent %d failed",
55286 - atomic_read(&sent[SMB2_FLUSH_HE]),
55287 - atomic_read(&failed[SMB2_FLUSH_HE]));
55288 + atomic_read_unchecked(&sent[SMB2_FLUSH_HE]),
55289 + atomic_read_unchecked(&failed[SMB2_FLUSH_HE]));
55290 seq_printf(m, "\nReads: %d sent %d failed",
55291 - atomic_read(&sent[SMB2_READ_HE]),
55292 - atomic_read(&failed[SMB2_READ_HE]));
55293 + atomic_read_unchecked(&sent[SMB2_READ_HE]),
55294 + atomic_read_unchecked(&failed[SMB2_READ_HE]));
55295 seq_printf(m, "\nWrites: %d sent %d failed",
55296 - atomic_read(&sent[SMB2_WRITE_HE]),
55297 - atomic_read(&failed[SMB2_WRITE_HE]));
55298 + atomic_read_unchecked(&sent[SMB2_WRITE_HE]),
55299 + atomic_read_unchecked(&failed[SMB2_WRITE_HE]));
55300 seq_printf(m, "\nLocks: %d sent %d failed",
55301 - atomic_read(&sent[SMB2_LOCK_HE]),
55302 - atomic_read(&failed[SMB2_LOCK_HE]));
55303 + atomic_read_unchecked(&sent[SMB2_LOCK_HE]),
55304 + atomic_read_unchecked(&failed[SMB2_LOCK_HE]));
55305 seq_printf(m, "\nIOCTLs: %d sent %d failed",
55306 - atomic_read(&sent[SMB2_IOCTL_HE]),
55307 - atomic_read(&failed[SMB2_IOCTL_HE]));
55308 + atomic_read_unchecked(&sent[SMB2_IOCTL_HE]),
55309 + atomic_read_unchecked(&failed[SMB2_IOCTL_HE]));
55310 seq_printf(m, "\nCancels: %d sent %d failed",
55311 - atomic_read(&sent[SMB2_CANCEL_HE]),
55312 - atomic_read(&failed[SMB2_CANCEL_HE]));
55313 + atomic_read_unchecked(&sent[SMB2_CANCEL_HE]),
55314 + atomic_read_unchecked(&failed[SMB2_CANCEL_HE]));
55315 seq_printf(m, "\nEchos: %d sent %d failed",
55316 - atomic_read(&sent[SMB2_ECHO_HE]),
55317 - atomic_read(&failed[SMB2_ECHO_HE]));
55318 + atomic_read_unchecked(&sent[SMB2_ECHO_HE]),
55319 + atomic_read_unchecked(&failed[SMB2_ECHO_HE]));
55320 seq_printf(m, "\nQueryDirectories: %d sent %d failed",
55321 - atomic_read(&sent[SMB2_QUERY_DIRECTORY_HE]),
55322 - atomic_read(&failed[SMB2_QUERY_DIRECTORY_HE]));
55323 + atomic_read_unchecked(&sent[SMB2_QUERY_DIRECTORY_HE]),
55324 + atomic_read_unchecked(&failed[SMB2_QUERY_DIRECTORY_HE]));
55325 seq_printf(m, "\nChangeNotifies: %d sent %d failed",
55326 - atomic_read(&sent[SMB2_CHANGE_NOTIFY_HE]),
55327 - atomic_read(&failed[SMB2_CHANGE_NOTIFY_HE]));
55328 + atomic_read_unchecked(&sent[SMB2_CHANGE_NOTIFY_HE]),
55329 + atomic_read_unchecked(&failed[SMB2_CHANGE_NOTIFY_HE]));
55330 seq_printf(m, "\nQueryInfos: %d sent %d failed",
55331 - atomic_read(&sent[SMB2_QUERY_INFO_HE]),
55332 - atomic_read(&failed[SMB2_QUERY_INFO_HE]));
55333 + atomic_read_unchecked(&sent[SMB2_QUERY_INFO_HE]),
55334 + atomic_read_unchecked(&failed[SMB2_QUERY_INFO_HE]));
55335 seq_printf(m, "\nSetInfos: %d sent %d failed",
55336 - atomic_read(&sent[SMB2_SET_INFO_HE]),
55337 - atomic_read(&failed[SMB2_SET_INFO_HE]));
55338 + atomic_read_unchecked(&sent[SMB2_SET_INFO_HE]),
55339 + atomic_read_unchecked(&failed[SMB2_SET_INFO_HE]));
55340 seq_printf(m, "\nOplockBreaks: %d sent %d failed",
55341 - atomic_read(&sent[SMB2_OPLOCK_BREAK_HE]),
55342 - atomic_read(&failed[SMB2_OPLOCK_BREAK_HE]));
55343 + atomic_read_unchecked(&sent[SMB2_OPLOCK_BREAK_HE]),
55344 + atomic_read_unchecked(&failed[SMB2_OPLOCK_BREAK_HE]));
55345 #endif
55346 }
55347
55348 diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c
55349 index edccb52..16bc6db 100644
55350 --- a/fs/cifs/smb2pdu.c
55351 +++ b/fs/cifs/smb2pdu.c
55352 @@ -1957,8 +1957,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon,
55353 default:
55354 cifs_dbg(VFS, "info level %u isn't supported\n",
55355 srch_inf->info_level);
55356 - rc = -EINVAL;
55357 - goto qdir_exit;
55358 + return -EINVAL;
55359 }
55360
55361 req->FileIndex = cpu_to_le32(index);
55362 diff --git a/fs/coda/cache.c b/fs/coda/cache.c
55363 index 1da168c..8bc7ff6 100644
55364 --- a/fs/coda/cache.c
55365 +++ b/fs/coda/cache.c
55366 @@ -24,7 +24,7 @@
55367 #include "coda_linux.h"
55368 #include "coda_cache.h"
55369
55370 -static atomic_t permission_epoch = ATOMIC_INIT(0);
55371 +static atomic_unchecked_t permission_epoch = ATOMIC_INIT(0);
55372
55373 /* replace or extend an acl cache hit */
55374 void coda_cache_enter(struct inode *inode, int mask)
55375 @@ -32,7 +32,7 @@ void coda_cache_enter(struct inode *inode, int mask)
55376 struct coda_inode_info *cii = ITOC(inode);
55377
55378 spin_lock(&cii->c_lock);
55379 - cii->c_cached_epoch = atomic_read(&permission_epoch);
55380 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch);
55381 if (!uid_eq(cii->c_uid, current_fsuid())) {
55382 cii->c_uid = current_fsuid();
55383 cii->c_cached_perm = mask;
55384 @@ -46,14 +46,14 @@ void coda_cache_clear_inode(struct inode *inode)
55385 {
55386 struct coda_inode_info *cii = ITOC(inode);
55387 spin_lock(&cii->c_lock);
55388 - cii->c_cached_epoch = atomic_read(&permission_epoch) - 1;
55389 + cii->c_cached_epoch = atomic_read_unchecked(&permission_epoch) - 1;
55390 spin_unlock(&cii->c_lock);
55391 }
55392
55393 /* remove all acl caches */
55394 void coda_cache_clear_all(struct super_block *sb)
55395 {
55396 - atomic_inc(&permission_epoch);
55397 + atomic_inc_unchecked(&permission_epoch);
55398 }
55399
55400
55401 @@ -66,7 +66,7 @@ int coda_cache_check(struct inode *inode, int mask)
55402 spin_lock(&cii->c_lock);
55403 hit = (mask & cii->c_cached_perm) == mask &&
55404 uid_eq(cii->c_uid, current_fsuid()) &&
55405 - cii->c_cached_epoch == atomic_read(&permission_epoch);
55406 + cii->c_cached_epoch == atomic_read_unchecked(&permission_epoch);
55407 spin_unlock(&cii->c_lock);
55408
55409 return hit;
55410 diff --git a/fs/compat.c b/fs/compat.c
55411 index 6af20de..fec3fbb 100644
55412 --- a/fs/compat.c
55413 +++ b/fs/compat.c
55414 @@ -54,7 +54,7 @@
55415 #include <asm/ioctls.h>
55416 #include "internal.h"
55417
55418 -int compat_log = 1;
55419 +int compat_log = 0;
55420
55421 int compat_printk(const char *fmt, ...)
55422 {
55423 @@ -488,7 +488,7 @@ compat_sys_io_setup(unsigned nr_reqs, u32 __user *ctx32p)
55424
55425 set_fs(KERNEL_DS);
55426 /* The __user pointer cast is valid because of the set_fs() */
55427 - ret = sys_io_setup(nr_reqs, (aio_context_t __user *) &ctx64);
55428 + ret = sys_io_setup(nr_reqs, (aio_context_t __force_user *) &ctx64);
55429 set_fs(oldfs);
55430 /* truncating is ok because it's a user address */
55431 if (!ret)
55432 @@ -546,7 +546,7 @@ ssize_t compat_rw_copy_check_uvector(int type,
55433 goto out;
55434
55435 ret = -EINVAL;
55436 - if (nr_segs > UIO_MAXIOV || nr_segs < 0)
55437 + if (nr_segs > UIO_MAXIOV)
55438 goto out;
55439 if (nr_segs > fast_segs) {
55440 ret = -ENOMEM;
55441 @@ -834,6 +834,7 @@ struct compat_old_linux_dirent {
55442 struct compat_readdir_callback {
55443 struct dir_context ctx;
55444 struct compat_old_linux_dirent __user *dirent;
55445 + struct file * file;
55446 int result;
55447 };
55448
55449 @@ -851,6 +852,10 @@ static int compat_fillonedir(void *__buf, const char *name, int namlen,
55450 buf->result = -EOVERFLOW;
55451 return -EOVERFLOW;
55452 }
55453 +
55454 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55455 + return 0;
55456 +
55457 buf->result++;
55458 dirent = buf->dirent;
55459 if (!access_ok(VERIFY_WRITE, dirent,
55460 @@ -882,6 +887,7 @@ asmlinkage long compat_sys_old_readdir(unsigned int fd,
55461 if (!f.file)
55462 return -EBADF;
55463
55464 + buf.file = f.file;
55465 error = iterate_dir(f.file, &buf.ctx);
55466 if (buf.result)
55467 error = buf.result;
55468 @@ -901,6 +907,7 @@ struct compat_getdents_callback {
55469 struct dir_context ctx;
55470 struct compat_linux_dirent __user *current_dir;
55471 struct compat_linux_dirent __user *previous;
55472 + struct file * file;
55473 int count;
55474 int error;
55475 };
55476 @@ -922,6 +929,10 @@ static int compat_filldir(void *__buf, const char *name, int namlen,
55477 buf->error = -EOVERFLOW;
55478 return -EOVERFLOW;
55479 }
55480 +
55481 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55482 + return 0;
55483 +
55484 dirent = buf->previous;
55485 if (dirent) {
55486 if (__put_user(offset, &dirent->d_off))
55487 @@ -967,6 +978,7 @@ asmlinkage long compat_sys_getdents(unsigned int fd,
55488 if (!f.file)
55489 return -EBADF;
55490
55491 + buf.file = f.file;
55492 error = iterate_dir(f.file, &buf.ctx);
55493 if (error >= 0)
55494 error = buf.error;
55495 @@ -987,6 +999,7 @@ struct compat_getdents_callback64 {
55496 struct dir_context ctx;
55497 struct linux_dirent64 __user *current_dir;
55498 struct linux_dirent64 __user *previous;
55499 + struct file * file;
55500 int count;
55501 int error;
55502 };
55503 @@ -1003,6 +1016,10 @@ static int compat_filldir64(void * __buf, const char * name, int namlen, loff_t
55504 buf->error = -EINVAL; /* only used if we fail.. */
55505 if (reclen > buf->count)
55506 return -EINVAL;
55507 +
55508 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
55509 + return 0;
55510 +
55511 dirent = buf->previous;
55512
55513 if (dirent) {
55514 @@ -1052,6 +1069,7 @@ asmlinkage long compat_sys_getdents64(unsigned int fd,
55515 if (!f.file)
55516 return -EBADF;
55517
55518 + buf.file = f.file;
55519 error = iterate_dir(f.file, &buf.ctx);
55520 if (error >= 0)
55521 error = buf.error;
55522 diff --git a/fs/compat_binfmt_elf.c b/fs/compat_binfmt_elf.c
55523 index a81147e..20bf2b5 100644
55524 --- a/fs/compat_binfmt_elf.c
55525 +++ b/fs/compat_binfmt_elf.c
55526 @@ -30,11 +30,13 @@
55527 #undef elf_phdr
55528 #undef elf_shdr
55529 #undef elf_note
55530 +#undef elf_dyn
55531 #undef elf_addr_t
55532 #define elfhdr elf32_hdr
55533 #define elf_phdr elf32_phdr
55534 #define elf_shdr elf32_shdr
55535 #define elf_note elf32_note
55536 +#define elf_dyn Elf32_Dyn
55537 #define elf_addr_t Elf32_Addr
55538
55539 /*
55540 diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c
55541 index 5d19acf..9ab093b 100644
55542 --- a/fs/compat_ioctl.c
55543 +++ b/fs/compat_ioctl.c
55544 @@ -621,7 +621,7 @@ static int serial_struct_ioctl(unsigned fd, unsigned cmd,
55545 return -EFAULT;
55546 if (__get_user(udata, &ss32->iomem_base))
55547 return -EFAULT;
55548 - ss.iomem_base = compat_ptr(udata);
55549 + ss.iomem_base = (unsigned char __force_kernel *)compat_ptr(udata);
55550 if (__get_user(ss.iomem_reg_shift, &ss32->iomem_reg_shift) ||
55551 __get_user(ss.port_high, &ss32->port_high))
55552 return -EFAULT;
55553 @@ -702,8 +702,8 @@ static int do_i2c_rdwr_ioctl(unsigned int fd, unsigned int cmd,
55554 for (i = 0; i < nmsgs; i++) {
55555 if (copy_in_user(&tmsgs[i].addr, &umsgs[i].addr, 3*sizeof(u16)))
55556 return -EFAULT;
55557 - if (get_user(datap, &umsgs[i].buf) ||
55558 - put_user(compat_ptr(datap), &tmsgs[i].buf))
55559 + if (get_user(datap, (u8 __user * __user *)&umsgs[i].buf) ||
55560 + put_user(compat_ptr(datap), (u8 __user * __user *)&tmsgs[i].buf))
55561 return -EFAULT;
55562 }
55563 return sys_ioctl(fd, cmd, (unsigned long)tdata);
55564 @@ -796,7 +796,7 @@ static int compat_ioctl_preallocate(struct file *file,
55565 copy_in_user(&p->l_len, &p32->l_len, sizeof(s64)) ||
55566 copy_in_user(&p->l_sysid, &p32->l_sysid, sizeof(s32)) ||
55567 copy_in_user(&p->l_pid, &p32->l_pid, sizeof(u32)) ||
55568 - copy_in_user(&p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55569 + copy_in_user(p->l_pad, &p32->l_pad, 4*sizeof(u32)))
55570 return -EFAULT;
55571
55572 return ioctl_preallocate(file, p);
55573 @@ -1616,8 +1616,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd,
55574 static int __init init_sys32_ioctl_cmp(const void *p, const void *q)
55575 {
55576 unsigned int a, b;
55577 - a = *(unsigned int *)p;
55578 - b = *(unsigned int *)q;
55579 + a = *(const unsigned int *)p;
55580 + b = *(const unsigned int *)q;
55581 if (a > b)
55582 return 1;
55583 if (a < b)
55584 diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
55585 index 511d415..319d0e5 100644
55586 --- a/fs/configfs/dir.c
55587 +++ b/fs/configfs/dir.c
55588 @@ -1558,7 +1558,8 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
55589 }
55590 for (p = q->next; p != &parent_sd->s_children; p = p->next) {
55591 struct configfs_dirent *next;
55592 - const char *name;
55593 + const unsigned char * name;
55594 + char d_name[sizeof(next->s_dentry->d_iname)];
55595 int len;
55596 struct inode *inode = NULL;
55597
55598 @@ -1567,7 +1568,12 @@ static int configfs_readdir(struct file *file, struct dir_context *ctx)
55599 continue;
55600
55601 name = configfs_get_name(next);
55602 - len = strlen(name);
55603 + if (next->s_dentry && name == next->s_dentry->d_iname) {
55604 + len = next->s_dentry->d_name.len;
55605 + memcpy(d_name, name, len);
55606 + name = d_name;
55607 + } else
55608 + len = strlen(name);
55609
55610 /*
55611 * We'll have a dentry and an inode for
55612 diff --git a/fs/coredump.c b/fs/coredump.c
55613 index 9bdeca1..2a9b08d 100644
55614 --- a/fs/coredump.c
55615 +++ b/fs/coredump.c
55616 @@ -438,8 +438,8 @@ static void wait_for_dump_helpers(struct file *file)
55617 struct pipe_inode_info *pipe = file->private_data;
55618
55619 pipe_lock(pipe);
55620 - pipe->readers++;
55621 - pipe->writers--;
55622 + atomic_inc(&pipe->readers);
55623 + atomic_dec(&pipe->writers);
55624 wake_up_interruptible_sync(&pipe->wait);
55625 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
55626 pipe_unlock(pipe);
55627 @@ -448,11 +448,11 @@ static void wait_for_dump_helpers(struct file *file)
55628 * We actually want wait_event_freezable() but then we need
55629 * to clear TIF_SIGPENDING and improve dump_interrupted().
55630 */
55631 - wait_event_interruptible(pipe->wait, pipe->readers == 1);
55632 + wait_event_interruptible(pipe->wait, atomic_read(&pipe->readers) == 1);
55633
55634 pipe_lock(pipe);
55635 - pipe->readers--;
55636 - pipe->writers++;
55637 + atomic_dec(&pipe->readers);
55638 + atomic_inc(&pipe->writers);
55639 pipe_unlock(pipe);
55640 }
55641
55642 @@ -499,7 +499,9 @@ void do_coredump(siginfo_t *siginfo)
55643 struct files_struct *displaced;
55644 bool need_nonrelative = false;
55645 bool core_dumped = false;
55646 - static atomic_t core_dump_count = ATOMIC_INIT(0);
55647 + static atomic_unchecked_t core_dump_count = ATOMIC_INIT(0);
55648 + long signr = siginfo->si_signo;
55649 + int dumpable;
55650 struct coredump_params cprm = {
55651 .siginfo = siginfo,
55652 .regs = signal_pt_regs(),
55653 @@ -512,12 +514,17 @@ void do_coredump(siginfo_t *siginfo)
55654 .mm_flags = mm->flags,
55655 };
55656
55657 - audit_core_dumps(siginfo->si_signo);
55658 + audit_core_dumps(signr);
55659 +
55660 + dumpable = __get_dumpable(cprm.mm_flags);
55661 +
55662 + if (signr == SIGSEGV || signr == SIGBUS || signr == SIGKILL || signr == SIGILL)
55663 + gr_handle_brute_attach(dumpable);
55664
55665 binfmt = mm->binfmt;
55666 if (!binfmt || !binfmt->core_dump)
55667 goto fail;
55668 - if (!__get_dumpable(cprm.mm_flags))
55669 + if (!dumpable)
55670 goto fail;
55671
55672 cred = prepare_creds();
55673 @@ -536,7 +543,7 @@ void do_coredump(siginfo_t *siginfo)
55674 need_nonrelative = true;
55675 }
55676
55677 - retval = coredump_wait(siginfo->si_signo, &core_state);
55678 + retval = coredump_wait(signr, &core_state);
55679 if (retval < 0)
55680 goto fail_creds;
55681
55682 @@ -579,7 +586,7 @@ void do_coredump(siginfo_t *siginfo)
55683 }
55684 cprm.limit = RLIM_INFINITY;
55685
55686 - dump_count = atomic_inc_return(&core_dump_count);
55687 + dump_count = atomic_inc_return_unchecked(&core_dump_count);
55688 if (core_pipe_limit && (core_pipe_limit < dump_count)) {
55689 printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
55690 task_tgid_vnr(current), current->comm);
55691 @@ -611,6 +618,8 @@ void do_coredump(siginfo_t *siginfo)
55692 } else {
55693 struct inode *inode;
55694
55695 + gr_learn_resource(current, RLIMIT_CORE, binfmt->min_coredump, 1);
55696 +
55697 if (cprm.limit < binfmt->min_coredump)
55698 goto fail_unlock;
55699
55700 @@ -669,7 +678,7 @@ close_fail:
55701 filp_close(cprm.file, NULL);
55702 fail_dropcount:
55703 if (ispipe)
55704 - atomic_dec(&core_dump_count);
55705 + atomic_dec_unchecked(&core_dump_count);
55706 fail_unlock:
55707 kfree(cn.corename);
55708 coredump_finish(mm, core_dumped);
55709 @@ -689,7 +698,7 @@ int dump_write(struct file *file, const void *addr, int nr)
55710 {
55711 return !dump_interrupted() &&
55712 access_ok(VERIFY_READ, addr, nr) &&
55713 - file->f_op->write(file, addr, nr, &file->f_pos) == nr;
55714 + file->f_op->write(file, (const char __force_user *)addr, nr, &file->f_pos) == nr;
55715 }
55716 EXPORT_SYMBOL(dump_write);
55717
55718 diff --git a/fs/dcache.c b/fs/dcache.c
55719 index 89f9671..d2dce57 100644
55720 --- a/fs/dcache.c
55721 +++ b/fs/dcache.c
55722 @@ -1570,7 +1570,7 @@ struct dentry *__d_alloc(struct super_block *sb, const struct qstr *name)
55723 */
55724 dentry->d_iname[DNAME_INLINE_LEN-1] = 0;
55725 if (name->len > DNAME_INLINE_LEN-1) {
55726 - dname = kmalloc(name->len + 1, GFP_KERNEL);
55727 + dname = kmalloc(round_up(name->len + 1, sizeof(unsigned long)), GFP_KERNEL);
55728 if (!dname) {
55729 kmem_cache_free(dentry_cache, dentry);
55730 return NULL;
55731 @@ -2893,6 +2893,7 @@ static int prepend_path(const struct path *path,
55732 restart:
55733 bptr = *buffer;
55734 blen = *buflen;
55735 + error = 0;
55736 dentry = path->dentry;
55737 vfsmnt = path->mnt;
55738 mnt = real_mount(vfsmnt);
55739 @@ -3432,7 +3433,8 @@ void __init vfs_caches_init(unsigned long mempages)
55740 mempages -= reserve;
55741
55742 names_cachep = kmem_cache_create("names_cache", PATH_MAX, 0,
55743 - SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
55744 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_USERCOPY|
55745 + SLAB_NO_SANITIZE, NULL);
55746
55747 dcache_init();
55748 inode_init();
55749 diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
55750 index c7c83ff..bda9461 100644
55751 --- a/fs/debugfs/inode.c
55752 +++ b/fs/debugfs/inode.c
55753 @@ -415,7 +415,11 @@ EXPORT_SYMBOL_GPL(debugfs_create_file);
55754 */
55755 struct dentry *debugfs_create_dir(const char *name, struct dentry *parent)
55756 {
55757 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
55758 + return __create_file(name, S_IFDIR | S_IRWXU,
55759 +#else
55760 return __create_file(name, S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
55761 +#endif
55762 parent, NULL, NULL);
55763 }
55764 EXPORT_SYMBOL_GPL(debugfs_create_dir);
55765 diff --git a/fs/ecryptfs/inode.c b/fs/ecryptfs/inode.c
55766 index 67e9b63..a9adb68 100644
55767 --- a/fs/ecryptfs/inode.c
55768 +++ b/fs/ecryptfs/inode.c
55769 @@ -674,7 +674,7 @@ static int ecryptfs_readlink_lower(struct dentry *dentry, char **buf,
55770 old_fs = get_fs();
55771 set_fs(get_ds());
55772 rc = lower_dentry->d_inode->i_op->readlink(lower_dentry,
55773 - (char __user *)lower_buf,
55774 + (char __force_user *)lower_buf,
55775 PATH_MAX);
55776 set_fs(old_fs);
55777 if (rc < 0)
55778 @@ -706,7 +706,7 @@ out:
55779 static void
55780 ecryptfs_put_link(struct dentry *dentry, struct nameidata *nd, void *ptr)
55781 {
55782 - char *buf = nd_get_link(nd);
55783 + const char *buf = nd_get_link(nd);
55784 if (!IS_ERR(buf)) {
55785 /* Free the char* */
55786 kfree(buf);
55787 diff --git a/fs/ecryptfs/miscdev.c b/fs/ecryptfs/miscdev.c
55788 index e4141f2..d8263e8 100644
55789 --- a/fs/ecryptfs/miscdev.c
55790 +++ b/fs/ecryptfs/miscdev.c
55791 @@ -304,7 +304,7 @@ check_list:
55792 goto out_unlock_msg_ctx;
55793 i = PKT_TYPE_SIZE + PKT_CTR_SIZE;
55794 if (msg_ctx->msg) {
55795 - if (copy_to_user(&buf[i], packet_length, packet_length_size))
55796 + if (packet_length_size > sizeof(packet_length) || copy_to_user(&buf[i], packet_length, packet_length_size))
55797 goto out_unlock_msg_ctx;
55798 i += packet_length_size;
55799 if (copy_to_user(&buf[i], msg_ctx->msg, msg_ctx->msg_size))
55800 diff --git a/fs/exec.c b/fs/exec.c
55801 index bb8afc1..2f5087e 100644
55802 --- a/fs/exec.c
55803 +++ b/fs/exec.c
55804 @@ -55,8 +55,20 @@
55805 #include <linux/pipe_fs_i.h>
55806 #include <linux/oom.h>
55807 #include <linux/compat.h>
55808 +#include <linux/random.h>
55809 +#include <linux/seq_file.h>
55810 +#include <linux/coredump.h>
55811 +#include <linux/mman.h>
55812 +
55813 +#ifdef CONFIG_PAX_REFCOUNT
55814 +#include <linux/kallsyms.h>
55815 +#include <linux/kdebug.h>
55816 +#endif
55817 +
55818 +#include <trace/events/fs.h>
55819
55820 #include <asm/uaccess.h>
55821 +#include <asm/sections.h>
55822 #include <asm/mmu_context.h>
55823 #include <asm/tlb.h>
55824
55825 @@ -66,19 +78,34 @@
55826
55827 #include <trace/events/sched.h>
55828
55829 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
55830 +void __weak pax_set_initial_flags(struct linux_binprm *bprm)
55831 +{
55832 + 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");
55833 +}
55834 +#endif
55835 +
55836 +#ifdef CONFIG_PAX_HOOK_ACL_FLAGS
55837 +void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
55838 +EXPORT_SYMBOL(pax_set_initial_flags_func);
55839 +#endif
55840 +
55841 int suid_dumpable = 0;
55842
55843 static LIST_HEAD(formats);
55844 static DEFINE_RWLOCK(binfmt_lock);
55845
55846 +extern int gr_process_kernel_exec_ban(void);
55847 +extern int gr_process_suid_exec_ban(const struct linux_binprm *bprm);
55848 +
55849 void __register_binfmt(struct linux_binfmt * fmt, int insert)
55850 {
55851 BUG_ON(!fmt);
55852 if (WARN_ON(!fmt->load_binary))
55853 return;
55854 write_lock(&binfmt_lock);
55855 - insert ? list_add(&fmt->lh, &formats) :
55856 - list_add_tail(&fmt->lh, &formats);
55857 + insert ? pax_list_add((struct list_head *)&fmt->lh, &formats) :
55858 + pax_list_add_tail((struct list_head *)&fmt->lh, &formats);
55859 write_unlock(&binfmt_lock);
55860 }
55861
55862 @@ -87,7 +114,7 @@ EXPORT_SYMBOL(__register_binfmt);
55863 void unregister_binfmt(struct linux_binfmt * fmt)
55864 {
55865 write_lock(&binfmt_lock);
55866 - list_del(&fmt->lh);
55867 + pax_list_del((struct list_head *)&fmt->lh);
55868 write_unlock(&binfmt_lock);
55869 }
55870
55871 @@ -183,18 +210,10 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55872 int write)
55873 {
55874 struct page *page;
55875 - int ret;
55876
55877 -#ifdef CONFIG_STACK_GROWSUP
55878 - if (write) {
55879 - ret = expand_downwards(bprm->vma, pos);
55880 - if (ret < 0)
55881 - return NULL;
55882 - }
55883 -#endif
55884 - ret = get_user_pages(current, bprm->mm, pos,
55885 - 1, write, 1, &page, NULL);
55886 - if (ret <= 0)
55887 + if (0 > expand_downwards(bprm->vma, pos))
55888 + return NULL;
55889 + if (0 >= get_user_pages(current, bprm->mm, pos, 1, write, 1, &page, NULL))
55890 return NULL;
55891
55892 if (write) {
55893 @@ -210,6 +229,17 @@ static struct page *get_arg_page(struct linux_binprm *bprm, unsigned long pos,
55894 if (size <= ARG_MAX)
55895 return page;
55896
55897 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
55898 + // only allow 512KB for argv+env on suid/sgid binaries
55899 + // to prevent easy ASLR exhaustion
55900 + if (((!uid_eq(bprm->cred->euid, current_euid())) ||
55901 + (!gid_eq(bprm->cred->egid, current_egid()))) &&
55902 + (size > (512 * 1024))) {
55903 + put_page(page);
55904 + return NULL;
55905 + }
55906 +#endif
55907 +
55908 /*
55909 * Limit to 1/4-th the stack size for the argv+env strings.
55910 * This ensures that:
55911 @@ -269,6 +299,11 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55912 vma->vm_end = STACK_TOP_MAX;
55913 vma->vm_start = vma->vm_end - PAGE_SIZE;
55914 vma->vm_flags = VM_SOFTDIRTY | VM_STACK_FLAGS | VM_STACK_INCOMPLETE_SETUP;
55915 +
55916 +#ifdef CONFIG_PAX_SEGMEXEC
55917 + vma->vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
55918 +#endif
55919 +
55920 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
55921 INIT_LIST_HEAD(&vma->anon_vma_chain);
55922
55923 @@ -279,6 +314,12 @@ static int __bprm_mm_init(struct linux_binprm *bprm)
55924 mm->stack_vm = mm->total_vm = 1;
55925 up_write(&mm->mmap_sem);
55926 bprm->p = vma->vm_end - sizeof(void *);
55927 +
55928 +#ifdef CONFIG_PAX_RANDUSTACK
55929 + if (randomize_va_space)
55930 + bprm->p ^= prandom_u32() & ~PAGE_MASK;
55931 +#endif
55932 +
55933 return 0;
55934 err:
55935 up_write(&mm->mmap_sem);
55936 @@ -399,7 +440,7 @@ struct user_arg_ptr {
55937 } ptr;
55938 };
55939
55940 -static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55941 +const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55942 {
55943 const char __user *native;
55944
55945 @@ -408,14 +449,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
55946 compat_uptr_t compat;
55947
55948 if (get_user(compat, argv.ptr.compat + nr))
55949 - return ERR_PTR(-EFAULT);
55950 + return (const char __force_user *)ERR_PTR(-EFAULT);
55951
55952 return compat_ptr(compat);
55953 }
55954 #endif
55955
55956 if (get_user(native, argv.ptr.native + nr))
55957 - return ERR_PTR(-EFAULT);
55958 + return (const char __force_user *)ERR_PTR(-EFAULT);
55959
55960 return native;
55961 }
55962 @@ -434,7 +475,7 @@ static int count(struct user_arg_ptr argv, int max)
55963 if (!p)
55964 break;
55965
55966 - if (IS_ERR(p))
55967 + if (IS_ERR((const char __force_kernel *)p))
55968 return -EFAULT;
55969
55970 if (i >= max)
55971 @@ -469,7 +510,7 @@ static int copy_strings(int argc, struct user_arg_ptr argv,
55972
55973 ret = -EFAULT;
55974 str = get_user_arg_ptr(argv, argc);
55975 - if (IS_ERR(str))
55976 + if (IS_ERR((const char __force_kernel *)str))
55977 goto out;
55978
55979 len = strnlen_user(str, MAX_ARG_STRLEN);
55980 @@ -551,7 +592,7 @@ int copy_strings_kernel(int argc, const char *const *__argv,
55981 int r;
55982 mm_segment_t oldfs = get_fs();
55983 struct user_arg_ptr argv = {
55984 - .ptr.native = (const char __user *const __user *)__argv,
55985 + .ptr.native = (const char __force_user * const __force_user *)__argv,
55986 };
55987
55988 set_fs(KERNEL_DS);
55989 @@ -586,7 +627,8 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
55990 unsigned long new_end = old_end - shift;
55991 struct mmu_gather tlb;
55992
55993 - BUG_ON(new_start > new_end);
55994 + if (new_start >= new_end || new_start < mmap_min_addr)
55995 + return -ENOMEM;
55996
55997 /*
55998 * ensure there are no vmas between where we want to go
55999 @@ -595,6 +637,10 @@ static int shift_arg_pages(struct vm_area_struct *vma, unsigned long shift)
56000 if (vma != find_vma(mm, new_start))
56001 return -EFAULT;
56002
56003 +#ifdef CONFIG_PAX_SEGMEXEC
56004 + BUG_ON(pax_find_mirror_vma(vma));
56005 +#endif
56006 +
56007 /*
56008 * cover the whole range: [new_start, old_end)
56009 */
56010 @@ -675,10 +721,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
56011 stack_top = arch_align_stack(stack_top);
56012 stack_top = PAGE_ALIGN(stack_top);
56013
56014 - if (unlikely(stack_top < mmap_min_addr) ||
56015 - unlikely(vma->vm_end - vma->vm_start >= stack_top - mmap_min_addr))
56016 - return -ENOMEM;
56017 -
56018 stack_shift = vma->vm_end - stack_top;
56019
56020 bprm->p -= stack_shift;
56021 @@ -690,8 +732,28 @@ int setup_arg_pages(struct linux_binprm *bprm,
56022 bprm->exec -= stack_shift;
56023
56024 down_write(&mm->mmap_sem);
56025 +
56026 + /* Move stack pages down in memory. */
56027 + if (stack_shift) {
56028 + ret = shift_arg_pages(vma, stack_shift);
56029 + if (ret)
56030 + goto out_unlock;
56031 + }
56032 +
56033 vm_flags = VM_STACK_FLAGS;
56034
56035 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56036 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
56037 + vm_flags &= ~VM_EXEC;
56038 +
56039 +#ifdef CONFIG_PAX_MPROTECT
56040 + if (mm->pax_flags & MF_PAX_MPROTECT)
56041 + vm_flags &= ~VM_MAYEXEC;
56042 +#endif
56043 +
56044 + }
56045 +#endif
56046 +
56047 /*
56048 * Adjust stack execute permissions; explicitly enable for
56049 * EXSTACK_ENABLE_X, disable for EXSTACK_DISABLE_X and leave alone
56050 @@ -710,13 +772,6 @@ int setup_arg_pages(struct linux_binprm *bprm,
56051 goto out_unlock;
56052 BUG_ON(prev != vma);
56053
56054 - /* Move stack pages down in memory. */
56055 - if (stack_shift) {
56056 - ret = shift_arg_pages(vma, stack_shift);
56057 - if (ret)
56058 - goto out_unlock;
56059 - }
56060 -
56061 /* mprotect_fixup is overkill to remove the temporary stack flags */
56062 vma->vm_flags &= ~VM_STACK_INCOMPLETE_SETUP;
56063
56064 @@ -740,6 +795,27 @@ int setup_arg_pages(struct linux_binprm *bprm,
56065 #endif
56066 current->mm->start_stack = bprm->p;
56067 ret = expand_stack(vma, stack_base);
56068 +
56069 +#if !defined(CONFIG_STACK_GROWSUP) && defined(CONFIG_PAX_RANDMMAP)
56070 + if (!ret && (mm->pax_flags & MF_PAX_RANDMMAP) && STACK_TOP <= 0xFFFFFFFFU && STACK_TOP > vma->vm_end) {
56071 + unsigned long size;
56072 + vm_flags_t vm_flags;
56073 +
56074 + size = STACK_TOP - vma->vm_end;
56075 + vm_flags = VM_NONE | VM_DONTEXPAND | VM_DONTDUMP;
56076 +
56077 + ret = vma->vm_end != mmap_region(NULL, vma->vm_end, size, vm_flags, 0);
56078 +
56079 +#ifdef CONFIG_X86
56080 + if (!ret) {
56081 + size = PAGE_SIZE + mmap_min_addr + ((mm->delta_mmap ^ mm->delta_stack) & (0xFFUL << PAGE_SHIFT));
56082 + ret = 0 != mmap_region(NULL, 0, PAGE_ALIGN(size), vm_flags, 0);
56083 + }
56084 +#endif
56085 +
56086 + }
56087 +#endif
56088 +
56089 if (ret)
56090 ret = -EFAULT;
56091
56092 @@ -776,6 +852,8 @@ struct file *open_exec(const char *name)
56093
56094 fsnotify_open(file);
56095
56096 + trace_open_exec(name);
56097 +
56098 err = deny_write_access(file);
56099 if (err)
56100 goto exit;
56101 @@ -799,7 +877,7 @@ int kernel_read(struct file *file, loff_t offset,
56102 old_fs = get_fs();
56103 set_fs(get_ds());
56104 /* The cast to a user pointer is valid due to the set_fs() */
56105 - result = vfs_read(file, (void __user *)addr, count, &pos);
56106 + result = vfs_read(file, (void __force_user *)addr, count, &pos);
56107 set_fs(old_fs);
56108 return result;
56109 }
56110 @@ -1255,7 +1333,7 @@ static int check_unsafe_exec(struct linux_binprm *bprm)
56111 }
56112 rcu_read_unlock();
56113
56114 - if (p->fs->users > n_fs) {
56115 + if (atomic_read(&p->fs->users) > n_fs) {
56116 bprm->unsafe |= LSM_UNSAFE_SHARE;
56117 } else {
56118 res = -EAGAIN;
56119 @@ -1451,6 +1529,31 @@ static int exec_binprm(struct linux_binprm *bprm)
56120 return ret;
56121 }
56122
56123 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56124 +static DEFINE_PER_CPU(u64, exec_counter);
56125 +static int __init init_exec_counters(void)
56126 +{
56127 + unsigned int cpu;
56128 +
56129 + for_each_possible_cpu(cpu) {
56130 + per_cpu(exec_counter, cpu) = (u64)cpu;
56131 + }
56132 +
56133 + return 0;
56134 +}
56135 +early_initcall(init_exec_counters);
56136 +static inline void increment_exec_counter(void)
56137 +{
56138 + BUILD_BUG_ON(NR_CPUS > (1 << 16));
56139 + current->exec_id = this_cpu_add_return(exec_counter, 1 << 16);
56140 +}
56141 +#else
56142 +static inline void increment_exec_counter(void) {}
56143 +#endif
56144 +
56145 +extern void gr_handle_exec_args(struct linux_binprm *bprm,
56146 + struct user_arg_ptr argv);
56147 +
56148 /*
56149 * sys_execve() executes a new program.
56150 */
56151 @@ -1458,12 +1561,19 @@ static int do_execve_common(const char *filename,
56152 struct user_arg_ptr argv,
56153 struct user_arg_ptr envp)
56154 {
56155 +#ifdef CONFIG_GRKERNSEC
56156 + struct file *old_exec_file;
56157 + struct acl_subject_label *old_acl;
56158 + struct rlimit old_rlim[RLIM_NLIMITS];
56159 +#endif
56160 struct linux_binprm *bprm;
56161 struct file *file;
56162 struct files_struct *displaced;
56163 bool clear_in_exec;
56164 int retval;
56165
56166 + gr_learn_resource(current, RLIMIT_NPROC, atomic_read(&current_user()->processes), 1);
56167 +
56168 /*
56169 * We move the actual failure in case of RLIMIT_NPROC excess from
56170 * set*uid() to execve() because too many poorly written programs
56171 @@ -1504,12 +1614,22 @@ static int do_execve_common(const char *filename,
56172 if (IS_ERR(file))
56173 goto out_unmark;
56174
56175 + if (gr_ptrace_readexec(file, bprm->unsafe)) {
56176 + retval = -EPERM;
56177 + goto out_file;
56178 + }
56179 +
56180 sched_exec();
56181
56182 bprm->file = file;
56183 bprm->filename = filename;
56184 bprm->interp = filename;
56185
56186 + if (!gr_acl_handle_execve(file->f_path.dentry, file->f_path.mnt)) {
56187 + retval = -EACCES;
56188 + goto out_file;
56189 + }
56190 +
56191 retval = bprm_mm_init(bprm);
56192 if (retval)
56193 goto out_file;
56194 @@ -1526,24 +1646,70 @@ static int do_execve_common(const char *filename,
56195 if (retval < 0)
56196 goto out;
56197
56198 +#ifdef CONFIG_GRKERNSEC
56199 + old_acl = current->acl;
56200 + memcpy(old_rlim, current->signal->rlim, sizeof(old_rlim));
56201 + old_exec_file = current->exec_file;
56202 + get_file(file);
56203 + current->exec_file = file;
56204 +#endif
56205 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
56206 + /* limit suid stack to 8MB
56207 + * we saved the old limits above and will restore them if this exec fails
56208 + */
56209 + if (((!uid_eq(bprm->cred->euid, current_euid())) || (!gid_eq(bprm->cred->egid, current_egid()))) &&
56210 + (old_rlim[RLIMIT_STACK].rlim_cur > (8 * 1024 * 1024)))
56211 + current->signal->rlim[RLIMIT_STACK].rlim_cur = 8 * 1024 * 1024;
56212 +#endif
56213 +
56214 + if (gr_process_kernel_exec_ban() || gr_process_suid_exec_ban(bprm)) {
56215 + retval = -EPERM;
56216 + goto out_fail;
56217 + }
56218 +
56219 + if (!gr_tpe_allow(file)) {
56220 + retval = -EACCES;
56221 + goto out_fail;
56222 + }
56223 +
56224 + if (gr_check_crash_exec(file)) {
56225 + retval = -EACCES;
56226 + goto out_fail;
56227 + }
56228 +
56229 + retval = gr_set_proc_label(file->f_path.dentry, file->f_path.mnt,
56230 + bprm->unsafe);
56231 + if (retval < 0)
56232 + goto out_fail;
56233 +
56234 retval = copy_strings_kernel(1, &bprm->filename, bprm);
56235 if (retval < 0)
56236 - goto out;
56237 + goto out_fail;
56238
56239 bprm->exec = bprm->p;
56240 retval = copy_strings(bprm->envc, envp, bprm);
56241 if (retval < 0)
56242 - goto out;
56243 + goto out_fail;
56244
56245 retval = copy_strings(bprm->argc, argv, bprm);
56246 if (retval < 0)
56247 - goto out;
56248 + goto out_fail;
56249 +
56250 + gr_log_chroot_exec(file->f_path.dentry, file->f_path.mnt);
56251 +
56252 + gr_handle_exec_args(bprm, argv);
56253
56254 retval = exec_binprm(bprm);
56255 if (retval < 0)
56256 - goto out;
56257 + goto out_fail;
56258 +#ifdef CONFIG_GRKERNSEC
56259 + if (old_exec_file)
56260 + fput(old_exec_file);
56261 +#endif
56262
56263 /* execve succeeded */
56264 +
56265 + increment_exec_counter();
56266 current->fs->in_exec = 0;
56267 current->in_execve = 0;
56268 acct_update_integrals(current);
56269 @@ -1552,6 +1718,14 @@ static int do_execve_common(const char *filename,
56270 put_files_struct(displaced);
56271 return retval;
56272
56273 +out_fail:
56274 +#ifdef CONFIG_GRKERNSEC
56275 + current->acl = old_acl;
56276 + memcpy(current->signal->rlim, old_rlim, sizeof(old_rlim));
56277 + fput(current->exec_file);
56278 + current->exec_file = old_exec_file;
56279 +#endif
56280 +
56281 out:
56282 if (bprm->mm) {
56283 acct_arg_size(bprm, 0);
56284 @@ -1706,3 +1880,295 @@ asmlinkage long compat_sys_execve(const char __user * filename,
56285 return error;
56286 }
56287 #endif
56288 +
56289 +int pax_check_flags(unsigned long *flags)
56290 +{
56291 + int retval = 0;
56292 +
56293 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_SEGMEXEC)
56294 + if (*flags & MF_PAX_SEGMEXEC)
56295 + {
56296 + *flags &= ~MF_PAX_SEGMEXEC;
56297 + retval = -EINVAL;
56298 + }
56299 +#endif
56300 +
56301 + if ((*flags & MF_PAX_PAGEEXEC)
56302 +
56303 +#ifdef CONFIG_PAX_PAGEEXEC
56304 + && (*flags & MF_PAX_SEGMEXEC)
56305 +#endif
56306 +
56307 + )
56308 + {
56309 + *flags &= ~MF_PAX_PAGEEXEC;
56310 + retval = -EINVAL;
56311 + }
56312 +
56313 + if ((*flags & MF_PAX_MPROTECT)
56314 +
56315 +#ifdef CONFIG_PAX_MPROTECT
56316 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56317 +#endif
56318 +
56319 + )
56320 + {
56321 + *flags &= ~MF_PAX_MPROTECT;
56322 + retval = -EINVAL;
56323 + }
56324 +
56325 + if ((*flags & MF_PAX_EMUTRAMP)
56326 +
56327 +#ifdef CONFIG_PAX_EMUTRAMP
56328 + && !(*flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC))
56329 +#endif
56330 +
56331 + )
56332 + {
56333 + *flags &= ~MF_PAX_EMUTRAMP;
56334 + retval = -EINVAL;
56335 + }
56336 +
56337 + return retval;
56338 +}
56339 +
56340 +EXPORT_SYMBOL(pax_check_flags);
56341 +
56342 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
56343 +char *pax_get_path(const struct path *path, char *buf, int buflen)
56344 +{
56345 + char *pathname = d_path(path, buf, buflen);
56346 +
56347 + if (IS_ERR(pathname))
56348 + goto toolong;
56349 +
56350 + pathname = mangle_path(buf, pathname, "\t\n\\");
56351 + if (!pathname)
56352 + goto toolong;
56353 +
56354 + *pathname = 0;
56355 + return buf;
56356 +
56357 +toolong:
56358 + return "<path too long>";
56359 +}
56360 +EXPORT_SYMBOL(pax_get_path);
56361 +
56362 +void pax_report_fault(struct pt_regs *regs, void *pc, void *sp)
56363 +{
56364 + struct task_struct *tsk = current;
56365 + struct mm_struct *mm = current->mm;
56366 + char *buffer_exec = (char *)__get_free_page(GFP_KERNEL);
56367 + char *buffer_fault = (char *)__get_free_page(GFP_KERNEL);
56368 + char *path_exec = NULL;
56369 + char *path_fault = NULL;
56370 + unsigned long start = 0UL, end = 0UL, offset = 0UL;
56371 + siginfo_t info = { };
56372 +
56373 + if (buffer_exec && buffer_fault) {
56374 + struct vm_area_struct *vma, *vma_exec = NULL, *vma_fault = NULL;
56375 +
56376 + down_read(&mm->mmap_sem);
56377 + vma = mm->mmap;
56378 + while (vma && (!vma_exec || !vma_fault)) {
56379 + if (vma->vm_file && mm->exe_file == vma->vm_file && (vma->vm_flags & VM_EXEC))
56380 + vma_exec = vma;
56381 + if (vma->vm_start <= (unsigned long)pc && (unsigned long)pc < vma->vm_end)
56382 + vma_fault = vma;
56383 + vma = vma->vm_next;
56384 + }
56385 + if (vma_exec)
56386 + path_exec = pax_get_path(&vma_exec->vm_file->f_path, buffer_exec, PAGE_SIZE);
56387 + if (vma_fault) {
56388 + start = vma_fault->vm_start;
56389 + end = vma_fault->vm_end;
56390 + offset = vma_fault->vm_pgoff << PAGE_SHIFT;
56391 + if (vma_fault->vm_file)
56392 + path_fault = pax_get_path(&vma_fault->vm_file->f_path, buffer_fault, PAGE_SIZE);
56393 + else if ((unsigned long)pc >= mm->start_brk && (unsigned long)pc < mm->brk)
56394 + path_fault = "<heap>";
56395 + else if (vma_fault->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
56396 + path_fault = "<stack>";
56397 + else
56398 + path_fault = "<anonymous mapping>";
56399 + }
56400 + up_read(&mm->mmap_sem);
56401 + }
56402 + if (tsk->signal->curr_ip)
56403 + printk(KERN_ERR "PAX: From %pI4: execution attempt in: %s, %08lx-%08lx %08lx\n", &tsk->signal->curr_ip, path_fault, start, end, offset);
56404 + else
56405 + printk(KERN_ERR "PAX: execution attempt in: %s, %08lx-%08lx %08lx\n", path_fault, start, end, offset);
56406 + 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),
56407 + from_kuid_munged(&init_user_ns, task_uid(tsk)), from_kuid_munged(&init_user_ns, task_euid(tsk)), pc, sp);
56408 + free_page((unsigned long)buffer_exec);
56409 + free_page((unsigned long)buffer_fault);
56410 + pax_report_insns(regs, pc, sp);
56411 + info.si_signo = SIGKILL;
56412 + info.si_errno = 0;
56413 + info.si_code = SI_KERNEL;
56414 + info.si_pid = 0;
56415 + info.si_uid = 0;
56416 + do_coredump(&info);
56417 +}
56418 +#endif
56419 +
56420 +#ifdef CONFIG_PAX_REFCOUNT
56421 +void pax_report_refcount_overflow(struct pt_regs *regs)
56422 +{
56423 + if (current->signal->curr_ip)
56424 + printk(KERN_ERR "PAX: From %pI4: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n",
56425 + &current->signal->curr_ip, current->comm, task_pid_nr(current),
56426 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56427 + else
56428 + printk(KERN_ERR "PAX: refcount overflow detected in: %s:%d, uid/euid: %u/%u\n", current->comm, task_pid_nr(current),
56429 + from_kuid_munged(&init_user_ns, current_uid()), from_kuid_munged(&init_user_ns, current_euid()));
56430 + print_symbol(KERN_ERR "PAX: refcount overflow occured at: %s\n", instruction_pointer(regs));
56431 + preempt_disable();
56432 + show_regs(regs);
56433 + preempt_enable();
56434 + force_sig_info(SIGKILL, SEND_SIG_FORCED, current);
56435 +}
56436 +#endif
56437 +
56438 +#ifdef CONFIG_PAX_USERCOPY
56439 +/* 0: not at all, 1: fully, 2: fully inside frame, -1: partially (implies an error) */
56440 +static noinline int check_stack_object(const void *obj, unsigned long len)
56441 +{
56442 + const void * const stack = task_stack_page(current);
56443 + const void * const stackend = stack + THREAD_SIZE;
56444 +
56445 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56446 + const void *frame = NULL;
56447 + const void *oldframe;
56448 +#endif
56449 +
56450 + if (obj + len < obj)
56451 + return -1;
56452 +
56453 + if (obj + len <= stack || stackend <= obj)
56454 + return 0;
56455 +
56456 + if (obj < stack || stackend < obj + len)
56457 + return -1;
56458 +
56459 +#if defined(CONFIG_FRAME_POINTER) && defined(CONFIG_X86)
56460 + oldframe = __builtin_frame_address(1);
56461 + if (oldframe)
56462 + frame = __builtin_frame_address(2);
56463 + /*
56464 + low ----------------------------------------------> high
56465 + [saved bp][saved ip][args][local vars][saved bp][saved ip]
56466 + ^----------------^
56467 + allow copies only within here
56468 + */
56469 + while (stack <= frame && frame < stackend) {
56470 + /* if obj + len extends past the last frame, this
56471 + check won't pass and the next frame will be 0,
56472 + causing us to bail out and correctly report
56473 + the copy as invalid
56474 + */
56475 + if (obj + len <= frame)
56476 + return obj >= oldframe + 2 * sizeof(void *) ? 2 : -1;
56477 + oldframe = frame;
56478 + frame = *(const void * const *)frame;
56479 + }
56480 + return -1;
56481 +#else
56482 + return 1;
56483 +#endif
56484 +}
56485 +
56486 +static __noreturn void pax_report_usercopy(const void *ptr, unsigned long len, bool to_user, const char *type)
56487 +{
56488 + if (current->signal->curr_ip)
56489 + printk(KERN_ERR "PAX: From %pI4: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56490 + &current->signal->curr_ip, to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56491 + else
56492 + printk(KERN_ERR "PAX: kernel memory %s attempt detected %s %p (%s) (%lu bytes)\n",
56493 + to_user ? "leak" : "overwrite", to_user ? "from" : "to", ptr, type ? : "unknown", len);
56494 + dump_stack();
56495 + gr_handle_kernel_exploit();
56496 + do_group_exit(SIGKILL);
56497 +}
56498 +#endif
56499 +
56500 +#ifdef CONFIG_PAX_USERCOPY
56501 +static inline bool check_kernel_text_object(unsigned long low, unsigned long high)
56502 +{
56503 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
56504 + unsigned long textlow = ktla_ktva((unsigned long)_stext);
56505 +#ifdef CONFIG_MODULES
56506 + unsigned long texthigh = (unsigned long)MODULES_EXEC_VADDR;
56507 +#else
56508 + unsigned long texthigh = ktla_ktva((unsigned long)_etext);
56509 +#endif
56510 +
56511 +#else
56512 + unsigned long textlow = (unsigned long)_stext;
56513 + unsigned long texthigh = (unsigned long)_etext;
56514 +
56515 +#ifdef CONFIG_X86_64
56516 + /* check against linear mapping as well */
56517 + if (high > (unsigned long)__va(__pa(textlow)) &&
56518 + low <= (unsigned long)__va(__pa(texthigh)))
56519 + return true;
56520 +#endif
56521 +
56522 +#endif
56523 +
56524 + if (high <= textlow || low > texthigh)
56525 + return false;
56526 + else
56527 + return true;
56528 +}
56529 +#endif
56530 +
56531 +void __check_object_size(const void *ptr, unsigned long n, bool to_user)
56532 +{
56533 +
56534 +#ifdef CONFIG_PAX_USERCOPY
56535 + const char *type;
56536 +
56537 + if (!n)
56538 + return;
56539 +
56540 + type = check_heap_object(ptr, n);
56541 + if (!type) {
56542 + int ret = check_stack_object(ptr, n);
56543 + if (ret == 1 || ret == 2)
56544 + return;
56545 + if (ret == 0) {
56546 + if (check_kernel_text_object((unsigned long)ptr, (unsigned long)ptr + n))
56547 + type = "<kernel text>";
56548 + else
56549 + return;
56550 + } else
56551 + type = "<process stack>";
56552 + }
56553 +
56554 + pax_report_usercopy(ptr, n, to_user, type);
56555 +#endif
56556 +
56557 +}
56558 +EXPORT_SYMBOL(__check_object_size);
56559 +
56560 +#ifdef CONFIG_PAX_MEMORY_STACKLEAK
56561 +void pax_track_stack(void)
56562 +{
56563 + unsigned long sp = (unsigned long)&sp;
56564 + if (sp < current_thread_info()->lowest_stack &&
56565 + sp > (unsigned long)task_stack_page(current))
56566 + current_thread_info()->lowest_stack = sp;
56567 +}
56568 +EXPORT_SYMBOL(pax_track_stack);
56569 +#endif
56570 +
56571 +#ifdef CONFIG_PAX_SIZE_OVERFLOW
56572 +void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
56573 +{
56574 + printk(KERN_ERR "PAX: size overflow detected in function %s %s:%u %s", func, file, line, ssa_name);
56575 + dump_stack();
56576 + do_group_exit(SIGKILL);
56577 +}
56578 +EXPORT_SYMBOL(report_size_overflow);
56579 +#endif
56580 diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c
56581 index 9f9992b..8b59411 100644
56582 --- a/fs/ext2/balloc.c
56583 +++ b/fs/ext2/balloc.c
56584 @@ -1184,10 +1184,10 @@ static int ext2_has_free_blocks(struct ext2_sb_info *sbi)
56585
56586 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56587 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56588 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56589 + if (free_blocks < root_blocks + 1 &&
56590 !uid_eq(sbi->s_resuid, current_fsuid()) &&
56591 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56592 - !in_group_p (sbi->s_resgid))) {
56593 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56594 return 0;
56595 }
56596 return 1;
56597 diff --git a/fs/ext2/xattr.c b/fs/ext2/xattr.c
56598 index 2d7557d..14e38f94 100644
56599 --- a/fs/ext2/xattr.c
56600 +++ b/fs/ext2/xattr.c
56601 @@ -247,7 +247,7 @@ ext2_xattr_list(struct dentry *dentry, char *buffer, size_t buffer_size)
56602 struct buffer_head *bh = NULL;
56603 struct ext2_xattr_entry *entry;
56604 char *end;
56605 - size_t rest = buffer_size;
56606 + size_t rest = buffer_size, total_size = 0;
56607 int error;
56608
56609 ea_idebug(inode, "buffer=%p, buffer_size=%ld",
56610 @@ -305,9 +305,10 @@ bad_block: ext2_error(inode->i_sb, "ext2_xattr_list",
56611 buffer += size;
56612 }
56613 rest -= size;
56614 + total_size += size;
56615 }
56616 }
56617 - error = buffer_size - rest; /* total size */
56618 + error = total_size;
56619
56620 cleanup:
56621 brelse(bh);
56622 diff --git a/fs/ext3/balloc.c b/fs/ext3/balloc.c
56623 index 22548f5..41521d8 100644
56624 --- a/fs/ext3/balloc.c
56625 +++ b/fs/ext3/balloc.c
56626 @@ -1438,10 +1438,10 @@ static int ext3_has_free_blocks(struct ext3_sb_info *sbi, int use_reservation)
56627
56628 free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
56629 root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
56630 - if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
56631 + if (free_blocks < root_blocks + 1 &&
56632 !use_reservation && !uid_eq(sbi->s_resuid, current_fsuid()) &&
56633 (gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
56634 - !in_group_p (sbi->s_resgid))) {
56635 + !in_group_p (sbi->s_resgid)) && !capable_nolog(CAP_SYS_RESOURCE)) {
56636 return 0;
56637 }
56638 return 1;
56639 diff --git a/fs/ext3/xattr.c b/fs/ext3/xattr.c
56640 index b1fc963..881228c 100644
56641 --- a/fs/ext3/xattr.c
56642 +++ b/fs/ext3/xattr.c
56643 @@ -330,7 +330,7 @@ static int
56644 ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
56645 char *buffer, size_t buffer_size)
56646 {
56647 - size_t rest = buffer_size;
56648 + size_t rest = buffer_size, total_size = 0;
56649
56650 for (; !IS_LAST_ENTRY(entry); entry = EXT3_XATTR_NEXT(entry)) {
56651 const struct xattr_handler *handler =
56652 @@ -347,9 +347,10 @@ ext3_xattr_list_entries(struct dentry *dentry, struct ext3_xattr_entry *entry,
56653 buffer += size;
56654 }
56655 rest -= size;
56656 + total_size += size;
56657 }
56658 }
56659 - return buffer_size - rest;
56660 + return total_size;
56661 }
56662
56663 static int
56664 diff --git a/fs/ext4/balloc.c b/fs/ext4/balloc.c
56665 index dc5d572..4c21f8e 100644
56666 --- a/fs/ext4/balloc.c
56667 +++ b/fs/ext4/balloc.c
56668 @@ -534,8 +534,8 @@ static int ext4_has_free_clusters(struct ext4_sb_info *sbi,
56669 /* Hm, nope. Are (enough) root reserved clusters available? */
56670 if (uid_eq(sbi->s_resuid, current_fsuid()) ||
56671 (!gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) && in_group_p(sbi->s_resgid)) ||
56672 - capable(CAP_SYS_RESOURCE) ||
56673 - (flags & EXT4_MB_USE_ROOT_BLOCKS)) {
56674 + (flags & EXT4_MB_USE_ROOT_BLOCKS) ||
56675 + capable_nolog(CAP_SYS_RESOURCE)) {
56676
56677 if (free_clusters >= (nclusters + dirty_clusters +
56678 resv_clusters))
56679 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
56680 index 745faaa..a072816 100644
56681 --- a/fs/ext4/ext4.h
56682 +++ b/fs/ext4/ext4.h
56683 @@ -1266,19 +1266,19 @@ struct ext4_sb_info {
56684 unsigned long s_mb_last_start;
56685
56686 /* stats for buddy allocator */
56687 - atomic_t s_bal_reqs; /* number of reqs with len > 1 */
56688 - atomic_t s_bal_success; /* we found long enough chunks */
56689 - atomic_t s_bal_allocated; /* in blocks */
56690 - atomic_t s_bal_ex_scanned; /* total extents scanned */
56691 - atomic_t s_bal_goals; /* goal hits */
56692 - atomic_t s_bal_breaks; /* too long searches */
56693 - atomic_t s_bal_2orders; /* 2^order hits */
56694 + atomic_unchecked_t s_bal_reqs; /* number of reqs with len > 1 */
56695 + atomic_unchecked_t s_bal_success; /* we found long enough chunks */
56696 + atomic_unchecked_t s_bal_allocated; /* in blocks */
56697 + atomic_unchecked_t s_bal_ex_scanned; /* total extents scanned */
56698 + atomic_unchecked_t s_bal_goals; /* goal hits */
56699 + atomic_unchecked_t s_bal_breaks; /* too long searches */
56700 + atomic_unchecked_t s_bal_2orders; /* 2^order hits */
56701 spinlock_t s_bal_lock;
56702 unsigned long s_mb_buddies_generated;
56703 unsigned long long s_mb_generation_time;
56704 - atomic_t s_mb_lost_chunks;
56705 - atomic_t s_mb_preallocated;
56706 - atomic_t s_mb_discarded;
56707 + atomic_unchecked_t s_mb_lost_chunks;
56708 + atomic_unchecked_t s_mb_preallocated;
56709 + atomic_unchecked_t s_mb_discarded;
56710 atomic_t s_lock_busy;
56711
56712 /* locality groups */
56713 diff --git a/fs/ext4/mballoc.c b/fs/ext4/mballoc.c
56714 index 04a5c75..09894fa 100644
56715 --- a/fs/ext4/mballoc.c
56716 +++ b/fs/ext4/mballoc.c
56717 @@ -1880,7 +1880,7 @@ void ext4_mb_simple_scan_group(struct ext4_allocation_context *ac,
56718 BUG_ON(ac->ac_b_ex.fe_len != ac->ac_g_ex.fe_len);
56719
56720 if (EXT4_SB(sb)->s_mb_stats)
56721 - atomic_inc(&EXT4_SB(sb)->s_bal_2orders);
56722 + atomic_inc_unchecked(&EXT4_SB(sb)->s_bal_2orders);
56723
56724 break;
56725 }
56726 @@ -2189,7 +2189,7 @@ repeat:
56727 ac->ac_status = AC_STATUS_CONTINUE;
56728 ac->ac_flags |= EXT4_MB_HINT_FIRST;
56729 cr = 3;
56730 - atomic_inc(&sbi->s_mb_lost_chunks);
56731 + atomic_inc_unchecked(&sbi->s_mb_lost_chunks);
56732 goto repeat;
56733 }
56734 }
56735 @@ -2697,25 +2697,25 @@ int ext4_mb_release(struct super_block *sb)
56736 if (sbi->s_mb_stats) {
56737 ext4_msg(sb, KERN_INFO,
56738 "mballoc: %u blocks %u reqs (%u success)",
56739 - atomic_read(&sbi->s_bal_allocated),
56740 - atomic_read(&sbi->s_bal_reqs),
56741 - atomic_read(&sbi->s_bal_success));
56742 + atomic_read_unchecked(&sbi->s_bal_allocated),
56743 + atomic_read_unchecked(&sbi->s_bal_reqs),
56744 + atomic_read_unchecked(&sbi->s_bal_success));
56745 ext4_msg(sb, KERN_INFO,
56746 "mballoc: %u extents scanned, %u goal hits, "
56747 "%u 2^N hits, %u breaks, %u lost",
56748 - atomic_read(&sbi->s_bal_ex_scanned),
56749 - atomic_read(&sbi->s_bal_goals),
56750 - atomic_read(&sbi->s_bal_2orders),
56751 - atomic_read(&sbi->s_bal_breaks),
56752 - atomic_read(&sbi->s_mb_lost_chunks));
56753 + atomic_read_unchecked(&sbi->s_bal_ex_scanned),
56754 + atomic_read_unchecked(&sbi->s_bal_goals),
56755 + atomic_read_unchecked(&sbi->s_bal_2orders),
56756 + atomic_read_unchecked(&sbi->s_bal_breaks),
56757 + atomic_read_unchecked(&sbi->s_mb_lost_chunks));
56758 ext4_msg(sb, KERN_INFO,
56759 "mballoc: %lu generated and it took %Lu",
56760 sbi->s_mb_buddies_generated,
56761 sbi->s_mb_generation_time);
56762 ext4_msg(sb, KERN_INFO,
56763 "mballoc: %u preallocated, %u discarded",
56764 - atomic_read(&sbi->s_mb_preallocated),
56765 - atomic_read(&sbi->s_mb_discarded));
56766 + atomic_read_unchecked(&sbi->s_mb_preallocated),
56767 + atomic_read_unchecked(&sbi->s_mb_discarded));
56768 }
56769
56770 free_percpu(sbi->s_locality_groups);
56771 @@ -3169,16 +3169,16 @@ static void ext4_mb_collect_stats(struct ext4_allocation_context *ac)
56772 struct ext4_sb_info *sbi = EXT4_SB(ac->ac_sb);
56773
56774 if (sbi->s_mb_stats && ac->ac_g_ex.fe_len > 1) {
56775 - atomic_inc(&sbi->s_bal_reqs);
56776 - atomic_add(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56777 + atomic_inc_unchecked(&sbi->s_bal_reqs);
56778 + atomic_add_unchecked(ac->ac_b_ex.fe_len, &sbi->s_bal_allocated);
56779 if (ac->ac_b_ex.fe_len >= ac->ac_o_ex.fe_len)
56780 - atomic_inc(&sbi->s_bal_success);
56781 - atomic_add(ac->ac_found, &sbi->s_bal_ex_scanned);
56782 + atomic_inc_unchecked(&sbi->s_bal_success);
56783 + atomic_add_unchecked(ac->ac_found, &sbi->s_bal_ex_scanned);
56784 if (ac->ac_g_ex.fe_start == ac->ac_b_ex.fe_start &&
56785 ac->ac_g_ex.fe_group == ac->ac_b_ex.fe_group)
56786 - atomic_inc(&sbi->s_bal_goals);
56787 + atomic_inc_unchecked(&sbi->s_bal_goals);
56788 if (ac->ac_found > sbi->s_mb_max_to_scan)
56789 - atomic_inc(&sbi->s_bal_breaks);
56790 + atomic_inc_unchecked(&sbi->s_bal_breaks);
56791 }
56792
56793 if (ac->ac_op == EXT4_MB_HISTORY_ALLOC)
56794 @@ -3583,7 +3583,7 @@ ext4_mb_new_inode_pa(struct ext4_allocation_context *ac)
56795 trace_ext4_mb_new_inode_pa(ac, pa);
56796
56797 ext4_mb_use_inode_pa(ac, pa);
56798 - atomic_add(pa->pa_free, &sbi->s_mb_preallocated);
56799 + atomic_add_unchecked(pa->pa_free, &sbi->s_mb_preallocated);
56800
56801 ei = EXT4_I(ac->ac_inode);
56802 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56803 @@ -3643,7 +3643,7 @@ ext4_mb_new_group_pa(struct ext4_allocation_context *ac)
56804 trace_ext4_mb_new_group_pa(ac, pa);
56805
56806 ext4_mb_use_group_pa(ac, pa);
56807 - atomic_add(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56808 + atomic_add_unchecked(pa->pa_free, &EXT4_SB(sb)->s_mb_preallocated);
56809
56810 grp = ext4_get_group_info(sb, ac->ac_b_ex.fe_group);
56811 lg = ac->ac_lg;
56812 @@ -3732,7 +3732,7 @@ ext4_mb_release_inode_pa(struct ext4_buddy *e4b, struct buffer_head *bitmap_bh,
56813 * from the bitmap and continue.
56814 */
56815 }
56816 - atomic_add(free, &sbi->s_mb_discarded);
56817 + atomic_add_unchecked(free, &sbi->s_mb_discarded);
56818
56819 return err;
56820 }
56821 @@ -3750,7 +3750,7 @@ ext4_mb_release_group_pa(struct ext4_buddy *e4b,
56822 ext4_get_group_no_and_offset(sb, pa->pa_pstart, &group, &bit);
56823 BUG_ON(group != e4b->bd_group && pa->pa_len != 0);
56824 mb_free_blocks(pa->pa_inode, e4b, bit, pa->pa_len);
56825 - atomic_add(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56826 + atomic_add_unchecked(pa->pa_len, &EXT4_SB(sb)->s_mb_discarded);
56827 trace_ext4_mballoc_discard(sb, NULL, group, bit, pa->pa_len);
56828
56829 return 0;
56830 diff --git a/fs/ext4/mmp.c b/fs/ext4/mmp.c
56831 index 214461e..3614c89 100644
56832 --- a/fs/ext4/mmp.c
56833 +++ b/fs/ext4/mmp.c
56834 @@ -113,7 +113,7 @@ static int read_mmp_block(struct super_block *sb, struct buffer_head **bh,
56835 void __dump_mmp_msg(struct super_block *sb, struct mmp_struct *mmp,
56836 const char *function, unsigned int line, const char *msg)
56837 {
56838 - __ext4_warning(sb, function, line, msg);
56839 + __ext4_warning(sb, function, line, "%s", msg);
56840 __ext4_warning(sb, function, line,
56841 "MMP failure info: last update time: %llu, last update "
56842 "node: %s, last update device: %s\n",
56843 diff --git a/fs/ext4/super.c b/fs/ext4/super.c
56844 index b947e0a..c102e3b 100644
56845 --- a/fs/ext4/super.c
56846 +++ b/fs/ext4/super.c
56847 @@ -1251,7 +1251,7 @@ static ext4_fsblk_t get_sb_block(void **data)
56848 }
56849
56850 #define DEFAULT_JOURNAL_IOPRIO (IOPRIO_PRIO_VALUE(IOPRIO_CLASS_BE, 3))
56851 -static char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56852 +static const char deprecated_msg[] = "Mount option \"%s\" will be removed by %s\n"
56853 "Contact linux-ext4@vger.kernel.org if you think we should keep it.\n";
56854
56855 #ifdef CONFIG_QUOTA
56856 @@ -2431,7 +2431,7 @@ struct ext4_attr {
56857 int offset;
56858 int deprecated_val;
56859 } u;
56860 -};
56861 +} __do_const;
56862
56863 static int parse_strtoull(const char *buf,
56864 unsigned long long max, unsigned long long *value)
56865 diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
56866 index 1423c48..9c0c6dc 100644
56867 --- a/fs/ext4/xattr.c
56868 +++ b/fs/ext4/xattr.c
56869 @@ -381,7 +381,7 @@ static int
56870 ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56871 char *buffer, size_t buffer_size)
56872 {
56873 - size_t rest = buffer_size;
56874 + size_t rest = buffer_size, total_size = 0;
56875
56876 for (; !IS_LAST_ENTRY(entry); entry = EXT4_XATTR_NEXT(entry)) {
56877 const struct xattr_handler *handler =
56878 @@ -398,9 +398,10 @@ ext4_xattr_list_entries(struct dentry *dentry, struct ext4_xattr_entry *entry,
56879 buffer += size;
56880 }
56881 rest -= size;
56882 + total_size += size;
56883 }
56884 }
56885 - return buffer_size - rest;
56886 + return total_size;
56887 }
56888
56889 static int
56890 diff --git a/fs/fcntl.c b/fs/fcntl.c
56891 index 65343c3..9969dcf 100644
56892 --- a/fs/fcntl.c
56893 +++ b/fs/fcntl.c
56894 @@ -107,6 +107,11 @@ int __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
56895 if (err)
56896 return err;
56897
56898 + if (gr_handle_chroot_fowner(pid, type))
56899 + return -ENOENT;
56900 + if (gr_check_protected_task_fowner(pid, type))
56901 + return -EACCES;
56902 +
56903 f_modown(filp, pid, type, force);
56904 return 0;
56905 }
56906 diff --git a/fs/fhandle.c b/fs/fhandle.c
56907 index 999ff5c..41f4109 100644
56908 --- a/fs/fhandle.c
56909 +++ b/fs/fhandle.c
56910 @@ -67,8 +67,7 @@ static long do_sys_name_to_handle(struct path *path,
56911 } else
56912 retval = 0;
56913 /* copy the mount id */
56914 - if (copy_to_user(mnt_id, &real_mount(path->mnt)->mnt_id,
56915 - sizeof(*mnt_id)) ||
56916 + if (put_user(real_mount(path->mnt)->mnt_id, mnt_id) ||
56917 copy_to_user(ufh, handle,
56918 sizeof(struct file_handle) + handle_bytes))
56919 retval = -EFAULT;
56920 diff --git a/fs/file.c b/fs/file.c
56921 index 4a78f98..f9a6d25 100644
56922 --- a/fs/file.c
56923 +++ b/fs/file.c
56924 @@ -16,6 +16,7 @@
56925 #include <linux/slab.h>
56926 #include <linux/vmalloc.h>
56927 #include <linux/file.h>
56928 +#include <linux/security.h>
56929 #include <linux/fdtable.h>
56930 #include <linux/bitops.h>
56931 #include <linux/interrupt.h>
56932 @@ -141,7 +142,7 @@ out:
56933 * Return <0 error code on error; 1 on successful completion.
56934 * The files->file_lock should be held on entry, and will be held on exit.
56935 */
56936 -static int expand_fdtable(struct files_struct *files, int nr)
56937 +static int expand_fdtable(struct files_struct *files, unsigned int nr)
56938 __releases(files->file_lock)
56939 __acquires(files->file_lock)
56940 {
56941 @@ -186,7 +187,7 @@ static int expand_fdtable(struct files_struct *files, int nr)
56942 * expanded and execution may have blocked.
56943 * The files->file_lock should be held on entry, and will be held on exit.
56944 */
56945 -static int expand_files(struct files_struct *files, int nr)
56946 +static int expand_files(struct files_struct *files, unsigned int nr)
56947 {
56948 struct fdtable *fdt;
56949
56950 @@ -828,6 +829,7 @@ int replace_fd(unsigned fd, struct file *file, unsigned flags)
56951 if (!file)
56952 return __close_fd(files, fd);
56953
56954 + gr_learn_resource(current, RLIMIT_NOFILE, fd, 0);
56955 if (fd >= rlimit(RLIMIT_NOFILE))
56956 return -EBADF;
56957
56958 @@ -854,6 +856,7 @@ SYSCALL_DEFINE3(dup3, unsigned int, oldfd, unsigned int, newfd, int, flags)
56959 if (unlikely(oldfd == newfd))
56960 return -EINVAL;
56961
56962 + gr_learn_resource(current, RLIMIT_NOFILE, newfd, 0);
56963 if (newfd >= rlimit(RLIMIT_NOFILE))
56964 return -EBADF;
56965
56966 @@ -909,6 +912,7 @@ SYSCALL_DEFINE1(dup, unsigned int, fildes)
56967 int f_dupfd(unsigned int from, struct file *file, unsigned flags)
56968 {
56969 int err;
56970 + gr_learn_resource(current, RLIMIT_NOFILE, from, 0);
56971 if (from >= rlimit(RLIMIT_NOFILE))
56972 return -EINVAL;
56973 err = alloc_fd(from, flags);
56974 diff --git a/fs/filesystems.c b/fs/filesystems.c
56975 index 92567d9..fcd8cbf 100644
56976 --- a/fs/filesystems.c
56977 +++ b/fs/filesystems.c
56978 @@ -273,7 +273,11 @@ struct file_system_type *get_fs_type(const char *name)
56979 int len = dot ? dot - name : strlen(name);
56980
56981 fs = __get_fs_type(name, len);
56982 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
56983 + if (!fs && (___request_module(true, "grsec_modharden_fs", "fs-%.*s", len, name) == 0))
56984 +#else
56985 if (!fs && (request_module("fs-%.*s", len, name) == 0))
56986 +#endif
56987 fs = __get_fs_type(name, len);
56988
56989 if (dot && fs && !(fs->fs_flags & FS_HAS_SUBTYPE)) {
56990 diff --git a/fs/fs_struct.c b/fs/fs_struct.c
56991 index d8ac61d..79a36f0 100644
56992 --- a/fs/fs_struct.c
56993 +++ b/fs/fs_struct.c
56994 @@ -4,6 +4,7 @@
56995 #include <linux/path.h>
56996 #include <linux/slab.h>
56997 #include <linux/fs_struct.h>
56998 +#include <linux/grsecurity.h>
56999 #include "internal.h"
57000
57001 /*
57002 @@ -19,6 +20,7 @@ void set_fs_root(struct fs_struct *fs, const struct path *path)
57003 write_seqcount_begin(&fs->seq);
57004 old_root = fs->root;
57005 fs->root = *path;
57006 + gr_set_chroot_entries(current, path);
57007 write_seqcount_end(&fs->seq);
57008 spin_unlock(&fs->lock);
57009 if (old_root.dentry)
57010 @@ -67,6 +69,10 @@ void chroot_fs_refs(const struct path *old_root, const struct path *new_root)
57011 int hits = 0;
57012 spin_lock(&fs->lock);
57013 write_seqcount_begin(&fs->seq);
57014 + /* this root replacement is only done by pivot_root,
57015 + leave grsec's chroot tagging alone for this task
57016 + so that a pivoted root isn't treated as a chroot
57017 + */
57018 hits += replace_path(&fs->root, old_root, new_root);
57019 hits += replace_path(&fs->pwd, old_root, new_root);
57020 write_seqcount_end(&fs->seq);
57021 @@ -99,7 +105,8 @@ void exit_fs(struct task_struct *tsk)
57022 task_lock(tsk);
57023 spin_lock(&fs->lock);
57024 tsk->fs = NULL;
57025 - kill = !--fs->users;
57026 + gr_clear_chroot_entries(tsk);
57027 + kill = !atomic_dec_return(&fs->users);
57028 spin_unlock(&fs->lock);
57029 task_unlock(tsk);
57030 if (kill)
57031 @@ -112,7 +119,7 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
57032 struct fs_struct *fs = kmem_cache_alloc(fs_cachep, GFP_KERNEL);
57033 /* We don't need to lock fs - think why ;-) */
57034 if (fs) {
57035 - fs->users = 1;
57036 + atomic_set(&fs->users, 1);
57037 fs->in_exec = 0;
57038 spin_lock_init(&fs->lock);
57039 seqcount_init(&fs->seq);
57040 @@ -121,6 +128,9 @@ struct fs_struct *copy_fs_struct(struct fs_struct *old)
57041 spin_lock(&old->lock);
57042 fs->root = old->root;
57043 path_get(&fs->root);
57044 + /* instead of calling gr_set_chroot_entries here,
57045 + we call it from every caller of this function
57046 + */
57047 fs->pwd = old->pwd;
57048 path_get(&fs->pwd);
57049 spin_unlock(&old->lock);
57050 @@ -139,8 +149,9 @@ int unshare_fs_struct(void)
57051
57052 task_lock(current);
57053 spin_lock(&fs->lock);
57054 - kill = !--fs->users;
57055 + kill = !atomic_dec_return(&fs->users);
57056 current->fs = new_fs;
57057 + gr_set_chroot_entries(current, &new_fs->root);
57058 spin_unlock(&fs->lock);
57059 task_unlock(current);
57060
57061 @@ -153,13 +164,13 @@ EXPORT_SYMBOL_GPL(unshare_fs_struct);
57062
57063 int current_umask(void)
57064 {
57065 - return current->fs->umask;
57066 + return current->fs->umask | gr_acl_umask();
57067 }
57068 EXPORT_SYMBOL(current_umask);
57069
57070 /* to be mentioned only in INIT_TASK */
57071 struct fs_struct init_fs = {
57072 - .users = 1,
57073 + .users = ATOMIC_INIT(1),
57074 .lock = __SPIN_LOCK_UNLOCKED(init_fs.lock),
57075 .seq = SEQCNT_ZERO,
57076 .umask = 0022,
57077 diff --git a/fs/fscache/cookie.c b/fs/fscache/cookie.c
57078 index b2a86e3..37f425a 100644
57079 --- a/fs/fscache/cookie.c
57080 +++ b/fs/fscache/cookie.c
57081 @@ -19,7 +19,7 @@
57082
57083 struct kmem_cache *fscache_cookie_jar;
57084
57085 -static atomic_t fscache_object_debug_id = ATOMIC_INIT(0);
57086 +static atomic_unchecked_t fscache_object_debug_id = ATOMIC_INIT(0);
57087
57088 static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie);
57089 static int fscache_alloc_object(struct fscache_cache *cache,
57090 @@ -68,11 +68,11 @@ struct fscache_cookie *__fscache_acquire_cookie(
57091 parent ? (char *) parent->def->name : "<no-parent>",
57092 def->name, netfs_data);
57093
57094 - fscache_stat(&fscache_n_acquires);
57095 + fscache_stat_unchecked(&fscache_n_acquires);
57096
57097 /* if there's no parent cookie, then we don't create one here either */
57098 if (!parent) {
57099 - fscache_stat(&fscache_n_acquires_null);
57100 + fscache_stat_unchecked(&fscache_n_acquires_null);
57101 _leave(" [no parent]");
57102 return NULL;
57103 }
57104 @@ -87,7 +87,7 @@ struct fscache_cookie *__fscache_acquire_cookie(
57105 /* allocate and initialise a cookie */
57106 cookie = kmem_cache_alloc(fscache_cookie_jar, GFP_KERNEL);
57107 if (!cookie) {
57108 - fscache_stat(&fscache_n_acquires_oom);
57109 + fscache_stat_unchecked(&fscache_n_acquires_oom);
57110 _leave(" [ENOMEM]");
57111 return NULL;
57112 }
57113 @@ -114,13 +114,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
57114
57115 switch (cookie->def->type) {
57116 case FSCACHE_COOKIE_TYPE_INDEX:
57117 - fscache_stat(&fscache_n_cookie_index);
57118 + fscache_stat_unchecked(&fscache_n_cookie_index);
57119 break;
57120 case FSCACHE_COOKIE_TYPE_DATAFILE:
57121 - fscache_stat(&fscache_n_cookie_data);
57122 + fscache_stat_unchecked(&fscache_n_cookie_data);
57123 break;
57124 default:
57125 - fscache_stat(&fscache_n_cookie_special);
57126 + fscache_stat_unchecked(&fscache_n_cookie_special);
57127 break;
57128 }
57129
57130 @@ -131,13 +131,13 @@ struct fscache_cookie *__fscache_acquire_cookie(
57131 if (fscache_acquire_non_index_cookie(cookie) < 0) {
57132 atomic_dec(&parent->n_children);
57133 __fscache_cookie_put(cookie);
57134 - fscache_stat(&fscache_n_acquires_nobufs);
57135 + fscache_stat_unchecked(&fscache_n_acquires_nobufs);
57136 _leave(" = NULL");
57137 return NULL;
57138 }
57139 }
57140
57141 - fscache_stat(&fscache_n_acquires_ok);
57142 + fscache_stat_unchecked(&fscache_n_acquires_ok);
57143 _leave(" = %p", cookie);
57144 return cookie;
57145 }
57146 @@ -173,7 +173,7 @@ static int fscache_acquire_non_index_cookie(struct fscache_cookie *cookie)
57147 cache = fscache_select_cache_for_object(cookie->parent);
57148 if (!cache) {
57149 up_read(&fscache_addremove_sem);
57150 - fscache_stat(&fscache_n_acquires_no_cache);
57151 + fscache_stat_unchecked(&fscache_n_acquires_no_cache);
57152 _leave(" = -ENOMEDIUM [no cache]");
57153 return -ENOMEDIUM;
57154 }
57155 @@ -259,14 +259,14 @@ static int fscache_alloc_object(struct fscache_cache *cache,
57156 object = cache->ops->alloc_object(cache, cookie);
57157 fscache_stat_d(&fscache_n_cop_alloc_object);
57158 if (IS_ERR(object)) {
57159 - fscache_stat(&fscache_n_object_no_alloc);
57160 + fscache_stat_unchecked(&fscache_n_object_no_alloc);
57161 ret = PTR_ERR(object);
57162 goto error;
57163 }
57164
57165 - fscache_stat(&fscache_n_object_alloc);
57166 + fscache_stat_unchecked(&fscache_n_object_alloc);
57167
57168 - object->debug_id = atomic_inc_return(&fscache_object_debug_id);
57169 + object->debug_id = atomic_inc_return_unchecked(&fscache_object_debug_id);
57170
57171 _debug("ALLOC OBJ%x: %s {%lx}",
57172 object->debug_id, cookie->def->name, object->events);
57173 @@ -380,7 +380,7 @@ void __fscache_invalidate(struct fscache_cookie *cookie)
57174
57175 _enter("{%s}", cookie->def->name);
57176
57177 - fscache_stat(&fscache_n_invalidates);
57178 + fscache_stat_unchecked(&fscache_n_invalidates);
57179
57180 /* Only permit invalidation of data files. Invalidating an index will
57181 * require the caller to release all its attachments to the tree rooted
57182 @@ -438,10 +438,10 @@ void __fscache_update_cookie(struct fscache_cookie *cookie)
57183 {
57184 struct fscache_object *object;
57185
57186 - fscache_stat(&fscache_n_updates);
57187 + fscache_stat_unchecked(&fscache_n_updates);
57188
57189 if (!cookie) {
57190 - fscache_stat(&fscache_n_updates_null);
57191 + fscache_stat_unchecked(&fscache_n_updates_null);
57192 _leave(" [no cookie]");
57193 return;
57194 }
57195 @@ -473,12 +473,12 @@ void __fscache_relinquish_cookie(struct fscache_cookie *cookie, int retire)
57196 {
57197 struct fscache_object *object;
57198
57199 - fscache_stat(&fscache_n_relinquishes);
57200 + fscache_stat_unchecked(&fscache_n_relinquishes);
57201 if (retire)
57202 - fscache_stat(&fscache_n_relinquishes_retire);
57203 + fscache_stat_unchecked(&fscache_n_relinquishes_retire);
57204
57205 if (!cookie) {
57206 - fscache_stat(&fscache_n_relinquishes_null);
57207 + fscache_stat_unchecked(&fscache_n_relinquishes_null);
57208 _leave(" [no cookie]");
57209 return;
57210 }
57211 @@ -598,7 +598,7 @@ int __fscache_check_consistency(struct fscache_cookie *cookie)
57212 if (test_bit(FSCACHE_IOERROR, &object->cache->flags))
57213 goto inconsistent;
57214
57215 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
57216 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
57217
57218 atomic_inc(&cookie->n_active);
57219 if (fscache_submit_op(object, op) < 0)
57220 diff --git a/fs/fscache/internal.h b/fs/fscache/internal.h
57221 index 4226f66..0fb3f45 100644
57222 --- a/fs/fscache/internal.h
57223 +++ b/fs/fscache/internal.h
57224 @@ -133,8 +133,8 @@ extern void fscache_operation_gc(struct work_struct *);
57225 extern int fscache_wait_for_deferred_lookup(struct fscache_cookie *);
57226 extern int fscache_wait_for_operation_activation(struct fscache_object *,
57227 struct fscache_operation *,
57228 - atomic_t *,
57229 - atomic_t *,
57230 + atomic_unchecked_t *,
57231 + atomic_unchecked_t *,
57232 void (*)(struct fscache_operation *));
57233 extern void fscache_invalidate_writes(struct fscache_cookie *);
57234
57235 @@ -153,101 +153,101 @@ extern void fscache_proc_cleanup(void);
57236 * stats.c
57237 */
57238 #ifdef CONFIG_FSCACHE_STATS
57239 -extern atomic_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
57240 -extern atomic_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
57241 +extern atomic_unchecked_t fscache_n_ops_processed[FSCACHE_MAX_THREADS];
57242 +extern atomic_unchecked_t fscache_n_objs_processed[FSCACHE_MAX_THREADS];
57243
57244 -extern atomic_t fscache_n_op_pend;
57245 -extern atomic_t fscache_n_op_run;
57246 -extern atomic_t fscache_n_op_enqueue;
57247 -extern atomic_t fscache_n_op_deferred_release;
57248 -extern atomic_t fscache_n_op_release;
57249 -extern atomic_t fscache_n_op_gc;
57250 -extern atomic_t fscache_n_op_cancelled;
57251 -extern atomic_t fscache_n_op_rejected;
57252 +extern atomic_unchecked_t fscache_n_op_pend;
57253 +extern atomic_unchecked_t fscache_n_op_run;
57254 +extern atomic_unchecked_t fscache_n_op_enqueue;
57255 +extern atomic_unchecked_t fscache_n_op_deferred_release;
57256 +extern atomic_unchecked_t fscache_n_op_release;
57257 +extern atomic_unchecked_t fscache_n_op_gc;
57258 +extern atomic_unchecked_t fscache_n_op_cancelled;
57259 +extern atomic_unchecked_t fscache_n_op_rejected;
57260
57261 -extern atomic_t fscache_n_attr_changed;
57262 -extern atomic_t fscache_n_attr_changed_ok;
57263 -extern atomic_t fscache_n_attr_changed_nobufs;
57264 -extern atomic_t fscache_n_attr_changed_nomem;
57265 -extern atomic_t fscache_n_attr_changed_calls;
57266 +extern atomic_unchecked_t fscache_n_attr_changed;
57267 +extern atomic_unchecked_t fscache_n_attr_changed_ok;
57268 +extern atomic_unchecked_t fscache_n_attr_changed_nobufs;
57269 +extern atomic_unchecked_t fscache_n_attr_changed_nomem;
57270 +extern atomic_unchecked_t fscache_n_attr_changed_calls;
57271
57272 -extern atomic_t fscache_n_allocs;
57273 -extern atomic_t fscache_n_allocs_ok;
57274 -extern atomic_t fscache_n_allocs_wait;
57275 -extern atomic_t fscache_n_allocs_nobufs;
57276 -extern atomic_t fscache_n_allocs_intr;
57277 -extern atomic_t fscache_n_allocs_object_dead;
57278 -extern atomic_t fscache_n_alloc_ops;
57279 -extern atomic_t fscache_n_alloc_op_waits;
57280 +extern atomic_unchecked_t fscache_n_allocs;
57281 +extern atomic_unchecked_t fscache_n_allocs_ok;
57282 +extern atomic_unchecked_t fscache_n_allocs_wait;
57283 +extern atomic_unchecked_t fscache_n_allocs_nobufs;
57284 +extern atomic_unchecked_t fscache_n_allocs_intr;
57285 +extern atomic_unchecked_t fscache_n_allocs_object_dead;
57286 +extern atomic_unchecked_t fscache_n_alloc_ops;
57287 +extern atomic_unchecked_t fscache_n_alloc_op_waits;
57288
57289 -extern atomic_t fscache_n_retrievals;
57290 -extern atomic_t fscache_n_retrievals_ok;
57291 -extern atomic_t fscache_n_retrievals_wait;
57292 -extern atomic_t fscache_n_retrievals_nodata;
57293 -extern atomic_t fscache_n_retrievals_nobufs;
57294 -extern atomic_t fscache_n_retrievals_intr;
57295 -extern atomic_t fscache_n_retrievals_nomem;
57296 -extern atomic_t fscache_n_retrievals_object_dead;
57297 -extern atomic_t fscache_n_retrieval_ops;
57298 -extern atomic_t fscache_n_retrieval_op_waits;
57299 +extern atomic_unchecked_t fscache_n_retrievals;
57300 +extern atomic_unchecked_t fscache_n_retrievals_ok;
57301 +extern atomic_unchecked_t fscache_n_retrievals_wait;
57302 +extern atomic_unchecked_t fscache_n_retrievals_nodata;
57303 +extern atomic_unchecked_t fscache_n_retrievals_nobufs;
57304 +extern atomic_unchecked_t fscache_n_retrievals_intr;
57305 +extern atomic_unchecked_t fscache_n_retrievals_nomem;
57306 +extern atomic_unchecked_t fscache_n_retrievals_object_dead;
57307 +extern atomic_unchecked_t fscache_n_retrieval_ops;
57308 +extern atomic_unchecked_t fscache_n_retrieval_op_waits;
57309
57310 -extern atomic_t fscache_n_stores;
57311 -extern atomic_t fscache_n_stores_ok;
57312 -extern atomic_t fscache_n_stores_again;
57313 -extern atomic_t fscache_n_stores_nobufs;
57314 -extern atomic_t fscache_n_stores_oom;
57315 -extern atomic_t fscache_n_store_ops;
57316 -extern atomic_t fscache_n_store_calls;
57317 -extern atomic_t fscache_n_store_pages;
57318 -extern atomic_t fscache_n_store_radix_deletes;
57319 -extern atomic_t fscache_n_store_pages_over_limit;
57320 +extern atomic_unchecked_t fscache_n_stores;
57321 +extern atomic_unchecked_t fscache_n_stores_ok;
57322 +extern atomic_unchecked_t fscache_n_stores_again;
57323 +extern atomic_unchecked_t fscache_n_stores_nobufs;
57324 +extern atomic_unchecked_t fscache_n_stores_oom;
57325 +extern atomic_unchecked_t fscache_n_store_ops;
57326 +extern atomic_unchecked_t fscache_n_store_calls;
57327 +extern atomic_unchecked_t fscache_n_store_pages;
57328 +extern atomic_unchecked_t fscache_n_store_radix_deletes;
57329 +extern atomic_unchecked_t fscache_n_store_pages_over_limit;
57330
57331 -extern atomic_t fscache_n_store_vmscan_not_storing;
57332 -extern atomic_t fscache_n_store_vmscan_gone;
57333 -extern atomic_t fscache_n_store_vmscan_busy;
57334 -extern atomic_t fscache_n_store_vmscan_cancelled;
57335 -extern atomic_t fscache_n_store_vmscan_wait;
57336 +extern atomic_unchecked_t fscache_n_store_vmscan_not_storing;
57337 +extern atomic_unchecked_t fscache_n_store_vmscan_gone;
57338 +extern atomic_unchecked_t fscache_n_store_vmscan_busy;
57339 +extern atomic_unchecked_t fscache_n_store_vmscan_cancelled;
57340 +extern atomic_unchecked_t fscache_n_store_vmscan_wait;
57341
57342 -extern atomic_t fscache_n_marks;
57343 -extern atomic_t fscache_n_uncaches;
57344 +extern atomic_unchecked_t fscache_n_marks;
57345 +extern atomic_unchecked_t fscache_n_uncaches;
57346
57347 -extern atomic_t fscache_n_acquires;
57348 -extern atomic_t fscache_n_acquires_null;
57349 -extern atomic_t fscache_n_acquires_no_cache;
57350 -extern atomic_t fscache_n_acquires_ok;
57351 -extern atomic_t fscache_n_acquires_nobufs;
57352 -extern atomic_t fscache_n_acquires_oom;
57353 +extern atomic_unchecked_t fscache_n_acquires;
57354 +extern atomic_unchecked_t fscache_n_acquires_null;
57355 +extern atomic_unchecked_t fscache_n_acquires_no_cache;
57356 +extern atomic_unchecked_t fscache_n_acquires_ok;
57357 +extern atomic_unchecked_t fscache_n_acquires_nobufs;
57358 +extern atomic_unchecked_t fscache_n_acquires_oom;
57359
57360 -extern atomic_t fscache_n_invalidates;
57361 -extern atomic_t fscache_n_invalidates_run;
57362 +extern atomic_unchecked_t fscache_n_invalidates;
57363 +extern atomic_unchecked_t fscache_n_invalidates_run;
57364
57365 -extern atomic_t fscache_n_updates;
57366 -extern atomic_t fscache_n_updates_null;
57367 -extern atomic_t fscache_n_updates_run;
57368 +extern atomic_unchecked_t fscache_n_updates;
57369 +extern atomic_unchecked_t fscache_n_updates_null;
57370 +extern atomic_unchecked_t fscache_n_updates_run;
57371
57372 -extern atomic_t fscache_n_relinquishes;
57373 -extern atomic_t fscache_n_relinquishes_null;
57374 -extern atomic_t fscache_n_relinquishes_waitcrt;
57375 -extern atomic_t fscache_n_relinquishes_retire;
57376 +extern atomic_unchecked_t fscache_n_relinquishes;
57377 +extern atomic_unchecked_t fscache_n_relinquishes_null;
57378 +extern atomic_unchecked_t fscache_n_relinquishes_waitcrt;
57379 +extern atomic_unchecked_t fscache_n_relinquishes_retire;
57380
57381 -extern atomic_t fscache_n_cookie_index;
57382 -extern atomic_t fscache_n_cookie_data;
57383 -extern atomic_t fscache_n_cookie_special;
57384 +extern atomic_unchecked_t fscache_n_cookie_index;
57385 +extern atomic_unchecked_t fscache_n_cookie_data;
57386 +extern atomic_unchecked_t fscache_n_cookie_special;
57387
57388 -extern atomic_t fscache_n_object_alloc;
57389 -extern atomic_t fscache_n_object_no_alloc;
57390 -extern atomic_t fscache_n_object_lookups;
57391 -extern atomic_t fscache_n_object_lookups_negative;
57392 -extern atomic_t fscache_n_object_lookups_positive;
57393 -extern atomic_t fscache_n_object_lookups_timed_out;
57394 -extern atomic_t fscache_n_object_created;
57395 -extern atomic_t fscache_n_object_avail;
57396 -extern atomic_t fscache_n_object_dead;
57397 +extern atomic_unchecked_t fscache_n_object_alloc;
57398 +extern atomic_unchecked_t fscache_n_object_no_alloc;
57399 +extern atomic_unchecked_t fscache_n_object_lookups;
57400 +extern atomic_unchecked_t fscache_n_object_lookups_negative;
57401 +extern atomic_unchecked_t fscache_n_object_lookups_positive;
57402 +extern atomic_unchecked_t fscache_n_object_lookups_timed_out;
57403 +extern atomic_unchecked_t fscache_n_object_created;
57404 +extern atomic_unchecked_t fscache_n_object_avail;
57405 +extern atomic_unchecked_t fscache_n_object_dead;
57406
57407 -extern atomic_t fscache_n_checkaux_none;
57408 -extern atomic_t fscache_n_checkaux_okay;
57409 -extern atomic_t fscache_n_checkaux_update;
57410 -extern atomic_t fscache_n_checkaux_obsolete;
57411 +extern atomic_unchecked_t fscache_n_checkaux_none;
57412 +extern atomic_unchecked_t fscache_n_checkaux_okay;
57413 +extern atomic_unchecked_t fscache_n_checkaux_update;
57414 +extern atomic_unchecked_t fscache_n_checkaux_obsolete;
57415
57416 extern atomic_t fscache_n_cop_alloc_object;
57417 extern atomic_t fscache_n_cop_lookup_object;
57418 @@ -272,6 +272,11 @@ static inline void fscache_stat(atomic_t *stat)
57419 atomic_inc(stat);
57420 }
57421
57422 +static inline void fscache_stat_unchecked(atomic_unchecked_t *stat)
57423 +{
57424 + atomic_inc_unchecked(stat);
57425 +}
57426 +
57427 static inline void fscache_stat_d(atomic_t *stat)
57428 {
57429 atomic_dec(stat);
57430 @@ -284,6 +289,7 @@ extern const struct file_operations fscache_stats_fops;
57431
57432 #define __fscache_stat(stat) (NULL)
57433 #define fscache_stat(stat) do {} while (0)
57434 +#define fscache_stat_unchecked(stat) do {} while (0)
57435 #define fscache_stat_d(stat) do {} while (0)
57436 #endif
57437
57438 diff --git a/fs/fscache/object.c b/fs/fscache/object.c
57439 index 86d75a6..5f3d7a0 100644
57440 --- a/fs/fscache/object.c
57441 +++ b/fs/fscache/object.c
57442 @@ -451,7 +451,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
57443 _debug("LOOKUP \"%s\" in \"%s\"",
57444 cookie->def->name, object->cache->tag->name);
57445
57446 - fscache_stat(&fscache_n_object_lookups);
57447 + fscache_stat_unchecked(&fscache_n_object_lookups);
57448 fscache_stat(&fscache_n_cop_lookup_object);
57449 ret = object->cache->ops->lookup_object(object);
57450 fscache_stat_d(&fscache_n_cop_lookup_object);
57451 @@ -461,7 +461,7 @@ static const struct fscache_state *fscache_look_up_object(struct fscache_object
57452 if (ret == -ETIMEDOUT) {
57453 /* probably stuck behind another object, so move this one to
57454 * the back of the queue */
57455 - fscache_stat(&fscache_n_object_lookups_timed_out);
57456 + fscache_stat_unchecked(&fscache_n_object_lookups_timed_out);
57457 _leave(" [timeout]");
57458 return NO_TRANSIT;
57459 }
57460 @@ -489,7 +489,7 @@ void fscache_object_lookup_negative(struct fscache_object *object)
57461 _enter("{OBJ%x,%s}", object->debug_id, object->state->name);
57462
57463 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
57464 - fscache_stat(&fscache_n_object_lookups_negative);
57465 + fscache_stat_unchecked(&fscache_n_object_lookups_negative);
57466
57467 /* Allow write requests to begin stacking up and read requests to begin
57468 * returning ENODATA.
57469 @@ -523,7 +523,7 @@ void fscache_obtained_object(struct fscache_object *object)
57470 /* if we were still looking up, then we must have a positive lookup
57471 * result, in which case there may be data available */
57472 if (!test_and_set_bit(FSCACHE_OBJECT_IS_LOOKED_UP, &object->flags)) {
57473 - fscache_stat(&fscache_n_object_lookups_positive);
57474 + fscache_stat_unchecked(&fscache_n_object_lookups_positive);
57475
57476 /* We do (presumably) have data */
57477 clear_bit_unlock(FSCACHE_COOKIE_NO_DATA_YET, &cookie->flags);
57478 @@ -534,7 +534,7 @@ void fscache_obtained_object(struct fscache_object *object)
57479 clear_bit_unlock(FSCACHE_COOKIE_LOOKING_UP, &cookie->flags);
57480 wake_up_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP);
57481 } else {
57482 - fscache_stat(&fscache_n_object_created);
57483 + fscache_stat_unchecked(&fscache_n_object_created);
57484 }
57485
57486 set_bit(FSCACHE_OBJECT_IS_AVAILABLE, &object->flags);
57487 @@ -570,7 +570,7 @@ static const struct fscache_state *fscache_object_available(struct fscache_objec
57488 fscache_stat_d(&fscache_n_cop_lookup_complete);
57489
57490 fscache_hist(fscache_obj_instantiate_histogram, object->lookup_jif);
57491 - fscache_stat(&fscache_n_object_avail);
57492 + fscache_stat_unchecked(&fscache_n_object_avail);
57493
57494 _leave("");
57495 return transit_to(JUMPSTART_DEPS);
57496 @@ -716,7 +716,7 @@ static const struct fscache_state *fscache_drop_object(struct fscache_object *ob
57497
57498 /* this just shifts the object release to the work processor */
57499 fscache_put_object(object);
57500 - fscache_stat(&fscache_n_object_dead);
57501 + fscache_stat_unchecked(&fscache_n_object_dead);
57502
57503 _leave("");
57504 return transit_to(OBJECT_DEAD);
57505 @@ -881,7 +881,7 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57506 enum fscache_checkaux result;
57507
57508 if (!object->cookie->def->check_aux) {
57509 - fscache_stat(&fscache_n_checkaux_none);
57510 + fscache_stat_unchecked(&fscache_n_checkaux_none);
57511 return FSCACHE_CHECKAUX_OKAY;
57512 }
57513
57514 @@ -890,17 +890,17 @@ enum fscache_checkaux fscache_check_aux(struct fscache_object *object,
57515 switch (result) {
57516 /* entry okay as is */
57517 case FSCACHE_CHECKAUX_OKAY:
57518 - fscache_stat(&fscache_n_checkaux_okay);
57519 + fscache_stat_unchecked(&fscache_n_checkaux_okay);
57520 break;
57521
57522 /* entry requires update */
57523 case FSCACHE_CHECKAUX_NEEDS_UPDATE:
57524 - fscache_stat(&fscache_n_checkaux_update);
57525 + fscache_stat_unchecked(&fscache_n_checkaux_update);
57526 break;
57527
57528 /* entry requires deletion */
57529 case FSCACHE_CHECKAUX_OBSOLETE:
57530 - fscache_stat(&fscache_n_checkaux_obsolete);
57531 + fscache_stat_unchecked(&fscache_n_checkaux_obsolete);
57532 break;
57533
57534 default:
57535 @@ -986,7 +986,7 @@ static const struct fscache_state *fscache_invalidate_object(struct fscache_obje
57536 {
57537 const struct fscache_state *s;
57538
57539 - fscache_stat(&fscache_n_invalidates_run);
57540 + fscache_stat_unchecked(&fscache_n_invalidates_run);
57541 fscache_stat(&fscache_n_cop_invalidate_object);
57542 s = _fscache_invalidate_object(object, event);
57543 fscache_stat_d(&fscache_n_cop_invalidate_object);
57544 @@ -1001,7 +1001,7 @@ static const struct fscache_state *fscache_update_object(struct fscache_object *
57545 {
57546 _enter("{OBJ%x},%d", object->debug_id, event);
57547
57548 - fscache_stat(&fscache_n_updates_run);
57549 + fscache_stat_unchecked(&fscache_n_updates_run);
57550 fscache_stat(&fscache_n_cop_update_object);
57551 object->cache->ops->update_object(object);
57552 fscache_stat_d(&fscache_n_cop_update_object);
57553 diff --git a/fs/fscache/operation.c b/fs/fscache/operation.c
57554 index 318071a..379938b 100644
57555 --- a/fs/fscache/operation.c
57556 +++ b/fs/fscache/operation.c
57557 @@ -17,7 +17,7 @@
57558 #include <linux/slab.h>
57559 #include "internal.h"
57560
57561 -atomic_t fscache_op_debug_id;
57562 +atomic_unchecked_t fscache_op_debug_id;
57563 EXPORT_SYMBOL(fscache_op_debug_id);
57564
57565 /**
57566 @@ -39,7 +39,7 @@ void fscache_enqueue_operation(struct fscache_operation *op)
57567 ASSERTCMP(atomic_read(&op->usage), >, 0);
57568 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_IN_PROGRESS);
57569
57570 - fscache_stat(&fscache_n_op_enqueue);
57571 + fscache_stat_unchecked(&fscache_n_op_enqueue);
57572 switch (op->flags & FSCACHE_OP_TYPE) {
57573 case FSCACHE_OP_ASYNC:
57574 _debug("queue async");
57575 @@ -73,7 +73,7 @@ static void fscache_run_op(struct fscache_object *object,
57576 wake_up_bit(&op->flags, FSCACHE_OP_WAITING);
57577 if (op->processor)
57578 fscache_enqueue_operation(op);
57579 - fscache_stat(&fscache_n_op_run);
57580 + fscache_stat_unchecked(&fscache_n_op_run);
57581 }
57582
57583 /*
57584 @@ -105,11 +105,11 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57585 if (object->n_in_progress > 0) {
57586 atomic_inc(&op->usage);
57587 list_add_tail(&op->pend_link, &object->pending_ops);
57588 - fscache_stat(&fscache_n_op_pend);
57589 + fscache_stat_unchecked(&fscache_n_op_pend);
57590 } else if (!list_empty(&object->pending_ops)) {
57591 atomic_inc(&op->usage);
57592 list_add_tail(&op->pend_link, &object->pending_ops);
57593 - fscache_stat(&fscache_n_op_pend);
57594 + fscache_stat_unchecked(&fscache_n_op_pend);
57595 fscache_start_operations(object);
57596 } else {
57597 ASSERTCMP(object->n_in_progress, ==, 0);
57598 @@ -125,7 +125,7 @@ int fscache_submit_exclusive_op(struct fscache_object *object,
57599 object->n_exclusive++; /* reads and writes must wait */
57600 atomic_inc(&op->usage);
57601 list_add_tail(&op->pend_link, &object->pending_ops);
57602 - fscache_stat(&fscache_n_op_pend);
57603 + fscache_stat_unchecked(&fscache_n_op_pend);
57604 ret = 0;
57605 } else {
57606 /* If we're in any other state, there must have been an I/O
57607 @@ -212,11 +212,11 @@ int fscache_submit_op(struct fscache_object *object,
57608 if (object->n_exclusive > 0) {
57609 atomic_inc(&op->usage);
57610 list_add_tail(&op->pend_link, &object->pending_ops);
57611 - fscache_stat(&fscache_n_op_pend);
57612 + fscache_stat_unchecked(&fscache_n_op_pend);
57613 } else if (!list_empty(&object->pending_ops)) {
57614 atomic_inc(&op->usage);
57615 list_add_tail(&op->pend_link, &object->pending_ops);
57616 - fscache_stat(&fscache_n_op_pend);
57617 + fscache_stat_unchecked(&fscache_n_op_pend);
57618 fscache_start_operations(object);
57619 } else {
57620 ASSERTCMP(object->n_exclusive, ==, 0);
57621 @@ -228,10 +228,10 @@ int fscache_submit_op(struct fscache_object *object,
57622 object->n_ops++;
57623 atomic_inc(&op->usage);
57624 list_add_tail(&op->pend_link, &object->pending_ops);
57625 - fscache_stat(&fscache_n_op_pend);
57626 + fscache_stat_unchecked(&fscache_n_op_pend);
57627 ret = 0;
57628 } else if (fscache_object_is_dying(object)) {
57629 - fscache_stat(&fscache_n_op_rejected);
57630 + fscache_stat_unchecked(&fscache_n_op_rejected);
57631 op->state = FSCACHE_OP_ST_CANCELLED;
57632 ret = -ENOBUFS;
57633 } else if (!test_bit(FSCACHE_IOERROR, &object->cache->flags)) {
57634 @@ -310,7 +310,7 @@ int fscache_cancel_op(struct fscache_operation *op,
57635 ret = -EBUSY;
57636 if (op->state == FSCACHE_OP_ST_PENDING) {
57637 ASSERT(!list_empty(&op->pend_link));
57638 - fscache_stat(&fscache_n_op_cancelled);
57639 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57640 list_del_init(&op->pend_link);
57641 if (do_cancel)
57642 do_cancel(op);
57643 @@ -342,7 +342,7 @@ void fscache_cancel_all_ops(struct fscache_object *object)
57644 while (!list_empty(&object->pending_ops)) {
57645 op = list_entry(object->pending_ops.next,
57646 struct fscache_operation, pend_link);
57647 - fscache_stat(&fscache_n_op_cancelled);
57648 + fscache_stat_unchecked(&fscache_n_op_cancelled);
57649 list_del_init(&op->pend_link);
57650
57651 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_PENDING);
57652 @@ -414,7 +414,7 @@ void fscache_put_operation(struct fscache_operation *op)
57653 op->state, ==, FSCACHE_OP_ST_CANCELLED);
57654 op->state = FSCACHE_OP_ST_DEAD;
57655
57656 - fscache_stat(&fscache_n_op_release);
57657 + fscache_stat_unchecked(&fscache_n_op_release);
57658
57659 if (op->release) {
57660 op->release(op);
57661 @@ -433,7 +433,7 @@ void fscache_put_operation(struct fscache_operation *op)
57662 * lock, and defer it otherwise */
57663 if (!spin_trylock(&object->lock)) {
57664 _debug("defer put");
57665 - fscache_stat(&fscache_n_op_deferred_release);
57666 + fscache_stat_unchecked(&fscache_n_op_deferred_release);
57667
57668 cache = object->cache;
57669 spin_lock(&cache->op_gc_list_lock);
57670 @@ -486,7 +486,7 @@ void fscache_operation_gc(struct work_struct *work)
57671
57672 _debug("GC DEFERRED REL OBJ%x OP%x",
57673 object->debug_id, op->debug_id);
57674 - fscache_stat(&fscache_n_op_gc);
57675 + fscache_stat_unchecked(&fscache_n_op_gc);
57676
57677 ASSERTCMP(atomic_read(&op->usage), ==, 0);
57678 ASSERTCMP(op->state, ==, FSCACHE_OP_ST_DEAD);
57679 diff --git a/fs/fscache/page.c b/fs/fscache/page.c
57680 index 73899c1..ae40c58 100644
57681 --- a/fs/fscache/page.c
57682 +++ b/fs/fscache/page.c
57683 @@ -61,7 +61,7 @@ try_again:
57684 val = radix_tree_lookup(&cookie->stores, page->index);
57685 if (!val) {
57686 rcu_read_unlock();
57687 - fscache_stat(&fscache_n_store_vmscan_not_storing);
57688 + fscache_stat_unchecked(&fscache_n_store_vmscan_not_storing);
57689 __fscache_uncache_page(cookie, page);
57690 return true;
57691 }
57692 @@ -91,11 +91,11 @@ try_again:
57693 spin_unlock(&cookie->stores_lock);
57694
57695 if (xpage) {
57696 - fscache_stat(&fscache_n_store_vmscan_cancelled);
57697 - fscache_stat(&fscache_n_store_radix_deletes);
57698 + fscache_stat_unchecked(&fscache_n_store_vmscan_cancelled);
57699 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57700 ASSERTCMP(xpage, ==, page);
57701 } else {
57702 - fscache_stat(&fscache_n_store_vmscan_gone);
57703 + fscache_stat_unchecked(&fscache_n_store_vmscan_gone);
57704 }
57705
57706 wake_up_bit(&cookie->flags, 0);
57707 @@ -110,11 +110,11 @@ page_busy:
57708 * sleeping on memory allocation, so we may need to impose a timeout
57709 * too. */
57710 if (!(gfp & __GFP_WAIT) || !(gfp & __GFP_FS)) {
57711 - fscache_stat(&fscache_n_store_vmscan_busy);
57712 + fscache_stat_unchecked(&fscache_n_store_vmscan_busy);
57713 return false;
57714 }
57715
57716 - fscache_stat(&fscache_n_store_vmscan_wait);
57717 + fscache_stat_unchecked(&fscache_n_store_vmscan_wait);
57718 __fscache_wait_on_page_write(cookie, page);
57719 gfp &= ~__GFP_WAIT;
57720 goto try_again;
57721 @@ -140,7 +140,7 @@ static void fscache_end_page_write(struct fscache_object *object,
57722 FSCACHE_COOKIE_STORING_TAG);
57723 if (!radix_tree_tag_get(&cookie->stores, page->index,
57724 FSCACHE_COOKIE_PENDING_TAG)) {
57725 - fscache_stat(&fscache_n_store_radix_deletes);
57726 + fscache_stat_unchecked(&fscache_n_store_radix_deletes);
57727 xpage = radix_tree_delete(&cookie->stores, page->index);
57728 }
57729 spin_unlock(&cookie->stores_lock);
57730 @@ -161,7 +161,7 @@ static void fscache_attr_changed_op(struct fscache_operation *op)
57731
57732 _enter("{OBJ%x OP%x}", object->debug_id, op->debug_id);
57733
57734 - fscache_stat(&fscache_n_attr_changed_calls);
57735 + fscache_stat_unchecked(&fscache_n_attr_changed_calls);
57736
57737 if (fscache_object_is_active(object) &&
57738 fscache_use_cookie(object)) {
57739 @@ -189,11 +189,11 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57740
57741 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
57742
57743 - fscache_stat(&fscache_n_attr_changed);
57744 + fscache_stat_unchecked(&fscache_n_attr_changed);
57745
57746 op = kzalloc(sizeof(*op), GFP_KERNEL);
57747 if (!op) {
57748 - fscache_stat(&fscache_n_attr_changed_nomem);
57749 + fscache_stat_unchecked(&fscache_n_attr_changed_nomem);
57750 _leave(" = -ENOMEM");
57751 return -ENOMEM;
57752 }
57753 @@ -211,7 +211,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57754 if (fscache_submit_exclusive_op(object, op) < 0)
57755 goto nobufs;
57756 spin_unlock(&cookie->lock);
57757 - fscache_stat(&fscache_n_attr_changed_ok);
57758 + fscache_stat_unchecked(&fscache_n_attr_changed_ok);
57759 fscache_put_operation(op);
57760 _leave(" = 0");
57761 return 0;
57762 @@ -219,7 +219,7 @@ int __fscache_attr_changed(struct fscache_cookie *cookie)
57763 nobufs:
57764 spin_unlock(&cookie->lock);
57765 kfree(op);
57766 - fscache_stat(&fscache_n_attr_changed_nobufs);
57767 + fscache_stat_unchecked(&fscache_n_attr_changed_nobufs);
57768 _leave(" = %d", -ENOBUFS);
57769 return -ENOBUFS;
57770 }
57771 @@ -258,7 +258,7 @@ static struct fscache_retrieval *fscache_alloc_retrieval(
57772 /* allocate a retrieval operation and attempt to submit it */
57773 op = kzalloc(sizeof(*op), GFP_NOIO);
57774 if (!op) {
57775 - fscache_stat(&fscache_n_retrievals_nomem);
57776 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57777 return NULL;
57778 }
57779
57780 @@ -289,13 +289,13 @@ int fscache_wait_for_deferred_lookup(struct fscache_cookie *cookie)
57781 return 0;
57782 }
57783
57784 - fscache_stat(&fscache_n_retrievals_wait);
57785 + fscache_stat_unchecked(&fscache_n_retrievals_wait);
57786
57787 jif = jiffies;
57788 if (wait_on_bit(&cookie->flags, FSCACHE_COOKIE_LOOKING_UP,
57789 fscache_wait_bit_interruptible,
57790 TASK_INTERRUPTIBLE) != 0) {
57791 - fscache_stat(&fscache_n_retrievals_intr);
57792 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57793 _leave(" = -ERESTARTSYS");
57794 return -ERESTARTSYS;
57795 }
57796 @@ -324,8 +324,8 @@ static void fscache_do_cancel_retrieval(struct fscache_operation *_op)
57797 */
57798 int fscache_wait_for_operation_activation(struct fscache_object *object,
57799 struct fscache_operation *op,
57800 - atomic_t *stat_op_waits,
57801 - atomic_t *stat_object_dead,
57802 + atomic_unchecked_t *stat_op_waits,
57803 + atomic_unchecked_t *stat_object_dead,
57804 void (*do_cancel)(struct fscache_operation *))
57805 {
57806 int ret;
57807 @@ -335,7 +335,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57808
57809 _debug(">>> WT");
57810 if (stat_op_waits)
57811 - fscache_stat(stat_op_waits);
57812 + fscache_stat_unchecked(stat_op_waits);
57813 if (wait_on_bit(&op->flags, FSCACHE_OP_WAITING,
57814 fscache_wait_bit_interruptible,
57815 TASK_INTERRUPTIBLE) != 0) {
57816 @@ -353,7 +353,7 @@ int fscache_wait_for_operation_activation(struct fscache_object *object,
57817 check_if_dead:
57818 if (op->state == FSCACHE_OP_ST_CANCELLED) {
57819 if (stat_object_dead)
57820 - fscache_stat(stat_object_dead);
57821 + fscache_stat_unchecked(stat_object_dead);
57822 _leave(" = -ENOBUFS [cancelled]");
57823 return -ENOBUFS;
57824 }
57825 @@ -361,7 +361,7 @@ check_if_dead:
57826 pr_err("%s() = -ENOBUFS [obj dead %d]\n", __func__, op->state);
57827 fscache_cancel_op(op, do_cancel);
57828 if (stat_object_dead)
57829 - fscache_stat(stat_object_dead);
57830 + fscache_stat_unchecked(stat_object_dead);
57831 return -ENOBUFS;
57832 }
57833 return 0;
57834 @@ -388,7 +388,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57835
57836 _enter("%p,%p,,,", cookie, page);
57837
57838 - fscache_stat(&fscache_n_retrievals);
57839 + fscache_stat_unchecked(&fscache_n_retrievals);
57840
57841 if (hlist_empty(&cookie->backing_objects))
57842 goto nobufs;
57843 @@ -428,7 +428,7 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57844 goto nobufs_unlock_dec;
57845 spin_unlock(&cookie->lock);
57846
57847 - fscache_stat(&fscache_n_retrieval_ops);
57848 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57849
57850 /* pin the netfs read context in case we need to do the actual netfs
57851 * read because we've encountered a cache read failure */
57852 @@ -459,15 +459,15 @@ int __fscache_read_or_alloc_page(struct fscache_cookie *cookie,
57853
57854 error:
57855 if (ret == -ENOMEM)
57856 - fscache_stat(&fscache_n_retrievals_nomem);
57857 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57858 else if (ret == -ERESTARTSYS)
57859 - fscache_stat(&fscache_n_retrievals_intr);
57860 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57861 else if (ret == -ENODATA)
57862 - fscache_stat(&fscache_n_retrievals_nodata);
57863 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57864 else if (ret < 0)
57865 - fscache_stat(&fscache_n_retrievals_nobufs);
57866 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57867 else
57868 - fscache_stat(&fscache_n_retrievals_ok);
57869 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57870
57871 fscache_put_retrieval(op);
57872 _leave(" = %d", ret);
57873 @@ -480,7 +480,7 @@ nobufs_unlock:
57874 atomic_dec(&cookie->n_active);
57875 kfree(op);
57876 nobufs:
57877 - fscache_stat(&fscache_n_retrievals_nobufs);
57878 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57879 _leave(" = -ENOBUFS");
57880 return -ENOBUFS;
57881 }
57882 @@ -518,7 +518,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57883
57884 _enter("%p,,%d,,,", cookie, *nr_pages);
57885
57886 - fscache_stat(&fscache_n_retrievals);
57887 + fscache_stat_unchecked(&fscache_n_retrievals);
57888
57889 if (hlist_empty(&cookie->backing_objects))
57890 goto nobufs;
57891 @@ -554,7 +554,7 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57892 goto nobufs_unlock_dec;
57893 spin_unlock(&cookie->lock);
57894
57895 - fscache_stat(&fscache_n_retrieval_ops);
57896 + fscache_stat_unchecked(&fscache_n_retrieval_ops);
57897
57898 /* pin the netfs read context in case we need to do the actual netfs
57899 * read because we've encountered a cache read failure */
57900 @@ -585,15 +585,15 @@ int __fscache_read_or_alloc_pages(struct fscache_cookie *cookie,
57901
57902 error:
57903 if (ret == -ENOMEM)
57904 - fscache_stat(&fscache_n_retrievals_nomem);
57905 + fscache_stat_unchecked(&fscache_n_retrievals_nomem);
57906 else if (ret == -ERESTARTSYS)
57907 - fscache_stat(&fscache_n_retrievals_intr);
57908 + fscache_stat_unchecked(&fscache_n_retrievals_intr);
57909 else if (ret == -ENODATA)
57910 - fscache_stat(&fscache_n_retrievals_nodata);
57911 + fscache_stat_unchecked(&fscache_n_retrievals_nodata);
57912 else if (ret < 0)
57913 - fscache_stat(&fscache_n_retrievals_nobufs);
57914 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57915 else
57916 - fscache_stat(&fscache_n_retrievals_ok);
57917 + fscache_stat_unchecked(&fscache_n_retrievals_ok);
57918
57919 fscache_put_retrieval(op);
57920 _leave(" = %d", ret);
57921 @@ -606,7 +606,7 @@ nobufs_unlock:
57922 atomic_dec(&cookie->n_active);
57923 kfree(op);
57924 nobufs:
57925 - fscache_stat(&fscache_n_retrievals_nobufs);
57926 + fscache_stat_unchecked(&fscache_n_retrievals_nobufs);
57927 _leave(" = -ENOBUFS");
57928 return -ENOBUFS;
57929 }
57930 @@ -630,7 +630,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57931
57932 _enter("%p,%p,,,", cookie, page);
57933
57934 - fscache_stat(&fscache_n_allocs);
57935 + fscache_stat_unchecked(&fscache_n_allocs);
57936
57937 if (hlist_empty(&cookie->backing_objects))
57938 goto nobufs;
57939 @@ -662,7 +662,7 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57940 goto nobufs_unlock;
57941 spin_unlock(&cookie->lock);
57942
57943 - fscache_stat(&fscache_n_alloc_ops);
57944 + fscache_stat_unchecked(&fscache_n_alloc_ops);
57945
57946 ret = fscache_wait_for_operation_activation(
57947 object, &op->op,
57948 @@ -679,11 +679,11 @@ int __fscache_alloc_page(struct fscache_cookie *cookie,
57949
57950 error:
57951 if (ret == -ERESTARTSYS)
57952 - fscache_stat(&fscache_n_allocs_intr);
57953 + fscache_stat_unchecked(&fscache_n_allocs_intr);
57954 else if (ret < 0)
57955 - fscache_stat(&fscache_n_allocs_nobufs);
57956 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57957 else
57958 - fscache_stat(&fscache_n_allocs_ok);
57959 + fscache_stat_unchecked(&fscache_n_allocs_ok);
57960
57961 fscache_put_retrieval(op);
57962 _leave(" = %d", ret);
57963 @@ -694,7 +694,7 @@ nobufs_unlock:
57964 atomic_dec(&cookie->n_active);
57965 kfree(op);
57966 nobufs:
57967 - fscache_stat(&fscache_n_allocs_nobufs);
57968 + fscache_stat_unchecked(&fscache_n_allocs_nobufs);
57969 _leave(" = -ENOBUFS");
57970 return -ENOBUFS;
57971 }
57972 @@ -770,7 +770,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57973
57974 spin_lock(&cookie->stores_lock);
57975
57976 - fscache_stat(&fscache_n_store_calls);
57977 + fscache_stat_unchecked(&fscache_n_store_calls);
57978
57979 /* find a page to store */
57980 page = NULL;
57981 @@ -781,7 +781,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57982 page = results[0];
57983 _debug("gang %d [%lx]", n, page->index);
57984 if (page->index > op->store_limit) {
57985 - fscache_stat(&fscache_n_store_pages_over_limit);
57986 + fscache_stat_unchecked(&fscache_n_store_pages_over_limit);
57987 goto superseded;
57988 }
57989
57990 @@ -793,7 +793,7 @@ static void fscache_write_op(struct fscache_operation *_op)
57991 spin_unlock(&cookie->stores_lock);
57992 spin_unlock(&object->lock);
57993
57994 - fscache_stat(&fscache_n_store_pages);
57995 + fscache_stat_unchecked(&fscache_n_store_pages);
57996 fscache_stat(&fscache_n_cop_write_page);
57997 ret = object->cache->ops->write_page(op, page);
57998 fscache_stat_d(&fscache_n_cop_write_page);
57999 @@ -896,7 +896,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58000 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
58001 ASSERT(PageFsCache(page));
58002
58003 - fscache_stat(&fscache_n_stores);
58004 + fscache_stat_unchecked(&fscache_n_stores);
58005
58006 if (test_bit(FSCACHE_COOKIE_INVALIDATING, &cookie->flags)) {
58007 _leave(" = -ENOBUFS [invalidating]");
58008 @@ -954,7 +954,7 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58009 spin_unlock(&cookie->stores_lock);
58010 spin_unlock(&object->lock);
58011
58012 - op->op.debug_id = atomic_inc_return(&fscache_op_debug_id);
58013 + op->op.debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
58014 op->store_limit = object->store_limit;
58015
58016 atomic_inc(&cookie->n_active);
58017 @@ -963,8 +963,8 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58018
58019 spin_unlock(&cookie->lock);
58020 radix_tree_preload_end();
58021 - fscache_stat(&fscache_n_store_ops);
58022 - fscache_stat(&fscache_n_stores_ok);
58023 + fscache_stat_unchecked(&fscache_n_store_ops);
58024 + fscache_stat_unchecked(&fscache_n_stores_ok);
58025
58026 /* the work queue now carries its own ref on the object */
58027 fscache_put_operation(&op->op);
58028 @@ -972,14 +972,14 @@ int __fscache_write_page(struct fscache_cookie *cookie,
58029 return 0;
58030
58031 already_queued:
58032 - fscache_stat(&fscache_n_stores_again);
58033 + fscache_stat_unchecked(&fscache_n_stores_again);
58034 already_pending:
58035 spin_unlock(&cookie->stores_lock);
58036 spin_unlock(&object->lock);
58037 spin_unlock(&cookie->lock);
58038 radix_tree_preload_end();
58039 kfree(op);
58040 - fscache_stat(&fscache_n_stores_ok);
58041 + fscache_stat_unchecked(&fscache_n_stores_ok);
58042 _leave(" = 0");
58043 return 0;
58044
58045 @@ -999,14 +999,14 @@ nobufs:
58046 spin_unlock(&cookie->lock);
58047 radix_tree_preload_end();
58048 kfree(op);
58049 - fscache_stat(&fscache_n_stores_nobufs);
58050 + fscache_stat_unchecked(&fscache_n_stores_nobufs);
58051 _leave(" = -ENOBUFS");
58052 return -ENOBUFS;
58053
58054 nomem_free:
58055 kfree(op);
58056 nomem:
58057 - fscache_stat(&fscache_n_stores_oom);
58058 + fscache_stat_unchecked(&fscache_n_stores_oom);
58059 _leave(" = -ENOMEM");
58060 return -ENOMEM;
58061 }
58062 @@ -1024,7 +1024,7 @@ void __fscache_uncache_page(struct fscache_cookie *cookie, struct page *page)
58063 ASSERTCMP(cookie->def->type, !=, FSCACHE_COOKIE_TYPE_INDEX);
58064 ASSERTCMP(page, !=, NULL);
58065
58066 - fscache_stat(&fscache_n_uncaches);
58067 + fscache_stat_unchecked(&fscache_n_uncaches);
58068
58069 /* cache withdrawal may beat us to it */
58070 if (!PageFsCache(page))
58071 @@ -1075,7 +1075,7 @@ void fscache_mark_page_cached(struct fscache_retrieval *op, struct page *page)
58072 struct fscache_cookie *cookie = op->op.object->cookie;
58073
58074 #ifdef CONFIG_FSCACHE_STATS
58075 - atomic_inc(&fscache_n_marks);
58076 + atomic_inc_unchecked(&fscache_n_marks);
58077 #endif
58078
58079 _debug("- mark %p{%lx}", page, page->index);
58080 diff --git a/fs/fscache/stats.c b/fs/fscache/stats.c
58081 index 40d13c7..ddf52b9 100644
58082 --- a/fs/fscache/stats.c
58083 +++ b/fs/fscache/stats.c
58084 @@ -18,99 +18,99 @@
58085 /*
58086 * operation counters
58087 */
58088 -atomic_t fscache_n_op_pend;
58089 -atomic_t fscache_n_op_run;
58090 -atomic_t fscache_n_op_enqueue;
58091 -atomic_t fscache_n_op_requeue;
58092 -atomic_t fscache_n_op_deferred_release;
58093 -atomic_t fscache_n_op_release;
58094 -atomic_t fscache_n_op_gc;
58095 -atomic_t fscache_n_op_cancelled;
58096 -atomic_t fscache_n_op_rejected;
58097 +atomic_unchecked_t fscache_n_op_pend;
58098 +atomic_unchecked_t fscache_n_op_run;
58099 +atomic_unchecked_t fscache_n_op_enqueue;
58100 +atomic_unchecked_t fscache_n_op_requeue;
58101 +atomic_unchecked_t fscache_n_op_deferred_release;
58102 +atomic_unchecked_t fscache_n_op_release;
58103 +atomic_unchecked_t fscache_n_op_gc;
58104 +atomic_unchecked_t fscache_n_op_cancelled;
58105 +atomic_unchecked_t fscache_n_op_rejected;
58106
58107 -atomic_t fscache_n_attr_changed;
58108 -atomic_t fscache_n_attr_changed_ok;
58109 -atomic_t fscache_n_attr_changed_nobufs;
58110 -atomic_t fscache_n_attr_changed_nomem;
58111 -atomic_t fscache_n_attr_changed_calls;
58112 +atomic_unchecked_t fscache_n_attr_changed;
58113 +atomic_unchecked_t fscache_n_attr_changed_ok;
58114 +atomic_unchecked_t fscache_n_attr_changed_nobufs;
58115 +atomic_unchecked_t fscache_n_attr_changed_nomem;
58116 +atomic_unchecked_t fscache_n_attr_changed_calls;
58117
58118 -atomic_t fscache_n_allocs;
58119 -atomic_t fscache_n_allocs_ok;
58120 -atomic_t fscache_n_allocs_wait;
58121 -atomic_t fscache_n_allocs_nobufs;
58122 -atomic_t fscache_n_allocs_intr;
58123 -atomic_t fscache_n_allocs_object_dead;
58124 -atomic_t fscache_n_alloc_ops;
58125 -atomic_t fscache_n_alloc_op_waits;
58126 +atomic_unchecked_t fscache_n_allocs;
58127 +atomic_unchecked_t fscache_n_allocs_ok;
58128 +atomic_unchecked_t fscache_n_allocs_wait;
58129 +atomic_unchecked_t fscache_n_allocs_nobufs;
58130 +atomic_unchecked_t fscache_n_allocs_intr;
58131 +atomic_unchecked_t fscache_n_allocs_object_dead;
58132 +atomic_unchecked_t fscache_n_alloc_ops;
58133 +atomic_unchecked_t fscache_n_alloc_op_waits;
58134
58135 -atomic_t fscache_n_retrievals;
58136 -atomic_t fscache_n_retrievals_ok;
58137 -atomic_t fscache_n_retrievals_wait;
58138 -atomic_t fscache_n_retrievals_nodata;
58139 -atomic_t fscache_n_retrievals_nobufs;
58140 -atomic_t fscache_n_retrievals_intr;
58141 -atomic_t fscache_n_retrievals_nomem;
58142 -atomic_t fscache_n_retrievals_object_dead;
58143 -atomic_t fscache_n_retrieval_ops;
58144 -atomic_t fscache_n_retrieval_op_waits;
58145 +atomic_unchecked_t fscache_n_retrievals;
58146 +atomic_unchecked_t fscache_n_retrievals_ok;
58147 +atomic_unchecked_t fscache_n_retrievals_wait;
58148 +atomic_unchecked_t fscache_n_retrievals_nodata;
58149 +atomic_unchecked_t fscache_n_retrievals_nobufs;
58150 +atomic_unchecked_t fscache_n_retrievals_intr;
58151 +atomic_unchecked_t fscache_n_retrievals_nomem;
58152 +atomic_unchecked_t fscache_n_retrievals_object_dead;
58153 +atomic_unchecked_t fscache_n_retrieval_ops;
58154 +atomic_unchecked_t fscache_n_retrieval_op_waits;
58155
58156 -atomic_t fscache_n_stores;
58157 -atomic_t fscache_n_stores_ok;
58158 -atomic_t fscache_n_stores_again;
58159 -atomic_t fscache_n_stores_nobufs;
58160 -atomic_t fscache_n_stores_oom;
58161 -atomic_t fscache_n_store_ops;
58162 -atomic_t fscache_n_store_calls;
58163 -atomic_t fscache_n_store_pages;
58164 -atomic_t fscache_n_store_radix_deletes;
58165 -atomic_t fscache_n_store_pages_over_limit;
58166 +atomic_unchecked_t fscache_n_stores;
58167 +atomic_unchecked_t fscache_n_stores_ok;
58168 +atomic_unchecked_t fscache_n_stores_again;
58169 +atomic_unchecked_t fscache_n_stores_nobufs;
58170 +atomic_unchecked_t fscache_n_stores_oom;
58171 +atomic_unchecked_t fscache_n_store_ops;
58172 +atomic_unchecked_t fscache_n_store_calls;
58173 +atomic_unchecked_t fscache_n_store_pages;
58174 +atomic_unchecked_t fscache_n_store_radix_deletes;
58175 +atomic_unchecked_t fscache_n_store_pages_over_limit;
58176
58177 -atomic_t fscache_n_store_vmscan_not_storing;
58178 -atomic_t fscache_n_store_vmscan_gone;
58179 -atomic_t fscache_n_store_vmscan_busy;
58180 -atomic_t fscache_n_store_vmscan_cancelled;
58181 -atomic_t fscache_n_store_vmscan_wait;
58182 +atomic_unchecked_t fscache_n_store_vmscan_not_storing;
58183 +atomic_unchecked_t fscache_n_store_vmscan_gone;
58184 +atomic_unchecked_t fscache_n_store_vmscan_busy;
58185 +atomic_unchecked_t fscache_n_store_vmscan_cancelled;
58186 +atomic_unchecked_t fscache_n_store_vmscan_wait;
58187
58188 -atomic_t fscache_n_marks;
58189 -atomic_t fscache_n_uncaches;
58190 +atomic_unchecked_t fscache_n_marks;
58191 +atomic_unchecked_t fscache_n_uncaches;
58192
58193 -atomic_t fscache_n_acquires;
58194 -atomic_t fscache_n_acquires_null;
58195 -atomic_t fscache_n_acquires_no_cache;
58196 -atomic_t fscache_n_acquires_ok;
58197 -atomic_t fscache_n_acquires_nobufs;
58198 -atomic_t fscache_n_acquires_oom;
58199 +atomic_unchecked_t fscache_n_acquires;
58200 +atomic_unchecked_t fscache_n_acquires_null;
58201 +atomic_unchecked_t fscache_n_acquires_no_cache;
58202 +atomic_unchecked_t fscache_n_acquires_ok;
58203 +atomic_unchecked_t fscache_n_acquires_nobufs;
58204 +atomic_unchecked_t fscache_n_acquires_oom;
58205
58206 -atomic_t fscache_n_invalidates;
58207 -atomic_t fscache_n_invalidates_run;
58208 +atomic_unchecked_t fscache_n_invalidates;
58209 +atomic_unchecked_t fscache_n_invalidates_run;
58210
58211 -atomic_t fscache_n_updates;
58212 -atomic_t fscache_n_updates_null;
58213 -atomic_t fscache_n_updates_run;
58214 +atomic_unchecked_t fscache_n_updates;
58215 +atomic_unchecked_t fscache_n_updates_null;
58216 +atomic_unchecked_t fscache_n_updates_run;
58217
58218 -atomic_t fscache_n_relinquishes;
58219 -atomic_t fscache_n_relinquishes_null;
58220 -atomic_t fscache_n_relinquishes_waitcrt;
58221 -atomic_t fscache_n_relinquishes_retire;
58222 +atomic_unchecked_t fscache_n_relinquishes;
58223 +atomic_unchecked_t fscache_n_relinquishes_null;
58224 +atomic_unchecked_t fscache_n_relinquishes_waitcrt;
58225 +atomic_unchecked_t fscache_n_relinquishes_retire;
58226
58227 -atomic_t fscache_n_cookie_index;
58228 -atomic_t fscache_n_cookie_data;
58229 -atomic_t fscache_n_cookie_special;
58230 +atomic_unchecked_t fscache_n_cookie_index;
58231 +atomic_unchecked_t fscache_n_cookie_data;
58232 +atomic_unchecked_t fscache_n_cookie_special;
58233
58234 -atomic_t fscache_n_object_alloc;
58235 -atomic_t fscache_n_object_no_alloc;
58236 -atomic_t fscache_n_object_lookups;
58237 -atomic_t fscache_n_object_lookups_negative;
58238 -atomic_t fscache_n_object_lookups_positive;
58239 -atomic_t fscache_n_object_lookups_timed_out;
58240 -atomic_t fscache_n_object_created;
58241 -atomic_t fscache_n_object_avail;
58242 -atomic_t fscache_n_object_dead;
58243 +atomic_unchecked_t fscache_n_object_alloc;
58244 +atomic_unchecked_t fscache_n_object_no_alloc;
58245 +atomic_unchecked_t fscache_n_object_lookups;
58246 +atomic_unchecked_t fscache_n_object_lookups_negative;
58247 +atomic_unchecked_t fscache_n_object_lookups_positive;
58248 +atomic_unchecked_t fscache_n_object_lookups_timed_out;
58249 +atomic_unchecked_t fscache_n_object_created;
58250 +atomic_unchecked_t fscache_n_object_avail;
58251 +atomic_unchecked_t fscache_n_object_dead;
58252
58253 -atomic_t fscache_n_checkaux_none;
58254 -atomic_t fscache_n_checkaux_okay;
58255 -atomic_t fscache_n_checkaux_update;
58256 -atomic_t fscache_n_checkaux_obsolete;
58257 +atomic_unchecked_t fscache_n_checkaux_none;
58258 +atomic_unchecked_t fscache_n_checkaux_okay;
58259 +atomic_unchecked_t fscache_n_checkaux_update;
58260 +atomic_unchecked_t fscache_n_checkaux_obsolete;
58261
58262 atomic_t fscache_n_cop_alloc_object;
58263 atomic_t fscache_n_cop_lookup_object;
58264 @@ -138,118 +138,118 @@ static int fscache_stats_show(struct seq_file *m, void *v)
58265 seq_puts(m, "FS-Cache statistics\n");
58266
58267 seq_printf(m, "Cookies: idx=%u dat=%u spc=%u\n",
58268 - atomic_read(&fscache_n_cookie_index),
58269 - atomic_read(&fscache_n_cookie_data),
58270 - atomic_read(&fscache_n_cookie_special));
58271 + atomic_read_unchecked(&fscache_n_cookie_index),
58272 + atomic_read_unchecked(&fscache_n_cookie_data),
58273 + atomic_read_unchecked(&fscache_n_cookie_special));
58274
58275 seq_printf(m, "Objects: alc=%u nal=%u avl=%u ded=%u\n",
58276 - atomic_read(&fscache_n_object_alloc),
58277 - atomic_read(&fscache_n_object_no_alloc),
58278 - atomic_read(&fscache_n_object_avail),
58279 - atomic_read(&fscache_n_object_dead));
58280 + atomic_read_unchecked(&fscache_n_object_alloc),
58281 + atomic_read_unchecked(&fscache_n_object_no_alloc),
58282 + atomic_read_unchecked(&fscache_n_object_avail),
58283 + atomic_read_unchecked(&fscache_n_object_dead));
58284 seq_printf(m, "ChkAux : non=%u ok=%u upd=%u obs=%u\n",
58285 - atomic_read(&fscache_n_checkaux_none),
58286 - atomic_read(&fscache_n_checkaux_okay),
58287 - atomic_read(&fscache_n_checkaux_update),
58288 - atomic_read(&fscache_n_checkaux_obsolete));
58289 + atomic_read_unchecked(&fscache_n_checkaux_none),
58290 + atomic_read_unchecked(&fscache_n_checkaux_okay),
58291 + atomic_read_unchecked(&fscache_n_checkaux_update),
58292 + atomic_read_unchecked(&fscache_n_checkaux_obsolete));
58293
58294 seq_printf(m, "Pages : mrk=%u unc=%u\n",
58295 - atomic_read(&fscache_n_marks),
58296 - atomic_read(&fscache_n_uncaches));
58297 + atomic_read_unchecked(&fscache_n_marks),
58298 + atomic_read_unchecked(&fscache_n_uncaches));
58299
58300 seq_printf(m, "Acquire: n=%u nul=%u noc=%u ok=%u nbf=%u"
58301 " oom=%u\n",
58302 - atomic_read(&fscache_n_acquires),
58303 - atomic_read(&fscache_n_acquires_null),
58304 - atomic_read(&fscache_n_acquires_no_cache),
58305 - atomic_read(&fscache_n_acquires_ok),
58306 - atomic_read(&fscache_n_acquires_nobufs),
58307 - atomic_read(&fscache_n_acquires_oom));
58308 + atomic_read_unchecked(&fscache_n_acquires),
58309 + atomic_read_unchecked(&fscache_n_acquires_null),
58310 + atomic_read_unchecked(&fscache_n_acquires_no_cache),
58311 + atomic_read_unchecked(&fscache_n_acquires_ok),
58312 + atomic_read_unchecked(&fscache_n_acquires_nobufs),
58313 + atomic_read_unchecked(&fscache_n_acquires_oom));
58314
58315 seq_printf(m, "Lookups: n=%u neg=%u pos=%u crt=%u tmo=%u\n",
58316 - atomic_read(&fscache_n_object_lookups),
58317 - atomic_read(&fscache_n_object_lookups_negative),
58318 - atomic_read(&fscache_n_object_lookups_positive),
58319 - atomic_read(&fscache_n_object_created),
58320 - atomic_read(&fscache_n_object_lookups_timed_out));
58321 + atomic_read_unchecked(&fscache_n_object_lookups),
58322 + atomic_read_unchecked(&fscache_n_object_lookups_negative),
58323 + atomic_read_unchecked(&fscache_n_object_lookups_positive),
58324 + atomic_read_unchecked(&fscache_n_object_created),
58325 + atomic_read_unchecked(&fscache_n_object_lookups_timed_out));
58326
58327 seq_printf(m, "Invals : n=%u run=%u\n",
58328 - atomic_read(&fscache_n_invalidates),
58329 - atomic_read(&fscache_n_invalidates_run));
58330 + atomic_read_unchecked(&fscache_n_invalidates),
58331 + atomic_read_unchecked(&fscache_n_invalidates_run));
58332
58333 seq_printf(m, "Updates: n=%u nul=%u run=%u\n",
58334 - atomic_read(&fscache_n_updates),
58335 - atomic_read(&fscache_n_updates_null),
58336 - atomic_read(&fscache_n_updates_run));
58337 + atomic_read_unchecked(&fscache_n_updates),
58338 + atomic_read_unchecked(&fscache_n_updates_null),
58339 + atomic_read_unchecked(&fscache_n_updates_run));
58340
58341 seq_printf(m, "Relinqs: n=%u nul=%u wcr=%u rtr=%u\n",
58342 - atomic_read(&fscache_n_relinquishes),
58343 - atomic_read(&fscache_n_relinquishes_null),
58344 - atomic_read(&fscache_n_relinquishes_waitcrt),
58345 - atomic_read(&fscache_n_relinquishes_retire));
58346 + atomic_read_unchecked(&fscache_n_relinquishes),
58347 + atomic_read_unchecked(&fscache_n_relinquishes_null),
58348 + atomic_read_unchecked(&fscache_n_relinquishes_waitcrt),
58349 + atomic_read_unchecked(&fscache_n_relinquishes_retire));
58350
58351 seq_printf(m, "AttrChg: n=%u ok=%u nbf=%u oom=%u run=%u\n",
58352 - atomic_read(&fscache_n_attr_changed),
58353 - atomic_read(&fscache_n_attr_changed_ok),
58354 - atomic_read(&fscache_n_attr_changed_nobufs),
58355 - atomic_read(&fscache_n_attr_changed_nomem),
58356 - atomic_read(&fscache_n_attr_changed_calls));
58357 + atomic_read_unchecked(&fscache_n_attr_changed),
58358 + atomic_read_unchecked(&fscache_n_attr_changed_ok),
58359 + atomic_read_unchecked(&fscache_n_attr_changed_nobufs),
58360 + atomic_read_unchecked(&fscache_n_attr_changed_nomem),
58361 + atomic_read_unchecked(&fscache_n_attr_changed_calls));
58362
58363 seq_printf(m, "Allocs : n=%u ok=%u wt=%u nbf=%u int=%u\n",
58364 - atomic_read(&fscache_n_allocs),
58365 - atomic_read(&fscache_n_allocs_ok),
58366 - atomic_read(&fscache_n_allocs_wait),
58367 - atomic_read(&fscache_n_allocs_nobufs),
58368 - atomic_read(&fscache_n_allocs_intr));
58369 + atomic_read_unchecked(&fscache_n_allocs),
58370 + atomic_read_unchecked(&fscache_n_allocs_ok),
58371 + atomic_read_unchecked(&fscache_n_allocs_wait),
58372 + atomic_read_unchecked(&fscache_n_allocs_nobufs),
58373 + atomic_read_unchecked(&fscache_n_allocs_intr));
58374 seq_printf(m, "Allocs : ops=%u owt=%u abt=%u\n",
58375 - atomic_read(&fscache_n_alloc_ops),
58376 - atomic_read(&fscache_n_alloc_op_waits),
58377 - atomic_read(&fscache_n_allocs_object_dead));
58378 + atomic_read_unchecked(&fscache_n_alloc_ops),
58379 + atomic_read_unchecked(&fscache_n_alloc_op_waits),
58380 + atomic_read_unchecked(&fscache_n_allocs_object_dead));
58381
58382 seq_printf(m, "Retrvls: n=%u ok=%u wt=%u nod=%u nbf=%u"
58383 " int=%u oom=%u\n",
58384 - atomic_read(&fscache_n_retrievals),
58385 - atomic_read(&fscache_n_retrievals_ok),
58386 - atomic_read(&fscache_n_retrievals_wait),
58387 - atomic_read(&fscache_n_retrievals_nodata),
58388 - atomic_read(&fscache_n_retrievals_nobufs),
58389 - atomic_read(&fscache_n_retrievals_intr),
58390 - atomic_read(&fscache_n_retrievals_nomem));
58391 + atomic_read_unchecked(&fscache_n_retrievals),
58392 + atomic_read_unchecked(&fscache_n_retrievals_ok),
58393 + atomic_read_unchecked(&fscache_n_retrievals_wait),
58394 + atomic_read_unchecked(&fscache_n_retrievals_nodata),
58395 + atomic_read_unchecked(&fscache_n_retrievals_nobufs),
58396 + atomic_read_unchecked(&fscache_n_retrievals_intr),
58397 + atomic_read_unchecked(&fscache_n_retrievals_nomem));
58398 seq_printf(m, "Retrvls: ops=%u owt=%u abt=%u\n",
58399 - atomic_read(&fscache_n_retrieval_ops),
58400 - atomic_read(&fscache_n_retrieval_op_waits),
58401 - atomic_read(&fscache_n_retrievals_object_dead));
58402 + atomic_read_unchecked(&fscache_n_retrieval_ops),
58403 + atomic_read_unchecked(&fscache_n_retrieval_op_waits),
58404 + atomic_read_unchecked(&fscache_n_retrievals_object_dead));
58405
58406 seq_printf(m, "Stores : n=%u ok=%u agn=%u nbf=%u oom=%u\n",
58407 - atomic_read(&fscache_n_stores),
58408 - atomic_read(&fscache_n_stores_ok),
58409 - atomic_read(&fscache_n_stores_again),
58410 - atomic_read(&fscache_n_stores_nobufs),
58411 - atomic_read(&fscache_n_stores_oom));
58412 + atomic_read_unchecked(&fscache_n_stores),
58413 + atomic_read_unchecked(&fscache_n_stores_ok),
58414 + atomic_read_unchecked(&fscache_n_stores_again),
58415 + atomic_read_unchecked(&fscache_n_stores_nobufs),
58416 + atomic_read_unchecked(&fscache_n_stores_oom));
58417 seq_printf(m, "Stores : ops=%u run=%u pgs=%u rxd=%u olm=%u\n",
58418 - atomic_read(&fscache_n_store_ops),
58419 - atomic_read(&fscache_n_store_calls),
58420 - atomic_read(&fscache_n_store_pages),
58421 - atomic_read(&fscache_n_store_radix_deletes),
58422 - atomic_read(&fscache_n_store_pages_over_limit));
58423 + atomic_read_unchecked(&fscache_n_store_ops),
58424 + atomic_read_unchecked(&fscache_n_store_calls),
58425 + atomic_read_unchecked(&fscache_n_store_pages),
58426 + atomic_read_unchecked(&fscache_n_store_radix_deletes),
58427 + atomic_read_unchecked(&fscache_n_store_pages_over_limit));
58428
58429 seq_printf(m, "VmScan : nos=%u gon=%u bsy=%u can=%u wt=%u\n",
58430 - atomic_read(&fscache_n_store_vmscan_not_storing),
58431 - atomic_read(&fscache_n_store_vmscan_gone),
58432 - atomic_read(&fscache_n_store_vmscan_busy),
58433 - atomic_read(&fscache_n_store_vmscan_cancelled),
58434 - atomic_read(&fscache_n_store_vmscan_wait));
58435 + atomic_read_unchecked(&fscache_n_store_vmscan_not_storing),
58436 + atomic_read_unchecked(&fscache_n_store_vmscan_gone),
58437 + atomic_read_unchecked(&fscache_n_store_vmscan_busy),
58438 + atomic_read_unchecked(&fscache_n_store_vmscan_cancelled),
58439 + atomic_read_unchecked(&fscache_n_store_vmscan_wait));
58440
58441 seq_printf(m, "Ops : pend=%u run=%u enq=%u can=%u rej=%u\n",
58442 - atomic_read(&fscache_n_op_pend),
58443 - atomic_read(&fscache_n_op_run),
58444 - atomic_read(&fscache_n_op_enqueue),
58445 - atomic_read(&fscache_n_op_cancelled),
58446 - atomic_read(&fscache_n_op_rejected));
58447 + atomic_read_unchecked(&fscache_n_op_pend),
58448 + atomic_read_unchecked(&fscache_n_op_run),
58449 + atomic_read_unchecked(&fscache_n_op_enqueue),
58450 + atomic_read_unchecked(&fscache_n_op_cancelled),
58451 + atomic_read_unchecked(&fscache_n_op_rejected));
58452 seq_printf(m, "Ops : dfr=%u rel=%u gc=%u\n",
58453 - atomic_read(&fscache_n_op_deferred_release),
58454 - atomic_read(&fscache_n_op_release),
58455 - atomic_read(&fscache_n_op_gc));
58456 + atomic_read_unchecked(&fscache_n_op_deferred_release),
58457 + atomic_read_unchecked(&fscache_n_op_release),
58458 + atomic_read_unchecked(&fscache_n_op_gc));
58459
58460 seq_printf(m, "CacheOp: alo=%d luo=%d luc=%d gro=%d\n",
58461 atomic_read(&fscache_n_cop_alloc_object),
58462 diff --git a/fs/fuse/cuse.c b/fs/fuse/cuse.c
58463 index adbfd66..4b25822 100644
58464 --- a/fs/fuse/cuse.c
58465 +++ b/fs/fuse/cuse.c
58466 @@ -603,10 +603,12 @@ static int __init cuse_init(void)
58467 INIT_LIST_HEAD(&cuse_conntbl[i]);
58468
58469 /* inherit and extend fuse_dev_operations */
58470 - cuse_channel_fops = fuse_dev_operations;
58471 - cuse_channel_fops.owner = THIS_MODULE;
58472 - cuse_channel_fops.open = cuse_channel_open;
58473 - cuse_channel_fops.release = cuse_channel_release;
58474 + pax_open_kernel();
58475 + memcpy((void *)&cuse_channel_fops, &fuse_dev_operations, sizeof(fuse_dev_operations));
58476 + *(void **)&cuse_channel_fops.owner = THIS_MODULE;
58477 + *(void **)&cuse_channel_fops.open = cuse_channel_open;
58478 + *(void **)&cuse_channel_fops.release = cuse_channel_release;
58479 + pax_close_kernel();
58480
58481 cuse_class = class_create(THIS_MODULE, "cuse");
58482 if (IS_ERR(cuse_class))
58483 diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
58484 index ef74ad5..c9ac759e 100644
58485 --- a/fs/fuse/dev.c
58486 +++ b/fs/fuse/dev.c
58487 @@ -1339,7 +1339,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58488 ret = 0;
58489 pipe_lock(pipe);
58490
58491 - if (!pipe->readers) {
58492 + if (!atomic_read(&pipe->readers)) {
58493 send_sig(SIGPIPE, current, 0);
58494 if (!ret)
58495 ret = -EPIPE;
58496 @@ -1364,7 +1364,7 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos,
58497 page_nr++;
58498 ret += buf->len;
58499
58500 - if (pipe->files)
58501 + if (atomic_read(&pipe->files))
58502 do_wakeup = 1;
58503 }
58504
58505 diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
58506 index b7989f2..1f72ec4 100644
58507 --- a/fs/fuse/dir.c
58508 +++ b/fs/fuse/dir.c
58509 @@ -1438,7 +1438,7 @@ static char *read_link(struct dentry *dentry)
58510 return link;
58511 }
58512
58513 -static void free_link(char *link)
58514 +static void free_link(const char *link)
58515 {
58516 if (!IS_ERR(link))
58517 free_page((unsigned long) link);
58518 diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c
58519 index 1298766..c964c60 100644
58520 --- a/fs/gfs2/inode.c
58521 +++ b/fs/gfs2/inode.c
58522 @@ -1515,7 +1515,7 @@ out:
58523
58524 static void gfs2_put_link(struct dentry *dentry, struct nameidata *nd, void *p)
58525 {
58526 - char *s = nd_get_link(nd);
58527 + const char *s = nd_get_link(nd);
58528 if (!IS_ERR(s))
58529 kfree(s);
58530 }
58531 diff --git a/fs/hostfs/hostfs_kern.c b/fs/hostfs/hostfs_kern.c
58532 index 2543728..14d7bd4 100644
58533 --- a/fs/hostfs/hostfs_kern.c
58534 +++ b/fs/hostfs/hostfs_kern.c
58535 @@ -904,7 +904,7 @@ static void *hostfs_follow_link(struct dentry *dentry, struct nameidata *nd)
58536
58537 static void hostfs_put_link(struct dentry *dentry, struct nameidata *nd, void *cookie)
58538 {
58539 - char *s = nd_get_link(nd);
58540 + const char *s = nd_get_link(nd);
58541 if (!IS_ERR(s))
58542 __putname(s);
58543 }
58544 diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
58545 index d19b30a..ef89c36 100644
58546 --- a/fs/hugetlbfs/inode.c
58547 +++ b/fs/hugetlbfs/inode.c
58548 @@ -152,6 +152,7 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58549 struct mm_struct *mm = current->mm;
58550 struct vm_area_struct *vma;
58551 struct hstate *h = hstate_file(file);
58552 + unsigned long offset = gr_rand_threadstack_offset(mm, file, flags);
58553 struct vm_unmapped_area_info info;
58554
58555 if (len & ~huge_page_mask(h))
58556 @@ -165,17 +166,26 @@ hugetlb_get_unmapped_area(struct file *file, unsigned long addr,
58557 return addr;
58558 }
58559
58560 +#ifdef CONFIG_PAX_RANDMMAP
58561 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
58562 +#endif
58563 +
58564 if (addr) {
58565 addr = ALIGN(addr, huge_page_size(h));
58566 vma = find_vma(mm, addr);
58567 - if (TASK_SIZE - len >= addr &&
58568 - (!vma || addr + len <= vma->vm_start))
58569 + if (TASK_SIZE - len >= addr && check_heap_stack_gap(vma, addr, len, offset))
58570 return addr;
58571 }
58572
58573 info.flags = 0;
58574 info.length = len;
58575 info.low_limit = TASK_UNMAPPED_BASE;
58576 +
58577 +#ifdef CONFIG_PAX_RANDMMAP
58578 + if (mm->pax_flags & MF_PAX_RANDMMAP)
58579 + info.low_limit += mm->delta_mmap;
58580 +#endif
58581 +
58582 info.high_limit = TASK_SIZE;
58583 info.align_mask = PAGE_MASK & ~huge_page_mask(h);
58584 info.align_offset = 0;
58585 @@ -908,7 +918,7 @@ static struct file_system_type hugetlbfs_fs_type = {
58586 };
58587 MODULE_ALIAS_FS("hugetlbfs");
58588
58589 -static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58590 +struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
58591
58592 static int can_do_hugetlb_shm(void)
58593 {
58594 diff --git a/fs/inode.c b/fs/inode.c
58595 index b33ba8e..3c79a47 100644
58596 --- a/fs/inode.c
58597 +++ b/fs/inode.c
58598 @@ -849,8 +849,8 @@ unsigned int get_next_ino(void)
58599
58600 #ifdef CONFIG_SMP
58601 if (unlikely((res & (LAST_INO_BATCH-1)) == 0)) {
58602 - static atomic_t shared_last_ino;
58603 - int next = atomic_add_return(LAST_INO_BATCH, &shared_last_ino);
58604 + static atomic_unchecked_t shared_last_ino;
58605 + int next = atomic_add_return_unchecked(LAST_INO_BATCH, &shared_last_ino);
58606
58607 res = next - LAST_INO_BATCH;
58608 }
58609 diff --git a/fs/jffs2/erase.c b/fs/jffs2/erase.c
58610 index 4a6cf28..d3a29d3 100644
58611 --- a/fs/jffs2/erase.c
58612 +++ b/fs/jffs2/erase.c
58613 @@ -452,7 +452,8 @@ static void jffs2_mark_erased_block(struct jffs2_sb_info *c, struct jffs2_eraseb
58614 struct jffs2_unknown_node marker = {
58615 .magic = cpu_to_je16(JFFS2_MAGIC_BITMASK),
58616 .nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58617 - .totlen = cpu_to_je32(c->cleanmarker_size)
58618 + .totlen = cpu_to_je32(c->cleanmarker_size),
58619 + .hdr_crc = cpu_to_je32(0)
58620 };
58621
58622 jffs2_prealloc_raw_node_refs(c, jeb, 1);
58623 diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c
58624 index a6597d6..41b30ec 100644
58625 --- a/fs/jffs2/wbuf.c
58626 +++ b/fs/jffs2/wbuf.c
58627 @@ -1023,7 +1023,8 @@ static const struct jffs2_unknown_node oob_cleanmarker =
58628 {
58629 .magic = constant_cpu_to_je16(JFFS2_MAGIC_BITMASK),
58630 .nodetype = constant_cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER),
58631 - .totlen = constant_cpu_to_je32(8)
58632 + .totlen = constant_cpu_to_je32(8),
58633 + .hdr_crc = constant_cpu_to_je32(0)
58634 };
58635
58636 /*
58637 diff --git a/fs/jfs/super.c b/fs/jfs/super.c
58638 index 6669aa2..36b033d 100644
58639 --- a/fs/jfs/super.c
58640 +++ b/fs/jfs/super.c
58641 @@ -882,7 +882,7 @@ static int __init init_jfs_fs(void)
58642
58643 jfs_inode_cachep =
58644 kmem_cache_create("jfs_ip", sizeof(struct jfs_inode_info), 0,
58645 - SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD,
58646 + SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|SLAB_USERCOPY,
58647 init_once);
58648 if (jfs_inode_cachep == NULL)
58649 return -ENOMEM;
58650 diff --git a/fs/libfs.c b/fs/libfs.c
58651 index 193e0c2..7404665 100644
58652 --- a/fs/libfs.c
58653 +++ b/fs/libfs.c
58654 @@ -150,6 +150,9 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
58655
58656 for (p = q->next; p != &dentry->d_subdirs; p = p->next) {
58657 struct dentry *next = list_entry(p, struct dentry, d_u.d_child);
58658 + char d_name[sizeof(next->d_iname)];
58659 + const unsigned char *name;
58660 +
58661 spin_lock_nested(&next->d_lock, DENTRY_D_LOCK_NESTED);
58662 if (!simple_positive(next)) {
58663 spin_unlock(&next->d_lock);
58664 @@ -158,7 +161,12 @@ int dcache_readdir(struct file *file, struct dir_context *ctx)
58665
58666 spin_unlock(&next->d_lock);
58667 spin_unlock(&dentry->d_lock);
58668 - if (!dir_emit(ctx, next->d_name.name, next->d_name.len,
58669 + name = next->d_name.name;
58670 + if (name == next->d_iname) {
58671 + memcpy(d_name, name, next->d_name.len);
58672 + name = d_name;
58673 + }
58674 + if (!dir_emit(ctx, name, next->d_name.len,
58675 next->d_inode->i_ino, dt_type(next->d_inode)))
58676 return 0;
58677 spin_lock(&dentry->d_lock);
58678 diff --git a/fs/lockd/clntproc.c b/fs/lockd/clntproc.c
58679 index acd3947..1f896e2 100644
58680 --- a/fs/lockd/clntproc.c
58681 +++ b/fs/lockd/clntproc.c
58682 @@ -36,11 +36,11 @@ static const struct rpc_call_ops nlmclnt_cancel_ops;
58683 /*
58684 * Cookie counter for NLM requests
58685 */
58686 -static atomic_t nlm_cookie = ATOMIC_INIT(0x1234);
58687 +static atomic_unchecked_t nlm_cookie = ATOMIC_INIT(0x1234);
58688
58689 void nlmclnt_next_cookie(struct nlm_cookie *c)
58690 {
58691 - u32 cookie = atomic_inc_return(&nlm_cookie);
58692 + u32 cookie = atomic_inc_return_unchecked(&nlm_cookie);
58693
58694 memcpy(c->data, &cookie, 4);
58695 c->len=4;
58696 diff --git a/fs/locks.c b/fs/locks.c
58697 index b27a300..4156d0b 100644
58698 --- a/fs/locks.c
58699 +++ b/fs/locks.c
58700 @@ -2183,16 +2183,16 @@ void locks_remove_flock(struct file *filp)
58701 return;
58702
58703 if (filp->f_op && filp->f_op->flock) {
58704 - struct file_lock fl = {
58705 + struct file_lock flock = {
58706 .fl_pid = current->tgid,
58707 .fl_file = filp,
58708 .fl_flags = FL_FLOCK,
58709 .fl_type = F_UNLCK,
58710 .fl_end = OFFSET_MAX,
58711 };
58712 - filp->f_op->flock(filp, F_SETLKW, &fl);
58713 - if (fl.fl_ops && fl.fl_ops->fl_release_private)
58714 - fl.fl_ops->fl_release_private(&fl);
58715 + filp->f_op->flock(filp, F_SETLKW, &flock);
58716 + if (flock.fl_ops && flock.fl_ops->fl_release_private)
58717 + flock.fl_ops->fl_release_private(&flock);
58718 }
58719
58720 spin_lock(&inode->i_lock);
58721 diff --git a/fs/namei.c b/fs/namei.c
58722 index 23ac50f..c6757a5 100644
58723 --- a/fs/namei.c
58724 +++ b/fs/namei.c
58725 @@ -319,16 +319,32 @@ int generic_permission(struct inode *inode, int mask)
58726 if (ret != -EACCES)
58727 return ret;
58728
58729 +#ifdef CONFIG_GRKERNSEC
58730 + /* we'll block if we have to log due to a denied capability use */
58731 + if (mask & MAY_NOT_BLOCK)
58732 + return -ECHILD;
58733 +#endif
58734 +
58735 if (S_ISDIR(inode->i_mode)) {
58736 /* DACs are overridable for directories */
58737 - if (inode_capable(inode, CAP_DAC_OVERRIDE))
58738 - return 0;
58739 if (!(mask & MAY_WRITE))
58740 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58741 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58742 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58743 return 0;
58744 + if (inode_capable(inode, CAP_DAC_OVERRIDE))
58745 + return 0;
58746 return -EACCES;
58747 }
58748 /*
58749 + * Searching includes executable on directories, else just read.
58750 + */
58751 + mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58752 + if (mask == MAY_READ)
58753 + if (inode_capable_nolog(inode, CAP_DAC_OVERRIDE) ||
58754 + inode_capable(inode, CAP_DAC_READ_SEARCH))
58755 + return 0;
58756 +
58757 + /*
58758 * Read/write DACs are always overridable.
58759 * Executable DACs are overridable when there is
58760 * at least one exec bit set.
58761 @@ -337,14 +353,6 @@ int generic_permission(struct inode *inode, int mask)
58762 if (inode_capable(inode, CAP_DAC_OVERRIDE))
58763 return 0;
58764
58765 - /*
58766 - * Searching includes executable on directories, else just read.
58767 - */
58768 - mask &= MAY_READ | MAY_WRITE | MAY_EXEC;
58769 - if (mask == MAY_READ)
58770 - if (inode_capable(inode, CAP_DAC_READ_SEARCH))
58771 - return 0;
58772 -
58773 return -EACCES;
58774 }
58775
58776 @@ -821,7 +829,7 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58777 {
58778 struct dentry *dentry = link->dentry;
58779 int error;
58780 - char *s;
58781 + const char *s;
58782
58783 BUG_ON(nd->flags & LOOKUP_RCU);
58784
58785 @@ -842,6 +850,12 @@ follow_link(struct path *link, struct nameidata *nd, void **p)
58786 if (error)
58787 goto out_put_nd_path;
58788
58789 + if (gr_handle_follow_link(dentry->d_parent->d_inode,
58790 + dentry->d_inode, dentry, nd->path.mnt)) {
58791 + error = -EACCES;
58792 + goto out_put_nd_path;
58793 + }
58794 +
58795 nd->last_type = LAST_BIND;
58796 *p = dentry->d_inode->i_op->follow_link(dentry, nd);
58797 error = PTR_ERR(*p);
58798 @@ -1602,6 +1616,8 @@ static inline int nested_symlink(struct path *path, struct nameidata *nd)
58799 if (res)
58800 break;
58801 res = walk_component(nd, path, LOOKUP_FOLLOW);
58802 + if (res >= 0 && gr_handle_symlink_owner(&link, nd->inode))
58803 + res = -EACCES;
58804 put_link(nd, &link, cookie);
58805 } while (res > 0);
58806
58807 @@ -1700,7 +1716,7 @@ EXPORT_SYMBOL(full_name_hash);
58808 static inline unsigned long hash_name(const char *name, unsigned int *hashp)
58809 {
58810 unsigned long a, b, adata, bdata, mask, hash, len;
58811 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58812 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
58813
58814 hash = a = 0;
58815 len = -sizeof(unsigned long);
58816 @@ -1981,6 +1997,8 @@ static int path_lookupat(int dfd, const char *name,
58817 if (err)
58818 break;
58819 err = lookup_last(nd, &path);
58820 + if (!err && gr_handle_symlink_owner(&link, nd->inode))
58821 + err = -EACCES;
58822 put_link(nd, &link, cookie);
58823 }
58824 }
58825 @@ -1988,6 +2006,13 @@ static int path_lookupat(int dfd, const char *name,
58826 if (!err)
58827 err = complete_walk(nd);
58828
58829 + if (!err && !(nd->flags & LOOKUP_PARENT)) {
58830 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58831 + path_put(&nd->path);
58832 + err = -ENOENT;
58833 + }
58834 + }
58835 +
58836 if (!err && nd->flags & LOOKUP_DIRECTORY) {
58837 if (!can_lookup(nd->inode)) {
58838 path_put(&nd->path);
58839 @@ -2015,8 +2040,15 @@ static int filename_lookup(int dfd, struct filename *name,
58840 retval = path_lookupat(dfd, name->name,
58841 flags | LOOKUP_REVAL, nd);
58842
58843 - if (likely(!retval))
58844 + if (likely(!retval)) {
58845 audit_inode(name, nd->path.dentry, flags & LOOKUP_PARENT);
58846 + if (name->name[0] != '/' && nd->path.dentry && nd->inode) {
58847 + if (!gr_chroot_fchdir(nd->path.dentry, nd->path.mnt)) {
58848 + path_put(&nd->path);
58849 + return -ENOENT;
58850 + }
58851 + }
58852 + }
58853 return retval;
58854 }
58855
58856 @@ -2587,6 +2619,13 @@ static int may_open(struct path *path, int acc_mode, int flag)
58857 if (flag & O_NOATIME && !inode_owner_or_capable(inode))
58858 return -EPERM;
58859
58860 + if (gr_handle_rofs_blockwrite(dentry, path->mnt, acc_mode))
58861 + return -EPERM;
58862 + if (gr_handle_rawio(inode))
58863 + return -EPERM;
58864 + if (!gr_acl_handle_open(dentry, path->mnt, acc_mode))
58865 + return -EACCES;
58866 +
58867 return 0;
58868 }
58869
58870 @@ -2818,7 +2857,7 @@ looked_up:
58871 * cleared otherwise prior to returning.
58872 */
58873 static int lookup_open(struct nameidata *nd, struct path *path,
58874 - struct file *file,
58875 + struct path *link, struct file *file,
58876 const struct open_flags *op,
58877 bool got_write, int *opened)
58878 {
58879 @@ -2853,6 +2892,17 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58880 /* Negative dentry, just create the file */
58881 if (!dentry->d_inode && (op->open_flag & O_CREAT)) {
58882 umode_t mode = op->mode;
58883 +
58884 + if (link && gr_handle_symlink_owner(link, dir->d_inode)) {
58885 + error = -EACCES;
58886 + goto out_dput;
58887 + }
58888 +
58889 + if (!gr_acl_handle_creat(dentry, dir, nd->path.mnt, op->open_flag, op->acc_mode, mode)) {
58890 + error = -EACCES;
58891 + goto out_dput;
58892 + }
58893 +
58894 if (!IS_POSIXACL(dir->d_inode))
58895 mode &= ~current_umask();
58896 /*
58897 @@ -2874,6 +2924,8 @@ static int lookup_open(struct nameidata *nd, struct path *path,
58898 nd->flags & LOOKUP_EXCL);
58899 if (error)
58900 goto out_dput;
58901 + else
58902 + gr_handle_create(dentry, nd->path.mnt);
58903 }
58904 out_no_open:
58905 path->dentry = dentry;
58906 @@ -2888,7 +2940,7 @@ out_dput:
58907 /*
58908 * Handle the last step of open()
58909 */
58910 -static int do_last(struct nameidata *nd, struct path *path,
58911 +static int do_last(struct nameidata *nd, struct path *path, struct path *link,
58912 struct file *file, const struct open_flags *op,
58913 int *opened, struct filename *name)
58914 {
58915 @@ -2938,6 +2990,15 @@ static int do_last(struct nameidata *nd, struct path *path,
58916 if (error)
58917 return error;
58918
58919 + if (!gr_acl_handle_hidden_file(dir, nd->path.mnt)) {
58920 + error = -ENOENT;
58921 + goto out;
58922 + }
58923 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
58924 + error = -EACCES;
58925 + goto out;
58926 + }
58927 +
58928 audit_inode(name, dir, LOOKUP_PARENT);
58929 error = -EISDIR;
58930 /* trailing slashes? */
58931 @@ -2957,7 +3018,7 @@ retry_lookup:
58932 */
58933 }
58934 mutex_lock(&dir->d_inode->i_mutex);
58935 - error = lookup_open(nd, path, file, op, got_write, opened);
58936 + error = lookup_open(nd, path, link, file, op, got_write, opened);
58937 mutex_unlock(&dir->d_inode->i_mutex);
58938
58939 if (error <= 0) {
58940 @@ -2981,11 +3042,28 @@ retry_lookup:
58941 goto finish_open_created;
58942 }
58943
58944 + if (!gr_acl_handle_hidden_file(path->dentry, nd->path.mnt)) {
58945 + error = -ENOENT;
58946 + goto exit_dput;
58947 + }
58948 + if (link && gr_handle_symlink_owner(link, path->dentry->d_inode)) {
58949 + error = -EACCES;
58950 + goto exit_dput;
58951 + }
58952 +
58953 /*
58954 * create/update audit record if it already exists.
58955 */
58956 - if (path->dentry->d_inode)
58957 + if (path->dentry->d_inode) {
58958 + /* only check if O_CREAT is specified, all other checks need to go
58959 + into may_open */
58960 + if (gr_handle_fifo(path->dentry, path->mnt, dir, open_flag, acc_mode)) {
58961 + error = -EACCES;
58962 + goto exit_dput;
58963 + }
58964 +
58965 audit_inode(name, path->dentry, 0);
58966 + }
58967
58968 /*
58969 * If atomic_open() acquired write access it is dropped now due to
58970 @@ -3026,6 +3104,11 @@ finish_lookup:
58971 }
58972 }
58973 BUG_ON(inode != path->dentry->d_inode);
58974 + /* if we're resolving a symlink to another symlink */
58975 + if (link && gr_handle_symlink_owner(link, inode)) {
58976 + error = -EACCES;
58977 + goto out;
58978 + }
58979 return 1;
58980 }
58981
58982 @@ -3035,7 +3118,6 @@ finish_lookup:
58983 save_parent.dentry = nd->path.dentry;
58984 save_parent.mnt = mntget(path->mnt);
58985 nd->path.dentry = path->dentry;
58986 -
58987 }
58988 nd->inode = inode;
58989 /* Why this, you ask? _Now_ we might have grown LOOKUP_JUMPED... */
58990 @@ -3045,7 +3127,18 @@ finish_open:
58991 path_put(&save_parent);
58992 return error;
58993 }
58994 +
58995 + if (!gr_acl_handle_hidden_file(nd->path.dentry, nd->path.mnt)) {
58996 + error = -ENOENT;
58997 + goto out;
58998 + }
58999 + if (link && gr_handle_symlink_owner(link, nd->inode)) {
59000 + error = -EACCES;
59001 + goto out;
59002 + }
59003 +
59004 audit_inode(name, nd->path.dentry, 0);
59005 +
59006 error = -EISDIR;
59007 if ((open_flag & O_CREAT) && S_ISDIR(nd->inode->i_mode))
59008 goto out;
59009 @@ -3208,7 +3301,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
59010 if (unlikely(error))
59011 goto out;
59012
59013 - error = do_last(nd, &path, file, op, &opened, pathname);
59014 + error = do_last(nd, &path, NULL, file, op, &opened, pathname);
59015 while (unlikely(error > 0)) { /* trailing symlink */
59016 struct path link = path;
59017 void *cookie;
59018 @@ -3226,7 +3319,7 @@ static struct file *path_openat(int dfd, struct filename *pathname,
59019 error = follow_link(&link, nd, &cookie);
59020 if (unlikely(error))
59021 break;
59022 - error = do_last(nd, &path, file, op, &opened, pathname);
59023 + error = do_last(nd, &path, &link, file, op, &opened, pathname);
59024 put_link(nd, &link, cookie);
59025 }
59026 out:
59027 @@ -3326,8 +3419,12 @@ struct dentry *kern_path_create(int dfd, const char *pathname,
59028 goto unlock;
59029
59030 error = -EEXIST;
59031 - if (dentry->d_inode)
59032 + if (dentry->d_inode) {
59033 + if (!gr_acl_handle_hidden_file(dentry, nd.path.mnt)) {
59034 + error = -ENOENT;
59035 + }
59036 goto fail;
59037 + }
59038 /*
59039 * Special case - lookup gave negative, but... we had foo/bar/
59040 * From the vfs_mknod() POV we just have a negative dentry -
59041 @@ -3379,6 +3476,20 @@ struct dentry *user_path_create(int dfd, const char __user *pathname,
59042 }
59043 EXPORT_SYMBOL(user_path_create);
59044
59045 +static struct dentry *user_path_create_with_name(int dfd, const char __user *pathname, struct path *path, struct filename **to, unsigned int lookup_flags)
59046 +{
59047 + struct filename *tmp = getname(pathname);
59048 + struct dentry *res;
59049 + if (IS_ERR(tmp))
59050 + return ERR_CAST(tmp);
59051 + res = kern_path_create(dfd, tmp->name, path, lookup_flags);
59052 + if (IS_ERR(res))
59053 + putname(tmp);
59054 + else
59055 + *to = tmp;
59056 + return res;
59057 +}
59058 +
59059 int vfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t dev)
59060 {
59061 int error = may_create(dir, dentry);
59062 @@ -3441,6 +3552,17 @@ retry:
59063
59064 if (!IS_POSIXACL(path.dentry->d_inode))
59065 mode &= ~current_umask();
59066 +
59067 + if (gr_handle_chroot_mknod(dentry, path.mnt, mode)) {
59068 + error = -EPERM;
59069 + goto out;
59070 + }
59071 +
59072 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
59073 + error = -EACCES;
59074 + goto out;
59075 + }
59076 +
59077 error = security_path_mknod(&path, dentry, mode, dev);
59078 if (error)
59079 goto out;
59080 @@ -3457,6 +3579,8 @@ retry:
59081 break;
59082 }
59083 out:
59084 + if (!error)
59085 + gr_handle_create(dentry, path.mnt);
59086 done_path_create(&path, dentry);
59087 if (retry_estale(error, lookup_flags)) {
59088 lookup_flags |= LOOKUP_REVAL;
59089 @@ -3509,9 +3633,16 @@ retry:
59090
59091 if (!IS_POSIXACL(path.dentry->d_inode))
59092 mode &= ~current_umask();
59093 + if (!gr_acl_handle_mkdir(dentry, path.dentry, path.mnt)) {
59094 + error = -EACCES;
59095 + goto out;
59096 + }
59097 error = security_path_mkdir(&path, dentry, mode);
59098 if (!error)
59099 error = vfs_mkdir(path.dentry->d_inode, dentry, mode);
59100 + if (!error)
59101 + gr_handle_create(dentry, path.mnt);
59102 +out:
59103 done_path_create(&path, dentry);
59104 if (retry_estale(error, lookup_flags)) {
59105 lookup_flags |= LOOKUP_REVAL;
59106 @@ -3592,6 +3723,8 @@ static long do_rmdir(int dfd, const char __user *pathname)
59107 struct filename *name;
59108 struct dentry *dentry;
59109 struct nameidata nd;
59110 + ino_t saved_ino = 0;
59111 + dev_t saved_dev = 0;
59112 unsigned int lookup_flags = 0;
59113 retry:
59114 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
59115 @@ -3624,10 +3757,21 @@ retry:
59116 error = -ENOENT;
59117 goto exit3;
59118 }
59119 +
59120 + saved_ino = dentry->d_inode->i_ino;
59121 + saved_dev = gr_get_dev_from_dentry(dentry);
59122 +
59123 + if (!gr_acl_handle_rmdir(dentry, nd.path.mnt)) {
59124 + error = -EACCES;
59125 + goto exit3;
59126 + }
59127 +
59128 error = security_path_rmdir(&nd.path, dentry);
59129 if (error)
59130 goto exit3;
59131 error = vfs_rmdir(nd.path.dentry->d_inode, dentry);
59132 + if (!error && (saved_dev || saved_ino))
59133 + gr_handle_delete(saved_ino, saved_dev);
59134 exit3:
59135 dput(dentry);
59136 exit2:
59137 @@ -3693,6 +3837,8 @@ static long do_unlinkat(int dfd, const char __user *pathname)
59138 struct dentry *dentry;
59139 struct nameidata nd;
59140 struct inode *inode = NULL;
59141 + ino_t saved_ino = 0;
59142 + dev_t saved_dev = 0;
59143 unsigned int lookup_flags = 0;
59144 retry:
59145 name = user_path_parent(dfd, pathname, &nd, lookup_flags);
59146 @@ -3719,10 +3865,22 @@ retry:
59147 if (!inode)
59148 goto slashes;
59149 ihold(inode);
59150 +
59151 + if (inode->i_nlink <= 1) {
59152 + saved_ino = inode->i_ino;
59153 + saved_dev = gr_get_dev_from_dentry(dentry);
59154 + }
59155 + if (!gr_acl_handle_unlink(dentry, nd.path.mnt)) {
59156 + error = -EACCES;
59157 + goto exit2;
59158 + }
59159 +
59160 error = security_path_unlink(&nd.path, dentry);
59161 if (error)
59162 goto exit2;
59163 error = vfs_unlink(nd.path.dentry->d_inode, dentry);
59164 + if (!error && (saved_ino || saved_dev))
59165 + gr_handle_delete(saved_ino, saved_dev);
59166 exit2:
59167 dput(dentry);
59168 }
59169 @@ -3800,9 +3958,17 @@ retry:
59170 if (IS_ERR(dentry))
59171 goto out_putname;
59172
59173 + if (!gr_acl_handle_symlink(dentry, path.dentry, path.mnt, from)) {
59174 + error = -EACCES;
59175 + goto out;
59176 + }
59177 +
59178 error = security_path_symlink(&path, dentry, from->name);
59179 if (!error)
59180 error = vfs_symlink(path.dentry->d_inode, dentry, from->name);
59181 + if (!error)
59182 + gr_handle_create(dentry, path.mnt);
59183 +out:
59184 done_path_create(&path, dentry);
59185 if (retry_estale(error, lookup_flags)) {
59186 lookup_flags |= LOOKUP_REVAL;
59187 @@ -3882,6 +4048,7 @@ SYSCALL_DEFINE5(linkat, int, olddfd, const char __user *, oldname,
59188 {
59189 struct dentry *new_dentry;
59190 struct path old_path, new_path;
59191 + struct filename *to = NULL;
59192 int how = 0;
59193 int error;
59194
59195 @@ -3905,7 +4072,7 @@ retry:
59196 if (error)
59197 return error;
59198
59199 - new_dentry = user_path_create(newdfd, newname, &new_path,
59200 + new_dentry = user_path_create_with_name(newdfd, newname, &new_path, &to,
59201 (how & LOOKUP_REVAL));
59202 error = PTR_ERR(new_dentry);
59203 if (IS_ERR(new_dentry))
59204 @@ -3917,11 +4084,28 @@ retry:
59205 error = may_linkat(&old_path);
59206 if (unlikely(error))
59207 goto out_dput;
59208 +
59209 + if (gr_handle_hardlink(old_path.dentry, old_path.mnt,
59210 + old_path.dentry->d_inode,
59211 + old_path.dentry->d_inode->i_mode, to)) {
59212 + error = -EACCES;
59213 + goto out_dput;
59214 + }
59215 +
59216 + if (!gr_acl_handle_link(new_dentry, new_path.dentry, new_path.mnt,
59217 + old_path.dentry, old_path.mnt, to)) {
59218 + error = -EACCES;
59219 + goto out_dput;
59220 + }
59221 +
59222 error = security_path_link(old_path.dentry, &new_path, new_dentry);
59223 if (error)
59224 goto out_dput;
59225 error = vfs_link(old_path.dentry, new_path.dentry->d_inode, new_dentry);
59226 + if (!error)
59227 + gr_handle_create(new_dentry, new_path.mnt);
59228 out_dput:
59229 + putname(to);
59230 done_path_create(&new_path, new_dentry);
59231 if (retry_estale(error, how)) {
59232 how |= LOOKUP_REVAL;
59233 @@ -4167,12 +4351,21 @@ retry:
59234 if (new_dentry == trap)
59235 goto exit5;
59236
59237 + error = gr_acl_handle_rename(new_dentry, new_dir, newnd.path.mnt,
59238 + old_dentry, old_dir->d_inode, oldnd.path.mnt,
59239 + to);
59240 + if (error)
59241 + goto exit5;
59242 +
59243 error = security_path_rename(&oldnd.path, old_dentry,
59244 &newnd.path, new_dentry);
59245 if (error)
59246 goto exit5;
59247 error = vfs_rename(old_dir->d_inode, old_dentry,
59248 new_dir->d_inode, new_dentry);
59249 + if (!error)
59250 + gr_handle_rename(old_dir->d_inode, new_dir->d_inode, old_dentry,
59251 + new_dentry, oldnd.path.mnt, new_dentry->d_inode ? 1 : 0);
59252 exit5:
59253 dput(new_dentry);
59254 exit4:
59255 @@ -4204,6 +4397,8 @@ SYSCALL_DEFINE2(rename, const char __user *, oldname, const char __user *, newna
59256
59257 int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
59258 {
59259 + char tmpbuf[64];
59260 + const char *newlink;
59261 int len;
59262
59263 len = PTR_ERR(link);
59264 @@ -4213,7 +4408,14 @@ int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const c
59265 len = strlen(link);
59266 if (len > (unsigned) buflen)
59267 len = buflen;
59268 - if (copy_to_user(buffer, link, len))
59269 +
59270 + if (len < sizeof(tmpbuf)) {
59271 + memcpy(tmpbuf, link, len);
59272 + newlink = tmpbuf;
59273 + } else
59274 + newlink = link;
59275 +
59276 + if (copy_to_user(buffer, newlink, len))
59277 len = -EFAULT;
59278 out:
59279 return len;
59280 diff --git a/fs/namespace.c b/fs/namespace.c
59281 index da5c494..a755a54 100644
59282 --- a/fs/namespace.c
59283 +++ b/fs/namespace.c
59284 @@ -1268,6 +1268,9 @@ static int do_umount(struct mount *mnt, int flags)
59285 if (!(sb->s_flags & MS_RDONLY))
59286 retval = do_remount_sb(sb, MS_RDONLY, NULL, 0);
59287 up_write(&sb->s_umount);
59288 +
59289 + gr_log_remount(mnt->mnt_devname, retval);
59290 +
59291 return retval;
59292 }
59293
59294 @@ -1286,6 +1289,9 @@ static int do_umount(struct mount *mnt, int flags)
59295 }
59296 br_write_unlock(&vfsmount_lock);
59297 namespace_unlock();
59298 +
59299 + gr_log_unmount(mnt->mnt_devname, retval);
59300 +
59301 return retval;
59302 }
59303
59304 @@ -1305,7 +1311,7 @@ static inline bool may_mount(void)
59305 * unixes. Our API is identical to OSF/1 to avoid making a mess of AMD
59306 */
59307
59308 -SYSCALL_DEFINE2(umount, char __user *, name, int, flags)
59309 +SYSCALL_DEFINE2(umount, const char __user *, name, int, flags)
59310 {
59311 struct path path;
59312 struct mount *mnt;
59313 @@ -1347,7 +1353,7 @@ out:
59314 /*
59315 * The 2.0 compatible umount. No flags.
59316 */
59317 -SYSCALL_DEFINE1(oldumount, char __user *, name)
59318 +SYSCALL_DEFINE1(oldumount, const char __user *, name)
59319 {
59320 return sys_umount(name, 0);
59321 }
59322 @@ -2358,6 +2364,16 @@ long do_mount(const char *dev_name, const char *dir_name,
59323 MS_NOATIME | MS_NODIRATIME | MS_RELATIME| MS_KERNMOUNT |
59324 MS_STRICTATIME);
59325
59326 + if (gr_handle_rofs_mount(path.dentry, path.mnt, mnt_flags)) {
59327 + retval = -EPERM;
59328 + goto dput_out;
59329 + }
59330 +
59331 + if (gr_handle_chroot_mount(path.dentry, path.mnt, dev_name)) {
59332 + retval = -EPERM;
59333 + goto dput_out;
59334 + }
59335 +
59336 if (flags & MS_REMOUNT)
59337 retval = do_remount(&path, flags & ~MS_REMOUNT, mnt_flags,
59338 data_page);
59339 @@ -2372,6 +2388,9 @@ long do_mount(const char *dev_name, const char *dir_name,
59340 dev_name, data_page);
59341 dput_out:
59342 path_put(&path);
59343 +
59344 + gr_log_mount(dev_name, dir_name, retval);
59345 +
59346 return retval;
59347 }
59348
59349 @@ -2389,7 +2408,7 @@ static void free_mnt_ns(struct mnt_namespace *ns)
59350 * number incrementing at 10Ghz will take 12,427 years to wrap which
59351 * is effectively never, so we can ignore the possibility.
59352 */
59353 -static atomic64_t mnt_ns_seq = ATOMIC64_INIT(1);
59354 +static atomic64_unchecked_t mnt_ns_seq = ATOMIC64_INIT(1);
59355
59356 static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59357 {
59358 @@ -2404,7 +2423,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59359 kfree(new_ns);
59360 return ERR_PTR(ret);
59361 }
59362 - new_ns->seq = atomic64_add_return(1, &mnt_ns_seq);
59363 + new_ns->seq = atomic64_inc_return_unchecked(&mnt_ns_seq);
59364 atomic_set(&new_ns->count, 1);
59365 new_ns->root = NULL;
59366 INIT_LIST_HEAD(&new_ns->list);
59367 @@ -2418,7 +2437,7 @@ static struct mnt_namespace *alloc_mnt_ns(struct user_namespace *user_ns)
59368 * Allocate a new namespace structure and populate it with contents
59369 * copied from the namespace of the passed in task structure.
59370 */
59371 -static struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
59372 +static __latent_entropy struct mnt_namespace *dup_mnt_ns(struct mnt_namespace *mnt_ns,
59373 struct user_namespace *user_ns, struct fs_struct *fs)
59374 {
59375 struct mnt_namespace *new_ns;
59376 @@ -2549,8 +2568,8 @@ struct dentry *mount_subtree(struct vfsmount *mnt, const char *name)
59377 }
59378 EXPORT_SYMBOL(mount_subtree);
59379
59380 -SYSCALL_DEFINE5(mount, char __user *, dev_name, char __user *, dir_name,
59381 - char __user *, type, unsigned long, flags, void __user *, data)
59382 +SYSCALL_DEFINE5(mount, const char __user *, dev_name, const char __user *, dir_name,
59383 + const char __user *, type, unsigned long, flags, void __user *, data)
59384 {
59385 int ret;
59386 char *kernel_type;
59387 @@ -2663,6 +2682,11 @@ SYSCALL_DEFINE2(pivot_root, const char __user *, new_root,
59388 if (error)
59389 goto out2;
59390
59391 + if (gr_handle_chroot_pivot()) {
59392 + error = -EPERM;
59393 + goto out2;
59394 + }
59395 +
59396 get_fs_root(current->fs, &root);
59397 old_mp = lock_mount(&old);
59398 error = PTR_ERR(old_mp);
59399 @@ -2932,7 +2956,7 @@ static int mntns_install(struct nsproxy *nsproxy, void *ns)
59400 !ns_capable(current_user_ns(), CAP_SYS_ADMIN))
59401 return -EPERM;
59402
59403 - if (fs->users != 1)
59404 + if (atomic_read(&fs->users) != 1)
59405 return -EINVAL;
59406
59407 get_mnt_ns(mnt_ns);
59408 diff --git a/fs/nfs/callback_xdr.c b/fs/nfs/callback_xdr.c
59409 index f4ccfe6..a5cf064 100644
59410 --- a/fs/nfs/callback_xdr.c
59411 +++ b/fs/nfs/callback_xdr.c
59412 @@ -51,7 +51,7 @@ struct callback_op {
59413 callback_decode_arg_t decode_args;
59414 callback_encode_res_t encode_res;
59415 long res_maxsize;
59416 -};
59417 +} __do_const;
59418
59419 static struct callback_op callback_ops[];
59420
59421 diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c
59422 index eda8879..bfc6837 100644
59423 --- a/fs/nfs/inode.c
59424 +++ b/fs/nfs/inode.c
59425 @@ -1150,16 +1150,16 @@ static int nfs_size_need_update(const struct inode *inode, const struct nfs_fatt
59426 return nfs_size_to_loff_t(fattr->size) > i_size_read(inode);
59427 }
59428
59429 -static atomic_long_t nfs_attr_generation_counter;
59430 +static atomic_long_unchecked_t nfs_attr_generation_counter;
59431
59432 static unsigned long nfs_read_attr_generation_counter(void)
59433 {
59434 - return atomic_long_read(&nfs_attr_generation_counter);
59435 + return atomic_long_read_unchecked(&nfs_attr_generation_counter);
59436 }
59437
59438 unsigned long nfs_inc_attr_generation_counter(void)
59439 {
59440 - return atomic_long_inc_return(&nfs_attr_generation_counter);
59441 + return atomic_long_inc_return_unchecked(&nfs_attr_generation_counter);
59442 }
59443
59444 void nfs_fattr_init(struct nfs_fattr *fattr)
59445 diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c
59446 index 419572f..5414a23 100644
59447 --- a/fs/nfsd/nfs4proc.c
59448 +++ b/fs/nfsd/nfs4proc.c
59449 @@ -1168,7 +1168,7 @@ struct nfsd4_operation {
59450 nfsd4op_rsize op_rsize_bop;
59451 stateid_getter op_get_currentstateid;
59452 stateid_setter op_set_currentstateid;
59453 -};
59454 +} __do_const;
59455
59456 static struct nfsd4_operation nfsd4_ops[];
59457
59458 diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
59459 index ecc735e..79b2d31 100644
59460 --- a/fs/nfsd/nfs4xdr.c
59461 +++ b/fs/nfsd/nfs4xdr.c
59462 @@ -1500,7 +1500,7 @@ nfsd4_decode_notsupp(struct nfsd4_compoundargs *argp, void *p)
59463
59464 typedef __be32(*nfsd4_dec)(struct nfsd4_compoundargs *argp, void *);
59465
59466 -static nfsd4_dec nfsd4_dec_ops[] = {
59467 +static const nfsd4_dec nfsd4_dec_ops[] = {
59468 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59469 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59470 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59471 @@ -1540,7 +1540,7 @@ static nfsd4_dec nfsd4_dec_ops[] = {
59472 [OP_RELEASE_LOCKOWNER] = (nfsd4_dec)nfsd4_decode_release_lockowner,
59473 };
59474
59475 -static nfsd4_dec nfsd41_dec_ops[] = {
59476 +static const nfsd4_dec nfsd41_dec_ops[] = {
59477 [OP_ACCESS] = (nfsd4_dec)nfsd4_decode_access,
59478 [OP_CLOSE] = (nfsd4_dec)nfsd4_decode_close,
59479 [OP_COMMIT] = (nfsd4_dec)nfsd4_decode_commit,
59480 @@ -1602,7 +1602,7 @@ static nfsd4_dec nfsd41_dec_ops[] = {
59481 };
59482
59483 struct nfsd4_minorversion_ops {
59484 - nfsd4_dec *decoders;
59485 + const nfsd4_dec *decoders;
59486 int nops;
59487 };
59488
59489 diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c
59490 index b6af150..f6ec5e3 100644
59491 --- a/fs/nfsd/nfscache.c
59492 +++ b/fs/nfsd/nfscache.c
59493 @@ -547,14 +547,17 @@ nfsd_cache_update(struct svc_rqst *rqstp, int cachetype, __be32 *statp)
59494 {
59495 struct svc_cacherep *rp = rqstp->rq_cacherep;
59496 struct kvec *resv = &rqstp->rq_res.head[0], *cachv;
59497 - int len;
59498 + long len;
59499 size_t bufsize = 0;
59500
59501 if (!rp)
59502 return;
59503
59504 - len = resv->iov_len - ((char*)statp - (char*)resv->iov_base);
59505 - len >>= 2;
59506 + if (statp) {
59507 + len = (char*)statp - (char*)resv->iov_base;
59508 + len = resv->iov_len - len;
59509 + len >>= 2;
59510 + }
59511
59512 /* Don't cache excessive amounts of data and XDR failures */
59513 if (!statp || len > (256 >> 2)) {
59514 diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c
59515 index 72cb28e..5b5f87d 100644
59516 --- a/fs/nfsd/vfs.c
59517 +++ b/fs/nfsd/vfs.c
59518 @@ -993,7 +993,7 @@ nfsd_vfs_read(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59519 } else {
59520 oldfs = get_fs();
59521 set_fs(KERNEL_DS);
59522 - host_err = vfs_readv(file, (struct iovec __user *)vec, vlen, &offset);
59523 + host_err = vfs_readv(file, (struct iovec __force_user *)vec, vlen, &offset);
59524 set_fs(oldfs);
59525 }
59526
59527 @@ -1080,7 +1080,7 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
59528
59529 /* Write the data. */
59530 oldfs = get_fs(); set_fs(KERNEL_DS);
59531 - host_err = vfs_writev(file, (struct iovec __user *)vec, vlen, &pos);
59532 + host_err = vfs_writev(file, (struct iovec __force_user *)vec, vlen, &pos);
59533 set_fs(oldfs);
59534 if (host_err < 0)
59535 goto out_nfserr;
59536 @@ -1626,7 +1626,7 @@ nfsd_readlink(struct svc_rqst *rqstp, struct svc_fh *fhp, char *buf, int *lenp)
59537 */
59538
59539 oldfs = get_fs(); set_fs(KERNEL_DS);
59540 - host_err = inode->i_op->readlink(path.dentry, (char __user *)buf, *lenp);
59541 + host_err = inode->i_op->readlink(path.dentry, (char __force_user *)buf, *lenp);
59542 set_fs(oldfs);
59543
59544 if (host_err < 0)
59545 diff --git a/fs/nls/nls_base.c b/fs/nls/nls_base.c
59546 index fea6bd5..8ee9d81 100644
59547 --- a/fs/nls/nls_base.c
59548 +++ b/fs/nls/nls_base.c
59549 @@ -234,20 +234,22 @@ EXPORT_SYMBOL(utf16s_to_utf8s);
59550
59551 int register_nls(struct nls_table * nls)
59552 {
59553 - struct nls_table ** tmp = &tables;
59554 + struct nls_table *tmp = tables;
59555
59556 if (nls->next)
59557 return -EBUSY;
59558
59559 spin_lock(&nls_lock);
59560 - while (*tmp) {
59561 - if (nls == *tmp) {
59562 + while (tmp) {
59563 + if (nls == tmp) {
59564 spin_unlock(&nls_lock);
59565 return -EBUSY;
59566 }
59567 - tmp = &(*tmp)->next;
59568 + tmp = tmp->next;
59569 }
59570 - nls->next = tables;
59571 + pax_open_kernel();
59572 + *(struct nls_table **)&nls->next = tables;
59573 + pax_close_kernel();
59574 tables = nls;
59575 spin_unlock(&nls_lock);
59576 return 0;
59577 @@ -255,12 +257,14 @@ int register_nls(struct nls_table * nls)
59578
59579 int unregister_nls(struct nls_table * nls)
59580 {
59581 - struct nls_table ** tmp = &tables;
59582 + struct nls_table * const * tmp = &tables;
59583
59584 spin_lock(&nls_lock);
59585 while (*tmp) {
59586 if (nls == *tmp) {
59587 - *tmp = nls->next;
59588 + pax_open_kernel();
59589 + *(struct nls_table **)tmp = nls->next;
59590 + pax_close_kernel();
59591 spin_unlock(&nls_lock);
59592 return 0;
59593 }
59594 diff --git a/fs/nls/nls_euc-jp.c b/fs/nls/nls_euc-jp.c
59595 index 7424929..35f6be5 100644
59596 --- a/fs/nls/nls_euc-jp.c
59597 +++ b/fs/nls/nls_euc-jp.c
59598 @@ -561,8 +561,10 @@ static int __init init_nls_euc_jp(void)
59599 p_nls = load_nls("cp932");
59600
59601 if (p_nls) {
59602 - table.charset2upper = p_nls->charset2upper;
59603 - table.charset2lower = p_nls->charset2lower;
59604 + pax_open_kernel();
59605 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59606 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59607 + pax_close_kernel();
59608 return register_nls(&table);
59609 }
59610
59611 diff --git a/fs/nls/nls_koi8-ru.c b/fs/nls/nls_koi8-ru.c
59612 index e7bc1d7..06bd4bb 100644
59613 --- a/fs/nls/nls_koi8-ru.c
59614 +++ b/fs/nls/nls_koi8-ru.c
59615 @@ -63,8 +63,10 @@ static int __init init_nls_koi8_ru(void)
59616 p_nls = load_nls("koi8-u");
59617
59618 if (p_nls) {
59619 - table.charset2upper = p_nls->charset2upper;
59620 - table.charset2lower = p_nls->charset2lower;
59621 + pax_open_kernel();
59622 + *(const unsigned char **)&table.charset2upper = p_nls->charset2upper;
59623 + *(const unsigned char **)&table.charset2lower = p_nls->charset2lower;
59624 + pax_close_kernel();
59625 return register_nls(&table);
59626 }
59627
59628 diff --git a/fs/notify/fanotify/fanotify_user.c b/fs/notify/fanotify/fanotify_user.c
59629 index e44cb64..4807084 100644
59630 --- a/fs/notify/fanotify/fanotify_user.c
59631 +++ b/fs/notify/fanotify/fanotify_user.c
59632 @@ -253,8 +253,8 @@ static ssize_t copy_event_to_user(struct fsnotify_group *group,
59633
59634 fd = fanotify_event_metadata.fd;
59635 ret = -EFAULT;
59636 - if (copy_to_user(buf, &fanotify_event_metadata,
59637 - fanotify_event_metadata.event_len))
59638 + if (fanotify_event_metadata.event_len > sizeof fanotify_event_metadata ||
59639 + copy_to_user(buf, &fanotify_event_metadata, fanotify_event_metadata.event_len))
59640 goto out_close_fd;
59641
59642 ret = prepare_for_access_response(group, event, fd);
59643 diff --git a/fs/notify/notification.c b/fs/notify/notification.c
59644 index 7b51b05..5ea5ef6 100644
59645 --- a/fs/notify/notification.c
59646 +++ b/fs/notify/notification.c
59647 @@ -57,7 +57,7 @@ static struct kmem_cache *fsnotify_event_holder_cachep;
59648 * get set to 0 so it will never get 'freed'
59649 */
59650 static struct fsnotify_event *q_overflow_event;
59651 -static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59652 +static atomic_unchecked_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59653
59654 /**
59655 * fsnotify_get_cookie - return a unique cookie for use in synchronizing events.
59656 @@ -65,7 +65,7 @@ static atomic_t fsnotify_sync_cookie = ATOMIC_INIT(0);
59657 */
59658 u32 fsnotify_get_cookie(void)
59659 {
59660 - return atomic_inc_return(&fsnotify_sync_cookie);
59661 + return atomic_inc_return_unchecked(&fsnotify_sync_cookie);
59662 }
59663 EXPORT_SYMBOL_GPL(fsnotify_get_cookie);
59664
59665 diff --git a/fs/ntfs/dir.c b/fs/ntfs/dir.c
59666 index 9e38daf..5727cae 100644
59667 --- a/fs/ntfs/dir.c
59668 +++ b/fs/ntfs/dir.c
59669 @@ -1310,7 +1310,7 @@ find_next_index_buffer:
59670 ia = (INDEX_ALLOCATION*)(kaddr + (ia_pos & ~PAGE_CACHE_MASK &
59671 ~(s64)(ndir->itype.index.block_size - 1)));
59672 /* Bounds checks. */
59673 - if (unlikely((u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59674 + if (unlikely(!kaddr || (u8*)ia < kaddr || (u8*)ia > kaddr + PAGE_CACHE_SIZE)) {
59675 ntfs_error(sb, "Out of bounds check failed. Corrupt directory "
59676 "inode 0x%lx or driver bug.", vdir->i_ino);
59677 goto err_out;
59678 diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
59679 index ea4ba9d..1e13d34 100644
59680 --- a/fs/ntfs/file.c
59681 +++ b/fs/ntfs/file.c
59682 @@ -1282,7 +1282,7 @@ static inline size_t ntfs_copy_from_user(struct page **pages,
59683 char *addr;
59684 size_t total = 0;
59685 unsigned len;
59686 - int left;
59687 + unsigned left;
59688
59689 do {
59690 len = PAGE_CACHE_SIZE - ofs;
59691 diff --git a/fs/ntfs/super.c b/fs/ntfs/super.c
59692 index 82650d5..db37dcf 100644
59693 --- a/fs/ntfs/super.c
59694 +++ b/fs/ntfs/super.c
59695 @@ -685,7 +685,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59696 if (!silent)
59697 ntfs_error(sb, "Primary boot sector is invalid.");
59698 } else if (!silent)
59699 - ntfs_error(sb, read_err_str, "primary");
59700 + ntfs_error(sb, read_err_str, "%s", "primary");
59701 if (!(NTFS_SB(sb)->on_errors & ON_ERRORS_RECOVER)) {
59702 if (bh_primary)
59703 brelse(bh_primary);
59704 @@ -701,7 +701,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59705 goto hotfix_primary_boot_sector;
59706 brelse(bh_backup);
59707 } else if (!silent)
59708 - ntfs_error(sb, read_err_str, "backup");
59709 + ntfs_error(sb, read_err_str, "%s", "backup");
59710 /* Try to read NT3.51- backup boot sector. */
59711 if ((bh_backup = sb_bread(sb, nr_blocks >> 1))) {
59712 if (is_boot_sector_ntfs(sb, (NTFS_BOOT_SECTOR*)
59713 @@ -712,7 +712,7 @@ static struct buffer_head *read_ntfs_boot_sector(struct super_block *sb,
59714 "sector.");
59715 brelse(bh_backup);
59716 } else if (!silent)
59717 - ntfs_error(sb, read_err_str, "backup");
59718 + ntfs_error(sb, read_err_str, "%s", "backup");
59719 /* We failed. Cleanup and return. */
59720 if (bh_primary)
59721 brelse(bh_primary);
59722 diff --git a/fs/ocfs2/localalloc.c b/fs/ocfs2/localalloc.c
59723 index cd5496b..26a1055 100644
59724 --- a/fs/ocfs2/localalloc.c
59725 +++ b/fs/ocfs2/localalloc.c
59726 @@ -1278,7 +1278,7 @@ static int ocfs2_local_alloc_slide_window(struct ocfs2_super *osb,
59727 goto bail;
59728 }
59729
59730 - atomic_inc(&osb->alloc_stats.moves);
59731 + atomic_inc_unchecked(&osb->alloc_stats.moves);
59732
59733 bail:
59734 if (handle)
59735 diff --git a/fs/ocfs2/ocfs2.h b/fs/ocfs2/ocfs2.h
59736 index 3a90347..c40bef8 100644
59737 --- a/fs/ocfs2/ocfs2.h
59738 +++ b/fs/ocfs2/ocfs2.h
59739 @@ -235,11 +235,11 @@ enum ocfs2_vol_state
59740
59741 struct ocfs2_alloc_stats
59742 {
59743 - atomic_t moves;
59744 - atomic_t local_data;
59745 - atomic_t bitmap_data;
59746 - atomic_t bg_allocs;
59747 - atomic_t bg_extends;
59748 + atomic_unchecked_t moves;
59749 + atomic_unchecked_t local_data;
59750 + atomic_unchecked_t bitmap_data;
59751 + atomic_unchecked_t bg_allocs;
59752 + atomic_unchecked_t bg_extends;
59753 };
59754
59755 enum ocfs2_local_alloc_state
59756 diff --git a/fs/ocfs2/suballoc.c b/fs/ocfs2/suballoc.c
59757 index 5397c07..54afc55 100644
59758 --- a/fs/ocfs2/suballoc.c
59759 +++ b/fs/ocfs2/suballoc.c
59760 @@ -872,7 +872,7 @@ static int ocfs2_reserve_suballoc_bits(struct ocfs2_super *osb,
59761 mlog_errno(status);
59762 goto bail;
59763 }
59764 - atomic_inc(&osb->alloc_stats.bg_extends);
59765 + atomic_inc_unchecked(&osb->alloc_stats.bg_extends);
59766
59767 /* You should never ask for this much metadata */
59768 BUG_ON(bits_wanted >
59769 @@ -2000,7 +2000,7 @@ int ocfs2_claim_metadata(handle_t *handle,
59770 mlog_errno(status);
59771 goto bail;
59772 }
59773 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59774 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59775
59776 *suballoc_loc = res.sr_bg_blkno;
59777 *suballoc_bit_start = res.sr_bit_offset;
59778 @@ -2164,7 +2164,7 @@ int ocfs2_claim_new_inode_at_loc(handle_t *handle,
59779 trace_ocfs2_claim_new_inode_at_loc((unsigned long long)di_blkno,
59780 res->sr_bits);
59781
59782 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59783 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59784
59785 BUG_ON(res->sr_bits != 1);
59786
59787 @@ -2206,7 +2206,7 @@ int ocfs2_claim_new_inode(handle_t *handle,
59788 mlog_errno(status);
59789 goto bail;
59790 }
59791 - atomic_inc(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59792 + atomic_inc_unchecked(&OCFS2_SB(ac->ac_inode->i_sb)->alloc_stats.bg_allocs);
59793
59794 BUG_ON(res.sr_bits != 1);
59795
59796 @@ -2310,7 +2310,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59797 cluster_start,
59798 num_clusters);
59799 if (!status)
59800 - atomic_inc(&osb->alloc_stats.local_data);
59801 + atomic_inc_unchecked(&osb->alloc_stats.local_data);
59802 } else {
59803 if (min_clusters > (osb->bitmap_cpg - 1)) {
59804 /* The only paths asking for contiguousness
59805 @@ -2336,7 +2336,7 @@ int __ocfs2_claim_clusters(handle_t *handle,
59806 ocfs2_desc_bitmap_to_cluster_off(ac->ac_inode,
59807 res.sr_bg_blkno,
59808 res.sr_bit_offset);
59809 - atomic_inc(&osb->alloc_stats.bitmap_data);
59810 + atomic_inc_unchecked(&osb->alloc_stats.bitmap_data);
59811 *num_clusters = res.sr_bits;
59812 }
59813 }
59814 diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c
59815 index d4e81e4..ad89f5f 100644
59816 --- a/fs/ocfs2/super.c
59817 +++ b/fs/ocfs2/super.c
59818 @@ -300,11 +300,11 @@ static int ocfs2_osb_dump(struct ocfs2_super *osb, char *buf, int len)
59819 "%10s => GlobalAllocs: %d LocalAllocs: %d "
59820 "SubAllocs: %d LAWinMoves: %d SAExtends: %d\n",
59821 "Stats",
59822 - atomic_read(&osb->alloc_stats.bitmap_data),
59823 - atomic_read(&osb->alloc_stats.local_data),
59824 - atomic_read(&osb->alloc_stats.bg_allocs),
59825 - atomic_read(&osb->alloc_stats.moves),
59826 - atomic_read(&osb->alloc_stats.bg_extends));
59827 + atomic_read_unchecked(&osb->alloc_stats.bitmap_data),
59828 + atomic_read_unchecked(&osb->alloc_stats.local_data),
59829 + atomic_read_unchecked(&osb->alloc_stats.bg_allocs),
59830 + atomic_read_unchecked(&osb->alloc_stats.moves),
59831 + atomic_read_unchecked(&osb->alloc_stats.bg_extends));
59832
59833 out += snprintf(buf + out, len - out,
59834 "%10s => State: %u Descriptor: %llu Size: %u bits "
59835 @@ -2121,11 +2121,11 @@ static int ocfs2_initialize_super(struct super_block *sb,
59836 spin_lock_init(&osb->osb_xattr_lock);
59837 ocfs2_init_steal_slots(osb);
59838
59839 - atomic_set(&osb->alloc_stats.moves, 0);
59840 - atomic_set(&osb->alloc_stats.local_data, 0);
59841 - atomic_set(&osb->alloc_stats.bitmap_data, 0);
59842 - atomic_set(&osb->alloc_stats.bg_allocs, 0);
59843 - atomic_set(&osb->alloc_stats.bg_extends, 0);
59844 + atomic_set_unchecked(&osb->alloc_stats.moves, 0);
59845 + atomic_set_unchecked(&osb->alloc_stats.local_data, 0);
59846 + atomic_set_unchecked(&osb->alloc_stats.bitmap_data, 0);
59847 + atomic_set_unchecked(&osb->alloc_stats.bg_allocs, 0);
59848 + atomic_set_unchecked(&osb->alloc_stats.bg_extends, 0);
59849
59850 /* Copy the blockcheck stats from the superblock probe */
59851 osb->osb_ecc_stats = *stats;
59852 diff --git a/fs/open.c b/fs/open.c
59853 index d420331..2dbb3fd 100644
59854 --- a/fs/open.c
59855 +++ b/fs/open.c
59856 @@ -32,6 +32,8 @@
59857 #include <linux/dnotify.h>
59858 #include <linux/compat.h>
59859
59860 +#define CREATE_TRACE_POINTS
59861 +#include <trace/events/fs.h>
59862 #include "internal.h"
59863
59864 int do_truncate(struct dentry *dentry, loff_t length, unsigned int time_attrs,
59865 @@ -102,6 +104,8 @@ long vfs_truncate(struct path *path, loff_t length)
59866 error = locks_verify_truncate(inode, NULL, length);
59867 if (!error)
59868 error = security_path_truncate(path);
59869 + if (!error && !gr_acl_handle_truncate(path->dentry, path->mnt))
59870 + error = -EACCES;
59871 if (!error)
59872 error = do_truncate(path->dentry, length, 0, NULL);
59873
59874 @@ -186,6 +190,8 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
59875 error = locks_verify_truncate(inode, f.file, length);
59876 if (!error)
59877 error = security_path_truncate(&f.file->f_path);
59878 + if (!error && !gr_acl_handle_truncate(f.file->f_path.dentry, f.file->f_path.mnt))
59879 + error = -EACCES;
59880 if (!error)
59881 error = do_truncate(dentry, length, ATTR_MTIME|ATTR_CTIME, f.file);
59882 sb_end_write(inode->i_sb);
59883 @@ -360,6 +366,9 @@ retry:
59884 if (__mnt_is_readonly(path.mnt))
59885 res = -EROFS;
59886
59887 + if (!res && !gr_acl_handle_access(path.dentry, path.mnt, mode))
59888 + res = -EACCES;
59889 +
59890 out_path_release:
59891 path_put(&path);
59892 if (retry_estale(res, lookup_flags)) {
59893 @@ -391,6 +400,8 @@ retry:
59894 if (error)
59895 goto dput_and_out;
59896
59897 + gr_log_chdir(path.dentry, path.mnt);
59898 +
59899 set_fs_pwd(current->fs, &path);
59900
59901 dput_and_out:
59902 @@ -420,6 +431,13 @@ SYSCALL_DEFINE1(fchdir, unsigned int, fd)
59903 goto out_putf;
59904
59905 error = inode_permission(inode, MAY_EXEC | MAY_CHDIR);
59906 +
59907 + if (!error && !gr_chroot_fchdir(f.file->f_path.dentry, f.file->f_path.mnt))
59908 + error = -EPERM;
59909 +
59910 + if (!error)
59911 + gr_log_chdir(f.file->f_path.dentry, f.file->f_path.mnt);
59912 +
59913 if (!error)
59914 set_fs_pwd(current->fs, &f.file->f_path);
59915 out_putf:
59916 @@ -449,7 +467,13 @@ retry:
59917 if (error)
59918 goto dput_and_out;
59919
59920 + if (gr_handle_chroot_chroot(path.dentry, path.mnt))
59921 + goto dput_and_out;
59922 +
59923 set_fs_root(current->fs, &path);
59924 +
59925 + gr_handle_chroot_chdir(&path);
59926 +
59927 error = 0;
59928 dput_and_out:
59929 path_put(&path);
59930 @@ -471,6 +495,16 @@ static int chmod_common(struct path *path, umode_t mode)
59931 if (error)
59932 return error;
59933 mutex_lock(&inode->i_mutex);
59934 +
59935 + if (!gr_acl_handle_chmod(path->dentry, path->mnt, &mode)) {
59936 + error = -EACCES;
59937 + goto out_unlock;
59938 + }
59939 + if (gr_handle_chroot_chmod(path->dentry, path->mnt, mode)) {
59940 + error = -EACCES;
59941 + goto out_unlock;
59942 + }
59943 +
59944 error = security_path_chmod(path, mode);
59945 if (error)
59946 goto out_unlock;
59947 @@ -530,6 +564,9 @@ static int chown_common(struct path *path, uid_t user, gid_t group)
59948 uid = make_kuid(current_user_ns(), user);
59949 gid = make_kgid(current_user_ns(), group);
59950
59951 + if (!gr_acl_handle_chown(path->dentry, path->mnt))
59952 + return -EACCES;
59953 +
59954 newattrs.ia_valid = ATTR_CTIME;
59955 if (user != (uid_t) -1) {
59956 if (!uid_valid(uid))
59957 @@ -974,6 +1011,7 @@ long do_sys_open(int dfd, const char __user *filename, int flags, umode_t mode)
59958 } else {
59959 fsnotify_open(f);
59960 fd_install(fd, f);
59961 + trace_do_sys_open(tmp->name, flags, mode);
59962 }
59963 }
59964 putname(tmp);
59965 diff --git a/fs/pipe.c b/fs/pipe.c
59966 index 0e0752e..7cfdd50 100644
59967 --- a/fs/pipe.c
59968 +++ b/fs/pipe.c
59969 @@ -56,7 +56,7 @@ unsigned int pipe_min_size = PAGE_SIZE;
59970
59971 static void pipe_lock_nested(struct pipe_inode_info *pipe, int subclass)
59972 {
59973 - if (pipe->files)
59974 + if (atomic_read(&pipe->files))
59975 mutex_lock_nested(&pipe->mutex, subclass);
59976 }
59977
59978 @@ -71,7 +71,7 @@ EXPORT_SYMBOL(pipe_lock);
59979
59980 void pipe_unlock(struct pipe_inode_info *pipe)
59981 {
59982 - if (pipe->files)
59983 + if (atomic_read(&pipe->files))
59984 mutex_unlock(&pipe->mutex);
59985 }
59986 EXPORT_SYMBOL(pipe_unlock);
59987 @@ -449,9 +449,9 @@ redo:
59988 }
59989 if (bufs) /* More to do? */
59990 continue;
59991 - if (!pipe->writers)
59992 + if (!atomic_read(&pipe->writers))
59993 break;
59994 - if (!pipe->waiting_writers) {
59995 + if (!atomic_read(&pipe->waiting_writers)) {
59996 /* syscall merging: Usually we must not sleep
59997 * if O_NONBLOCK is set, or if we got some data.
59998 * But if a writer sleeps in kernel space, then
59999 @@ -513,7 +513,7 @@ pipe_write(struct kiocb *iocb, const struct iovec *_iov,
60000 ret = 0;
60001 __pipe_lock(pipe);
60002
60003 - if (!pipe->readers) {
60004 + if (!atomic_read(&pipe->readers)) {
60005 send_sig(SIGPIPE, current, 0);
60006 ret = -EPIPE;
60007 goto out;
60008 @@ -562,7 +562,7 @@ redo1:
60009 for (;;) {
60010 int bufs;
60011
60012 - if (!pipe->readers) {
60013 + if (!atomic_read(&pipe->readers)) {
60014 send_sig(SIGPIPE, current, 0);
60015 if (!ret)
60016 ret = -EPIPE;
60017 @@ -653,9 +653,9 @@ redo2:
60018 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
60019 do_wakeup = 0;
60020 }
60021 - pipe->waiting_writers++;
60022 + atomic_inc(&pipe->waiting_writers);
60023 pipe_wait(pipe);
60024 - pipe->waiting_writers--;
60025 + atomic_dec(&pipe->waiting_writers);
60026 }
60027 out:
60028 __pipe_unlock(pipe);
60029 @@ -709,7 +709,7 @@ pipe_poll(struct file *filp, poll_table *wait)
60030 mask = 0;
60031 if (filp->f_mode & FMODE_READ) {
60032 mask = (nrbufs > 0) ? POLLIN | POLLRDNORM : 0;
60033 - if (!pipe->writers && filp->f_version != pipe->w_counter)
60034 + if (!atomic_read(&pipe->writers) && filp->f_version != pipe->w_counter)
60035 mask |= POLLHUP;
60036 }
60037
60038 @@ -719,7 +719,7 @@ pipe_poll(struct file *filp, poll_table *wait)
60039 * Most Unices do not set POLLERR for FIFOs but on Linux they
60040 * behave exactly like pipes for poll().
60041 */
60042 - if (!pipe->readers)
60043 + if (!atomic_read(&pipe->readers))
60044 mask |= POLLERR;
60045 }
60046
60047 @@ -731,7 +731,7 @@ static void put_pipe_info(struct inode *inode, struct pipe_inode_info *pipe)
60048 int kill = 0;
60049
60050 spin_lock(&inode->i_lock);
60051 - if (!--pipe->files) {
60052 + if (atomic_dec_and_test(&pipe->files)) {
60053 inode->i_pipe = NULL;
60054 kill = 1;
60055 }
60056 @@ -748,11 +748,11 @@ pipe_release(struct inode *inode, struct file *file)
60057
60058 __pipe_lock(pipe);
60059 if (file->f_mode & FMODE_READ)
60060 - pipe->readers--;
60061 + atomic_dec(&pipe->readers);
60062 if (file->f_mode & FMODE_WRITE)
60063 - pipe->writers--;
60064 + atomic_dec(&pipe->writers);
60065
60066 - if (pipe->readers || pipe->writers) {
60067 + if (atomic_read(&pipe->readers) || atomic_read(&pipe->writers)) {
60068 wake_up_interruptible_sync_poll(&pipe->wait, POLLIN | POLLOUT | POLLRDNORM | POLLWRNORM | POLLERR | POLLHUP);
60069 kill_fasync(&pipe->fasync_readers, SIGIO, POLL_IN);
60070 kill_fasync(&pipe->fasync_writers, SIGIO, POLL_OUT);
60071 @@ -817,7 +817,7 @@ void free_pipe_info(struct pipe_inode_info *pipe)
60072 kfree(pipe);
60073 }
60074
60075 -static struct vfsmount *pipe_mnt __read_mostly;
60076 +struct vfsmount *pipe_mnt __read_mostly;
60077
60078 /*
60079 * pipefs_dname() is called from d_path().
60080 @@ -847,8 +847,9 @@ static struct inode * get_pipe_inode(void)
60081 goto fail_iput;
60082
60083 inode->i_pipe = pipe;
60084 - pipe->files = 2;
60085 - pipe->readers = pipe->writers = 1;
60086 + atomic_set(&pipe->files, 2);
60087 + atomic_set(&pipe->readers, 1);
60088 + atomic_set(&pipe->writers, 1);
60089 inode->i_fop = &pipefifo_fops;
60090
60091 /*
60092 @@ -1027,17 +1028,17 @@ static int fifo_open(struct inode *inode, struct file *filp)
60093 spin_lock(&inode->i_lock);
60094 if (inode->i_pipe) {
60095 pipe = inode->i_pipe;
60096 - pipe->files++;
60097 + atomic_inc(&pipe->files);
60098 spin_unlock(&inode->i_lock);
60099 } else {
60100 spin_unlock(&inode->i_lock);
60101 pipe = alloc_pipe_info();
60102 if (!pipe)
60103 return -ENOMEM;
60104 - pipe->files = 1;
60105 + atomic_set(&pipe->files, 1);
60106 spin_lock(&inode->i_lock);
60107 if (unlikely(inode->i_pipe)) {
60108 - inode->i_pipe->files++;
60109 + atomic_inc(&inode->i_pipe->files);
60110 spin_unlock(&inode->i_lock);
60111 free_pipe_info(pipe);
60112 pipe = inode->i_pipe;
60113 @@ -1062,10 +1063,10 @@ static int fifo_open(struct inode *inode, struct file *filp)
60114 * opened, even when there is no process writing the FIFO.
60115 */
60116 pipe->r_counter++;
60117 - if (pipe->readers++ == 0)
60118 + if (atomic_inc_return(&pipe->readers) == 1)
60119 wake_up_partner(pipe);
60120
60121 - if (!is_pipe && !pipe->writers) {
60122 + if (!is_pipe && !atomic_read(&pipe->writers)) {
60123 if ((filp->f_flags & O_NONBLOCK)) {
60124 /* suppress POLLHUP until we have
60125 * seen a writer */
60126 @@ -1084,14 +1085,14 @@ static int fifo_open(struct inode *inode, struct file *filp)
60127 * errno=ENXIO when there is no process reading the FIFO.
60128 */
60129 ret = -ENXIO;
60130 - if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !pipe->readers)
60131 + if (!is_pipe && (filp->f_flags & O_NONBLOCK) && !atomic_read(&pipe->readers))
60132 goto err;
60133
60134 pipe->w_counter++;
60135 - if (!pipe->writers++)
60136 + if (atomic_inc_return(&pipe->writers) == 1)
60137 wake_up_partner(pipe);
60138
60139 - if (!is_pipe && !pipe->readers) {
60140 + if (!is_pipe && !atomic_read(&pipe->readers)) {
60141 if (wait_for_partner(pipe, &pipe->r_counter))
60142 goto err_wr;
60143 }
60144 @@ -1105,11 +1106,11 @@ static int fifo_open(struct inode *inode, struct file *filp)
60145 * the process can at least talk to itself.
60146 */
60147
60148 - pipe->readers++;
60149 - pipe->writers++;
60150 + atomic_inc(&pipe->readers);
60151 + atomic_inc(&pipe->writers);
60152 pipe->r_counter++;
60153 pipe->w_counter++;
60154 - if (pipe->readers == 1 || pipe->writers == 1)
60155 + if (atomic_read(&pipe->readers) == 1 || atomic_read(&pipe->writers) == 1)
60156 wake_up_partner(pipe);
60157 break;
60158
60159 @@ -1123,13 +1124,13 @@ static int fifo_open(struct inode *inode, struct file *filp)
60160 return 0;
60161
60162 err_rd:
60163 - if (!--pipe->readers)
60164 + if (atomic_dec_and_test(&pipe->readers))
60165 wake_up_interruptible(&pipe->wait);
60166 ret = -ERESTARTSYS;
60167 goto err;
60168
60169 err_wr:
60170 - if (!--pipe->writers)
60171 + if (atomic_dec_and_test(&pipe->writers))
60172 wake_up_interruptible(&pipe->wait);
60173 ret = -ERESTARTSYS;
60174 goto err;
60175 diff --git a/fs/proc/Kconfig b/fs/proc/Kconfig
60176 index 15af622..0e9f4467 100644
60177 --- a/fs/proc/Kconfig
60178 +++ b/fs/proc/Kconfig
60179 @@ -30,12 +30,12 @@ config PROC_FS
60180
60181 config PROC_KCORE
60182 bool "/proc/kcore support" if !ARM
60183 - depends on PROC_FS && MMU
60184 + depends on PROC_FS && MMU && !GRKERNSEC_PROC_ADD
60185
60186 config PROC_VMCORE
60187 bool "/proc/vmcore support"
60188 - depends on PROC_FS && CRASH_DUMP
60189 - default y
60190 + depends on PROC_FS && CRASH_DUMP && !GRKERNSEC
60191 + default n
60192 help
60193 Exports the dump image of crashed kernel in ELF format.
60194
60195 @@ -59,8 +59,8 @@ config PROC_SYSCTL
60196 limited in memory.
60197
60198 config PROC_PAGE_MONITOR
60199 - default y
60200 - depends on PROC_FS && MMU
60201 + default n
60202 + depends on PROC_FS && MMU && !GRKERNSEC
60203 bool "Enable /proc page monitoring" if EXPERT
60204 help
60205 Various /proc files exist to monitor process memory utilization:
60206 diff --git a/fs/proc/array.c b/fs/proc/array.c
60207 index cbd0f1b..adec3f0 100644
60208 --- a/fs/proc/array.c
60209 +++ b/fs/proc/array.c
60210 @@ -60,6 +60,7 @@
60211 #include <linux/tty.h>
60212 #include <linux/string.h>
60213 #include <linux/mman.h>
60214 +#include <linux/grsecurity.h>
60215 #include <linux/proc_fs.h>
60216 #include <linux/ioport.h>
60217 #include <linux/uaccess.h>
60218 @@ -363,6 +364,21 @@ static void task_cpus_allowed(struct seq_file *m, struct task_struct *task)
60219 seq_putc(m, '\n');
60220 }
60221
60222 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60223 +static inline void task_pax(struct seq_file *m, struct task_struct *p)
60224 +{
60225 + if (p->mm)
60226 + seq_printf(m, "PaX:\t%c%c%c%c%c\n",
60227 + p->mm->pax_flags & MF_PAX_PAGEEXEC ? 'P' : 'p',
60228 + p->mm->pax_flags & MF_PAX_EMUTRAMP ? 'E' : 'e',
60229 + p->mm->pax_flags & MF_PAX_MPROTECT ? 'M' : 'm',
60230 + p->mm->pax_flags & MF_PAX_RANDMMAP ? 'R' : 'r',
60231 + p->mm->pax_flags & MF_PAX_SEGMEXEC ? 'S' : 's');
60232 + else
60233 + seq_printf(m, "PaX:\t-----\n");
60234 +}
60235 +#endif
60236 +
60237 int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60238 struct pid *pid, struct task_struct *task)
60239 {
60240 @@ -381,9 +397,24 @@ int proc_pid_status(struct seq_file *m, struct pid_namespace *ns,
60241 task_cpus_allowed(m, task);
60242 cpuset_task_status_allowed(m, task);
60243 task_context_switch_counts(m, task);
60244 +
60245 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
60246 + task_pax(m, task);
60247 +#endif
60248 +
60249 +#if defined(CONFIG_GRKERNSEC) && !defined(CONFIG_GRKERNSEC_NO_RBAC)
60250 + task_grsec_rbac(m, task);
60251 +#endif
60252 +
60253 return 0;
60254 }
60255
60256 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60257 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60258 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60259 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60260 +#endif
60261 +
60262 static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60263 struct pid *pid, struct task_struct *task, int whole)
60264 {
60265 @@ -405,6 +436,13 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60266 char tcomm[sizeof(task->comm)];
60267 unsigned long flags;
60268
60269 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60270 + if (current->exec_id != m->exec_id) {
60271 + gr_log_badprocpid("stat");
60272 + return 0;
60273 + }
60274 +#endif
60275 +
60276 state = *get_task_state(task);
60277 vsize = eip = esp = 0;
60278 permitted = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60279 @@ -476,6 +514,19 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60280 gtime = task_gtime(task);
60281 }
60282
60283 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60284 + if (PAX_RAND_FLAGS(mm)) {
60285 + eip = 0;
60286 + esp = 0;
60287 + wchan = 0;
60288 + }
60289 +#endif
60290 +#ifdef CONFIG_GRKERNSEC_HIDESYM
60291 + wchan = 0;
60292 + eip =0;
60293 + esp =0;
60294 +#endif
60295 +
60296 /* scale priority and nice values from timeslices to -20..20 */
60297 /* to make it look like a "normal" Unix priority/nice value */
60298 priority = task_prio(task);
60299 @@ -512,9 +563,15 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60300 seq_put_decimal_ull(m, ' ', vsize);
60301 seq_put_decimal_ull(m, ' ', mm ? get_mm_rss(mm) : 0);
60302 seq_put_decimal_ull(m, ' ', rsslim);
60303 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60304 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->start_code : 1) : 0));
60305 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 1 : (mm ? (permitted ? mm->end_code : 1) : 0));
60306 + seq_put_decimal_ull(m, ' ', PAX_RAND_FLAGS(mm) ? 0 : ((permitted && mm) ? mm->start_stack : 0));
60307 +#else
60308 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->start_code : 1) : 0);
60309 seq_put_decimal_ull(m, ' ', mm ? (permitted ? mm->end_code : 1) : 0);
60310 seq_put_decimal_ull(m, ' ', (permitted && mm) ? mm->start_stack : 0);
60311 +#endif
60312 seq_put_decimal_ull(m, ' ', esp);
60313 seq_put_decimal_ull(m, ' ', eip);
60314 /* The signal information here is obsolete.
60315 @@ -536,7 +593,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns,
60316 seq_put_decimal_ull(m, ' ', cputime_to_clock_t(gtime));
60317 seq_put_decimal_ll(m, ' ', cputime_to_clock_t(cgtime));
60318
60319 - if (mm && permitted) {
60320 + if (mm && permitted
60321 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60322 + && !PAX_RAND_FLAGS(mm)
60323 +#endif
60324 + ) {
60325 seq_put_decimal_ull(m, ' ', mm->start_data);
60326 seq_put_decimal_ull(m, ' ', mm->end_data);
60327 seq_put_decimal_ull(m, ' ', mm->start_brk);
60328 @@ -574,8 +635,15 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60329 struct pid *pid, struct task_struct *task)
60330 {
60331 unsigned long size = 0, resident = 0, shared = 0, text = 0, data = 0;
60332 - struct mm_struct *mm = get_task_mm(task);
60333 + struct mm_struct *mm;
60334
60335 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60336 + if (current->exec_id != m->exec_id) {
60337 + gr_log_badprocpid("statm");
60338 + return 0;
60339 + }
60340 +#endif
60341 + mm = get_task_mm(task);
60342 if (mm) {
60343 size = task_statm(mm, &shared, &text, &data, &resident);
60344 mmput(mm);
60345 @@ -598,6 +666,13 @@ int proc_pid_statm(struct seq_file *m, struct pid_namespace *ns,
60346 return 0;
60347 }
60348
60349 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60350 +int proc_pid_ipaddr(struct task_struct *task, char *buffer)
60351 +{
60352 + return sprintf(buffer, "%pI4\n", &task->signal->curr_ip);
60353 +}
60354 +#endif
60355 +
60356 #ifdef CONFIG_CHECKPOINT_RESTORE
60357 static struct pid *
60358 get_children_pid(struct inode *inode, struct pid *pid_prev, loff_t pos)
60359 diff --git a/fs/proc/base.c b/fs/proc/base.c
60360 index 1485e38..8ad4236 100644
60361 --- a/fs/proc/base.c
60362 +++ b/fs/proc/base.c
60363 @@ -113,6 +113,14 @@ struct pid_entry {
60364 union proc_op op;
60365 };
60366
60367 +struct getdents_callback {
60368 + struct linux_dirent __user * current_dir;
60369 + struct linux_dirent __user * previous;
60370 + struct file * file;
60371 + int count;
60372 + int error;
60373 +};
60374 +
60375 #define NOD(NAME, MODE, IOP, FOP, OP) { \
60376 .name = (NAME), \
60377 .len = sizeof(NAME) - 1, \
60378 @@ -210,6 +218,9 @@ static int proc_pid_cmdline(struct task_struct *task, char * buffer)
60379 if (!mm->arg_end)
60380 goto out_mm; /* Shh! No looking before we're done */
60381
60382 + if (gr_acl_handle_procpidmem(task))
60383 + goto out_mm;
60384 +
60385 len = mm->arg_end - mm->arg_start;
60386
60387 if (len > PAGE_SIZE)
60388 @@ -237,12 +248,28 @@ out:
60389 return res;
60390 }
60391
60392 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60393 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
60394 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
60395 + _mm->pax_flags & MF_PAX_SEGMEXEC))
60396 +#endif
60397 +
60398 static int proc_pid_auxv(struct task_struct *task, char *buffer)
60399 {
60400 struct mm_struct *mm = mm_access(task, PTRACE_MODE_READ);
60401 int res = PTR_ERR(mm);
60402 if (mm && !IS_ERR(mm)) {
60403 unsigned int nwords = 0;
60404 +
60405 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60406 + /* allow if we're currently ptracing this task */
60407 + if (PAX_RAND_FLAGS(mm) &&
60408 + (!(task->ptrace & PT_PTRACED) || (task->parent != current))) {
60409 + mmput(mm);
60410 + return 0;
60411 + }
60412 +#endif
60413 +
60414 do {
60415 nwords += 2;
60416 } while (mm->saved_auxv[nwords - 2] != 0); /* AT_NULL */
60417 @@ -256,7 +283,7 @@ static int proc_pid_auxv(struct task_struct *task, char *buffer)
60418 }
60419
60420
60421 -#ifdef CONFIG_KALLSYMS
60422 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60423 /*
60424 * Provides a wchan file via kallsyms in a proper one-value-per-file format.
60425 * Returns the resolved symbol. If that fails, simply return the address.
60426 @@ -295,7 +322,7 @@ static void unlock_trace(struct task_struct *task)
60427 mutex_unlock(&task->signal->cred_guard_mutex);
60428 }
60429
60430 -#ifdef CONFIG_STACKTRACE
60431 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60432
60433 #define MAX_STACK_TRACE_DEPTH 64
60434
60435 @@ -518,7 +545,7 @@ static int proc_pid_limits(struct task_struct *task, char *buffer)
60436 return count;
60437 }
60438
60439 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60440 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60441 static int proc_pid_syscall(struct task_struct *task, char *buffer)
60442 {
60443 long nr;
60444 @@ -547,7 +574,7 @@ static int proc_pid_syscall(struct task_struct *task, char *buffer)
60445 /************************************************************************/
60446
60447 /* permission checks */
60448 -static int proc_fd_access_allowed(struct inode *inode)
60449 +static int proc_fd_access_allowed(struct inode *inode, unsigned int log)
60450 {
60451 struct task_struct *task;
60452 int allowed = 0;
60453 @@ -557,7 +584,10 @@ static int proc_fd_access_allowed(struct inode *inode)
60454 */
60455 task = get_proc_task(inode);
60456 if (task) {
60457 - allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60458 + if (log)
60459 + allowed = ptrace_may_access(task, PTRACE_MODE_READ);
60460 + else
60461 + allowed = ptrace_may_access(task, PTRACE_MODE_READ | PTRACE_MODE_NOAUDIT);
60462 put_task_struct(task);
60463 }
60464 return allowed;
60465 @@ -588,10 +618,35 @@ static bool has_pid_permissions(struct pid_namespace *pid,
60466 struct task_struct *task,
60467 int hide_pid_min)
60468 {
60469 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60470 + return false;
60471 +
60472 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60473 + rcu_read_lock();
60474 + {
60475 + const struct cred *tmpcred = current_cred();
60476 + const struct cred *cred = __task_cred(task);
60477 +
60478 + if (uid_eq(tmpcred->uid, GLOBAL_ROOT_UID) || uid_eq(tmpcred->uid, cred->uid)
60479 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60480 + || in_group_p(grsec_proc_gid)
60481 +#endif
60482 + ) {
60483 + rcu_read_unlock();
60484 + return true;
60485 + }
60486 + }
60487 + rcu_read_unlock();
60488 +
60489 + if (!pid->hide_pid)
60490 + return false;
60491 +#endif
60492 +
60493 if (pid->hide_pid < hide_pid_min)
60494 return true;
60495 if (in_group_p(pid->pid_gid))
60496 return true;
60497 +
60498 return ptrace_may_access(task, PTRACE_MODE_READ);
60499 }
60500
60501 @@ -609,7 +664,11 @@ static int proc_pid_permission(struct inode *inode, int mask)
60502 put_task_struct(task);
60503
60504 if (!has_perms) {
60505 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60506 + {
60507 +#else
60508 if (pid->hide_pid == 2) {
60509 +#endif
60510 /*
60511 * Let's make getdents(), stat(), and open()
60512 * consistent with each other. If a process
60513 @@ -707,6 +766,11 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60514 if (!task)
60515 return -ESRCH;
60516
60517 + if (gr_acl_handle_procpidmem(task)) {
60518 + put_task_struct(task);
60519 + return -EPERM;
60520 + }
60521 +
60522 mm = mm_access(task, mode);
60523 put_task_struct(task);
60524
60525 @@ -722,6 +786,10 @@ static int __mem_open(struct inode *inode, struct file *file, unsigned int mode)
60526
60527 file->private_data = mm;
60528
60529 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60530 + file->f_version = current->exec_id;
60531 +#endif
60532 +
60533 return 0;
60534 }
60535
60536 @@ -743,6 +811,17 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60537 ssize_t copied;
60538 char *page;
60539
60540 +#ifdef CONFIG_GRKERNSEC
60541 + if (write)
60542 + return -EPERM;
60543 +#endif
60544 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60545 + if (file->f_version != current->exec_id) {
60546 + gr_log_badprocpid("mem");
60547 + return 0;
60548 + }
60549 +#endif
60550 +
60551 if (!mm)
60552 return 0;
60553
60554 @@ -755,7 +834,7 @@ static ssize_t mem_rw(struct file *file, char __user *buf,
60555 goto free;
60556
60557 while (count > 0) {
60558 - int this_len = min_t(int, count, PAGE_SIZE);
60559 + ssize_t this_len = min_t(ssize_t, count, PAGE_SIZE);
60560
60561 if (write && copy_from_user(page, buf, this_len)) {
60562 copied = -EFAULT;
60563 @@ -847,6 +926,13 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60564 if (!mm)
60565 return 0;
60566
60567 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
60568 + if (file->f_version != current->exec_id) {
60569 + gr_log_badprocpid("environ");
60570 + return 0;
60571 + }
60572 +#endif
60573 +
60574 page = (char *)__get_free_page(GFP_TEMPORARY);
60575 if (!page)
60576 return -ENOMEM;
60577 @@ -856,7 +942,7 @@ static ssize_t environ_read(struct file *file, char __user *buf,
60578 goto free;
60579 while (count > 0) {
60580 size_t this_len, max_len;
60581 - int retval;
60582 + ssize_t retval;
60583
60584 if (src >= (mm->env_end - mm->env_start))
60585 break;
60586 @@ -1461,7 +1547,7 @@ static void *proc_pid_follow_link(struct dentry *dentry, struct nameidata *nd)
60587 int error = -EACCES;
60588
60589 /* Are we allowed to snoop on the tasks file descriptors? */
60590 - if (!proc_fd_access_allowed(inode))
60591 + if (!proc_fd_access_allowed(inode, 0))
60592 goto out;
60593
60594 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60595 @@ -1505,8 +1591,18 @@ static int proc_pid_readlink(struct dentry * dentry, char __user * buffer, int b
60596 struct path path;
60597
60598 /* Are we allowed to snoop on the tasks file descriptors? */
60599 - if (!proc_fd_access_allowed(inode))
60600 - goto out;
60601 + /* logging this is needed for learning on chromium to work properly,
60602 + but we don't want to flood the logs from 'ps' which does a readlink
60603 + on /proc/fd/2 of tasks in the listing, nor do we want 'ps' to learn
60604 + CAP_SYS_PTRACE as it's not necessary for its basic functionality
60605 + */
60606 + if (dentry->d_name.name[0] == '2' && dentry->d_name.name[1] == '\0') {
60607 + if (!proc_fd_access_allowed(inode,0))
60608 + goto out;
60609 + } else {
60610 + if (!proc_fd_access_allowed(inode,1))
60611 + goto out;
60612 + }
60613
60614 error = PROC_I(inode)->op.proc_get_link(dentry, &path);
60615 if (error)
60616 @@ -1556,7 +1652,11 @@ struct inode *proc_pid_make_inode(struct super_block * sb, struct task_struct *t
60617 rcu_read_lock();
60618 cred = __task_cred(task);
60619 inode->i_uid = cred->euid;
60620 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60621 + inode->i_gid = grsec_proc_gid;
60622 +#else
60623 inode->i_gid = cred->egid;
60624 +#endif
60625 rcu_read_unlock();
60626 }
60627 security_task_to_inode(task, inode);
60628 @@ -1592,10 +1692,19 @@ int pid_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
60629 return -ENOENT;
60630 }
60631 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60632 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60633 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60634 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60635 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60636 +#endif
60637 task_dumpable(task)) {
60638 cred = __task_cred(task);
60639 stat->uid = cred->euid;
60640 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60641 + stat->gid = grsec_proc_gid;
60642 +#else
60643 stat->gid = cred->egid;
60644 +#endif
60645 }
60646 }
60647 rcu_read_unlock();
60648 @@ -1633,11 +1742,20 @@ int pid_revalidate(struct dentry *dentry, unsigned int flags)
60649
60650 if (task) {
60651 if ((inode->i_mode == (S_IFDIR|S_IRUGO|S_IXUGO)) ||
60652 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60653 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IXUSR)) ||
60654 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60655 + (inode->i_mode == (S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP)) ||
60656 +#endif
60657 task_dumpable(task)) {
60658 rcu_read_lock();
60659 cred = __task_cred(task);
60660 inode->i_uid = cred->euid;
60661 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60662 + inode->i_gid = grsec_proc_gid;
60663 +#else
60664 inode->i_gid = cred->egid;
60665 +#endif
60666 rcu_read_unlock();
60667 } else {
60668 inode->i_uid = GLOBAL_ROOT_UID;
60669 @@ -2166,6 +2284,9 @@ static struct dentry *proc_pident_lookup(struct inode *dir,
60670 if (!task)
60671 goto out_no_task;
60672
60673 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60674 + goto out;
60675 +
60676 /*
60677 * Yes, it does not scale. And it should not. Don't add
60678 * new entries into /proc/<tgid>/ without very good reasons.
60679 @@ -2196,6 +2317,9 @@ static int proc_pident_readdir(struct file *file, struct dir_context *ctx,
60680 if (!task)
60681 return -ENOENT;
60682
60683 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60684 + goto out;
60685 +
60686 if (!dir_emit_dots(file, ctx))
60687 goto out;
60688
60689 @@ -2585,7 +2709,7 @@ static const struct pid_entry tgid_base_stuff[] = {
60690 REG("autogroup", S_IRUGO|S_IWUSR, proc_pid_sched_autogroup_operations),
60691 #endif
60692 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60693 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60694 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60695 INF("syscall", S_IRUGO, proc_pid_syscall),
60696 #endif
60697 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60698 @@ -2610,10 +2734,10 @@ static const struct pid_entry tgid_base_stuff[] = {
60699 #ifdef CONFIG_SECURITY
60700 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60701 #endif
60702 -#ifdef CONFIG_KALLSYMS
60703 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60704 INF("wchan", S_IRUGO, proc_pid_wchan),
60705 #endif
60706 -#ifdef CONFIG_STACKTRACE
60707 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60708 ONE("stack", S_IRUGO, proc_pid_stack),
60709 #endif
60710 #ifdef CONFIG_SCHEDSTATS
60711 @@ -2647,6 +2771,9 @@ static const struct pid_entry tgid_base_stuff[] = {
60712 #ifdef CONFIG_HARDWALL
60713 INF("hardwall", S_IRUGO, proc_pid_hardwall),
60714 #endif
60715 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60716 + INF("ipaddr", S_IRUSR, proc_pid_ipaddr),
60717 +#endif
60718 #ifdef CONFIG_USER_NS
60719 REG("uid_map", S_IRUGO|S_IWUSR, proc_uid_map_operations),
60720 REG("gid_map", S_IRUGO|S_IWUSR, proc_gid_map_operations),
60721 @@ -2777,7 +2904,14 @@ static int proc_pid_instantiate(struct inode *dir,
60722 if (!inode)
60723 goto out;
60724
60725 +#ifdef CONFIG_GRKERNSEC_PROC_USER
60726 + inode->i_mode = S_IFDIR|S_IRUSR|S_IXUSR;
60727 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
60728 + inode->i_gid = grsec_proc_gid;
60729 + inode->i_mode = S_IFDIR|S_IRUSR|S_IRGRP|S_IXUSR|S_IXGRP;
60730 +#else
60731 inode->i_mode = S_IFDIR|S_IRUGO|S_IXUGO;
60732 +#endif
60733 inode->i_op = &proc_tgid_base_inode_operations;
60734 inode->i_fop = &proc_tgid_base_operations;
60735 inode->i_flags|=S_IMMUTABLE;
60736 @@ -2815,7 +2949,11 @@ struct dentry *proc_pid_lookup(struct inode *dir, struct dentry * dentry, unsign
60737 if (!task)
60738 goto out;
60739
60740 + if (gr_pid_is_chrooted(task) || gr_check_hidden_task(task))
60741 + goto out_put_task;
60742 +
60743 result = proc_pid_instantiate(dir, dentry, task, NULL);
60744 +out_put_task:
60745 put_task_struct(task);
60746 out:
60747 return ERR_PTR(result);
60748 @@ -2921,7 +3059,7 @@ static const struct pid_entry tid_base_stuff[] = {
60749 REG("sched", S_IRUGO|S_IWUSR, proc_pid_sched_operations),
60750 #endif
60751 REG("comm", S_IRUGO|S_IWUSR, proc_pid_set_comm_operations),
60752 -#ifdef CONFIG_HAVE_ARCH_TRACEHOOK
60753 +#if defined(CONFIG_HAVE_ARCH_TRACEHOOK) && !defined(CONFIG_GRKERNSEC_PROC_MEMMAP)
60754 INF("syscall", S_IRUGO, proc_pid_syscall),
60755 #endif
60756 INF("cmdline", S_IRUGO, proc_pid_cmdline),
60757 @@ -2948,10 +3086,10 @@ static const struct pid_entry tid_base_stuff[] = {
60758 #ifdef CONFIG_SECURITY
60759 DIR("attr", S_IRUGO|S_IXUGO, proc_attr_dir_inode_operations, proc_attr_dir_operations),
60760 #endif
60761 -#ifdef CONFIG_KALLSYMS
60762 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60763 INF("wchan", S_IRUGO, proc_pid_wchan),
60764 #endif
60765 -#ifdef CONFIG_STACKTRACE
60766 +#if defined(CONFIG_STACKTRACE) && !defined(CONFIG_GRKERNSEC_HIDESYM)
60767 ONE("stack", S_IRUGO, proc_pid_stack),
60768 #endif
60769 #ifdef CONFIG_SCHEDSTATS
60770 diff --git a/fs/proc/cmdline.c b/fs/proc/cmdline.c
60771 index 82676e3..5f8518a 100644
60772 --- a/fs/proc/cmdline.c
60773 +++ b/fs/proc/cmdline.c
60774 @@ -23,7 +23,11 @@ static const struct file_operations cmdline_proc_fops = {
60775
60776 static int __init proc_cmdline_init(void)
60777 {
60778 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60779 + proc_create_grsec("cmdline", 0, NULL, &cmdline_proc_fops);
60780 +#else
60781 proc_create("cmdline", 0, NULL, &cmdline_proc_fops);
60782 +#endif
60783 return 0;
60784 }
60785 module_init(proc_cmdline_init);
60786 diff --git a/fs/proc/devices.c b/fs/proc/devices.c
60787 index b143471..bb105e5 100644
60788 --- a/fs/proc/devices.c
60789 +++ b/fs/proc/devices.c
60790 @@ -64,7 +64,11 @@ static const struct file_operations proc_devinfo_operations = {
60791
60792 static int __init proc_devices_init(void)
60793 {
60794 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60795 + proc_create_grsec("devices", 0, NULL, &proc_devinfo_operations);
60796 +#else
60797 proc_create("devices", 0, NULL, &proc_devinfo_operations);
60798 +#endif
60799 return 0;
60800 }
60801 module_init(proc_devices_init);
60802 diff --git a/fs/proc/fd.c b/fs/proc/fd.c
60803 index 985ea88..d118a0a 100644
60804 --- a/fs/proc/fd.c
60805 +++ b/fs/proc/fd.c
60806 @@ -25,7 +25,8 @@ static int seq_show(struct seq_file *m, void *v)
60807 if (!task)
60808 return -ENOENT;
60809
60810 - files = get_files_struct(task);
60811 + if (!gr_acl_handle_procpidmem(task))
60812 + files = get_files_struct(task);
60813 put_task_struct(task);
60814
60815 if (files) {
60816 @@ -283,11 +284,21 @@ static struct dentry *proc_lookupfd(struct inode *dir, struct dentry *dentry,
60817 */
60818 int proc_fd_permission(struct inode *inode, int mask)
60819 {
60820 + struct task_struct *task;
60821 int rv = generic_permission(inode, mask);
60822 - if (rv == 0)
60823 - return 0;
60824 +
60825 if (task_tgid(current) == proc_pid(inode))
60826 rv = 0;
60827 +
60828 + task = get_proc_task(inode);
60829 + if (task == NULL)
60830 + return rv;
60831 +
60832 + if (gr_acl_handle_procpidmem(task))
60833 + rv = -EACCES;
60834 +
60835 + put_task_struct(task);
60836 +
60837 return rv;
60838 }
60839
60840 diff --git a/fs/proc/inode.c b/fs/proc/inode.c
60841 index 8eaa1ba..cc6ff42 100644
60842 --- a/fs/proc/inode.c
60843 +++ b/fs/proc/inode.c
60844 @@ -23,11 +23,17 @@
60845 #include <linux/slab.h>
60846 #include <linux/mount.h>
60847 #include <linux/magic.h>
60848 +#include <linux/grsecurity.h>
60849
60850 #include <asm/uaccess.h>
60851
60852 #include "internal.h"
60853
60854 +#ifdef CONFIG_PROC_SYSCTL
60855 +extern const struct inode_operations proc_sys_inode_operations;
60856 +extern const struct inode_operations proc_sys_dir_operations;
60857 +#endif
60858 +
60859 static void proc_evict_inode(struct inode *inode)
60860 {
60861 struct proc_dir_entry *de;
60862 @@ -55,6 +61,13 @@ static void proc_evict_inode(struct inode *inode)
60863 ns = PROC_I(inode)->ns.ns;
60864 if (ns_ops && ns)
60865 ns_ops->put(ns);
60866 +
60867 +#ifdef CONFIG_PROC_SYSCTL
60868 + if (inode->i_op == &proc_sys_inode_operations ||
60869 + inode->i_op == &proc_sys_dir_operations)
60870 + gr_handle_delete(inode->i_ino, inode->i_sb->s_dev);
60871 +#endif
60872 +
60873 }
60874
60875 static struct kmem_cache * proc_inode_cachep;
60876 @@ -405,7 +418,11 @@ struct inode *proc_get_inode(struct super_block *sb, struct proc_dir_entry *de)
60877 if (de->mode) {
60878 inode->i_mode = de->mode;
60879 inode->i_uid = de->uid;
60880 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
60881 + inode->i_gid = grsec_proc_gid;
60882 +#else
60883 inode->i_gid = de->gid;
60884 +#endif
60885 }
60886 if (de->size)
60887 inode->i_size = de->size;
60888 diff --git a/fs/proc/internal.h b/fs/proc/internal.h
60889 index 651d09a..60c73ae 100644
60890 --- a/fs/proc/internal.h
60891 +++ b/fs/proc/internal.h
60892 @@ -155,6 +155,9 @@ extern int proc_pid_status(struct seq_file *, struct pid_namespace *,
60893 struct pid *, struct task_struct *);
60894 extern int proc_pid_statm(struct seq_file *, struct pid_namespace *,
60895 struct pid *, struct task_struct *);
60896 +#ifdef CONFIG_GRKERNSEC_PROC_IPADDR
60897 +extern int proc_pid_ipaddr(struct task_struct *task, char *buffer);
60898 +#endif
60899
60900 /*
60901 * base.c
60902 diff --git a/fs/proc/interrupts.c b/fs/proc/interrupts.c
60903 index 05029c0..7ea1987 100644
60904 --- a/fs/proc/interrupts.c
60905 +++ b/fs/proc/interrupts.c
60906 @@ -47,7 +47,11 @@ static const struct file_operations proc_interrupts_operations = {
60907
60908 static int __init proc_interrupts_init(void)
60909 {
60910 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
60911 + proc_create_grsec("interrupts", 0, NULL, &proc_interrupts_operations);
60912 +#else
60913 proc_create("interrupts", 0, NULL, &proc_interrupts_operations);
60914 +#endif
60915 return 0;
60916 }
60917 module_init(proc_interrupts_init);
60918 diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c
60919 index 06ea155..9a798c7 100644
60920 --- a/fs/proc/kcore.c
60921 +++ b/fs/proc/kcore.c
60922 @@ -484,9 +484,10 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60923 * the addresses in the elf_phdr on our list.
60924 */
60925 start = kc_offset_to_vaddr(*fpos - elf_buflen);
60926 - if ((tsz = (PAGE_SIZE - (start & ~PAGE_MASK))) > buflen)
60927 + tsz = PAGE_SIZE - (start & ~PAGE_MASK);
60928 + if (tsz > buflen)
60929 tsz = buflen;
60930 -
60931 +
60932 while (buflen) {
60933 struct kcore_list *m;
60934
60935 @@ -515,20 +516,23 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60936 kfree(elf_buf);
60937 } else {
60938 if (kern_addr_valid(start)) {
60939 - unsigned long n;
60940 + char *elf_buf;
60941 + mm_segment_t oldfs;
60942
60943 - n = copy_to_user(buffer, (char *)start, tsz);
60944 - /*
60945 - * We cannot distinguish between fault on source
60946 - * and fault on destination. When this happens
60947 - * we clear too and hope it will trigger the
60948 - * EFAULT again.
60949 - */
60950 - if (n) {
60951 - if (clear_user(buffer + tsz - n,
60952 - n))
60953 + elf_buf = kmalloc(tsz, GFP_KERNEL);
60954 + if (!elf_buf)
60955 + return -ENOMEM;
60956 + oldfs = get_fs();
60957 + set_fs(KERNEL_DS);
60958 + if (!__copy_from_user(elf_buf, (const void __user *)start, tsz)) {
60959 + set_fs(oldfs);
60960 + if (copy_to_user(buffer, elf_buf, tsz)) {
60961 + kfree(elf_buf);
60962 return -EFAULT;
60963 + }
60964 }
60965 + set_fs(oldfs);
60966 + kfree(elf_buf);
60967 } else {
60968 if (clear_user(buffer, tsz))
60969 return -EFAULT;
60970 @@ -548,6 +552,9 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos)
60971
60972 static int open_kcore(struct inode *inode, struct file *filp)
60973 {
60974 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
60975 + return -EPERM;
60976 +#endif
60977 if (!capable(CAP_SYS_RAWIO))
60978 return -EPERM;
60979 if (kcore_need_update)
60980 diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c
60981 index 59d85d6..ac6fc05 100644
60982 --- a/fs/proc/meminfo.c
60983 +++ b/fs/proc/meminfo.c
60984 @@ -153,7 +153,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v)
60985 vmi.used >> 10,
60986 vmi.largest_chunk >> 10
60987 #ifdef CONFIG_MEMORY_FAILURE
60988 - ,atomic_long_read(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60989 + ,atomic_long_read_unchecked(&num_poisoned_pages) << (PAGE_SHIFT - 10)
60990 #endif
60991 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
60992 ,K(global_page_state(NR_ANON_TRANSPARENT_HUGEPAGES) *
60993 diff --git a/fs/proc/nommu.c b/fs/proc/nommu.c
60994 index ccfd99b..1b7e255 100644
60995 --- a/fs/proc/nommu.c
60996 +++ b/fs/proc/nommu.c
60997 @@ -66,7 +66,7 @@ static int nommu_region_show(struct seq_file *m, struct vm_region *region)
60998 if (len < 1)
60999 len = 1;
61000 seq_printf(m, "%*c", len, ' ');
61001 - seq_path(m, &file->f_path, "");
61002 + seq_path(m, &file->f_path, "\n\\");
61003 }
61004
61005 seq_putc(m, '\n');
61006 diff --git a/fs/proc/proc_net.c b/fs/proc/proc_net.c
61007 index 4677bb7..408e936 100644
61008 --- a/fs/proc/proc_net.c
61009 +++ b/fs/proc/proc_net.c
61010 @@ -23,6 +23,7 @@
61011 #include <linux/nsproxy.h>
61012 #include <net/net_namespace.h>
61013 #include <linux/seq_file.h>
61014 +#include <linux/grsecurity.h>
61015
61016 #include "internal.h"
61017
61018 @@ -109,6 +110,17 @@ static struct net *get_proc_task_net(struct inode *dir)
61019 struct task_struct *task;
61020 struct nsproxy *ns;
61021 struct net *net = NULL;
61022 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61023 + const struct cred *cred = current_cred();
61024 +#endif
61025 +
61026 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61027 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID))
61028 + return net;
61029 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61030 + if (!uid_eq(cred->fsuid, GLOBAL_ROOT_UID) && !in_group_p(grsec_proc_gid))
61031 + return net;
61032 +#endif
61033
61034 rcu_read_lock();
61035 task = pid_task(proc_pid(dir), PIDTYPE_PID);
61036 diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c
61037 index 7129046..6914844 100644
61038 --- a/fs/proc/proc_sysctl.c
61039 +++ b/fs/proc/proc_sysctl.c
61040 @@ -11,13 +11,21 @@
61041 #include <linux/namei.h>
61042 #include <linux/mm.h>
61043 #include <linux/module.h>
61044 +#include <linux/nsproxy.h>
61045 +#ifdef CONFIG_GRKERNSEC
61046 +#include <net/net_namespace.h>
61047 +#endif
61048 #include "internal.h"
61049
61050 +extern int gr_handle_chroot_sysctl(const int op);
61051 +extern int gr_handle_sysctl_mod(const char *dirname, const char *name,
61052 + const int op);
61053 +
61054 static const struct dentry_operations proc_sys_dentry_operations;
61055 static const struct file_operations proc_sys_file_operations;
61056 -static const struct inode_operations proc_sys_inode_operations;
61057 +const struct inode_operations proc_sys_inode_operations;
61058 static const struct file_operations proc_sys_dir_file_operations;
61059 -static const struct inode_operations proc_sys_dir_operations;
61060 +const struct inode_operations proc_sys_dir_operations;
61061
61062 void proc_sys_poll_notify(struct ctl_table_poll *poll)
61063 {
61064 @@ -467,6 +475,9 @@ static struct dentry *proc_sys_lookup(struct inode *dir, struct dentry *dentry,
61065
61066 err = NULL;
61067 d_set_d_op(dentry, &proc_sys_dentry_operations);
61068 +
61069 + gr_handle_proc_create(dentry, inode);
61070 +
61071 d_add(dentry, inode);
61072
61073 out:
61074 @@ -482,6 +493,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61075 struct inode *inode = file_inode(filp);
61076 struct ctl_table_header *head = grab_header(inode);
61077 struct ctl_table *table = PROC_I(inode)->sysctl_entry;
61078 + int op = write ? MAY_WRITE : MAY_READ;
61079 ssize_t error;
61080 size_t res;
61081
61082 @@ -493,7 +505,7 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61083 * and won't be until we finish.
61084 */
61085 error = -EPERM;
61086 - if (sysctl_perm(head, table, write ? MAY_WRITE : MAY_READ))
61087 + if (sysctl_perm(head, table, op))
61088 goto out;
61089
61090 /* if that can happen at all, it should be -EINVAL, not -EISDIR */
61091 @@ -501,6 +513,27 @@ static ssize_t proc_sys_call_handler(struct file *filp, void __user *buf,
61092 if (!table->proc_handler)
61093 goto out;
61094
61095 +#ifdef CONFIG_GRKERNSEC
61096 + error = -EPERM;
61097 + if (gr_handle_chroot_sysctl(op))
61098 + goto out;
61099 + dget(filp->f_path.dentry);
61100 + if (gr_handle_sysctl_mod(filp->f_path.dentry->d_parent->d_name.name, table->procname, op)) {
61101 + dput(filp->f_path.dentry);
61102 + goto out;
61103 + }
61104 + dput(filp->f_path.dentry);
61105 + if (!gr_acl_handle_open(filp->f_path.dentry, filp->f_path.mnt, op))
61106 + goto out;
61107 + if (write) {
61108 + if (current->nsproxy->net_ns != table->extra2) {
61109 + if (!capable(CAP_SYS_ADMIN))
61110 + goto out;
61111 + } else if (!ns_capable(current->nsproxy->net_ns->user_ns, CAP_NET_ADMIN))
61112 + goto out;
61113 + }
61114 +#endif
61115 +
61116 /* careful: calling conventions are nasty here */
61117 res = count;
61118 error = table->proc_handler(table, write, buf, &res, ppos);
61119 @@ -598,6 +631,9 @@ static bool proc_sys_fill_cache(struct file *file,
61120 return false;
61121 } else {
61122 d_set_d_op(child, &proc_sys_dentry_operations);
61123 +
61124 + gr_handle_proc_create(child, inode);
61125 +
61126 d_add(child, inode);
61127 }
61128 } else {
61129 @@ -641,6 +677,9 @@ static int scan(struct ctl_table_header *head, ctl_table *table,
61130 if ((*pos)++ < ctx->pos)
61131 return true;
61132
61133 + if (!gr_acl_handle_hidden_file(file->f_path.dentry, file->f_path.mnt))
61134 + return 0;
61135 +
61136 if (unlikely(S_ISLNK(table->mode)))
61137 res = proc_sys_link_fill_cache(file, ctx, head, table);
61138 else
61139 @@ -734,6 +773,9 @@ static int proc_sys_getattr(struct vfsmount *mnt, struct dentry *dentry, struct
61140 if (IS_ERR(head))
61141 return PTR_ERR(head);
61142
61143 + if (table && !gr_acl_handle_hidden_file(dentry, mnt))
61144 + return -ENOENT;
61145 +
61146 generic_fillattr(inode, stat);
61147 if (table)
61148 stat->mode = (stat->mode & S_IFMT) | table->mode;
61149 @@ -756,13 +798,13 @@ static const struct file_operations proc_sys_dir_file_operations = {
61150 .llseek = generic_file_llseek,
61151 };
61152
61153 -static const struct inode_operations proc_sys_inode_operations = {
61154 +const struct inode_operations proc_sys_inode_operations = {
61155 .permission = proc_sys_permission,
61156 .setattr = proc_sys_setattr,
61157 .getattr = proc_sys_getattr,
61158 };
61159
61160 -static const struct inode_operations proc_sys_dir_operations = {
61161 +const struct inode_operations proc_sys_dir_operations = {
61162 .lookup = proc_sys_lookup,
61163 .permission = proc_sys_permission,
61164 .setattr = proc_sys_setattr,
61165 @@ -839,7 +881,7 @@ static struct ctl_dir *find_subdir(struct ctl_dir *dir,
61166 static struct ctl_dir *new_dir(struct ctl_table_set *set,
61167 const char *name, int namelen)
61168 {
61169 - struct ctl_table *table;
61170 + ctl_table_no_const *table;
61171 struct ctl_dir *new;
61172 struct ctl_node *node;
61173 char *new_name;
61174 @@ -851,7 +893,7 @@ static struct ctl_dir *new_dir(struct ctl_table_set *set,
61175 return NULL;
61176
61177 node = (struct ctl_node *)(new + 1);
61178 - table = (struct ctl_table *)(node + 1);
61179 + table = (ctl_table_no_const *)(node + 1);
61180 new_name = (char *)(table + 2);
61181 memcpy(new_name, name, namelen);
61182 new_name[namelen] = '\0';
61183 @@ -1020,7 +1062,8 @@ static int sysctl_check_table(const char *path, struct ctl_table *table)
61184 static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table *table,
61185 struct ctl_table_root *link_root)
61186 {
61187 - struct ctl_table *link_table, *entry, *link;
61188 + ctl_table_no_const *link_table, *link;
61189 + struct ctl_table *entry;
61190 struct ctl_table_header *links;
61191 struct ctl_node *node;
61192 char *link_name;
61193 @@ -1043,7 +1086,7 @@ static struct ctl_table_header *new_links(struct ctl_dir *dir, struct ctl_table
61194 return NULL;
61195
61196 node = (struct ctl_node *)(links + 1);
61197 - link_table = (struct ctl_table *)(node + nr_entries);
61198 + link_table = (ctl_table_no_const *)(node + nr_entries);
61199 link_name = (char *)&link_table[nr_entries + 1];
61200
61201 for (link = link_table, entry = table; entry->procname; link++, entry++) {
61202 @@ -1291,8 +1334,8 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61203 struct ctl_table_header ***subheader, struct ctl_table_set *set,
61204 struct ctl_table *table)
61205 {
61206 - struct ctl_table *ctl_table_arg = NULL;
61207 - struct ctl_table *entry, *files;
61208 + ctl_table_no_const *ctl_table_arg = NULL, *files = NULL;
61209 + struct ctl_table *entry;
61210 int nr_files = 0;
61211 int nr_dirs = 0;
61212 int err = -ENOMEM;
61213 @@ -1304,10 +1347,9 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61214 nr_files++;
61215 }
61216
61217 - files = table;
61218 /* If there are mixed files and directories we need a new table */
61219 if (nr_dirs && nr_files) {
61220 - struct ctl_table *new;
61221 + ctl_table_no_const *new;
61222 files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
61223 GFP_KERNEL);
61224 if (!files)
61225 @@ -1325,7 +1367,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos,
61226 /* Register everything except a directory full of subdirectories */
61227 if (nr_files || !nr_dirs) {
61228 struct ctl_table_header *header;
61229 - header = __register_sysctl_table(set, path, files);
61230 + header = __register_sysctl_table(set, path, files ? files : table);
61231 if (!header) {
61232 kfree(ctl_table_arg);
61233 goto out;
61234 diff --git a/fs/proc/root.c b/fs/proc/root.c
61235 index 87dbcbe..55e1b4d 100644
61236 --- a/fs/proc/root.c
61237 +++ b/fs/proc/root.c
61238 @@ -186,7 +186,15 @@ void __init proc_root_init(void)
61239 #ifdef CONFIG_PROC_DEVICETREE
61240 proc_device_tree_init();
61241 #endif
61242 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61243 +#ifdef CONFIG_GRKERNSEC_PROC_USER
61244 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR, NULL);
61245 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61246 + proc_mkdir_mode("bus", S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP, NULL);
61247 +#endif
61248 +#else
61249 proc_mkdir("bus", NULL);
61250 +#endif
61251 proc_sys_init();
61252 }
61253
61254 diff --git a/fs/proc/self.c b/fs/proc/self.c
61255 index 6b6a993..807cccc 100644
61256 --- a/fs/proc/self.c
61257 +++ b/fs/proc/self.c
61258 @@ -39,7 +39,7 @@ static void *proc_self_follow_link(struct dentry *dentry, struct nameidata *nd)
61259 static void proc_self_put_link(struct dentry *dentry, struct nameidata *nd,
61260 void *cookie)
61261 {
61262 - char *s = nd_get_link(nd);
61263 + const char *s = nd_get_link(nd);
61264 if (!IS_ERR(s))
61265 kfree(s);
61266 }
61267 diff --git a/fs/proc/stat.c b/fs/proc/stat.c
61268 index 1cf86c0..0ee1ca5 100644
61269 --- a/fs/proc/stat.c
61270 +++ b/fs/proc/stat.c
61271 @@ -11,6 +11,7 @@
61272 #include <linux/irqnr.h>
61273 #include <asm/cputime.h>
61274 #include <linux/tick.h>
61275 +#include <linux/grsecurity.h>
61276
61277 #ifndef arch_irq_stat_cpu
61278 #define arch_irq_stat_cpu(cpu) 0
61279 @@ -87,6 +88,18 @@ static int show_stat(struct seq_file *p, void *v)
61280 u64 sum_softirq = 0;
61281 unsigned int per_softirq_sums[NR_SOFTIRQS] = {0};
61282 struct timespec boottime;
61283 + int unrestricted = 1;
61284 +
61285 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
61286 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
61287 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
61288 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
61289 + && !in_group_p(grsec_proc_gid)
61290 +#endif
61291 + )
61292 + unrestricted = 0;
61293 +#endif
61294 +#endif
61295
61296 user = nice = system = idle = iowait =
61297 irq = softirq = steal = 0;
61298 @@ -94,6 +107,7 @@ static int show_stat(struct seq_file *p, void *v)
61299 getboottime(&boottime);
61300 jif = boottime.tv_sec;
61301
61302 + if (unrestricted) {
61303 for_each_possible_cpu(i) {
61304 user += kcpustat_cpu(i).cpustat[CPUTIME_USER];
61305 nice += kcpustat_cpu(i).cpustat[CPUTIME_NICE];
61306 @@ -116,6 +130,7 @@ static int show_stat(struct seq_file *p, void *v)
61307 }
61308 }
61309 sum += arch_irq_stat();
61310 + }
61311
61312 seq_puts(p, "cpu ");
61313 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
61314 @@ -131,6 +146,7 @@ static int show_stat(struct seq_file *p, void *v)
61315 seq_putc(p, '\n');
61316
61317 for_each_online_cpu(i) {
61318 + if (unrestricted) {
61319 /* Copy values here to work around gcc-2.95.3, gcc-2.96 */
61320 user = kcpustat_cpu(i).cpustat[CPUTIME_USER];
61321 nice = kcpustat_cpu(i).cpustat[CPUTIME_NICE];
61322 @@ -142,6 +158,7 @@ static int show_stat(struct seq_file *p, void *v)
61323 steal = kcpustat_cpu(i).cpustat[CPUTIME_STEAL];
61324 guest = kcpustat_cpu(i).cpustat[CPUTIME_GUEST];
61325 guest_nice = kcpustat_cpu(i).cpustat[CPUTIME_GUEST_NICE];
61326 + }
61327 seq_printf(p, "cpu%d", i);
61328 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(user));
61329 seq_put_decimal_ull(p, ' ', cputime64_to_clock_t(nice));
61330 @@ -159,7 +176,7 @@ static int show_stat(struct seq_file *p, void *v)
61331
61332 /* sum again ? it could be updated? */
61333 for_each_irq_nr(j)
61334 - seq_put_decimal_ull(p, ' ', kstat_irqs(j));
61335 + seq_put_decimal_ull(p, ' ', unrestricted ? kstat_irqs(j) : 0ULL);
61336
61337 seq_printf(p,
61338 "\nctxt %llu\n"
61339 @@ -167,11 +184,11 @@ static int show_stat(struct seq_file *p, void *v)
61340 "processes %lu\n"
61341 "procs_running %lu\n"
61342 "procs_blocked %lu\n",
61343 - nr_context_switches(),
61344 + unrestricted ? nr_context_switches() : 0ULL,
61345 (unsigned long)jif,
61346 - total_forks,
61347 - nr_running(),
61348 - nr_iowait());
61349 + unrestricted ? total_forks : 0UL,
61350 + unrestricted ? nr_running() : 0UL,
61351 + unrestricted ? nr_iowait() : 0UL);
61352
61353 seq_printf(p, "softirq %llu", (unsigned long long)sum_softirq);
61354
61355 diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c
61356 index 390bdab..83c1e8a 100644
61357 --- a/fs/proc/task_mmu.c
61358 +++ b/fs/proc/task_mmu.c
61359 @@ -12,12 +12,19 @@
61360 #include <linux/swap.h>
61361 #include <linux/swapops.h>
61362 #include <linux/mmu_notifier.h>
61363 +#include <linux/grsecurity.h>
61364
61365 #include <asm/elf.h>
61366 #include <asm/uaccess.h>
61367 #include <asm/tlbflush.h>
61368 #include "internal.h"
61369
61370 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61371 +#define PAX_RAND_FLAGS(_mm) (_mm != NULL && _mm != current->mm && \
61372 + (_mm->pax_flags & MF_PAX_RANDMMAP || \
61373 + _mm->pax_flags & MF_PAX_SEGMEXEC))
61374 +#endif
61375 +
61376 void task_mem(struct seq_file *m, struct mm_struct *mm)
61377 {
61378 unsigned long data, text, lib, swap;
61379 @@ -53,8 +60,13 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61380 "VmExe:\t%8lu kB\n"
61381 "VmLib:\t%8lu kB\n"
61382 "VmPTE:\t%8lu kB\n"
61383 - "VmSwap:\t%8lu kB\n",
61384 - hiwater_vm << (PAGE_SHIFT-10),
61385 + "VmSwap:\t%8lu kB\n"
61386 +
61387 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61388 + "CsBase:\t%8lx\nCsLim:\t%8lx\n"
61389 +#endif
61390 +
61391 + ,hiwater_vm << (PAGE_SHIFT-10),
61392 total_vm << (PAGE_SHIFT-10),
61393 mm->locked_vm << (PAGE_SHIFT-10),
61394 mm->pinned_vm << (PAGE_SHIFT-10),
61395 @@ -63,7 +75,19 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61396 data << (PAGE_SHIFT-10),
61397 mm->stack_vm << (PAGE_SHIFT-10), text, lib,
61398 (PTRS_PER_PTE*sizeof(pte_t)*mm->nr_ptes) >> 10,
61399 - swap << (PAGE_SHIFT-10));
61400 + swap << (PAGE_SHIFT-10)
61401 +
61402 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
61403 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61404 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_base
61405 + , PAX_RAND_FLAGS(mm) ? 0 : mm->context.user_cs_limit
61406 +#else
61407 + , mm->context.user_cs_base
61408 + , mm->context.user_cs_limit
61409 +#endif
61410 +#endif
61411 +
61412 + );
61413 }
61414
61415 unsigned long task_vsize(struct mm_struct *mm)
61416 @@ -278,13 +302,13 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61417 pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT;
61418 }
61419
61420 - /* We don't show the stack guard page in /proc/maps */
61421 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61422 + start = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_start;
61423 + end = PAX_RAND_FLAGS(mm) ? 0UL : vma->vm_end;
61424 +#else
61425 start = vma->vm_start;
61426 - if (stack_guard_page_start(vma, start))
61427 - start += PAGE_SIZE;
61428 end = vma->vm_end;
61429 - if (stack_guard_page_end(vma, end))
61430 - end -= PAGE_SIZE;
61431 +#endif
61432
61433 seq_printf(m, "%08lx-%08lx %c%c%c%c %08llx %02x:%02x %lu %n",
61434 start,
61435 @@ -293,7 +317,11 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61436 flags & VM_WRITE ? 'w' : '-',
61437 flags & VM_EXEC ? 'x' : '-',
61438 flags & VM_MAYSHARE ? 's' : 'p',
61439 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61440 + PAX_RAND_FLAGS(mm) ? 0UL : pgoff,
61441 +#else
61442 pgoff,
61443 +#endif
61444 MAJOR(dev), MINOR(dev), ino, &len);
61445
61446 /*
61447 @@ -302,7 +330,7 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61448 */
61449 if (file) {
61450 pad_len_spaces(m, len);
61451 - seq_path(m, &file->f_path, "\n");
61452 + seq_path(m, &file->f_path, "\n\\");
61453 goto done;
61454 }
61455
61456 @@ -328,8 +356,9 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma, int is_pid)
61457 * Thread stack in /proc/PID/task/TID/maps or
61458 * the main process stack.
61459 */
61460 - if (!is_pid || (vma->vm_start <= mm->start_stack &&
61461 - vma->vm_end >= mm->start_stack)) {
61462 + if (!is_pid || (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP)) ||
61463 + (vma->vm_start <= mm->start_stack &&
61464 + vma->vm_end >= mm->start_stack)) {
61465 name = "[stack]";
61466 } else {
61467 /* Thread stack in /proc/PID/maps */
61468 @@ -353,6 +382,13 @@ static int show_map(struct seq_file *m, void *v, int is_pid)
61469 struct proc_maps_private *priv = m->private;
61470 struct task_struct *task = priv->task;
61471
61472 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61473 + if (current->exec_id != m->exec_id) {
61474 + gr_log_badprocpid("maps");
61475 + return 0;
61476 + }
61477 +#endif
61478 +
61479 show_map_vma(m, vma, is_pid);
61480
61481 if (m->count < m->size) /* vma is copied successfully */
61482 @@ -590,12 +626,23 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61483 .private = &mss,
61484 };
61485
61486 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61487 + if (current->exec_id != m->exec_id) {
61488 + gr_log_badprocpid("smaps");
61489 + return 0;
61490 + }
61491 +#endif
61492 memset(&mss, 0, sizeof mss);
61493 - mss.vma = vma;
61494 - /* mmap_sem is held in m_start */
61495 - if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61496 - walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61497 -
61498 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61499 + if (!PAX_RAND_FLAGS(vma->vm_mm)) {
61500 +#endif
61501 + mss.vma = vma;
61502 + /* mmap_sem is held in m_start */
61503 + if (vma->vm_mm && !is_vm_hugetlb_page(vma))
61504 + walk_page_range(vma->vm_start, vma->vm_end, &smaps_walk);
61505 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61506 + }
61507 +#endif
61508 show_map_vma(m, vma, is_pid);
61509
61510 seq_printf(m,
61511 @@ -613,7 +660,11 @@ static int show_smap(struct seq_file *m, void *v, int is_pid)
61512 "KernelPageSize: %8lu kB\n"
61513 "MMUPageSize: %8lu kB\n"
61514 "Locked: %8lu kB\n",
61515 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61516 + PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : (vma->vm_end - vma->vm_start) >> 10,
61517 +#else
61518 (vma->vm_end - vma->vm_start) >> 10,
61519 +#endif
61520 mss.resident >> 10,
61521 (unsigned long)(mss.pss >> (10 + PSS_SHIFT)),
61522 mss.shared_clean >> 10,
61523 @@ -1390,6 +1441,13 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61524 int n;
61525 char buffer[50];
61526
61527 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61528 + if (current->exec_id != m->exec_id) {
61529 + gr_log_badprocpid("numa_maps");
61530 + return 0;
61531 + }
61532 +#endif
61533 +
61534 if (!mm)
61535 return 0;
61536
61537 @@ -1409,11 +1467,15 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
61538 if (n < 0)
61539 return n;
61540
61541 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61542 + seq_printf(m, "%08lx %s", PAX_RAND_FLAGS(vma->vm_mm) ? 0UL : vma->vm_start, buffer);
61543 +#else
61544 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
61545 +#endif
61546
61547 if (file) {
61548 seq_printf(m, " file=");
61549 - seq_path(m, &file->f_path, "\n\t= ");
61550 + seq_path(m, &file->f_path, "\n\t\\= ");
61551 } else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {
61552 seq_printf(m, " heap");
61553 } else {
61554 diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c
61555 index 56123a6..5a2f6ec 100644
61556 --- a/fs/proc/task_nommu.c
61557 +++ b/fs/proc/task_nommu.c
61558 @@ -51,7 +51,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
61559 else
61560 bytes += kobjsize(mm);
61561
61562 - if (current->fs && current->fs->users > 1)
61563 + if (current->fs && atomic_read(&current->fs->users) > 1)
61564 sbytes += kobjsize(current->fs);
61565 else
61566 bytes += kobjsize(current->fs);
61567 @@ -168,7 +168,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma,
61568
61569 if (file) {
61570 pad_len_spaces(m, len);
61571 - seq_path(m, &file->f_path, "");
61572 + seq_path(m, &file->f_path, "\n\\");
61573 } else if (mm) {
61574 pid_t tid = vm_is_stack(priv->task, vma, is_pid);
61575
61576 diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c
61577 index 9100d69..f1f9fc9 100644
61578 --- a/fs/proc/vmcore.c
61579 +++ b/fs/proc/vmcore.c
61580 @@ -105,9 +105,13 @@ static ssize_t read_from_oldmem(char *buf, size_t count,
61581 nr_bytes = count;
61582
61583 /* If pfn is not ram, return zeros for sparse dump files */
61584 - if (pfn_is_ram(pfn) == 0)
61585 - memset(buf, 0, nr_bytes);
61586 - else {
61587 + if (pfn_is_ram(pfn) == 0) {
61588 + if (userbuf) {
61589 + if (clear_user((char __force_user *)buf, nr_bytes))
61590 + return -EFAULT;
61591 + } else
61592 + memset(buf, 0, nr_bytes);
61593 + } else {
61594 tmp = copy_oldmem_page(pfn, buf, nr_bytes,
61595 offset, userbuf);
61596 if (tmp < 0)
61597 @@ -233,7 +237,7 @@ static ssize_t __read_vmcore(char *buffer, size_t buflen, loff_t *fpos,
61598 if (*fpos < m->offset + m->size) {
61599 tsz = min_t(size_t, m->offset + m->size - *fpos, buflen);
61600 start = m->paddr + *fpos - m->offset;
61601 - tmp = read_from_oldmem(buffer, tsz, &start, userbuf);
61602 + tmp = read_from_oldmem((char __force_kernel *)buffer, tsz, &start, userbuf);
61603 if (tmp < 0)
61604 return tmp;
61605 buflen -= tsz;
61606 diff --git a/fs/qnx6/qnx6.h b/fs/qnx6/qnx6.h
61607 index b00fcc9..e0c6381 100644
61608 --- a/fs/qnx6/qnx6.h
61609 +++ b/fs/qnx6/qnx6.h
61610 @@ -74,7 +74,7 @@ enum {
61611 BYTESEX_BE,
61612 };
61613
61614 -static inline __u64 fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61615 +static inline __u64 __intentional_overflow(-1) fs64_to_cpu(struct qnx6_sb_info *sbi, __fs64 n)
61616 {
61617 if (sbi->s_bytesex == BYTESEX_LE)
61618 return le64_to_cpu((__force __le64)n);
61619 @@ -90,7 +90,7 @@ static inline __fs64 cpu_to_fs64(struct qnx6_sb_info *sbi, __u64 n)
61620 return (__force __fs64)cpu_to_be64(n);
61621 }
61622
61623 -static inline __u32 fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61624 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct qnx6_sb_info *sbi, __fs32 n)
61625 {
61626 if (sbi->s_bytesex == BYTESEX_LE)
61627 return le32_to_cpu((__force __le32)n);
61628 diff --git a/fs/quota/netlink.c b/fs/quota/netlink.c
61629 index 16e8abb..2dcf914 100644
61630 --- a/fs/quota/netlink.c
61631 +++ b/fs/quota/netlink.c
61632 @@ -33,7 +33,7 @@ static struct genl_family quota_genl_family = {
61633 void quota_send_warning(struct kqid qid, dev_t dev,
61634 const char warntype)
61635 {
61636 - static atomic_t seq;
61637 + static atomic_unchecked_t seq;
61638 struct sk_buff *skb;
61639 void *msg_head;
61640 int ret;
61641 @@ -49,7 +49,7 @@ void quota_send_warning(struct kqid qid, dev_t dev,
61642 "VFS: Not enough memory to send quota warning.\n");
61643 return;
61644 }
61645 - msg_head = genlmsg_put(skb, 0, atomic_add_return(1, &seq),
61646 + msg_head = genlmsg_put(skb, 0, atomic_add_return_unchecked(1, &seq),
61647 &quota_genl_family, 0, QUOTA_NL_C_WARNING);
61648 if (!msg_head) {
61649 printk(KERN_ERR
61650 diff --git a/fs/read_write.c b/fs/read_write.c
61651 index e3cd280..a378473 100644
61652 --- a/fs/read_write.c
61653 +++ b/fs/read_write.c
61654 @@ -438,7 +438,7 @@ ssize_t __kernel_write(struct file *file, const char *buf, size_t count, loff_t
61655
61656 old_fs = get_fs();
61657 set_fs(get_ds());
61658 - p = (__force const char __user *)buf;
61659 + p = (const char __force_user *)buf;
61660 if (count > MAX_RW_COUNT)
61661 count = MAX_RW_COUNT;
61662 if (file->f_op->write)
61663 diff --git a/fs/readdir.c b/fs/readdir.c
61664 index 93d71e5..6a14be8 100644
61665 --- a/fs/readdir.c
61666 +++ b/fs/readdir.c
61667 @@ -17,6 +17,7 @@
61668 #include <linux/security.h>
61669 #include <linux/syscalls.h>
61670 #include <linux/unistd.h>
61671 +#include <linux/namei.h>
61672
61673 #include <asm/uaccess.h>
61674
61675 @@ -69,6 +70,7 @@ struct old_linux_dirent {
61676 struct readdir_callback {
61677 struct dir_context ctx;
61678 struct old_linux_dirent __user * dirent;
61679 + struct file * file;
61680 int result;
61681 };
61682
61683 @@ -86,6 +88,10 @@ static int fillonedir(void * __buf, const char * name, int namlen, loff_t offset
61684 buf->result = -EOVERFLOW;
61685 return -EOVERFLOW;
61686 }
61687 +
61688 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61689 + return 0;
61690 +
61691 buf->result++;
61692 dirent = buf->dirent;
61693 if (!access_ok(VERIFY_WRITE, dirent,
61694 @@ -117,6 +123,7 @@ SYSCALL_DEFINE3(old_readdir, unsigned int, fd,
61695 if (!f.file)
61696 return -EBADF;
61697
61698 + buf.file = f.file;
61699 error = iterate_dir(f.file, &buf.ctx);
61700 if (buf.result)
61701 error = buf.result;
61702 @@ -142,6 +149,7 @@ struct getdents_callback {
61703 struct dir_context ctx;
61704 struct linux_dirent __user * current_dir;
61705 struct linux_dirent __user * previous;
61706 + struct file * file;
61707 int count;
61708 int error;
61709 };
61710 @@ -163,6 +171,10 @@ static int filldir(void * __buf, const char * name, int namlen, loff_t offset,
61711 buf->error = -EOVERFLOW;
61712 return -EOVERFLOW;
61713 }
61714 +
61715 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61716 + return 0;
61717 +
61718 dirent = buf->previous;
61719 if (dirent) {
61720 if (__put_user(offset, &dirent->d_off))
61721 @@ -208,6 +220,7 @@ SYSCALL_DEFINE3(getdents, unsigned int, fd,
61722 if (!f.file)
61723 return -EBADF;
61724
61725 + buf.file = f.file;
61726 error = iterate_dir(f.file, &buf.ctx);
61727 if (error >= 0)
61728 error = buf.error;
61729 @@ -226,6 +239,7 @@ struct getdents_callback64 {
61730 struct dir_context ctx;
61731 struct linux_dirent64 __user * current_dir;
61732 struct linux_dirent64 __user * previous;
61733 + struct file *file;
61734 int count;
61735 int error;
61736 };
61737 @@ -241,6 +255,10 @@ static int filldir64(void * __buf, const char * name, int namlen, loff_t offset,
61738 buf->error = -EINVAL; /* only used if we fail.. */
61739 if (reclen > buf->count)
61740 return -EINVAL;
61741 +
61742 + if (!gr_acl_handle_filldir(buf->file, name, namlen, ino))
61743 + return 0;
61744 +
61745 dirent = buf->previous;
61746 if (dirent) {
61747 if (__put_user(offset, &dirent->d_off))
61748 @@ -288,6 +306,7 @@ SYSCALL_DEFINE3(getdents64, unsigned int, fd,
61749 if (!f.file)
61750 return -EBADF;
61751
61752 + buf.file = f.file;
61753 error = iterate_dir(f.file, &buf.ctx);
61754 if (error >= 0)
61755 error = buf.error;
61756 diff --git a/fs/reiserfs/do_balan.c b/fs/reiserfs/do_balan.c
61757 index 2b7882b..1c5ef48 100644
61758 --- a/fs/reiserfs/do_balan.c
61759 +++ b/fs/reiserfs/do_balan.c
61760 @@ -2051,7 +2051,7 @@ void do_balance(struct tree_balance *tb, /* tree_balance structure */
61761 return;
61762 }
61763
61764 - atomic_inc(&(fs_generation(tb->tb_sb)));
61765 + atomic_inc_unchecked(&(fs_generation(tb->tb_sb)));
61766 do_balance_starts(tb);
61767
61768 /* balance leaf returns 0 except if combining L R and S into
61769 diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
61770 index a958444..42b2323 100644
61771 --- a/fs/reiserfs/procfs.c
61772 +++ b/fs/reiserfs/procfs.c
61773 @@ -114,7 +114,7 @@ static int show_super(struct seq_file *m, void *unused)
61774 "SMALL_TAILS " : "NO_TAILS ",
61775 replay_only(sb) ? "REPLAY_ONLY " : "",
61776 convert_reiserfs(sb) ? "CONV " : "",
61777 - atomic_read(&r->s_generation_counter),
61778 + atomic_read_unchecked(&r->s_generation_counter),
61779 SF(s_disk_reads), SF(s_disk_writes), SF(s_fix_nodes),
61780 SF(s_do_balance), SF(s_unneeded_left_neighbor),
61781 SF(s_good_search_by_key_reada), SF(s_bmaps),
61782 diff --git a/fs/reiserfs/reiserfs.h b/fs/reiserfs/reiserfs.h
61783 index f8adaee..0eeeeca 100644
61784 --- a/fs/reiserfs/reiserfs.h
61785 +++ b/fs/reiserfs/reiserfs.h
61786 @@ -453,7 +453,7 @@ struct reiserfs_sb_info {
61787 /* Comment? -Hans */
61788 wait_queue_head_t s_wait;
61789 /* To be obsoleted soon by per buffer seals.. -Hans */
61790 - atomic_t s_generation_counter; // increased by one every time the
61791 + atomic_unchecked_t s_generation_counter; // increased by one every time the
61792 // tree gets re-balanced
61793 unsigned long s_properties; /* File system properties. Currently holds
61794 on-disk FS format */
61795 @@ -1982,7 +1982,7 @@ static inline loff_t max_reiserfs_offset(struct inode *inode)
61796 #define REISERFS_USER_MEM 1 /* reiserfs user memory mode */
61797
61798 #define fs_generation(s) (REISERFS_SB(s)->s_generation_counter)
61799 -#define get_generation(s) atomic_read (&fs_generation(s))
61800 +#define get_generation(s) atomic_read_unchecked (&fs_generation(s))
61801 #define FILESYSTEM_CHANGED_TB(tb) (get_generation((tb)->tb_sb) != (tb)->fs_gen)
61802 #define __fs_changed(gen,s) (gen != get_generation (s))
61803 #define fs_changed(gen,s) \
61804 diff --git a/fs/select.c b/fs/select.c
61805 index dfd5cb1..1754d57 100644
61806 --- a/fs/select.c
61807 +++ b/fs/select.c
61808 @@ -20,6 +20,7 @@
61809 #include <linux/export.h>
61810 #include <linux/slab.h>
61811 #include <linux/poll.h>
61812 +#include <linux/security.h>
61813 #include <linux/personality.h> /* for STICKY_TIMEOUTS */
61814 #include <linux/file.h>
61815 #include <linux/fdtable.h>
61816 @@ -880,6 +881,7 @@ int do_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
61817 struct poll_list *walk = head;
61818 unsigned long todo = nfds;
61819
61820 + gr_learn_resource(current, RLIMIT_NOFILE, nfds, 1);
61821 if (nfds > rlimit(RLIMIT_NOFILE))
61822 return -EINVAL;
61823
61824 diff --git a/fs/seq_file.c b/fs/seq_file.c
61825 index a290157..ec3211a 100644
61826 --- a/fs/seq_file.c
61827 +++ b/fs/seq_file.c
61828 @@ -10,6 +10,7 @@
61829 #include <linux/seq_file.h>
61830 #include <linux/slab.h>
61831 #include <linux/cred.h>
61832 +#include <linux/sched.h>
61833
61834 #include <asm/uaccess.h>
61835 #include <asm/page.h>
61836 @@ -60,6 +61,9 @@ int seq_open(struct file *file, const struct seq_operations *op)
61837 #ifdef CONFIG_USER_NS
61838 p->user_ns = file->f_cred->user_ns;
61839 #endif
61840 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
61841 + p->exec_id = current->exec_id;
61842 +#endif
61843
61844 /*
61845 * Wrappers around seq_open(e.g. swaps_open) need to be
61846 @@ -96,7 +100,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61847 return 0;
61848 }
61849 if (!m->buf) {
61850 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61851 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61852 if (!m->buf)
61853 return -ENOMEM;
61854 }
61855 @@ -136,7 +140,7 @@ static int traverse(struct seq_file *m, loff_t offset)
61856 Eoverflow:
61857 m->op->stop(m, p);
61858 kfree(m->buf);
61859 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61860 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61861 return !m->buf ? -ENOMEM : -EAGAIN;
61862 }
61863
61864 @@ -152,7 +156,7 @@ Eoverflow:
61865 ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61866 {
61867 struct seq_file *m = file->private_data;
61868 - size_t copied = 0;
61869 + ssize_t copied = 0;
61870 loff_t pos;
61871 size_t n;
61872 void *p;
61873 @@ -191,7 +195,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61874
61875 /* grab buffer if we didn't have one */
61876 if (!m->buf) {
61877 - m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL);
61878 + m->buf = kmalloc(m->size = PAGE_SIZE, GFP_KERNEL | GFP_USERCOPY);
61879 if (!m->buf)
61880 goto Enomem;
61881 }
61882 @@ -232,7 +236,7 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos)
61883 goto Fill;
61884 m->op->stop(m, p);
61885 kfree(m->buf);
61886 - m->buf = kmalloc(m->size <<= 1, GFP_KERNEL);
61887 + m->buf = kmalloc(m->size <<= 1, GFP_KERNEL | GFP_USERCOPY);
61888 if (!m->buf)
61889 goto Enomem;
61890 m->count = 0;
61891 @@ -583,7 +587,7 @@ static void single_stop(struct seq_file *p, void *v)
61892 int single_open(struct file *file, int (*show)(struct seq_file *, void *),
61893 void *data)
61894 {
61895 - struct seq_operations *op = kmalloc(sizeof(*op), GFP_KERNEL);
61896 + seq_operations_no_const *op = kzalloc(sizeof(*op), GFP_KERNEL);
61897 int res = -ENOMEM;
61898
61899 if (op) {
61900 diff --git a/fs/splice.c b/fs/splice.c
61901 index 3b7ee65..87fc2e4 100644
61902 --- a/fs/splice.c
61903 +++ b/fs/splice.c
61904 @@ -196,7 +196,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61905 pipe_lock(pipe);
61906
61907 for (;;) {
61908 - if (!pipe->readers) {
61909 + if (!atomic_read(&pipe->readers)) {
61910 send_sig(SIGPIPE, current, 0);
61911 if (!ret)
61912 ret = -EPIPE;
61913 @@ -219,7 +219,7 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61914 page_nr++;
61915 ret += buf->len;
61916
61917 - if (pipe->files)
61918 + if (atomic_read(&pipe->files))
61919 do_wakeup = 1;
61920
61921 if (!--spd->nr_pages)
61922 @@ -250,9 +250,9 @@ ssize_t splice_to_pipe(struct pipe_inode_info *pipe,
61923 do_wakeup = 0;
61924 }
61925
61926 - pipe->waiting_writers++;
61927 + atomic_inc(&pipe->waiting_writers);
61928 pipe_wait(pipe);
61929 - pipe->waiting_writers--;
61930 + atomic_dec(&pipe->waiting_writers);
61931 }
61932
61933 pipe_unlock(pipe);
61934 @@ -565,7 +565,7 @@ static ssize_t kernel_readv(struct file *file, const struct iovec *vec,
61935 old_fs = get_fs();
61936 set_fs(get_ds());
61937 /* The cast to a user pointer is valid due to the set_fs() */
61938 - res = vfs_readv(file, (const struct iovec __user *)vec, vlen, &pos);
61939 + res = vfs_readv(file, (const struct iovec __force_user *)vec, vlen, &pos);
61940 set_fs(old_fs);
61941
61942 return res;
61943 @@ -580,7 +580,7 @@ ssize_t kernel_write(struct file *file, const char *buf, size_t count,
61944 old_fs = get_fs();
61945 set_fs(get_ds());
61946 /* The cast to a user pointer is valid due to the set_fs() */
61947 - res = vfs_write(file, (__force const char __user *)buf, count, &pos);
61948 + res = vfs_write(file, (const char __force_user *)buf, count, &pos);
61949 set_fs(old_fs);
61950
61951 return res;
61952 @@ -633,7 +633,7 @@ ssize_t default_file_splice_read(struct file *in, loff_t *ppos,
61953 goto err;
61954
61955 this_len = min_t(size_t, len, PAGE_CACHE_SIZE - offset);
61956 - vec[i].iov_base = (void __user *) page_address(page);
61957 + vec[i].iov_base = (void __force_user *) page_address(page);
61958 vec[i].iov_len = this_len;
61959 spd.pages[i] = page;
61960 spd.nr_pages++;
61961 @@ -829,7 +829,7 @@ int splice_from_pipe_feed(struct pipe_inode_info *pipe, struct splice_desc *sd,
61962 ops->release(pipe, buf);
61963 pipe->curbuf = (pipe->curbuf + 1) & (pipe->buffers - 1);
61964 pipe->nrbufs--;
61965 - if (pipe->files)
61966 + if (atomic_read(&pipe->files))
61967 sd->need_wakeup = true;
61968 }
61969
61970 @@ -854,10 +854,10 @@ EXPORT_SYMBOL(splice_from_pipe_feed);
61971 int splice_from_pipe_next(struct pipe_inode_info *pipe, struct splice_desc *sd)
61972 {
61973 while (!pipe->nrbufs) {
61974 - if (!pipe->writers)
61975 + if (!atomic_read(&pipe->writers))
61976 return 0;
61977
61978 - if (!pipe->waiting_writers && sd->num_spliced)
61979 + if (!atomic_read(&pipe->waiting_writers) && sd->num_spliced)
61980 return 0;
61981
61982 if (sd->flags & SPLICE_F_NONBLOCK)
61983 @@ -1179,7 +1179,7 @@ ssize_t splice_direct_to_actor(struct file *in, struct splice_desc *sd,
61984 * out of the pipe right after the splice_to_pipe(). So set
61985 * PIPE_READERS appropriately.
61986 */
61987 - pipe->readers = 1;
61988 + atomic_set(&pipe->readers, 1);
61989
61990 current->splice_pipe = pipe;
61991 }
61992 @@ -1475,6 +1475,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
61993
61994 partial[buffers].offset = off;
61995 partial[buffers].len = plen;
61996 + partial[buffers].private = 0;
61997
61998 off = 0;
61999 len -= plen;
62000 @@ -1777,9 +1778,9 @@ static int ipipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
62001 ret = -ERESTARTSYS;
62002 break;
62003 }
62004 - if (!pipe->writers)
62005 + if (!atomic_read(&pipe->writers))
62006 break;
62007 - if (!pipe->waiting_writers) {
62008 + if (!atomic_read(&pipe->waiting_writers)) {
62009 if (flags & SPLICE_F_NONBLOCK) {
62010 ret = -EAGAIN;
62011 break;
62012 @@ -1811,7 +1812,7 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
62013 pipe_lock(pipe);
62014
62015 while (pipe->nrbufs >= pipe->buffers) {
62016 - if (!pipe->readers) {
62017 + if (!atomic_read(&pipe->readers)) {
62018 send_sig(SIGPIPE, current, 0);
62019 ret = -EPIPE;
62020 break;
62021 @@ -1824,9 +1825,9 @@ static int opipe_prep(struct pipe_inode_info *pipe, unsigned int flags)
62022 ret = -ERESTARTSYS;
62023 break;
62024 }
62025 - pipe->waiting_writers++;
62026 + atomic_inc(&pipe->waiting_writers);
62027 pipe_wait(pipe);
62028 - pipe->waiting_writers--;
62029 + atomic_dec(&pipe->waiting_writers);
62030 }
62031
62032 pipe_unlock(pipe);
62033 @@ -1862,14 +1863,14 @@ retry:
62034 pipe_double_lock(ipipe, opipe);
62035
62036 do {
62037 - if (!opipe->readers) {
62038 + if (!atomic_read(&opipe->readers)) {
62039 send_sig(SIGPIPE, current, 0);
62040 if (!ret)
62041 ret = -EPIPE;
62042 break;
62043 }
62044
62045 - if (!ipipe->nrbufs && !ipipe->writers)
62046 + if (!ipipe->nrbufs && !atomic_read(&ipipe->writers))
62047 break;
62048
62049 /*
62050 @@ -1966,7 +1967,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
62051 pipe_double_lock(ipipe, opipe);
62052
62053 do {
62054 - if (!opipe->readers) {
62055 + if (!atomic_read(&opipe->readers)) {
62056 send_sig(SIGPIPE, current, 0);
62057 if (!ret)
62058 ret = -EPIPE;
62059 @@ -2011,7 +2012,7 @@ static int link_pipe(struct pipe_inode_info *ipipe,
62060 * return EAGAIN if we have the potential of some data in the
62061 * future, otherwise just return 0
62062 */
62063 - if (!ret && ipipe->waiting_writers && (flags & SPLICE_F_NONBLOCK))
62064 + if (!ret && atomic_read(&ipipe->waiting_writers) && (flags & SPLICE_F_NONBLOCK))
62065 ret = -EAGAIN;
62066
62067 pipe_unlock(ipipe);
62068 diff --git a/fs/stat.c b/fs/stat.c
62069 index ae0c3ce..9ee641c 100644
62070 --- a/fs/stat.c
62071 +++ b/fs/stat.c
62072 @@ -28,8 +28,13 @@ void generic_fillattr(struct inode *inode, struct kstat *stat)
62073 stat->gid = inode->i_gid;
62074 stat->rdev = inode->i_rdev;
62075 stat->size = i_size_read(inode);
62076 - stat->atime = inode->i_atime;
62077 - stat->mtime = inode->i_mtime;
62078 + if (is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
62079 + stat->atime = inode->i_ctime;
62080 + stat->mtime = inode->i_ctime;
62081 + } else {
62082 + stat->atime = inode->i_atime;
62083 + stat->mtime = inode->i_mtime;
62084 + }
62085 stat->ctime = inode->i_ctime;
62086 stat->blksize = (1 << inode->i_blkbits);
62087 stat->blocks = inode->i_blocks;
62088 @@ -52,9 +57,16 @@ EXPORT_SYMBOL(generic_fillattr);
62089 int vfs_getattr_nosec(struct path *path, struct kstat *stat)
62090 {
62091 struct inode *inode = path->dentry->d_inode;
62092 + int retval;
62093
62094 - if (inode->i_op->getattr)
62095 - return inode->i_op->getattr(path->mnt, path->dentry, stat);
62096 + if (inode->i_op->getattr) {
62097 + retval = inode->i_op->getattr(path->mnt, path->dentry, stat);
62098 + if (!retval && is_sidechannel_device(inode) && !capable_nolog(CAP_MKNOD)) {
62099 + stat->atime = stat->ctime;
62100 + stat->mtime = stat->ctime;
62101 + }
62102 + return retval;
62103 + }
62104
62105 generic_fillattr(inode, stat);
62106 return 0;
62107 diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
62108 index c590cab..6dfd6fc 100644
62109 --- a/fs/sysfs/bin.c
62110 +++ b/fs/sysfs/bin.c
62111 @@ -234,13 +234,13 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
62112 return ret;
62113 }
62114
62115 -static int bin_access(struct vm_area_struct *vma, unsigned long addr,
62116 - void *buf, int len, int write)
62117 +static ssize_t bin_access(struct vm_area_struct *vma, unsigned long addr,
62118 + void *buf, size_t len, int write)
62119 {
62120 struct file *file = vma->vm_file;
62121 struct bin_buffer *bb = file->private_data;
62122 struct sysfs_dirent *attr_sd = file->f_path.dentry->d_fsdata;
62123 - int ret;
62124 + ssize_t ret;
62125
62126 if (!bb->vm_ops)
62127 return -EINVAL;
62128 diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
62129 index 4d83ced..049dc45 100644
62130 --- a/fs/sysfs/dir.c
62131 +++ b/fs/sysfs/dir.c
62132 @@ -40,7 +40,7 @@ static DEFINE_IDA(sysfs_ino_ida);
62133 *
62134 * Returns 31 bit hash of ns + name (so it fits in an off_t )
62135 */
62136 -static unsigned int sysfs_name_hash(const void *ns, const char *name)
62137 +static unsigned int sysfs_name_hash(const void *ns, const unsigned char *name)
62138 {
62139 unsigned long hash = init_name_hash();
62140 unsigned int len = strlen(name);
62141 @@ -675,6 +675,18 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
62142 struct sysfs_dirent *sd;
62143 int rc;
62144
62145 +#ifdef CONFIG_GRKERNSEC_SYSFS_RESTRICT
62146 + const char *parent_name = parent_sd->s_name;
62147 +
62148 + mode = S_IFDIR | S_IRWXU;
62149 +
62150 + if ((!strcmp(parent_name, "") && (!strcmp(name, "devices") || !strcmp(name, "fs"))) ||
62151 + (!strcmp(parent_name, "devices") && !strcmp(name, "system")) ||
62152 + (!strcmp(parent_name, "fs") && (!strcmp(name, "selinux") || !strcmp(name, "fuse") || !strcmp(name, "ecryptfs"))) ||
62153 + (!strcmp(parent_name, "system") && !strcmp(name, "cpu")))
62154 + mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO;
62155 +#endif
62156 +
62157 /* allocate */
62158 sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
62159 if (!sd)
62160 diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
62161 index 15ef5eb..e474372 100644
62162 --- a/fs/sysfs/file.c
62163 +++ b/fs/sysfs/file.c
62164 @@ -37,7 +37,7 @@ static DEFINE_SPINLOCK(sysfs_open_dirent_lock);
62165
62166 struct sysfs_open_dirent {
62167 atomic_t refcnt;
62168 - atomic_t event;
62169 + atomic_unchecked_t event;
62170 wait_queue_head_t poll;
62171 struct list_head buffers; /* goes through sysfs_buffer.list */
62172 };
62173 @@ -81,7 +81,7 @@ static int fill_read_buffer(struct dentry *dentry, struct sysfs_buffer *buffer)
62174 if (!sysfs_get_active(attr_sd))
62175 return -ENODEV;
62176
62177 - buffer->event = atomic_read(&attr_sd->s_attr.open->event);
62178 + buffer->event = atomic_read_unchecked(&attr_sd->s_attr.open->event);
62179 count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);
62180
62181 sysfs_put_active(attr_sd);
62182 @@ -284,7 +284,7 @@ static int sysfs_get_open_dirent(struct sysfs_dirent *sd,
62183 return -ENOMEM;
62184
62185 atomic_set(&new_od->refcnt, 0);
62186 - atomic_set(&new_od->event, 1);
62187 + atomic_set_unchecked(&new_od->event, 1);
62188 init_waitqueue_head(&new_od->poll);
62189 INIT_LIST_HEAD(&new_od->buffers);
62190 goto retry;
62191 @@ -430,7 +430,7 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
62192
62193 sysfs_put_active(attr_sd);
62194
62195 - if (buffer->event != atomic_read(&od->event))
62196 + if (buffer->event != atomic_read_unchecked(&od->event))
62197 goto trigger;
62198
62199 return DEFAULT_POLLMASK;
62200 @@ -450,7 +450,7 @@ void sysfs_notify_dirent(struct sysfs_dirent *sd)
62201 if (!WARN_ON(sysfs_type(sd) != SYSFS_KOBJ_ATTR)) {
62202 od = sd->s_attr.open;
62203 if (od) {
62204 - atomic_inc(&od->event);
62205 + atomic_inc_unchecked(&od->event);
62206 wake_up_interruptible(&od->poll);
62207 }
62208 }
62209 diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
62210 index 2dd4507..62a215a 100644
62211 --- a/fs/sysfs/symlink.c
62212 +++ b/fs/sysfs/symlink.c
62213 @@ -308,7 +308,7 @@ static void *sysfs_follow_link(struct dentry *dentry, struct nameidata *nd)
62214 static void sysfs_put_link(struct dentry *dentry, struct nameidata *nd,
62215 void *cookie)
62216 {
62217 - char *page = nd_get_link(nd);
62218 + const char *page = nd_get_link(nd);
62219 if (!IS_ERR(page))
62220 free_page((unsigned long)page);
62221 }
62222 diff --git a/fs/sysv/sysv.h b/fs/sysv/sysv.h
62223 index 69d4889..a810bd4 100644
62224 --- a/fs/sysv/sysv.h
62225 +++ b/fs/sysv/sysv.h
62226 @@ -188,7 +188,7 @@ static inline u32 PDP_swab(u32 x)
62227 #endif
62228 }
62229
62230 -static inline __u32 fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62231 +static inline __u32 __intentional_overflow(-1) fs32_to_cpu(struct sysv_sb_info *sbi, __fs32 n)
62232 {
62233 if (sbi->s_bytesex == BYTESEX_PDP)
62234 return PDP_swab((__force __u32)n);
62235 diff --git a/fs/ubifs/io.c b/fs/ubifs/io.c
62236 index e18b988..f1d4ad0f 100644
62237 --- a/fs/ubifs/io.c
62238 +++ b/fs/ubifs/io.c
62239 @@ -155,7 +155,7 @@ int ubifs_leb_change(struct ubifs_info *c, int lnum, const void *buf, int len)
62240 return err;
62241 }
62242
62243 -int ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62244 +int __intentional_overflow(-1) ubifs_leb_unmap(struct ubifs_info *c, int lnum)
62245 {
62246 int err;
62247
62248 diff --git a/fs/udf/misc.c b/fs/udf/misc.c
62249 index c175b4d..8f36a16 100644
62250 --- a/fs/udf/misc.c
62251 +++ b/fs/udf/misc.c
62252 @@ -289,7 +289,7 @@ void udf_new_tag(char *data, uint16_t ident, uint16_t version, uint16_t snum,
62253
62254 u8 udf_tag_checksum(const struct tag *t)
62255 {
62256 - u8 *data = (u8 *)t;
62257 + const u8 *data = (const u8 *)t;
62258 u8 checksum = 0;
62259 int i;
62260 for (i = 0; i < sizeof(struct tag); ++i)
62261 diff --git a/fs/ufs/swab.h b/fs/ufs/swab.h
62262 index 8d974c4..b82f6ec 100644
62263 --- a/fs/ufs/swab.h
62264 +++ b/fs/ufs/swab.h
62265 @@ -22,7 +22,7 @@ enum {
62266 BYTESEX_BE
62267 };
62268
62269 -static inline u64
62270 +static inline u64 __intentional_overflow(-1)
62271 fs64_to_cpu(struct super_block *sbp, __fs64 n)
62272 {
62273 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62274 @@ -40,7 +40,7 @@ cpu_to_fs64(struct super_block *sbp, u64 n)
62275 return (__force __fs64)cpu_to_be64(n);
62276 }
62277
62278 -static inline u32
62279 +static inline u32 __intentional_overflow(-1)
62280 fs32_to_cpu(struct super_block *sbp, __fs32 n)
62281 {
62282 if (UFS_SB(sbp)->s_bytesex == BYTESEX_LE)
62283 diff --git a/fs/utimes.c b/fs/utimes.c
62284 index f4fb7ec..3fe03c0 100644
62285 --- a/fs/utimes.c
62286 +++ b/fs/utimes.c
62287 @@ -1,6 +1,7 @@
62288 #include <linux/compiler.h>
62289 #include <linux/file.h>
62290 #include <linux/fs.h>
62291 +#include <linux/security.h>
62292 #include <linux/linkage.h>
62293 #include <linux/mount.h>
62294 #include <linux/namei.h>
62295 @@ -101,6 +102,12 @@ static int utimes_common(struct path *path, struct timespec *times)
62296 goto mnt_drop_write_and_out;
62297 }
62298 }
62299 +
62300 + if (!gr_acl_handle_utime(path->dentry, path->mnt)) {
62301 + error = -EACCES;
62302 + goto mnt_drop_write_and_out;
62303 + }
62304 +
62305 mutex_lock(&inode->i_mutex);
62306 error = notify_change(path->dentry, &newattrs);
62307 mutex_unlock(&inode->i_mutex);
62308 diff --git a/fs/xattr.c b/fs/xattr.c
62309 index 3377dff..f394815 100644
62310 --- a/fs/xattr.c
62311 +++ b/fs/xattr.c
62312 @@ -227,6 +227,27 @@ int vfs_xattr_cmp(struct dentry *dentry, const char *xattr_name,
62313 return rc;
62314 }
62315
62316 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
62317 +ssize_t
62318 +pax_getxattr(struct dentry *dentry, void *value, size_t size)
62319 +{
62320 + struct inode *inode = dentry->d_inode;
62321 + ssize_t error;
62322 +
62323 + error = inode_permission(inode, MAY_EXEC);
62324 + if (error)
62325 + return error;
62326 +
62327 + if (inode->i_op->getxattr)
62328 + error = inode->i_op->getxattr(dentry, XATTR_NAME_PAX_FLAGS, value, size);
62329 + else
62330 + error = -EOPNOTSUPP;
62331 +
62332 + return error;
62333 +}
62334 +EXPORT_SYMBOL(pax_getxattr);
62335 +#endif
62336 +
62337 ssize_t
62338 vfs_getxattr(struct dentry *dentry, const char *name, void *value, size_t size)
62339 {
62340 @@ -319,7 +340,7 @@ EXPORT_SYMBOL_GPL(vfs_removexattr);
62341 * Extended attribute SET operations
62342 */
62343 static long
62344 -setxattr(struct dentry *d, const char __user *name, const void __user *value,
62345 +setxattr(struct path *path, const char __user *name, const void __user *value,
62346 size_t size, int flags)
62347 {
62348 int error;
62349 @@ -355,7 +376,12 @@ setxattr(struct dentry *d, const char __user *name, const void __user *value,
62350 posix_acl_fix_xattr_from_user(kvalue, size);
62351 }
62352
62353 - error = vfs_setxattr(d, kname, kvalue, size, flags);
62354 + if (!gr_acl_handle_setxattr(path->dentry, path->mnt)) {
62355 + error = -EACCES;
62356 + goto out;
62357 + }
62358 +
62359 + error = vfs_setxattr(path->dentry, kname, kvalue, size, flags);
62360 out:
62361 if (vvalue)
62362 vfree(vvalue);
62363 @@ -377,7 +403,7 @@ retry:
62364 return error;
62365 error = mnt_want_write(path.mnt);
62366 if (!error) {
62367 - error = setxattr(path.dentry, name, value, size, flags);
62368 + error = setxattr(&path, name, value, size, flags);
62369 mnt_drop_write(path.mnt);
62370 }
62371 path_put(&path);
62372 @@ -401,7 +427,7 @@ retry:
62373 return error;
62374 error = mnt_want_write(path.mnt);
62375 if (!error) {
62376 - error = setxattr(path.dentry, name, value, size, flags);
62377 + error = setxattr(&path, name, value, size, flags);
62378 mnt_drop_write(path.mnt);
62379 }
62380 path_put(&path);
62381 @@ -416,16 +442,14 @@ SYSCALL_DEFINE5(fsetxattr, int, fd, const char __user *, name,
62382 const void __user *,value, size_t, size, int, flags)
62383 {
62384 struct fd f = fdget(fd);
62385 - struct dentry *dentry;
62386 int error = -EBADF;
62387
62388 if (!f.file)
62389 return error;
62390 - dentry = f.file->f_path.dentry;
62391 - audit_inode(NULL, dentry, 0);
62392 + audit_inode(NULL, f.file->f_path.dentry, 0);
62393 error = mnt_want_write_file(f.file);
62394 if (!error) {
62395 - error = setxattr(dentry, name, value, size, flags);
62396 + error = setxattr(&f.file->f_path, name, value, size, flags);
62397 mnt_drop_write_file(f.file);
62398 }
62399 fdput(f);
62400 @@ -626,7 +650,7 @@ SYSCALL_DEFINE3(flistxattr, int, fd, char __user *, list, size_t, size)
62401 * Extended attribute REMOVE operations
62402 */
62403 static long
62404 -removexattr(struct dentry *d, const char __user *name)
62405 +removexattr(struct path *path, const char __user *name)
62406 {
62407 int error;
62408 char kname[XATTR_NAME_MAX + 1];
62409 @@ -637,7 +661,10 @@ removexattr(struct dentry *d, const char __user *name)
62410 if (error < 0)
62411 return error;
62412
62413 - return vfs_removexattr(d, kname);
62414 + if (!gr_acl_handle_removexattr(path->dentry, path->mnt))
62415 + return -EACCES;
62416 +
62417 + return vfs_removexattr(path->dentry, kname);
62418 }
62419
62420 SYSCALL_DEFINE2(removexattr, const char __user *, pathname,
62421 @@ -652,7 +679,7 @@ retry:
62422 return error;
62423 error = mnt_want_write(path.mnt);
62424 if (!error) {
62425 - error = removexattr(path.dentry, name);
62426 + error = removexattr(&path, name);
62427 mnt_drop_write(path.mnt);
62428 }
62429 path_put(&path);
62430 @@ -675,7 +702,7 @@ retry:
62431 return error;
62432 error = mnt_want_write(path.mnt);
62433 if (!error) {
62434 - error = removexattr(path.dentry, name);
62435 + error = removexattr(&path, name);
62436 mnt_drop_write(path.mnt);
62437 }
62438 path_put(&path);
62439 @@ -689,16 +716,16 @@ retry:
62440 SYSCALL_DEFINE2(fremovexattr, int, fd, const char __user *, name)
62441 {
62442 struct fd f = fdget(fd);
62443 - struct dentry *dentry;
62444 + struct path *path;
62445 int error = -EBADF;
62446
62447 if (!f.file)
62448 return error;
62449 - dentry = f.file->f_path.dentry;
62450 - audit_inode(NULL, dentry, 0);
62451 + path = &f.file->f_path;
62452 + audit_inode(NULL, path->dentry, 0);
62453 error = mnt_want_write_file(f.file);
62454 if (!error) {
62455 - error = removexattr(dentry, name);
62456 + error = removexattr(path, name);
62457 mnt_drop_write_file(f.file);
62458 }
62459 fdput(f);
62460 diff --git a/fs/xattr_acl.c b/fs/xattr_acl.c
62461 index 9fbea87..6b19972 100644
62462 --- a/fs/xattr_acl.c
62463 +++ b/fs/xattr_acl.c
62464 @@ -76,8 +76,8 @@ struct posix_acl *
62465 posix_acl_from_xattr(struct user_namespace *user_ns,
62466 const void *value, size_t size)
62467 {
62468 - posix_acl_xattr_header *header = (posix_acl_xattr_header *)value;
62469 - posix_acl_xattr_entry *entry = (posix_acl_xattr_entry *)(header+1), *end;
62470 + const posix_acl_xattr_header *header = (const posix_acl_xattr_header *)value;
62471 + const posix_acl_xattr_entry *entry = (const posix_acl_xattr_entry *)(header+1), *end;
62472 int count;
62473 struct posix_acl *acl;
62474 struct posix_acl_entry *acl_e;
62475 diff --git a/fs/xfs/xfs_bmap.c b/fs/xfs/xfs_bmap.c
62476 index f47e65c..e7125d9 100644
62477 --- a/fs/xfs/xfs_bmap.c
62478 +++ b/fs/xfs/xfs_bmap.c
62479 @@ -586,7 +586,7 @@ xfs_bmap_validate_ret(
62480
62481 #else
62482 #define xfs_bmap_check_leaf_extents(cur, ip, whichfork) do { } while (0)
62483 -#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap)
62484 +#define xfs_bmap_validate_ret(bno,len,flags,mval,onmap,nmap) do { } while (0)
62485 #endif /* DEBUG */
62486
62487 /*
62488 diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
62489 index 8f84153..7ce60d0 100644
62490 --- a/fs/xfs/xfs_dir2_readdir.c
62491 +++ b/fs/xfs/xfs_dir2_readdir.c
62492 @@ -160,7 +160,12 @@ xfs_dir2_sf_getdents(
62493 ino = xfs_dir3_sfe_get_ino(mp, sfp, sfep);
62494 filetype = xfs_dir3_sfe_get_ftype(mp, sfp, sfep);
62495 ctx->pos = off & 0x7fffffff;
62496 - if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
62497 + if (dp->i_df.if_u1.if_data == dp->i_df.if_u2.if_inline_data) {
62498 + char name[sfep->namelen];
62499 + memcpy(name, sfep->name, sfep->namelen);
62500 + if (!dir_emit(ctx, name, sfep->namelen, ino, xfs_dir3_get_dtype(mp, filetype)))
62501 + return 0;
62502 + } else if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
62503 xfs_dir3_get_dtype(mp, filetype)))
62504 return 0;
62505 sfep = xfs_dir3_sf_nextentry(mp, sfp, sfep);
62506 diff --git a/fs/xfs/xfs_ioctl.c b/fs/xfs/xfs_ioctl.c
62507 index 8c8ef24..689f742 100644
62508 --- a/fs/xfs/xfs_ioctl.c
62509 +++ b/fs/xfs/xfs_ioctl.c
62510 @@ -127,7 +127,7 @@ xfs_find_handle(
62511 }
62512
62513 error = -EFAULT;
62514 - if (copy_to_user(hreq->ohandle, &handle, hsize) ||
62515 + if (hsize > sizeof handle || copy_to_user(hreq->ohandle, &handle, hsize) ||
62516 copy_to_user(hreq->ohandlen, &hsize, sizeof(__s32)))
62517 goto out_put;
62518
62519 diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c
62520 index 2b8952d..a60c6be 100644
62521 --- a/fs/xfs/xfs_iops.c
62522 +++ b/fs/xfs/xfs_iops.c
62523 @@ -401,7 +401,7 @@ xfs_vn_put_link(
62524 struct nameidata *nd,
62525 void *p)
62526 {
62527 - char *s = nd_get_link(nd);
62528 + const char *s = nd_get_link(nd);
62529
62530 if (!IS_ERR(s))
62531 kfree(s);
62532 diff --git a/grsecurity/Kconfig b/grsecurity/Kconfig
62533 new file mode 100644
62534 index 0000000..5b2538b
62535 --- /dev/null
62536 +++ b/grsecurity/Kconfig
62537 @@ -0,0 +1,1116 @@
62538 +#
62539 +# grecurity configuration
62540 +#
62541 +menu "Memory Protections"
62542 +depends on GRKERNSEC
62543 +
62544 +config GRKERNSEC_KMEM
62545 + bool "Deny reading/writing to /dev/kmem, /dev/mem, and /dev/port"
62546 + default y if GRKERNSEC_CONFIG_AUTO
62547 + select STRICT_DEVMEM if (X86 || ARM || TILE || S390)
62548 + help
62549 + If you say Y here, /dev/kmem and /dev/mem won't be allowed to
62550 + be written to or read from to modify or leak the contents of the running
62551 + kernel. /dev/port will also not be allowed to be opened, and support
62552 + for /dev/cpu/*/msr and kexec will be removed. If you have module
62553 + support disabled, enabling this will close up six ways that are
62554 + currently used to insert malicious code into the running kernel.
62555 +
62556 + Even with this feature enabled, we still highly recommend that
62557 + you use the RBAC system, as it is still possible for an attacker to
62558 + modify the running kernel through other more obscure methods.
62559 +
62560 + Enabling this feature will prevent the "cpupower" and "powertop" tools
62561 + from working.
62562 +
62563 + It is highly recommended that you say Y here if you meet all the
62564 + conditions above.
62565 +
62566 +config GRKERNSEC_VM86
62567 + bool "Restrict VM86 mode"
62568 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62569 + depends on X86_32
62570 +
62571 + help
62572 + If you say Y here, only processes with CAP_SYS_RAWIO will be able to
62573 + make use of a special execution mode on 32bit x86 processors called
62574 + Virtual 8086 (VM86) mode. XFree86 may need vm86 mode for certain
62575 + video cards and will still work with this option enabled. The purpose
62576 + of the option is to prevent exploitation of emulation errors in
62577 + virtualization of vm86 mode like the one discovered in VMWare in 2009.
62578 + Nearly all users should be able to enable this option.
62579 +
62580 +config GRKERNSEC_IO
62581 + bool "Disable privileged I/O"
62582 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62583 + depends on X86
62584 + select RTC_CLASS
62585 + select RTC_INTF_DEV
62586 + select RTC_DRV_CMOS
62587 +
62588 + help
62589 + If you say Y here, all ioperm and iopl calls will return an error.
62590 + Ioperm and iopl can be used to modify the running kernel.
62591 + Unfortunately, some programs need this access to operate properly,
62592 + the most notable of which are XFree86 and hwclock. hwclock can be
62593 + remedied by having RTC support in the kernel, so real-time
62594 + clock support is enabled if this option is enabled, to ensure
62595 + that hwclock operates correctly.
62596 +
62597 + If you're using XFree86 or a version of Xorg from 2012 or earlier,
62598 + you may not be able to boot into a graphical environment with this
62599 + option enabled. In this case, you should use the RBAC system instead.
62600 +
62601 +config GRKERNSEC_JIT_HARDEN
62602 + bool "Harden BPF JIT against spray attacks"
62603 + default y if GRKERNSEC_CONFIG_AUTO
62604 + depends on BPF_JIT
62605 + help
62606 + If you say Y here, the native code generated by the kernel's Berkeley
62607 + Packet Filter (BPF) JIT engine will be hardened against JIT-spraying
62608 + attacks that attempt to fit attacker-beneficial instructions in
62609 + 32bit immediate fields of JIT-generated native instructions. The
62610 + attacker will generally aim to cause an unintended instruction sequence
62611 + of JIT-generated native code to execute by jumping into the middle of
62612 + a generated instruction. This feature effectively randomizes the 32bit
62613 + immediate constants present in the generated code to thwart such attacks.
62614 +
62615 + If you're using KERNEXEC, it's recommended that you enable this option
62616 + to supplement the hardening of the kernel.
62617 +
62618 +config GRKERNSEC_PERF_HARDEN
62619 + bool "Disable unprivileged PERF_EVENTS usage by default"
62620 + default y if GRKERNSEC_CONFIG_AUTO
62621 + depends on PERF_EVENTS
62622 + help
62623 + If you say Y here, the range of acceptable values for the
62624 + /proc/sys/kernel/perf_event_paranoid sysctl will be expanded to allow and
62625 + default to a new value: 3. When the sysctl is set to this value, no
62626 + unprivileged use of the PERF_EVENTS syscall interface will be permitted.
62627 +
62628 + Though PERF_EVENTS can be used legitimately for performance monitoring
62629 + and low-level application profiling, it is forced on regardless of
62630 + configuration, has been at fault for several vulnerabilities, and
62631 + creates new opportunities for side channels and other information leaks.
62632 +
62633 + This feature puts PERF_EVENTS into a secure default state and permits
62634 + the administrator to change out of it temporarily if unprivileged
62635 + application profiling is needed.
62636 +
62637 +config GRKERNSEC_RAND_THREADSTACK
62638 + bool "Insert random gaps between thread stacks"
62639 + default y if GRKERNSEC_CONFIG_AUTO
62640 + depends on PAX_RANDMMAP && !PPC
62641 + help
62642 + If you say Y here, a random-sized gap will be enforced between allocated
62643 + thread stacks. Glibc's NPTL and other threading libraries that
62644 + pass MAP_STACK to the kernel for thread stack allocation are supported.
62645 + The implementation currently provides 8 bits of entropy for the gap.
62646 +
62647 + Many distributions do not compile threaded remote services with the
62648 + -fstack-check argument to GCC, causing the variable-sized stack-based
62649 + allocator, alloca(), to not probe the stack on allocation. This
62650 + permits an unbounded alloca() to skip over any guard page and potentially
62651 + modify another thread's stack reliably. An enforced random gap
62652 + reduces the reliability of such an attack and increases the chance
62653 + that such a read/write to another thread's stack instead lands in
62654 + an unmapped area, causing a crash and triggering grsecurity's
62655 + anti-bruteforcing logic.
62656 +
62657 +config GRKERNSEC_PROC_MEMMAP
62658 + bool "Harden ASLR against information leaks and entropy reduction"
62659 + default y if (GRKERNSEC_CONFIG_AUTO || PAX_NOEXEC || PAX_ASLR)
62660 + depends on PAX_NOEXEC || PAX_ASLR
62661 + help
62662 + If you say Y here, the /proc/<pid>/maps and /proc/<pid>/stat files will
62663 + give no information about the addresses of its mappings if
62664 + PaX features that rely on random addresses are enabled on the task.
62665 + In addition to sanitizing this information and disabling other
62666 + dangerous sources of information, this option causes reads of sensitive
62667 + /proc/<pid> entries where the file descriptor was opened in a different
62668 + task than the one performing the read. Such attempts are logged.
62669 + This option also limits argv/env strings for suid/sgid binaries
62670 + to 512KB to prevent a complete exhaustion of the stack entropy provided
62671 + by ASLR. Finally, it places an 8MB stack resource limit on suid/sgid
62672 + binaries to prevent alternative mmap layouts from being abused.
62673 +
62674 + If you use PaX it is essential that you say Y here as it closes up
62675 + several holes that make full ASLR useless locally.
62676 +
62677 +config GRKERNSEC_BRUTE
62678 + bool "Deter exploit bruteforcing"
62679 + default y if GRKERNSEC_CONFIG_AUTO
62680 + help
62681 + If you say Y here, attempts to bruteforce exploits against forking
62682 + daemons such as apache or sshd, as well as against suid/sgid binaries
62683 + will be deterred. When a child of a forking daemon is killed by PaX
62684 + or crashes due to an illegal instruction or other suspicious signal,
62685 + the parent process will be delayed 30 seconds upon every subsequent
62686 + fork until the administrator is able to assess the situation and
62687 + restart the daemon.
62688 + In the suid/sgid case, the attempt is logged, the user has all their
62689 + existing instances of the suid/sgid binary terminated and will
62690 + be unable to execute any suid/sgid binaries for 15 minutes.
62691 +
62692 + It is recommended that you also enable signal logging in the auditing
62693 + section so that logs are generated when a process triggers a suspicious
62694 + signal.
62695 + If the sysctl option is enabled, a sysctl option with name
62696 + "deter_bruteforce" is created.
62697 +
62698 +
62699 +config GRKERNSEC_MODHARDEN
62700 + bool "Harden module auto-loading"
62701 + default y if GRKERNSEC_CONFIG_AUTO
62702 + depends on MODULES
62703 + help
62704 + If you say Y here, module auto-loading in response to use of some
62705 + feature implemented by an unloaded module will be restricted to
62706 + root users. Enabling this option helps defend against attacks
62707 + by unprivileged users who abuse the auto-loading behavior to
62708 + cause a vulnerable module to load that is then exploited.
62709 +
62710 + If this option prevents a legitimate use of auto-loading for a
62711 + non-root user, the administrator can execute modprobe manually
62712 + with the exact name of the module mentioned in the alert log.
62713 + Alternatively, the administrator can add the module to the list
62714 + of modules loaded at boot by modifying init scripts.
62715 +
62716 + Modification of init scripts will most likely be needed on
62717 + Ubuntu servers with encrypted home directory support enabled,
62718 + as the first non-root user logging in will cause the ecb(aes),
62719 + ecb(aes)-all, cbc(aes), and cbc(aes)-all modules to be loaded.
62720 +
62721 +config GRKERNSEC_HIDESYM
62722 + bool "Hide kernel symbols"
62723 + default y if GRKERNSEC_CONFIG_AUTO
62724 + select PAX_USERCOPY_SLABS
62725 + help
62726 + If you say Y here, getting information on loaded modules, and
62727 + displaying all kernel symbols through a syscall will be restricted
62728 + to users with CAP_SYS_MODULE. For software compatibility reasons,
62729 + /proc/kallsyms will be restricted to the root user. The RBAC
62730 + system can hide that entry even from root.
62731 +
62732 + This option also prevents leaking of kernel addresses through
62733 + several /proc entries.
62734 +
62735 + Note that this option is only effective provided the following
62736 + conditions are met:
62737 + 1) The kernel using grsecurity is not precompiled by some distribution
62738 + 2) You have also enabled GRKERNSEC_DMESG
62739 + 3) You are using the RBAC system and hiding other files such as your
62740 + kernel image and System.map. Alternatively, enabling this option
62741 + causes the permissions on /boot, /lib/modules, and the kernel
62742 + source directory to change at compile time to prevent
62743 + reading by non-root users.
62744 + If the above conditions are met, this option will aid in providing a
62745 + useful protection against local kernel exploitation of overflows
62746 + and arbitrary read/write vulnerabilities.
62747 +
62748 + It is highly recommended that you enable GRKERNSEC_PERF_HARDEN
62749 + in addition to this feature.
62750 +
62751 +config GRKERNSEC_KERN_LOCKOUT
62752 + bool "Active kernel exploit response"
62753 + default y if GRKERNSEC_CONFIG_AUTO
62754 + depends on X86 || ARM || PPC || SPARC
62755 + help
62756 + If you say Y here, when a PaX alert is triggered due to suspicious
62757 + activity in the kernel (from KERNEXEC/UDEREF/USERCOPY)
62758 + or an OOPS occurs due to bad memory accesses, instead of just
62759 + terminating the offending process (and potentially allowing
62760 + a subsequent exploit from the same user), we will take one of two
62761 + actions:
62762 + If the user was root, we will panic the system
62763 + If the user was non-root, we will log the attempt, terminate
62764 + all processes owned by the user, then prevent them from creating
62765 + any new processes until the system is restarted
62766 + This deters repeated kernel exploitation/bruteforcing attempts
62767 + and is useful for later forensics.
62768 +
62769 +config GRKERNSEC_OLD_ARM_USERLAND
62770 + bool "Old ARM userland compatibility"
62771 + depends on ARM && (CPU_V6 || CPU_V6K || CPU_V7)
62772 + help
62773 + If you say Y here, stubs of executable code to perform such operations
62774 + as "compare-exchange" will be placed at fixed locations in the ARM vector
62775 + table. This is unfortunately needed for old ARM userland meant to run
62776 + across a wide range of processors. Without this option enabled,
62777 + the get_tls and data memory barrier stubs will be emulated by the kernel,
62778 + which is enough for Linaro userlands or other userlands designed for v6
62779 + and newer ARM CPUs. It's recommended that you try without this option enabled
62780 + first, and only enable it if your userland does not boot (it will likely fail
62781 + at init time).
62782 +
62783 +endmenu
62784 +menu "Role Based Access Control Options"
62785 +depends on GRKERNSEC
62786 +
62787 +config GRKERNSEC_RBAC_DEBUG
62788 + bool
62789 +
62790 +config GRKERNSEC_NO_RBAC
62791 + bool "Disable RBAC system"
62792 + help
62793 + If you say Y here, the /dev/grsec device will be removed from the kernel,
62794 + preventing the RBAC system from being enabled. You should only say Y
62795 + here if you have no intention of using the RBAC system, so as to prevent
62796 + an attacker with root access from misusing the RBAC system to hide files
62797 + and processes when loadable module support and /dev/[k]mem have been
62798 + locked down.
62799 +
62800 +config GRKERNSEC_ACL_HIDEKERN
62801 + bool "Hide kernel processes"
62802 + help
62803 + If you say Y here, all kernel threads will be hidden to all
62804 + processes but those whose subject has the "view hidden processes"
62805 + flag.
62806 +
62807 +config GRKERNSEC_ACL_MAXTRIES
62808 + int "Maximum tries before password lockout"
62809 + default 3
62810 + help
62811 + This option enforces the maximum number of times a user can attempt
62812 + to authorize themselves with the grsecurity RBAC system before being
62813 + denied the ability to attempt authorization again for a specified time.
62814 + The lower the number, the harder it will be to brute-force a password.
62815 +
62816 +config GRKERNSEC_ACL_TIMEOUT
62817 + int "Time to wait after max password tries, in seconds"
62818 + default 30
62819 + help
62820 + This option specifies the time the user must wait after attempting to
62821 + authorize to the RBAC system with the maximum number of invalid
62822 + passwords. The higher the number, the harder it will be to brute-force
62823 + a password.
62824 +
62825 +endmenu
62826 +menu "Filesystem Protections"
62827 +depends on GRKERNSEC
62828 +
62829 +config GRKERNSEC_PROC
62830 + bool "Proc restrictions"
62831 + default y if GRKERNSEC_CONFIG_AUTO
62832 + help
62833 + If you say Y here, the permissions of the /proc filesystem
62834 + will be altered to enhance system security and privacy. You MUST
62835 + choose either a user only restriction or a user and group restriction.
62836 + Depending upon the option you choose, you can either restrict users to
62837 + see only the processes they themselves run, or choose a group that can
62838 + view all processes and files normally restricted to root if you choose
62839 + the "restrict to user only" option. NOTE: If you're running identd or
62840 + ntpd as a non-root user, you will have to run it as the group you
62841 + specify here.
62842 +
62843 +config GRKERNSEC_PROC_USER
62844 + bool "Restrict /proc to user only"
62845 + depends on GRKERNSEC_PROC
62846 + help
62847 + If you say Y here, non-root users will only be able to view their own
62848 + processes, and restricts them from viewing network-related information,
62849 + and viewing kernel symbol and module information.
62850 +
62851 +config GRKERNSEC_PROC_USERGROUP
62852 + bool "Allow special group"
62853 + default y if GRKERNSEC_CONFIG_AUTO
62854 + depends on GRKERNSEC_PROC && !GRKERNSEC_PROC_USER
62855 + help
62856 + If you say Y here, you will be able to select a group that will be
62857 + able to view all processes and network-related information. If you've
62858 + enabled GRKERNSEC_HIDESYM, kernel and symbol information may still
62859 + remain hidden. This option is useful if you want to run identd as
62860 + a non-root user. The group you select may also be chosen at boot time
62861 + via "grsec_proc_gid=" on the kernel commandline.
62862 +
62863 +config GRKERNSEC_PROC_GID
62864 + int "GID for special group"
62865 + depends on GRKERNSEC_PROC_USERGROUP
62866 + default 1001
62867 +
62868 +config GRKERNSEC_PROC_ADD
62869 + bool "Additional restrictions"
62870 + default y if GRKERNSEC_CONFIG_AUTO
62871 + depends on GRKERNSEC_PROC_USER || GRKERNSEC_PROC_USERGROUP
62872 + help
62873 + If you say Y here, additional restrictions will be placed on
62874 + /proc that keep normal users from viewing device information and
62875 + slabinfo information that could be useful for exploits.
62876 +
62877 +config GRKERNSEC_LINK
62878 + bool "Linking restrictions"
62879 + default y if GRKERNSEC_CONFIG_AUTO
62880 + help
62881 + If you say Y here, /tmp race exploits will be prevented, since users
62882 + will no longer be able to follow symlinks owned by other users in
62883 + world-writable +t directories (e.g. /tmp), unless the owner of the
62884 + symlink is the owner of the directory. users will also not be
62885 + able to hardlink to files they do not own. If the sysctl option is
62886 + enabled, a sysctl option with name "linking_restrictions" is created.
62887 +
62888 +config GRKERNSEC_SYMLINKOWN
62889 + bool "Kernel-enforced SymlinksIfOwnerMatch"
62890 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
62891 + help
62892 + Apache's SymlinksIfOwnerMatch option has an inherent race condition
62893 + that prevents it from being used as a security feature. As Apache
62894 + verifies the symlink by performing a stat() against the target of
62895 + the symlink before it is followed, an attacker can setup a symlink
62896 + to point to a same-owned file, then replace the symlink with one
62897 + that targets another user's file just after Apache "validates" the
62898 + symlink -- a classic TOCTOU race. If you say Y here, a complete,
62899 + race-free replacement for Apache's "SymlinksIfOwnerMatch" option
62900 + will be in place for the group you specify. If the sysctl option
62901 + is enabled, a sysctl option with name "enforce_symlinksifowner" is
62902 + created.
62903 +
62904 +config GRKERNSEC_SYMLINKOWN_GID
62905 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
62906 + depends on GRKERNSEC_SYMLINKOWN
62907 + default 1006
62908 + help
62909 + Setting this GID determines what group kernel-enforced
62910 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
62911 + is enabled, a sysctl option with name "symlinkown_gid" is created.
62912 +
62913 +config GRKERNSEC_FIFO
62914 + bool "FIFO restrictions"
62915 + default y if GRKERNSEC_CONFIG_AUTO
62916 + help
62917 + If you say Y here, users will not be able to write to FIFOs they don't
62918 + own in world-writable +t directories (e.g. /tmp), unless the owner of
62919 + the FIFO is the same owner of the directory it's held in. If the sysctl
62920 + option is enabled, a sysctl option with name "fifo_restrictions" is
62921 + created.
62922 +
62923 +config GRKERNSEC_SYSFS_RESTRICT
62924 + bool "Sysfs/debugfs restriction"
62925 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER)
62926 + depends on SYSFS
62927 + help
62928 + If you say Y here, sysfs (the pseudo-filesystem mounted at /sys) and
62929 + any filesystem normally mounted under it (e.g. debugfs) will be
62930 + mostly accessible only by root. These filesystems generally provide access
62931 + to hardware and debug information that isn't appropriate for unprivileged
62932 + users of the system. Sysfs and debugfs have also become a large source
62933 + of new vulnerabilities, ranging from infoleaks to local compromise.
62934 + There has been very little oversight with an eye toward security involved
62935 + in adding new exporters of information to these filesystems, so their
62936 + use is discouraged.
62937 + For reasons of compatibility, a few directories have been whitelisted
62938 + for access by non-root users:
62939 + /sys/fs/selinux
62940 + /sys/fs/fuse
62941 + /sys/devices/system/cpu
62942 +
62943 +config GRKERNSEC_ROFS
62944 + bool "Runtime read-only mount protection"
62945 + depends on SYSCTL
62946 + help
62947 + If you say Y here, a sysctl option with name "romount_protect" will
62948 + be created. By setting this option to 1 at runtime, filesystems
62949 + will be protected in the following ways:
62950 + * No new writable mounts will be allowed
62951 + * Existing read-only mounts won't be able to be remounted read/write
62952 + * Write operations will be denied on all block devices
62953 + This option acts independently of grsec_lock: once it is set to 1,
62954 + it cannot be turned off. Therefore, please be mindful of the resulting
62955 + behavior if this option is enabled in an init script on a read-only
62956 + filesystem.
62957 + Also be aware that as with other root-focused features, GRKERNSEC_KMEM
62958 + and GRKERNSEC_IO should be enabled and module loading disabled via
62959 + config or at runtime.
62960 + This feature is mainly intended for secure embedded systems.
62961 +
62962 +
62963 +config GRKERNSEC_DEVICE_SIDECHANNEL
62964 + bool "Eliminate stat/notify-based device sidechannels"
62965 + default y if GRKERNSEC_CONFIG_AUTO
62966 + help
62967 + If you say Y here, timing analyses on block or character
62968 + devices like /dev/ptmx using stat or inotify/dnotify/fanotify
62969 + will be thwarted for unprivileged users. If a process without
62970 + CAP_MKNOD stats such a device, the last access and last modify times
62971 + will match the device's create time. No access or modify events
62972 + will be triggered through inotify/dnotify/fanotify for such devices.
62973 + This feature will prevent attacks that may at a minimum
62974 + allow an attacker to determine the administrator's password length.
62975 +
62976 +config GRKERNSEC_CHROOT
62977 + bool "Chroot jail restrictions"
62978 + default y if GRKERNSEC_CONFIG_AUTO
62979 + help
62980 + If you say Y here, you will be able to choose several options that will
62981 + make breaking out of a chrooted jail much more difficult. If you
62982 + encounter no software incompatibilities with the following options, it
62983 + is recommended that you enable each one.
62984 +
62985 +config GRKERNSEC_CHROOT_MOUNT
62986 + bool "Deny mounts"
62987 + default y if GRKERNSEC_CONFIG_AUTO
62988 + depends on GRKERNSEC_CHROOT
62989 + help
62990 + If you say Y here, processes inside a chroot will not be able to
62991 + mount or remount filesystems. If the sysctl option is enabled, a
62992 + sysctl option with name "chroot_deny_mount" is created.
62993 +
62994 +config GRKERNSEC_CHROOT_DOUBLE
62995 + bool "Deny double-chroots"
62996 + default y if GRKERNSEC_CONFIG_AUTO
62997 + depends on GRKERNSEC_CHROOT
62998 + help
62999 + If you say Y here, processes inside a chroot will not be able to chroot
63000 + again outside the chroot. This is a widely used method of breaking
63001 + out of a chroot jail and should not be allowed. If the sysctl
63002 + option is enabled, a sysctl option with name
63003 + "chroot_deny_chroot" is created.
63004 +
63005 +config GRKERNSEC_CHROOT_PIVOT
63006 + bool "Deny pivot_root in chroot"
63007 + default y if GRKERNSEC_CONFIG_AUTO
63008 + depends on GRKERNSEC_CHROOT
63009 + help
63010 + If you say Y here, processes inside a chroot will not be able to use
63011 + a function called pivot_root() that was introduced in Linux 2.3.41. It
63012 + works similar to chroot in that it changes the root filesystem. This
63013 + function could be misused in a chrooted process to attempt to break out
63014 + of the chroot, and therefore should not be allowed. If the sysctl
63015 + option is enabled, a sysctl option with name "chroot_deny_pivot" is
63016 + created.
63017 +
63018 +config GRKERNSEC_CHROOT_CHDIR
63019 + bool "Enforce chdir(\"/\") on all chroots"
63020 + default y if GRKERNSEC_CONFIG_AUTO
63021 + depends on GRKERNSEC_CHROOT
63022 + help
63023 + If you say Y here, the current working directory of all newly-chrooted
63024 + applications will be set to the the root directory of the chroot.
63025 + The man page on chroot(2) states:
63026 + Note that this call does not change the current working
63027 + directory, so that `.' can be outside the tree rooted at
63028 + `/'. In particular, the super-user can escape from a
63029 + `chroot jail' by doing `mkdir foo; chroot foo; cd ..'.
63030 +
63031 + It is recommended that you say Y here, since it's not known to break
63032 + any software. If the sysctl option is enabled, a sysctl option with
63033 + name "chroot_enforce_chdir" is created.
63034 +
63035 +config GRKERNSEC_CHROOT_CHMOD
63036 + bool "Deny (f)chmod +s"
63037 + default y if GRKERNSEC_CONFIG_AUTO
63038 + depends on GRKERNSEC_CHROOT
63039 + help
63040 + If you say Y here, processes inside a chroot will not be able to chmod
63041 + or fchmod files to make them have suid or sgid bits. This protects
63042 + against another published method of breaking a chroot. If the sysctl
63043 + option is enabled, a sysctl option with name "chroot_deny_chmod" is
63044 + created.
63045 +
63046 +config GRKERNSEC_CHROOT_FCHDIR
63047 + bool "Deny fchdir out of chroot"
63048 + default y if GRKERNSEC_CONFIG_AUTO
63049 + depends on GRKERNSEC_CHROOT
63050 + help
63051 + If you say Y here, a well-known method of breaking chroots by fchdir'ing
63052 + to a file descriptor of the chrooting process that points to a directory
63053 + outside the filesystem will be stopped. If the sysctl option
63054 + is enabled, a sysctl option with name "chroot_deny_fchdir" is created.
63055 +
63056 +config GRKERNSEC_CHROOT_MKNOD
63057 + bool "Deny mknod"
63058 + default y if GRKERNSEC_CONFIG_AUTO
63059 + depends on GRKERNSEC_CHROOT
63060 + help
63061 + If you say Y here, processes inside a chroot will not be allowed to
63062 + mknod. The problem with using mknod inside a chroot is that it
63063 + would allow an attacker to create a device entry that is the same
63064 + as one on the physical root of your system, which could range from
63065 + anything from the console device to a device for your harddrive (which
63066 + they could then use to wipe the drive or steal data). It is recommended
63067 + that you say Y here, unless you run into software incompatibilities.
63068 + If the sysctl option is enabled, a sysctl option with name
63069 + "chroot_deny_mknod" is created.
63070 +
63071 +config GRKERNSEC_CHROOT_SHMAT
63072 + bool "Deny shmat() out of chroot"
63073 + default y if GRKERNSEC_CONFIG_AUTO
63074 + depends on GRKERNSEC_CHROOT
63075 + help
63076 + If you say Y here, processes inside a chroot will not be able to attach
63077 + to shared memory segments that were created outside of the chroot jail.
63078 + It is recommended that you say Y here. If the sysctl option is enabled,
63079 + a sysctl option with name "chroot_deny_shmat" is created.
63080 +
63081 +config GRKERNSEC_CHROOT_UNIX
63082 + bool "Deny access to abstract AF_UNIX sockets out of chroot"
63083 + default y if GRKERNSEC_CONFIG_AUTO
63084 + depends on GRKERNSEC_CHROOT
63085 + help
63086 + If you say Y here, processes inside a chroot will not be able to
63087 + connect to abstract (meaning not belonging to a filesystem) Unix
63088 + domain sockets that were bound outside of a chroot. It is recommended
63089 + that you say Y here. If the sysctl option is enabled, a sysctl option
63090 + with name "chroot_deny_unix" is created.
63091 +
63092 +config GRKERNSEC_CHROOT_FINDTASK
63093 + bool "Protect outside processes"
63094 + default y if GRKERNSEC_CONFIG_AUTO
63095 + depends on GRKERNSEC_CHROOT
63096 + help
63097 + If you say Y here, processes inside a chroot will not be able to
63098 + kill, send signals with fcntl, ptrace, capget, getpgid, setpgid,
63099 + getsid, or view any process outside of the chroot. If the sysctl
63100 + option is enabled, a sysctl option with name "chroot_findtask" is
63101 + created.
63102 +
63103 +config GRKERNSEC_CHROOT_NICE
63104 + bool "Restrict priority changes"
63105 + default y if GRKERNSEC_CONFIG_AUTO
63106 + depends on GRKERNSEC_CHROOT
63107 + help
63108 + If you say Y here, processes inside a chroot will not be able to raise
63109 + the priority of processes in the chroot, or alter the priority of
63110 + processes outside the chroot. This provides more security than simply
63111 + removing CAP_SYS_NICE from the process' capability set. If the
63112 + sysctl option is enabled, a sysctl option with name "chroot_restrict_nice"
63113 + is created.
63114 +
63115 +config GRKERNSEC_CHROOT_SYSCTL
63116 + bool "Deny sysctl writes"
63117 + default y if GRKERNSEC_CONFIG_AUTO
63118 + depends on GRKERNSEC_CHROOT
63119 + help
63120 + If you say Y here, an attacker in a chroot will not be able to
63121 + write to sysctl entries, either by sysctl(2) or through a /proc
63122 + interface. It is strongly recommended that you say Y here. If the
63123 + sysctl option is enabled, a sysctl option with name
63124 + "chroot_deny_sysctl" is created.
63125 +
63126 +config GRKERNSEC_CHROOT_CAPS
63127 + bool "Capability restrictions"
63128 + default y if GRKERNSEC_CONFIG_AUTO
63129 + depends on GRKERNSEC_CHROOT
63130 + help
63131 + If you say Y here, the capabilities on all processes within a
63132 + chroot jail will be lowered to stop module insertion, raw i/o,
63133 + system and net admin tasks, rebooting the system, modifying immutable
63134 + files, modifying IPC owned by another, and changing the system time.
63135 + This is left an option because it can break some apps. Disable this
63136 + if your chrooted apps are having problems performing those kinds of
63137 + tasks. If the sysctl option is enabled, a sysctl option with
63138 + name "chroot_caps" is created.
63139 +
63140 +config GRKERNSEC_CHROOT_INITRD
63141 + bool "Exempt initrd tasks from restrictions"
63142 + default y if GRKERNSEC_CONFIG_AUTO
63143 + depends on GRKERNSEC_CHROOT && BLK_DEV_INITRD
63144 + help
63145 + If you say Y here, tasks started prior to init will be exempted from
63146 + grsecurity's chroot restrictions. This option is mainly meant to
63147 + resolve Plymouth's performing privileged operations unnecessarily
63148 + in a chroot.
63149 +
63150 +endmenu
63151 +menu "Kernel Auditing"
63152 +depends on GRKERNSEC
63153 +
63154 +config GRKERNSEC_AUDIT_GROUP
63155 + bool "Single group for auditing"
63156 + help
63157 + If you say Y here, the exec and chdir logging features will only operate
63158 + on a group you specify. This option is recommended if you only want to
63159 + watch certain users instead of having a large amount of logs from the
63160 + entire system. If the sysctl option is enabled, a sysctl option with
63161 + name "audit_group" is created.
63162 +
63163 +config GRKERNSEC_AUDIT_GID
63164 + int "GID for auditing"
63165 + depends on GRKERNSEC_AUDIT_GROUP
63166 + default 1007
63167 +
63168 +config GRKERNSEC_EXECLOG
63169 + bool "Exec logging"
63170 + help
63171 + If you say Y here, all execve() calls will be logged (since the
63172 + other exec*() calls are frontends to execve(), all execution
63173 + will be logged). Useful for shell-servers that like to keep track
63174 + of their users. If the sysctl option is enabled, a sysctl option with
63175 + name "exec_logging" is created.
63176 + WARNING: This option when enabled will produce a LOT of logs, especially
63177 + on an active system.
63178 +
63179 +config GRKERNSEC_RESLOG
63180 + bool "Resource logging"
63181 + default y if GRKERNSEC_CONFIG_AUTO
63182 + help
63183 + If you say Y here, all attempts to overstep resource limits will
63184 + be logged with the resource name, the requested size, and the current
63185 + limit. It is highly recommended that you say Y here. If the sysctl
63186 + option is enabled, a sysctl option with name "resource_logging" is
63187 + created. If the RBAC system is enabled, the sysctl value is ignored.
63188 +
63189 +config GRKERNSEC_CHROOT_EXECLOG
63190 + bool "Log execs within chroot"
63191 + help
63192 + If you say Y here, all executions inside a chroot jail will be logged
63193 + to syslog. This can cause a large amount of logs if certain
63194 + applications (eg. djb's daemontools) are installed on the system, and
63195 + is therefore left as an option. If the sysctl option is enabled, a
63196 + sysctl option with name "chroot_execlog" is created.
63197 +
63198 +config GRKERNSEC_AUDIT_PTRACE
63199 + bool "Ptrace logging"
63200 + help
63201 + If you say Y here, all attempts to attach to a process via ptrace
63202 + will be logged. If the sysctl option is enabled, a sysctl option
63203 + with name "audit_ptrace" is created.
63204 +
63205 +config GRKERNSEC_AUDIT_CHDIR
63206 + bool "Chdir logging"
63207 + help
63208 + If you say Y here, all chdir() calls will be logged. If the sysctl
63209 + option is enabled, a sysctl option with name "audit_chdir" is created.
63210 +
63211 +config GRKERNSEC_AUDIT_MOUNT
63212 + bool "(Un)Mount logging"
63213 + help
63214 + If you say Y here, all mounts and unmounts will be logged. If the
63215 + sysctl option is enabled, a sysctl option with name "audit_mount" is
63216 + created.
63217 +
63218 +config GRKERNSEC_SIGNAL
63219 + bool "Signal logging"
63220 + default y if GRKERNSEC_CONFIG_AUTO
63221 + help
63222 + If you say Y here, certain important signals will be logged, such as
63223 + SIGSEGV, which will as a result inform you of when a error in a program
63224 + occurred, which in some cases could mean a possible exploit attempt.
63225 + If the sysctl option is enabled, a sysctl option with name
63226 + "signal_logging" is created.
63227 +
63228 +config GRKERNSEC_FORKFAIL
63229 + bool "Fork failure logging"
63230 + help
63231 + If you say Y here, all failed fork() attempts will be logged.
63232 + This could suggest a fork bomb, or someone attempting to overstep
63233 + their process limit. If the sysctl option is enabled, a sysctl option
63234 + with name "forkfail_logging" is created.
63235 +
63236 +config GRKERNSEC_TIME
63237 + bool "Time change logging"
63238 + default y if GRKERNSEC_CONFIG_AUTO
63239 + help
63240 + If you say Y here, any changes of the system clock will be logged.
63241 + If the sysctl option is enabled, a sysctl option with name
63242 + "timechange_logging" is created.
63243 +
63244 +config GRKERNSEC_PROC_IPADDR
63245 + bool "/proc/<pid>/ipaddr support"
63246 + default y if GRKERNSEC_CONFIG_AUTO
63247 + help
63248 + If you say Y here, a new entry will be added to each /proc/<pid>
63249 + directory that contains the IP address of the person using the task.
63250 + The IP is carried across local TCP and AF_UNIX stream sockets.
63251 + This information can be useful for IDS/IPSes to perform remote response
63252 + to a local attack. The entry is readable by only the owner of the
63253 + process (and root if he has CAP_DAC_OVERRIDE, which can be removed via
63254 + the RBAC system), and thus does not create privacy concerns.
63255 +
63256 +config GRKERNSEC_RWXMAP_LOG
63257 + bool 'Denied RWX mmap/mprotect logging'
63258 + default y if GRKERNSEC_CONFIG_AUTO
63259 + depends on PAX_MPROTECT && !PAX_EMUPLT && !PAX_EMUSIGRT
63260 + help
63261 + If you say Y here, calls to mmap() and mprotect() with explicit
63262 + usage of PROT_WRITE and PROT_EXEC together will be logged when
63263 + denied by the PAX_MPROTECT feature. This feature will also
63264 + log other problematic scenarios that can occur when PAX_MPROTECT
63265 + is enabled on a binary, like textrels and PT_GNU_STACK. If the
63266 + sysctl option is enabled, a sysctl option with name "rwxmap_logging"
63267 + is created.
63268 +
63269 +endmenu
63270 +
63271 +menu "Executable Protections"
63272 +depends on GRKERNSEC
63273 +
63274 +config GRKERNSEC_DMESG
63275 + bool "Dmesg(8) restriction"
63276 + default y if GRKERNSEC_CONFIG_AUTO
63277 + help
63278 + If you say Y here, non-root users will not be able to use dmesg(8)
63279 + to view the contents of the kernel's circular log buffer.
63280 + The kernel's log buffer often contains kernel addresses and other
63281 + identifying information useful to an attacker in fingerprinting a
63282 + system for a targeted exploit.
63283 + If the sysctl option is enabled, a sysctl option with name "dmesg" is
63284 + created.
63285 +
63286 +config GRKERNSEC_HARDEN_PTRACE
63287 + bool "Deter ptrace-based process snooping"
63288 + default y if GRKERNSEC_CONFIG_AUTO
63289 + help
63290 + If you say Y here, TTY sniffers and other malicious monitoring
63291 + programs implemented through ptrace will be defeated. If you
63292 + have been using the RBAC system, this option has already been
63293 + enabled for several years for all users, with the ability to make
63294 + fine-grained exceptions.
63295 +
63296 + This option only affects the ability of non-root users to ptrace
63297 + processes that are not a descendent of the ptracing process.
63298 + This means that strace ./binary and gdb ./binary will still work,
63299 + but attaching to arbitrary processes will not. If the sysctl
63300 + option is enabled, a sysctl option with name "harden_ptrace" is
63301 + created.
63302 +
63303 +config GRKERNSEC_PTRACE_READEXEC
63304 + bool "Require read access to ptrace sensitive binaries"
63305 + default y if GRKERNSEC_CONFIG_AUTO
63306 + help
63307 + If you say Y here, unprivileged users will not be able to ptrace unreadable
63308 + binaries. This option is useful in environments that
63309 + remove the read bits (e.g. file mode 4711) from suid binaries to
63310 + prevent infoleaking of their contents. This option adds
63311 + consistency to the use of that file mode, as the binary could normally
63312 + be read out when run without privileges while ptracing.
63313 +
63314 + If the sysctl option is enabled, a sysctl option with name "ptrace_readexec"
63315 + is created.
63316 +
63317 +config GRKERNSEC_SETXID
63318 + bool "Enforce consistent multithreaded privileges"
63319 + default y if GRKERNSEC_CONFIG_AUTO
63320 + depends on (X86 || SPARC64 || PPC || ARM || MIPS)
63321 + help
63322 + If you say Y here, a change from a root uid to a non-root uid
63323 + in a multithreaded application will cause the resulting uids,
63324 + gids, supplementary groups, and capabilities in that thread
63325 + to be propagated to the other threads of the process. In most
63326 + cases this is unnecessary, as glibc will emulate this behavior
63327 + on behalf of the application. Other libcs do not act in the
63328 + same way, allowing the other threads of the process to continue
63329 + running with root privileges. If the sysctl option is enabled,
63330 + a sysctl option with name "consistent_setxid" is created.
63331 +
63332 +config GRKERNSEC_HARDEN_IPC
63333 + bool "Disallow access to overly-permissive IPC objects"
63334 + default y if GRKERNSEC_CONFIG_AUTO
63335 + depends on SYSVIPC
63336 + help
63337 + If you say Y here, access to overly-permissive IPC objects (shared
63338 + memory, message queues, and semaphores) will be denied for processes
63339 + given the following criteria beyond normal permission checks:
63340 + 1) If the IPC object is world-accessible and the euid doesn't match
63341 + that of the creator or current uid for the IPC object
63342 + 2) If the IPC object is group-accessible and the egid doesn't
63343 + match that of the creator or current gid for the IPC object
63344 + It's a common error to grant too much permission to these objects,
63345 + with impact ranging from denial of service and information leaking to
63346 + privilege escalation. This feature was developed in response to
63347 + research by Tim Brown:
63348 + http://labs.portcullis.co.uk/whitepapers/memory-squatting-attacks-on-system-v-shared-memory/
63349 + who found hundreds of such insecure usages. Processes with
63350 + CAP_IPC_OWNER are still permitted to access these IPC objects.
63351 + If the sysctl option is enabled, a sysctl option with name
63352 + "harden_ipc" is created.
63353 +
63354 +config GRKERNSEC_TPE
63355 + bool "Trusted Path Execution (TPE)"
63356 + default y if GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_SERVER
63357 + help
63358 + If you say Y here, you will be able to choose a gid to add to the
63359 + supplementary groups of users you want to mark as "untrusted."
63360 + These users will not be able to execute any files that are not in
63361 + root-owned directories writable only by root. If the sysctl option
63362 + is enabled, a sysctl option with name "tpe" is created.
63363 +
63364 +config GRKERNSEC_TPE_ALL
63365 + bool "Partially restrict all non-root users"
63366 + depends on GRKERNSEC_TPE
63367 + help
63368 + If you say Y here, all non-root users will be covered under
63369 + a weaker TPE restriction. This is separate from, and in addition to,
63370 + the main TPE options that you have selected elsewhere. Thus, if a
63371 + "trusted" GID is chosen, this restriction applies to even that GID.
63372 + Under this restriction, all non-root users will only be allowed to
63373 + execute files in directories they own that are not group or
63374 + world-writable, or in directories owned by root and writable only by
63375 + root. If the sysctl option is enabled, a sysctl option with name
63376 + "tpe_restrict_all" is created.
63377 +
63378 +config GRKERNSEC_TPE_INVERT
63379 + bool "Invert GID option"
63380 + depends on GRKERNSEC_TPE
63381 + help
63382 + If you say Y here, the group you specify in the TPE configuration will
63383 + decide what group TPE restrictions will be *disabled* for. This
63384 + option is useful if you want TPE restrictions to be applied to most
63385 + users on the system. If the sysctl option is enabled, a sysctl option
63386 + with name "tpe_invert" is created. Unlike other sysctl options, this
63387 + entry will default to on for backward-compatibility.
63388 +
63389 +config GRKERNSEC_TPE_GID
63390 + int
63391 + default GRKERNSEC_TPE_UNTRUSTED_GID if (GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT)
63392 + default GRKERNSEC_TPE_TRUSTED_GID if (GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT)
63393 +
63394 +config GRKERNSEC_TPE_UNTRUSTED_GID
63395 + int "GID for TPE-untrusted users"
63396 + depends on GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
63397 + default 1005
63398 + help
63399 + Setting this GID determines what group TPE restrictions will be
63400 + *enabled* for. If the sysctl option is enabled, a sysctl option
63401 + with name "tpe_gid" is created.
63402 +
63403 +config GRKERNSEC_TPE_TRUSTED_GID
63404 + int "GID for TPE-trusted users"
63405 + depends on GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
63406 + default 1005
63407 + help
63408 + Setting this GID determines what group TPE restrictions will be
63409 + *disabled* for. If the sysctl option is enabled, a sysctl option
63410 + with name "tpe_gid" is created.
63411 +
63412 +endmenu
63413 +menu "Network Protections"
63414 +depends on GRKERNSEC
63415 +
63416 +config GRKERNSEC_RANDNET
63417 + bool "Larger entropy pools"
63418 + default y if GRKERNSEC_CONFIG_AUTO
63419 + help
63420 + If you say Y here, the entropy pools used for many features of Linux
63421 + and grsecurity will be doubled in size. Since several grsecurity
63422 + features use additional randomness, it is recommended that you say Y
63423 + here. Saying Y here has a similar effect as modifying
63424 + /proc/sys/kernel/random/poolsize.
63425 +
63426 +config GRKERNSEC_BLACKHOLE
63427 + bool "TCP/UDP blackhole and LAST_ACK DoS prevention"
63428 + default y if GRKERNSEC_CONFIG_AUTO
63429 + depends on NET
63430 + help
63431 + If you say Y here, neither TCP resets nor ICMP
63432 + destination-unreachable packets will be sent in response to packets
63433 + sent to ports for which no associated listening process exists.
63434 + This feature supports both IPV4 and IPV6 and exempts the
63435 + loopback interface from blackholing. Enabling this feature
63436 + makes a host more resilient to DoS attacks and reduces network
63437 + visibility against scanners.
63438 +
63439 + The blackhole feature as-implemented is equivalent to the FreeBSD
63440 + blackhole feature, as it prevents RST responses to all packets, not
63441 + just SYNs. Under most application behavior this causes no
63442 + problems, but applications (like haproxy) may not close certain
63443 + connections in a way that cleanly terminates them on the remote
63444 + end, leaving the remote host in LAST_ACK state. Because of this
63445 + side-effect and to prevent intentional LAST_ACK DoSes, this
63446 + feature also adds automatic mitigation against such attacks.
63447 + The mitigation drastically reduces the amount of time a socket
63448 + can spend in LAST_ACK state. If you're using haproxy and not
63449 + all servers it connects to have this option enabled, consider
63450 + disabling this feature on the haproxy host.
63451 +
63452 + If the sysctl option is enabled, two sysctl options with names
63453 + "ip_blackhole" and "lastack_retries" will be created.
63454 + While "ip_blackhole" takes the standard zero/non-zero on/off
63455 + toggle, "lastack_retries" uses the same kinds of values as
63456 + "tcp_retries1" and "tcp_retries2". The default value of 4
63457 + prevents a socket from lasting more than 45 seconds in LAST_ACK
63458 + state.
63459 +
63460 +config GRKERNSEC_NO_SIMULT_CONNECT
63461 + bool "Disable TCP Simultaneous Connect"
63462 + default y if GRKERNSEC_CONFIG_AUTO
63463 + depends on NET
63464 + help
63465 + If you say Y here, a feature by Willy Tarreau will be enabled that
63466 + removes a weakness in Linux's strict implementation of TCP that
63467 + allows two clients to connect to each other without either entering
63468 + a listening state. The weakness allows an attacker to easily prevent
63469 + a client from connecting to a known server provided the source port
63470 + for the connection is guessed correctly.
63471 +
63472 + As the weakness could be used to prevent an antivirus or IPS from
63473 + fetching updates, or prevent an SSL gateway from fetching a CRL,
63474 + it should be eliminated by enabling this option. Though Linux is
63475 + one of few operating systems supporting simultaneous connect, it
63476 + has no legitimate use in practice and is rarely supported by firewalls.
63477 +
63478 +config GRKERNSEC_SOCKET
63479 + bool "Socket restrictions"
63480 + depends on NET
63481 + help
63482 + If you say Y here, you will be able to choose from several options.
63483 + If you assign a GID on your system and add it to the supplementary
63484 + groups of users you want to restrict socket access to, this patch
63485 + will perform up to three things, based on the option(s) you choose.
63486 +
63487 +config GRKERNSEC_SOCKET_ALL
63488 + bool "Deny any sockets to group"
63489 + depends on GRKERNSEC_SOCKET
63490 + help
63491 + If you say Y here, you will be able to choose a GID of whose users will
63492 + be unable to connect to other hosts from your machine or run server
63493 + applications from your machine. If the sysctl option is enabled, a
63494 + sysctl option with name "socket_all" is created.
63495 +
63496 +config GRKERNSEC_SOCKET_ALL_GID
63497 + int "GID to deny all sockets for"
63498 + depends on GRKERNSEC_SOCKET_ALL
63499 + default 1004
63500 + help
63501 + Here you can choose the GID to disable socket access for. Remember to
63502 + add the users you want socket access disabled for to the GID
63503 + specified here. If the sysctl option is enabled, a sysctl option
63504 + with name "socket_all_gid" is created.
63505 +
63506 +config GRKERNSEC_SOCKET_CLIENT
63507 + bool "Deny client sockets to group"
63508 + depends on GRKERNSEC_SOCKET
63509 + help
63510 + If you say Y here, you will be able to choose a GID of whose users will
63511 + be unable to connect to other hosts from your machine, but will be
63512 + able to run servers. If this option is enabled, all users in the group
63513 + you specify will have to use passive mode when initiating ftp transfers
63514 + from the shell on your machine. If the sysctl option is enabled, a
63515 + sysctl option with name "socket_client" is created.
63516 +
63517 +config GRKERNSEC_SOCKET_CLIENT_GID
63518 + int "GID to deny client sockets for"
63519 + depends on GRKERNSEC_SOCKET_CLIENT
63520 + default 1003
63521 + help
63522 + Here you can choose the GID to disable client socket access for.
63523 + Remember to add the users you want client socket access disabled for to
63524 + the GID specified here. If the sysctl option is enabled, a sysctl
63525 + option with name "socket_client_gid" is created.
63526 +
63527 +config GRKERNSEC_SOCKET_SERVER
63528 + bool "Deny server sockets to group"
63529 + depends on GRKERNSEC_SOCKET
63530 + help
63531 + If you say Y here, you will be able to choose a GID of whose users will
63532 + be unable to run server applications from your machine. If the sysctl
63533 + option is enabled, a sysctl option with name "socket_server" is created.
63534 +
63535 +config GRKERNSEC_SOCKET_SERVER_GID
63536 + int "GID to deny server sockets for"
63537 + depends on GRKERNSEC_SOCKET_SERVER
63538 + default 1002
63539 + help
63540 + Here you can choose the GID to disable server socket access for.
63541 + Remember to add the users you want server socket access disabled for to
63542 + the GID specified here. If the sysctl option is enabled, a sysctl
63543 + option with name "socket_server_gid" is created.
63544 +
63545 +endmenu
63546 +
63547 +menu "Physical Protections"
63548 +depends on GRKERNSEC
63549 +
63550 +config GRKERNSEC_DENYUSB
63551 + bool "Deny new USB connections after toggle"
63552 + default y if GRKERNSEC_CONFIG_AUTO
63553 + depends on SYSCTL && USB_SUPPORT
63554 + help
63555 + If you say Y here, a new sysctl option with name "deny_new_usb"
63556 + will be created. Setting its value to 1 will prevent any new
63557 + USB devices from being recognized by the OS. Any attempted USB
63558 + device insertion will be logged. This option is intended to be
63559 + used against custom USB devices designed to exploit vulnerabilities
63560 + in various USB device drivers.
63561 +
63562 + For greatest effectiveness, this sysctl should be set after any
63563 + relevant init scripts. This option is safe to enable in distros
63564 + as each user can choose whether or not to toggle the sysctl.
63565 +
63566 +config GRKERNSEC_DENYUSB_FORCE
63567 + bool "Reject all USB devices not connected at boot"
63568 + select USB
63569 + depends on GRKERNSEC_DENYUSB
63570 + help
63571 + If you say Y here, a variant of GRKERNSEC_DENYUSB will be enabled
63572 + that doesn't involve a sysctl entry. This option should only be
63573 + enabled if you're sure you want to deny all new USB connections
63574 + at runtime and don't want to modify init scripts. This should not
63575 + be enabled by distros. It forces the core USB code to be built
63576 + into the kernel image so that all devices connected at boot time
63577 + can be recognized and new USB device connections can be prevented
63578 + prior to init running.
63579 +
63580 +endmenu
63581 +
63582 +menu "Sysctl Support"
63583 +depends on GRKERNSEC && SYSCTL
63584 +
63585 +config GRKERNSEC_SYSCTL
63586 + bool "Sysctl support"
63587 + default y if GRKERNSEC_CONFIG_AUTO
63588 + help
63589 + If you say Y here, you will be able to change the options that
63590 + grsecurity runs with at bootup, without having to recompile your
63591 + kernel. You can echo values to files in /proc/sys/kernel/grsecurity
63592 + to enable (1) or disable (0) various features. All the sysctl entries
63593 + are mutable until the "grsec_lock" entry is set to a non-zero value.
63594 + All features enabled in the kernel configuration are disabled at boot
63595 + if you do not say Y to the "Turn on features by default" option.
63596 + All options should be set at startup, and the grsec_lock entry should
63597 + be set to a non-zero value after all the options are set.
63598 + *THIS IS EXTREMELY IMPORTANT*
63599 +
63600 +config GRKERNSEC_SYSCTL_DISTRO
63601 + bool "Extra sysctl support for distro makers (READ HELP)"
63602 + depends on GRKERNSEC_SYSCTL && GRKERNSEC_IO
63603 + help
63604 + If you say Y here, additional sysctl options will be created
63605 + for features that affect processes running as root. Therefore,
63606 + it is critical when using this option that the grsec_lock entry be
63607 + enabled after boot. Only distros with prebuilt kernel packages
63608 + with this option enabled that can ensure grsec_lock is enabled
63609 + after boot should use this option.
63610 + *Failure to set grsec_lock after boot makes all grsec features
63611 + this option covers useless*
63612 +
63613 + Currently this option creates the following sysctl entries:
63614 + "Disable Privileged I/O": "disable_priv_io"
63615 +
63616 +config GRKERNSEC_SYSCTL_ON
63617 + bool "Turn on features by default"
63618 + default y if GRKERNSEC_CONFIG_AUTO
63619 + depends on GRKERNSEC_SYSCTL
63620 + help
63621 + If you say Y here, instead of having all features enabled in the
63622 + kernel configuration disabled at boot time, the features will be
63623 + enabled at boot time. It is recommended you say Y here unless
63624 + there is some reason you would want all sysctl-tunable features to
63625 + be disabled by default. As mentioned elsewhere, it is important
63626 + to enable the grsec_lock entry once you have finished modifying
63627 + the sysctl entries.
63628 +
63629 +endmenu
63630 +menu "Logging Options"
63631 +depends on GRKERNSEC
63632 +
63633 +config GRKERNSEC_FLOODTIME
63634 + int "Seconds in between log messages (minimum)"
63635 + default 10
63636 + help
63637 + This option allows you to enforce the number of seconds between
63638 + grsecurity log messages. The default should be suitable for most
63639 + people, however, if you choose to change it, choose a value small enough
63640 + to allow informative logs to be produced, but large enough to
63641 + prevent flooding.
63642 +
63643 +config GRKERNSEC_FLOODBURST
63644 + int "Number of messages in a burst (maximum)"
63645 + default 6
63646 + help
63647 + This option allows you to choose the maximum number of messages allowed
63648 + within the flood time interval you chose in a separate option. The
63649 + default should be suitable for most people, however if you find that
63650 + many of your logs are being interpreted as flooding, you may want to
63651 + raise this value.
63652 +
63653 +endmenu
63654 diff --git a/grsecurity/Makefile b/grsecurity/Makefile
63655 new file mode 100644
63656 index 0000000..85beb79
63657 --- /dev/null
63658 +++ b/grsecurity/Makefile
63659 @@ -0,0 +1,43 @@
63660 +# grsecurity's ACL system was originally written in 2001 by Michael Dalton
63661 +# during 2001-2009 it has been completely redesigned by Brad Spengler
63662 +# into an RBAC system
63663 +#
63664 +# All code in this directory and various hooks inserted throughout the kernel
63665 +# are copyright Brad Spengler - Open Source Security, Inc., and released
63666 +# under the GPL v2 or higher
63667 +
63668 +KBUILD_CFLAGS += -Werror
63669 +
63670 +obj-y = grsec_chdir.o grsec_chroot.o grsec_exec.o grsec_fifo.o grsec_fork.o \
63671 + grsec_mount.o grsec_sig.o grsec_sysctl.o \
63672 + grsec_time.o grsec_tpe.o grsec_link.o grsec_pax.o grsec_ptrace.o \
63673 + grsec_usb.o grsec_ipc.o
63674 +
63675 +obj-$(CONFIG_GRKERNSEC) += grsec_init.o grsum.o gracl.o gracl_segv.o \
63676 + gracl_cap.o gracl_alloc.o gracl_shm.o grsec_mem.o gracl_fs.o \
63677 + gracl_learn.o grsec_log.o gracl_policy.o
63678 +ifdef CONFIG_COMPAT
63679 +obj-$(CONFIG_GRKERNSEC) += gracl_compat.o
63680 +endif
63681 +
63682 +obj-$(CONFIG_GRKERNSEC_RESLOG) += gracl_res.o
63683 +
63684 +ifdef CONFIG_NET
63685 +obj-y += grsec_sock.o
63686 +obj-$(CONFIG_GRKERNSEC) += gracl_ip.o
63687 +endif
63688 +
63689 +ifndef CONFIG_GRKERNSEC
63690 +obj-y += grsec_disabled.o
63691 +endif
63692 +
63693 +ifdef CONFIG_GRKERNSEC_HIDESYM
63694 +extra-y := grsec_hidesym.o
63695 +$(obj)/grsec_hidesym.o:
63696 + @-chmod -f 500 /boot
63697 + @-chmod -f 500 /lib/modules
63698 + @-chmod -f 500 /lib64/modules
63699 + @-chmod -f 500 /lib32/modules
63700 + @-chmod -f 700 .
63701 + @echo ' grsec: protected kernel image paths'
63702 +endif
63703 diff --git a/grsecurity/gracl.c b/grsecurity/gracl.c
63704 new file mode 100644
63705 index 0000000..90f71ce
63706 --- /dev/null
63707 +++ b/grsecurity/gracl.c
63708 @@ -0,0 +1,2679 @@
63709 +#include <linux/kernel.h>
63710 +#include <linux/module.h>
63711 +#include <linux/sched.h>
63712 +#include <linux/mm.h>
63713 +#include <linux/file.h>
63714 +#include <linux/fs.h>
63715 +#include <linux/namei.h>
63716 +#include <linux/mount.h>
63717 +#include <linux/tty.h>
63718 +#include <linux/proc_fs.h>
63719 +#include <linux/lglock.h>
63720 +#include <linux/slab.h>
63721 +#include <linux/vmalloc.h>
63722 +#include <linux/types.h>
63723 +#include <linux/sysctl.h>
63724 +#include <linux/netdevice.h>
63725 +#include <linux/ptrace.h>
63726 +#include <linux/gracl.h>
63727 +#include <linux/gralloc.h>
63728 +#include <linux/security.h>
63729 +#include <linux/grinternal.h>
63730 +#include <linux/pid_namespace.h>
63731 +#include <linux/stop_machine.h>
63732 +#include <linux/fdtable.h>
63733 +#include <linux/percpu.h>
63734 +#include <linux/lglock.h>
63735 +#include <linux/hugetlb.h>
63736 +#include <linux/posix-timers.h>
63737 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63738 +#include <linux/magic.h>
63739 +#include <linux/pagemap.h>
63740 +#include "../fs/btrfs/async-thread.h"
63741 +#include "../fs/btrfs/ctree.h"
63742 +#include "../fs/btrfs/btrfs_inode.h"
63743 +#endif
63744 +#include "../fs/mount.h"
63745 +
63746 +#include <asm/uaccess.h>
63747 +#include <asm/errno.h>
63748 +#include <asm/mman.h>
63749 +
63750 +#define FOR_EACH_ROLE_START(role) \
63751 + role = running_polstate.role_list; \
63752 + while (role) {
63753 +
63754 +#define FOR_EACH_ROLE_END(role) \
63755 + role = role->prev; \
63756 + }
63757 +
63758 +extern struct lglock vfsmount_lock;
63759 +
63760 +extern struct path gr_real_root;
63761 +
63762 +static struct gr_policy_state running_polstate;
63763 +struct gr_policy_state *polstate = &running_polstate;
63764 +extern struct gr_alloc_state *current_alloc_state;
63765 +
63766 +extern char *gr_shared_page[4];
63767 +DEFINE_RWLOCK(gr_inode_lock);
63768 +
63769 +static unsigned int gr_status __read_only = GR_STATUS_INIT;
63770 +
63771 +#ifdef CONFIG_NET
63772 +extern struct vfsmount *sock_mnt;
63773 +#endif
63774 +
63775 +extern struct vfsmount *pipe_mnt;
63776 +extern struct vfsmount *shm_mnt;
63777 +
63778 +#ifdef CONFIG_HUGETLBFS
63779 +extern struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];
63780 +#endif
63781 +
63782 +extern u16 acl_sp_role_value;
63783 +extern struct acl_object_label *fakefs_obj_rw;
63784 +extern struct acl_object_label *fakefs_obj_rwx;
63785 +
63786 +int gr_acl_is_enabled(void)
63787 +{
63788 + return (gr_status & GR_READY);
63789 +}
63790 +
63791 +void gr_enable_rbac_system(void)
63792 +{
63793 + pax_open_kernel();
63794 + gr_status |= GR_READY;
63795 + pax_close_kernel();
63796 +}
63797 +
63798 +int gr_rbac_disable(void *unused)
63799 +{
63800 + pax_open_kernel();
63801 + gr_status &= ~GR_READY;
63802 + pax_close_kernel();
63803 +
63804 + return 0;
63805 +}
63806 +
63807 +static inline dev_t __get_dev(const struct dentry *dentry)
63808 +{
63809 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
63810 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
63811 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
63812 + else
63813 +#endif
63814 + return dentry->d_sb->s_dev;
63815 +}
63816 +
63817 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
63818 +{
63819 + return __get_dev(dentry);
63820 +}
63821 +
63822 +static char gr_task_roletype_to_char(struct task_struct *task)
63823 +{
63824 + switch (task->role->roletype &
63825 + (GR_ROLE_DEFAULT | GR_ROLE_USER | GR_ROLE_GROUP |
63826 + GR_ROLE_SPECIAL)) {
63827 + case GR_ROLE_DEFAULT:
63828 + return 'D';
63829 + case GR_ROLE_USER:
63830 + return 'U';
63831 + case GR_ROLE_GROUP:
63832 + return 'G';
63833 + case GR_ROLE_SPECIAL:
63834 + return 'S';
63835 + }
63836 +
63837 + return 'X';
63838 +}
63839 +
63840 +char gr_roletype_to_char(void)
63841 +{
63842 + return gr_task_roletype_to_char(current);
63843 +}
63844 +
63845 +__inline__ int
63846 +gr_acl_tpe_check(void)
63847 +{
63848 + if (unlikely(!(gr_status & GR_READY)))
63849 + return 0;
63850 + if (current->role->roletype & GR_ROLE_TPE)
63851 + return 1;
63852 + else
63853 + return 0;
63854 +}
63855 +
63856 +int
63857 +gr_handle_rawio(const struct inode *inode)
63858 +{
63859 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
63860 + if (inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR)) &&
63861 + grsec_enable_chroot_caps && proc_is_chrooted(current) &&
63862 + !capable(CAP_SYS_RAWIO))
63863 + return 1;
63864 +#endif
63865 + return 0;
63866 +}
63867 +
63868 +int
63869 +gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb)
63870 +{
63871 + if (likely(lena != lenb))
63872 + return 0;
63873 +
63874 + return !memcmp(a, b, lena);
63875 +}
63876 +
63877 +static int prepend(char **buffer, int *buflen, const char *str, int namelen)
63878 +{
63879 + *buflen -= namelen;
63880 + if (*buflen < 0)
63881 + return -ENAMETOOLONG;
63882 + *buffer -= namelen;
63883 + memcpy(*buffer, str, namelen);
63884 + return 0;
63885 +}
63886 +
63887 +static int prepend_name(char **buffer, int *buflen, struct qstr *name)
63888 +{
63889 + return prepend(buffer, buflen, name->name, name->len);
63890 +}
63891 +
63892 +static int prepend_path(const struct path *path, struct path *root,
63893 + char **buffer, int *buflen)
63894 +{
63895 + struct dentry *dentry = path->dentry;
63896 + struct vfsmount *vfsmnt = path->mnt;
63897 + struct mount *mnt = real_mount(vfsmnt);
63898 + bool slash = false;
63899 + int error = 0;
63900 +
63901 + while (dentry != root->dentry || vfsmnt != root->mnt) {
63902 + struct dentry * parent;
63903 +
63904 + if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
63905 + /* Global root? */
63906 + if (!mnt_has_parent(mnt)) {
63907 + goto out;
63908 + }
63909 + dentry = mnt->mnt_mountpoint;
63910 + mnt = mnt->mnt_parent;
63911 + vfsmnt = &mnt->mnt;
63912 + continue;
63913 + }
63914 + parent = dentry->d_parent;
63915 + prefetch(parent);
63916 + spin_lock(&dentry->d_lock);
63917 + error = prepend_name(buffer, buflen, &dentry->d_name);
63918 + spin_unlock(&dentry->d_lock);
63919 + if (!error)
63920 + error = prepend(buffer, buflen, "/", 1);
63921 + if (error)
63922 + break;
63923 +
63924 + slash = true;
63925 + dentry = parent;
63926 + }
63927 +
63928 +out:
63929 + if (!error && !slash)
63930 + error = prepend(buffer, buflen, "/", 1);
63931 +
63932 + return error;
63933 +}
63934 +
63935 +/* this must be called with vfsmount_lock and rename_lock held */
63936 +
63937 +static char *__our_d_path(const struct path *path, struct path *root,
63938 + char *buf, int buflen)
63939 +{
63940 + char *res = buf + buflen;
63941 + int error;
63942 +
63943 + prepend(&res, &buflen, "\0", 1);
63944 + error = prepend_path(path, root, &res, &buflen);
63945 + if (error)
63946 + return ERR_PTR(error);
63947 +
63948 + return res;
63949 +}
63950 +
63951 +static char *
63952 +gen_full_path(struct path *path, struct path *root, char *buf, int buflen)
63953 +{
63954 + char *retval;
63955 +
63956 + retval = __our_d_path(path, root, buf, buflen);
63957 + if (unlikely(IS_ERR(retval)))
63958 + retval = strcpy(buf, "<path too long>");
63959 + else if (unlikely(retval[1] == '/' && retval[2] == '\0'))
63960 + retval[1] = '\0';
63961 +
63962 + return retval;
63963 +}
63964 +
63965 +static char *
63966 +__d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63967 + char *buf, int buflen)
63968 +{
63969 + struct path path;
63970 + char *res;
63971 +
63972 + path.dentry = (struct dentry *)dentry;
63973 + path.mnt = (struct vfsmount *)vfsmnt;
63974 +
63975 + /* we can use gr_real_root.dentry, gr_real_root.mnt, because this is only called
63976 + by the RBAC system */
63977 + res = gen_full_path(&path, &gr_real_root, buf, buflen);
63978 +
63979 + return res;
63980 +}
63981 +
63982 +static char *
63983 +d_real_path(const struct dentry *dentry, const struct vfsmount *vfsmnt,
63984 + char *buf, int buflen)
63985 +{
63986 + char *res;
63987 + struct path path;
63988 + struct path root;
63989 + struct task_struct *reaper = init_pid_ns.child_reaper;
63990 +
63991 + path.dentry = (struct dentry *)dentry;
63992 + path.mnt = (struct vfsmount *)vfsmnt;
63993 +
63994 + /* we can't use gr_real_root.dentry, gr_real_root.mnt, because they belong only to the RBAC system */
63995 + get_fs_root(reaper->fs, &root);
63996 +
63997 + br_read_lock(&vfsmount_lock);
63998 + write_seqlock(&rename_lock);
63999 + res = gen_full_path(&path, &root, buf, buflen);
64000 + write_sequnlock(&rename_lock);
64001 + br_read_unlock(&vfsmount_lock);
64002 +
64003 + path_put(&root);
64004 + return res;
64005 +}
64006 +
64007 +char *
64008 +gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
64009 +{
64010 + char *ret;
64011 + br_read_lock(&vfsmount_lock);
64012 + write_seqlock(&rename_lock);
64013 + ret = __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
64014 + PAGE_SIZE);
64015 + write_sequnlock(&rename_lock);
64016 + br_read_unlock(&vfsmount_lock);
64017 + return ret;
64018 +}
64019 +
64020 +static char *
64021 +gr_to_proc_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt)
64022 +{
64023 + char *ret;
64024 + char *buf;
64025 + int buflen;
64026 +
64027 + br_read_lock(&vfsmount_lock);
64028 + write_seqlock(&rename_lock);
64029 + buf = per_cpu_ptr(gr_shared_page[0], smp_processor_id());
64030 + ret = __d_real_path(dentry, mnt, buf, PAGE_SIZE - 6);
64031 + buflen = (int)(ret - buf);
64032 + if (buflen >= 5)
64033 + prepend(&ret, &buflen, "/proc", 5);
64034 + else
64035 + ret = strcpy(buf, "<path too long>");
64036 + write_sequnlock(&rename_lock);
64037 + br_read_unlock(&vfsmount_lock);
64038 + return ret;
64039 +}
64040 +
64041 +char *
64042 +gr_to_filename_nolock(const struct dentry *dentry, const struct vfsmount *mnt)
64043 +{
64044 + return __d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0],smp_processor_id()),
64045 + PAGE_SIZE);
64046 +}
64047 +
64048 +char *
64049 +gr_to_filename(const struct dentry *dentry, const struct vfsmount *mnt)
64050 +{
64051 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
64052 + PAGE_SIZE);
64053 +}
64054 +
64055 +char *
64056 +gr_to_filename1(const struct dentry *dentry, const struct vfsmount *mnt)
64057 +{
64058 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[1], smp_processor_id()),
64059 + PAGE_SIZE);
64060 +}
64061 +
64062 +char *
64063 +gr_to_filename2(const struct dentry *dentry, const struct vfsmount *mnt)
64064 +{
64065 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[2], smp_processor_id()),
64066 + PAGE_SIZE);
64067 +}
64068 +
64069 +char *
64070 +gr_to_filename3(const struct dentry *dentry, const struct vfsmount *mnt)
64071 +{
64072 + return d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[3], smp_processor_id()),
64073 + PAGE_SIZE);
64074 +}
64075 +
64076 +__inline__ __u32
64077 +to_gr_audit(const __u32 reqmode)
64078 +{
64079 + /* masks off auditable permission flags, then shifts them to create
64080 + auditing flags, and adds the special case of append auditing if
64081 + we're requesting write */
64082 + return (((reqmode & ~GR_AUDITS) << 10) | ((reqmode & GR_WRITE) ? GR_AUDIT_APPEND : 0));
64083 +}
64084 +
64085 +struct acl_role_label *
64086 +__lookup_acl_role_label(const struct gr_policy_state *state, const struct task_struct *task, const uid_t uid,
64087 + const gid_t gid)
64088 +{
64089 + unsigned int index = gr_rhash(uid, GR_ROLE_USER, state->acl_role_set.r_size);
64090 + struct acl_role_label *match;
64091 + struct role_allowed_ip *ipp;
64092 + unsigned int x;
64093 + u32 curr_ip = task->signal->saved_ip;
64094 +
64095 + match = state->acl_role_set.r_hash[index];
64096 +
64097 + while (match) {
64098 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_USER)) == (GR_ROLE_DOMAIN | GR_ROLE_USER)) {
64099 + for (x = 0; x < match->domain_child_num; x++) {
64100 + if (match->domain_children[x] == uid)
64101 + goto found;
64102 + }
64103 + } else if (match->uidgid == uid && match->roletype & GR_ROLE_USER)
64104 + break;
64105 + match = match->next;
64106 + }
64107 +found:
64108 + if (match == NULL) {
64109 + try_group:
64110 + index = gr_rhash(gid, GR_ROLE_GROUP, state->acl_role_set.r_size);
64111 + match = state->acl_role_set.r_hash[index];
64112 +
64113 + while (match) {
64114 + if ((match->roletype & (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) == (GR_ROLE_DOMAIN | GR_ROLE_GROUP)) {
64115 + for (x = 0; x < match->domain_child_num; x++) {
64116 + if (match->domain_children[x] == gid)
64117 + goto found2;
64118 + }
64119 + } else if (match->uidgid == gid && match->roletype & GR_ROLE_GROUP)
64120 + break;
64121 + match = match->next;
64122 + }
64123 +found2:
64124 + if (match == NULL)
64125 + match = state->default_role;
64126 + if (match->allowed_ips == NULL)
64127 + return match;
64128 + else {
64129 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64130 + if (likely
64131 + ((ntohl(curr_ip) & ipp->netmask) ==
64132 + (ntohl(ipp->addr) & ipp->netmask)))
64133 + return match;
64134 + }
64135 + match = state->default_role;
64136 + }
64137 + } else if (match->allowed_ips == NULL) {
64138 + return match;
64139 + } else {
64140 + for (ipp = match->allowed_ips; ipp; ipp = ipp->next) {
64141 + if (likely
64142 + ((ntohl(curr_ip) & ipp->netmask) ==
64143 + (ntohl(ipp->addr) & ipp->netmask)))
64144 + return match;
64145 + }
64146 + goto try_group;
64147 + }
64148 +
64149 + return match;
64150 +}
64151 +
64152 +static struct acl_role_label *
64153 +lookup_acl_role_label(const struct task_struct *task, const uid_t uid,
64154 + const gid_t gid)
64155 +{
64156 + return __lookup_acl_role_label(&running_polstate, task, uid, gid);
64157 +}
64158 +
64159 +struct acl_subject_label *
64160 +lookup_acl_subj_label(const ino_t ino, const dev_t dev,
64161 + const struct acl_role_label *role)
64162 +{
64163 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64164 + struct acl_subject_label *match;
64165 +
64166 + match = role->subj_hash[index];
64167 +
64168 + while (match && (match->inode != ino || match->device != dev ||
64169 + (match->mode & GR_DELETED))) {
64170 + match = match->next;
64171 + }
64172 +
64173 + if (match && !(match->mode & GR_DELETED))
64174 + return match;
64175 + else
64176 + return NULL;
64177 +}
64178 +
64179 +struct acl_subject_label *
64180 +lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev,
64181 + const struct acl_role_label *role)
64182 +{
64183 + unsigned int index = gr_fhash(ino, dev, role->subj_hash_size);
64184 + struct acl_subject_label *match;
64185 +
64186 + match = role->subj_hash[index];
64187 +
64188 + while (match && (match->inode != ino || match->device != dev ||
64189 + !(match->mode & GR_DELETED))) {
64190 + match = match->next;
64191 + }
64192 +
64193 + if (match && (match->mode & GR_DELETED))
64194 + return match;
64195 + else
64196 + return NULL;
64197 +}
64198 +
64199 +static struct acl_object_label *
64200 +lookup_acl_obj_label(const ino_t ino, const dev_t dev,
64201 + const struct acl_subject_label *subj)
64202 +{
64203 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64204 + struct acl_object_label *match;
64205 +
64206 + match = subj->obj_hash[index];
64207 +
64208 + while (match && (match->inode != ino || match->device != dev ||
64209 + (match->mode & GR_DELETED))) {
64210 + match = match->next;
64211 + }
64212 +
64213 + if (match && !(match->mode & GR_DELETED))
64214 + return match;
64215 + else
64216 + return NULL;
64217 +}
64218 +
64219 +static struct acl_object_label *
64220 +lookup_acl_obj_label_create(const ino_t ino, const dev_t dev,
64221 + const struct acl_subject_label *subj)
64222 +{
64223 + unsigned int index = gr_fhash(ino, dev, subj->obj_hash_size);
64224 + struct acl_object_label *match;
64225 +
64226 + match = subj->obj_hash[index];
64227 +
64228 + while (match && (match->inode != ino || match->device != dev ||
64229 + !(match->mode & GR_DELETED))) {
64230 + match = match->next;
64231 + }
64232 +
64233 + if (match && (match->mode & GR_DELETED))
64234 + return match;
64235 +
64236 + match = subj->obj_hash[index];
64237 +
64238 + while (match && (match->inode != ino || match->device != dev ||
64239 + (match->mode & GR_DELETED))) {
64240 + match = match->next;
64241 + }
64242 +
64243 + if (match && !(match->mode & GR_DELETED))
64244 + return match;
64245 + else
64246 + return NULL;
64247 +}
64248 +
64249 +struct name_entry *
64250 +__lookup_name_entry(const struct gr_policy_state *state, const char *name)
64251 +{
64252 + unsigned int len = strlen(name);
64253 + unsigned int key = full_name_hash(name, len);
64254 + unsigned int index = key % state->name_set.n_size;
64255 + struct name_entry *match;
64256 +
64257 + match = state->name_set.n_hash[index];
64258 +
64259 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len)))
64260 + match = match->next;
64261 +
64262 + return match;
64263 +}
64264 +
64265 +static struct name_entry *
64266 +lookup_name_entry(const char *name)
64267 +{
64268 + return __lookup_name_entry(&running_polstate, name);
64269 +}
64270 +
64271 +static struct name_entry *
64272 +lookup_name_entry_create(const char *name)
64273 +{
64274 + unsigned int len = strlen(name);
64275 + unsigned int key = full_name_hash(name, len);
64276 + unsigned int index = key % running_polstate.name_set.n_size;
64277 + struct name_entry *match;
64278 +
64279 + match = running_polstate.name_set.n_hash[index];
64280 +
64281 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64282 + !match->deleted))
64283 + match = match->next;
64284 +
64285 + if (match && match->deleted)
64286 + return match;
64287 +
64288 + match = running_polstate.name_set.n_hash[index];
64289 +
64290 + while (match && (match->key != key || !gr_streq(match->name, name, match->len, len) ||
64291 + match->deleted))
64292 + match = match->next;
64293 +
64294 + if (match && !match->deleted)
64295 + return match;
64296 + else
64297 + return NULL;
64298 +}
64299 +
64300 +static struct inodev_entry *
64301 +lookup_inodev_entry(const ino_t ino, const dev_t dev)
64302 +{
64303 + unsigned int index = gr_fhash(ino, dev, running_polstate.inodev_set.i_size);
64304 + struct inodev_entry *match;
64305 +
64306 + match = running_polstate.inodev_set.i_hash[index];
64307 +
64308 + while (match && (match->nentry->inode != ino || match->nentry->device != dev))
64309 + match = match->next;
64310 +
64311 + return match;
64312 +}
64313 +
64314 +void
64315 +__insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry)
64316 +{
64317 + unsigned int index = gr_fhash(entry->nentry->inode, entry->nentry->device,
64318 + state->inodev_set.i_size);
64319 + struct inodev_entry **curr;
64320 +
64321 + entry->prev = NULL;
64322 +
64323 + curr = &state->inodev_set.i_hash[index];
64324 + if (*curr != NULL)
64325 + (*curr)->prev = entry;
64326 +
64327 + entry->next = *curr;
64328 + *curr = entry;
64329 +
64330 + return;
64331 +}
64332 +
64333 +static void
64334 +insert_inodev_entry(struct inodev_entry *entry)
64335 +{
64336 + __insert_inodev_entry(&running_polstate, entry);
64337 +}
64338 +
64339 +void
64340 +insert_acl_obj_label(struct acl_object_label *obj,
64341 + struct acl_subject_label *subj)
64342 +{
64343 + unsigned int index =
64344 + gr_fhash(obj->inode, obj->device, subj->obj_hash_size);
64345 + struct acl_object_label **curr;
64346 +
64347 + obj->prev = NULL;
64348 +
64349 + curr = &subj->obj_hash[index];
64350 + if (*curr != NULL)
64351 + (*curr)->prev = obj;
64352 +
64353 + obj->next = *curr;
64354 + *curr = obj;
64355 +
64356 + return;
64357 +}
64358 +
64359 +void
64360 +insert_acl_subj_label(struct acl_subject_label *obj,
64361 + struct acl_role_label *role)
64362 +{
64363 + unsigned int index = gr_fhash(obj->inode, obj->device, role->subj_hash_size);
64364 + struct acl_subject_label **curr;
64365 +
64366 + obj->prev = NULL;
64367 +
64368 + curr = &role->subj_hash[index];
64369 + if (*curr != NULL)
64370 + (*curr)->prev = obj;
64371 +
64372 + obj->next = *curr;
64373 + *curr = obj;
64374 +
64375 + return;
64376 +}
64377 +
64378 +/* derived from glibc fnmatch() 0: match, 1: no match*/
64379 +
64380 +static int
64381 +glob_match(const char *p, const char *n)
64382 +{
64383 + char c;
64384 +
64385 + while ((c = *p++) != '\0') {
64386 + switch (c) {
64387 + case '?':
64388 + if (*n == '\0')
64389 + return 1;
64390 + else if (*n == '/')
64391 + return 1;
64392 + break;
64393 + case '\\':
64394 + if (*n != c)
64395 + return 1;
64396 + break;
64397 + case '*':
64398 + for (c = *p++; c == '?' || c == '*'; c = *p++) {
64399 + if (*n == '/')
64400 + return 1;
64401 + else if (c == '?') {
64402 + if (*n == '\0')
64403 + return 1;
64404 + else
64405 + ++n;
64406 + }
64407 + }
64408 + if (c == '\0') {
64409 + return 0;
64410 + } else {
64411 + const char *endp;
64412 +
64413 + if ((endp = strchr(n, '/')) == NULL)
64414 + endp = n + strlen(n);
64415 +
64416 + if (c == '[') {
64417 + for (--p; n < endp; ++n)
64418 + if (!glob_match(p, n))
64419 + return 0;
64420 + } else if (c == '/') {
64421 + while (*n != '\0' && *n != '/')
64422 + ++n;
64423 + if (*n == '/' && !glob_match(p, n + 1))
64424 + return 0;
64425 + } else {
64426 + for (--p; n < endp; ++n)
64427 + if (*n == c && !glob_match(p, n))
64428 + return 0;
64429 + }
64430 +
64431 + return 1;
64432 + }
64433 + case '[':
64434 + {
64435 + int not;
64436 + char cold;
64437 +
64438 + if (*n == '\0' || *n == '/')
64439 + return 1;
64440 +
64441 + not = (*p == '!' || *p == '^');
64442 + if (not)
64443 + ++p;
64444 +
64445 + c = *p++;
64446 + for (;;) {
64447 + unsigned char fn = (unsigned char)*n;
64448 +
64449 + if (c == '\0')
64450 + return 1;
64451 + else {
64452 + if (c == fn)
64453 + goto matched;
64454 + cold = c;
64455 + c = *p++;
64456 +
64457 + if (c == '-' && *p != ']') {
64458 + unsigned char cend = *p++;
64459 +
64460 + if (cend == '\0')
64461 + return 1;
64462 +
64463 + if (cold <= fn && fn <= cend)
64464 + goto matched;
64465 +
64466 + c = *p++;
64467 + }
64468 + }
64469 +
64470 + if (c == ']')
64471 + break;
64472 + }
64473 + if (!not)
64474 + return 1;
64475 + break;
64476 + matched:
64477 + while (c != ']') {
64478 + if (c == '\0')
64479 + return 1;
64480 +
64481 + c = *p++;
64482 + }
64483 + if (not)
64484 + return 1;
64485 + }
64486 + break;
64487 + default:
64488 + if (c != *n)
64489 + return 1;
64490 + }
64491 +
64492 + ++n;
64493 + }
64494 +
64495 + if (*n == '\0')
64496 + return 0;
64497 +
64498 + if (*n == '/')
64499 + return 0;
64500 +
64501 + return 1;
64502 +}
64503 +
64504 +static struct acl_object_label *
64505 +chk_glob_label(struct acl_object_label *globbed,
64506 + const struct dentry *dentry, const struct vfsmount *mnt, char **path)
64507 +{
64508 + struct acl_object_label *tmp;
64509 +
64510 + if (*path == NULL)
64511 + *path = gr_to_filename_nolock(dentry, mnt);
64512 +
64513 + tmp = globbed;
64514 +
64515 + while (tmp) {
64516 + if (!glob_match(tmp->filename, *path))
64517 + return tmp;
64518 + tmp = tmp->next;
64519 + }
64520 +
64521 + return NULL;
64522 +}
64523 +
64524 +static struct acl_object_label *
64525 +__full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64526 + const ino_t curr_ino, const dev_t curr_dev,
64527 + const struct acl_subject_label *subj, char **path, const int checkglob)
64528 +{
64529 + struct acl_subject_label *tmpsubj;
64530 + struct acl_object_label *retval;
64531 + struct acl_object_label *retval2;
64532 +
64533 + tmpsubj = (struct acl_subject_label *) subj;
64534 + read_lock(&gr_inode_lock);
64535 + do {
64536 + retval = lookup_acl_obj_label(curr_ino, curr_dev, tmpsubj);
64537 + if (retval) {
64538 + if (checkglob && retval->globbed) {
64539 + retval2 = chk_glob_label(retval->globbed, orig_dentry, orig_mnt, path);
64540 + if (retval2)
64541 + retval = retval2;
64542 + }
64543 + break;
64544 + }
64545 + } while ((tmpsubj = tmpsubj->parent_subject));
64546 + read_unlock(&gr_inode_lock);
64547 +
64548 + return retval;
64549 +}
64550 +
64551 +static __inline__ struct acl_object_label *
64552 +full_lookup(const struct dentry *orig_dentry, const struct vfsmount *orig_mnt,
64553 + struct dentry *curr_dentry,
64554 + const struct acl_subject_label *subj, char **path, const int checkglob)
64555 +{
64556 + int newglob = checkglob;
64557 + ino_t inode;
64558 + dev_t device;
64559 +
64560 + /* if we aren't checking a subdirectory of the original path yet, don't do glob checking
64561 + as we don't want a / * rule to match instead of the / object
64562 + don't do this for create lookups that call this function though, since they're looking up
64563 + on the parent and thus need globbing checks on all paths
64564 + */
64565 + if (orig_dentry == curr_dentry && newglob != GR_CREATE_GLOB)
64566 + newglob = GR_NO_GLOB;
64567 +
64568 + spin_lock(&curr_dentry->d_lock);
64569 + inode = curr_dentry->d_inode->i_ino;
64570 + device = __get_dev(curr_dentry);
64571 + spin_unlock(&curr_dentry->d_lock);
64572 +
64573 + return __full_lookup(orig_dentry, orig_mnt, inode, device, subj, path, newglob);
64574 +}
64575 +
64576 +#ifdef CONFIG_HUGETLBFS
64577 +static inline bool
64578 +is_hugetlbfs_mnt(const struct vfsmount *mnt)
64579 +{
64580 + int i;
64581 + for (i = 0; i < HUGE_MAX_HSTATE; i++) {
64582 + if (unlikely(hugetlbfs_vfsmount[i] == mnt))
64583 + return true;
64584 + }
64585 +
64586 + return false;
64587 +}
64588 +#endif
64589 +
64590 +static struct acl_object_label *
64591 +__chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64592 + const struct acl_subject_label *subj, char *path, const int checkglob)
64593 +{
64594 + struct dentry *dentry = (struct dentry *) l_dentry;
64595 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64596 + struct mount *real_mnt = real_mount(mnt);
64597 + struct acl_object_label *retval;
64598 + struct dentry *parent;
64599 +
64600 + br_read_lock(&vfsmount_lock);
64601 + write_seqlock(&rename_lock);
64602 +
64603 + if (unlikely((mnt == shm_mnt && dentry->d_inode->i_nlink == 0) || mnt == pipe_mnt ||
64604 +#ifdef CONFIG_NET
64605 + mnt == sock_mnt ||
64606 +#endif
64607 +#ifdef CONFIG_HUGETLBFS
64608 + (is_hugetlbfs_mnt(mnt) && dentry->d_inode->i_nlink == 0) ||
64609 +#endif
64610 + /* ignore Eric Biederman */
64611 + IS_PRIVATE(l_dentry->d_inode))) {
64612 + retval = (subj->mode & GR_SHMEXEC) ? fakefs_obj_rwx : fakefs_obj_rw;
64613 + goto out;
64614 + }
64615 +
64616 + for (;;) {
64617 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
64618 + break;
64619 +
64620 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64621 + if (!mnt_has_parent(real_mnt))
64622 + break;
64623 +
64624 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64625 + if (retval != NULL)
64626 + goto out;
64627 +
64628 + dentry = real_mnt->mnt_mountpoint;
64629 + real_mnt = real_mnt->mnt_parent;
64630 + mnt = &real_mnt->mnt;
64631 + continue;
64632 + }
64633 +
64634 + parent = dentry->d_parent;
64635 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64636 + if (retval != NULL)
64637 + goto out;
64638 +
64639 + dentry = parent;
64640 + }
64641 +
64642 + retval = full_lookup(l_dentry, l_mnt, dentry, subj, &path, checkglob);
64643 +
64644 + /* gr_real_root is pinned so we don't have to hold a reference */
64645 + if (retval == NULL)
64646 + retval = full_lookup(l_dentry, l_mnt, gr_real_root.dentry, subj, &path, checkglob);
64647 +out:
64648 + write_sequnlock(&rename_lock);
64649 + br_read_unlock(&vfsmount_lock);
64650 +
64651 + BUG_ON(retval == NULL);
64652 +
64653 + return retval;
64654 +}
64655 +
64656 +static __inline__ struct acl_object_label *
64657 +chk_obj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64658 + const struct acl_subject_label *subj)
64659 +{
64660 + char *path = NULL;
64661 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_REG_GLOB);
64662 +}
64663 +
64664 +static __inline__ struct acl_object_label *
64665 +chk_obj_label_noglob(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64666 + const struct acl_subject_label *subj)
64667 +{
64668 + char *path = NULL;
64669 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_NO_GLOB);
64670 +}
64671 +
64672 +static __inline__ struct acl_object_label *
64673 +chk_obj_create_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64674 + const struct acl_subject_label *subj, char *path)
64675 +{
64676 + return __chk_obj_label(l_dentry, l_mnt, subj, path, GR_CREATE_GLOB);
64677 +}
64678 +
64679 +struct acl_subject_label *
64680 +chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt,
64681 + const struct acl_role_label *role)
64682 +{
64683 + struct dentry *dentry = (struct dentry *) l_dentry;
64684 + struct vfsmount *mnt = (struct vfsmount *) l_mnt;
64685 + struct mount *real_mnt = real_mount(mnt);
64686 + struct acl_subject_label *retval;
64687 + struct dentry *parent;
64688 +
64689 + br_read_lock(&vfsmount_lock);
64690 + write_seqlock(&rename_lock);
64691 +
64692 + for (;;) {
64693 + if (dentry == gr_real_root.dentry && mnt == gr_real_root.mnt)
64694 + break;
64695 + if (dentry == mnt->mnt_root || IS_ROOT(dentry)) {
64696 + if (!mnt_has_parent(real_mnt))
64697 + break;
64698 +
64699 + spin_lock(&dentry->d_lock);
64700 + read_lock(&gr_inode_lock);
64701 + retval =
64702 + lookup_acl_subj_label(dentry->d_inode->i_ino,
64703 + __get_dev(dentry), role);
64704 + read_unlock(&gr_inode_lock);
64705 + spin_unlock(&dentry->d_lock);
64706 + if (retval != NULL)
64707 + goto out;
64708 +
64709 + dentry = real_mnt->mnt_mountpoint;
64710 + real_mnt = real_mnt->mnt_parent;
64711 + mnt = &real_mnt->mnt;
64712 + continue;
64713 + }
64714 +
64715 + spin_lock(&dentry->d_lock);
64716 + read_lock(&gr_inode_lock);
64717 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64718 + __get_dev(dentry), role);
64719 + read_unlock(&gr_inode_lock);
64720 + parent = dentry->d_parent;
64721 + spin_unlock(&dentry->d_lock);
64722 +
64723 + if (retval != NULL)
64724 + goto out;
64725 +
64726 + dentry = parent;
64727 + }
64728 +
64729 + spin_lock(&dentry->d_lock);
64730 + read_lock(&gr_inode_lock);
64731 + retval = lookup_acl_subj_label(dentry->d_inode->i_ino,
64732 + __get_dev(dentry), role);
64733 + read_unlock(&gr_inode_lock);
64734 + spin_unlock(&dentry->d_lock);
64735 +
64736 + if (unlikely(retval == NULL)) {
64737 + /* gr_real_root is pinned, we don't need to hold a reference */
64738 + read_lock(&gr_inode_lock);
64739 + retval = lookup_acl_subj_label(gr_real_root.dentry->d_inode->i_ino,
64740 + __get_dev(gr_real_root.dentry), role);
64741 + read_unlock(&gr_inode_lock);
64742 + }
64743 +out:
64744 + write_sequnlock(&rename_lock);
64745 + br_read_unlock(&vfsmount_lock);
64746 +
64747 + BUG_ON(retval == NULL);
64748 +
64749 + return retval;
64750 +}
64751 +
64752 +void
64753 +assign_special_role(const char *rolename)
64754 +{
64755 + struct acl_object_label *obj;
64756 + struct acl_role_label *r;
64757 + struct acl_role_label *assigned = NULL;
64758 + struct task_struct *tsk;
64759 + struct file *filp;
64760 +
64761 + FOR_EACH_ROLE_START(r)
64762 + if (!strcmp(rolename, r->rolename) &&
64763 + (r->roletype & GR_ROLE_SPECIAL)) {
64764 + assigned = r;
64765 + break;
64766 + }
64767 + FOR_EACH_ROLE_END(r)
64768 +
64769 + if (!assigned)
64770 + return;
64771 +
64772 + read_lock(&tasklist_lock);
64773 + read_lock(&grsec_exec_file_lock);
64774 +
64775 + tsk = current->real_parent;
64776 + if (tsk == NULL)
64777 + goto out_unlock;
64778 +
64779 + filp = tsk->exec_file;
64780 + if (filp == NULL)
64781 + goto out_unlock;
64782 +
64783 + tsk->is_writable = 0;
64784 + tsk->inherited = 0;
64785 +
64786 + tsk->acl_sp_role = 1;
64787 + tsk->acl_role_id = ++acl_sp_role_value;
64788 + tsk->role = assigned;
64789 + tsk->acl = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role);
64790 +
64791 + /* ignore additional mmap checks for processes that are writable
64792 + by the default ACL */
64793 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
64794 + if (unlikely(obj->mode & GR_WRITE))
64795 + tsk->is_writable = 1;
64796 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, tsk->role->root_label);
64797 + if (unlikely(obj->mode & GR_WRITE))
64798 + tsk->is_writable = 1;
64799 +
64800 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64801 + printk(KERN_ALERT "Assigning special role:%s subject:%s to process (%s:%d)\n", tsk->role->rolename,
64802 + tsk->acl->filename, tsk->comm, task_pid_nr(tsk));
64803 +#endif
64804 +
64805 +out_unlock:
64806 + read_unlock(&grsec_exec_file_lock);
64807 + read_unlock(&tasklist_lock);
64808 + return;
64809 +}
64810 +
64811 +
64812 +static void
64813 +gr_log_learn(const struct dentry *dentry, const struct vfsmount *mnt, const __u32 mode)
64814 +{
64815 + struct task_struct *task = current;
64816 + const struct cred *cred = current_cred();
64817 +
64818 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename, task->role->roletype,
64819 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64820 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64821 + 1UL, 1UL, gr_to_filename(dentry, mnt), (unsigned long) mode, &task->signal->saved_ip);
64822 +
64823 + return;
64824 +}
64825 +
64826 +static void
64827 +gr_log_learn_uid_change(const kuid_t real, const kuid_t effective, const kuid_t fs)
64828 +{
64829 + struct task_struct *task = current;
64830 + const struct cred *cred = current_cred();
64831 +
64832 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64833 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64834 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64835 + 'u', GR_GLOBAL_UID(real), GR_GLOBAL_UID(effective), GR_GLOBAL_UID(fs), &task->signal->saved_ip);
64836 +
64837 + return;
64838 +}
64839 +
64840 +static void
64841 +gr_log_learn_gid_change(const kgid_t real, const kgid_t effective, const kgid_t fs)
64842 +{
64843 + struct task_struct *task = current;
64844 + const struct cred *cred = current_cred();
64845 +
64846 + security_learn(GR_ID_LEARN_MSG, task->role->rolename, task->role->roletype,
64847 + GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), task->exec_file ? gr_to_filename1(task->exec_file->f_path.dentry,
64848 + task->exec_file->f_path.mnt) : task->acl->filename, task->acl->filename,
64849 + 'g', GR_GLOBAL_GID(real), GR_GLOBAL_GID(effective), GR_GLOBAL_GID(fs), &task->signal->saved_ip);
64850 +
64851 + return;
64852 +}
64853 +
64854 +static void
64855 +gr_set_proc_res(struct task_struct *task)
64856 +{
64857 + struct acl_subject_label *proc;
64858 + unsigned short i;
64859 +
64860 + proc = task->acl;
64861 +
64862 + if (proc->mode & (GR_LEARN | GR_INHERITLEARN))
64863 + return;
64864 +
64865 + for (i = 0; i < RLIM_NLIMITS; i++) {
64866 + if (!(proc->resmask & (1U << i)))
64867 + continue;
64868 +
64869 + task->signal->rlim[i].rlim_cur = proc->res[i].rlim_cur;
64870 + task->signal->rlim[i].rlim_max = proc->res[i].rlim_max;
64871 +
64872 + if (i == RLIMIT_CPU)
64873 + update_rlimit_cpu(task, proc->res[i].rlim_cur);
64874 + }
64875 +
64876 + return;
64877 +}
64878 +
64879 +/* both of the below must be called with
64880 + rcu_read_lock();
64881 + read_lock(&tasklist_lock);
64882 + read_lock(&grsec_exec_file_lock);
64883 +*/
64884 +
64885 +struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename)
64886 +{
64887 + char *tmpname;
64888 + struct acl_subject_label *tmpsubj;
64889 + struct file *filp;
64890 + struct name_entry *nmatch;
64891 +
64892 + filp = task->exec_file;
64893 + if (filp == NULL)
64894 + return NULL;
64895 +
64896 + /* the following is to apply the correct subject
64897 + on binaries running when the RBAC system
64898 + is enabled, when the binaries have been
64899 + replaced or deleted since their execution
64900 + -----
64901 + when the RBAC system starts, the inode/dev
64902 + from exec_file will be one the RBAC system
64903 + is unaware of. It only knows the inode/dev
64904 + of the present file on disk, or the absence
64905 + of it.
64906 + */
64907 +
64908 + if (filename)
64909 + nmatch = __lookup_name_entry(state, filename);
64910 + else {
64911 + preempt_disable();
64912 + tmpname = gr_to_filename_rbac(filp->f_path.dentry, filp->f_path.mnt);
64913 +
64914 + nmatch = __lookup_name_entry(state, tmpname);
64915 + preempt_enable();
64916 + }
64917 + tmpsubj = NULL;
64918 + if (nmatch) {
64919 + if (nmatch->deleted)
64920 + tmpsubj = lookup_acl_subj_label_deleted(nmatch->inode, nmatch->device, task->role);
64921 + else
64922 + tmpsubj = lookup_acl_subj_label(nmatch->inode, nmatch->device, task->role);
64923 + }
64924 + /* this also works for the reload case -- if we don't match a potentially inherited subject
64925 + then we fall back to a normal lookup based on the binary's ino/dev
64926 + */
64927 + if (tmpsubj == NULL)
64928 + tmpsubj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, task->role);
64929 +
64930 + return tmpsubj;
64931 +}
64932 +
64933 +static struct acl_subject_label *gr_get_subject_for_task(struct task_struct *task, const char *filename)
64934 +{
64935 + return __gr_get_subject_for_task(&running_polstate, task, filename);
64936 +}
64937 +
64938 +void __gr_apply_subject_to_task(const struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj)
64939 +{
64940 + struct acl_object_label *obj;
64941 + struct file *filp;
64942 +
64943 + filp = task->exec_file;
64944 +
64945 + task->acl = subj;
64946 + task->is_writable = 0;
64947 + /* ignore additional mmap checks for processes that are writable
64948 + by the default ACL */
64949 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, state->default_role->root_label);
64950 + if (unlikely(obj->mode & GR_WRITE))
64951 + task->is_writable = 1;
64952 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
64953 + if (unlikely(obj->mode & GR_WRITE))
64954 + task->is_writable = 1;
64955 +
64956 + gr_set_proc_res(task);
64957 +
64958 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
64959 + 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);
64960 +#endif
64961 +}
64962 +
64963 +static void gr_apply_subject_to_task(struct task_struct *task, struct acl_subject_label *subj)
64964 +{
64965 + __gr_apply_subject_to_task(&running_polstate, task, subj);
64966 +}
64967 +
64968 +__u32
64969 +gr_search_file(const struct dentry * dentry, const __u32 mode,
64970 + const struct vfsmount * mnt)
64971 +{
64972 + __u32 retval = mode;
64973 + struct acl_subject_label *curracl;
64974 + struct acl_object_label *currobj;
64975 +
64976 + if (unlikely(!(gr_status & GR_READY)))
64977 + return (mode & ~GR_AUDITS);
64978 +
64979 + curracl = current->acl;
64980 +
64981 + currobj = chk_obj_label(dentry, mnt, curracl);
64982 + retval = currobj->mode & mode;
64983 +
64984 + /* if we're opening a specified transfer file for writing
64985 + (e.g. /dev/initctl), then transfer our role to init
64986 + */
64987 + if (unlikely(currobj->mode & GR_INIT_TRANSFER && retval & GR_WRITE &&
64988 + current->role->roletype & GR_ROLE_PERSIST)) {
64989 + struct task_struct *task = init_pid_ns.child_reaper;
64990 +
64991 + if (task->role != current->role) {
64992 + struct acl_subject_label *subj;
64993 +
64994 + task->acl_sp_role = 0;
64995 + task->acl_role_id = current->acl_role_id;
64996 + task->role = current->role;
64997 + rcu_read_lock();
64998 + read_lock(&grsec_exec_file_lock);
64999 + subj = gr_get_subject_for_task(task, NULL);
65000 + gr_apply_subject_to_task(task, subj);
65001 + read_unlock(&grsec_exec_file_lock);
65002 + rcu_read_unlock();
65003 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_INIT_TRANSFER_MSG);
65004 + }
65005 + }
65006 +
65007 + if (unlikely
65008 + ((curracl->mode & (GR_LEARN | GR_INHERITLEARN)) && !(mode & GR_NOPTRACE)
65009 + && (retval != (mode & ~(GR_AUDITS | GR_SUPPRESS))))) {
65010 + __u32 new_mode = mode;
65011 +
65012 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65013 +
65014 + retval = new_mode;
65015 +
65016 + if (new_mode & GR_EXEC && curracl->mode & GR_INHERITLEARN)
65017 + new_mode |= GR_INHERIT;
65018 +
65019 + if (!(mode & GR_NOLEARN))
65020 + gr_log_learn(dentry, mnt, new_mode);
65021 + }
65022 +
65023 + return retval;
65024 +}
65025 +
65026 +struct acl_object_label *gr_get_create_object(const struct dentry *new_dentry,
65027 + const struct dentry *parent,
65028 + const struct vfsmount *mnt)
65029 +{
65030 + struct name_entry *match;
65031 + struct acl_object_label *matchpo;
65032 + struct acl_subject_label *curracl;
65033 + char *path;
65034 +
65035 + if (unlikely(!(gr_status & GR_READY)))
65036 + return NULL;
65037 +
65038 + preempt_disable();
65039 + path = gr_to_filename_rbac(new_dentry, mnt);
65040 + match = lookup_name_entry_create(path);
65041 +
65042 + curracl = current->acl;
65043 +
65044 + if (match) {
65045 + read_lock(&gr_inode_lock);
65046 + matchpo = lookup_acl_obj_label_create(match->inode, match->device, curracl);
65047 + read_unlock(&gr_inode_lock);
65048 +
65049 + if (matchpo) {
65050 + preempt_enable();
65051 + return matchpo;
65052 + }
65053 + }
65054 +
65055 + // lookup parent
65056 +
65057 + matchpo = chk_obj_create_label(parent, mnt, curracl, path);
65058 +
65059 + preempt_enable();
65060 + return matchpo;
65061 +}
65062 +
65063 +__u32
65064 +gr_check_create(const struct dentry * new_dentry, const struct dentry * parent,
65065 + const struct vfsmount * mnt, const __u32 mode)
65066 +{
65067 + struct acl_object_label *matchpo;
65068 + __u32 retval;
65069 +
65070 + if (unlikely(!(gr_status & GR_READY)))
65071 + return (mode & ~GR_AUDITS);
65072 +
65073 + matchpo = gr_get_create_object(new_dentry, parent, mnt);
65074 +
65075 + retval = matchpo->mode & mode;
65076 +
65077 + if ((retval != (mode & ~(GR_AUDITS | GR_SUPPRESS)))
65078 + && (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65079 + __u32 new_mode = mode;
65080 +
65081 + new_mode &= ~(GR_AUDITS | GR_SUPPRESS);
65082 +
65083 + gr_log_learn(new_dentry, mnt, new_mode);
65084 + return new_mode;
65085 + }
65086 +
65087 + return retval;
65088 +}
65089 +
65090 +__u32
65091 +gr_check_link(const struct dentry * new_dentry,
65092 + const struct dentry * parent_dentry,
65093 + const struct vfsmount * parent_mnt,
65094 + const struct dentry * old_dentry, const struct vfsmount * old_mnt)
65095 +{
65096 + struct acl_object_label *obj;
65097 + __u32 oldmode, newmode;
65098 + __u32 needmode;
65099 + __u32 checkmodes = GR_FIND | GR_APPEND | GR_WRITE | GR_EXEC | GR_SETID | GR_READ |
65100 + GR_DELETE | GR_INHERIT;
65101 +
65102 + if (unlikely(!(gr_status & GR_READY)))
65103 + return (GR_CREATE | GR_LINK);
65104 +
65105 + obj = chk_obj_label(old_dentry, old_mnt, current->acl);
65106 + oldmode = obj->mode;
65107 +
65108 + obj = gr_get_create_object(new_dentry, parent_dentry, parent_mnt);
65109 + newmode = obj->mode;
65110 +
65111 + needmode = newmode & checkmodes;
65112 +
65113 + // old name for hardlink must have at least the permissions of the new name
65114 + if ((oldmode & needmode) != needmode)
65115 + goto bad;
65116 +
65117 + // if old name had restrictions/auditing, make sure the new name does as well
65118 + needmode = oldmode & (GR_NOPTRACE | GR_PTRACERD | GR_INHERIT | GR_AUDITS);
65119 +
65120 + // don't allow hardlinking of suid/sgid/fcapped files without permission
65121 + if (is_privileged_binary(old_dentry))
65122 + needmode |= GR_SETID;
65123 +
65124 + if ((newmode & needmode) != needmode)
65125 + goto bad;
65126 +
65127 + // enforce minimum permissions
65128 + if ((newmode & (GR_CREATE | GR_LINK)) == (GR_CREATE | GR_LINK))
65129 + return newmode;
65130 +bad:
65131 + needmode = oldmode;
65132 + if (is_privileged_binary(old_dentry))
65133 + needmode |= GR_SETID;
65134 +
65135 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN)) {
65136 + gr_log_learn(old_dentry, old_mnt, needmode | GR_CREATE | GR_LINK);
65137 + return (GR_CREATE | GR_LINK);
65138 + } else if (newmode & GR_SUPPRESS)
65139 + return GR_SUPPRESS;
65140 + else
65141 + return 0;
65142 +}
65143 +
65144 +int
65145 +gr_check_hidden_task(const struct task_struct *task)
65146 +{
65147 + if (unlikely(!(gr_status & GR_READY)))
65148 + return 0;
65149 +
65150 + if (!(task->acl->mode & GR_PROCFIND) && !(current->acl->mode & GR_VIEW))
65151 + return 1;
65152 +
65153 + return 0;
65154 +}
65155 +
65156 +int
65157 +gr_check_protected_task(const struct task_struct *task)
65158 +{
65159 + if (unlikely(!(gr_status & GR_READY) || !task))
65160 + return 0;
65161 +
65162 + if ((task->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65163 + task->acl != current->acl)
65164 + return 1;
65165 +
65166 + return 0;
65167 +}
65168 +
65169 +int
65170 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
65171 +{
65172 + struct task_struct *p;
65173 + int ret = 0;
65174 +
65175 + if (unlikely(!(gr_status & GR_READY) || !pid))
65176 + return ret;
65177 +
65178 + read_lock(&tasklist_lock);
65179 + do_each_pid_task(pid, type, p) {
65180 + if ((p->acl->mode & GR_PROTECTED) && !(current->acl->mode & GR_KILL) &&
65181 + p->acl != current->acl) {
65182 + ret = 1;
65183 + goto out;
65184 + }
65185 + } while_each_pid_task(pid, type, p);
65186 +out:
65187 + read_unlock(&tasklist_lock);
65188 +
65189 + return ret;
65190 +}
65191 +
65192 +void
65193 +gr_copy_label(struct task_struct *tsk)
65194 +{
65195 + struct task_struct *p = current;
65196 +
65197 + tsk->inherited = p->inherited;
65198 + tsk->acl_sp_role = 0;
65199 + tsk->acl_role_id = p->acl_role_id;
65200 + tsk->acl = p->acl;
65201 + tsk->role = p->role;
65202 + tsk->signal->used_accept = 0;
65203 + tsk->signal->curr_ip = p->signal->curr_ip;
65204 + tsk->signal->saved_ip = p->signal->saved_ip;
65205 + if (p->exec_file)
65206 + get_file(p->exec_file);
65207 + tsk->exec_file = p->exec_file;
65208 + tsk->is_writable = p->is_writable;
65209 + if (unlikely(p->signal->used_accept)) {
65210 + p->signal->curr_ip = 0;
65211 + p->signal->saved_ip = 0;
65212 + }
65213 +
65214 + return;
65215 +}
65216 +
65217 +extern int gr_process_kernel_setuid_ban(struct user_struct *user);
65218 +
65219 +int
65220 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
65221 +{
65222 + unsigned int i;
65223 + __u16 num;
65224 + uid_t *uidlist;
65225 + uid_t curuid;
65226 + int realok = 0;
65227 + int effectiveok = 0;
65228 + int fsok = 0;
65229 + uid_t globalreal, globaleffective, globalfs;
65230 +
65231 +#if defined(CONFIG_GRKERNSEC_KERN_LOCKOUT)
65232 + struct user_struct *user;
65233 +
65234 + if (!uid_valid(real))
65235 + goto skipit;
65236 +
65237 + /* find user based on global namespace */
65238 +
65239 + globalreal = GR_GLOBAL_UID(real);
65240 +
65241 + user = find_user(make_kuid(&init_user_ns, globalreal));
65242 + if (user == NULL)
65243 + goto skipit;
65244 +
65245 + if (gr_process_kernel_setuid_ban(user)) {
65246 + /* for find_user */
65247 + free_uid(user);
65248 + return 1;
65249 + }
65250 +
65251 + /* for find_user */
65252 + free_uid(user);
65253 +
65254 +skipit:
65255 +#endif
65256 +
65257 + if (unlikely(!(gr_status & GR_READY)))
65258 + return 0;
65259 +
65260 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65261 + gr_log_learn_uid_change(real, effective, fs);
65262 +
65263 + num = current->acl->user_trans_num;
65264 + uidlist = current->acl->user_transitions;
65265 +
65266 + if (uidlist == NULL)
65267 + return 0;
65268 +
65269 + if (!uid_valid(real)) {
65270 + realok = 1;
65271 + globalreal = (uid_t)-1;
65272 + } else {
65273 + globalreal = GR_GLOBAL_UID(real);
65274 + }
65275 + if (!uid_valid(effective)) {
65276 + effectiveok = 1;
65277 + globaleffective = (uid_t)-1;
65278 + } else {
65279 + globaleffective = GR_GLOBAL_UID(effective);
65280 + }
65281 + if (!uid_valid(fs)) {
65282 + fsok = 1;
65283 + globalfs = (uid_t)-1;
65284 + } else {
65285 + globalfs = GR_GLOBAL_UID(fs);
65286 + }
65287 +
65288 + if (current->acl->user_trans_type & GR_ID_ALLOW) {
65289 + for (i = 0; i < num; i++) {
65290 + curuid = uidlist[i];
65291 + if (globalreal == curuid)
65292 + realok = 1;
65293 + if (globaleffective == curuid)
65294 + effectiveok = 1;
65295 + if (globalfs == curuid)
65296 + fsok = 1;
65297 + }
65298 + } else if (current->acl->user_trans_type & GR_ID_DENY) {
65299 + for (i = 0; i < num; i++) {
65300 + curuid = uidlist[i];
65301 + if (globalreal == curuid)
65302 + break;
65303 + if (globaleffective == curuid)
65304 + break;
65305 + if (globalfs == curuid)
65306 + break;
65307 + }
65308 + /* not in deny list */
65309 + if (i == num) {
65310 + realok = 1;
65311 + effectiveok = 1;
65312 + fsok = 1;
65313 + }
65314 + }
65315 +
65316 + if (realok && effectiveok && fsok)
65317 + return 0;
65318 + else {
65319 + gr_log_int(GR_DONT_AUDIT, GR_USRCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65320 + return 1;
65321 + }
65322 +}
65323 +
65324 +int
65325 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
65326 +{
65327 + unsigned int i;
65328 + __u16 num;
65329 + gid_t *gidlist;
65330 + gid_t curgid;
65331 + int realok = 0;
65332 + int effectiveok = 0;
65333 + int fsok = 0;
65334 + gid_t globalreal, globaleffective, globalfs;
65335 +
65336 + if (unlikely(!(gr_status & GR_READY)))
65337 + return 0;
65338 +
65339 + if (current->acl->mode & (GR_LEARN | GR_INHERITLEARN))
65340 + gr_log_learn_gid_change(real, effective, fs);
65341 +
65342 + num = current->acl->group_trans_num;
65343 + gidlist = current->acl->group_transitions;
65344 +
65345 + if (gidlist == NULL)
65346 + return 0;
65347 +
65348 + if (!gid_valid(real)) {
65349 + realok = 1;
65350 + globalreal = (gid_t)-1;
65351 + } else {
65352 + globalreal = GR_GLOBAL_GID(real);
65353 + }
65354 + if (!gid_valid(effective)) {
65355 + effectiveok = 1;
65356 + globaleffective = (gid_t)-1;
65357 + } else {
65358 + globaleffective = GR_GLOBAL_GID(effective);
65359 + }
65360 + if (!gid_valid(fs)) {
65361 + fsok = 1;
65362 + globalfs = (gid_t)-1;
65363 + } else {
65364 + globalfs = GR_GLOBAL_GID(fs);
65365 + }
65366 +
65367 + if (current->acl->group_trans_type & GR_ID_ALLOW) {
65368 + for (i = 0; i < num; i++) {
65369 + curgid = gidlist[i];
65370 + if (globalreal == curgid)
65371 + realok = 1;
65372 + if (globaleffective == curgid)
65373 + effectiveok = 1;
65374 + if (globalfs == curgid)
65375 + fsok = 1;
65376 + }
65377 + } else if (current->acl->group_trans_type & GR_ID_DENY) {
65378 + for (i = 0; i < num; i++) {
65379 + curgid = gidlist[i];
65380 + if (globalreal == curgid)
65381 + break;
65382 + if (globaleffective == curgid)
65383 + break;
65384 + if (globalfs == curgid)
65385 + break;
65386 + }
65387 + /* not in deny list */
65388 + if (i == num) {
65389 + realok = 1;
65390 + effectiveok = 1;
65391 + fsok = 1;
65392 + }
65393 + }
65394 +
65395 + if (realok && effectiveok && fsok)
65396 + return 0;
65397 + else {
65398 + gr_log_int(GR_DONT_AUDIT, GR_GRPCHANGE_ACL_MSG, realok ? (effectiveok ? (fsok ? 0 : globalfs) : globaleffective) : globalreal);
65399 + return 1;
65400 + }
65401 +}
65402 +
65403 +extern int gr_acl_is_capable(const int cap);
65404 +
65405 +void
65406 +gr_set_role_label(struct task_struct *task, const kuid_t kuid, const kgid_t kgid)
65407 +{
65408 + struct acl_role_label *role = task->role;
65409 + struct acl_subject_label *subj = NULL;
65410 + struct acl_object_label *obj;
65411 + struct file *filp;
65412 + uid_t uid;
65413 + gid_t gid;
65414 +
65415 + if (unlikely(!(gr_status & GR_READY)))
65416 + return;
65417 +
65418 + uid = GR_GLOBAL_UID(kuid);
65419 + gid = GR_GLOBAL_GID(kgid);
65420 +
65421 + filp = task->exec_file;
65422 +
65423 + /* kernel process, we'll give them the kernel role */
65424 + if (unlikely(!filp)) {
65425 + task->role = running_polstate.kernel_role;
65426 + task->acl = running_polstate.kernel_role->root_label;
65427 + return;
65428 + } else if (!task->role || !(task->role->roletype & GR_ROLE_SPECIAL)) {
65429 + /* save the current ip at time of role lookup so that the proper
65430 + IP will be learned for role_allowed_ip */
65431 + task->signal->saved_ip = task->signal->curr_ip;
65432 + role = lookup_acl_role_label(task, uid, gid);
65433 + }
65434 +
65435 + /* don't change the role if we're not a privileged process */
65436 + if (role && task->role != role &&
65437 + (((role->roletype & GR_ROLE_USER) && !gr_acl_is_capable(CAP_SETUID)) ||
65438 + ((role->roletype & GR_ROLE_GROUP) && !gr_acl_is_capable(CAP_SETGID))))
65439 + return;
65440 +
65441 + /* perform subject lookup in possibly new role
65442 + we can use this result below in the case where role == task->role
65443 + */
65444 + subj = chk_subj_label(filp->f_path.dentry, filp->f_path.mnt, role);
65445 +
65446 + /* if we changed uid/gid, but result in the same role
65447 + and are using inheritance, don't lose the inherited subject
65448 + if current subject is other than what normal lookup
65449 + would result in, we arrived via inheritance, don't
65450 + lose subject
65451 + */
65452 + if (role != task->role || (!(task->acl->mode & GR_INHERITLEARN) &&
65453 + (subj == task->acl)))
65454 + task->acl = subj;
65455 +
65456 + /* leave task->inherited unaffected */
65457 +
65458 + task->role = role;
65459 +
65460 + task->is_writable = 0;
65461 +
65462 + /* ignore additional mmap checks for processes that are writable
65463 + by the default ACL */
65464 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
65465 + if (unlikely(obj->mode & GR_WRITE))
65466 + task->is_writable = 1;
65467 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, task->role->root_label);
65468 + if (unlikely(obj->mode & GR_WRITE))
65469 + task->is_writable = 1;
65470 +
65471 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65472 + 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);
65473 +#endif
65474 +
65475 + gr_set_proc_res(task);
65476 +
65477 + return;
65478 +}
65479 +
65480 +int
65481 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
65482 + const int unsafe_flags)
65483 +{
65484 + struct task_struct *task = current;
65485 + struct acl_subject_label *newacl;
65486 + struct acl_object_label *obj;
65487 + __u32 retmode;
65488 +
65489 + if (unlikely(!(gr_status & GR_READY)))
65490 + return 0;
65491 +
65492 + newacl = chk_subj_label(dentry, mnt, task->role);
65493 +
65494 + /* special handling for if we did an strace -f -p <pid> from an admin role, where pid then
65495 + did an exec
65496 + */
65497 + rcu_read_lock();
65498 + read_lock(&tasklist_lock);
65499 + if (task->ptrace && task->parent && ((task->parent->role->roletype & GR_ROLE_GOD) ||
65500 + (task->parent->acl->mode & GR_POVERRIDE))) {
65501 + read_unlock(&tasklist_lock);
65502 + rcu_read_unlock();
65503 + goto skip_check;
65504 + }
65505 + read_unlock(&tasklist_lock);
65506 + rcu_read_unlock();
65507 +
65508 + if (unsafe_flags && !(task->acl->mode & GR_POVERRIDE) && (task->acl != newacl) &&
65509 + !(task->role->roletype & GR_ROLE_GOD) &&
65510 + !gr_search_file(dentry, GR_PTRACERD, mnt) &&
65511 + !(task->acl->mode & (GR_LEARN | GR_INHERITLEARN))) {
65512 + if (unsafe_flags & LSM_UNSAFE_SHARE)
65513 + gr_log_fs_generic(GR_DONT_AUDIT, GR_UNSAFESHARE_EXEC_ACL_MSG, dentry, mnt);
65514 + else
65515 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_EXEC_ACL_MSG, dentry, mnt);
65516 + return -EACCES;
65517 + }
65518 +
65519 +skip_check:
65520 +
65521 + obj = chk_obj_label(dentry, mnt, task->acl);
65522 + retmode = obj->mode & (GR_INHERIT | GR_AUDIT_INHERIT);
65523 +
65524 + if (!(task->acl->mode & GR_INHERITLEARN) &&
65525 + ((newacl->mode & GR_LEARN) || !(retmode & GR_INHERIT))) {
65526 + if (obj->nested)
65527 + task->acl = obj->nested;
65528 + else
65529 + task->acl = newacl;
65530 + task->inherited = 0;
65531 + } else {
65532 + task->inherited = 1;
65533 + if (retmode & GR_INHERIT && retmode & GR_AUDIT_INHERIT)
65534 + gr_log_str_fs(GR_DO_AUDIT, GR_INHERIT_ACL_MSG, task->acl->filename, dentry, mnt);
65535 + }
65536 +
65537 + task->is_writable = 0;
65538 +
65539 + /* ignore additional mmap checks for processes that are writable
65540 + by the default ACL */
65541 + obj = chk_obj_label(dentry, mnt, running_polstate.default_role->root_label);
65542 + if (unlikely(obj->mode & GR_WRITE))
65543 + task->is_writable = 1;
65544 + obj = chk_obj_label(dentry, mnt, task->role->root_label);
65545 + if (unlikely(obj->mode & GR_WRITE))
65546 + task->is_writable = 1;
65547 +
65548 + gr_set_proc_res(task);
65549 +
65550 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
65551 + 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);
65552 +#endif
65553 + return 0;
65554 +}
65555 +
65556 +/* always called with valid inodev ptr */
65557 +static void
65558 +do_handle_delete(struct inodev_entry *inodev, const ino_t ino, const dev_t dev)
65559 +{
65560 + struct acl_object_label *matchpo;
65561 + struct acl_subject_label *matchps;
65562 + struct acl_subject_label *subj;
65563 + struct acl_role_label *role;
65564 + unsigned int x;
65565 +
65566 + FOR_EACH_ROLE_START(role)
65567 + FOR_EACH_SUBJECT_START(role, subj, x)
65568 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65569 + matchpo->mode |= GR_DELETED;
65570 + FOR_EACH_SUBJECT_END(subj,x)
65571 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65572 + /* nested subjects aren't in the role's subj_hash table */
65573 + if ((matchpo = lookup_acl_obj_label(ino, dev, subj)) != NULL)
65574 + matchpo->mode |= GR_DELETED;
65575 + FOR_EACH_NESTED_SUBJECT_END(subj)
65576 + if ((matchps = lookup_acl_subj_label(ino, dev, role)) != NULL)
65577 + matchps->mode |= GR_DELETED;
65578 + FOR_EACH_ROLE_END(role)
65579 +
65580 + inodev->nentry->deleted = 1;
65581 +
65582 + return;
65583 +}
65584 +
65585 +void
65586 +gr_handle_delete(const ino_t ino, const dev_t dev)
65587 +{
65588 + struct inodev_entry *inodev;
65589 +
65590 + if (unlikely(!(gr_status & GR_READY)))
65591 + return;
65592 +
65593 + write_lock(&gr_inode_lock);
65594 + inodev = lookup_inodev_entry(ino, dev);
65595 + if (inodev != NULL)
65596 + do_handle_delete(inodev, ino, dev);
65597 + write_unlock(&gr_inode_lock);
65598 +
65599 + return;
65600 +}
65601 +
65602 +static void
65603 +update_acl_obj_label(const ino_t oldinode, const dev_t olddevice,
65604 + const ino_t newinode, const dev_t newdevice,
65605 + struct acl_subject_label *subj)
65606 +{
65607 + unsigned int index = gr_fhash(oldinode, olddevice, subj->obj_hash_size);
65608 + struct acl_object_label *match;
65609 +
65610 + match = subj->obj_hash[index];
65611 +
65612 + while (match && (match->inode != oldinode ||
65613 + match->device != olddevice ||
65614 + !(match->mode & GR_DELETED)))
65615 + match = match->next;
65616 +
65617 + if (match && (match->inode == oldinode)
65618 + && (match->device == olddevice)
65619 + && (match->mode & GR_DELETED)) {
65620 + if (match->prev == NULL) {
65621 + subj->obj_hash[index] = match->next;
65622 + if (match->next != NULL)
65623 + match->next->prev = NULL;
65624 + } else {
65625 + match->prev->next = match->next;
65626 + if (match->next != NULL)
65627 + match->next->prev = match->prev;
65628 + }
65629 + match->prev = NULL;
65630 + match->next = NULL;
65631 + match->inode = newinode;
65632 + match->device = newdevice;
65633 + match->mode &= ~GR_DELETED;
65634 +
65635 + insert_acl_obj_label(match, subj);
65636 + }
65637 +
65638 + return;
65639 +}
65640 +
65641 +static void
65642 +update_acl_subj_label(const ino_t oldinode, const dev_t olddevice,
65643 + const ino_t newinode, const dev_t newdevice,
65644 + struct acl_role_label *role)
65645 +{
65646 + unsigned int index = gr_fhash(oldinode, olddevice, role->subj_hash_size);
65647 + struct acl_subject_label *match;
65648 +
65649 + match = role->subj_hash[index];
65650 +
65651 + while (match && (match->inode != oldinode ||
65652 + match->device != olddevice ||
65653 + !(match->mode & GR_DELETED)))
65654 + match = match->next;
65655 +
65656 + if (match && (match->inode == oldinode)
65657 + && (match->device == olddevice)
65658 + && (match->mode & GR_DELETED)) {
65659 + if (match->prev == NULL) {
65660 + role->subj_hash[index] = match->next;
65661 + if (match->next != NULL)
65662 + match->next->prev = NULL;
65663 + } else {
65664 + match->prev->next = match->next;
65665 + if (match->next != NULL)
65666 + match->next->prev = match->prev;
65667 + }
65668 + match->prev = NULL;
65669 + match->next = NULL;
65670 + match->inode = newinode;
65671 + match->device = newdevice;
65672 + match->mode &= ~GR_DELETED;
65673 +
65674 + insert_acl_subj_label(match, role);
65675 + }
65676 +
65677 + return;
65678 +}
65679 +
65680 +static void
65681 +update_inodev_entry(const ino_t oldinode, const dev_t olddevice,
65682 + const ino_t newinode, const dev_t newdevice)
65683 +{
65684 + unsigned int index = gr_fhash(oldinode, olddevice, running_polstate.inodev_set.i_size);
65685 + struct inodev_entry *match;
65686 +
65687 + match = running_polstate.inodev_set.i_hash[index];
65688 +
65689 + while (match && (match->nentry->inode != oldinode ||
65690 + match->nentry->device != olddevice || !match->nentry->deleted))
65691 + match = match->next;
65692 +
65693 + if (match && (match->nentry->inode == oldinode)
65694 + && (match->nentry->device == olddevice) &&
65695 + match->nentry->deleted) {
65696 + if (match->prev == NULL) {
65697 + running_polstate.inodev_set.i_hash[index] = match->next;
65698 + if (match->next != NULL)
65699 + match->next->prev = NULL;
65700 + } else {
65701 + match->prev->next = match->next;
65702 + if (match->next != NULL)
65703 + match->next->prev = match->prev;
65704 + }
65705 + match->prev = NULL;
65706 + match->next = NULL;
65707 + match->nentry->inode = newinode;
65708 + match->nentry->device = newdevice;
65709 + match->nentry->deleted = 0;
65710 +
65711 + insert_inodev_entry(match);
65712 + }
65713 +
65714 + return;
65715 +}
65716 +
65717 +static void
65718 +__do_handle_create(const struct name_entry *matchn, ino_t ino, dev_t dev)
65719 +{
65720 + struct acl_subject_label *subj;
65721 + struct acl_role_label *role;
65722 + unsigned int x;
65723 +
65724 + FOR_EACH_ROLE_START(role)
65725 + update_acl_subj_label(matchn->inode, matchn->device, ino, dev, role);
65726 +
65727 + FOR_EACH_NESTED_SUBJECT_START(role, subj)
65728 + if ((subj->inode == ino) && (subj->device == dev)) {
65729 + subj->inode = ino;
65730 + subj->device = dev;
65731 + }
65732 + /* nested subjects aren't in the role's subj_hash table */
65733 + update_acl_obj_label(matchn->inode, matchn->device,
65734 + ino, dev, subj);
65735 + FOR_EACH_NESTED_SUBJECT_END(subj)
65736 + FOR_EACH_SUBJECT_START(role, subj, x)
65737 + update_acl_obj_label(matchn->inode, matchn->device,
65738 + ino, dev, subj);
65739 + FOR_EACH_SUBJECT_END(subj,x)
65740 + FOR_EACH_ROLE_END(role)
65741 +
65742 + update_inodev_entry(matchn->inode, matchn->device, ino, dev);
65743 +
65744 + return;
65745 +}
65746 +
65747 +static void
65748 +do_handle_create(const struct name_entry *matchn, const struct dentry *dentry,
65749 + const struct vfsmount *mnt)
65750 +{
65751 + ino_t ino = dentry->d_inode->i_ino;
65752 + dev_t dev = __get_dev(dentry);
65753 +
65754 + __do_handle_create(matchn, ino, dev);
65755 +
65756 + return;
65757 +}
65758 +
65759 +void
65760 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
65761 +{
65762 + struct name_entry *matchn;
65763 +
65764 + if (unlikely(!(gr_status & GR_READY)))
65765 + return;
65766 +
65767 + preempt_disable();
65768 + matchn = lookup_name_entry(gr_to_filename_rbac(dentry, mnt));
65769 +
65770 + if (unlikely((unsigned long)matchn)) {
65771 + write_lock(&gr_inode_lock);
65772 + do_handle_create(matchn, dentry, mnt);
65773 + write_unlock(&gr_inode_lock);
65774 + }
65775 + preempt_enable();
65776 +
65777 + return;
65778 +}
65779 +
65780 +void
65781 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
65782 +{
65783 + struct name_entry *matchn;
65784 +
65785 + if (unlikely(!(gr_status & GR_READY)))
65786 + return;
65787 +
65788 + preempt_disable();
65789 + matchn = lookup_name_entry(gr_to_proc_filename_rbac(dentry, init_pid_ns.proc_mnt));
65790 +
65791 + if (unlikely((unsigned long)matchn)) {
65792 + write_lock(&gr_inode_lock);
65793 + __do_handle_create(matchn, inode->i_ino, inode->i_sb->s_dev);
65794 + write_unlock(&gr_inode_lock);
65795 + }
65796 + preempt_enable();
65797 +
65798 + return;
65799 +}
65800 +
65801 +void
65802 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
65803 + struct dentry *old_dentry,
65804 + struct dentry *new_dentry,
65805 + struct vfsmount *mnt, const __u8 replace)
65806 +{
65807 + struct name_entry *matchn;
65808 + struct inodev_entry *inodev;
65809 + struct inode *inode = new_dentry->d_inode;
65810 + ino_t old_ino = old_dentry->d_inode->i_ino;
65811 + dev_t old_dev = __get_dev(old_dentry);
65812 +
65813 + /* vfs_rename swaps the name and parent link for old_dentry and
65814 + new_dentry
65815 + at this point, old_dentry has the new name, parent link, and inode
65816 + for the renamed file
65817 + if a file is being replaced by a rename, new_dentry has the inode
65818 + and name for the replaced file
65819 + */
65820 +
65821 + if (unlikely(!(gr_status & GR_READY)))
65822 + return;
65823 +
65824 + preempt_disable();
65825 + matchn = lookup_name_entry(gr_to_filename_rbac(old_dentry, mnt));
65826 +
65827 + /* we wouldn't have to check d_inode if it weren't for
65828 + NFS silly-renaming
65829 + */
65830 +
65831 + write_lock(&gr_inode_lock);
65832 + if (unlikely(replace && inode)) {
65833 + ino_t new_ino = inode->i_ino;
65834 + dev_t new_dev = __get_dev(new_dentry);
65835 +
65836 + inodev = lookup_inodev_entry(new_ino, new_dev);
65837 + if (inodev != NULL && ((inode->i_nlink <= 1) || S_ISDIR(inode->i_mode)))
65838 + do_handle_delete(inodev, new_ino, new_dev);
65839 + }
65840 +
65841 + inodev = lookup_inodev_entry(old_ino, old_dev);
65842 + if (inodev != NULL && ((old_dentry->d_inode->i_nlink <= 1) || S_ISDIR(old_dentry->d_inode->i_mode)))
65843 + do_handle_delete(inodev, old_ino, old_dev);
65844 +
65845 + if (unlikely((unsigned long)matchn))
65846 + do_handle_create(matchn, old_dentry, mnt);
65847 +
65848 + write_unlock(&gr_inode_lock);
65849 + preempt_enable();
65850 +
65851 + return;
65852 +}
65853 +
65854 +#if defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC)
65855 +static const unsigned long res_learn_bumps[GR_NLIMITS] = {
65856 + [RLIMIT_CPU] = GR_RLIM_CPU_BUMP,
65857 + [RLIMIT_FSIZE] = GR_RLIM_FSIZE_BUMP,
65858 + [RLIMIT_DATA] = GR_RLIM_DATA_BUMP,
65859 + [RLIMIT_STACK] = GR_RLIM_STACK_BUMP,
65860 + [RLIMIT_CORE] = GR_RLIM_CORE_BUMP,
65861 + [RLIMIT_RSS] = GR_RLIM_RSS_BUMP,
65862 + [RLIMIT_NPROC] = GR_RLIM_NPROC_BUMP,
65863 + [RLIMIT_NOFILE] = GR_RLIM_NOFILE_BUMP,
65864 + [RLIMIT_MEMLOCK] = GR_RLIM_MEMLOCK_BUMP,
65865 + [RLIMIT_AS] = GR_RLIM_AS_BUMP,
65866 + [RLIMIT_LOCKS] = GR_RLIM_LOCKS_BUMP,
65867 + [RLIMIT_SIGPENDING] = GR_RLIM_SIGPENDING_BUMP,
65868 + [RLIMIT_MSGQUEUE] = GR_RLIM_MSGQUEUE_BUMP,
65869 + [RLIMIT_NICE] = GR_RLIM_NICE_BUMP,
65870 + [RLIMIT_RTPRIO] = GR_RLIM_RTPRIO_BUMP,
65871 + [RLIMIT_RTTIME] = GR_RLIM_RTTIME_BUMP
65872 +};
65873 +
65874 +void
65875 +gr_learn_resource(const struct task_struct *task,
65876 + const int res, const unsigned long wanted, const int gt)
65877 +{
65878 + struct acl_subject_label *acl;
65879 + const struct cred *cred;
65880 +
65881 + if (unlikely((gr_status & GR_READY) &&
65882 + task->acl && (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))))
65883 + goto skip_reslog;
65884 +
65885 + gr_log_resource(task, res, wanted, gt);
65886 +skip_reslog:
65887 +
65888 + if (unlikely(!(gr_status & GR_READY) || !wanted || res >= GR_NLIMITS))
65889 + return;
65890 +
65891 + acl = task->acl;
65892 +
65893 + if (likely(!acl || !(acl->mode & (GR_LEARN | GR_INHERITLEARN)) ||
65894 + !(acl->resmask & (1U << (unsigned short) res))))
65895 + return;
65896 +
65897 + if (wanted >= acl->res[res].rlim_cur) {
65898 + unsigned long res_add;
65899 +
65900 + res_add = wanted + res_learn_bumps[res];
65901 +
65902 + acl->res[res].rlim_cur = res_add;
65903 +
65904 + if (wanted > acl->res[res].rlim_max)
65905 + acl->res[res].rlim_max = res_add;
65906 +
65907 + /* only log the subject filename, since resource logging is supported for
65908 + single-subject learning only */
65909 + rcu_read_lock();
65910 + cred = __task_cred(task);
65911 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
65912 + task->role->roletype, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid), acl->filename,
65913 + acl->filename, acl->res[res].rlim_cur, acl->res[res].rlim_max,
65914 + "", (unsigned long) res, &task->signal->saved_ip);
65915 + rcu_read_unlock();
65916 + }
65917 +
65918 + return;
65919 +}
65920 +EXPORT_SYMBOL(gr_learn_resource);
65921 +#endif
65922 +
65923 +#if defined(CONFIG_PAX_HAVE_ACL_FLAGS) && (defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR))
65924 +void
65925 +pax_set_initial_flags(struct linux_binprm *bprm)
65926 +{
65927 + struct task_struct *task = current;
65928 + struct acl_subject_label *proc;
65929 + unsigned long flags;
65930 +
65931 + if (unlikely(!(gr_status & GR_READY)))
65932 + return;
65933 +
65934 + flags = pax_get_flags(task);
65935 +
65936 + proc = task->acl;
65937 +
65938 + if (proc->pax_flags & GR_PAX_DISABLE_PAGEEXEC)
65939 + flags &= ~MF_PAX_PAGEEXEC;
65940 + if (proc->pax_flags & GR_PAX_DISABLE_SEGMEXEC)
65941 + flags &= ~MF_PAX_SEGMEXEC;
65942 + if (proc->pax_flags & GR_PAX_DISABLE_RANDMMAP)
65943 + flags &= ~MF_PAX_RANDMMAP;
65944 + if (proc->pax_flags & GR_PAX_DISABLE_EMUTRAMP)
65945 + flags &= ~MF_PAX_EMUTRAMP;
65946 + if (proc->pax_flags & GR_PAX_DISABLE_MPROTECT)
65947 + flags &= ~MF_PAX_MPROTECT;
65948 +
65949 + if (proc->pax_flags & GR_PAX_ENABLE_PAGEEXEC)
65950 + flags |= MF_PAX_PAGEEXEC;
65951 + if (proc->pax_flags & GR_PAX_ENABLE_SEGMEXEC)
65952 + flags |= MF_PAX_SEGMEXEC;
65953 + if (proc->pax_flags & GR_PAX_ENABLE_RANDMMAP)
65954 + flags |= MF_PAX_RANDMMAP;
65955 + if (proc->pax_flags & GR_PAX_ENABLE_EMUTRAMP)
65956 + flags |= MF_PAX_EMUTRAMP;
65957 + if (proc->pax_flags & GR_PAX_ENABLE_MPROTECT)
65958 + flags |= MF_PAX_MPROTECT;
65959 +
65960 + pax_set_flags(task, flags);
65961 +
65962 + return;
65963 +}
65964 +#endif
65965 +
65966 +int
65967 +gr_handle_proc_ptrace(struct task_struct *task)
65968 +{
65969 + struct file *filp;
65970 + struct task_struct *tmp = task;
65971 + struct task_struct *curtemp = current;
65972 + __u32 retmode;
65973 +
65974 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
65975 + if (unlikely(!(gr_status & GR_READY)))
65976 + return 0;
65977 +#endif
65978 +
65979 + read_lock(&tasklist_lock);
65980 + read_lock(&grsec_exec_file_lock);
65981 + filp = task->exec_file;
65982 +
65983 + while (task_pid_nr(tmp) > 0) {
65984 + if (tmp == curtemp)
65985 + break;
65986 + tmp = tmp->real_parent;
65987 + }
65988 +
65989 + if (!filp || (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
65990 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE))))) {
65991 + read_unlock(&grsec_exec_file_lock);
65992 + read_unlock(&tasklist_lock);
65993 + return 1;
65994 + }
65995 +
65996 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
65997 + if (!(gr_status & GR_READY)) {
65998 + read_unlock(&grsec_exec_file_lock);
65999 + read_unlock(&tasklist_lock);
66000 + return 0;
66001 + }
66002 +#endif
66003 +
66004 + retmode = gr_search_file(filp->f_path.dentry, GR_NOPTRACE, filp->f_path.mnt);
66005 + read_unlock(&grsec_exec_file_lock);
66006 + read_unlock(&tasklist_lock);
66007 +
66008 + if (retmode & GR_NOPTRACE)
66009 + return 1;
66010 +
66011 + if (!(current->acl->mode & GR_POVERRIDE) && !(current->role->roletype & GR_ROLE_GOD)
66012 + && (current->acl != task->acl || (current->acl != current->role->root_label
66013 + && task_pid_nr(current) != task_pid_nr(task))))
66014 + return 1;
66015 +
66016 + return 0;
66017 +}
66018 +
66019 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p)
66020 +{
66021 + if (unlikely(!(gr_status & GR_READY)))
66022 + return;
66023 +
66024 + if (!(current->role->roletype & GR_ROLE_GOD))
66025 + return;
66026 +
66027 + seq_printf(m, "RBAC:\t%.64s:%c:%.950s\n",
66028 + p->role->rolename, gr_task_roletype_to_char(p),
66029 + p->acl->filename);
66030 +}
66031 +
66032 +int
66033 +gr_handle_ptrace(struct task_struct *task, const long request)
66034 +{
66035 + struct task_struct *tmp = task;
66036 + struct task_struct *curtemp = current;
66037 + __u32 retmode;
66038 +
66039 +#ifndef CONFIG_GRKERNSEC_HARDEN_PTRACE
66040 + if (unlikely(!(gr_status & GR_READY)))
66041 + return 0;
66042 +#endif
66043 + if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
66044 + read_lock(&tasklist_lock);
66045 + while (task_pid_nr(tmp) > 0) {
66046 + if (tmp == curtemp)
66047 + break;
66048 + tmp = tmp->real_parent;
66049 + }
66050 +
66051 + if (task_pid_nr(tmp) == 0 && ((grsec_enable_harden_ptrace && gr_is_global_nonroot(current_uid()) && !(gr_status & GR_READY)) ||
66052 + ((gr_status & GR_READY) && !(current->acl->mode & GR_RELAXPTRACE)))) {
66053 + read_unlock(&tasklist_lock);
66054 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66055 + return 1;
66056 + }
66057 + read_unlock(&tasklist_lock);
66058 + }
66059 +
66060 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
66061 + if (!(gr_status & GR_READY))
66062 + return 0;
66063 +#endif
66064 +
66065 + read_lock(&grsec_exec_file_lock);
66066 + if (unlikely(!task->exec_file)) {
66067 + read_unlock(&grsec_exec_file_lock);
66068 + return 0;
66069 + }
66070 +
66071 + retmode = gr_search_file(task->exec_file->f_path.dentry, GR_PTRACERD | GR_NOPTRACE, task->exec_file->f_path.mnt);
66072 + read_unlock(&grsec_exec_file_lock);
66073 +
66074 + if (retmode & GR_NOPTRACE) {
66075 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66076 + return 1;
66077 + }
66078 +
66079 + if (retmode & GR_PTRACERD) {
66080 + switch (request) {
66081 + case PTRACE_SEIZE:
66082 + case PTRACE_POKETEXT:
66083 + case PTRACE_POKEDATA:
66084 + case PTRACE_POKEUSR:
66085 +#if !defined(CONFIG_PPC32) && !defined(CONFIG_PPC64) && !defined(CONFIG_PARISC) && !defined(CONFIG_ALPHA) && !defined(CONFIG_IA64)
66086 + case PTRACE_SETREGS:
66087 + case PTRACE_SETFPREGS:
66088 +#endif
66089 +#ifdef CONFIG_X86
66090 + case PTRACE_SETFPXREGS:
66091 +#endif
66092 +#ifdef CONFIG_ALTIVEC
66093 + case PTRACE_SETVRREGS:
66094 +#endif
66095 + return 1;
66096 + default:
66097 + return 0;
66098 + }
66099 + } else if (!(current->acl->mode & GR_POVERRIDE) &&
66100 + !(current->role->roletype & GR_ROLE_GOD) &&
66101 + (current->acl != task->acl)) {
66102 + gr_log_ptrace(GR_DONT_AUDIT, GR_PTRACE_ACL_MSG, task);
66103 + return 1;
66104 + }
66105 +
66106 + return 0;
66107 +}
66108 +
66109 +static int is_writable_mmap(const struct file *filp)
66110 +{
66111 + struct task_struct *task = current;
66112 + struct acl_object_label *obj, *obj2;
66113 +
66114 + if (gr_status & GR_READY && !(task->acl->mode & GR_OVERRIDE) &&
66115 + !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))) {
66116 + obj = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt, running_polstate.default_role->root_label);
66117 + obj2 = chk_obj_label(filp->f_path.dentry, filp->f_path.mnt,
66118 + task->role->root_label);
66119 + if (unlikely((obj->mode & GR_WRITE) || (obj2->mode & GR_WRITE))) {
66120 + gr_log_fs_generic(GR_DONT_AUDIT, GR_WRITLIB_ACL_MSG, filp->f_path.dentry, filp->f_path.mnt);
66121 + return 1;
66122 + }
66123 + }
66124 + return 0;
66125 +}
66126 +
66127 +int
66128 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot)
66129 +{
66130 + __u32 mode;
66131 +
66132 + if (unlikely(!file || !(prot & PROT_EXEC)))
66133 + return 1;
66134 +
66135 + if (is_writable_mmap(file))
66136 + return 0;
66137 +
66138 + mode =
66139 + gr_search_file(file->f_path.dentry,
66140 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66141 + file->f_path.mnt);
66142 +
66143 + if (!gr_tpe_allow(file))
66144 + return 0;
66145 +
66146 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66147 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66148 + return 0;
66149 + } else if (unlikely(!(mode & GR_EXEC))) {
66150 + return 0;
66151 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66152 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MMAP_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66153 + return 1;
66154 + }
66155 +
66156 + return 1;
66157 +}
66158 +
66159 +int
66160 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
66161 +{
66162 + __u32 mode;
66163 +
66164 + if (unlikely(!file || !(prot & PROT_EXEC)))
66165 + return 1;
66166 +
66167 + if (is_writable_mmap(file))
66168 + return 0;
66169 +
66170 + mode =
66171 + gr_search_file(file->f_path.dentry,
66172 + GR_EXEC | GR_AUDIT_EXEC | GR_SUPPRESS,
66173 + file->f_path.mnt);
66174 +
66175 + if (!gr_tpe_allow(file))
66176 + return 0;
66177 +
66178 + if (unlikely(!(mode & GR_EXEC) && !(mode & GR_SUPPRESS))) {
66179 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66180 + return 0;
66181 + } else if (unlikely(!(mode & GR_EXEC))) {
66182 + return 0;
66183 + } else if (unlikely(mode & GR_EXEC && mode & GR_AUDIT_EXEC)) {
66184 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_MPROTECT_ACL_MSG, file->f_path.dentry, file->f_path.mnt);
66185 + return 1;
66186 + }
66187 +
66188 + return 1;
66189 +}
66190 +
66191 +void
66192 +gr_acl_handle_psacct(struct task_struct *task, const long code)
66193 +{
66194 + unsigned long runtime;
66195 + unsigned long cputime;
66196 + unsigned int wday, cday;
66197 + __u8 whr, chr;
66198 + __u8 wmin, cmin;
66199 + __u8 wsec, csec;
66200 + struct timespec timeval;
66201 +
66202 + if (unlikely(!(gr_status & GR_READY) || !task->acl ||
66203 + !(task->acl->mode & GR_PROCACCT)))
66204 + return;
66205 +
66206 + do_posix_clock_monotonic_gettime(&timeval);
66207 + runtime = timeval.tv_sec - task->start_time.tv_sec;
66208 + wday = runtime / (3600 * 24);
66209 + runtime -= wday * (3600 * 24);
66210 + whr = runtime / 3600;
66211 + runtime -= whr * 3600;
66212 + wmin = runtime / 60;
66213 + runtime -= wmin * 60;
66214 + wsec = runtime;
66215 +
66216 + cputime = (task->utime + task->stime) / HZ;
66217 + cday = cputime / (3600 * 24);
66218 + cputime -= cday * (3600 * 24);
66219 + chr = cputime / 3600;
66220 + cputime -= chr * 3600;
66221 + cmin = cputime / 60;
66222 + cputime -= cmin * 60;
66223 + csec = cputime;
66224 +
66225 + gr_log_procacct(GR_DO_AUDIT, GR_ACL_PROCACCT_MSG, task, wday, whr, wmin, wsec, cday, chr, cmin, csec, code);
66226 +
66227 + return;
66228 +}
66229 +
66230 +#ifdef CONFIG_TASKSTATS
66231 +int gr_is_taskstats_denied(int pid)
66232 +{
66233 + struct task_struct *task;
66234 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66235 + const struct cred *cred;
66236 +#endif
66237 + int ret = 0;
66238 +
66239 + /* restrict taskstats viewing to un-chrooted root users
66240 + who have the 'view' subject flag if the RBAC system is enabled
66241 + */
66242 +
66243 + rcu_read_lock();
66244 + read_lock(&tasklist_lock);
66245 + task = find_task_by_vpid(pid);
66246 + if (task) {
66247 +#ifdef CONFIG_GRKERNSEC_CHROOT
66248 + if (proc_is_chrooted(task))
66249 + ret = -EACCES;
66250 +#endif
66251 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66252 + cred = __task_cred(task);
66253 +#ifdef CONFIG_GRKERNSEC_PROC_USER
66254 + if (gr_is_global_nonroot(cred->uid))
66255 + ret = -EACCES;
66256 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
66257 + if (gr_is_global_nonroot(cred->uid) && !groups_search(cred->group_info, grsec_proc_gid))
66258 + ret = -EACCES;
66259 +#endif
66260 +#endif
66261 + if (gr_status & GR_READY) {
66262 + if (!(task->acl->mode & GR_VIEW))
66263 + ret = -EACCES;
66264 + }
66265 + } else
66266 + ret = -ENOENT;
66267 +
66268 + read_unlock(&tasklist_lock);
66269 + rcu_read_unlock();
66270 +
66271 + return ret;
66272 +}
66273 +#endif
66274 +
66275 +/* AUXV entries are filled via a descendant of search_binary_handler
66276 + after we've already applied the subject for the target
66277 +*/
66278 +int gr_acl_enable_at_secure(void)
66279 +{
66280 + if (unlikely(!(gr_status & GR_READY)))
66281 + return 0;
66282 +
66283 + if (current->acl->mode & GR_ATSECURE)
66284 + return 1;
66285 +
66286 + return 0;
66287 +}
66288 +
66289 +int gr_acl_handle_filldir(const struct file *file, const char *name, const unsigned int namelen, const ino_t ino)
66290 +{
66291 + struct task_struct *task = current;
66292 + struct dentry *dentry = file->f_path.dentry;
66293 + struct vfsmount *mnt = file->f_path.mnt;
66294 + struct acl_object_label *obj, *tmp;
66295 + struct acl_subject_label *subj;
66296 + unsigned int bufsize;
66297 + int is_not_root;
66298 + char *path;
66299 + dev_t dev = __get_dev(dentry);
66300 +
66301 + if (unlikely(!(gr_status & GR_READY)))
66302 + return 1;
66303 +
66304 + if (task->acl->mode & (GR_LEARN | GR_INHERITLEARN))
66305 + return 1;
66306 +
66307 + /* ignore Eric Biederman */
66308 + if (IS_PRIVATE(dentry->d_inode))
66309 + return 1;
66310 +
66311 + subj = task->acl;
66312 + read_lock(&gr_inode_lock);
66313 + do {
66314 + obj = lookup_acl_obj_label(ino, dev, subj);
66315 + if (obj != NULL) {
66316 + read_unlock(&gr_inode_lock);
66317 + return (obj->mode & GR_FIND) ? 1 : 0;
66318 + }
66319 + } while ((subj = subj->parent_subject));
66320 + read_unlock(&gr_inode_lock);
66321 +
66322 + /* this is purely an optimization since we're looking for an object
66323 + for the directory we're doing a readdir on
66324 + if it's possible for any globbed object to match the entry we're
66325 + filling into the directory, then the object we find here will be
66326 + an anchor point with attached globbed objects
66327 + */
66328 + obj = chk_obj_label_noglob(dentry, mnt, task->acl);
66329 + if (obj->globbed == NULL)
66330 + return (obj->mode & GR_FIND) ? 1 : 0;
66331 +
66332 + is_not_root = ((obj->filename[0] == '/') &&
66333 + (obj->filename[1] == '\0')) ? 0 : 1;
66334 + bufsize = PAGE_SIZE - namelen - is_not_root;
66335 +
66336 + /* check bufsize > PAGE_SIZE || bufsize == 0 */
66337 + if (unlikely((bufsize - 1) > (PAGE_SIZE - 1)))
66338 + return 1;
66339 +
66340 + preempt_disable();
66341 + path = d_real_path(dentry, mnt, per_cpu_ptr(gr_shared_page[0], smp_processor_id()),
66342 + bufsize);
66343 +
66344 + bufsize = strlen(path);
66345 +
66346 + /* if base is "/", don't append an additional slash */
66347 + if (is_not_root)
66348 + *(path + bufsize) = '/';
66349 + memcpy(path + bufsize + is_not_root, name, namelen);
66350 + *(path + bufsize + namelen + is_not_root) = '\0';
66351 +
66352 + tmp = obj->globbed;
66353 + while (tmp) {
66354 + if (!glob_match(tmp->filename, path)) {
66355 + preempt_enable();
66356 + return (tmp->mode & GR_FIND) ? 1 : 0;
66357 + }
66358 + tmp = tmp->next;
66359 + }
66360 + preempt_enable();
66361 + return (obj->mode & GR_FIND) ? 1 : 0;
66362 +}
66363 +
66364 +void gr_put_exec_file(struct task_struct *task)
66365 +{
66366 + struct file *filp;
66367 +
66368 + write_lock(&grsec_exec_file_lock);
66369 + filp = task->exec_file;
66370 + task->exec_file = NULL;
66371 + write_unlock(&grsec_exec_file_lock);
66372 +
66373 + if (filp)
66374 + fput(filp);
66375 +
66376 + return;
66377 +}
66378 +
66379 +
66380 +#ifdef CONFIG_NETFILTER_XT_MATCH_GRADM_MODULE
66381 +EXPORT_SYMBOL(gr_acl_is_enabled);
66382 +#endif
66383 +#ifdef CONFIG_SECURITY
66384 +EXPORT_SYMBOL(gr_check_user_change);
66385 +EXPORT_SYMBOL(gr_check_group_change);
66386 +#endif
66387 +
66388 diff --git a/grsecurity/gracl_alloc.c b/grsecurity/gracl_alloc.c
66389 new file mode 100644
66390 index 0000000..18ffbbd
66391 --- /dev/null
66392 +++ b/grsecurity/gracl_alloc.c
66393 @@ -0,0 +1,105 @@
66394 +#include <linux/kernel.h>
66395 +#include <linux/mm.h>
66396 +#include <linux/slab.h>
66397 +#include <linux/vmalloc.h>
66398 +#include <linux/gracl.h>
66399 +#include <linux/grsecurity.h>
66400 +
66401 +static struct gr_alloc_state __current_alloc_state = { 1, 1, NULL };
66402 +struct gr_alloc_state *current_alloc_state = &__current_alloc_state;
66403 +
66404 +static __inline__ int
66405 +alloc_pop(void)
66406 +{
66407 + if (current_alloc_state->alloc_stack_next == 1)
66408 + return 0;
66409 +
66410 + kfree(current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 2]);
66411 +
66412 + current_alloc_state->alloc_stack_next--;
66413 +
66414 + return 1;
66415 +}
66416 +
66417 +static __inline__ int
66418 +alloc_push(void *buf)
66419 +{
66420 + if (current_alloc_state->alloc_stack_next >= current_alloc_state->alloc_stack_size)
66421 + return 1;
66422 +
66423 + current_alloc_state->alloc_stack[current_alloc_state->alloc_stack_next - 1] = buf;
66424 +
66425 + current_alloc_state->alloc_stack_next++;
66426 +
66427 + return 0;
66428 +}
66429 +
66430 +void *
66431 +acl_alloc(unsigned long len)
66432 +{
66433 + void *ret = NULL;
66434 +
66435 + if (!len || len > PAGE_SIZE)
66436 + goto out;
66437 +
66438 + ret = kmalloc(len, GFP_KERNEL);
66439 +
66440 + if (ret) {
66441 + if (alloc_push(ret)) {
66442 + kfree(ret);
66443 + ret = NULL;
66444 + }
66445 + }
66446 +
66447 +out:
66448 + return ret;
66449 +}
66450 +
66451 +void *
66452 +acl_alloc_num(unsigned long num, unsigned long len)
66453 +{
66454 + if (!len || (num > (PAGE_SIZE / len)))
66455 + return NULL;
66456 +
66457 + return acl_alloc(num * len);
66458 +}
66459 +
66460 +void
66461 +acl_free_all(void)
66462 +{
66463 + if (!current_alloc_state->alloc_stack)
66464 + return;
66465 +
66466 + while (alloc_pop()) ;
66467 +
66468 + if (current_alloc_state->alloc_stack) {
66469 + if ((current_alloc_state->alloc_stack_size * sizeof (void *)) <= PAGE_SIZE)
66470 + kfree(current_alloc_state->alloc_stack);
66471 + else
66472 + vfree(current_alloc_state->alloc_stack);
66473 + }
66474 +
66475 + current_alloc_state->alloc_stack = NULL;
66476 + current_alloc_state->alloc_stack_size = 1;
66477 + current_alloc_state->alloc_stack_next = 1;
66478 +
66479 + return;
66480 +}
66481 +
66482 +int
66483 +acl_alloc_stack_init(unsigned long size)
66484 +{
66485 + if ((size * sizeof (void *)) <= PAGE_SIZE)
66486 + current_alloc_state->alloc_stack =
66487 + (void **) kmalloc(size * sizeof (void *), GFP_KERNEL);
66488 + else
66489 + current_alloc_state->alloc_stack = (void **) vmalloc(size * sizeof (void *));
66490 +
66491 + current_alloc_state->alloc_stack_size = size;
66492 + current_alloc_state->alloc_stack_next = 1;
66493 +
66494 + if (!current_alloc_state->alloc_stack)
66495 + return 0;
66496 + else
66497 + return 1;
66498 +}
66499 diff --git a/grsecurity/gracl_cap.c b/grsecurity/gracl_cap.c
66500 new file mode 100644
66501 index 0000000..bdd51ea
66502 --- /dev/null
66503 +++ b/grsecurity/gracl_cap.c
66504 @@ -0,0 +1,110 @@
66505 +#include <linux/kernel.h>
66506 +#include <linux/module.h>
66507 +#include <linux/sched.h>
66508 +#include <linux/gracl.h>
66509 +#include <linux/grsecurity.h>
66510 +#include <linux/grinternal.h>
66511 +
66512 +extern const char *captab_log[];
66513 +extern int captab_log_entries;
66514 +
66515 +int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
66516 +{
66517 + struct acl_subject_label *curracl;
66518 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66519 + kernel_cap_t cap_audit = __cap_empty_set;
66520 +
66521 + if (!gr_acl_is_enabled())
66522 + return 1;
66523 +
66524 + curracl = task->acl;
66525 +
66526 + cap_drop = curracl->cap_lower;
66527 + cap_mask = curracl->cap_mask;
66528 + cap_audit = curracl->cap_invert_audit;
66529 +
66530 + while ((curracl = curracl->parent_subject)) {
66531 + /* if the cap isn't specified in the current computed mask but is specified in the
66532 + current level subject, and is lowered in the current level subject, then add
66533 + it to the set of dropped capabilities
66534 + otherwise, add the current level subject's mask to the current computed mask
66535 + */
66536 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66537 + cap_raise(cap_mask, cap);
66538 + if (cap_raised(curracl->cap_lower, cap))
66539 + cap_raise(cap_drop, cap);
66540 + if (cap_raised(curracl->cap_invert_audit, cap))
66541 + cap_raise(cap_audit, cap);
66542 + }
66543 + }
66544 +
66545 + if (!cap_raised(cap_drop, cap)) {
66546 + if (cap_raised(cap_audit, cap))
66547 + gr_log_cap(GR_DO_AUDIT, GR_CAP_ACL_MSG2, task, captab_log[cap]);
66548 + return 1;
66549 + }
66550 +
66551 + curracl = task->acl;
66552 +
66553 + if ((curracl->mode & (GR_LEARN | GR_INHERITLEARN))
66554 + && cap_raised(cred->cap_effective, cap)) {
66555 + security_learn(GR_LEARN_AUDIT_MSG, task->role->rolename,
66556 + task->role->roletype, GR_GLOBAL_UID(cred->uid),
66557 + GR_GLOBAL_GID(cred->gid), task->exec_file ?
66558 + gr_to_filename(task->exec_file->f_path.dentry,
66559 + task->exec_file->f_path.mnt) : curracl->filename,
66560 + curracl->filename, 0UL,
66561 + 0UL, "", (unsigned long) cap, &task->signal->saved_ip);
66562 + return 1;
66563 + }
66564 +
66565 + if ((cap >= 0) && (cap < captab_log_entries) && cap_raised(cred->cap_effective, cap) && !cap_raised(cap_audit, cap))
66566 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_ACL_MSG, task, captab_log[cap]);
66567 +
66568 + return 0;
66569 +}
66570 +
66571 +int
66572 +gr_acl_is_capable(const int cap)
66573 +{
66574 + return gr_task_acl_is_capable(current, current_cred(), cap);
66575 +}
66576 +
66577 +int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap)
66578 +{
66579 + struct acl_subject_label *curracl;
66580 + kernel_cap_t cap_drop = __cap_empty_set, cap_mask = __cap_empty_set;
66581 +
66582 + if (!gr_acl_is_enabled())
66583 + return 1;
66584 +
66585 + curracl = task->acl;
66586 +
66587 + cap_drop = curracl->cap_lower;
66588 + cap_mask = curracl->cap_mask;
66589 +
66590 + while ((curracl = curracl->parent_subject)) {
66591 + /* if the cap isn't specified in the current computed mask but is specified in the
66592 + current level subject, and is lowered in the current level subject, then add
66593 + it to the set of dropped capabilities
66594 + otherwise, add the current level subject's mask to the current computed mask
66595 + */
66596 + if (!cap_raised(cap_mask, cap) && cap_raised(curracl->cap_mask, cap)) {
66597 + cap_raise(cap_mask, cap);
66598 + if (cap_raised(curracl->cap_lower, cap))
66599 + cap_raise(cap_drop, cap);
66600 + }
66601 + }
66602 +
66603 + if (!cap_raised(cap_drop, cap))
66604 + return 1;
66605 +
66606 + return 0;
66607 +}
66608 +
66609 +int
66610 +gr_acl_is_capable_nolog(const int cap)
66611 +{
66612 + return gr_task_acl_is_capable_nolog(current, cap);
66613 +}
66614 +
66615 diff --git a/grsecurity/gracl_compat.c b/grsecurity/gracl_compat.c
66616 new file mode 100644
66617 index 0000000..ca25605
66618 --- /dev/null
66619 +++ b/grsecurity/gracl_compat.c
66620 @@ -0,0 +1,270 @@
66621 +#include <linux/kernel.h>
66622 +#include <linux/gracl.h>
66623 +#include <linux/compat.h>
66624 +#include <linux/gracl_compat.h>
66625 +
66626 +#include <asm/uaccess.h>
66627 +
66628 +int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap)
66629 +{
66630 + struct gr_arg_wrapper_compat uwrapcompat;
66631 +
66632 + if (copy_from_user(&uwrapcompat, buf, sizeof(uwrapcompat)))
66633 + return -EFAULT;
66634 +
66635 + if (((uwrapcompat.version != GRSECURITY_VERSION) &&
66636 + (uwrapcompat.version != 0x2901)) ||
66637 + (uwrapcompat.size != sizeof(struct gr_arg_compat)))
66638 + return -EINVAL;
66639 +
66640 + uwrap->arg = compat_ptr(uwrapcompat.arg);
66641 + uwrap->version = uwrapcompat.version;
66642 + uwrap->size = sizeof(struct gr_arg);
66643 +
66644 + return 0;
66645 +}
66646 +
66647 +int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg)
66648 +{
66649 + struct gr_arg_compat argcompat;
66650 +
66651 + if (copy_from_user(&argcompat, buf, sizeof(argcompat)))
66652 + return -EFAULT;
66653 +
66654 + arg->role_db.r_table = compat_ptr(argcompat.role_db.r_table);
66655 + arg->role_db.num_pointers = argcompat.role_db.num_pointers;
66656 + arg->role_db.num_roles = argcompat.role_db.num_roles;
66657 + arg->role_db.num_domain_children = argcompat.role_db.num_domain_children;
66658 + arg->role_db.num_subjects = argcompat.role_db.num_subjects;
66659 + arg->role_db.num_objects = argcompat.role_db.num_objects;
66660 +
66661 + memcpy(&arg->pw, &argcompat.pw, sizeof(arg->pw));
66662 + memcpy(&arg->salt, &argcompat.salt, sizeof(arg->salt));
66663 + memcpy(&arg->sum, &argcompat.sum, sizeof(arg->sum));
66664 + memcpy(&arg->sp_role, &argcompat.sp_role, sizeof(arg->sp_role));
66665 + arg->sprole_pws = compat_ptr(argcompat.sprole_pws);
66666 + arg->segv_device = argcompat.segv_device;
66667 + arg->segv_inode = argcompat.segv_inode;
66668 + arg->segv_uid = argcompat.segv_uid;
66669 + arg->num_sprole_pws = argcompat.num_sprole_pws;
66670 + arg->mode = argcompat.mode;
66671 +
66672 + return 0;
66673 +}
66674 +
66675 +int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp)
66676 +{
66677 + struct acl_object_label_compat objcompat;
66678 +
66679 + if (copy_from_user(&objcompat, userp, sizeof(objcompat)))
66680 + return -EFAULT;
66681 +
66682 + obj->filename = compat_ptr(objcompat.filename);
66683 + obj->inode = objcompat.inode;
66684 + obj->device = objcompat.device;
66685 + obj->mode = objcompat.mode;
66686 +
66687 + obj->nested = compat_ptr(objcompat.nested);
66688 + obj->globbed = compat_ptr(objcompat.globbed);
66689 +
66690 + obj->prev = compat_ptr(objcompat.prev);
66691 + obj->next = compat_ptr(objcompat.next);
66692 +
66693 + return 0;
66694 +}
66695 +
66696 +int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp)
66697 +{
66698 + unsigned int i;
66699 + struct acl_subject_label_compat subjcompat;
66700 +
66701 + if (copy_from_user(&subjcompat, userp, sizeof(subjcompat)))
66702 + return -EFAULT;
66703 +
66704 + subj->filename = compat_ptr(subjcompat.filename);
66705 + subj->inode = subjcompat.inode;
66706 + subj->device = subjcompat.device;
66707 + subj->mode = subjcompat.mode;
66708 + subj->cap_mask = subjcompat.cap_mask;
66709 + subj->cap_lower = subjcompat.cap_lower;
66710 + subj->cap_invert_audit = subjcompat.cap_invert_audit;
66711 +
66712 + for (i = 0; i < GR_NLIMITS; i++) {
66713 + if (subjcompat.res[i].rlim_cur == COMPAT_RLIM_INFINITY)
66714 + subj->res[i].rlim_cur = RLIM_INFINITY;
66715 + else
66716 + subj->res[i].rlim_cur = subjcompat.res[i].rlim_cur;
66717 + if (subjcompat.res[i].rlim_max == COMPAT_RLIM_INFINITY)
66718 + subj->res[i].rlim_max = RLIM_INFINITY;
66719 + else
66720 + subj->res[i].rlim_max = subjcompat.res[i].rlim_max;
66721 + }
66722 + subj->resmask = subjcompat.resmask;
66723 +
66724 + subj->user_trans_type = subjcompat.user_trans_type;
66725 + subj->group_trans_type = subjcompat.group_trans_type;
66726 + subj->user_transitions = compat_ptr(subjcompat.user_transitions);
66727 + subj->group_transitions = compat_ptr(subjcompat.group_transitions);
66728 + subj->user_trans_num = subjcompat.user_trans_num;
66729 + subj->group_trans_num = subjcompat.group_trans_num;
66730 +
66731 + memcpy(&subj->sock_families, &subjcompat.sock_families, sizeof(subj->sock_families));
66732 + memcpy(&subj->ip_proto, &subjcompat.ip_proto, sizeof(subj->ip_proto));
66733 + subj->ip_type = subjcompat.ip_type;
66734 + subj->ips = compat_ptr(subjcompat.ips);
66735 + subj->ip_num = subjcompat.ip_num;
66736 + subj->inaddr_any_override = subjcompat.inaddr_any_override;
66737 +
66738 + subj->crashes = subjcompat.crashes;
66739 + subj->expires = subjcompat.expires;
66740 +
66741 + subj->parent_subject = compat_ptr(subjcompat.parent_subject);
66742 + subj->hash = compat_ptr(subjcompat.hash);
66743 + subj->prev = compat_ptr(subjcompat.prev);
66744 + subj->next = compat_ptr(subjcompat.next);
66745 +
66746 + subj->obj_hash = compat_ptr(subjcompat.obj_hash);
66747 + subj->obj_hash_size = subjcompat.obj_hash_size;
66748 + subj->pax_flags = subjcompat.pax_flags;
66749 +
66750 + return 0;
66751 +}
66752 +
66753 +int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp)
66754 +{
66755 + struct acl_role_label_compat rolecompat;
66756 +
66757 + if (copy_from_user(&rolecompat, userp, sizeof(rolecompat)))
66758 + return -EFAULT;
66759 +
66760 + role->rolename = compat_ptr(rolecompat.rolename);
66761 + role->uidgid = rolecompat.uidgid;
66762 + role->roletype = rolecompat.roletype;
66763 +
66764 + role->auth_attempts = rolecompat.auth_attempts;
66765 + role->expires = rolecompat.expires;
66766 +
66767 + role->root_label = compat_ptr(rolecompat.root_label);
66768 + role->hash = compat_ptr(rolecompat.hash);
66769 +
66770 + role->prev = compat_ptr(rolecompat.prev);
66771 + role->next = compat_ptr(rolecompat.next);
66772 +
66773 + role->transitions = compat_ptr(rolecompat.transitions);
66774 + role->allowed_ips = compat_ptr(rolecompat.allowed_ips);
66775 + role->domain_children = compat_ptr(rolecompat.domain_children);
66776 + role->domain_child_num = rolecompat.domain_child_num;
66777 +
66778 + role->umask = rolecompat.umask;
66779 +
66780 + role->subj_hash = compat_ptr(rolecompat.subj_hash);
66781 + role->subj_hash_size = rolecompat.subj_hash_size;
66782 +
66783 + return 0;
66784 +}
66785 +
66786 +int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
66787 +{
66788 + struct role_allowed_ip_compat roleip_compat;
66789 +
66790 + if (copy_from_user(&roleip_compat, userp, sizeof(roleip_compat)))
66791 + return -EFAULT;
66792 +
66793 + roleip->addr = roleip_compat.addr;
66794 + roleip->netmask = roleip_compat.netmask;
66795 +
66796 + roleip->prev = compat_ptr(roleip_compat.prev);
66797 + roleip->next = compat_ptr(roleip_compat.next);
66798 +
66799 + return 0;
66800 +}
66801 +
66802 +int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp)
66803 +{
66804 + struct role_transition_compat trans_compat;
66805 +
66806 + if (copy_from_user(&trans_compat, userp, sizeof(trans_compat)))
66807 + return -EFAULT;
66808 +
66809 + trans->rolename = compat_ptr(trans_compat.rolename);
66810 +
66811 + trans->prev = compat_ptr(trans_compat.prev);
66812 + trans->next = compat_ptr(trans_compat.next);
66813 +
66814 + return 0;
66815 +
66816 +}
66817 +
66818 +int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
66819 +{
66820 + struct gr_hash_struct_compat hash_compat;
66821 +
66822 + if (copy_from_user(&hash_compat, userp, sizeof(hash_compat)))
66823 + return -EFAULT;
66824 +
66825 + hash->table = compat_ptr(hash_compat.table);
66826 + hash->nametable = compat_ptr(hash_compat.nametable);
66827 + hash->first = compat_ptr(hash_compat.first);
66828 +
66829 + hash->table_size = hash_compat.table_size;
66830 + hash->used_size = hash_compat.used_size;
66831 +
66832 + hash->type = hash_compat.type;
66833 +
66834 + return 0;
66835 +}
66836 +
66837 +int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp)
66838 +{
66839 + compat_uptr_t ptrcompat;
66840 +
66841 + if (copy_from_user(&ptrcompat, userp + (idx * sizeof(ptrcompat)), sizeof(ptrcompat)))
66842 + return -EFAULT;
66843 +
66844 + *(void **)ptr = compat_ptr(ptrcompat);
66845 +
66846 + return 0;
66847 +}
66848 +
66849 +int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp)
66850 +{
66851 + struct acl_ip_label_compat ip_compat;
66852 +
66853 + if (copy_from_user(&ip_compat, userp, sizeof(ip_compat)))
66854 + return -EFAULT;
66855 +
66856 + ip->iface = compat_ptr(ip_compat.iface);
66857 + ip->addr = ip_compat.addr;
66858 + ip->netmask = ip_compat.netmask;
66859 + ip->low = ip_compat.low;
66860 + ip->high = ip_compat.high;
66861 + ip->mode = ip_compat.mode;
66862 + ip->type = ip_compat.type;
66863 +
66864 + memcpy(&ip->proto, &ip_compat.proto, sizeof(ip->proto));
66865 +
66866 + ip->prev = compat_ptr(ip_compat.prev);
66867 + ip->next = compat_ptr(ip_compat.next);
66868 +
66869 + return 0;
66870 +}
66871 +
66872 +int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
66873 +{
66874 + struct sprole_pw_compat pw_compat;
66875 +
66876 + if (copy_from_user(&pw_compat, (const void *)userp + (sizeof(pw_compat) * idx), sizeof(pw_compat)))
66877 + return -EFAULT;
66878 +
66879 + pw->rolename = compat_ptr(pw_compat.rolename);
66880 + memcpy(&pw->salt, pw_compat.salt, sizeof(pw->salt));
66881 + memcpy(&pw->sum, pw_compat.sum, sizeof(pw->sum));
66882 +
66883 + return 0;
66884 +}
66885 +
66886 +size_t get_gr_arg_wrapper_size_compat(void)
66887 +{
66888 + return sizeof(struct gr_arg_wrapper_compat);
66889 +}
66890 +
66891 diff --git a/grsecurity/gracl_fs.c b/grsecurity/gracl_fs.c
66892 new file mode 100644
66893 index 0000000..deb6f3b
66894 --- /dev/null
66895 +++ b/grsecurity/gracl_fs.c
66896 @@ -0,0 +1,437 @@
66897 +#include <linux/kernel.h>
66898 +#include <linux/sched.h>
66899 +#include <linux/types.h>
66900 +#include <linux/fs.h>
66901 +#include <linux/file.h>
66902 +#include <linux/stat.h>
66903 +#include <linux/grsecurity.h>
66904 +#include <linux/grinternal.h>
66905 +#include <linux/gracl.h>
66906 +
66907 +umode_t
66908 +gr_acl_umask(void)
66909 +{
66910 + if (unlikely(!gr_acl_is_enabled()))
66911 + return 0;
66912 +
66913 + return current->role->umask;
66914 +}
66915 +
66916 +__u32
66917 +gr_acl_handle_hidden_file(const struct dentry * dentry,
66918 + const struct vfsmount * mnt)
66919 +{
66920 + __u32 mode;
66921 +
66922 + if (unlikely(!dentry->d_inode))
66923 + return GR_FIND;
66924 +
66925 + mode =
66926 + gr_search_file(dentry, GR_FIND | GR_AUDIT_FIND | GR_SUPPRESS, mnt);
66927 +
66928 + if (unlikely(mode & GR_FIND && mode & GR_AUDIT_FIND)) {
66929 + gr_log_fs_rbac_generic(GR_DO_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66930 + return mode;
66931 + } else if (unlikely(!(mode & GR_FIND) && !(mode & GR_SUPPRESS))) {
66932 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, GR_HIDDEN_ACL_MSG, dentry, mnt);
66933 + return 0;
66934 + } else if (unlikely(!(mode & GR_FIND)))
66935 + return 0;
66936 +
66937 + return GR_FIND;
66938 +}
66939 +
66940 +__u32
66941 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
66942 + int acc_mode)
66943 +{
66944 + __u32 reqmode = GR_FIND;
66945 + __u32 mode;
66946 +
66947 + if (unlikely(!dentry->d_inode))
66948 + return reqmode;
66949 +
66950 + if (acc_mode & MAY_APPEND)
66951 + reqmode |= GR_APPEND;
66952 + else if (acc_mode & MAY_WRITE)
66953 + reqmode |= GR_WRITE;
66954 + if ((acc_mode & MAY_READ) && !S_ISDIR(dentry->d_inode->i_mode))
66955 + reqmode |= GR_READ;
66956 +
66957 + mode =
66958 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
66959 + mnt);
66960 +
66961 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
66962 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66963 + reqmode & GR_READ ? " reading" : "",
66964 + reqmode & GR_WRITE ? " writing" : reqmode &
66965 + GR_APPEND ? " appending" : "");
66966 + return reqmode;
66967 + } else
66968 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
66969 + {
66970 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_OPEN_ACL_MSG, dentry, mnt,
66971 + reqmode & GR_READ ? " reading" : "",
66972 + reqmode & GR_WRITE ? " writing" : reqmode &
66973 + GR_APPEND ? " appending" : "");
66974 + return 0;
66975 + } else if (unlikely((mode & reqmode) != reqmode))
66976 + return 0;
66977 +
66978 + return reqmode;
66979 +}
66980 +
66981 +__u32
66982 +gr_acl_handle_creat(const struct dentry * dentry,
66983 + const struct dentry * p_dentry,
66984 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
66985 + const int imode)
66986 +{
66987 + __u32 reqmode = GR_WRITE | GR_CREATE;
66988 + __u32 mode;
66989 +
66990 + if (acc_mode & MAY_APPEND)
66991 + reqmode |= GR_APPEND;
66992 + // if a directory was required or the directory already exists, then
66993 + // don't count this open as a read
66994 + if ((acc_mode & MAY_READ) &&
66995 + !((open_flags & O_DIRECTORY) || (dentry->d_inode && S_ISDIR(dentry->d_inode->i_mode))))
66996 + reqmode |= GR_READ;
66997 + if ((open_flags & O_CREAT) &&
66998 + ((imode & S_ISUID) || ((imode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
66999 + reqmode |= GR_SETID;
67000 +
67001 + mode =
67002 + gr_check_create(dentry, p_dentry, p_mnt,
67003 + reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67004 +
67005 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67006 + gr_log_fs_rbac_mode2(GR_DO_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67007 + reqmode & GR_READ ? " reading" : "",
67008 + reqmode & GR_WRITE ? " writing" : reqmode &
67009 + GR_APPEND ? " appending" : "");
67010 + return reqmode;
67011 + } else
67012 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67013 + {
67014 + gr_log_fs_rbac_mode2(GR_DONT_AUDIT, GR_CREATE_ACL_MSG, dentry, p_mnt,
67015 + reqmode & GR_READ ? " reading" : "",
67016 + reqmode & GR_WRITE ? " writing" : reqmode &
67017 + GR_APPEND ? " appending" : "");
67018 + return 0;
67019 + } else if (unlikely((mode & reqmode) != reqmode))
67020 + return 0;
67021 +
67022 + return reqmode;
67023 +}
67024 +
67025 +__u32
67026 +gr_acl_handle_access(const struct dentry * dentry, const struct vfsmount * mnt,
67027 + const int fmode)
67028 +{
67029 + __u32 mode, reqmode = GR_FIND;
67030 +
67031 + if ((fmode & S_IXOTH) && !S_ISDIR(dentry->d_inode->i_mode))
67032 + reqmode |= GR_EXEC;
67033 + if (fmode & S_IWOTH)
67034 + reqmode |= GR_WRITE;
67035 + if (fmode & S_IROTH)
67036 + reqmode |= GR_READ;
67037 +
67038 + mode =
67039 + gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS,
67040 + mnt);
67041 +
67042 + if (unlikely(((mode & reqmode) == reqmode) && mode & GR_AUDITS)) {
67043 + gr_log_fs_rbac_mode3(GR_DO_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67044 + reqmode & GR_READ ? " reading" : "",
67045 + reqmode & GR_WRITE ? " writing" : "",
67046 + reqmode & GR_EXEC ? " executing" : "");
67047 + return reqmode;
67048 + } else
67049 + if (unlikely((mode & reqmode) != reqmode && !(mode & GR_SUPPRESS)))
67050 + {
67051 + gr_log_fs_rbac_mode3(GR_DONT_AUDIT, GR_ACCESS_ACL_MSG, dentry, mnt,
67052 + reqmode & GR_READ ? " reading" : "",
67053 + reqmode & GR_WRITE ? " writing" : "",
67054 + reqmode & GR_EXEC ? " executing" : "");
67055 + return 0;
67056 + } else if (unlikely((mode & reqmode) != reqmode))
67057 + return 0;
67058 +
67059 + return reqmode;
67060 +}
67061 +
67062 +static __u32 generic_fs_handler(const struct dentry *dentry, const struct vfsmount *mnt, __u32 reqmode, const char *fmt)
67063 +{
67064 + __u32 mode;
67065 +
67066 + mode = gr_search_file(dentry, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS, mnt);
67067 +
67068 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67069 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, dentry, mnt);
67070 + return mode;
67071 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67072 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, dentry, mnt);
67073 + return 0;
67074 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67075 + return 0;
67076 +
67077 + return (reqmode);
67078 +}
67079 +
67080 +__u32
67081 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
67082 +{
67083 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_RMDIR_ACL_MSG);
67084 +}
67085 +
67086 +__u32
67087 +gr_acl_handle_unlink(const struct dentry *dentry, const struct vfsmount *mnt)
67088 +{
67089 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_DELETE , GR_UNLINK_ACL_MSG);
67090 +}
67091 +
67092 +__u32
67093 +gr_acl_handle_truncate(const struct dentry *dentry, const struct vfsmount *mnt)
67094 +{
67095 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_TRUNCATE_ACL_MSG);
67096 +}
67097 +
67098 +__u32
67099 +gr_acl_handle_utime(const struct dentry *dentry, const struct vfsmount *mnt)
67100 +{
67101 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_ATIME_ACL_MSG);
67102 +}
67103 +
67104 +__u32
67105 +gr_acl_handle_chmod(const struct dentry *dentry, const struct vfsmount *mnt,
67106 + umode_t *modeptr)
67107 +{
67108 + umode_t mode;
67109 +
67110 + *modeptr &= ~gr_acl_umask();
67111 + mode = *modeptr;
67112 +
67113 + if (unlikely(dentry->d_inode && S_ISSOCK(dentry->d_inode->i_mode)))
67114 + return 1;
67115 +
67116 + if (unlikely(dentry->d_inode && !S_ISDIR(dentry->d_inode->i_mode) &&
67117 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))) {
67118 + return generic_fs_handler(dentry, mnt, GR_WRITE | GR_SETID,
67119 + GR_CHMOD_ACL_MSG);
67120 + } else {
67121 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHMOD_ACL_MSG);
67122 + }
67123 +}
67124 +
67125 +__u32
67126 +gr_acl_handle_chown(const struct dentry *dentry, const struct vfsmount *mnt)
67127 +{
67128 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_CHOWN_ACL_MSG);
67129 +}
67130 +
67131 +__u32
67132 +gr_acl_handle_setxattr(const struct dentry *dentry, const struct vfsmount *mnt)
67133 +{
67134 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_SETXATTR_ACL_MSG);
67135 +}
67136 +
67137 +__u32
67138 +gr_acl_handle_removexattr(const struct dentry *dentry, const struct vfsmount *mnt)
67139 +{
67140 + return generic_fs_handler(dentry, mnt, GR_WRITE, GR_REMOVEXATTR_ACL_MSG);
67141 +}
67142 +
67143 +__u32
67144 +gr_acl_handle_execve(const struct dentry *dentry, const struct vfsmount *mnt)
67145 +{
67146 + return generic_fs_handler(dentry, mnt, GR_EXEC, GR_EXEC_ACL_MSG);
67147 +}
67148 +
67149 +__u32
67150 +gr_acl_handle_unix(const struct dentry *dentry, const struct vfsmount *mnt)
67151 +{
67152 + return generic_fs_handler(dentry, mnt, GR_READ | GR_WRITE,
67153 + GR_UNIXCONNECT_ACL_MSG);
67154 +}
67155 +
67156 +/* hardlinks require at minimum create and link permission,
67157 + any additional privilege required is based on the
67158 + privilege of the file being linked to
67159 +*/
67160 +__u32
67161 +gr_acl_handle_link(const struct dentry * new_dentry,
67162 + const struct dentry * parent_dentry,
67163 + const struct vfsmount * parent_mnt,
67164 + const struct dentry * old_dentry,
67165 + const struct vfsmount * old_mnt, const struct filename *to)
67166 +{
67167 + __u32 mode;
67168 + __u32 needmode = GR_CREATE | GR_LINK;
67169 + __u32 needaudit = GR_AUDIT_CREATE | GR_AUDIT_LINK;
67170 +
67171 + mode =
67172 + gr_check_link(new_dentry, parent_dentry, parent_mnt, old_dentry,
67173 + old_mnt);
67174 +
67175 + if (unlikely(((mode & needmode) == needmode) && (mode & needaudit))) {
67176 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67177 + return mode;
67178 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67179 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_LINK_ACL_MSG, old_dentry, old_mnt, to->name);
67180 + return 0;
67181 + } else if (unlikely((mode & needmode) != needmode))
67182 + return 0;
67183 +
67184 + return 1;
67185 +}
67186 +
67187 +__u32
67188 +gr_acl_handle_symlink(const struct dentry * new_dentry,
67189 + const struct dentry * parent_dentry,
67190 + const struct vfsmount * parent_mnt, const struct filename *from)
67191 +{
67192 + __u32 needmode = GR_WRITE | GR_CREATE;
67193 + __u32 mode;
67194 +
67195 + mode =
67196 + gr_check_create(new_dentry, parent_dentry, parent_mnt,
67197 + GR_CREATE | GR_AUDIT_CREATE |
67198 + GR_WRITE | GR_AUDIT_WRITE | GR_SUPPRESS);
67199 +
67200 + if (unlikely(mode & GR_WRITE && mode & GR_AUDITS)) {
67201 + gr_log_fs_str_rbac(GR_DO_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67202 + return mode;
67203 + } else if (unlikely(((mode & needmode) != needmode) && !(mode & GR_SUPPRESS))) {
67204 + gr_log_fs_str_rbac(GR_DONT_AUDIT, GR_SYMLINK_ACL_MSG, from->name, new_dentry, parent_mnt);
67205 + return 0;
67206 + } else if (unlikely((mode & needmode) != needmode))
67207 + return 0;
67208 +
67209 + return (GR_WRITE | GR_CREATE);
67210 +}
67211 +
67212 +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)
67213 +{
67214 + __u32 mode;
67215 +
67216 + mode = gr_check_create(new_dentry, parent_dentry, parent_mnt, reqmode | to_gr_audit(reqmode) | GR_SUPPRESS);
67217 +
67218 + if (unlikely(((mode & (reqmode)) == (reqmode)) && mode & GR_AUDITS)) {
67219 + gr_log_fs_rbac_generic(GR_DO_AUDIT, fmt, new_dentry, parent_mnt);
67220 + return mode;
67221 + } else if (unlikely((mode & (reqmode)) != (reqmode) && !(mode & GR_SUPPRESS))) {
67222 + gr_log_fs_rbac_generic(GR_DONT_AUDIT, fmt, new_dentry, parent_mnt);
67223 + return 0;
67224 + } else if (unlikely((mode & (reqmode)) != (reqmode)))
67225 + return 0;
67226 +
67227 + return (reqmode);
67228 +}
67229 +
67230 +__u32
67231 +gr_acl_handle_mknod(const struct dentry * new_dentry,
67232 + const struct dentry * parent_dentry,
67233 + const struct vfsmount * parent_mnt,
67234 + const int mode)
67235 +{
67236 + __u32 reqmode = GR_WRITE | GR_CREATE;
67237 + if (unlikely((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))))
67238 + reqmode |= GR_SETID;
67239 +
67240 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67241 + reqmode, GR_MKNOD_ACL_MSG);
67242 +}
67243 +
67244 +__u32
67245 +gr_acl_handle_mkdir(const struct dentry *new_dentry,
67246 + const struct dentry *parent_dentry,
67247 + const struct vfsmount *parent_mnt)
67248 +{
67249 + return generic_fs_create_handler(new_dentry, parent_dentry, parent_mnt,
67250 + GR_WRITE | GR_CREATE, GR_MKDIR_ACL_MSG);
67251 +}
67252 +
67253 +#define RENAME_CHECK_SUCCESS(old, new) \
67254 + (((old & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)) && \
67255 + ((new & (GR_WRITE | GR_READ)) == (GR_WRITE | GR_READ)))
67256 +
67257 +int
67258 +gr_acl_handle_rename(struct dentry *new_dentry,
67259 + struct dentry *parent_dentry,
67260 + const struct vfsmount *parent_mnt,
67261 + struct dentry *old_dentry,
67262 + struct inode *old_parent_inode,
67263 + struct vfsmount *old_mnt, const struct filename *newname)
67264 +{
67265 + __u32 comp1, comp2;
67266 + int error = 0;
67267 +
67268 + if (unlikely(!gr_acl_is_enabled()))
67269 + return 0;
67270 +
67271 + if (!new_dentry->d_inode) {
67272 + comp1 = gr_check_create(new_dentry, parent_dentry, parent_mnt,
67273 + GR_READ | GR_WRITE | GR_CREATE | GR_AUDIT_READ |
67274 + GR_AUDIT_WRITE | GR_AUDIT_CREATE | GR_SUPPRESS);
67275 + comp2 = gr_search_file(old_dentry, GR_READ | GR_WRITE |
67276 + GR_DELETE | GR_AUDIT_DELETE |
67277 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67278 + GR_SUPPRESS, old_mnt);
67279 + } else {
67280 + comp1 = gr_search_file(new_dentry, GR_READ | GR_WRITE |
67281 + GR_CREATE | GR_DELETE |
67282 + GR_AUDIT_CREATE | GR_AUDIT_DELETE |
67283 + GR_AUDIT_READ | GR_AUDIT_WRITE |
67284 + GR_SUPPRESS, parent_mnt);
67285 + comp2 =
67286 + gr_search_file(old_dentry,
67287 + GR_READ | GR_WRITE | GR_AUDIT_READ |
67288 + GR_DELETE | GR_AUDIT_DELETE |
67289 + GR_AUDIT_WRITE | GR_SUPPRESS, old_mnt);
67290 + }
67291 +
67292 + if (RENAME_CHECK_SUCCESS(comp1, comp2) &&
67293 + ((comp1 & GR_AUDITS) || (comp2 & GR_AUDITS)))
67294 + gr_log_fs_rbac_str(GR_DO_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67295 + else if (!RENAME_CHECK_SUCCESS(comp1, comp2) && !(comp1 & GR_SUPPRESS)
67296 + && !(comp2 & GR_SUPPRESS)) {
67297 + gr_log_fs_rbac_str(GR_DONT_AUDIT, GR_RENAME_ACL_MSG, old_dentry, old_mnt, newname->name);
67298 + error = -EACCES;
67299 + } else if (unlikely(!RENAME_CHECK_SUCCESS(comp1, comp2)))
67300 + error = -EACCES;
67301 +
67302 + return error;
67303 +}
67304 +
67305 +void
67306 +gr_acl_handle_exit(void)
67307 +{
67308 + u16 id;
67309 + char *rolename;
67310 +
67311 + if (unlikely(current->acl_sp_role && gr_acl_is_enabled() &&
67312 + !(current->role->roletype & GR_ROLE_PERSIST))) {
67313 + id = current->acl_role_id;
67314 + rolename = current->role->rolename;
67315 + gr_set_acls(1);
67316 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLEL_ACL_MSG, rolename, id);
67317 + }
67318 +
67319 + gr_put_exec_file(current);
67320 + return;
67321 +}
67322 +
67323 +int
67324 +gr_acl_handle_procpidmem(const struct task_struct *task)
67325 +{
67326 + if (unlikely(!gr_acl_is_enabled()))
67327 + return 0;
67328 +
67329 + if (task != current && task->acl->mode & GR_PROTPROCFD)
67330 + return -EACCES;
67331 +
67332 + return 0;
67333 +}
67334 diff --git a/grsecurity/gracl_ip.c b/grsecurity/gracl_ip.c
67335 new file mode 100644
67336 index 0000000..f056b81
67337 --- /dev/null
67338 +++ b/grsecurity/gracl_ip.c
67339 @@ -0,0 +1,386 @@
67340 +#include <linux/kernel.h>
67341 +#include <asm/uaccess.h>
67342 +#include <asm/errno.h>
67343 +#include <net/sock.h>
67344 +#include <linux/file.h>
67345 +#include <linux/fs.h>
67346 +#include <linux/net.h>
67347 +#include <linux/in.h>
67348 +#include <linux/skbuff.h>
67349 +#include <linux/ip.h>
67350 +#include <linux/udp.h>
67351 +#include <linux/types.h>
67352 +#include <linux/sched.h>
67353 +#include <linux/netdevice.h>
67354 +#include <linux/inetdevice.h>
67355 +#include <linux/gracl.h>
67356 +#include <linux/grsecurity.h>
67357 +#include <linux/grinternal.h>
67358 +
67359 +#define GR_BIND 0x01
67360 +#define GR_CONNECT 0x02
67361 +#define GR_INVERT 0x04
67362 +#define GR_BINDOVERRIDE 0x08
67363 +#define GR_CONNECTOVERRIDE 0x10
67364 +#define GR_SOCK_FAMILY 0x20
67365 +
67366 +static const char * gr_protocols[IPPROTO_MAX] = {
67367 + "ip", "icmp", "igmp", "ggp", "ipencap", "st", "tcp", "cbt",
67368 + "egp", "igp", "bbn-rcc", "nvp", "pup", "argus", "emcon", "xnet",
67369 + "chaos", "udp", "mux", "dcn", "hmp", "prm", "xns-idp", "trunk-1",
67370 + "trunk-2", "leaf-1", "leaf-2", "rdp", "irtp", "iso-tp4", "netblt", "mfe-nsp",
67371 + "merit-inp", "sep", "3pc", "idpr", "xtp", "ddp", "idpr-cmtp", "tp++",
67372 + "il", "ipv6", "sdrp", "ipv6-route", "ipv6-frag", "idrp", "rsvp", "gre",
67373 + "mhrp", "bna", "ipv6-crypt", "ipv6-auth", "i-nlsp", "swipe", "narp", "mobile",
67374 + "tlsp", "skip", "ipv6-icmp", "ipv6-nonxt", "ipv6-opts", "unknown:61", "cftp", "unknown:63",
67375 + "sat-expak", "kryptolan", "rvd", "ippc", "unknown:68", "sat-mon", "visa", "ipcv",
67376 + "cpnx", "cphb", "wsn", "pvp", "br-sat-mon", "sun-nd", "wb-mon", "wb-expak",
67377 + "iso-ip", "vmtp", "secure-vmtp", "vines", "ttp", "nfsnet-igp", "dgp", "tcf",
67378 + "eigrp", "ospf", "sprite-rpc", "larp", "mtp", "ax.25", "ipip", "micp",
67379 + "scc-sp", "etherip", "encap", "unknown:99", "gmtp", "ifmp", "pnni", "pim",
67380 + "aris", "scps", "qnx", "a/n", "ipcomp", "snp", "compaq-peer", "ipx-in-ip",
67381 + "vrrp", "pgm", "unknown:114", "l2tp", "ddx", "iatp", "stp", "srp",
67382 + "uti", "smp", "sm", "ptp", "isis", "fire", "crtp", "crdup",
67383 + "sscopmce", "iplt", "sps", "pipe", "sctp", "fc", "unkown:134", "unknown:135",
67384 + "unknown:136", "unknown:137", "unknown:138", "unknown:139", "unknown:140", "unknown:141", "unknown:142", "unknown:143",
67385 + "unknown:144", "unknown:145", "unknown:146", "unknown:147", "unknown:148", "unknown:149", "unknown:150", "unknown:151",
67386 + "unknown:152", "unknown:153", "unknown:154", "unknown:155", "unknown:156", "unknown:157", "unknown:158", "unknown:159",
67387 + "unknown:160", "unknown:161", "unknown:162", "unknown:163", "unknown:164", "unknown:165", "unknown:166", "unknown:167",
67388 + "unknown:168", "unknown:169", "unknown:170", "unknown:171", "unknown:172", "unknown:173", "unknown:174", "unknown:175",
67389 + "unknown:176", "unknown:177", "unknown:178", "unknown:179", "unknown:180", "unknown:181", "unknown:182", "unknown:183",
67390 + "unknown:184", "unknown:185", "unknown:186", "unknown:187", "unknown:188", "unknown:189", "unknown:190", "unknown:191",
67391 + "unknown:192", "unknown:193", "unknown:194", "unknown:195", "unknown:196", "unknown:197", "unknown:198", "unknown:199",
67392 + "unknown:200", "unknown:201", "unknown:202", "unknown:203", "unknown:204", "unknown:205", "unknown:206", "unknown:207",
67393 + "unknown:208", "unknown:209", "unknown:210", "unknown:211", "unknown:212", "unknown:213", "unknown:214", "unknown:215",
67394 + "unknown:216", "unknown:217", "unknown:218", "unknown:219", "unknown:220", "unknown:221", "unknown:222", "unknown:223",
67395 + "unknown:224", "unknown:225", "unknown:226", "unknown:227", "unknown:228", "unknown:229", "unknown:230", "unknown:231",
67396 + "unknown:232", "unknown:233", "unknown:234", "unknown:235", "unknown:236", "unknown:237", "unknown:238", "unknown:239",
67397 + "unknown:240", "unknown:241", "unknown:242", "unknown:243", "unknown:244", "unknown:245", "unknown:246", "unknown:247",
67398 + "unknown:248", "unknown:249", "unknown:250", "unknown:251", "unknown:252", "unknown:253", "unknown:254", "unknown:255",
67399 + };
67400 +
67401 +static const char * gr_socktypes[SOCK_MAX] = {
67402 + "unknown:0", "stream", "dgram", "raw", "rdm", "seqpacket", "unknown:6",
67403 + "unknown:7", "unknown:8", "unknown:9", "packet"
67404 + };
67405 +
67406 +static const char * gr_sockfamilies[AF_MAX+1] = {
67407 + "unspec", "unix", "inet", "ax25", "ipx", "appletalk", "netrom", "bridge", "atmpvc", "x25",
67408 + "inet6", "rose", "decnet", "netbeui", "security", "key", "netlink", "packet", "ash",
67409 + "econet", "atmsvc", "rds", "sna", "irda", "ppox", "wanpipe", "llc", "fam_27", "fam_28",
67410 + "tipc", "bluetooth", "iucv", "rxrpc", "isdn", "phonet", "ieee802154", "ciaf"
67411 + };
67412 +
67413 +const char *
67414 +gr_proto_to_name(unsigned char proto)
67415 +{
67416 + return gr_protocols[proto];
67417 +}
67418 +
67419 +const char *
67420 +gr_socktype_to_name(unsigned char type)
67421 +{
67422 + return gr_socktypes[type];
67423 +}
67424 +
67425 +const char *
67426 +gr_sockfamily_to_name(unsigned char family)
67427 +{
67428 + return gr_sockfamilies[family];
67429 +}
67430 +
67431 +extern const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
67432 +
67433 +int
67434 +gr_search_socket(const int domain, const int type, const int protocol)
67435 +{
67436 + struct acl_subject_label *curr;
67437 + const struct cred *cred = current_cred();
67438 +
67439 + if (unlikely(!gr_acl_is_enabled()))
67440 + goto exit;
67441 +
67442 + if ((domain < 0) || (type < 0) || (protocol < 0) ||
67443 + (domain >= AF_MAX) || (type >= SOCK_MAX) || (protocol >= IPPROTO_MAX))
67444 + goto exit; // let the kernel handle it
67445 +
67446 + curr = current->acl;
67447 +
67448 + if (curr->sock_families[domain / 32] & (1U << (domain % 32))) {
67449 + /* the family is allowed, if this is PF_INET allow it only if
67450 + the extra sock type/protocol checks pass */
67451 + if (domain == PF_INET)
67452 + goto inet_check;
67453 + goto exit;
67454 + } else {
67455 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67456 + __u32 fakeip = 0;
67457 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67458 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67459 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67460 + gr_to_filename(current->exec_file->f_path.dentry,
67461 + current->exec_file->f_path.mnt) :
67462 + curr->filename, curr->filename,
67463 + &fakeip, domain, 0, 0, GR_SOCK_FAMILY,
67464 + &current->signal->saved_ip);
67465 + goto exit;
67466 + }
67467 + goto exit_fail;
67468 + }
67469 +
67470 +inet_check:
67471 + /* the rest of this checking is for IPv4 only */
67472 + if (!curr->ips)
67473 + goto exit;
67474 +
67475 + if ((curr->ip_type & (1U << type)) &&
67476 + (curr->ip_proto[protocol / 32] & (1U << (protocol % 32))))
67477 + goto exit;
67478 +
67479 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67480 + /* we don't place acls on raw sockets , and sometimes
67481 + dgram/ip sockets are opened for ioctl and not
67482 + bind/connect, so we'll fake a bind learn log */
67483 + if (type == SOCK_RAW || type == SOCK_PACKET) {
67484 + __u32 fakeip = 0;
67485 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67486 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67487 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67488 + gr_to_filename(current->exec_file->f_path.dentry,
67489 + current->exec_file->f_path.mnt) :
67490 + curr->filename, curr->filename,
67491 + &fakeip, 0, type,
67492 + protocol, GR_CONNECT, &current->signal->saved_ip);
67493 + } else if ((type == SOCK_DGRAM) && (protocol == IPPROTO_IP)) {
67494 + __u32 fakeip = 0;
67495 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67496 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67497 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67498 + gr_to_filename(current->exec_file->f_path.dentry,
67499 + current->exec_file->f_path.mnt) :
67500 + curr->filename, curr->filename,
67501 + &fakeip, 0, type,
67502 + protocol, GR_BIND, &current->signal->saved_ip);
67503 + }
67504 + /* we'll log when they use connect or bind */
67505 + goto exit;
67506 + }
67507 +
67508 +exit_fail:
67509 + if (domain == PF_INET)
67510 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(domain),
67511 + gr_socktype_to_name(type), gr_proto_to_name(protocol));
67512 + else if (rcu_access_pointer(net_families[domain]) != NULL)
67513 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(domain),
67514 + gr_socktype_to_name(type), protocol);
67515 +
67516 + return 0;
67517 +exit:
67518 + return 1;
67519 +}
67520 +
67521 +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)
67522 +{
67523 + if ((ip->mode & mode) &&
67524 + (ip_port >= ip->low) &&
67525 + (ip_port <= ip->high) &&
67526 + ((ntohl(ip_addr) & our_netmask) ==
67527 + (ntohl(our_addr) & our_netmask))
67528 + && (ip->proto[protocol / 32] & (1U << (protocol % 32)))
67529 + && (ip->type & (1U << type))) {
67530 + if (ip->mode & GR_INVERT)
67531 + return 2; // specifically denied
67532 + else
67533 + return 1; // allowed
67534 + }
67535 +
67536 + return 0; // not specifically allowed, may continue parsing
67537 +}
67538 +
67539 +static int
67540 +gr_search_connectbind(const int full_mode, struct sock *sk,
67541 + struct sockaddr_in *addr, const int type)
67542 +{
67543 + char iface[IFNAMSIZ] = {0};
67544 + struct acl_subject_label *curr;
67545 + struct acl_ip_label *ip;
67546 + struct inet_sock *isk;
67547 + struct net_device *dev;
67548 + struct in_device *idev;
67549 + unsigned long i;
67550 + int ret;
67551 + int mode = full_mode & (GR_BIND | GR_CONNECT);
67552 + __u32 ip_addr = 0;
67553 + __u32 our_addr;
67554 + __u32 our_netmask;
67555 + char *p;
67556 + __u16 ip_port = 0;
67557 + const struct cred *cred = current_cred();
67558 +
67559 + if (unlikely(!gr_acl_is_enabled() || sk->sk_family != PF_INET))
67560 + return 0;
67561 +
67562 + curr = current->acl;
67563 + isk = inet_sk(sk);
67564 +
67565 + /* INADDR_ANY overriding for binds, inaddr_any_override is already in network order */
67566 + if ((full_mode & GR_BINDOVERRIDE) && addr->sin_addr.s_addr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0)
67567 + addr->sin_addr.s_addr = curr->inaddr_any_override;
67568 + if ((full_mode & GR_CONNECT) && isk->inet_saddr == htonl(INADDR_ANY) && curr->inaddr_any_override != 0) {
67569 + struct sockaddr_in saddr;
67570 + int err;
67571 +
67572 + saddr.sin_family = AF_INET;
67573 + saddr.sin_addr.s_addr = curr->inaddr_any_override;
67574 + saddr.sin_port = isk->inet_sport;
67575 +
67576 + err = security_socket_bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67577 + if (err)
67578 + return err;
67579 +
67580 + err = sk->sk_socket->ops->bind(sk->sk_socket, (struct sockaddr *)&saddr, sizeof(struct sockaddr_in));
67581 + if (err)
67582 + return err;
67583 + }
67584 +
67585 + if (!curr->ips)
67586 + return 0;
67587 +
67588 + ip_addr = addr->sin_addr.s_addr;
67589 + ip_port = ntohs(addr->sin_port);
67590 +
67591 + if (curr->mode & (GR_LEARN | GR_INHERITLEARN)) {
67592 + security_learn(GR_IP_LEARN_MSG, current->role->rolename,
67593 + current->role->roletype, GR_GLOBAL_UID(cred->uid),
67594 + GR_GLOBAL_GID(cred->gid), current->exec_file ?
67595 + gr_to_filename(current->exec_file->f_path.dentry,
67596 + current->exec_file->f_path.mnt) :
67597 + curr->filename, curr->filename,
67598 + &ip_addr, ip_port, type,
67599 + sk->sk_protocol, mode, &current->signal->saved_ip);
67600 + return 0;
67601 + }
67602 +
67603 + for (i = 0; i < curr->ip_num; i++) {
67604 + ip = *(curr->ips + i);
67605 + if (ip->iface != NULL) {
67606 + strncpy(iface, ip->iface, IFNAMSIZ - 1);
67607 + p = strchr(iface, ':');
67608 + if (p != NULL)
67609 + *p = '\0';
67610 + dev = dev_get_by_name(sock_net(sk), iface);
67611 + if (dev == NULL)
67612 + continue;
67613 + idev = in_dev_get(dev);
67614 + if (idev == NULL) {
67615 + dev_put(dev);
67616 + continue;
67617 + }
67618 + rcu_read_lock();
67619 + for_ifa(idev) {
67620 + if (!strcmp(ip->iface, ifa->ifa_label)) {
67621 + our_addr = ifa->ifa_address;
67622 + our_netmask = 0xffffffff;
67623 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67624 + if (ret == 1) {
67625 + rcu_read_unlock();
67626 + in_dev_put(idev);
67627 + dev_put(dev);
67628 + return 0;
67629 + } else if (ret == 2) {
67630 + rcu_read_unlock();
67631 + in_dev_put(idev);
67632 + dev_put(dev);
67633 + goto denied;
67634 + }
67635 + }
67636 + } endfor_ifa(idev);
67637 + rcu_read_unlock();
67638 + in_dev_put(idev);
67639 + dev_put(dev);
67640 + } else {
67641 + our_addr = ip->addr;
67642 + our_netmask = ip->netmask;
67643 + ret = check_ip_policy(ip, ip_addr, ip_port, sk->sk_protocol, mode, type, our_addr, our_netmask);
67644 + if (ret == 1)
67645 + return 0;
67646 + else if (ret == 2)
67647 + goto denied;
67648 + }
67649 + }
67650 +
67651 +denied:
67652 + if (mode == GR_BIND)
67653 + 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));
67654 + else if (mode == GR_CONNECT)
67655 + 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));
67656 +
67657 + return -EACCES;
67658 +}
67659 +
67660 +int
67661 +gr_search_connect(struct socket *sock, struct sockaddr_in *addr)
67662 +{
67663 + /* always allow disconnection of dgram sockets with connect */
67664 + if (addr->sin_family == AF_UNSPEC)
67665 + return 0;
67666 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sock->sk, addr, sock->type);
67667 +}
67668 +
67669 +int
67670 +gr_search_bind(struct socket *sock, struct sockaddr_in *addr)
67671 +{
67672 + return gr_search_connectbind(GR_BIND | GR_BINDOVERRIDE, sock->sk, addr, sock->type);
67673 +}
67674 +
67675 +int gr_search_listen(struct socket *sock)
67676 +{
67677 + struct sock *sk = sock->sk;
67678 + struct sockaddr_in addr;
67679 +
67680 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67681 + addr.sin_port = inet_sk(sk)->inet_sport;
67682 +
67683 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67684 +}
67685 +
67686 +int gr_search_accept(struct socket *sock)
67687 +{
67688 + struct sock *sk = sock->sk;
67689 + struct sockaddr_in addr;
67690 +
67691 + addr.sin_addr.s_addr = inet_sk(sk)->inet_saddr;
67692 + addr.sin_port = inet_sk(sk)->inet_sport;
67693 +
67694 + return gr_search_connectbind(GR_BIND | GR_CONNECTOVERRIDE, sock->sk, &addr, sock->type);
67695 +}
67696 +
67697 +int
67698 +gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr)
67699 +{
67700 + if (addr)
67701 + return gr_search_connectbind(GR_CONNECT, sk, addr, SOCK_DGRAM);
67702 + else {
67703 + struct sockaddr_in sin;
67704 + const struct inet_sock *inet = inet_sk(sk);
67705 +
67706 + sin.sin_addr.s_addr = inet->inet_daddr;
67707 + sin.sin_port = inet->inet_dport;
67708 +
67709 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67710 + }
67711 +}
67712 +
67713 +int
67714 +gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb)
67715 +{
67716 + struct sockaddr_in sin;
67717 +
67718 + if (unlikely(skb->len < sizeof (struct udphdr)))
67719 + return 0; // skip this packet
67720 +
67721 + sin.sin_addr.s_addr = ip_hdr(skb)->saddr;
67722 + sin.sin_port = udp_hdr(skb)->source;
67723 +
67724 + return gr_search_connectbind(GR_CONNECT | GR_CONNECTOVERRIDE, sk, &sin, SOCK_DGRAM);
67725 +}
67726 diff --git a/grsecurity/gracl_learn.c b/grsecurity/gracl_learn.c
67727 new file mode 100644
67728 index 0000000..25f54ef
67729 --- /dev/null
67730 +++ b/grsecurity/gracl_learn.c
67731 @@ -0,0 +1,207 @@
67732 +#include <linux/kernel.h>
67733 +#include <linux/mm.h>
67734 +#include <linux/sched.h>
67735 +#include <linux/poll.h>
67736 +#include <linux/string.h>
67737 +#include <linux/file.h>
67738 +#include <linux/types.h>
67739 +#include <linux/vmalloc.h>
67740 +#include <linux/grinternal.h>
67741 +
67742 +extern ssize_t write_grsec_handler(struct file * file, const char __user * buf,
67743 + size_t count, loff_t *ppos);
67744 +extern int gr_acl_is_enabled(void);
67745 +
67746 +static DECLARE_WAIT_QUEUE_HEAD(learn_wait);
67747 +static int gr_learn_attached;
67748 +
67749 +/* use a 512k buffer */
67750 +#define LEARN_BUFFER_SIZE (512 * 1024)
67751 +
67752 +static DEFINE_SPINLOCK(gr_learn_lock);
67753 +static DEFINE_MUTEX(gr_learn_user_mutex);
67754 +
67755 +/* we need to maintain two buffers, so that the kernel context of grlearn
67756 + uses a semaphore around the userspace copying, and the other kernel contexts
67757 + use a spinlock when copying into the buffer, since they cannot sleep
67758 +*/
67759 +static char *learn_buffer;
67760 +static char *learn_buffer_user;
67761 +static int learn_buffer_len;
67762 +static int learn_buffer_user_len;
67763 +
67764 +static ssize_t
67765 +read_learn(struct file *file, char __user * buf, size_t count, loff_t * ppos)
67766 +{
67767 + DECLARE_WAITQUEUE(wait, current);
67768 + ssize_t retval = 0;
67769 +
67770 + add_wait_queue(&learn_wait, &wait);
67771 + set_current_state(TASK_INTERRUPTIBLE);
67772 + do {
67773 + mutex_lock(&gr_learn_user_mutex);
67774 + spin_lock(&gr_learn_lock);
67775 + if (learn_buffer_len)
67776 + break;
67777 + spin_unlock(&gr_learn_lock);
67778 + mutex_unlock(&gr_learn_user_mutex);
67779 + if (file->f_flags & O_NONBLOCK) {
67780 + retval = -EAGAIN;
67781 + goto out;
67782 + }
67783 + if (signal_pending(current)) {
67784 + retval = -ERESTARTSYS;
67785 + goto out;
67786 + }
67787 +
67788 + schedule();
67789 + } while (1);
67790 +
67791 + memcpy(learn_buffer_user, learn_buffer, learn_buffer_len);
67792 + learn_buffer_user_len = learn_buffer_len;
67793 + retval = learn_buffer_len;
67794 + learn_buffer_len = 0;
67795 +
67796 + spin_unlock(&gr_learn_lock);
67797 +
67798 + if (copy_to_user(buf, learn_buffer_user, learn_buffer_user_len))
67799 + retval = -EFAULT;
67800 +
67801 + mutex_unlock(&gr_learn_user_mutex);
67802 +out:
67803 + set_current_state(TASK_RUNNING);
67804 + remove_wait_queue(&learn_wait, &wait);
67805 + return retval;
67806 +}
67807 +
67808 +static unsigned int
67809 +poll_learn(struct file * file, poll_table * wait)
67810 +{
67811 + poll_wait(file, &learn_wait, wait);
67812 +
67813 + if (learn_buffer_len)
67814 + return (POLLIN | POLLRDNORM);
67815 +
67816 + return 0;
67817 +}
67818 +
67819 +void
67820 +gr_clear_learn_entries(void)
67821 +{
67822 + char *tmp;
67823 +
67824 + mutex_lock(&gr_learn_user_mutex);
67825 + spin_lock(&gr_learn_lock);
67826 + tmp = learn_buffer;
67827 + learn_buffer = NULL;
67828 + spin_unlock(&gr_learn_lock);
67829 + if (tmp)
67830 + vfree(tmp);
67831 + if (learn_buffer_user != NULL) {
67832 + vfree(learn_buffer_user);
67833 + learn_buffer_user = NULL;
67834 + }
67835 + learn_buffer_len = 0;
67836 + mutex_unlock(&gr_learn_user_mutex);
67837 +
67838 + return;
67839 +}
67840 +
67841 +void
67842 +gr_add_learn_entry(const char *fmt, ...)
67843 +{
67844 + va_list args;
67845 + unsigned int len;
67846 +
67847 + if (!gr_learn_attached)
67848 + return;
67849 +
67850 + spin_lock(&gr_learn_lock);
67851 +
67852 + /* leave a gap at the end so we know when it's "full" but don't have to
67853 + compute the exact length of the string we're trying to append
67854 + */
67855 + if (learn_buffer_len > LEARN_BUFFER_SIZE - 16384) {
67856 + spin_unlock(&gr_learn_lock);
67857 + wake_up_interruptible(&learn_wait);
67858 + return;
67859 + }
67860 + if (learn_buffer == NULL) {
67861 + spin_unlock(&gr_learn_lock);
67862 + return;
67863 + }
67864 +
67865 + va_start(args, fmt);
67866 + len = vsnprintf(learn_buffer + learn_buffer_len, LEARN_BUFFER_SIZE - learn_buffer_len, fmt, args);
67867 + va_end(args);
67868 +
67869 + learn_buffer_len += len + 1;
67870 +
67871 + spin_unlock(&gr_learn_lock);
67872 + wake_up_interruptible(&learn_wait);
67873 +
67874 + return;
67875 +}
67876 +
67877 +static int
67878 +open_learn(struct inode *inode, struct file *file)
67879 +{
67880 + if (file->f_mode & FMODE_READ && gr_learn_attached)
67881 + return -EBUSY;
67882 + if (file->f_mode & FMODE_READ) {
67883 + int retval = 0;
67884 + mutex_lock(&gr_learn_user_mutex);
67885 + if (learn_buffer == NULL)
67886 + learn_buffer = vmalloc(LEARN_BUFFER_SIZE);
67887 + if (learn_buffer_user == NULL)
67888 + learn_buffer_user = vmalloc(LEARN_BUFFER_SIZE);
67889 + if (learn_buffer == NULL) {
67890 + retval = -ENOMEM;
67891 + goto out_error;
67892 + }
67893 + if (learn_buffer_user == NULL) {
67894 + retval = -ENOMEM;
67895 + goto out_error;
67896 + }
67897 + learn_buffer_len = 0;
67898 + learn_buffer_user_len = 0;
67899 + gr_learn_attached = 1;
67900 +out_error:
67901 + mutex_unlock(&gr_learn_user_mutex);
67902 + return retval;
67903 + }
67904 + return 0;
67905 +}
67906 +
67907 +static int
67908 +close_learn(struct inode *inode, struct file *file)
67909 +{
67910 + if (file->f_mode & FMODE_READ) {
67911 + char *tmp = NULL;
67912 + mutex_lock(&gr_learn_user_mutex);
67913 + spin_lock(&gr_learn_lock);
67914 + tmp = learn_buffer;
67915 + learn_buffer = NULL;
67916 + spin_unlock(&gr_learn_lock);
67917 + if (tmp)
67918 + vfree(tmp);
67919 + if (learn_buffer_user != NULL) {
67920 + vfree(learn_buffer_user);
67921 + learn_buffer_user = NULL;
67922 + }
67923 + learn_buffer_len = 0;
67924 + learn_buffer_user_len = 0;
67925 + gr_learn_attached = 0;
67926 + mutex_unlock(&gr_learn_user_mutex);
67927 + }
67928 +
67929 + return 0;
67930 +}
67931 +
67932 +const struct file_operations grsec_fops = {
67933 + .read = read_learn,
67934 + .write = write_grsec_handler,
67935 + .open = open_learn,
67936 + .release = close_learn,
67937 + .poll = poll_learn,
67938 +};
67939 diff --git a/grsecurity/gracl_policy.c b/grsecurity/gracl_policy.c
67940 new file mode 100644
67941 index 0000000..361a099
67942 --- /dev/null
67943 +++ b/grsecurity/gracl_policy.c
67944 @@ -0,0 +1,1782 @@
67945 +#include <linux/kernel.h>
67946 +#include <linux/module.h>
67947 +#include <linux/sched.h>
67948 +#include <linux/mm.h>
67949 +#include <linux/file.h>
67950 +#include <linux/fs.h>
67951 +#include <linux/namei.h>
67952 +#include <linux/mount.h>
67953 +#include <linux/tty.h>
67954 +#include <linux/proc_fs.h>
67955 +#include <linux/lglock.h>
67956 +#include <linux/slab.h>
67957 +#include <linux/vmalloc.h>
67958 +#include <linux/types.h>
67959 +#include <linux/sysctl.h>
67960 +#include <linux/netdevice.h>
67961 +#include <linux/ptrace.h>
67962 +#include <linux/gracl.h>
67963 +#include <linux/gralloc.h>
67964 +#include <linux/security.h>
67965 +#include <linux/grinternal.h>
67966 +#include <linux/pid_namespace.h>
67967 +#include <linux/stop_machine.h>
67968 +#include <linux/fdtable.h>
67969 +#include <linux/percpu.h>
67970 +#include <linux/lglock.h>
67971 +#include <linux/hugetlb.h>
67972 +#include <linux/posix-timers.h>
67973 +#include "../fs/mount.h"
67974 +
67975 +#include <asm/uaccess.h>
67976 +#include <asm/errno.h>
67977 +#include <asm/mman.h>
67978 +
67979 +extern struct gr_policy_state *polstate;
67980 +
67981 +#define FOR_EACH_ROLE_START(role) \
67982 + role = polstate->role_list; \
67983 + while (role) {
67984 +
67985 +#define FOR_EACH_ROLE_END(role) \
67986 + role = role->prev; \
67987 + }
67988 +
67989 +struct path gr_real_root;
67990 +
67991 +extern struct gr_alloc_state *current_alloc_state;
67992 +
67993 +u16 acl_sp_role_value;
67994 +
67995 +static DEFINE_MUTEX(gr_dev_mutex);
67996 +
67997 +extern int chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum);
67998 +extern void gr_clear_learn_entries(void);
67999 +
68000 +static struct gr_arg gr_usermode;
68001 +static unsigned char gr_system_salt[GR_SALT_LEN];
68002 +static unsigned char gr_system_sum[GR_SHA_LEN];
68003 +
68004 +static unsigned int gr_auth_attempts = 0;
68005 +static unsigned long gr_auth_expires = 0UL;
68006 +
68007 +struct acl_object_label *fakefs_obj_rw;
68008 +struct acl_object_label *fakefs_obj_rwx;
68009 +
68010 +extern int gr_init_uidset(void);
68011 +extern void gr_free_uidset(void);
68012 +extern void gr_remove_uid(uid_t uid);
68013 +extern int gr_find_uid(uid_t uid);
68014 +
68015 +extern struct acl_subject_label *__gr_get_subject_for_task(const struct gr_policy_state *state, struct task_struct *task, const char *filename);
68016 +extern void __gr_apply_subject_to_task(struct gr_policy_state *state, struct task_struct *task, struct acl_subject_label *subj);
68017 +extern int gr_streq(const char *a, const char *b, const unsigned int lena, const unsigned int lenb);
68018 +extern void __insert_inodev_entry(const struct gr_policy_state *state, struct inodev_entry *entry);
68019 +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);
68020 +extern void insert_acl_obj_label(struct acl_object_label *obj, struct acl_subject_label *subj);
68021 +extern void insert_acl_subj_label(struct acl_subject_label *obj, struct acl_role_label *role);
68022 +extern struct name_entry * __lookup_name_entry(const struct gr_policy_state *state, const char *name);
68023 +extern char *gr_to_filename_rbac(const struct dentry *dentry, const struct vfsmount *mnt);
68024 +extern struct acl_subject_label *lookup_acl_subj_label(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
68025 +extern struct acl_subject_label *lookup_acl_subj_label_deleted(const ino_t ino, const dev_t dev, const struct acl_role_label *role);
68026 +extern void assign_special_role(const char *rolename);
68027 +extern struct acl_subject_label *chk_subj_label(const struct dentry *l_dentry, const struct vfsmount *l_mnt, const struct acl_role_label *role);
68028 +extern int gr_rbac_disable(void *unused);
68029 +extern void gr_enable_rbac_system(void);
68030 +
68031 +static int copy_acl_object_label_normal(struct acl_object_label *obj, const struct acl_object_label *userp)
68032 +{
68033 + if (copy_from_user(obj, userp, sizeof(struct acl_object_label)))
68034 + return -EFAULT;
68035 +
68036 + return 0;
68037 +}
68038 +
68039 +static int copy_acl_ip_label_normal(struct acl_ip_label *ip, const struct acl_ip_label *userp)
68040 +{
68041 + if (copy_from_user(ip, userp, sizeof(struct acl_ip_label)))
68042 + return -EFAULT;
68043 +
68044 + return 0;
68045 +}
68046 +
68047 +static int copy_acl_subject_label_normal(struct acl_subject_label *subj, const struct acl_subject_label *userp)
68048 +{
68049 + if (copy_from_user(subj, userp, sizeof(struct acl_subject_label)))
68050 + return -EFAULT;
68051 +
68052 + return 0;
68053 +}
68054 +
68055 +static int copy_acl_role_label_normal(struct acl_role_label *role, const struct acl_role_label *userp)
68056 +{
68057 + if (copy_from_user(role, userp, sizeof(struct acl_role_label)))
68058 + return -EFAULT;
68059 +
68060 + return 0;
68061 +}
68062 +
68063 +static int copy_role_allowed_ip_normal(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp)
68064 +{
68065 + if (copy_from_user(roleip, userp, sizeof(struct role_allowed_ip)))
68066 + return -EFAULT;
68067 +
68068 + return 0;
68069 +}
68070 +
68071 +static int copy_sprole_pw_normal(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp)
68072 +{
68073 + if (copy_from_user(pw, userp + idx, sizeof(struct sprole_pw)))
68074 + return -EFAULT;
68075 +
68076 + return 0;
68077 +}
68078 +
68079 +static int copy_gr_hash_struct_normal(struct gr_hash_struct *hash, const struct gr_hash_struct *userp)
68080 +{
68081 + if (copy_from_user(hash, userp, sizeof(struct gr_hash_struct)))
68082 + return -EFAULT;
68083 +
68084 + return 0;
68085 +}
68086 +
68087 +static int copy_role_transition_normal(struct role_transition *trans, const struct role_transition *userp)
68088 +{
68089 + if (copy_from_user(trans, userp, sizeof(struct role_transition)))
68090 + return -EFAULT;
68091 +
68092 + return 0;
68093 +}
68094 +
68095 +int copy_pointer_from_array_normal(void *ptr, unsigned long idx, const void *userp)
68096 +{
68097 + if (copy_from_user(ptr, userp + (idx * sizeof(void *)), sizeof(void *)))
68098 + return -EFAULT;
68099 +
68100 + return 0;
68101 +}
68102 +
68103 +static int copy_gr_arg_wrapper_normal(const char __user *buf, struct gr_arg_wrapper *uwrap)
68104 +{
68105 + if (copy_from_user(uwrap, buf, sizeof (struct gr_arg_wrapper)))
68106 + return -EFAULT;
68107 +
68108 + if (((uwrap->version != GRSECURITY_VERSION) &&
68109 + (uwrap->version != 0x2901)) ||
68110 + (uwrap->size != sizeof(struct gr_arg)))
68111 + return -EINVAL;
68112 +
68113 + return 0;
68114 +}
68115 +
68116 +static int copy_gr_arg_normal(const struct gr_arg __user *buf, struct gr_arg *arg)
68117 +{
68118 + if (copy_from_user(arg, buf, sizeof (struct gr_arg)))
68119 + return -EFAULT;
68120 +
68121 + return 0;
68122 +}
68123 +
68124 +static size_t get_gr_arg_wrapper_size_normal(void)
68125 +{
68126 + return sizeof(struct gr_arg_wrapper);
68127 +}
68128 +
68129 +#ifdef CONFIG_COMPAT
68130 +extern int copy_gr_arg_wrapper_compat(const char *buf, struct gr_arg_wrapper *uwrap);
68131 +extern int copy_gr_arg_compat(const struct gr_arg __user *buf, struct gr_arg *arg);
68132 +extern int copy_acl_object_label_compat(struct acl_object_label *obj, const struct acl_object_label *userp);
68133 +extern int copy_acl_subject_label_compat(struct acl_subject_label *subj, const struct acl_subject_label *userp);
68134 +extern int copy_acl_role_label_compat(struct acl_role_label *role, const struct acl_role_label *userp);
68135 +extern int copy_role_allowed_ip_compat(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp);
68136 +extern int copy_role_transition_compat(struct role_transition *trans, const struct role_transition *userp);
68137 +extern int copy_gr_hash_struct_compat(struct gr_hash_struct *hash, const struct gr_hash_struct *userp);
68138 +extern int copy_pointer_from_array_compat(void *ptr, unsigned long idx, const void *userp);
68139 +extern int copy_acl_ip_label_compat(struct acl_ip_label *ip, const struct acl_ip_label *userp);
68140 +extern int copy_sprole_pw_compat(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp);
68141 +extern size_t get_gr_arg_wrapper_size_compat(void);
68142 +
68143 +int (* copy_gr_arg_wrapper)(const char *buf, struct gr_arg_wrapper *uwrap) __read_only;
68144 +int (* copy_gr_arg)(const struct gr_arg *buf, struct gr_arg *arg) __read_only;
68145 +int (* copy_acl_object_label)(struct acl_object_label *obj, const struct acl_object_label *userp) __read_only;
68146 +int (* copy_acl_subject_label)(struct acl_subject_label *subj, const struct acl_subject_label *userp) __read_only;
68147 +int (* copy_acl_role_label)(struct acl_role_label *role, const struct acl_role_label *userp) __read_only;
68148 +int (* copy_acl_ip_label)(struct acl_ip_label *ip, const struct acl_ip_label *userp) __read_only;
68149 +int (* copy_pointer_from_array)(void *ptr, unsigned long idx, const void *userp) __read_only;
68150 +int (* copy_sprole_pw)(struct sprole_pw *pw, unsigned long idx, const struct sprole_pw *userp) __read_only;
68151 +int (* copy_gr_hash_struct)(struct gr_hash_struct *hash, const struct gr_hash_struct *userp) __read_only;
68152 +int (* copy_role_transition)(struct role_transition *trans, const struct role_transition *userp) __read_only;
68153 +int (* copy_role_allowed_ip)(struct role_allowed_ip *roleip, const struct role_allowed_ip *userp) __read_only;
68154 +size_t (* get_gr_arg_wrapper_size)(void) __read_only;
68155 +
68156 +#else
68157 +#define copy_gr_arg_wrapper copy_gr_arg_wrapper_normal
68158 +#define copy_gr_arg copy_gr_arg_normal
68159 +#define copy_gr_hash_struct copy_gr_hash_struct_normal
68160 +#define copy_acl_object_label copy_acl_object_label_normal
68161 +#define copy_acl_subject_label copy_acl_subject_label_normal
68162 +#define copy_acl_role_label copy_acl_role_label_normal
68163 +#define copy_acl_ip_label copy_acl_ip_label_normal
68164 +#define copy_pointer_from_array copy_pointer_from_array_normal
68165 +#define copy_sprole_pw copy_sprole_pw_normal
68166 +#define copy_role_transition copy_role_transition_normal
68167 +#define copy_role_allowed_ip copy_role_allowed_ip_normal
68168 +#define get_gr_arg_wrapper_size get_gr_arg_wrapper_size_normal
68169 +#endif
68170 +
68171 +static struct acl_subject_label *
68172 +lookup_subject_map(const struct acl_subject_label *userp)
68173 +{
68174 + unsigned int index = gr_shash(userp, polstate->subj_map_set.s_size);
68175 + struct subject_map *match;
68176 +
68177 + match = polstate->subj_map_set.s_hash[index];
68178 +
68179 + while (match && match->user != userp)
68180 + match = match->next;
68181 +
68182 + if (match != NULL)
68183 + return match->kernel;
68184 + else
68185 + return NULL;
68186 +}
68187 +
68188 +static void
68189 +insert_subj_map_entry(struct subject_map *subjmap)
68190 +{
68191 + unsigned int index = gr_shash(subjmap->user, polstate->subj_map_set.s_size);
68192 + struct subject_map **curr;
68193 +
68194 + subjmap->prev = NULL;
68195 +
68196 + curr = &polstate->subj_map_set.s_hash[index];
68197 + if (*curr != NULL)
68198 + (*curr)->prev = subjmap;
68199 +
68200 + subjmap->next = *curr;
68201 + *curr = subjmap;
68202 +
68203 + return;
68204 +}
68205 +
68206 +static void
68207 +__insert_acl_role_label(struct acl_role_label *role, uid_t uidgid)
68208 +{
68209 + unsigned int index =
68210 + gr_rhash(uidgid, role->roletype & (GR_ROLE_USER | GR_ROLE_GROUP), polstate->acl_role_set.r_size);
68211 + struct acl_role_label **curr;
68212 + struct acl_role_label *tmp, *tmp2;
68213 +
68214 + curr = &polstate->acl_role_set.r_hash[index];
68215 +
68216 + /* simple case, slot is empty, just set it to our role */
68217 + if (*curr == NULL) {
68218 + *curr = role;
68219 + } else {
68220 + /* example:
68221 + 1 -> 2 -> 3 (adding 2 -> 3 to here)
68222 + 2 -> 3
68223 + */
68224 + /* first check to see if we can already be reached via this slot */
68225 + tmp = *curr;
68226 + while (tmp && tmp != role)
68227 + tmp = tmp->next;
68228 + if (tmp == role) {
68229 + /* we don't need to add ourselves to this slot's chain */
68230 + return;
68231 + }
68232 + /* we need to add ourselves to this chain, two cases */
68233 + if (role->next == NULL) {
68234 + /* simple case, append the current chain to our role */
68235 + role->next = *curr;
68236 + *curr = role;
68237 + } else {
68238 + /* 1 -> 2 -> 3 -> 4
68239 + 2 -> 3 -> 4
68240 + 3 -> 4 (adding 1 -> 2 -> 3 -> 4 to here)
68241 + */
68242 + /* trickier case: walk our role's chain until we find
68243 + the role for the start of the current slot's chain */
68244 + tmp = role;
68245 + tmp2 = *curr;
68246 + while (tmp->next && tmp->next != tmp2)
68247 + tmp = tmp->next;
68248 + if (tmp->next == tmp2) {
68249 + /* from example above, we found 3, so just
68250 + replace this slot's chain with ours */
68251 + *curr = role;
68252 + } else {
68253 + /* we didn't find a subset of our role's chain
68254 + in the current slot's chain, so append their
68255 + chain to ours, and set us as the first role in
68256 + the slot's chain
68257 +
68258 + we could fold this case with the case above,
68259 + but making it explicit for clarity
68260 + */
68261 + tmp->next = tmp2;
68262 + *curr = role;
68263 + }
68264 + }
68265 + }
68266 +
68267 + return;
68268 +}
68269 +
68270 +static void
68271 +insert_acl_role_label(struct acl_role_label *role)
68272 +{
68273 + int i;
68274 +
68275 + if (polstate->role_list == NULL) {
68276 + polstate->role_list = role;
68277 + role->prev = NULL;
68278 + } else {
68279 + role->prev = polstate->role_list;
68280 + polstate->role_list = role;
68281 + }
68282 +
68283 + /* used for hash chains */
68284 + role->next = NULL;
68285 +
68286 + if (role->roletype & GR_ROLE_DOMAIN) {
68287 + for (i = 0; i < role->domain_child_num; i++)
68288 + __insert_acl_role_label(role, role->domain_children[i]);
68289 + } else
68290 + __insert_acl_role_label(role, role->uidgid);
68291 +}
68292 +
68293 +static int
68294 +insert_name_entry(char *name, const ino_t inode, const dev_t device, __u8 deleted)
68295 +{
68296 + struct name_entry **curr, *nentry;
68297 + struct inodev_entry *ientry;
68298 + unsigned int len = strlen(name);
68299 + unsigned int key = full_name_hash(name, len);
68300 + unsigned int index = key % polstate->name_set.n_size;
68301 +
68302 + curr = &polstate->name_set.n_hash[index];
68303 +
68304 + while (*curr && ((*curr)->key != key || !gr_streq((*curr)->name, name, (*curr)->len, len)))
68305 + curr = &((*curr)->next);
68306 +
68307 + if (*curr != NULL)
68308 + return 1;
68309 +
68310 + nentry = acl_alloc(sizeof (struct name_entry));
68311 + if (nentry == NULL)
68312 + return 0;
68313 + ientry = acl_alloc(sizeof (struct inodev_entry));
68314 + if (ientry == NULL)
68315 + return 0;
68316 + ientry->nentry = nentry;
68317 +
68318 + nentry->key = key;
68319 + nentry->name = name;
68320 + nentry->inode = inode;
68321 + nentry->device = device;
68322 + nentry->len = len;
68323 + nentry->deleted = deleted;
68324 +
68325 + nentry->prev = NULL;
68326 + curr = &polstate->name_set.n_hash[index];
68327 + if (*curr != NULL)
68328 + (*curr)->prev = nentry;
68329 + nentry->next = *curr;
68330 + *curr = nentry;
68331 +
68332 + /* insert us into the table searchable by inode/dev */
68333 + __insert_inodev_entry(polstate, ientry);
68334 +
68335 + return 1;
68336 +}
68337 +
68338 +/* allocating chained hash tables, so optimal size is where lambda ~ 1 */
68339 +
68340 +static void *
68341 +create_table(__u32 * len, int elementsize)
68342 +{
68343 + unsigned int table_sizes[] = {
68344 + 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381,
68345 + 32749, 65521, 131071, 262139, 524287, 1048573, 2097143,
68346 + 4194301, 8388593, 16777213, 33554393, 67108859
68347 + };
68348 + void *newtable = NULL;
68349 + unsigned int pwr = 0;
68350 +
68351 + while ((pwr < ((sizeof (table_sizes) / sizeof (table_sizes[0])) - 1)) &&
68352 + table_sizes[pwr] <= *len)
68353 + pwr++;
68354 +
68355 + if (table_sizes[pwr] <= *len || (table_sizes[pwr] > ULONG_MAX / elementsize))
68356 + return newtable;
68357 +
68358 + if ((table_sizes[pwr] * elementsize) <= PAGE_SIZE)
68359 + newtable =
68360 + kmalloc(table_sizes[pwr] * elementsize, GFP_KERNEL);
68361 + else
68362 + newtable = vmalloc(table_sizes[pwr] * elementsize);
68363 +
68364 + *len = table_sizes[pwr];
68365 +
68366 + return newtable;
68367 +}
68368 +
68369 +static int
68370 +init_variables(const struct gr_arg *arg, bool reload)
68371 +{
68372 + struct task_struct *reaper = init_pid_ns.child_reaper;
68373 + unsigned int stacksize;
68374 +
68375 + polstate->subj_map_set.s_size = arg->role_db.num_subjects;
68376 + polstate->acl_role_set.r_size = arg->role_db.num_roles + arg->role_db.num_domain_children;
68377 + polstate->name_set.n_size = arg->role_db.num_objects;
68378 + polstate->inodev_set.i_size = arg->role_db.num_objects;
68379 +
68380 + if (!polstate->subj_map_set.s_size || !polstate->acl_role_set.r_size ||
68381 + !polstate->name_set.n_size || !polstate->inodev_set.i_size)
68382 + return 1;
68383 +
68384 + if (!reload) {
68385 + if (!gr_init_uidset())
68386 + return 1;
68387 + }
68388 +
68389 + /* set up the stack that holds allocation info */
68390 +
68391 + stacksize = arg->role_db.num_pointers + 5;
68392 +
68393 + if (!acl_alloc_stack_init(stacksize))
68394 + return 1;
68395 +
68396 + if (!reload) {
68397 + /* grab reference for the real root dentry and vfsmount */
68398 + get_fs_root(reaper->fs, &gr_real_root);
68399 +
68400 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68401 + 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);
68402 +#endif
68403 +
68404 + fakefs_obj_rw = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
68405 + if (fakefs_obj_rw == NULL)
68406 + return 1;
68407 + fakefs_obj_rw->mode = GR_FIND | GR_READ | GR_WRITE;
68408 +
68409 + fakefs_obj_rwx = kzalloc(sizeof(struct acl_object_label), GFP_KERNEL);
68410 + if (fakefs_obj_rwx == NULL)
68411 + return 1;
68412 + fakefs_obj_rwx->mode = GR_FIND | GR_READ | GR_WRITE | GR_EXEC;
68413 + }
68414 +
68415 + polstate->subj_map_set.s_hash =
68416 + (struct subject_map **) create_table(&polstate->subj_map_set.s_size, sizeof(void *));
68417 + polstate->acl_role_set.r_hash =
68418 + (struct acl_role_label **) create_table(&polstate->acl_role_set.r_size, sizeof(void *));
68419 + polstate->name_set.n_hash = (struct name_entry **) create_table(&polstate->name_set.n_size, sizeof(void *));
68420 + polstate->inodev_set.i_hash =
68421 + (struct inodev_entry **) create_table(&polstate->inodev_set.i_size, sizeof(void *));
68422 +
68423 + if (!polstate->subj_map_set.s_hash || !polstate->acl_role_set.r_hash ||
68424 + !polstate->name_set.n_hash || !polstate->inodev_set.i_hash)
68425 + return 1;
68426 +
68427 + memset(polstate->subj_map_set.s_hash, 0,
68428 + sizeof(struct subject_map *) * polstate->subj_map_set.s_size);
68429 + memset(polstate->acl_role_set.r_hash, 0,
68430 + sizeof (struct acl_role_label *) * polstate->acl_role_set.r_size);
68431 + memset(polstate->name_set.n_hash, 0,
68432 + sizeof (struct name_entry *) * polstate->name_set.n_size);
68433 + memset(polstate->inodev_set.i_hash, 0,
68434 + sizeof (struct inodev_entry *) * polstate->inodev_set.i_size);
68435 +
68436 + return 0;
68437 +}
68438 +
68439 +/* free information not needed after startup
68440 + currently contains user->kernel pointer mappings for subjects
68441 +*/
68442 +
68443 +static void
68444 +free_init_variables(void)
68445 +{
68446 + __u32 i;
68447 +
68448 + if (polstate->subj_map_set.s_hash) {
68449 + for (i = 0; i < polstate->subj_map_set.s_size; i++) {
68450 + if (polstate->subj_map_set.s_hash[i]) {
68451 + kfree(polstate->subj_map_set.s_hash[i]);
68452 + polstate->subj_map_set.s_hash[i] = NULL;
68453 + }
68454 + }
68455 +
68456 + if ((polstate->subj_map_set.s_size * sizeof (struct subject_map *)) <=
68457 + PAGE_SIZE)
68458 + kfree(polstate->subj_map_set.s_hash);
68459 + else
68460 + vfree(polstate->subj_map_set.s_hash);
68461 + }
68462 +
68463 + return;
68464 +}
68465 +
68466 +static void
68467 +free_variables(bool reload)
68468 +{
68469 + struct acl_subject_label *s;
68470 + struct acl_role_label *r;
68471 + struct task_struct *task, *task2;
68472 + unsigned int x;
68473 +
68474 + if (!reload) {
68475 + gr_clear_learn_entries();
68476 +
68477 + read_lock(&tasklist_lock);
68478 + do_each_thread(task2, task) {
68479 + task->acl_sp_role = 0;
68480 + task->acl_role_id = 0;
68481 + task->inherited = 0;
68482 + task->acl = NULL;
68483 + task->role = NULL;
68484 + } while_each_thread(task2, task);
68485 + read_unlock(&tasklist_lock);
68486 +
68487 + kfree(fakefs_obj_rw);
68488 + fakefs_obj_rw = NULL;
68489 + kfree(fakefs_obj_rwx);
68490 + fakefs_obj_rwx = NULL;
68491 +
68492 + /* release the reference to the real root dentry and vfsmount */
68493 + path_put(&gr_real_root);
68494 + memset(&gr_real_root, 0, sizeof(gr_real_root));
68495 + }
68496 +
68497 + /* free all object hash tables */
68498 +
68499 + FOR_EACH_ROLE_START(r)
68500 + if (r->subj_hash == NULL)
68501 + goto next_role;
68502 + FOR_EACH_SUBJECT_START(r, s, x)
68503 + if (s->obj_hash == NULL)
68504 + break;
68505 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
68506 + kfree(s->obj_hash);
68507 + else
68508 + vfree(s->obj_hash);
68509 + FOR_EACH_SUBJECT_END(s, x)
68510 + FOR_EACH_NESTED_SUBJECT_START(r, s)
68511 + if (s->obj_hash == NULL)
68512 + break;
68513 + if ((s->obj_hash_size * sizeof (struct acl_object_label *)) <= PAGE_SIZE)
68514 + kfree(s->obj_hash);
68515 + else
68516 + vfree(s->obj_hash);
68517 + FOR_EACH_NESTED_SUBJECT_END(s)
68518 + if ((r->subj_hash_size * sizeof (struct acl_subject_label *)) <= PAGE_SIZE)
68519 + kfree(r->subj_hash);
68520 + else
68521 + vfree(r->subj_hash);
68522 + r->subj_hash = NULL;
68523 +next_role:
68524 + FOR_EACH_ROLE_END(r)
68525 +
68526 + acl_free_all();
68527 +
68528 + if (polstate->acl_role_set.r_hash) {
68529 + if ((polstate->acl_role_set.r_size * sizeof (struct acl_role_label *)) <=
68530 + PAGE_SIZE)
68531 + kfree(polstate->acl_role_set.r_hash);
68532 + else
68533 + vfree(polstate->acl_role_set.r_hash);
68534 + }
68535 + if (polstate->name_set.n_hash) {
68536 + if ((polstate->name_set.n_size * sizeof (struct name_entry *)) <=
68537 + PAGE_SIZE)
68538 + kfree(polstate->name_set.n_hash);
68539 + else
68540 + vfree(polstate->name_set.n_hash);
68541 + }
68542 +
68543 + if (polstate->inodev_set.i_hash) {
68544 + if ((polstate->inodev_set.i_size * sizeof (struct inodev_entry *)) <=
68545 + PAGE_SIZE)
68546 + kfree(polstate->inodev_set.i_hash);
68547 + else
68548 + vfree(polstate->inodev_set.i_hash);
68549 + }
68550 +
68551 + if (!reload)
68552 + gr_free_uidset();
68553 +
68554 + memset(&polstate->name_set, 0, sizeof (struct name_db));
68555 + memset(&polstate->inodev_set, 0, sizeof (struct inodev_db));
68556 + memset(&polstate->acl_role_set, 0, sizeof (struct acl_role_db));
68557 + memset(&polstate->subj_map_set, 0, sizeof (struct acl_subj_map_db));
68558 +
68559 + polstate->default_role = NULL;
68560 + polstate->kernel_role = NULL;
68561 + polstate->role_list = NULL;
68562 +
68563 + return;
68564 +}
68565 +
68566 +static struct acl_subject_label *
68567 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied);
68568 +
68569 +static int alloc_and_copy_string(char **name, unsigned int maxlen)
68570 +{
68571 + unsigned int len = strnlen_user(*name, maxlen);
68572 + char *tmp;
68573 +
68574 + if (!len || len >= maxlen)
68575 + return -EINVAL;
68576 +
68577 + if ((tmp = (char *) acl_alloc(len)) == NULL)
68578 + return -ENOMEM;
68579 +
68580 + if (copy_from_user(tmp, *name, len))
68581 + return -EFAULT;
68582 +
68583 + tmp[len-1] = '\0';
68584 + *name = tmp;
68585 +
68586 + return 0;
68587 +}
68588 +
68589 +static int
68590 +copy_user_glob(struct acl_object_label *obj)
68591 +{
68592 + struct acl_object_label *g_tmp, **guser;
68593 + int error;
68594 +
68595 + if (obj->globbed == NULL)
68596 + return 0;
68597 +
68598 + guser = &obj->globbed;
68599 + while (*guser) {
68600 + g_tmp = (struct acl_object_label *)
68601 + acl_alloc(sizeof (struct acl_object_label));
68602 + if (g_tmp == NULL)
68603 + return -ENOMEM;
68604 +
68605 + if (copy_acl_object_label(g_tmp, *guser))
68606 + return -EFAULT;
68607 +
68608 + error = alloc_and_copy_string(&g_tmp->filename, PATH_MAX);
68609 + if (error)
68610 + return error;
68611 +
68612 + *guser = g_tmp;
68613 + guser = &(g_tmp->next);
68614 + }
68615 +
68616 + return 0;
68617 +}
68618 +
68619 +static int
68620 +copy_user_objs(struct acl_object_label *userp, struct acl_subject_label *subj,
68621 + struct acl_role_label *role)
68622 +{
68623 + struct acl_object_label *o_tmp;
68624 + int ret;
68625 +
68626 + while (userp) {
68627 + if ((o_tmp = (struct acl_object_label *)
68628 + acl_alloc(sizeof (struct acl_object_label))) == NULL)
68629 + return -ENOMEM;
68630 +
68631 + if (copy_acl_object_label(o_tmp, userp))
68632 + return -EFAULT;
68633 +
68634 + userp = o_tmp->prev;
68635 +
68636 + ret = alloc_and_copy_string(&o_tmp->filename, PATH_MAX);
68637 + if (ret)
68638 + return ret;
68639 +
68640 + insert_acl_obj_label(o_tmp, subj);
68641 + if (!insert_name_entry(o_tmp->filename, o_tmp->inode,
68642 + o_tmp->device, (o_tmp->mode & GR_DELETED) ? 1 : 0))
68643 + return -ENOMEM;
68644 +
68645 + ret = copy_user_glob(o_tmp);
68646 + if (ret)
68647 + return ret;
68648 +
68649 + if (o_tmp->nested) {
68650 + int already_copied;
68651 +
68652 + o_tmp->nested = do_copy_user_subj(o_tmp->nested, role, &already_copied);
68653 + if (IS_ERR(o_tmp->nested))
68654 + return PTR_ERR(o_tmp->nested);
68655 +
68656 + /* insert into nested subject list if we haven't copied this one yet
68657 + to prevent duplicate entries */
68658 + if (!already_copied) {
68659 + o_tmp->nested->next = role->hash->first;
68660 + role->hash->first = o_tmp->nested;
68661 + }
68662 + }
68663 + }
68664 +
68665 + return 0;
68666 +}
68667 +
68668 +static __u32
68669 +count_user_subjs(struct acl_subject_label *userp)
68670 +{
68671 + struct acl_subject_label s_tmp;
68672 + __u32 num = 0;
68673 +
68674 + while (userp) {
68675 + if (copy_acl_subject_label(&s_tmp, userp))
68676 + break;
68677 +
68678 + userp = s_tmp.prev;
68679 + }
68680 +
68681 + return num;
68682 +}
68683 +
68684 +static int
68685 +copy_user_allowedips(struct acl_role_label *rolep)
68686 +{
68687 + struct role_allowed_ip *ruserip, *rtmp = NULL, *rlast;
68688 +
68689 + ruserip = rolep->allowed_ips;
68690 +
68691 + while (ruserip) {
68692 + rlast = rtmp;
68693 +
68694 + if ((rtmp = (struct role_allowed_ip *)
68695 + acl_alloc(sizeof (struct role_allowed_ip))) == NULL)
68696 + return -ENOMEM;
68697 +
68698 + if (copy_role_allowed_ip(rtmp, ruserip))
68699 + return -EFAULT;
68700 +
68701 + ruserip = rtmp->prev;
68702 +
68703 + if (!rlast) {
68704 + rtmp->prev = NULL;
68705 + rolep->allowed_ips = rtmp;
68706 + } else {
68707 + rlast->next = rtmp;
68708 + rtmp->prev = rlast;
68709 + }
68710 +
68711 + if (!ruserip)
68712 + rtmp->next = NULL;
68713 + }
68714 +
68715 + return 0;
68716 +}
68717 +
68718 +static int
68719 +copy_user_transitions(struct acl_role_label *rolep)
68720 +{
68721 + struct role_transition *rusertp, *rtmp = NULL, *rlast;
68722 + int error;
68723 +
68724 + rusertp = rolep->transitions;
68725 +
68726 + while (rusertp) {
68727 + rlast = rtmp;
68728 +
68729 + if ((rtmp = (struct role_transition *)
68730 + acl_alloc(sizeof (struct role_transition))) == NULL)
68731 + return -ENOMEM;
68732 +
68733 + if (copy_role_transition(rtmp, rusertp))
68734 + return -EFAULT;
68735 +
68736 + rusertp = rtmp->prev;
68737 +
68738 + error = alloc_and_copy_string(&rtmp->rolename, GR_SPROLE_LEN);
68739 + if (error)
68740 + return error;
68741 +
68742 + if (!rlast) {
68743 + rtmp->prev = NULL;
68744 + rolep->transitions = rtmp;
68745 + } else {
68746 + rlast->next = rtmp;
68747 + rtmp->prev = rlast;
68748 + }
68749 +
68750 + if (!rusertp)
68751 + rtmp->next = NULL;
68752 + }
68753 +
68754 + return 0;
68755 +}
68756 +
68757 +static __u32 count_user_objs(const struct acl_object_label __user *userp)
68758 +{
68759 + struct acl_object_label o_tmp;
68760 + __u32 num = 0;
68761 +
68762 + while (userp) {
68763 + if (copy_acl_object_label(&o_tmp, userp))
68764 + break;
68765 +
68766 + userp = o_tmp.prev;
68767 + num++;
68768 + }
68769 +
68770 + return num;
68771 +}
68772 +
68773 +static struct acl_subject_label *
68774 +do_copy_user_subj(struct acl_subject_label *userp, struct acl_role_label *role, int *already_copied)
68775 +{
68776 + struct acl_subject_label *s_tmp = NULL, *s_tmp2;
68777 + __u32 num_objs;
68778 + struct acl_ip_label **i_tmp, *i_utmp2;
68779 + struct gr_hash_struct ghash;
68780 + struct subject_map *subjmap;
68781 + unsigned int i_num;
68782 + int err;
68783 +
68784 + if (already_copied != NULL)
68785 + *already_copied = 0;
68786 +
68787 + s_tmp = lookup_subject_map(userp);
68788 +
68789 + /* we've already copied this subject into the kernel, just return
68790 + the reference to it, and don't copy it over again
68791 + */
68792 + if (s_tmp) {
68793 + if (already_copied != NULL)
68794 + *already_copied = 1;
68795 + return(s_tmp);
68796 + }
68797 +
68798 + if ((s_tmp = (struct acl_subject_label *)
68799 + acl_alloc(sizeof (struct acl_subject_label))) == NULL)
68800 + return ERR_PTR(-ENOMEM);
68801 +
68802 + subjmap = (struct subject_map *)kmalloc(sizeof (struct subject_map), GFP_KERNEL);
68803 + if (subjmap == NULL)
68804 + return ERR_PTR(-ENOMEM);
68805 +
68806 + subjmap->user = userp;
68807 + subjmap->kernel = s_tmp;
68808 + insert_subj_map_entry(subjmap);
68809 +
68810 + if (copy_acl_subject_label(s_tmp, userp))
68811 + return ERR_PTR(-EFAULT);
68812 +
68813 + err = alloc_and_copy_string(&s_tmp->filename, PATH_MAX);
68814 + if (err)
68815 + return ERR_PTR(err);
68816 +
68817 + if (!strcmp(s_tmp->filename, "/"))
68818 + role->root_label = s_tmp;
68819 +
68820 + if (copy_gr_hash_struct(&ghash, s_tmp->hash))
68821 + return ERR_PTR(-EFAULT);
68822 +
68823 + /* copy user and group transition tables */
68824 +
68825 + if (s_tmp->user_trans_num) {
68826 + uid_t *uidlist;
68827 +
68828 + uidlist = (uid_t *)acl_alloc_num(s_tmp->user_trans_num, sizeof(uid_t));
68829 + if (uidlist == NULL)
68830 + return ERR_PTR(-ENOMEM);
68831 + if (copy_from_user(uidlist, s_tmp->user_transitions, s_tmp->user_trans_num * sizeof(uid_t)))
68832 + return ERR_PTR(-EFAULT);
68833 +
68834 + s_tmp->user_transitions = uidlist;
68835 + }
68836 +
68837 + if (s_tmp->group_trans_num) {
68838 + gid_t *gidlist;
68839 +
68840 + gidlist = (gid_t *)acl_alloc_num(s_tmp->group_trans_num, sizeof(gid_t));
68841 + if (gidlist == NULL)
68842 + return ERR_PTR(-ENOMEM);
68843 + if (copy_from_user(gidlist, s_tmp->group_transitions, s_tmp->group_trans_num * sizeof(gid_t)))
68844 + return ERR_PTR(-EFAULT);
68845 +
68846 + s_tmp->group_transitions = gidlist;
68847 + }
68848 +
68849 + /* set up object hash table */
68850 + num_objs = count_user_objs(ghash.first);
68851 +
68852 + s_tmp->obj_hash_size = num_objs;
68853 + s_tmp->obj_hash =
68854 + (struct acl_object_label **)
68855 + create_table(&(s_tmp->obj_hash_size), sizeof(void *));
68856 +
68857 + if (!s_tmp->obj_hash)
68858 + return ERR_PTR(-ENOMEM);
68859 +
68860 + memset(s_tmp->obj_hash, 0,
68861 + s_tmp->obj_hash_size *
68862 + sizeof (struct acl_object_label *));
68863 +
68864 + /* add in objects */
68865 + err = copy_user_objs(ghash.first, s_tmp, role);
68866 +
68867 + if (err)
68868 + return ERR_PTR(err);
68869 +
68870 + /* set pointer for parent subject */
68871 + if (s_tmp->parent_subject) {
68872 + s_tmp2 = do_copy_user_subj(s_tmp->parent_subject, role, NULL);
68873 +
68874 + if (IS_ERR(s_tmp2))
68875 + return s_tmp2;
68876 +
68877 + s_tmp->parent_subject = s_tmp2;
68878 + }
68879 +
68880 + /* add in ip acls */
68881 +
68882 + if (!s_tmp->ip_num) {
68883 + s_tmp->ips = NULL;
68884 + goto insert;
68885 + }
68886 +
68887 + i_tmp =
68888 + (struct acl_ip_label **) acl_alloc_num(s_tmp->ip_num,
68889 + sizeof (struct acl_ip_label *));
68890 +
68891 + if (!i_tmp)
68892 + return ERR_PTR(-ENOMEM);
68893 +
68894 + for (i_num = 0; i_num < s_tmp->ip_num; i_num++) {
68895 + *(i_tmp + i_num) =
68896 + (struct acl_ip_label *)
68897 + acl_alloc(sizeof (struct acl_ip_label));
68898 + if (!*(i_tmp + i_num))
68899 + return ERR_PTR(-ENOMEM);
68900 +
68901 + if (copy_pointer_from_array(&i_utmp2, i_num, s_tmp->ips))
68902 + return ERR_PTR(-EFAULT);
68903 +
68904 + if (copy_acl_ip_label(*(i_tmp + i_num), i_utmp2))
68905 + return ERR_PTR(-EFAULT);
68906 +
68907 + if ((*(i_tmp + i_num))->iface == NULL)
68908 + continue;
68909 +
68910 + err = alloc_and_copy_string(&(*(i_tmp + i_num))->iface, IFNAMSIZ);
68911 + if (err)
68912 + return ERR_PTR(err);
68913 + }
68914 +
68915 + s_tmp->ips = i_tmp;
68916 +
68917 +insert:
68918 + if (!insert_name_entry(s_tmp->filename, s_tmp->inode,
68919 + s_tmp->device, (s_tmp->mode & GR_DELETED) ? 1 : 0))
68920 + return ERR_PTR(-ENOMEM);
68921 +
68922 + return s_tmp;
68923 +}
68924 +
68925 +static int
68926 +copy_user_subjs(struct acl_subject_label *userp, struct acl_role_label *role)
68927 +{
68928 + struct acl_subject_label s_pre;
68929 + struct acl_subject_label * ret;
68930 + int err;
68931 +
68932 + while (userp) {
68933 + if (copy_acl_subject_label(&s_pre, userp))
68934 + return -EFAULT;
68935 +
68936 + ret = do_copy_user_subj(userp, role, NULL);
68937 +
68938 + err = PTR_ERR(ret);
68939 + if (IS_ERR(ret))
68940 + return err;
68941 +
68942 + insert_acl_subj_label(ret, role);
68943 +
68944 + userp = s_pre.prev;
68945 + }
68946 +
68947 + return 0;
68948 +}
68949 +
68950 +static int
68951 +copy_user_acl(struct gr_arg *arg)
68952 +{
68953 + struct acl_role_label *r_tmp = NULL, **r_utmp, *r_utmp2;
68954 + struct acl_subject_label *subj_list;
68955 + struct sprole_pw *sptmp;
68956 + struct gr_hash_struct *ghash;
68957 + uid_t *domainlist;
68958 + unsigned int r_num;
68959 + int err = 0;
68960 + __u16 i;
68961 + __u32 num_subjs;
68962 +
68963 + /* we need a default and kernel role */
68964 + if (arg->role_db.num_roles < 2)
68965 + return -EINVAL;
68966 +
68967 + /* copy special role authentication info from userspace */
68968 +
68969 + polstate->num_sprole_pws = arg->num_sprole_pws;
68970 + polstate->acl_special_roles = (struct sprole_pw **) acl_alloc_num(polstate->num_sprole_pws, sizeof(struct sprole_pw *));
68971 +
68972 + if (!polstate->acl_special_roles && polstate->num_sprole_pws)
68973 + return -ENOMEM;
68974 +
68975 + for (i = 0; i < polstate->num_sprole_pws; i++) {
68976 + sptmp = (struct sprole_pw *) acl_alloc(sizeof(struct sprole_pw));
68977 + if (!sptmp)
68978 + return -ENOMEM;
68979 + if (copy_sprole_pw(sptmp, i, arg->sprole_pws))
68980 + return -EFAULT;
68981 +
68982 + err = alloc_and_copy_string((char **)&sptmp->rolename, GR_SPROLE_LEN);
68983 + if (err)
68984 + return err;
68985 +
68986 +#ifdef CONFIG_GRKERNSEC_RBAC_DEBUG
68987 + printk(KERN_ALERT "Copying special role %s\n", sptmp->rolename);
68988 +#endif
68989 +
68990 + polstate->acl_special_roles[i] = sptmp;
68991 + }
68992 +
68993 + r_utmp = (struct acl_role_label **) arg->role_db.r_table;
68994 +
68995 + for (r_num = 0; r_num < arg->role_db.num_roles; r_num++) {
68996 + r_tmp = acl_alloc(sizeof (struct acl_role_label));
68997 +
68998 + if (!r_tmp)
68999 + return -ENOMEM;
69000 +
69001 + if (copy_pointer_from_array(&r_utmp2, r_num, r_utmp))
69002 + return -EFAULT;
69003 +
69004 + if (copy_acl_role_label(r_tmp, r_utmp2))
69005 + return -EFAULT;
69006 +
69007 + err = alloc_and_copy_string(&r_tmp->rolename, GR_SPROLE_LEN);
69008 + if (err)
69009 + return err;
69010 +
69011 + if (!strcmp(r_tmp->rolename, "default")
69012 + && (r_tmp->roletype & GR_ROLE_DEFAULT)) {
69013 + polstate->default_role = r_tmp;
69014 + } else if (!strcmp(r_tmp->rolename, ":::kernel:::")) {
69015 + polstate->kernel_role = r_tmp;
69016 + }
69017 +
69018 + if ((ghash = (struct gr_hash_struct *) acl_alloc(sizeof(struct gr_hash_struct))) == NULL)
69019 + return -ENOMEM;
69020 +
69021 + if (copy_gr_hash_struct(ghash, r_tmp->hash))
69022 + return -EFAULT;
69023 +
69024 + r_tmp->hash = ghash;
69025 +
69026 + num_subjs = count_user_subjs(r_tmp->hash->first);
69027 +
69028 + r_tmp->subj_hash_size = num_subjs;
69029 + r_tmp->subj_hash =
69030 + (struct acl_subject_label **)
69031 + create_table(&(r_tmp->subj_hash_size), sizeof(void *));
69032 +
69033 + if (!r_tmp->subj_hash)
69034 + return -ENOMEM;
69035 +
69036 + err = copy_user_allowedips(r_tmp);
69037 + if (err)
69038 + return err;
69039 +
69040 + /* copy domain info */
69041 + if (r_tmp->domain_children != NULL) {
69042 + domainlist = acl_alloc_num(r_tmp->domain_child_num, sizeof(uid_t));
69043 + if (domainlist == NULL)
69044 + return -ENOMEM;
69045 +
69046 + if (copy_from_user(domainlist, r_tmp->domain_children, r_tmp->domain_child_num * sizeof(uid_t)))
69047 + return -EFAULT;
69048 +
69049 + r_tmp->domain_children = domainlist;
69050 + }
69051 +
69052 + err = copy_user_transitions(r_tmp);
69053 + if (err)
69054 + return err;
69055 +
69056 + memset(r_tmp->subj_hash, 0,
69057 + r_tmp->subj_hash_size *
69058 + sizeof (struct acl_subject_label *));
69059 +
69060 + /* acquire the list of subjects, then NULL out
69061 + the list prior to parsing the subjects for this role,
69062 + as during this parsing the list is replaced with a list
69063 + of *nested* subjects for the role
69064 + */
69065 + subj_list = r_tmp->hash->first;
69066 +
69067 + /* set nested subject list to null */
69068 + r_tmp->hash->first = NULL;
69069 +
69070 + err = copy_user_subjs(subj_list, r_tmp);
69071 +
69072 + if (err)
69073 + return err;
69074 +
69075 + insert_acl_role_label(r_tmp);
69076 + }
69077 +
69078 + if (polstate->default_role == NULL || polstate->kernel_role == NULL)
69079 + return -EINVAL;
69080 +
69081 + return err;
69082 +}
69083 +
69084 +static int gracl_reload_apply_policies(void *reload)
69085 +{
69086 + struct gr_reload_state *reload_state = (struct gr_reload_state *)reload;
69087 + struct task_struct *task, *task2;
69088 + struct acl_role_label *role, *rtmp;
69089 + struct acl_subject_label *subj;
69090 + const struct cred *cred;
69091 + int role_applied;
69092 + int ret = 0;
69093 +
69094 + memcpy(&reload_state->oldpolicy, reload_state->oldpolicy_ptr, sizeof(struct gr_policy_state));
69095 + memcpy(&reload_state->oldalloc, reload_state->oldalloc_ptr, sizeof(struct gr_alloc_state));
69096 +
69097 + /* first make sure we'll be able to apply the new policy cleanly */
69098 + do_each_thread(task2, task) {
69099 + if (task->exec_file == NULL)
69100 + continue;
69101 + role_applied = 0;
69102 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
69103 + /* preserve special roles */
69104 + FOR_EACH_ROLE_START(role)
69105 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
69106 + rtmp = task->role;
69107 + task->role = role;
69108 + role_applied = 1;
69109 + break;
69110 + }
69111 + FOR_EACH_ROLE_END(role)
69112 + }
69113 + if (!role_applied) {
69114 + cred = __task_cred(task);
69115 + rtmp = task->role;
69116 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69117 + }
69118 + /* this handles non-nested inherited subjects, nested subjects will still
69119 + be dropped currently */
69120 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
69121 + task->tmpacl = __gr_get_subject_for_task(polstate, task, NULL);
69122 + /* change the role back so that we've made no modifications to the policy */
69123 + task->role = rtmp;
69124 +
69125 + if (subj == NULL || task->tmpacl == NULL) {
69126 + ret = -EINVAL;
69127 + goto out;
69128 + }
69129 + } while_each_thread(task2, task);
69130 +
69131 + /* now actually apply the policy */
69132 +
69133 + do_each_thread(task2, task) {
69134 + if (task->exec_file) {
69135 + role_applied = 0;
69136 + if (!reload_state->oldmode && task->role->roletype & GR_ROLE_SPECIAL) {
69137 + /* preserve special roles */
69138 + FOR_EACH_ROLE_START(role)
69139 + if ((role->roletype & GR_ROLE_SPECIAL) && !strcmp(task->role->rolename, role->rolename)) {
69140 + task->role = role;
69141 + role_applied = 1;
69142 + break;
69143 + }
69144 + FOR_EACH_ROLE_END(role)
69145 + }
69146 + if (!role_applied) {
69147 + cred = __task_cred(task);
69148 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69149 + }
69150 + /* this handles non-nested inherited subjects, nested subjects will still
69151 + be dropped currently */
69152 + if (!reload_state->oldmode && task->inherited)
69153 + subj = __gr_get_subject_for_task(polstate, task, task->acl->filename);
69154 + else {
69155 + /* looked up and tagged to the task previously */
69156 + subj = task->tmpacl;
69157 + }
69158 + /* subj will be non-null */
69159 + __gr_apply_subject_to_task(polstate, task, subj);
69160 + if (reload_state->oldmode) {
69161 + task->acl_role_id = 0;
69162 + task->acl_sp_role = 0;
69163 + task->inherited = 0;
69164 + }
69165 + } else {
69166 + // it's a kernel process
69167 + task->role = polstate->kernel_role;
69168 + task->acl = polstate->kernel_role->root_label;
69169 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
69170 + task->acl->mode &= ~GR_PROCFIND;
69171 +#endif
69172 + }
69173 + } while_each_thread(task2, task);
69174 +
69175 + memcpy(reload_state->oldpolicy_ptr, &reload_state->newpolicy, sizeof(struct gr_policy_state));
69176 + memcpy(reload_state->oldalloc_ptr, &reload_state->newalloc, sizeof(struct gr_alloc_state));
69177 +
69178 +out:
69179 +
69180 + return ret;
69181 +}
69182 +
69183 +static int gracl_reload(struct gr_arg *args, unsigned char oldmode)
69184 +{
69185 + struct gr_reload_state new_reload_state = { };
69186 + int err;
69187 +
69188 + new_reload_state.oldpolicy_ptr = polstate;
69189 + new_reload_state.oldalloc_ptr = current_alloc_state;
69190 + new_reload_state.oldmode = oldmode;
69191 +
69192 + current_alloc_state = &new_reload_state.newalloc;
69193 + polstate = &new_reload_state.newpolicy;
69194 +
69195 + /* everything relevant is now saved off, copy in the new policy */
69196 + if (init_variables(args, true)) {
69197 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
69198 + err = -ENOMEM;
69199 + goto error;
69200 + }
69201 +
69202 + err = copy_user_acl(args);
69203 + free_init_variables();
69204 + if (err)
69205 + goto error;
69206 + /* the new policy is copied in, with the old policy available via saved_state
69207 + first go through applying roles, making sure to preserve special roles
69208 + then apply new subjects, making sure to preserve inherited and nested subjects,
69209 + though currently only inherited subjects will be preserved
69210 + */
69211 + err = stop_machine(gracl_reload_apply_policies, &new_reload_state, NULL);
69212 + if (err)
69213 + goto error;
69214 +
69215 + /* we've now applied the new policy, so restore the old policy state to free it */
69216 + polstate = &new_reload_state.oldpolicy;
69217 + current_alloc_state = &new_reload_state.oldalloc;
69218 + free_variables(true);
69219 +
69220 + /* oldpolicy/oldalloc_ptr point to the new policy/alloc states as they were copied
69221 + to running_polstate/current_alloc_state inside stop_machine
69222 + */
69223 + err = 0;
69224 + goto out;
69225 +error:
69226 + /* on error of loading the new policy, we'll just keep the previous
69227 + policy set around
69228 + */
69229 + free_variables(true);
69230 +
69231 + /* doesn't affect runtime, but maintains consistent state */
69232 +out:
69233 + polstate = new_reload_state.oldpolicy_ptr;
69234 + current_alloc_state = new_reload_state.oldalloc_ptr;
69235 +
69236 + return err;
69237 +}
69238 +
69239 +static int
69240 +gracl_init(struct gr_arg *args)
69241 +{
69242 + int error = 0;
69243 +
69244 + memcpy(&gr_system_salt, args->salt, sizeof(gr_system_salt));
69245 + memcpy(&gr_system_sum, args->sum, sizeof(gr_system_sum));
69246 +
69247 + if (init_variables(args, false)) {
69248 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_INITF_ACL_MSG, GR_VERSION);
69249 + error = -ENOMEM;
69250 + goto out;
69251 + }
69252 +
69253 + error = copy_user_acl(args);
69254 + free_init_variables();
69255 + if (error)
69256 + goto out;
69257 +
69258 + error = gr_set_acls(0);
69259 + if (error)
69260 + goto out;
69261 +
69262 + gr_enable_rbac_system();
69263 +
69264 + return 0;
69265 +
69266 +out:
69267 + free_variables(false);
69268 + return error;
69269 +}
69270 +
69271 +static int
69272 +lookup_special_role_auth(__u16 mode, const char *rolename, unsigned char **salt,
69273 + unsigned char **sum)
69274 +{
69275 + struct acl_role_label *r;
69276 + struct role_allowed_ip *ipp;
69277 + struct role_transition *trans;
69278 + unsigned int i;
69279 + int found = 0;
69280 + u32 curr_ip = current->signal->curr_ip;
69281 +
69282 + current->signal->saved_ip = curr_ip;
69283 +
69284 + /* check transition table */
69285 +
69286 + for (trans = current->role->transitions; trans; trans = trans->next) {
69287 + if (!strcmp(rolename, trans->rolename)) {
69288 + found = 1;
69289 + break;
69290 + }
69291 + }
69292 +
69293 + if (!found)
69294 + return 0;
69295 +
69296 + /* handle special roles that do not require authentication
69297 + and check ip */
69298 +
69299 + FOR_EACH_ROLE_START(r)
69300 + if (!strcmp(rolename, r->rolename) &&
69301 + (r->roletype & GR_ROLE_SPECIAL)) {
69302 + found = 0;
69303 + if (r->allowed_ips != NULL) {
69304 + for (ipp = r->allowed_ips; ipp; ipp = ipp->next) {
69305 + if ((ntohl(curr_ip) & ipp->netmask) ==
69306 + (ntohl(ipp->addr) & ipp->netmask))
69307 + found = 1;
69308 + }
69309 + } else
69310 + found = 2;
69311 + if (!found)
69312 + return 0;
69313 +
69314 + if (((mode == GR_SPROLE) && (r->roletype & GR_ROLE_NOPW)) ||
69315 + ((mode == GR_SPROLEPAM) && (r->roletype & GR_ROLE_PAM))) {
69316 + *salt = NULL;
69317 + *sum = NULL;
69318 + return 1;
69319 + }
69320 + }
69321 + FOR_EACH_ROLE_END(r)
69322 +
69323 + for (i = 0; i < polstate->num_sprole_pws; i++) {
69324 + if (!strcmp(rolename, polstate->acl_special_roles[i]->rolename)) {
69325 + *salt = polstate->acl_special_roles[i]->salt;
69326 + *sum = polstate->acl_special_roles[i]->sum;
69327 + return 1;
69328 + }
69329 + }
69330 +
69331 + return 0;
69332 +}
69333 +
69334 +int gr_check_secure_terminal(struct task_struct *task)
69335 +{
69336 + struct task_struct *p, *p2, *p3;
69337 + struct files_struct *files;
69338 + struct fdtable *fdt;
69339 + struct file *our_file = NULL, *file;
69340 + int i;
69341 +
69342 + if (task->signal->tty == NULL)
69343 + return 1;
69344 +
69345 + files = get_files_struct(task);
69346 + if (files != NULL) {
69347 + rcu_read_lock();
69348 + fdt = files_fdtable(files);
69349 + for (i=0; i < fdt->max_fds; i++) {
69350 + file = fcheck_files(files, i);
69351 + if (file && (our_file == NULL) && (file->private_data == task->signal->tty)) {
69352 + get_file(file);
69353 + our_file = file;
69354 + }
69355 + }
69356 + rcu_read_unlock();
69357 + put_files_struct(files);
69358 + }
69359 +
69360 + if (our_file == NULL)
69361 + return 1;
69362 +
69363 + read_lock(&tasklist_lock);
69364 + do_each_thread(p2, p) {
69365 + files = get_files_struct(p);
69366 + if (files == NULL ||
69367 + (p->signal && p->signal->tty == task->signal->tty)) {
69368 + if (files != NULL)
69369 + put_files_struct(files);
69370 + continue;
69371 + }
69372 + rcu_read_lock();
69373 + fdt = files_fdtable(files);
69374 + for (i=0; i < fdt->max_fds; i++) {
69375 + file = fcheck_files(files, i);
69376 + if (file && S_ISCHR(file->f_path.dentry->d_inode->i_mode) &&
69377 + file->f_path.dentry->d_inode->i_rdev == our_file->f_path.dentry->d_inode->i_rdev) {
69378 + p3 = task;
69379 + while (task_pid_nr(p3) > 0) {
69380 + if (p3 == p)
69381 + break;
69382 + p3 = p3->real_parent;
69383 + }
69384 + if (p3 == p)
69385 + break;
69386 + gr_log_ttysniff(GR_DONT_AUDIT_GOOD, GR_TTYSNIFF_ACL_MSG, p);
69387 + gr_handle_alertkill(p);
69388 + rcu_read_unlock();
69389 + put_files_struct(files);
69390 + read_unlock(&tasklist_lock);
69391 + fput(our_file);
69392 + return 0;
69393 + }
69394 + }
69395 + rcu_read_unlock();
69396 + put_files_struct(files);
69397 + } while_each_thread(p2, p);
69398 + read_unlock(&tasklist_lock);
69399 +
69400 + fput(our_file);
69401 + return 1;
69402 +}
69403 +
69404 +ssize_t
69405 +write_grsec_handler(struct file *file, const char __user * buf, size_t count, loff_t *ppos)
69406 +{
69407 + struct gr_arg_wrapper uwrap;
69408 + unsigned char *sprole_salt = NULL;
69409 + unsigned char *sprole_sum = NULL;
69410 + int error = 0;
69411 + int error2 = 0;
69412 + size_t req_count = 0;
69413 + unsigned char oldmode = 0;
69414 +
69415 + mutex_lock(&gr_dev_mutex);
69416 +
69417 + if (gr_acl_is_enabled() && !(current->acl->mode & GR_KERNELAUTH)) {
69418 + error = -EPERM;
69419 + goto out;
69420 + }
69421 +
69422 +#ifdef CONFIG_COMPAT
69423 + pax_open_kernel();
69424 + if (is_compat_task()) {
69425 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_compat;
69426 + copy_gr_arg = &copy_gr_arg_compat;
69427 + copy_acl_object_label = &copy_acl_object_label_compat;
69428 + copy_acl_subject_label = &copy_acl_subject_label_compat;
69429 + copy_acl_role_label = &copy_acl_role_label_compat;
69430 + copy_acl_ip_label = &copy_acl_ip_label_compat;
69431 + copy_role_allowed_ip = &copy_role_allowed_ip_compat;
69432 + copy_role_transition = &copy_role_transition_compat;
69433 + copy_sprole_pw = &copy_sprole_pw_compat;
69434 + copy_gr_hash_struct = &copy_gr_hash_struct_compat;
69435 + copy_pointer_from_array = &copy_pointer_from_array_compat;
69436 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_compat;
69437 + } else {
69438 + copy_gr_arg_wrapper = &copy_gr_arg_wrapper_normal;
69439 + copy_gr_arg = &copy_gr_arg_normal;
69440 + copy_acl_object_label = &copy_acl_object_label_normal;
69441 + copy_acl_subject_label = &copy_acl_subject_label_normal;
69442 + copy_acl_role_label = &copy_acl_role_label_normal;
69443 + copy_acl_ip_label = &copy_acl_ip_label_normal;
69444 + copy_role_allowed_ip = &copy_role_allowed_ip_normal;
69445 + copy_role_transition = &copy_role_transition_normal;
69446 + copy_sprole_pw = &copy_sprole_pw_normal;
69447 + copy_gr_hash_struct = &copy_gr_hash_struct_normal;
69448 + copy_pointer_from_array = &copy_pointer_from_array_normal;
69449 + get_gr_arg_wrapper_size = &get_gr_arg_wrapper_size_normal;
69450 + }
69451 + pax_close_kernel();
69452 +#endif
69453 +
69454 + req_count = get_gr_arg_wrapper_size();
69455 +
69456 + if (count != req_count) {
69457 + gr_log_int_int(GR_DONT_AUDIT_GOOD, GR_DEV_ACL_MSG, (int)count, (int)req_count);
69458 + error = -EINVAL;
69459 + goto out;
69460 + }
69461 +
69462 +
69463 + if (gr_auth_expires && time_after_eq(get_seconds(), gr_auth_expires)) {
69464 + gr_auth_expires = 0;
69465 + gr_auth_attempts = 0;
69466 + }
69467 +
69468 + error = copy_gr_arg_wrapper(buf, &uwrap);
69469 + if (error)
69470 + goto out;
69471 +
69472 + error = copy_gr_arg(uwrap.arg, &gr_usermode);
69473 + if (error)
69474 + goto out;
69475 +
69476 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_SPROLEPAM &&
69477 + gr_auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
69478 + time_after(gr_auth_expires, get_seconds())) {
69479 + error = -EBUSY;
69480 + goto out;
69481 + }
69482 +
69483 + /* if non-root trying to do anything other than use a special role,
69484 + do not attempt authentication, do not count towards authentication
69485 + locking
69486 + */
69487 +
69488 + if (gr_usermode.mode != GR_SPROLE && gr_usermode.mode != GR_STATUS &&
69489 + gr_usermode.mode != GR_UNSPROLE && gr_usermode.mode != GR_SPROLEPAM &&
69490 + gr_is_global_nonroot(current_uid())) {
69491 + error = -EPERM;
69492 + goto out;
69493 + }
69494 +
69495 + /* ensure pw and special role name are null terminated */
69496 +
69497 + gr_usermode.pw[GR_PW_LEN - 1] = '\0';
69498 + gr_usermode.sp_role[GR_SPROLE_LEN - 1] = '\0';
69499 +
69500 + /* Okay.
69501 + * We have our enough of the argument structure..(we have yet
69502 + * to copy_from_user the tables themselves) . Copy the tables
69503 + * only if we need them, i.e. for loading operations. */
69504 +
69505 + switch (gr_usermode.mode) {
69506 + case GR_STATUS:
69507 + if (gr_acl_is_enabled()) {
69508 + error = 1;
69509 + if (!gr_check_secure_terminal(current))
69510 + error = 3;
69511 + } else
69512 + error = 2;
69513 + goto out;
69514 + case GR_SHUTDOWN:
69515 + if (gr_acl_is_enabled() && !(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69516 + stop_machine(gr_rbac_disable, NULL, NULL);
69517 + free_variables(false);
69518 + memset(&gr_usermode, 0, sizeof(gr_usermode));
69519 + memset(&gr_system_salt, 0, sizeof(gr_system_salt));
69520 + memset(&gr_system_sum, 0, sizeof(gr_system_sum));
69521 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTS_ACL_MSG);
69522 + } else if (gr_acl_is_enabled()) {
69523 + gr_log_noargs(GR_DONT_AUDIT, GR_SHUTF_ACL_MSG);
69524 + error = -EPERM;
69525 + } else {
69526 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SHUTI_ACL_MSG);
69527 + error = -EAGAIN;
69528 + }
69529 + break;
69530 + case GR_ENABLE:
69531 + if (!gr_acl_is_enabled() && !(error2 = gracl_init(&gr_usermode)))
69532 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_ENABLE_ACL_MSG, GR_VERSION);
69533 + else {
69534 + if (gr_acl_is_enabled())
69535 + error = -EAGAIN;
69536 + else
69537 + error = error2;
69538 + gr_log_str(GR_DONT_AUDIT, GR_ENABLEF_ACL_MSG, GR_VERSION);
69539 + }
69540 + break;
69541 + case GR_OLDRELOAD:
69542 + oldmode = 1;
69543 + case GR_RELOAD:
69544 + if (!gr_acl_is_enabled()) {
69545 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOADI_ACL_MSG, GR_VERSION);
69546 + error = -EAGAIN;
69547 + } else if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69548 + error2 = gracl_reload(&gr_usermode, oldmode);
69549 + if (!error2)
69550 + gr_log_str(GR_DONT_AUDIT_GOOD, GR_RELOAD_ACL_MSG, GR_VERSION);
69551 + else {
69552 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
69553 + error = error2;
69554 + }
69555 + } else {
69556 + gr_log_str(GR_DONT_AUDIT, GR_RELOADF_ACL_MSG, GR_VERSION);
69557 + error = -EPERM;
69558 + }
69559 + break;
69560 + case GR_SEGVMOD:
69561 + if (unlikely(!gr_acl_is_enabled())) {
69562 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODI_ACL_MSG);
69563 + error = -EAGAIN;
69564 + break;
69565 + }
69566 +
69567 + if (!(chkpw(&gr_usermode, (unsigned char *)&gr_system_salt, (unsigned char *)&gr_system_sum))) {
69568 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SEGVMODS_ACL_MSG);
69569 + if (gr_usermode.segv_device && gr_usermode.segv_inode) {
69570 + struct acl_subject_label *segvacl;
69571 + segvacl =
69572 + lookup_acl_subj_label(gr_usermode.segv_inode,
69573 + gr_usermode.segv_device,
69574 + current->role);
69575 + if (segvacl) {
69576 + segvacl->crashes = 0;
69577 + segvacl->expires = 0;
69578 + }
69579 + } else if (gr_find_uid(gr_usermode.segv_uid) >= 0) {
69580 + gr_remove_uid(gr_usermode.segv_uid);
69581 + }
69582 + } else {
69583 + gr_log_noargs(GR_DONT_AUDIT, GR_SEGVMODF_ACL_MSG);
69584 + error = -EPERM;
69585 + }
69586 + break;
69587 + case GR_SPROLE:
69588 + case GR_SPROLEPAM:
69589 + if (unlikely(!gr_acl_is_enabled())) {
69590 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_SPROLEI_ACL_MSG);
69591 + error = -EAGAIN;
69592 + break;
69593 + }
69594 +
69595 + if (current->role->expires && time_after_eq(get_seconds(), current->role->expires)) {
69596 + current->role->expires = 0;
69597 + current->role->auth_attempts = 0;
69598 + }
69599 +
69600 + if (current->role->auth_attempts >= CONFIG_GRKERNSEC_ACL_MAXTRIES &&
69601 + time_after(current->role->expires, get_seconds())) {
69602 + error = -EBUSY;
69603 + goto out;
69604 + }
69605 +
69606 + if (lookup_special_role_auth
69607 + (gr_usermode.mode, gr_usermode.sp_role, &sprole_salt, &sprole_sum)
69608 + && ((!sprole_salt && !sprole_sum)
69609 + || !(chkpw(&gr_usermode, sprole_salt, sprole_sum)))) {
69610 + char *p = "";
69611 + assign_special_role(gr_usermode.sp_role);
69612 + read_lock(&tasklist_lock);
69613 + if (current->real_parent)
69614 + p = current->real_parent->role->rolename;
69615 + read_unlock(&tasklist_lock);
69616 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_SPROLES_ACL_MSG,
69617 + p, acl_sp_role_value);
69618 + } else {
69619 + gr_log_str(GR_DONT_AUDIT, GR_SPROLEF_ACL_MSG, gr_usermode.sp_role);
69620 + error = -EPERM;
69621 + if(!(current->role->auth_attempts++))
69622 + current->role->expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
69623 +
69624 + goto out;
69625 + }
69626 + break;
69627 + case GR_UNSPROLE:
69628 + if (unlikely(!gr_acl_is_enabled())) {
69629 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_UNSPROLEI_ACL_MSG);
69630 + error = -EAGAIN;
69631 + break;
69632 + }
69633 +
69634 + if (current->role->roletype & GR_ROLE_SPECIAL) {
69635 + char *p = "";
69636 + int i = 0;
69637 +
69638 + read_lock(&tasklist_lock);
69639 + if (current->real_parent) {
69640 + p = current->real_parent->role->rolename;
69641 + i = current->real_parent->acl_role_id;
69642 + }
69643 + read_unlock(&tasklist_lock);
69644 +
69645 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_UNSPROLES_ACL_MSG, p, i);
69646 + gr_set_acls(1);
69647 + } else {
69648 + error = -EPERM;
69649 + goto out;
69650 + }
69651 + break;
69652 + default:
69653 + gr_log_int(GR_DONT_AUDIT, GR_INVMODE_ACL_MSG, gr_usermode.mode);
69654 + error = -EINVAL;
69655 + break;
69656 + }
69657 +
69658 + if (error != -EPERM)
69659 + goto out;
69660 +
69661 + if(!(gr_auth_attempts++))
69662 + gr_auth_expires = get_seconds() + CONFIG_GRKERNSEC_ACL_TIMEOUT;
69663 +
69664 + out:
69665 + mutex_unlock(&gr_dev_mutex);
69666 +
69667 + if (!error)
69668 + error = req_count;
69669 +
69670 + return error;
69671 +}
69672 +
69673 +int
69674 +gr_set_acls(const int type)
69675 +{
69676 + struct task_struct *task, *task2;
69677 + struct acl_role_label *role = current->role;
69678 + struct acl_subject_label *subj;
69679 + __u16 acl_role_id = current->acl_role_id;
69680 + const struct cred *cred;
69681 + int ret;
69682 +
69683 + rcu_read_lock();
69684 + read_lock(&tasklist_lock);
69685 + read_lock(&grsec_exec_file_lock);
69686 + do_each_thread(task2, task) {
69687 + /* check to see if we're called from the exit handler,
69688 + if so, only replace ACLs that have inherited the admin
69689 + ACL */
69690 +
69691 + if (type && (task->role != role ||
69692 + task->acl_role_id != acl_role_id))
69693 + continue;
69694 +
69695 + task->acl_role_id = 0;
69696 + task->acl_sp_role = 0;
69697 + task->inherited = 0;
69698 +
69699 + if (task->exec_file) {
69700 + cred = __task_cred(task);
69701 + task->role = __lookup_acl_role_label(polstate, task, GR_GLOBAL_UID(cred->uid), GR_GLOBAL_GID(cred->gid));
69702 + subj = __gr_get_subject_for_task(polstate, task, NULL);
69703 + if (subj == NULL) {
69704 + ret = -EINVAL;
69705 + read_unlock(&grsec_exec_file_lock);
69706 + read_unlock(&tasklist_lock);
69707 + rcu_read_unlock();
69708 + gr_log_str_int(GR_DONT_AUDIT_GOOD, GR_DEFACL_MSG, task->comm, task_pid_nr(task));
69709 + return ret;
69710 + }
69711 + __gr_apply_subject_to_task(polstate, task, subj);
69712 + } else {
69713 + // it's a kernel process
69714 + task->role = polstate->kernel_role;
69715 + task->acl = polstate->kernel_role->root_label;
69716 +#ifdef CONFIG_GRKERNSEC_ACL_HIDEKERN
69717 + task->acl->mode &= ~GR_PROCFIND;
69718 +#endif
69719 + }
69720 + } while_each_thread(task2, task);
69721 + read_unlock(&grsec_exec_file_lock);
69722 + read_unlock(&tasklist_lock);
69723 + rcu_read_unlock();
69724 +
69725 + return 0;
69726 +}
69727 diff --git a/grsecurity/gracl_res.c b/grsecurity/gracl_res.c
69728 new file mode 100644
69729 index 0000000..39645c9
69730 --- /dev/null
69731 +++ b/grsecurity/gracl_res.c
69732 @@ -0,0 +1,68 @@
69733 +#include <linux/kernel.h>
69734 +#include <linux/sched.h>
69735 +#include <linux/gracl.h>
69736 +#include <linux/grinternal.h>
69737 +
69738 +static const char *restab_log[] = {
69739 + [RLIMIT_CPU] = "RLIMIT_CPU",
69740 + [RLIMIT_FSIZE] = "RLIMIT_FSIZE",
69741 + [RLIMIT_DATA] = "RLIMIT_DATA",
69742 + [RLIMIT_STACK] = "RLIMIT_STACK",
69743 + [RLIMIT_CORE] = "RLIMIT_CORE",
69744 + [RLIMIT_RSS] = "RLIMIT_RSS",
69745 + [RLIMIT_NPROC] = "RLIMIT_NPROC",
69746 + [RLIMIT_NOFILE] = "RLIMIT_NOFILE",
69747 + [RLIMIT_MEMLOCK] = "RLIMIT_MEMLOCK",
69748 + [RLIMIT_AS] = "RLIMIT_AS",
69749 + [RLIMIT_LOCKS] = "RLIMIT_LOCKS",
69750 + [RLIMIT_SIGPENDING] = "RLIMIT_SIGPENDING",
69751 + [RLIMIT_MSGQUEUE] = "RLIMIT_MSGQUEUE",
69752 + [RLIMIT_NICE] = "RLIMIT_NICE",
69753 + [RLIMIT_RTPRIO] = "RLIMIT_RTPRIO",
69754 + [RLIMIT_RTTIME] = "RLIMIT_RTTIME",
69755 + [GR_CRASH_RES] = "RLIMIT_CRASH"
69756 +};
69757 +
69758 +void
69759 +gr_log_resource(const struct task_struct *task,
69760 + const int res, const unsigned long wanted, const int gt)
69761 +{
69762 + const struct cred *cred;
69763 + unsigned long rlim;
69764 +
69765 + if (!gr_acl_is_enabled() && !grsec_resource_logging)
69766 + return;
69767 +
69768 + // not yet supported resource
69769 + if (unlikely(!restab_log[res]))
69770 + return;
69771 +
69772 + if (res == RLIMIT_CPU || res == RLIMIT_RTTIME)
69773 + rlim = task_rlimit_max(task, res);
69774 + else
69775 + rlim = task_rlimit(task, res);
69776 +
69777 + if (likely((rlim == RLIM_INFINITY) || (gt && wanted <= rlim) || (!gt && wanted < rlim)))
69778 + return;
69779 +
69780 + rcu_read_lock();
69781 + cred = __task_cred(task);
69782 +
69783 + if (res == RLIMIT_NPROC &&
69784 + (cap_raised(cred->cap_effective, CAP_SYS_ADMIN) ||
69785 + cap_raised(cred->cap_effective, CAP_SYS_RESOURCE)))
69786 + goto out_rcu_unlock;
69787 + else if (res == RLIMIT_MEMLOCK &&
69788 + cap_raised(cred->cap_effective, CAP_IPC_LOCK))
69789 + goto out_rcu_unlock;
69790 + else if (res == RLIMIT_NICE && cap_raised(cred->cap_effective, CAP_SYS_NICE))
69791 + goto out_rcu_unlock;
69792 + rcu_read_unlock();
69793 +
69794 + gr_log_res_ulong2_str(GR_DONT_AUDIT, GR_RESOURCE_MSG, task, wanted, restab_log[res], rlim);
69795 +
69796 + return;
69797 +out_rcu_unlock:
69798 + rcu_read_unlock();
69799 + return;
69800 +}
69801 diff --git a/grsecurity/gracl_segv.c b/grsecurity/gracl_segv.c
69802 new file mode 100644
69803 index 0000000..2040e61
69804 --- /dev/null
69805 +++ b/grsecurity/gracl_segv.c
69806 @@ -0,0 +1,313 @@
69807 +#include <linux/kernel.h>
69808 +#include <linux/mm.h>
69809 +#include <asm/uaccess.h>
69810 +#include <asm/errno.h>
69811 +#include <asm/mman.h>
69812 +#include <net/sock.h>
69813 +#include <linux/file.h>
69814 +#include <linux/fs.h>
69815 +#include <linux/net.h>
69816 +#include <linux/in.h>
69817 +#include <linux/slab.h>
69818 +#include <linux/types.h>
69819 +#include <linux/sched.h>
69820 +#include <linux/timer.h>
69821 +#include <linux/gracl.h>
69822 +#include <linux/grsecurity.h>
69823 +#include <linux/grinternal.h>
69824 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69825 +#include <linux/magic.h>
69826 +#include <linux/pagemap.h>
69827 +#include "../fs/btrfs/async-thread.h"
69828 +#include "../fs/btrfs/ctree.h"
69829 +#include "../fs/btrfs/btrfs_inode.h"
69830 +#endif
69831 +
69832 +static struct crash_uid *uid_set;
69833 +static unsigned short uid_used;
69834 +static DEFINE_SPINLOCK(gr_uid_lock);
69835 +extern rwlock_t gr_inode_lock;
69836 +extern struct acl_subject_label *
69837 + lookup_acl_subj_label(const ino_t inode, const dev_t dev,
69838 + struct acl_role_label *role);
69839 +
69840 +static inline dev_t __get_dev(const struct dentry *dentry)
69841 +{
69842 +#if defined(CONFIG_BTRFS_FS) || defined(CONFIG_BTRFS_FS_MODULE)
69843 + if (dentry->d_sb->s_magic == BTRFS_SUPER_MAGIC)
69844 + return BTRFS_I(dentry->d_inode)->root->anon_dev;
69845 + else
69846 +#endif
69847 + return dentry->d_sb->s_dev;
69848 +}
69849 +
69850 +int
69851 +gr_init_uidset(void)
69852 +{
69853 + uid_set =
69854 + kmalloc(GR_UIDTABLE_MAX * sizeof (struct crash_uid), GFP_KERNEL);
69855 + uid_used = 0;
69856 +
69857 + return uid_set ? 1 : 0;
69858 +}
69859 +
69860 +void
69861 +gr_free_uidset(void)
69862 +{
69863 + if (uid_set) {
69864 + struct crash_uid *tmpset;
69865 + spin_lock(&gr_uid_lock);
69866 + tmpset = uid_set;
69867 + uid_set = NULL;
69868 + uid_used = 0;
69869 + spin_unlock(&gr_uid_lock);
69870 + if (tmpset)
69871 + kfree(tmpset);
69872 + }
69873 +
69874 + return;
69875 +}
69876 +
69877 +int
69878 +gr_find_uid(const uid_t uid)
69879 +{
69880 + struct crash_uid *tmp = uid_set;
69881 + uid_t buid;
69882 + int low = 0, high = uid_used - 1, mid;
69883 +
69884 + while (high >= low) {
69885 + mid = (low + high) >> 1;
69886 + buid = tmp[mid].uid;
69887 + if (buid == uid)
69888 + return mid;
69889 + if (buid > uid)
69890 + high = mid - 1;
69891 + if (buid < uid)
69892 + low = mid + 1;
69893 + }
69894 +
69895 + return -1;
69896 +}
69897 +
69898 +static __inline__ void
69899 +gr_insertsort(void)
69900 +{
69901 + unsigned short i, j;
69902 + struct crash_uid index;
69903 +
69904 + for (i = 1; i < uid_used; i++) {
69905 + index = uid_set[i];
69906 + j = i;
69907 + while ((j > 0) && uid_set[j - 1].uid > index.uid) {
69908 + uid_set[j] = uid_set[j - 1];
69909 + j--;
69910 + }
69911 + uid_set[j] = index;
69912 + }
69913 +
69914 + return;
69915 +}
69916 +
69917 +static __inline__ void
69918 +gr_insert_uid(const kuid_t kuid, const unsigned long expires)
69919 +{
69920 + int loc;
69921 + uid_t uid = GR_GLOBAL_UID(kuid);
69922 +
69923 + if (uid_used == GR_UIDTABLE_MAX)
69924 + return;
69925 +
69926 + loc = gr_find_uid(uid);
69927 +
69928 + if (loc >= 0) {
69929 + uid_set[loc].expires = expires;
69930 + return;
69931 + }
69932 +
69933 + uid_set[uid_used].uid = uid;
69934 + uid_set[uid_used].expires = expires;
69935 + uid_used++;
69936 +
69937 + gr_insertsort();
69938 +
69939 + return;
69940 +}
69941 +
69942 +void
69943 +gr_remove_uid(const unsigned short loc)
69944 +{
69945 + unsigned short i;
69946 +
69947 + for (i = loc + 1; i < uid_used; i++)
69948 + uid_set[i - 1] = uid_set[i];
69949 +
69950 + uid_used--;
69951 +
69952 + return;
69953 +}
69954 +
69955 +int
69956 +gr_check_crash_uid(const kuid_t kuid)
69957 +{
69958 + int loc;
69959 + int ret = 0;
69960 + uid_t uid;
69961 +
69962 + if (unlikely(!gr_acl_is_enabled()))
69963 + return 0;
69964 +
69965 + uid = GR_GLOBAL_UID(kuid);
69966 +
69967 + spin_lock(&gr_uid_lock);
69968 + loc = gr_find_uid(uid);
69969 +
69970 + if (loc < 0)
69971 + goto out_unlock;
69972 +
69973 + if (time_before_eq(uid_set[loc].expires, get_seconds()))
69974 + gr_remove_uid(loc);
69975 + else
69976 + ret = 1;
69977 +
69978 +out_unlock:
69979 + spin_unlock(&gr_uid_lock);
69980 + return ret;
69981 +}
69982 +
69983 +static __inline__ int
69984 +proc_is_setxid(const struct cred *cred)
69985 +{
69986 + if (!uid_eq(cred->uid, cred->euid) || !uid_eq(cred->uid, cred->suid) ||
69987 + !uid_eq(cred->uid, cred->fsuid))
69988 + return 1;
69989 + if (!gid_eq(cred->gid, cred->egid) || !gid_eq(cred->gid, cred->sgid) ||
69990 + !gid_eq(cred->gid, cred->fsgid))
69991 + return 1;
69992 +
69993 + return 0;
69994 +}
69995 +
69996 +extern int gr_fake_force_sig(int sig, struct task_struct *t);
69997 +
69998 +void
69999 +gr_handle_crash(struct task_struct *task, const int sig)
70000 +{
70001 + struct acl_subject_label *curr;
70002 + struct task_struct *tsk, *tsk2;
70003 + const struct cred *cred;
70004 + const struct cred *cred2;
70005 +
70006 + if (sig != SIGSEGV && sig != SIGKILL && sig != SIGBUS && sig != SIGILL)
70007 + return;
70008 +
70009 + if (unlikely(!gr_acl_is_enabled()))
70010 + return;
70011 +
70012 + curr = task->acl;
70013 +
70014 + if (!(curr->resmask & (1U << GR_CRASH_RES)))
70015 + return;
70016 +
70017 + if (time_before_eq(curr->expires, get_seconds())) {
70018 + curr->expires = 0;
70019 + curr->crashes = 0;
70020 + }
70021 +
70022 + curr->crashes++;
70023 +
70024 + if (!curr->expires)
70025 + curr->expires = get_seconds() + curr->res[GR_CRASH_RES].rlim_max;
70026 +
70027 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
70028 + time_after(curr->expires, get_seconds())) {
70029 + rcu_read_lock();
70030 + cred = __task_cred(task);
70031 + if (gr_is_global_nonroot(cred->uid) && proc_is_setxid(cred)) {
70032 + gr_log_crash1(GR_DONT_AUDIT, GR_SEGVSTART_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
70033 + spin_lock(&gr_uid_lock);
70034 + gr_insert_uid(cred->uid, curr->expires);
70035 + spin_unlock(&gr_uid_lock);
70036 + curr->expires = 0;
70037 + curr->crashes = 0;
70038 + read_lock(&tasklist_lock);
70039 + do_each_thread(tsk2, tsk) {
70040 + cred2 = __task_cred(tsk);
70041 + if (tsk != task && uid_eq(cred2->uid, cred->uid))
70042 + gr_fake_force_sig(SIGKILL, tsk);
70043 + } while_each_thread(tsk2, tsk);
70044 + read_unlock(&tasklist_lock);
70045 + } else {
70046 + gr_log_crash2(GR_DONT_AUDIT, GR_SEGVNOSUID_ACL_MSG, task, curr->res[GR_CRASH_RES].rlim_max);
70047 + read_lock(&tasklist_lock);
70048 + read_lock(&grsec_exec_file_lock);
70049 + do_each_thread(tsk2, tsk) {
70050 + if (likely(tsk != task)) {
70051 + // if this thread has the same subject as the one that triggered
70052 + // RES_CRASH and it's the same binary, kill it
70053 + if (tsk->acl == task->acl && gr_is_same_file(tsk->exec_file, task->exec_file))
70054 + gr_fake_force_sig(SIGKILL, tsk);
70055 + }
70056 + } while_each_thread(tsk2, tsk);
70057 + read_unlock(&grsec_exec_file_lock);
70058 + read_unlock(&tasklist_lock);
70059 + }
70060 + rcu_read_unlock();
70061 + }
70062 +
70063 + return;
70064 +}
70065 +
70066 +int
70067 +gr_check_crash_exec(const struct file *filp)
70068 +{
70069 + struct acl_subject_label *curr;
70070 +
70071 + if (unlikely(!gr_acl_is_enabled()))
70072 + return 0;
70073 +
70074 + read_lock(&gr_inode_lock);
70075 + curr = lookup_acl_subj_label(filp->f_path.dentry->d_inode->i_ino,
70076 + __get_dev(filp->f_path.dentry),
70077 + current->role);
70078 + read_unlock(&gr_inode_lock);
70079 +
70080 + if (!curr || !(curr->resmask & (1U << GR_CRASH_RES)) ||
70081 + (!curr->crashes && !curr->expires))
70082 + return 0;
70083 +
70084 + if ((curr->crashes >= curr->res[GR_CRASH_RES].rlim_cur) &&
70085 + time_after(curr->expires, get_seconds()))
70086 + return 1;
70087 + else if (time_before_eq(curr->expires, get_seconds())) {
70088 + curr->crashes = 0;
70089 + curr->expires = 0;
70090 + }
70091 +
70092 + return 0;
70093 +}
70094 +
70095 +void
70096 +gr_handle_alertkill(struct task_struct *task)
70097 +{
70098 + struct acl_subject_label *curracl;
70099 + __u32 curr_ip;
70100 + struct task_struct *p, *p2;
70101 +
70102 + if (unlikely(!gr_acl_is_enabled()))
70103 + return;
70104 +
70105 + curracl = task->acl;
70106 + curr_ip = task->signal->curr_ip;
70107 +
70108 + if ((curracl->mode & GR_KILLIPPROC) && curr_ip) {
70109 + read_lock(&tasklist_lock);
70110 + do_each_thread(p2, p) {
70111 + if (p->signal->curr_ip == curr_ip)
70112 + gr_fake_force_sig(SIGKILL, p);
70113 + } while_each_thread(p2, p);
70114 + read_unlock(&tasklist_lock);
70115 + } else if (curracl->mode & GR_KILLPROC)
70116 + gr_fake_force_sig(SIGKILL, task);
70117 +
70118 + return;
70119 +}
70120 diff --git a/grsecurity/gracl_shm.c b/grsecurity/gracl_shm.c
70121 new file mode 100644
70122 index 0000000..98011b0
70123 --- /dev/null
70124 +++ b/grsecurity/gracl_shm.c
70125 @@ -0,0 +1,40 @@
70126 +#include <linux/kernel.h>
70127 +#include <linux/mm.h>
70128 +#include <linux/sched.h>
70129 +#include <linux/file.h>
70130 +#include <linux/ipc.h>
70131 +#include <linux/gracl.h>
70132 +#include <linux/grsecurity.h>
70133 +#include <linux/grinternal.h>
70134 +
70135 +int
70136 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70137 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70138 +{
70139 + struct task_struct *task;
70140 +
70141 + if (!gr_acl_is_enabled())
70142 + return 1;
70143 +
70144 + rcu_read_lock();
70145 + read_lock(&tasklist_lock);
70146 +
70147 + task = find_task_by_vpid(shm_cprid);
70148 +
70149 + if (unlikely(!task))
70150 + task = find_task_by_vpid(shm_lapid);
70151 +
70152 + if (unlikely(task && (time_before_eq((unsigned long)task->start_time.tv_sec, (unsigned long)shm_createtime) ||
70153 + (task_pid_nr(task) == shm_lapid)) &&
70154 + (task->acl->mode & GR_PROTSHM) &&
70155 + (task->acl != current->acl))) {
70156 + read_unlock(&tasklist_lock);
70157 + rcu_read_unlock();
70158 + gr_log_int3(GR_DONT_AUDIT, GR_SHMAT_ACL_MSG, GR_GLOBAL_UID(cuid), shm_cprid, shmid);
70159 + return 0;
70160 + }
70161 + read_unlock(&tasklist_lock);
70162 + rcu_read_unlock();
70163 +
70164 + return 1;
70165 +}
70166 diff --git a/grsecurity/grsec_chdir.c b/grsecurity/grsec_chdir.c
70167 new file mode 100644
70168 index 0000000..bc0be01
70169 --- /dev/null
70170 +++ b/grsecurity/grsec_chdir.c
70171 @@ -0,0 +1,19 @@
70172 +#include <linux/kernel.h>
70173 +#include <linux/sched.h>
70174 +#include <linux/fs.h>
70175 +#include <linux/file.h>
70176 +#include <linux/grsecurity.h>
70177 +#include <linux/grinternal.h>
70178 +
70179 +void
70180 +gr_log_chdir(const struct dentry *dentry, const struct vfsmount *mnt)
70181 +{
70182 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
70183 + if ((grsec_enable_chdir && grsec_enable_group &&
70184 + in_group_p(grsec_audit_gid)) || (grsec_enable_chdir &&
70185 + !grsec_enable_group)) {
70186 + gr_log_fs_generic(GR_DO_AUDIT, GR_CHDIR_AUDIT_MSG, dentry, mnt);
70187 + }
70188 +#endif
70189 + return;
70190 +}
70191 diff --git a/grsecurity/grsec_chroot.c b/grsecurity/grsec_chroot.c
70192 new file mode 100644
70193 index 0000000..e10b319
70194 --- /dev/null
70195 +++ b/grsecurity/grsec_chroot.c
70196 @@ -0,0 +1,370 @@
70197 +#include <linux/kernel.h>
70198 +#include <linux/module.h>
70199 +#include <linux/sched.h>
70200 +#include <linux/file.h>
70201 +#include <linux/fs.h>
70202 +#include <linux/mount.h>
70203 +#include <linux/types.h>
70204 +#include "../fs/mount.h"
70205 +#include <linux/grsecurity.h>
70206 +#include <linux/grinternal.h>
70207 +
70208 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70209 +int gr_init_ran;
70210 +#endif
70211 +
70212 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path)
70213 +{
70214 +#ifdef CONFIG_GRKERNSEC
70215 + if (task_pid_nr(task) > 1 && path->dentry != init_task.fs->root.dentry &&
70216 + path->dentry != task->nsproxy->mnt_ns->root->mnt.mnt_root
70217 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70218 + && gr_init_ran
70219 +#endif
70220 + )
70221 + task->gr_is_chrooted = 1;
70222 + else {
70223 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
70224 + if (task_pid_nr(task) == 1 && !gr_init_ran)
70225 + gr_init_ran = 1;
70226 +#endif
70227 + task->gr_is_chrooted = 0;
70228 + }
70229 +
70230 + task->gr_chroot_dentry = path->dentry;
70231 +#endif
70232 + return;
70233 +}
70234 +
70235 +void gr_clear_chroot_entries(struct task_struct *task)
70236 +{
70237 +#ifdef CONFIG_GRKERNSEC
70238 + task->gr_is_chrooted = 0;
70239 + task->gr_chroot_dentry = NULL;
70240 +#endif
70241 + return;
70242 +}
70243 +
70244 +int
70245 +gr_handle_chroot_unix(const pid_t pid)
70246 +{
70247 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
70248 + struct task_struct *p;
70249 +
70250 + if (unlikely(!grsec_enable_chroot_unix))
70251 + return 1;
70252 +
70253 + if (likely(!proc_is_chrooted(current)))
70254 + return 1;
70255 +
70256 + rcu_read_lock();
70257 + read_lock(&tasklist_lock);
70258 + p = find_task_by_vpid_unrestricted(pid);
70259 + if (unlikely(p && !have_same_root(current, p))) {
70260 + read_unlock(&tasklist_lock);
70261 + rcu_read_unlock();
70262 + gr_log_noargs(GR_DONT_AUDIT, GR_UNIX_CHROOT_MSG);
70263 + return 0;
70264 + }
70265 + read_unlock(&tasklist_lock);
70266 + rcu_read_unlock();
70267 +#endif
70268 + return 1;
70269 +}
70270 +
70271 +int
70272 +gr_handle_chroot_nice(void)
70273 +{
70274 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70275 + if (grsec_enable_chroot_nice && proc_is_chrooted(current)) {
70276 + gr_log_noargs(GR_DONT_AUDIT, GR_NICE_CHROOT_MSG);
70277 + return -EPERM;
70278 + }
70279 +#endif
70280 + return 0;
70281 +}
70282 +
70283 +int
70284 +gr_handle_chroot_setpriority(struct task_struct *p, const int niceval)
70285 +{
70286 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
70287 + if (grsec_enable_chroot_nice && (niceval < task_nice(p))
70288 + && proc_is_chrooted(current)) {
70289 + gr_log_str_int(GR_DONT_AUDIT, GR_PRIORITY_CHROOT_MSG, p->comm, task_pid_nr(p));
70290 + return -EACCES;
70291 + }
70292 +#endif
70293 + return 0;
70294 +}
70295 +
70296 +int
70297 +gr_handle_chroot_fowner(struct pid *pid, enum pid_type type)
70298 +{
70299 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70300 + struct task_struct *p;
70301 + int ret = 0;
70302 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || !pid)
70303 + return ret;
70304 +
70305 + read_lock(&tasklist_lock);
70306 + do_each_pid_task(pid, type, p) {
70307 + if (!have_same_root(current, p)) {
70308 + ret = 1;
70309 + goto out;
70310 + }
70311 + } while_each_pid_task(pid, type, p);
70312 +out:
70313 + read_unlock(&tasklist_lock);
70314 + return ret;
70315 +#endif
70316 + return 0;
70317 +}
70318 +
70319 +int
70320 +gr_pid_is_chrooted(struct task_struct *p)
70321 +{
70322 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
70323 + if (!grsec_enable_chroot_findtask || !proc_is_chrooted(current) || p == NULL)
70324 + return 0;
70325 +
70326 + if ((p->exit_state & (EXIT_ZOMBIE | EXIT_DEAD)) ||
70327 + !have_same_root(current, p)) {
70328 + return 1;
70329 + }
70330 +#endif
70331 + return 0;
70332 +}
70333 +
70334 +EXPORT_SYMBOL(gr_pid_is_chrooted);
70335 +
70336 +#if defined(CONFIG_GRKERNSEC_CHROOT_DOUBLE) || defined(CONFIG_GRKERNSEC_CHROOT_FCHDIR)
70337 +int gr_is_outside_chroot(const struct dentry *u_dentry, const struct vfsmount *u_mnt)
70338 +{
70339 + struct path path, currentroot;
70340 + int ret = 0;
70341 +
70342 + path.dentry = (struct dentry *)u_dentry;
70343 + path.mnt = (struct vfsmount *)u_mnt;
70344 + get_fs_root(current->fs, &currentroot);
70345 + if (path_is_under(&path, &currentroot))
70346 + ret = 1;
70347 + path_put(&currentroot);
70348 +
70349 + return ret;
70350 +}
70351 +#endif
70352 +
70353 +int
70354 +gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt)
70355 +{
70356 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
70357 + if (!grsec_enable_chroot_fchdir)
70358 + return 1;
70359 +
70360 + if (!proc_is_chrooted(current))
70361 + return 1;
70362 + else if (!gr_is_outside_chroot(u_dentry, u_mnt)) {
70363 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_FCHDIR_MSG, u_dentry, u_mnt);
70364 + return 0;
70365 + }
70366 +#endif
70367 + return 1;
70368 +}
70369 +
70370 +int
70371 +gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70372 + const time_t shm_createtime)
70373 +{
70374 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
70375 + struct task_struct *p;
70376 + time_t starttime;
70377 +
70378 + if (unlikely(!grsec_enable_chroot_shmat))
70379 + return 1;
70380 +
70381 + if (likely(!proc_is_chrooted(current)))
70382 + return 1;
70383 +
70384 + rcu_read_lock();
70385 + read_lock(&tasklist_lock);
70386 +
70387 + if ((p = find_task_by_vpid_unrestricted(shm_cprid))) {
70388 + starttime = p->start_time.tv_sec;
70389 + if (time_before_eq((unsigned long)starttime, (unsigned long)shm_createtime)) {
70390 + if (have_same_root(current, p)) {
70391 + goto allow;
70392 + } else {
70393 + read_unlock(&tasklist_lock);
70394 + rcu_read_unlock();
70395 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
70396 + return 0;
70397 + }
70398 + }
70399 + /* creator exited, pid reuse, fall through to next check */
70400 + }
70401 + if ((p = find_task_by_vpid_unrestricted(shm_lapid))) {
70402 + if (unlikely(!have_same_root(current, p))) {
70403 + read_unlock(&tasklist_lock);
70404 + rcu_read_unlock();
70405 + gr_log_noargs(GR_DONT_AUDIT, GR_SHMAT_CHROOT_MSG);
70406 + return 0;
70407 + }
70408 + }
70409 +
70410 +allow:
70411 + read_unlock(&tasklist_lock);
70412 + rcu_read_unlock();
70413 +#endif
70414 + return 1;
70415 +}
70416 +
70417 +void
70418 +gr_log_chroot_exec(const struct dentry *dentry, const struct vfsmount *mnt)
70419 +{
70420 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
70421 + if (grsec_enable_chroot_execlog && proc_is_chrooted(current))
70422 + gr_log_fs_generic(GR_DO_AUDIT, GR_EXEC_CHROOT_MSG, dentry, mnt);
70423 +#endif
70424 + return;
70425 +}
70426 +
70427 +int
70428 +gr_handle_chroot_mknod(const struct dentry *dentry,
70429 + const struct vfsmount *mnt, const int mode)
70430 +{
70431 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
70432 + if (grsec_enable_chroot_mknod && !S_ISFIFO(mode) && !S_ISREG(mode) &&
70433 + proc_is_chrooted(current)) {
70434 + gr_log_fs_generic(GR_DONT_AUDIT, GR_MKNOD_CHROOT_MSG, dentry, mnt);
70435 + return -EPERM;
70436 + }
70437 +#endif
70438 + return 0;
70439 +}
70440 +
70441 +int
70442 +gr_handle_chroot_mount(const struct dentry *dentry,
70443 + const struct vfsmount *mnt, const char *dev_name)
70444 +{
70445 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
70446 + if (grsec_enable_chroot_mount && proc_is_chrooted(current)) {
70447 + gr_log_str_fs(GR_DONT_AUDIT, GR_MOUNT_CHROOT_MSG, dev_name ? dev_name : "none", dentry, mnt);
70448 + return -EPERM;
70449 + }
70450 +#endif
70451 + return 0;
70452 +}
70453 +
70454 +int
70455 +gr_handle_chroot_pivot(void)
70456 +{
70457 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
70458 + if (grsec_enable_chroot_pivot && proc_is_chrooted(current)) {
70459 + gr_log_noargs(GR_DONT_AUDIT, GR_PIVOT_CHROOT_MSG);
70460 + return -EPERM;
70461 + }
70462 +#endif
70463 + return 0;
70464 +}
70465 +
70466 +int
70467 +gr_handle_chroot_chroot(const struct dentry *dentry, const struct vfsmount *mnt)
70468 +{
70469 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
70470 + if (grsec_enable_chroot_double && proc_is_chrooted(current) &&
70471 + !gr_is_outside_chroot(dentry, mnt)) {
70472 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHROOT_CHROOT_MSG, dentry, mnt);
70473 + return -EPERM;
70474 + }
70475 +#endif
70476 + return 0;
70477 +}
70478 +
70479 +extern const char *captab_log[];
70480 +extern int captab_log_entries;
70481 +
70482 +int
70483 +gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
70484 +{
70485 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70486 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70487 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70488 + if (cap_raised(chroot_caps, cap)) {
70489 + if (cap_raised(cred->cap_effective, cap) && cap < captab_log_entries) {
70490 + gr_log_cap(GR_DONT_AUDIT, GR_CAP_CHROOT_MSG, task, captab_log[cap]);
70491 + }
70492 + return 0;
70493 + }
70494 + }
70495 +#endif
70496 + return 1;
70497 +}
70498 +
70499 +int
70500 +gr_chroot_is_capable(const int cap)
70501 +{
70502 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70503 + return gr_task_chroot_is_capable(current, current_cred(), cap);
70504 +#endif
70505 + return 1;
70506 +}
70507 +
70508 +int
70509 +gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap)
70510 +{
70511 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70512 + if (grsec_enable_chroot_caps && proc_is_chrooted(task)) {
70513 + kernel_cap_t chroot_caps = GR_CHROOT_CAPS;
70514 + if (cap_raised(chroot_caps, cap)) {
70515 + return 0;
70516 + }
70517 + }
70518 +#endif
70519 + return 1;
70520 +}
70521 +
70522 +int
70523 +gr_chroot_is_capable_nolog(const int cap)
70524 +{
70525 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
70526 + return gr_task_chroot_is_capable_nolog(current, cap);
70527 +#endif
70528 + return 1;
70529 +}
70530 +
70531 +int
70532 +gr_handle_chroot_sysctl(const int op)
70533 +{
70534 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
70535 + if (grsec_enable_chroot_sysctl && (op & MAY_WRITE) &&
70536 + proc_is_chrooted(current))
70537 + return -EACCES;
70538 +#endif
70539 + return 0;
70540 +}
70541 +
70542 +void
70543 +gr_handle_chroot_chdir(const struct path *path)
70544 +{
70545 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
70546 + if (grsec_enable_chroot_chdir)
70547 + set_fs_pwd(current->fs, path);
70548 +#endif
70549 + return;
70550 +}
70551 +
70552 +int
70553 +gr_handle_chroot_chmod(const struct dentry *dentry,
70554 + const struct vfsmount *mnt, const int mode)
70555 +{
70556 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
70557 + /* allow chmod +s on directories, but not files */
70558 + if (grsec_enable_chroot_chmod && !S_ISDIR(dentry->d_inode->i_mode) &&
70559 + ((mode & S_ISUID) || ((mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))) &&
70560 + proc_is_chrooted(current)) {
70561 + gr_log_fs_generic(GR_DONT_AUDIT, GR_CHMOD_CHROOT_MSG, dentry, mnt);
70562 + return -EPERM;
70563 + }
70564 +#endif
70565 + return 0;
70566 +}
70567 diff --git a/grsecurity/grsec_disabled.c b/grsecurity/grsec_disabled.c
70568 new file mode 100644
70569 index 0000000..52b3e30
70570 --- /dev/null
70571 +++ b/grsecurity/grsec_disabled.c
70572 @@ -0,0 +1,433 @@
70573 +#include <linux/kernel.h>
70574 +#include <linux/module.h>
70575 +#include <linux/sched.h>
70576 +#include <linux/file.h>
70577 +#include <linux/fs.h>
70578 +#include <linux/kdev_t.h>
70579 +#include <linux/net.h>
70580 +#include <linux/in.h>
70581 +#include <linux/ip.h>
70582 +#include <linux/skbuff.h>
70583 +#include <linux/sysctl.h>
70584 +
70585 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
70586 +void
70587 +pax_set_initial_flags(struct linux_binprm *bprm)
70588 +{
70589 + return;
70590 +}
70591 +#endif
70592 +
70593 +#ifdef CONFIG_SYSCTL
70594 +__u32
70595 +gr_handle_sysctl(const struct ctl_table * table, const int op)
70596 +{
70597 + return 0;
70598 +}
70599 +#endif
70600 +
70601 +#ifdef CONFIG_TASKSTATS
70602 +int gr_is_taskstats_denied(int pid)
70603 +{
70604 + return 0;
70605 +}
70606 +#endif
70607 +
70608 +int
70609 +gr_acl_is_enabled(void)
70610 +{
70611 + return 0;
70612 +}
70613 +
70614 +void
70615 +gr_handle_proc_create(const struct dentry *dentry, const struct inode *inode)
70616 +{
70617 + return;
70618 +}
70619 +
70620 +int
70621 +gr_handle_rawio(const struct inode *inode)
70622 +{
70623 + return 0;
70624 +}
70625 +
70626 +void
70627 +gr_acl_handle_psacct(struct task_struct *task, const long code)
70628 +{
70629 + return;
70630 +}
70631 +
70632 +int
70633 +gr_handle_ptrace(struct task_struct *task, const long request)
70634 +{
70635 + return 0;
70636 +}
70637 +
70638 +int
70639 +gr_handle_proc_ptrace(struct task_struct *task)
70640 +{
70641 + return 0;
70642 +}
70643 +
70644 +int
70645 +gr_set_acls(const int type)
70646 +{
70647 + return 0;
70648 +}
70649 +
70650 +int
70651 +gr_check_hidden_task(const struct task_struct *tsk)
70652 +{
70653 + return 0;
70654 +}
70655 +
70656 +int
70657 +gr_check_protected_task(const struct task_struct *task)
70658 +{
70659 + return 0;
70660 +}
70661 +
70662 +int
70663 +gr_check_protected_task_fowner(struct pid *pid, enum pid_type type)
70664 +{
70665 + return 0;
70666 +}
70667 +
70668 +void
70669 +gr_copy_label(struct task_struct *tsk)
70670 +{
70671 + return;
70672 +}
70673 +
70674 +void
70675 +gr_set_pax_flags(struct task_struct *task)
70676 +{
70677 + return;
70678 +}
70679 +
70680 +int
70681 +gr_set_proc_label(const struct dentry *dentry, const struct vfsmount *mnt,
70682 + const int unsafe_share)
70683 +{
70684 + return 0;
70685 +}
70686 +
70687 +void
70688 +gr_handle_delete(const ino_t ino, const dev_t dev)
70689 +{
70690 + return;
70691 +}
70692 +
70693 +void
70694 +gr_handle_create(const struct dentry *dentry, const struct vfsmount *mnt)
70695 +{
70696 + return;
70697 +}
70698 +
70699 +void
70700 +gr_handle_crash(struct task_struct *task, const int sig)
70701 +{
70702 + return;
70703 +}
70704 +
70705 +int
70706 +gr_check_crash_exec(const struct file *filp)
70707 +{
70708 + return 0;
70709 +}
70710 +
70711 +int
70712 +gr_check_crash_uid(const kuid_t uid)
70713 +{
70714 + return 0;
70715 +}
70716 +
70717 +void
70718 +gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
70719 + struct dentry *old_dentry,
70720 + struct dentry *new_dentry,
70721 + struct vfsmount *mnt, const __u8 replace)
70722 +{
70723 + return;
70724 +}
70725 +
70726 +int
70727 +gr_search_socket(const int family, const int type, const int protocol)
70728 +{
70729 + return 1;
70730 +}
70731 +
70732 +int
70733 +gr_search_connectbind(const int mode, const struct socket *sock,
70734 + const struct sockaddr_in *addr)
70735 +{
70736 + return 0;
70737 +}
70738 +
70739 +void
70740 +gr_handle_alertkill(struct task_struct *task)
70741 +{
70742 + return;
70743 +}
70744 +
70745 +__u32
70746 +gr_acl_handle_execve(const struct dentry * dentry, const struct vfsmount * mnt)
70747 +{
70748 + return 1;
70749 +}
70750 +
70751 +__u32
70752 +gr_acl_handle_hidden_file(const struct dentry * dentry,
70753 + const struct vfsmount * mnt)
70754 +{
70755 + return 1;
70756 +}
70757 +
70758 +__u32
70759 +gr_acl_handle_open(const struct dentry * dentry, const struct vfsmount * mnt,
70760 + int acc_mode)
70761 +{
70762 + return 1;
70763 +}
70764 +
70765 +__u32
70766 +gr_acl_handle_rmdir(const struct dentry * dentry, const struct vfsmount * mnt)
70767 +{
70768 + return 1;
70769 +}
70770 +
70771 +__u32
70772 +gr_acl_handle_unlink(const struct dentry * dentry, const struct vfsmount * mnt)
70773 +{
70774 + return 1;
70775 +}
70776 +
70777 +int
70778 +gr_acl_handle_mmap(const struct file *file, const unsigned long prot,
70779 + unsigned int *vm_flags)
70780 +{
70781 + return 1;
70782 +}
70783 +
70784 +__u32
70785 +gr_acl_handle_truncate(const struct dentry * dentry,
70786 + const struct vfsmount * mnt)
70787 +{
70788 + return 1;
70789 +}
70790 +
70791 +__u32
70792 +gr_acl_handle_utime(const struct dentry * dentry, const struct vfsmount * mnt)
70793 +{
70794 + return 1;
70795 +}
70796 +
70797 +__u32
70798 +gr_acl_handle_access(const struct dentry * dentry,
70799 + const struct vfsmount * mnt, const int fmode)
70800 +{
70801 + return 1;
70802 +}
70803 +
70804 +__u32
70805 +gr_acl_handle_chmod(const struct dentry * dentry, const struct vfsmount * mnt,
70806 + umode_t *mode)
70807 +{
70808 + return 1;
70809 +}
70810 +
70811 +__u32
70812 +gr_acl_handle_chown(const struct dentry * dentry, const struct vfsmount * mnt)
70813 +{
70814 + return 1;
70815 +}
70816 +
70817 +__u32
70818 +gr_acl_handle_setxattr(const struct dentry * dentry, const struct vfsmount * mnt)
70819 +{
70820 + return 1;
70821 +}
70822 +
70823 +__u32
70824 +gr_acl_handle_removexattr(const struct dentry * dentry, const struct vfsmount * mnt)
70825 +{
70826 + return 1;
70827 +}
70828 +
70829 +void
70830 +grsecurity_init(void)
70831 +{
70832 + return;
70833 +}
70834 +
70835 +umode_t gr_acl_umask(void)
70836 +{
70837 + return 0;
70838 +}
70839 +
70840 +__u32
70841 +gr_acl_handle_mknod(const struct dentry * new_dentry,
70842 + const struct dentry * parent_dentry,
70843 + const struct vfsmount * parent_mnt,
70844 + const int mode)
70845 +{
70846 + return 1;
70847 +}
70848 +
70849 +__u32
70850 +gr_acl_handle_mkdir(const struct dentry * new_dentry,
70851 + const struct dentry * parent_dentry,
70852 + const struct vfsmount * parent_mnt)
70853 +{
70854 + return 1;
70855 +}
70856 +
70857 +__u32
70858 +gr_acl_handle_symlink(const struct dentry * new_dentry,
70859 + const struct dentry * parent_dentry,
70860 + const struct vfsmount * parent_mnt, const struct filename *from)
70861 +{
70862 + return 1;
70863 +}
70864 +
70865 +__u32
70866 +gr_acl_handle_link(const struct dentry * new_dentry,
70867 + const struct dentry * parent_dentry,
70868 + const struct vfsmount * parent_mnt,
70869 + const struct dentry * old_dentry,
70870 + const struct vfsmount * old_mnt, const struct filename *to)
70871 +{
70872 + return 1;
70873 +}
70874 +
70875 +int
70876 +gr_acl_handle_rename(const struct dentry *new_dentry,
70877 + const struct dentry *parent_dentry,
70878 + const struct vfsmount *parent_mnt,
70879 + const struct dentry *old_dentry,
70880 + const struct inode *old_parent_inode,
70881 + const struct vfsmount *old_mnt, const struct filename *newname)
70882 +{
70883 + return 0;
70884 +}
70885 +
70886 +int
70887 +gr_acl_handle_filldir(const struct file *file, const char *name,
70888 + const int namelen, const ino_t ino)
70889 +{
70890 + return 1;
70891 +}
70892 +
70893 +int
70894 +gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
70895 + const time_t shm_createtime, const kuid_t cuid, const int shmid)
70896 +{
70897 + return 1;
70898 +}
70899 +
70900 +int
70901 +gr_search_bind(const struct socket *sock, const struct sockaddr_in *addr)
70902 +{
70903 + return 0;
70904 +}
70905 +
70906 +int
70907 +gr_search_accept(const struct socket *sock)
70908 +{
70909 + return 0;
70910 +}
70911 +
70912 +int
70913 +gr_search_listen(const struct socket *sock)
70914 +{
70915 + return 0;
70916 +}
70917 +
70918 +int
70919 +gr_search_connect(const struct socket *sock, const struct sockaddr_in *addr)
70920 +{
70921 + return 0;
70922 +}
70923 +
70924 +__u32
70925 +gr_acl_handle_unix(const struct dentry * dentry, const struct vfsmount * mnt)
70926 +{
70927 + return 1;
70928 +}
70929 +
70930 +__u32
70931 +gr_acl_handle_creat(const struct dentry * dentry,
70932 + const struct dentry * p_dentry,
70933 + const struct vfsmount * p_mnt, int open_flags, int acc_mode,
70934 + const int imode)
70935 +{
70936 + return 1;
70937 +}
70938 +
70939 +void
70940 +gr_acl_handle_exit(void)
70941 +{
70942 + return;
70943 +}
70944 +
70945 +int
70946 +gr_acl_handle_mprotect(const struct file *file, const unsigned long prot)
70947 +{
70948 + return 1;
70949 +}
70950 +
70951 +void
70952 +gr_set_role_label(const kuid_t uid, const kgid_t gid)
70953 +{
70954 + return;
70955 +}
70956 +
70957 +int
70958 +gr_acl_handle_procpidmem(const struct task_struct *task)
70959 +{
70960 + return 0;
70961 +}
70962 +
70963 +int
70964 +gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb)
70965 +{
70966 + return 0;
70967 +}
70968 +
70969 +int
70970 +gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr)
70971 +{
70972 + return 0;
70973 +}
70974 +
70975 +int
70976 +gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs)
70977 +{
70978 + return 0;
70979 +}
70980 +
70981 +int
70982 +gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs)
70983 +{
70984 + return 0;
70985 +}
70986 +
70987 +int gr_acl_enable_at_secure(void)
70988 +{
70989 + return 0;
70990 +}
70991 +
70992 +dev_t gr_get_dev_from_dentry(struct dentry *dentry)
70993 +{
70994 + return dentry->d_sb->s_dev;
70995 +}
70996 +
70997 +void gr_put_exec_file(struct task_struct *task)
70998 +{
70999 + return;
71000 +}
71001 +
71002 +#ifdef CONFIG_SECURITY
71003 +EXPORT_SYMBOL(gr_check_user_change);
71004 +EXPORT_SYMBOL(gr_check_group_change);
71005 +#endif
71006 diff --git a/grsecurity/grsec_exec.c b/grsecurity/grsec_exec.c
71007 new file mode 100644
71008 index 0000000..387032b
71009 --- /dev/null
71010 +++ b/grsecurity/grsec_exec.c
71011 @@ -0,0 +1,187 @@
71012 +#include <linux/kernel.h>
71013 +#include <linux/sched.h>
71014 +#include <linux/file.h>
71015 +#include <linux/binfmts.h>
71016 +#include <linux/fs.h>
71017 +#include <linux/types.h>
71018 +#include <linux/grdefs.h>
71019 +#include <linux/grsecurity.h>
71020 +#include <linux/grinternal.h>
71021 +#include <linux/capability.h>
71022 +#include <linux/module.h>
71023 +#include <linux/compat.h>
71024 +
71025 +#include <asm/uaccess.h>
71026 +
71027 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71028 +static char gr_exec_arg_buf[132];
71029 +static DEFINE_MUTEX(gr_exec_arg_mutex);
71030 +#endif
71031 +
71032 +struct user_arg_ptr {
71033 +#ifdef CONFIG_COMPAT
71034 + bool is_compat;
71035 +#endif
71036 + union {
71037 + const char __user *const __user *native;
71038 +#ifdef CONFIG_COMPAT
71039 + const compat_uptr_t __user *compat;
71040 +#endif
71041 + } ptr;
71042 +};
71043 +
71044 +extern const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr);
71045 +
71046 +void
71047 +gr_handle_exec_args(struct linux_binprm *bprm, struct user_arg_ptr argv)
71048 +{
71049 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71050 + char *grarg = gr_exec_arg_buf;
71051 + unsigned int i, x, execlen = 0;
71052 + char c;
71053 +
71054 + if (!((grsec_enable_execlog && grsec_enable_group &&
71055 + in_group_p(grsec_audit_gid))
71056 + || (grsec_enable_execlog && !grsec_enable_group)))
71057 + return;
71058 +
71059 + mutex_lock(&gr_exec_arg_mutex);
71060 + memset(grarg, 0, sizeof(gr_exec_arg_buf));
71061 +
71062 + for (i = 0; i < bprm->argc && execlen < 128; i++) {
71063 + const char __user *p;
71064 + unsigned int len;
71065 +
71066 + p = get_user_arg_ptr(argv, i);
71067 + if (IS_ERR(p))
71068 + goto log;
71069 +
71070 + len = strnlen_user(p, 128 - execlen);
71071 + if (len > 128 - execlen)
71072 + len = 128 - execlen;
71073 + else if (len > 0)
71074 + len--;
71075 + if (copy_from_user(grarg + execlen, p, len))
71076 + goto log;
71077 +
71078 + /* rewrite unprintable characters */
71079 + for (x = 0; x < len; x++) {
71080 + c = *(grarg + execlen + x);
71081 + if (c < 32 || c > 126)
71082 + *(grarg + execlen + x) = ' ';
71083 + }
71084 +
71085 + execlen += len;
71086 + *(grarg + execlen) = ' ';
71087 + *(grarg + execlen + 1) = '\0';
71088 + execlen++;
71089 + }
71090 +
71091 + log:
71092 + gr_log_fs_str(GR_DO_AUDIT, GR_EXEC_AUDIT_MSG, bprm->file->f_path.dentry,
71093 + bprm->file->f_path.mnt, grarg);
71094 + mutex_unlock(&gr_exec_arg_mutex);
71095 +#endif
71096 + return;
71097 +}
71098 +
71099 +#ifdef CONFIG_GRKERNSEC
71100 +extern int gr_acl_is_capable(const int cap);
71101 +extern int gr_acl_is_capable_nolog(const int cap);
71102 +extern int gr_task_acl_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
71103 +extern int gr_task_acl_is_capable_nolog(const struct task_struct *task, const int cap);
71104 +extern int gr_chroot_is_capable(const int cap);
71105 +extern int gr_chroot_is_capable_nolog(const int cap);
71106 +extern int gr_task_chroot_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
71107 +extern int gr_task_chroot_is_capable_nolog(const struct task_struct *task, const int cap);
71108 +#endif
71109 +
71110 +const char *captab_log[] = {
71111 + "CAP_CHOWN",
71112 + "CAP_DAC_OVERRIDE",
71113 + "CAP_DAC_READ_SEARCH",
71114 + "CAP_FOWNER",
71115 + "CAP_FSETID",
71116 + "CAP_KILL",
71117 + "CAP_SETGID",
71118 + "CAP_SETUID",
71119 + "CAP_SETPCAP",
71120 + "CAP_LINUX_IMMUTABLE",
71121 + "CAP_NET_BIND_SERVICE",
71122 + "CAP_NET_BROADCAST",
71123 + "CAP_NET_ADMIN",
71124 + "CAP_NET_RAW",
71125 + "CAP_IPC_LOCK",
71126 + "CAP_IPC_OWNER",
71127 + "CAP_SYS_MODULE",
71128 + "CAP_SYS_RAWIO",
71129 + "CAP_SYS_CHROOT",
71130 + "CAP_SYS_PTRACE",
71131 + "CAP_SYS_PACCT",
71132 + "CAP_SYS_ADMIN",
71133 + "CAP_SYS_BOOT",
71134 + "CAP_SYS_NICE",
71135 + "CAP_SYS_RESOURCE",
71136 + "CAP_SYS_TIME",
71137 + "CAP_SYS_TTY_CONFIG",
71138 + "CAP_MKNOD",
71139 + "CAP_LEASE",
71140 + "CAP_AUDIT_WRITE",
71141 + "CAP_AUDIT_CONTROL",
71142 + "CAP_SETFCAP",
71143 + "CAP_MAC_OVERRIDE",
71144 + "CAP_MAC_ADMIN",
71145 + "CAP_SYSLOG",
71146 + "CAP_WAKE_ALARM"
71147 +};
71148 +
71149 +int captab_log_entries = sizeof(captab_log)/sizeof(captab_log[0]);
71150 +
71151 +int gr_is_capable(const int cap)
71152 +{
71153 +#ifdef CONFIG_GRKERNSEC
71154 + if (gr_acl_is_capable(cap) && gr_chroot_is_capable(cap))
71155 + return 1;
71156 + return 0;
71157 +#else
71158 + return 1;
71159 +#endif
71160 +}
71161 +
71162 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap)
71163 +{
71164 +#ifdef CONFIG_GRKERNSEC
71165 + if (gr_task_acl_is_capable(task, cred, cap) && gr_task_chroot_is_capable(task, cred, cap))
71166 + return 1;
71167 + return 0;
71168 +#else
71169 + return 1;
71170 +#endif
71171 +}
71172 +
71173 +int gr_is_capable_nolog(const int cap)
71174 +{
71175 +#ifdef CONFIG_GRKERNSEC
71176 + if (gr_acl_is_capable_nolog(cap) && gr_chroot_is_capable_nolog(cap))
71177 + return 1;
71178 + return 0;
71179 +#else
71180 + return 1;
71181 +#endif
71182 +}
71183 +
71184 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap)
71185 +{
71186 +#ifdef CONFIG_GRKERNSEC
71187 + if (gr_task_acl_is_capable_nolog(task, cap) && gr_task_chroot_is_capable_nolog(task, cap))
71188 + return 1;
71189 + return 0;
71190 +#else
71191 + return 1;
71192 +#endif
71193 +}
71194 +
71195 +EXPORT_SYMBOL(gr_is_capable);
71196 +EXPORT_SYMBOL(gr_is_capable_nolog);
71197 +EXPORT_SYMBOL(gr_task_is_capable);
71198 +EXPORT_SYMBOL(gr_task_is_capable_nolog);
71199 diff --git a/grsecurity/grsec_fifo.c b/grsecurity/grsec_fifo.c
71200 new file mode 100644
71201 index 0000000..06cc6ea
71202 --- /dev/null
71203 +++ b/grsecurity/grsec_fifo.c
71204 @@ -0,0 +1,24 @@
71205 +#include <linux/kernel.h>
71206 +#include <linux/sched.h>
71207 +#include <linux/fs.h>
71208 +#include <linux/file.h>
71209 +#include <linux/grinternal.h>
71210 +
71211 +int
71212 +gr_handle_fifo(const struct dentry *dentry, const struct vfsmount *mnt,
71213 + const struct dentry *dir, const int flag, const int acc_mode)
71214 +{
71215 +#ifdef CONFIG_GRKERNSEC_FIFO
71216 + const struct cred *cred = current_cred();
71217 +
71218 + if (grsec_enable_fifo && S_ISFIFO(dentry->d_inode->i_mode) &&
71219 + !(flag & O_EXCL) && (dir->d_inode->i_mode & S_ISVTX) &&
71220 + !uid_eq(dentry->d_inode->i_uid, dir->d_inode->i_uid) &&
71221 + !uid_eq(cred->fsuid, dentry->d_inode->i_uid)) {
71222 + if (!inode_permission(dentry->d_inode, acc_mode))
71223 + 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));
71224 + return -EACCES;
71225 + }
71226 +#endif
71227 + return 0;
71228 +}
71229 diff --git a/grsecurity/grsec_fork.c b/grsecurity/grsec_fork.c
71230 new file mode 100644
71231 index 0000000..8ca18bf
71232 --- /dev/null
71233 +++ b/grsecurity/grsec_fork.c
71234 @@ -0,0 +1,23 @@
71235 +#include <linux/kernel.h>
71236 +#include <linux/sched.h>
71237 +#include <linux/grsecurity.h>
71238 +#include <linux/grinternal.h>
71239 +#include <linux/errno.h>
71240 +
71241 +void
71242 +gr_log_forkfail(const int retval)
71243 +{
71244 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71245 + if (grsec_enable_forkfail && (retval == -EAGAIN || retval == -ENOMEM)) {
71246 + switch (retval) {
71247 + case -EAGAIN:
71248 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "EAGAIN");
71249 + break;
71250 + case -ENOMEM:
71251 + gr_log_str(GR_DONT_AUDIT, GR_FAILFORK_MSG, "ENOMEM");
71252 + break;
71253 + }
71254 + }
71255 +#endif
71256 + return;
71257 +}
71258 diff --git a/grsecurity/grsec_init.c b/grsecurity/grsec_init.c
71259 new file mode 100644
71260 index 0000000..a88e901
71261 --- /dev/null
71262 +++ b/grsecurity/grsec_init.c
71263 @@ -0,0 +1,272 @@
71264 +#include <linux/kernel.h>
71265 +#include <linux/sched.h>
71266 +#include <linux/mm.h>
71267 +#include <linux/gracl.h>
71268 +#include <linux/slab.h>
71269 +#include <linux/vmalloc.h>
71270 +#include <linux/percpu.h>
71271 +#include <linux/module.h>
71272 +
71273 +int grsec_enable_ptrace_readexec;
71274 +int grsec_enable_setxid;
71275 +int grsec_enable_symlinkown;
71276 +kgid_t grsec_symlinkown_gid;
71277 +int grsec_enable_brute;
71278 +int grsec_enable_link;
71279 +int grsec_enable_dmesg;
71280 +int grsec_enable_harden_ptrace;
71281 +int grsec_enable_harden_ipc;
71282 +int grsec_enable_fifo;
71283 +int grsec_enable_execlog;
71284 +int grsec_enable_signal;
71285 +int grsec_enable_forkfail;
71286 +int grsec_enable_audit_ptrace;
71287 +int grsec_enable_time;
71288 +int grsec_enable_group;
71289 +kgid_t grsec_audit_gid;
71290 +int grsec_enable_chdir;
71291 +int grsec_enable_mount;
71292 +int grsec_enable_rofs;
71293 +int grsec_deny_new_usb;
71294 +int grsec_enable_chroot_findtask;
71295 +int grsec_enable_chroot_mount;
71296 +int grsec_enable_chroot_shmat;
71297 +int grsec_enable_chroot_fchdir;
71298 +int grsec_enable_chroot_double;
71299 +int grsec_enable_chroot_pivot;
71300 +int grsec_enable_chroot_chdir;
71301 +int grsec_enable_chroot_chmod;
71302 +int grsec_enable_chroot_mknod;
71303 +int grsec_enable_chroot_nice;
71304 +int grsec_enable_chroot_execlog;
71305 +int grsec_enable_chroot_caps;
71306 +int grsec_enable_chroot_sysctl;
71307 +int grsec_enable_chroot_unix;
71308 +int grsec_enable_tpe;
71309 +kgid_t grsec_tpe_gid;
71310 +int grsec_enable_blackhole;
71311 +#ifdef CONFIG_IPV6_MODULE
71312 +EXPORT_SYMBOL(grsec_enable_blackhole);
71313 +#endif
71314 +int grsec_lastack_retries;
71315 +int grsec_enable_tpe_all;
71316 +int grsec_enable_tpe_invert;
71317 +int grsec_enable_socket_all;
71318 +kgid_t grsec_socket_all_gid;
71319 +int grsec_enable_socket_client;
71320 +kgid_t grsec_socket_client_gid;
71321 +int grsec_enable_socket_server;
71322 +kgid_t grsec_socket_server_gid;
71323 +int grsec_resource_logging;
71324 +int grsec_disable_privio;
71325 +int grsec_enable_log_rwxmaps;
71326 +int grsec_lock;
71327 +
71328 +DEFINE_SPINLOCK(grsec_alert_lock);
71329 +unsigned long grsec_alert_wtime = 0;
71330 +unsigned long grsec_alert_fyet = 0;
71331 +
71332 +DEFINE_SPINLOCK(grsec_audit_lock);
71333 +
71334 +DEFINE_RWLOCK(grsec_exec_file_lock);
71335 +
71336 +char *gr_shared_page[4];
71337 +
71338 +char *gr_alert_log_fmt;
71339 +char *gr_audit_log_fmt;
71340 +char *gr_alert_log_buf;
71341 +char *gr_audit_log_buf;
71342 +
71343 +void __init
71344 +grsecurity_init(void)
71345 +{
71346 + int j;
71347 + /* create the per-cpu shared pages */
71348 +
71349 +#ifdef CONFIG_X86
71350 + memset((char *)(0x41a + PAGE_OFFSET), 0, 36);
71351 +#endif
71352 +
71353 + for (j = 0; j < 4; j++) {
71354 + gr_shared_page[j] = (char *)__alloc_percpu(PAGE_SIZE, __alignof__(unsigned long long));
71355 + if (gr_shared_page[j] == NULL) {
71356 + panic("Unable to allocate grsecurity shared page");
71357 + return;
71358 + }
71359 + }
71360 +
71361 + /* allocate log buffers */
71362 + gr_alert_log_fmt = kmalloc(512, GFP_KERNEL);
71363 + if (!gr_alert_log_fmt) {
71364 + panic("Unable to allocate grsecurity alert log format buffer");
71365 + return;
71366 + }
71367 + gr_audit_log_fmt = kmalloc(512, GFP_KERNEL);
71368 + if (!gr_audit_log_fmt) {
71369 + panic("Unable to allocate grsecurity audit log format buffer");
71370 + return;
71371 + }
71372 + gr_alert_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
71373 + if (!gr_alert_log_buf) {
71374 + panic("Unable to allocate grsecurity alert log buffer");
71375 + return;
71376 + }
71377 + gr_audit_log_buf = (char *) get_zeroed_page(GFP_KERNEL);
71378 + if (!gr_audit_log_buf) {
71379 + panic("Unable to allocate grsecurity audit log buffer");
71380 + return;
71381 + }
71382 +
71383 +#ifdef CONFIG_GRKERNSEC_IO
71384 +#if !defined(CONFIG_GRKERNSEC_SYSCTL_DISTRO)
71385 + grsec_disable_privio = 1;
71386 +#elif defined(CONFIG_GRKERNSEC_SYSCTL_ON)
71387 + grsec_disable_privio = 1;
71388 +#else
71389 + grsec_disable_privio = 0;
71390 +#endif
71391 +#endif
71392 +
71393 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
71394 + /* for backward compatibility, tpe_invert always defaults to on if
71395 + enabled in the kernel
71396 + */
71397 + grsec_enable_tpe_invert = 1;
71398 +#endif
71399 +
71400 +#if !defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_SYSCTL_ON)
71401 +#ifndef CONFIG_GRKERNSEC_SYSCTL
71402 + grsec_lock = 1;
71403 +#endif
71404 +
71405 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
71406 + grsec_enable_log_rwxmaps = 1;
71407 +#endif
71408 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
71409 + grsec_enable_group = 1;
71410 + grsec_audit_gid = KGIDT_INIT(CONFIG_GRKERNSEC_AUDIT_GID);
71411 +#endif
71412 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
71413 + grsec_enable_ptrace_readexec = 1;
71414 +#endif
71415 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
71416 + grsec_enable_chdir = 1;
71417 +#endif
71418 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
71419 + grsec_enable_harden_ptrace = 1;
71420 +#endif
71421 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71422 + grsec_enable_harden_ipc = 1;
71423 +#endif
71424 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
71425 + grsec_enable_mount = 1;
71426 +#endif
71427 +#ifdef CONFIG_GRKERNSEC_LINK
71428 + grsec_enable_link = 1;
71429 +#endif
71430 +#ifdef CONFIG_GRKERNSEC_BRUTE
71431 + grsec_enable_brute = 1;
71432 +#endif
71433 +#ifdef CONFIG_GRKERNSEC_DMESG
71434 + grsec_enable_dmesg = 1;
71435 +#endif
71436 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
71437 + grsec_enable_blackhole = 1;
71438 + grsec_lastack_retries = 4;
71439 +#endif
71440 +#ifdef CONFIG_GRKERNSEC_FIFO
71441 + grsec_enable_fifo = 1;
71442 +#endif
71443 +#ifdef CONFIG_GRKERNSEC_EXECLOG
71444 + grsec_enable_execlog = 1;
71445 +#endif
71446 +#ifdef CONFIG_GRKERNSEC_SETXID
71447 + grsec_enable_setxid = 1;
71448 +#endif
71449 +#ifdef CONFIG_GRKERNSEC_SIGNAL
71450 + grsec_enable_signal = 1;
71451 +#endif
71452 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
71453 + grsec_enable_forkfail = 1;
71454 +#endif
71455 +#ifdef CONFIG_GRKERNSEC_TIME
71456 + grsec_enable_time = 1;
71457 +#endif
71458 +#ifdef CONFIG_GRKERNSEC_RESLOG
71459 + grsec_resource_logging = 1;
71460 +#endif
71461 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
71462 + grsec_enable_chroot_findtask = 1;
71463 +#endif
71464 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
71465 + grsec_enable_chroot_unix = 1;
71466 +#endif
71467 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
71468 + grsec_enable_chroot_mount = 1;
71469 +#endif
71470 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
71471 + grsec_enable_chroot_fchdir = 1;
71472 +#endif
71473 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
71474 + grsec_enable_chroot_shmat = 1;
71475 +#endif
71476 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
71477 + grsec_enable_audit_ptrace = 1;
71478 +#endif
71479 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
71480 + grsec_enable_chroot_double = 1;
71481 +#endif
71482 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
71483 + grsec_enable_chroot_pivot = 1;
71484 +#endif
71485 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
71486 + grsec_enable_chroot_chdir = 1;
71487 +#endif
71488 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
71489 + grsec_enable_chroot_chmod = 1;
71490 +#endif
71491 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
71492 + grsec_enable_chroot_mknod = 1;
71493 +#endif
71494 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
71495 + grsec_enable_chroot_nice = 1;
71496 +#endif
71497 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
71498 + grsec_enable_chroot_execlog = 1;
71499 +#endif
71500 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
71501 + grsec_enable_chroot_caps = 1;
71502 +#endif
71503 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
71504 + grsec_enable_chroot_sysctl = 1;
71505 +#endif
71506 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71507 + grsec_enable_symlinkown = 1;
71508 + grsec_symlinkown_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SYMLINKOWN_GID);
71509 +#endif
71510 +#ifdef CONFIG_GRKERNSEC_TPE
71511 + grsec_enable_tpe = 1;
71512 + grsec_tpe_gid = KGIDT_INIT(CONFIG_GRKERNSEC_TPE_GID);
71513 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
71514 + grsec_enable_tpe_all = 1;
71515 +#endif
71516 +#endif
71517 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
71518 + grsec_enable_socket_all = 1;
71519 + grsec_socket_all_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_ALL_GID);
71520 +#endif
71521 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
71522 + grsec_enable_socket_client = 1;
71523 + grsec_socket_client_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_CLIENT_GID);
71524 +#endif
71525 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
71526 + grsec_enable_socket_server = 1;
71527 + grsec_socket_server_gid = KGIDT_INIT(CONFIG_GRKERNSEC_SOCKET_SERVER_GID);
71528 +#endif
71529 +#endif
71530 +#ifdef CONFIG_GRKERNSEC_DENYUSB_FORCE
71531 + grsec_deny_new_usb = 1;
71532 +#endif
71533 +
71534 + return;
71535 +}
71536 diff --git a/grsecurity/grsec_ipc.c b/grsecurity/grsec_ipc.c
71537 new file mode 100644
71538 index 0000000..78d1680
71539 --- /dev/null
71540 +++ b/grsecurity/grsec_ipc.c
71541 @@ -0,0 +1,48 @@
71542 +#include <linux/kernel.h>
71543 +#include <linux/mm.h>
71544 +#include <linux/sched.h>
71545 +#include <linux/file.h>
71546 +#include <linux/ipc.h>
71547 +#include <linux/ipc_namespace.h>
71548 +#include <linux/grsecurity.h>
71549 +#include <linux/grinternal.h>
71550 +
71551 +int
71552 +gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode)
71553 +{
71554 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
71555 + int write;
71556 + int orig_granted_mode;
71557 + kuid_t euid;
71558 + kgid_t egid;
71559 +
71560 + if (!grsec_enable_harden_ipc)
71561 + return 0;
71562 +
71563 + euid = current_euid();
71564 + egid = current_egid();
71565 +
71566 + write = requested_mode & 00002;
71567 + orig_granted_mode = ipcp->mode;
71568 +
71569 + if (uid_eq(euid, ipcp->cuid) || uid_eq(euid, ipcp->uid))
71570 + orig_granted_mode >>= 6;
71571 + else {
71572 + /* if likely wrong permissions, lock to user */
71573 + if (orig_granted_mode & 0007)
71574 + orig_granted_mode = 0;
71575 + /* otherwise do a egid-only check */
71576 + else if (gid_eq(egid, ipcp->cgid) || gid_eq(egid, ipcp->gid))
71577 + orig_granted_mode >>= 3;
71578 + /* otherwise, no access */
71579 + else
71580 + orig_granted_mode = 0;
71581 + }
71582 + if (!(requested_mode & ~granted_mode & 0007) && (requested_mode & ~orig_granted_mode & 0007) &&
71583 + !ns_capable_nolog(ns->user_ns, CAP_IPC_OWNER)) {
71584 + gr_log_str_int(GR_DONT_AUDIT, GR_IPC_DENIED_MSG, write ? "write" : "read", GR_GLOBAL_UID(ipcp->cuid));
71585 + return 0;
71586 + }
71587 +#endif
71588 + return 1;
71589 +}
71590 diff --git a/grsecurity/grsec_link.c b/grsecurity/grsec_link.c
71591 new file mode 100644
71592 index 0000000..5e05e20
71593 --- /dev/null
71594 +++ b/grsecurity/grsec_link.c
71595 @@ -0,0 +1,58 @@
71596 +#include <linux/kernel.h>
71597 +#include <linux/sched.h>
71598 +#include <linux/fs.h>
71599 +#include <linux/file.h>
71600 +#include <linux/grinternal.h>
71601 +
71602 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target)
71603 +{
71604 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
71605 + const struct inode *link_inode = link->dentry->d_inode;
71606 +
71607 + if (grsec_enable_symlinkown && in_group_p(grsec_symlinkown_gid) &&
71608 + /* ignore root-owned links, e.g. /proc/self */
71609 + gr_is_global_nonroot(link_inode->i_uid) && target &&
71610 + !uid_eq(link_inode->i_uid, target->i_uid)) {
71611 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINKOWNER_MSG, link->dentry, link->mnt, link_inode->i_uid, target->i_uid);
71612 + return 1;
71613 + }
71614 +#endif
71615 + return 0;
71616 +}
71617 +
71618 +int
71619 +gr_handle_follow_link(const struct inode *parent,
71620 + const struct inode *inode,
71621 + const struct dentry *dentry, const struct vfsmount *mnt)
71622 +{
71623 +#ifdef CONFIG_GRKERNSEC_LINK
71624 + const struct cred *cred = current_cred();
71625 +
71626 + if (grsec_enable_link && S_ISLNK(inode->i_mode) &&
71627 + (parent->i_mode & S_ISVTX) && !uid_eq(parent->i_uid, inode->i_uid) &&
71628 + (parent->i_mode & S_IWOTH) && !uid_eq(cred->fsuid, inode->i_uid)) {
71629 + gr_log_fs_int2(GR_DONT_AUDIT, GR_SYMLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid);
71630 + return -EACCES;
71631 + }
71632 +#endif
71633 + return 0;
71634 +}
71635 +
71636 +int
71637 +gr_handle_hardlink(const struct dentry *dentry,
71638 + const struct vfsmount *mnt,
71639 + struct inode *inode, const int mode, const struct filename *to)
71640 +{
71641 +#ifdef CONFIG_GRKERNSEC_LINK
71642 + const struct cred *cred = current_cred();
71643 +
71644 + if (grsec_enable_link && !uid_eq(cred->fsuid, inode->i_uid) &&
71645 + (!S_ISREG(mode) || is_privileged_binary(dentry) ||
71646 + (inode_permission(inode, MAY_READ | MAY_WRITE))) &&
71647 + !capable(CAP_FOWNER) && gr_is_global_nonroot(cred->uid)) {
71648 + gr_log_fs_int2_str(GR_DONT_AUDIT, GR_HARDLINK_MSG, dentry, mnt, inode->i_uid, inode->i_gid, to->name);
71649 + return -EPERM;
71650 + }
71651 +#endif
71652 + return 0;
71653 +}
71654 diff --git a/grsecurity/grsec_log.c b/grsecurity/grsec_log.c
71655 new file mode 100644
71656 index 0000000..dbe0a6b
71657 --- /dev/null
71658 +++ b/grsecurity/grsec_log.c
71659 @@ -0,0 +1,341 @@
71660 +#include <linux/kernel.h>
71661 +#include <linux/sched.h>
71662 +#include <linux/file.h>
71663 +#include <linux/tty.h>
71664 +#include <linux/fs.h>
71665 +#include <linux/mm.h>
71666 +#include <linux/grinternal.h>
71667 +
71668 +#ifdef CONFIG_TREE_PREEMPT_RCU
71669 +#define DISABLE_PREEMPT() preempt_disable()
71670 +#define ENABLE_PREEMPT() preempt_enable()
71671 +#else
71672 +#define DISABLE_PREEMPT()
71673 +#define ENABLE_PREEMPT()
71674 +#endif
71675 +
71676 +#define BEGIN_LOCKS(x) \
71677 + DISABLE_PREEMPT(); \
71678 + rcu_read_lock(); \
71679 + read_lock(&tasklist_lock); \
71680 + read_lock(&grsec_exec_file_lock); \
71681 + if (x != GR_DO_AUDIT) \
71682 + spin_lock(&grsec_alert_lock); \
71683 + else \
71684 + spin_lock(&grsec_audit_lock)
71685 +
71686 +#define END_LOCKS(x) \
71687 + if (x != GR_DO_AUDIT) \
71688 + spin_unlock(&grsec_alert_lock); \
71689 + else \
71690 + spin_unlock(&grsec_audit_lock); \
71691 + read_unlock(&grsec_exec_file_lock); \
71692 + read_unlock(&tasklist_lock); \
71693 + rcu_read_unlock(); \
71694 + ENABLE_PREEMPT(); \
71695 + if (x == GR_DONT_AUDIT) \
71696 + gr_handle_alertkill(current)
71697 +
71698 +enum {
71699 + FLOODING,
71700 + NO_FLOODING
71701 +};
71702 +
71703 +extern char *gr_alert_log_fmt;
71704 +extern char *gr_audit_log_fmt;
71705 +extern char *gr_alert_log_buf;
71706 +extern char *gr_audit_log_buf;
71707 +
71708 +static int gr_log_start(int audit)
71709 +{
71710 + char *loglevel = (audit == GR_DO_AUDIT) ? KERN_INFO : KERN_ALERT;
71711 + char *fmt = (audit == GR_DO_AUDIT) ? gr_audit_log_fmt : gr_alert_log_fmt;
71712 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71713 +#if (CONFIG_GRKERNSEC_FLOODTIME > 0 && CONFIG_GRKERNSEC_FLOODBURST > 0)
71714 + unsigned long curr_secs = get_seconds();
71715 +
71716 + if (audit == GR_DO_AUDIT)
71717 + goto set_fmt;
71718 +
71719 + if (!grsec_alert_wtime || time_after(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)) {
71720 + grsec_alert_wtime = curr_secs;
71721 + grsec_alert_fyet = 0;
71722 + } else if (time_before_eq(curr_secs, grsec_alert_wtime + CONFIG_GRKERNSEC_FLOODTIME)
71723 + && (grsec_alert_fyet < CONFIG_GRKERNSEC_FLOODBURST)) {
71724 + grsec_alert_fyet++;
71725 + } else if (grsec_alert_fyet == CONFIG_GRKERNSEC_FLOODBURST) {
71726 + grsec_alert_wtime = curr_secs;
71727 + grsec_alert_fyet++;
71728 + printk(KERN_ALERT "grsec: more alerts, logging disabled for %d seconds\n", CONFIG_GRKERNSEC_FLOODTIME);
71729 + return FLOODING;
71730 + }
71731 + else return FLOODING;
71732 +
71733 +set_fmt:
71734 +#endif
71735 + memset(buf, 0, PAGE_SIZE);
71736 + if (current->signal->curr_ip && gr_acl_is_enabled()) {
71737 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: (%.64s:%c:%.950s) ");
71738 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71739 + } else if (current->signal->curr_ip) {
71740 + sprintf(fmt, "%s%s", loglevel, "grsec: From %pI4: ");
71741 + snprintf(buf, PAGE_SIZE - 1, fmt, &current->signal->curr_ip);
71742 + } else if (gr_acl_is_enabled()) {
71743 + sprintf(fmt, "%s%s", loglevel, "grsec: (%.64s:%c:%.950s) ");
71744 + snprintf(buf, PAGE_SIZE - 1, fmt, current->role->rolename, gr_roletype_to_char(), current->acl->filename);
71745 + } else {
71746 + sprintf(fmt, "%s%s", loglevel, "grsec: ");
71747 + strcpy(buf, fmt);
71748 + }
71749 +
71750 + return NO_FLOODING;
71751 +}
71752 +
71753 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71754 + __attribute__ ((format (printf, 2, 0)));
71755 +
71756 +static void gr_log_middle(int audit, const char *msg, va_list ap)
71757 +{
71758 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71759 + unsigned int len = strlen(buf);
71760 +
71761 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71762 +
71763 + return;
71764 +}
71765 +
71766 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71767 + __attribute__ ((format (printf, 2, 3)));
71768 +
71769 +static void gr_log_middle_varargs(int audit, const char *msg, ...)
71770 +{
71771 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71772 + unsigned int len = strlen(buf);
71773 + va_list ap;
71774 +
71775 + va_start(ap, msg);
71776 + vsnprintf(buf + len, PAGE_SIZE - len - 1, msg, ap);
71777 + va_end(ap);
71778 +
71779 + return;
71780 +}
71781 +
71782 +static void gr_log_end(int audit, int append_default)
71783 +{
71784 + char *buf = (audit == GR_DO_AUDIT) ? gr_audit_log_buf : gr_alert_log_buf;
71785 + if (append_default) {
71786 + struct task_struct *task = current;
71787 + struct task_struct *parent = task->real_parent;
71788 + const struct cred *cred = __task_cred(task);
71789 + const struct cred *pcred = __task_cred(parent);
71790 + unsigned int len = strlen(buf);
71791 +
71792 + 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));
71793 + }
71794 +
71795 + printk("%s\n", buf);
71796 +
71797 + return;
71798 +}
71799 +
71800 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...)
71801 +{
71802 + int logtype;
71803 + char *result = (audit == GR_DO_AUDIT) ? "successful" : "denied";
71804 + char *str1 = NULL, *str2 = NULL, *str3 = NULL;
71805 + void *voidptr = NULL;
71806 + int num1 = 0, num2 = 0;
71807 + unsigned long ulong1 = 0, ulong2 = 0;
71808 + struct dentry *dentry = NULL;
71809 + struct vfsmount *mnt = NULL;
71810 + struct file *file = NULL;
71811 + struct task_struct *task = NULL;
71812 + struct vm_area_struct *vma = NULL;
71813 + const struct cred *cred, *pcred;
71814 + va_list ap;
71815 +
71816 + BEGIN_LOCKS(audit);
71817 + logtype = gr_log_start(audit);
71818 + if (logtype == FLOODING) {
71819 + END_LOCKS(audit);
71820 + return;
71821 + }
71822 + va_start(ap, argtypes);
71823 + switch (argtypes) {
71824 + case GR_TTYSNIFF:
71825 + task = va_arg(ap, struct task_struct *);
71826 + 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));
71827 + break;
71828 + case GR_SYSCTL_HIDDEN:
71829 + str1 = va_arg(ap, char *);
71830 + gr_log_middle_varargs(audit, msg, result, str1);
71831 + break;
71832 + case GR_RBAC:
71833 + dentry = va_arg(ap, struct dentry *);
71834 + mnt = va_arg(ap, struct vfsmount *);
71835 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt));
71836 + break;
71837 + case GR_RBAC_STR:
71838 + dentry = va_arg(ap, struct dentry *);
71839 + mnt = va_arg(ap, struct vfsmount *);
71840 + str1 = va_arg(ap, char *);
71841 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1);
71842 + break;
71843 + case GR_STR_RBAC:
71844 + str1 = va_arg(ap, char *);
71845 + dentry = va_arg(ap, struct dentry *);
71846 + mnt = va_arg(ap, struct vfsmount *);
71847 + gr_log_middle_varargs(audit, msg, result, str1, gr_to_filename(dentry, mnt));
71848 + break;
71849 + case GR_RBAC_MODE2:
71850 + dentry = va_arg(ap, struct dentry *);
71851 + mnt = va_arg(ap, struct vfsmount *);
71852 + str1 = va_arg(ap, char *);
71853 + str2 = va_arg(ap, char *);
71854 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2);
71855 + break;
71856 + case GR_RBAC_MODE3:
71857 + dentry = va_arg(ap, struct dentry *);
71858 + mnt = va_arg(ap, struct vfsmount *);
71859 + str1 = va_arg(ap, char *);
71860 + str2 = va_arg(ap, char *);
71861 + str3 = va_arg(ap, char *);
71862 + gr_log_middle_varargs(audit, msg, result, gr_to_filename(dentry, mnt), str1, str2, str3);
71863 + break;
71864 + case GR_FILENAME:
71865 + dentry = va_arg(ap, struct dentry *);
71866 + mnt = va_arg(ap, struct vfsmount *);
71867 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt));
71868 + break;
71869 + case GR_STR_FILENAME:
71870 + str1 = va_arg(ap, char *);
71871 + dentry = va_arg(ap, struct dentry *);
71872 + mnt = va_arg(ap, struct vfsmount *);
71873 + gr_log_middle_varargs(audit, msg, str1, gr_to_filename(dentry, mnt));
71874 + break;
71875 + case GR_FILENAME_STR:
71876 + dentry = va_arg(ap, struct dentry *);
71877 + mnt = va_arg(ap, struct vfsmount *);
71878 + str1 = va_arg(ap, char *);
71879 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), str1);
71880 + break;
71881 + case GR_FILENAME_TWO_INT:
71882 + dentry = va_arg(ap, struct dentry *);
71883 + mnt = va_arg(ap, struct vfsmount *);
71884 + num1 = va_arg(ap, int);
71885 + num2 = va_arg(ap, int);
71886 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2);
71887 + break;
71888 + case GR_FILENAME_TWO_INT_STR:
71889 + dentry = va_arg(ap, struct dentry *);
71890 + mnt = va_arg(ap, struct vfsmount *);
71891 + num1 = va_arg(ap, int);
71892 + num2 = va_arg(ap, int);
71893 + str1 = va_arg(ap, char *);
71894 + gr_log_middle_varargs(audit, msg, gr_to_filename(dentry, mnt), num1, num2, str1);
71895 + break;
71896 + case GR_TEXTREL:
71897 + file = va_arg(ap, struct file *);
71898 + ulong1 = va_arg(ap, unsigned long);
71899 + ulong2 = va_arg(ap, unsigned long);
71900 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>", ulong1, ulong2);
71901 + break;
71902 + case GR_PTRACE:
71903 + task = va_arg(ap, struct task_struct *);
71904 + 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));
71905 + break;
71906 + case GR_RESOURCE:
71907 + task = va_arg(ap, struct task_struct *);
71908 + cred = __task_cred(task);
71909 + pcred = __task_cred(task->real_parent);
71910 + ulong1 = va_arg(ap, unsigned long);
71911 + str1 = va_arg(ap, char *);
71912 + ulong2 = va_arg(ap, unsigned long);
71913 + 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));
71914 + break;
71915 + case GR_CAP:
71916 + task = va_arg(ap, struct task_struct *);
71917 + cred = __task_cred(task);
71918 + pcred = __task_cred(task->real_parent);
71919 + str1 = va_arg(ap, char *);
71920 + 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));
71921 + break;
71922 + case GR_SIG:
71923 + str1 = va_arg(ap, char *);
71924 + voidptr = va_arg(ap, void *);
71925 + gr_log_middle_varargs(audit, msg, str1, voidptr);
71926 + break;
71927 + case GR_SIG2:
71928 + task = va_arg(ap, struct task_struct *);
71929 + cred = __task_cred(task);
71930 + pcred = __task_cred(task->real_parent);
71931 + num1 = va_arg(ap, int);
71932 + 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));
71933 + break;
71934 + case GR_CRASH1:
71935 + task = va_arg(ap, struct task_struct *);
71936 + cred = __task_cred(task);
71937 + pcred = __task_cred(task->real_parent);
71938 + ulong1 = va_arg(ap, unsigned long);
71939 + 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);
71940 + break;
71941 + case GR_CRASH2:
71942 + task = va_arg(ap, struct task_struct *);
71943 + cred = __task_cred(task);
71944 + pcred = __task_cred(task->real_parent);
71945 + ulong1 = va_arg(ap, unsigned long);
71946 + 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);
71947 + break;
71948 + case GR_RWXMAP:
71949 + file = va_arg(ap, struct file *);
71950 + gr_log_middle_varargs(audit, msg, file ? gr_to_filename(file->f_path.dentry, file->f_path.mnt) : "<anonymous mapping>");
71951 + break;
71952 + case GR_RWXMAPVMA:
71953 + vma = va_arg(ap, struct vm_area_struct *);
71954 + if (vma->vm_file)
71955 + str1 = gr_to_filename(vma->vm_file->f_path.dentry, vma->vm_file->f_path.mnt);
71956 + else if (vma->vm_flags & (VM_GROWSDOWN | VM_GROWSUP))
71957 + str1 = "<stack>";
71958 + else if (vma->vm_start <= current->mm->brk &&
71959 + vma->vm_end >= current->mm->start_brk)
71960 + str1 = "<heap>";
71961 + else
71962 + str1 = "<anonymous mapping>";
71963 + gr_log_middle_varargs(audit, msg, str1);
71964 + break;
71965 + case GR_PSACCT:
71966 + {
71967 + unsigned int wday, cday;
71968 + __u8 whr, chr;
71969 + __u8 wmin, cmin;
71970 + __u8 wsec, csec;
71971 + char cur_tty[64] = { 0 };
71972 + char parent_tty[64] = { 0 };
71973 +
71974 + task = va_arg(ap, struct task_struct *);
71975 + wday = va_arg(ap, unsigned int);
71976 + cday = va_arg(ap, unsigned int);
71977 + whr = va_arg(ap, int);
71978 + chr = va_arg(ap, int);
71979 + wmin = va_arg(ap, int);
71980 + cmin = va_arg(ap, int);
71981 + wsec = va_arg(ap, int);
71982 + csec = va_arg(ap, int);
71983 + ulong1 = va_arg(ap, unsigned long);
71984 + cred = __task_cred(task);
71985 + pcred = __task_cred(task->real_parent);
71986 +
71987 + 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));
71988 + }
71989 + break;
71990 + default:
71991 + gr_log_middle(audit, msg, ap);
71992 + }
71993 + va_end(ap);
71994 + // these don't need DEFAULTSECARGS printed on the end
71995 + if (argtypes == GR_CRASH1 || argtypes == GR_CRASH2)
71996 + gr_log_end(audit, 0);
71997 + else
71998 + gr_log_end(audit, 1);
71999 + END_LOCKS(audit);
72000 +}
72001 diff --git a/grsecurity/grsec_mem.c b/grsecurity/grsec_mem.c
72002 new file mode 100644
72003 index 0000000..f536303
72004 --- /dev/null
72005 +++ b/grsecurity/grsec_mem.c
72006 @@ -0,0 +1,40 @@
72007 +#include <linux/kernel.h>
72008 +#include <linux/sched.h>
72009 +#include <linux/mm.h>
72010 +#include <linux/mman.h>
72011 +#include <linux/grinternal.h>
72012 +
72013 +void
72014 +gr_handle_ioperm(void)
72015 +{
72016 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPERM_MSG);
72017 + return;
72018 +}
72019 +
72020 +void
72021 +gr_handle_iopl(void)
72022 +{
72023 + gr_log_noargs(GR_DONT_AUDIT, GR_IOPL_MSG);
72024 + return;
72025 +}
72026 +
72027 +void
72028 +gr_handle_mem_readwrite(u64 from, u64 to)
72029 +{
72030 + gr_log_two_u64(GR_DONT_AUDIT, GR_MEM_READWRITE_MSG, from, to);
72031 + return;
72032 +}
72033 +
72034 +void
72035 +gr_handle_vm86(void)
72036 +{
72037 + gr_log_noargs(GR_DONT_AUDIT, GR_VM86_MSG);
72038 + return;
72039 +}
72040 +
72041 +void
72042 +gr_log_badprocpid(const char *entry)
72043 +{
72044 + gr_log_str(GR_DONT_AUDIT, GR_BADPROCPID_MSG, entry);
72045 + return;
72046 +}
72047 diff --git a/grsecurity/grsec_mount.c b/grsecurity/grsec_mount.c
72048 new file mode 100644
72049 index 0000000..cd9e124
72050 --- /dev/null
72051 +++ b/grsecurity/grsec_mount.c
72052 @@ -0,0 +1,65 @@
72053 +#include <linux/kernel.h>
72054 +#include <linux/sched.h>
72055 +#include <linux/mount.h>
72056 +#include <linux/major.h>
72057 +#include <linux/grsecurity.h>
72058 +#include <linux/grinternal.h>
72059 +
72060 +void
72061 +gr_log_remount(const char *devname, const int retval)
72062 +{
72063 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72064 + if (grsec_enable_mount && (retval >= 0))
72065 + gr_log_str(GR_DO_AUDIT, GR_REMOUNT_AUDIT_MSG, devname ? devname : "none");
72066 +#endif
72067 + return;
72068 +}
72069 +
72070 +void
72071 +gr_log_unmount(const char *devname, const int retval)
72072 +{
72073 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72074 + if (grsec_enable_mount && (retval >= 0))
72075 + gr_log_str(GR_DO_AUDIT, GR_UNMOUNT_AUDIT_MSG, devname ? devname : "none");
72076 +#endif
72077 + return;
72078 +}
72079 +
72080 +void
72081 +gr_log_mount(const char *from, const char *to, const int retval)
72082 +{
72083 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
72084 + if (grsec_enable_mount && (retval >= 0))
72085 + gr_log_str_str(GR_DO_AUDIT, GR_MOUNT_AUDIT_MSG, from ? from : "none", to);
72086 +#endif
72087 + return;
72088 +}
72089 +
72090 +int
72091 +gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags)
72092 +{
72093 +#ifdef CONFIG_GRKERNSEC_ROFS
72094 + if (grsec_enable_rofs && !(mnt_flags & MNT_READONLY)) {
72095 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_MOUNT_MSG, dentry, mnt);
72096 + return -EPERM;
72097 + } else
72098 + return 0;
72099 +#endif
72100 + return 0;
72101 +}
72102 +
72103 +int
72104 +gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode)
72105 +{
72106 +#ifdef CONFIG_GRKERNSEC_ROFS
72107 + struct inode *inode = dentry->d_inode;
72108 +
72109 + if (grsec_enable_rofs && (acc_mode & MAY_WRITE) &&
72110 + inode && (S_ISBLK(inode->i_mode) || (S_ISCHR(inode->i_mode) && imajor(inode) == RAW_MAJOR))) {
72111 + gr_log_fs_generic(GR_DO_AUDIT, GR_ROFS_BLOCKWRITE_MSG, dentry, mnt);
72112 + return -EPERM;
72113 + } else
72114 + return 0;
72115 +#endif
72116 + return 0;
72117 +}
72118 diff --git a/grsecurity/grsec_pax.c b/grsecurity/grsec_pax.c
72119 new file mode 100644
72120 index 0000000..6ee9d50
72121 --- /dev/null
72122 +++ b/grsecurity/grsec_pax.c
72123 @@ -0,0 +1,45 @@
72124 +#include <linux/kernel.h>
72125 +#include <linux/sched.h>
72126 +#include <linux/mm.h>
72127 +#include <linux/file.h>
72128 +#include <linux/grinternal.h>
72129 +#include <linux/grsecurity.h>
72130 +
72131 +void
72132 +gr_log_textrel(struct vm_area_struct * vma)
72133 +{
72134 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72135 + if (grsec_enable_log_rwxmaps)
72136 + gr_log_textrel_ulong_ulong(GR_DONT_AUDIT, GR_TEXTREL_AUDIT_MSG, vma->vm_file, vma->vm_start, vma->vm_pgoff);
72137 +#endif
72138 + return;
72139 +}
72140 +
72141 +void gr_log_ptgnustack(struct file *file)
72142 +{
72143 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72144 + if (grsec_enable_log_rwxmaps)
72145 + gr_log_rwxmap(GR_DONT_AUDIT, GR_PTGNUSTACK_MSG, file);
72146 +#endif
72147 + return;
72148 +}
72149 +
72150 +void
72151 +gr_log_rwxmmap(struct file *file)
72152 +{
72153 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72154 + if (grsec_enable_log_rwxmaps)
72155 + gr_log_rwxmap(GR_DONT_AUDIT, GR_RWXMMAP_MSG, file);
72156 +#endif
72157 + return;
72158 +}
72159 +
72160 +void
72161 +gr_log_rwxmprotect(struct vm_area_struct *vma)
72162 +{
72163 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72164 + if (grsec_enable_log_rwxmaps)
72165 + gr_log_rwxmap_vma(GR_DONT_AUDIT, GR_RWXMPROTECT_MSG, vma);
72166 +#endif
72167 + return;
72168 +}
72169 diff --git a/grsecurity/grsec_ptrace.c b/grsecurity/grsec_ptrace.c
72170 new file mode 100644
72171 index 0000000..f7f29aa
72172 --- /dev/null
72173 +++ b/grsecurity/grsec_ptrace.c
72174 @@ -0,0 +1,30 @@
72175 +#include <linux/kernel.h>
72176 +#include <linux/sched.h>
72177 +#include <linux/grinternal.h>
72178 +#include <linux/security.h>
72179 +
72180 +void
72181 +gr_audit_ptrace(struct task_struct *task)
72182 +{
72183 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
72184 + if (grsec_enable_audit_ptrace)
72185 + gr_log_ptrace(GR_DO_AUDIT, GR_PTRACE_AUDIT_MSG, task);
72186 +#endif
72187 + return;
72188 +}
72189 +
72190 +int
72191 +gr_ptrace_readexec(struct file *file, int unsafe_flags)
72192 +{
72193 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
72194 + const struct dentry *dentry = file->f_path.dentry;
72195 + const struct vfsmount *mnt = file->f_path.mnt;
72196 +
72197 + if (grsec_enable_ptrace_readexec && (unsafe_flags & LSM_UNSAFE_PTRACE) &&
72198 + (inode_permission(dentry->d_inode, MAY_READ) || !gr_acl_handle_open(dentry, mnt, MAY_READ))) {
72199 + gr_log_fs_generic(GR_DONT_AUDIT, GR_PTRACE_READEXEC_MSG, dentry, mnt);
72200 + return -EACCES;
72201 + }
72202 +#endif
72203 + return 0;
72204 +}
72205 diff --git a/grsecurity/grsec_sig.c b/grsecurity/grsec_sig.c
72206 new file mode 100644
72207 index 0000000..3860c7e
72208 --- /dev/null
72209 +++ b/grsecurity/grsec_sig.c
72210 @@ -0,0 +1,236 @@
72211 +#include <linux/kernel.h>
72212 +#include <linux/sched.h>
72213 +#include <linux/fs.h>
72214 +#include <linux/delay.h>
72215 +#include <linux/grsecurity.h>
72216 +#include <linux/grinternal.h>
72217 +#include <linux/hardirq.h>
72218 +
72219 +char *signames[] = {
72220 + [SIGSEGV] = "Segmentation fault",
72221 + [SIGILL] = "Illegal instruction",
72222 + [SIGABRT] = "Abort",
72223 + [SIGBUS] = "Invalid alignment/Bus error"
72224 +};
72225 +
72226 +void
72227 +gr_log_signal(const int sig, const void *addr, const struct task_struct *t)
72228 +{
72229 +#ifdef CONFIG_GRKERNSEC_SIGNAL
72230 + if (grsec_enable_signal && ((sig == SIGSEGV) || (sig == SIGILL) ||
72231 + (sig == SIGABRT) || (sig == SIGBUS))) {
72232 + if (task_pid_nr(t) == task_pid_nr(current)) {
72233 + gr_log_sig_addr(GR_DONT_AUDIT_GOOD, GR_UNISIGLOG_MSG, signames[sig], addr);
72234 + } else {
72235 + gr_log_sig_task(GR_DONT_AUDIT_GOOD, GR_DUALSIGLOG_MSG, t, sig);
72236 + }
72237 + }
72238 +#endif
72239 + return;
72240 +}
72241 +
72242 +int
72243 +gr_handle_signal(const struct task_struct *p, const int sig)
72244 +{
72245 +#ifdef CONFIG_GRKERNSEC
72246 + /* ignore the 0 signal for protected task checks */
72247 + if (task_pid_nr(current) > 1 && sig && gr_check_protected_task(p)) {
72248 + gr_log_sig_task(GR_DONT_AUDIT, GR_SIG_ACL_MSG, p, sig);
72249 + return -EPERM;
72250 + } else if (gr_pid_is_chrooted((struct task_struct *)p)) {
72251 + return -EPERM;
72252 + }
72253 +#endif
72254 + return 0;
72255 +}
72256 +
72257 +#ifdef CONFIG_GRKERNSEC
72258 +extern int specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t);
72259 +
72260 +int gr_fake_force_sig(int sig, struct task_struct *t)
72261 +{
72262 + unsigned long int flags;
72263 + int ret, blocked, ignored;
72264 + struct k_sigaction *action;
72265 +
72266 + spin_lock_irqsave(&t->sighand->siglock, flags);
72267 + action = &t->sighand->action[sig-1];
72268 + ignored = action->sa.sa_handler == SIG_IGN;
72269 + blocked = sigismember(&t->blocked, sig);
72270 + if (blocked || ignored) {
72271 + action->sa.sa_handler = SIG_DFL;
72272 + if (blocked) {
72273 + sigdelset(&t->blocked, sig);
72274 + recalc_sigpending_and_wake(t);
72275 + }
72276 + }
72277 + if (action->sa.sa_handler == SIG_DFL)
72278 + t->signal->flags &= ~SIGNAL_UNKILLABLE;
72279 + ret = specific_send_sig_info(sig, SEND_SIG_PRIV, t);
72280 +
72281 + spin_unlock_irqrestore(&t->sighand->siglock, flags);
72282 +
72283 + return ret;
72284 +}
72285 +#endif
72286 +
72287 +#define GR_USER_BAN_TIME (15 * 60)
72288 +#define GR_DAEMON_BRUTE_TIME (30 * 60)
72289 +
72290 +void gr_handle_brute_attach(int dumpable)
72291 +{
72292 +#ifdef CONFIG_GRKERNSEC_BRUTE
72293 + struct task_struct *p = current;
72294 + kuid_t uid = GLOBAL_ROOT_UID;
72295 + int daemon = 0;
72296 +
72297 + if (!grsec_enable_brute)
72298 + return;
72299 +
72300 + rcu_read_lock();
72301 + read_lock(&tasklist_lock);
72302 + read_lock(&grsec_exec_file_lock);
72303 + if (p->real_parent && gr_is_same_file(p->real_parent->exec_file, p->exec_file)) {
72304 + p->real_parent->brute_expires = get_seconds() + GR_DAEMON_BRUTE_TIME;
72305 + p->real_parent->brute = 1;
72306 + daemon = 1;
72307 + } else {
72308 + const struct cred *cred = __task_cred(p), *cred2;
72309 + struct task_struct *tsk, *tsk2;
72310 +
72311 + if (dumpable != SUID_DUMP_USER && gr_is_global_nonroot(cred->uid)) {
72312 + struct user_struct *user;
72313 +
72314 + uid = cred->uid;
72315 +
72316 + /* this is put upon execution past expiration */
72317 + user = find_user(uid);
72318 + if (user == NULL)
72319 + goto unlock;
72320 + user->suid_banned = 1;
72321 + user->suid_ban_expires = get_seconds() + GR_USER_BAN_TIME;
72322 + if (user->suid_ban_expires == ~0UL)
72323 + user->suid_ban_expires--;
72324 +
72325 + /* only kill other threads of the same binary, from the same user */
72326 + do_each_thread(tsk2, tsk) {
72327 + cred2 = __task_cred(tsk);
72328 + if (tsk != p && uid_eq(cred2->uid, uid) && gr_is_same_file(tsk->exec_file, p->exec_file))
72329 + gr_fake_force_sig(SIGKILL, tsk);
72330 + } while_each_thread(tsk2, tsk);
72331 + }
72332 + }
72333 +unlock:
72334 + read_unlock(&grsec_exec_file_lock);
72335 + read_unlock(&tasklist_lock);
72336 + rcu_read_unlock();
72337 +
72338 + if (gr_is_global_nonroot(uid))
72339 + 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);
72340 + else if (daemon)
72341 + gr_log_noargs(GR_DONT_AUDIT, GR_BRUTE_DAEMON_MSG);
72342 +
72343 +#endif
72344 + return;
72345 +}
72346 +
72347 +void gr_handle_brute_check(void)
72348 +{
72349 +#ifdef CONFIG_GRKERNSEC_BRUTE
72350 + struct task_struct *p = current;
72351 +
72352 + if (unlikely(p->brute)) {
72353 + if (!grsec_enable_brute)
72354 + p->brute = 0;
72355 + else if (time_before(get_seconds(), p->brute_expires))
72356 + msleep(30 * 1000);
72357 + }
72358 +#endif
72359 + return;
72360 +}
72361 +
72362 +void gr_handle_kernel_exploit(void)
72363 +{
72364 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72365 + const struct cred *cred;
72366 + struct task_struct *tsk, *tsk2;
72367 + struct user_struct *user;
72368 + kuid_t uid;
72369 +
72370 + if (in_irq() || in_serving_softirq() || in_nmi())
72371 + panic("grsec: halting the system due to suspicious kernel crash caused in interrupt context");
72372 +
72373 + uid = current_uid();
72374 +
72375 + if (gr_is_global_root(uid))
72376 + panic("grsec: halting the system due to suspicious kernel crash caused by root");
72377 + else {
72378 + /* kill all the processes of this user, hold a reference
72379 + to their creds struct, and prevent them from creating
72380 + another process until system reset
72381 + */
72382 + printk(KERN_ALERT "grsec: banning user with uid %u until system restart for suspicious kernel crash\n",
72383 + GR_GLOBAL_UID(uid));
72384 + /* we intentionally leak this ref */
72385 + user = get_uid(current->cred->user);
72386 + if (user)
72387 + user->kernel_banned = 1;
72388 +
72389 + /* kill all processes of this user */
72390 + read_lock(&tasklist_lock);
72391 + do_each_thread(tsk2, tsk) {
72392 + cred = __task_cred(tsk);
72393 + if (uid_eq(cred->uid, uid))
72394 + gr_fake_force_sig(SIGKILL, tsk);
72395 + } while_each_thread(tsk2, tsk);
72396 + read_unlock(&tasklist_lock);
72397 + }
72398 +#endif
72399 +}
72400 +
72401 +#ifdef CONFIG_GRKERNSEC_BRUTE
72402 +static bool suid_ban_expired(struct user_struct *user)
72403 +{
72404 + if (user->suid_ban_expires != ~0UL && time_after_eq(get_seconds(), user->suid_ban_expires)) {
72405 + user->suid_banned = 0;
72406 + user->suid_ban_expires = 0;
72407 + free_uid(user);
72408 + return true;
72409 + }
72410 +
72411 + return false;
72412 +}
72413 +#endif
72414 +
72415 +int gr_process_kernel_exec_ban(void)
72416 +{
72417 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72418 + if (unlikely(current->cred->user->kernel_banned))
72419 + return -EPERM;
72420 +#endif
72421 + return 0;
72422 +}
72423 +
72424 +int gr_process_kernel_setuid_ban(struct user_struct *user)
72425 +{
72426 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
72427 + if (unlikely(user->kernel_banned))
72428 + gr_fake_force_sig(SIGKILL, current);
72429 +#endif
72430 + return 0;
72431 +}
72432 +
72433 +int gr_process_suid_exec_ban(const struct linux_binprm *bprm)
72434 +{
72435 +#ifdef CONFIG_GRKERNSEC_BRUTE
72436 + struct user_struct *user = current->cred->user;
72437 + if (unlikely(user->suid_banned)) {
72438 + if (suid_ban_expired(user))
72439 + return 0;
72440 + /* disallow execution of suid binaries only */
72441 + else if (!uid_eq(bprm->cred->euid, current->cred->uid))
72442 + return -EPERM;
72443 + }
72444 +#endif
72445 + return 0;
72446 +}
72447 diff --git a/grsecurity/grsec_sock.c b/grsecurity/grsec_sock.c
72448 new file mode 100644
72449 index 0000000..4030d57
72450 --- /dev/null
72451 +++ b/grsecurity/grsec_sock.c
72452 @@ -0,0 +1,244 @@
72453 +#include <linux/kernel.h>
72454 +#include <linux/module.h>
72455 +#include <linux/sched.h>
72456 +#include <linux/file.h>
72457 +#include <linux/net.h>
72458 +#include <linux/in.h>
72459 +#include <linux/ip.h>
72460 +#include <net/sock.h>
72461 +#include <net/inet_sock.h>
72462 +#include <linux/grsecurity.h>
72463 +#include <linux/grinternal.h>
72464 +#include <linux/gracl.h>
72465 +
72466 +extern int gr_search_udp_recvmsg(const struct sock *sk, const struct sk_buff *skb);
72467 +extern int gr_search_udp_sendmsg(const struct sock *sk, const struct sockaddr_in *addr);
72468 +
72469 +EXPORT_SYMBOL(gr_search_udp_recvmsg);
72470 +EXPORT_SYMBOL(gr_search_udp_sendmsg);
72471 +
72472 +#ifdef CONFIG_UNIX_MODULE
72473 +EXPORT_SYMBOL(gr_acl_handle_unix);
72474 +EXPORT_SYMBOL(gr_acl_handle_mknod);
72475 +EXPORT_SYMBOL(gr_handle_chroot_unix);
72476 +EXPORT_SYMBOL(gr_handle_create);
72477 +#endif
72478 +
72479 +#ifdef CONFIG_GRKERNSEC
72480 +#define gr_conn_table_size 32749
72481 +struct conn_table_entry {
72482 + struct conn_table_entry *next;
72483 + struct signal_struct *sig;
72484 +};
72485 +
72486 +struct conn_table_entry *gr_conn_table[gr_conn_table_size];
72487 +DEFINE_SPINLOCK(gr_conn_table_lock);
72488 +
72489 +extern const char * gr_socktype_to_name(unsigned char type);
72490 +extern const char * gr_proto_to_name(unsigned char proto);
72491 +extern const char * gr_sockfamily_to_name(unsigned char family);
72492 +
72493 +static __inline__ int
72494 +conn_hash(__u32 saddr, __u32 daddr, __u16 sport, __u16 dport, unsigned int size)
72495 +{
72496 + return ((daddr + saddr + (sport << 8) + (dport << 16)) % size);
72497 +}
72498 +
72499 +static __inline__ int
72500 +conn_match(const struct signal_struct *sig, __u32 saddr, __u32 daddr,
72501 + __u16 sport, __u16 dport)
72502 +{
72503 + if (unlikely(sig->gr_saddr == saddr && sig->gr_daddr == daddr &&
72504 + sig->gr_sport == sport && sig->gr_dport == dport))
72505 + return 1;
72506 + else
72507 + return 0;
72508 +}
72509 +
72510 +static void gr_add_to_task_ip_table_nolock(struct signal_struct *sig, struct conn_table_entry *newent)
72511 +{
72512 + struct conn_table_entry **match;
72513 + unsigned int index;
72514 +
72515 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72516 + sig->gr_sport, sig->gr_dport,
72517 + gr_conn_table_size);
72518 +
72519 + newent->sig = sig;
72520 +
72521 + match = &gr_conn_table[index];
72522 + newent->next = *match;
72523 + *match = newent;
72524 +
72525 + return;
72526 +}
72527 +
72528 +static void gr_del_task_from_ip_table_nolock(struct signal_struct *sig)
72529 +{
72530 + struct conn_table_entry *match, *last = NULL;
72531 + unsigned int index;
72532 +
72533 + index = conn_hash(sig->gr_saddr, sig->gr_daddr,
72534 + sig->gr_sport, sig->gr_dport,
72535 + gr_conn_table_size);
72536 +
72537 + match = gr_conn_table[index];
72538 + while (match && !conn_match(match->sig,
72539 + sig->gr_saddr, sig->gr_daddr, sig->gr_sport,
72540 + sig->gr_dport)) {
72541 + last = match;
72542 + match = match->next;
72543 + }
72544 +
72545 + if (match) {
72546 + if (last)
72547 + last->next = match->next;
72548 + else
72549 + gr_conn_table[index] = NULL;
72550 + kfree(match);
72551 + }
72552 +
72553 + return;
72554 +}
72555 +
72556 +static struct signal_struct * gr_lookup_task_ip_table(__u32 saddr, __u32 daddr,
72557 + __u16 sport, __u16 dport)
72558 +{
72559 + struct conn_table_entry *match;
72560 + unsigned int index;
72561 +
72562 + index = conn_hash(saddr, daddr, sport, dport, gr_conn_table_size);
72563 +
72564 + match = gr_conn_table[index];
72565 + while (match && !conn_match(match->sig, saddr, daddr, sport, dport))
72566 + match = match->next;
72567 +
72568 + if (match)
72569 + return match->sig;
72570 + else
72571 + return NULL;
72572 +}
72573 +
72574 +#endif
72575 +
72576 +void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet)
72577 +{
72578 +#ifdef CONFIG_GRKERNSEC
72579 + struct signal_struct *sig = task->signal;
72580 + struct conn_table_entry *newent;
72581 +
72582 + newent = kmalloc(sizeof(struct conn_table_entry), GFP_ATOMIC);
72583 + if (newent == NULL)
72584 + return;
72585 + /* no bh lock needed since we are called with bh disabled */
72586 + spin_lock(&gr_conn_table_lock);
72587 + gr_del_task_from_ip_table_nolock(sig);
72588 + sig->gr_saddr = inet->inet_rcv_saddr;
72589 + sig->gr_daddr = inet->inet_daddr;
72590 + sig->gr_sport = inet->inet_sport;
72591 + sig->gr_dport = inet->inet_dport;
72592 + gr_add_to_task_ip_table_nolock(sig, newent);
72593 + spin_unlock(&gr_conn_table_lock);
72594 +#endif
72595 + return;
72596 +}
72597 +
72598 +void gr_del_task_from_ip_table(struct task_struct *task)
72599 +{
72600 +#ifdef CONFIG_GRKERNSEC
72601 + spin_lock_bh(&gr_conn_table_lock);
72602 + gr_del_task_from_ip_table_nolock(task->signal);
72603 + spin_unlock_bh(&gr_conn_table_lock);
72604 +#endif
72605 + return;
72606 +}
72607 +
72608 +void
72609 +gr_attach_curr_ip(const struct sock *sk)
72610 +{
72611 +#ifdef CONFIG_GRKERNSEC
72612 + struct signal_struct *p, *set;
72613 + const struct inet_sock *inet = inet_sk(sk);
72614 +
72615 + if (unlikely(sk->sk_protocol != IPPROTO_TCP))
72616 + return;
72617 +
72618 + set = current->signal;
72619 +
72620 + spin_lock_bh(&gr_conn_table_lock);
72621 + p = gr_lookup_task_ip_table(inet->inet_daddr, inet->inet_rcv_saddr,
72622 + inet->inet_dport, inet->inet_sport);
72623 + if (unlikely(p != NULL)) {
72624 + set->curr_ip = p->curr_ip;
72625 + set->used_accept = 1;
72626 + gr_del_task_from_ip_table_nolock(p);
72627 + spin_unlock_bh(&gr_conn_table_lock);
72628 + return;
72629 + }
72630 + spin_unlock_bh(&gr_conn_table_lock);
72631 +
72632 + set->curr_ip = inet->inet_daddr;
72633 + set->used_accept = 1;
72634 +#endif
72635 + return;
72636 +}
72637 +
72638 +int
72639 +gr_handle_sock_all(const int family, const int type, const int protocol)
72640 +{
72641 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
72642 + if (grsec_enable_socket_all && in_group_p(grsec_socket_all_gid) &&
72643 + (family != AF_UNIX)) {
72644 + if (family == AF_INET)
72645 + gr_log_str3(GR_DONT_AUDIT, GR_SOCK_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), gr_proto_to_name(protocol));
72646 + else
72647 + gr_log_str2_int(GR_DONT_AUDIT, GR_SOCK_NOINET_MSG, gr_sockfamily_to_name(family), gr_socktype_to_name(type), protocol);
72648 + return -EACCES;
72649 + }
72650 +#endif
72651 + return 0;
72652 +}
72653 +
72654 +int
72655 +gr_handle_sock_server(const struct sockaddr *sck)
72656 +{
72657 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72658 + if (grsec_enable_socket_server &&
72659 + in_group_p(grsec_socket_server_gid) &&
72660 + sck && (sck->sa_family != AF_UNIX) &&
72661 + (sck->sa_family != AF_LOCAL)) {
72662 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72663 + return -EACCES;
72664 + }
72665 +#endif
72666 + return 0;
72667 +}
72668 +
72669 +int
72670 +gr_handle_sock_server_other(const struct sock *sck)
72671 +{
72672 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
72673 + if (grsec_enable_socket_server &&
72674 + in_group_p(grsec_socket_server_gid) &&
72675 + sck && (sck->sk_family != AF_UNIX) &&
72676 + (sck->sk_family != AF_LOCAL)) {
72677 + gr_log_noargs(GR_DONT_AUDIT, GR_BIND_MSG);
72678 + return -EACCES;
72679 + }
72680 +#endif
72681 + return 0;
72682 +}
72683 +
72684 +int
72685 +gr_handle_sock_client(const struct sockaddr *sck)
72686 +{
72687 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
72688 + if (grsec_enable_socket_client && in_group_p(grsec_socket_client_gid) &&
72689 + sck && (sck->sa_family != AF_UNIX) &&
72690 + (sck->sa_family != AF_LOCAL)) {
72691 + gr_log_noargs(GR_DONT_AUDIT, GR_CONNECT_MSG);
72692 + return -EACCES;
72693 + }
72694 +#endif
72695 + return 0;
72696 +}
72697 diff --git a/grsecurity/grsec_sysctl.c b/grsecurity/grsec_sysctl.c
72698 new file mode 100644
72699 index 0000000..8159888
72700 --- /dev/null
72701 +++ b/grsecurity/grsec_sysctl.c
72702 @@ -0,0 +1,479 @@
72703 +#include <linux/kernel.h>
72704 +#include <linux/sched.h>
72705 +#include <linux/sysctl.h>
72706 +#include <linux/grsecurity.h>
72707 +#include <linux/grinternal.h>
72708 +
72709 +int
72710 +gr_handle_sysctl_mod(const char *dirname, const char *name, const int op)
72711 +{
72712 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72713 + if (dirname == NULL || name == NULL)
72714 + return 0;
72715 + if (!strcmp(dirname, "grsecurity") && grsec_lock && (op & MAY_WRITE)) {
72716 + gr_log_str(GR_DONT_AUDIT, GR_SYSCTL_MSG, name);
72717 + return -EACCES;
72718 + }
72719 +#endif
72720 + return 0;
72721 +}
72722 +
72723 +#if defined(CONFIG_GRKERNSEC_ROFS) || defined(CONFIG_GRKERNSEC_DENYUSB)
72724 +static int __maybe_unused __read_only one = 1;
72725 +#endif
72726 +
72727 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS) || \
72728 + defined(CONFIG_GRKERNSEC_DENYUSB)
72729 +struct ctl_table grsecurity_table[] = {
72730 +#ifdef CONFIG_GRKERNSEC_SYSCTL
72731 +#ifdef CONFIG_GRKERNSEC_SYSCTL_DISTRO
72732 +#ifdef CONFIG_GRKERNSEC_IO
72733 + {
72734 + .procname = "disable_priv_io",
72735 + .data = &grsec_disable_privio,
72736 + .maxlen = sizeof(int),
72737 + .mode = 0600,
72738 + .proc_handler = &proc_dointvec,
72739 + },
72740 +#endif
72741 +#endif
72742 +#ifdef CONFIG_GRKERNSEC_LINK
72743 + {
72744 + .procname = "linking_restrictions",
72745 + .data = &grsec_enable_link,
72746 + .maxlen = sizeof(int),
72747 + .mode = 0600,
72748 + .proc_handler = &proc_dointvec,
72749 + },
72750 +#endif
72751 +#ifdef CONFIG_GRKERNSEC_SYMLINKOWN
72752 + {
72753 + .procname = "enforce_symlinksifowner",
72754 + .data = &grsec_enable_symlinkown,
72755 + .maxlen = sizeof(int),
72756 + .mode = 0600,
72757 + .proc_handler = &proc_dointvec,
72758 + },
72759 + {
72760 + .procname = "symlinkown_gid",
72761 + .data = &grsec_symlinkown_gid,
72762 + .maxlen = sizeof(int),
72763 + .mode = 0600,
72764 + .proc_handler = &proc_dointvec,
72765 + },
72766 +#endif
72767 +#ifdef CONFIG_GRKERNSEC_BRUTE
72768 + {
72769 + .procname = "deter_bruteforce",
72770 + .data = &grsec_enable_brute,
72771 + .maxlen = sizeof(int),
72772 + .mode = 0600,
72773 + .proc_handler = &proc_dointvec,
72774 + },
72775 +#endif
72776 +#ifdef CONFIG_GRKERNSEC_FIFO
72777 + {
72778 + .procname = "fifo_restrictions",
72779 + .data = &grsec_enable_fifo,
72780 + .maxlen = sizeof(int),
72781 + .mode = 0600,
72782 + .proc_handler = &proc_dointvec,
72783 + },
72784 +#endif
72785 +#ifdef CONFIG_GRKERNSEC_PTRACE_READEXEC
72786 + {
72787 + .procname = "ptrace_readexec",
72788 + .data = &grsec_enable_ptrace_readexec,
72789 + .maxlen = sizeof(int),
72790 + .mode = 0600,
72791 + .proc_handler = &proc_dointvec,
72792 + },
72793 +#endif
72794 +#ifdef CONFIG_GRKERNSEC_SETXID
72795 + {
72796 + .procname = "consistent_setxid",
72797 + .data = &grsec_enable_setxid,
72798 + .maxlen = sizeof(int),
72799 + .mode = 0600,
72800 + .proc_handler = &proc_dointvec,
72801 + },
72802 +#endif
72803 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
72804 + {
72805 + .procname = "ip_blackhole",
72806 + .data = &grsec_enable_blackhole,
72807 + .maxlen = sizeof(int),
72808 + .mode = 0600,
72809 + .proc_handler = &proc_dointvec,
72810 + },
72811 + {
72812 + .procname = "lastack_retries",
72813 + .data = &grsec_lastack_retries,
72814 + .maxlen = sizeof(int),
72815 + .mode = 0600,
72816 + .proc_handler = &proc_dointvec,
72817 + },
72818 +#endif
72819 +#ifdef CONFIG_GRKERNSEC_EXECLOG
72820 + {
72821 + .procname = "exec_logging",
72822 + .data = &grsec_enable_execlog,
72823 + .maxlen = sizeof(int),
72824 + .mode = 0600,
72825 + .proc_handler = &proc_dointvec,
72826 + },
72827 +#endif
72828 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
72829 + {
72830 + .procname = "rwxmap_logging",
72831 + .data = &grsec_enable_log_rwxmaps,
72832 + .maxlen = sizeof(int),
72833 + .mode = 0600,
72834 + .proc_handler = &proc_dointvec,
72835 + },
72836 +#endif
72837 +#ifdef CONFIG_GRKERNSEC_SIGNAL
72838 + {
72839 + .procname = "signal_logging",
72840 + .data = &grsec_enable_signal,
72841 + .maxlen = sizeof(int),
72842 + .mode = 0600,
72843 + .proc_handler = &proc_dointvec,
72844 + },
72845 +#endif
72846 +#ifdef CONFIG_GRKERNSEC_FORKFAIL
72847 + {
72848 + .procname = "forkfail_logging",
72849 + .data = &grsec_enable_forkfail,
72850 + .maxlen = sizeof(int),
72851 + .mode = 0600,
72852 + .proc_handler = &proc_dointvec,
72853 + },
72854 +#endif
72855 +#ifdef CONFIG_GRKERNSEC_TIME
72856 + {
72857 + .procname = "timechange_logging",
72858 + .data = &grsec_enable_time,
72859 + .maxlen = sizeof(int),
72860 + .mode = 0600,
72861 + .proc_handler = &proc_dointvec,
72862 + },
72863 +#endif
72864 +#ifdef CONFIG_GRKERNSEC_CHROOT_SHMAT
72865 + {
72866 + .procname = "chroot_deny_shmat",
72867 + .data = &grsec_enable_chroot_shmat,
72868 + .maxlen = sizeof(int),
72869 + .mode = 0600,
72870 + .proc_handler = &proc_dointvec,
72871 + },
72872 +#endif
72873 +#ifdef CONFIG_GRKERNSEC_CHROOT_UNIX
72874 + {
72875 + .procname = "chroot_deny_unix",
72876 + .data = &grsec_enable_chroot_unix,
72877 + .maxlen = sizeof(int),
72878 + .mode = 0600,
72879 + .proc_handler = &proc_dointvec,
72880 + },
72881 +#endif
72882 +#ifdef CONFIG_GRKERNSEC_CHROOT_MOUNT
72883 + {
72884 + .procname = "chroot_deny_mount",
72885 + .data = &grsec_enable_chroot_mount,
72886 + .maxlen = sizeof(int),
72887 + .mode = 0600,
72888 + .proc_handler = &proc_dointvec,
72889 + },
72890 +#endif
72891 +#ifdef CONFIG_GRKERNSEC_CHROOT_FCHDIR
72892 + {
72893 + .procname = "chroot_deny_fchdir",
72894 + .data = &grsec_enable_chroot_fchdir,
72895 + .maxlen = sizeof(int),
72896 + .mode = 0600,
72897 + .proc_handler = &proc_dointvec,
72898 + },
72899 +#endif
72900 +#ifdef CONFIG_GRKERNSEC_CHROOT_DOUBLE
72901 + {
72902 + .procname = "chroot_deny_chroot",
72903 + .data = &grsec_enable_chroot_double,
72904 + .maxlen = sizeof(int),
72905 + .mode = 0600,
72906 + .proc_handler = &proc_dointvec,
72907 + },
72908 +#endif
72909 +#ifdef CONFIG_GRKERNSEC_CHROOT_PIVOT
72910 + {
72911 + .procname = "chroot_deny_pivot",
72912 + .data = &grsec_enable_chroot_pivot,
72913 + .maxlen = sizeof(int),
72914 + .mode = 0600,
72915 + .proc_handler = &proc_dointvec,
72916 + },
72917 +#endif
72918 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHDIR
72919 + {
72920 + .procname = "chroot_enforce_chdir",
72921 + .data = &grsec_enable_chroot_chdir,
72922 + .maxlen = sizeof(int),
72923 + .mode = 0600,
72924 + .proc_handler = &proc_dointvec,
72925 + },
72926 +#endif
72927 +#ifdef CONFIG_GRKERNSEC_CHROOT_CHMOD
72928 + {
72929 + .procname = "chroot_deny_chmod",
72930 + .data = &grsec_enable_chroot_chmod,
72931 + .maxlen = sizeof(int),
72932 + .mode = 0600,
72933 + .proc_handler = &proc_dointvec,
72934 + },
72935 +#endif
72936 +#ifdef CONFIG_GRKERNSEC_CHROOT_MKNOD
72937 + {
72938 + .procname = "chroot_deny_mknod",
72939 + .data = &grsec_enable_chroot_mknod,
72940 + .maxlen = sizeof(int),
72941 + .mode = 0600,
72942 + .proc_handler = &proc_dointvec,
72943 + },
72944 +#endif
72945 +#ifdef CONFIG_GRKERNSEC_CHROOT_NICE
72946 + {
72947 + .procname = "chroot_restrict_nice",
72948 + .data = &grsec_enable_chroot_nice,
72949 + .maxlen = sizeof(int),
72950 + .mode = 0600,
72951 + .proc_handler = &proc_dointvec,
72952 + },
72953 +#endif
72954 +#ifdef CONFIG_GRKERNSEC_CHROOT_EXECLOG
72955 + {
72956 + .procname = "chroot_execlog",
72957 + .data = &grsec_enable_chroot_execlog,
72958 + .maxlen = sizeof(int),
72959 + .mode = 0600,
72960 + .proc_handler = &proc_dointvec,
72961 + },
72962 +#endif
72963 +#ifdef CONFIG_GRKERNSEC_CHROOT_CAPS
72964 + {
72965 + .procname = "chroot_caps",
72966 + .data = &grsec_enable_chroot_caps,
72967 + .maxlen = sizeof(int),
72968 + .mode = 0600,
72969 + .proc_handler = &proc_dointvec,
72970 + },
72971 +#endif
72972 +#ifdef CONFIG_GRKERNSEC_CHROOT_SYSCTL
72973 + {
72974 + .procname = "chroot_deny_sysctl",
72975 + .data = &grsec_enable_chroot_sysctl,
72976 + .maxlen = sizeof(int),
72977 + .mode = 0600,
72978 + .proc_handler = &proc_dointvec,
72979 + },
72980 +#endif
72981 +#ifdef CONFIG_GRKERNSEC_TPE
72982 + {
72983 + .procname = "tpe",
72984 + .data = &grsec_enable_tpe,
72985 + .maxlen = sizeof(int),
72986 + .mode = 0600,
72987 + .proc_handler = &proc_dointvec,
72988 + },
72989 + {
72990 + .procname = "tpe_gid",
72991 + .data = &grsec_tpe_gid,
72992 + .maxlen = sizeof(int),
72993 + .mode = 0600,
72994 + .proc_handler = &proc_dointvec,
72995 + },
72996 +#endif
72997 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
72998 + {
72999 + .procname = "tpe_invert",
73000 + .data = &grsec_enable_tpe_invert,
73001 + .maxlen = sizeof(int),
73002 + .mode = 0600,
73003 + .proc_handler = &proc_dointvec,
73004 + },
73005 +#endif
73006 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
73007 + {
73008 + .procname = "tpe_restrict_all",
73009 + .data = &grsec_enable_tpe_all,
73010 + .maxlen = sizeof(int),
73011 + .mode = 0600,
73012 + .proc_handler = &proc_dointvec,
73013 + },
73014 +#endif
73015 +#ifdef CONFIG_GRKERNSEC_SOCKET_ALL
73016 + {
73017 + .procname = "socket_all",
73018 + .data = &grsec_enable_socket_all,
73019 + .maxlen = sizeof(int),
73020 + .mode = 0600,
73021 + .proc_handler = &proc_dointvec,
73022 + },
73023 + {
73024 + .procname = "socket_all_gid",
73025 + .data = &grsec_socket_all_gid,
73026 + .maxlen = sizeof(int),
73027 + .mode = 0600,
73028 + .proc_handler = &proc_dointvec,
73029 + },
73030 +#endif
73031 +#ifdef CONFIG_GRKERNSEC_SOCKET_CLIENT
73032 + {
73033 + .procname = "socket_client",
73034 + .data = &grsec_enable_socket_client,
73035 + .maxlen = sizeof(int),
73036 + .mode = 0600,
73037 + .proc_handler = &proc_dointvec,
73038 + },
73039 + {
73040 + .procname = "socket_client_gid",
73041 + .data = &grsec_socket_client_gid,
73042 + .maxlen = sizeof(int),
73043 + .mode = 0600,
73044 + .proc_handler = &proc_dointvec,
73045 + },
73046 +#endif
73047 +#ifdef CONFIG_GRKERNSEC_SOCKET_SERVER
73048 + {
73049 + .procname = "socket_server",
73050 + .data = &grsec_enable_socket_server,
73051 + .maxlen = sizeof(int),
73052 + .mode = 0600,
73053 + .proc_handler = &proc_dointvec,
73054 + },
73055 + {
73056 + .procname = "socket_server_gid",
73057 + .data = &grsec_socket_server_gid,
73058 + .maxlen = sizeof(int),
73059 + .mode = 0600,
73060 + .proc_handler = &proc_dointvec,
73061 + },
73062 +#endif
73063 +#ifdef CONFIG_GRKERNSEC_AUDIT_GROUP
73064 + {
73065 + .procname = "audit_group",
73066 + .data = &grsec_enable_group,
73067 + .maxlen = sizeof(int),
73068 + .mode = 0600,
73069 + .proc_handler = &proc_dointvec,
73070 + },
73071 + {
73072 + .procname = "audit_gid",
73073 + .data = &grsec_audit_gid,
73074 + .maxlen = sizeof(int),
73075 + .mode = 0600,
73076 + .proc_handler = &proc_dointvec,
73077 + },
73078 +#endif
73079 +#ifdef CONFIG_GRKERNSEC_AUDIT_CHDIR
73080 + {
73081 + .procname = "audit_chdir",
73082 + .data = &grsec_enable_chdir,
73083 + .maxlen = sizeof(int),
73084 + .mode = 0600,
73085 + .proc_handler = &proc_dointvec,
73086 + },
73087 +#endif
73088 +#ifdef CONFIG_GRKERNSEC_AUDIT_MOUNT
73089 + {
73090 + .procname = "audit_mount",
73091 + .data = &grsec_enable_mount,
73092 + .maxlen = sizeof(int),
73093 + .mode = 0600,
73094 + .proc_handler = &proc_dointvec,
73095 + },
73096 +#endif
73097 +#ifdef CONFIG_GRKERNSEC_DMESG
73098 + {
73099 + .procname = "dmesg",
73100 + .data = &grsec_enable_dmesg,
73101 + .maxlen = sizeof(int),
73102 + .mode = 0600,
73103 + .proc_handler = &proc_dointvec,
73104 + },
73105 +#endif
73106 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
73107 + {
73108 + .procname = "chroot_findtask",
73109 + .data = &grsec_enable_chroot_findtask,
73110 + .maxlen = sizeof(int),
73111 + .mode = 0600,
73112 + .proc_handler = &proc_dointvec,
73113 + },
73114 +#endif
73115 +#ifdef CONFIG_GRKERNSEC_RESLOG
73116 + {
73117 + .procname = "resource_logging",
73118 + .data = &grsec_resource_logging,
73119 + .maxlen = sizeof(int),
73120 + .mode = 0600,
73121 + .proc_handler = &proc_dointvec,
73122 + },
73123 +#endif
73124 +#ifdef CONFIG_GRKERNSEC_AUDIT_PTRACE
73125 + {
73126 + .procname = "audit_ptrace",
73127 + .data = &grsec_enable_audit_ptrace,
73128 + .maxlen = sizeof(int),
73129 + .mode = 0600,
73130 + .proc_handler = &proc_dointvec,
73131 + },
73132 +#endif
73133 +#ifdef CONFIG_GRKERNSEC_HARDEN_PTRACE
73134 + {
73135 + .procname = "harden_ptrace",
73136 + .data = &grsec_enable_harden_ptrace,
73137 + .maxlen = sizeof(int),
73138 + .mode = 0600,
73139 + .proc_handler = &proc_dointvec,
73140 + },
73141 +#endif
73142 +#ifdef CONFIG_GRKERNSEC_HARDEN_IPC
73143 + {
73144 + .procname = "harden_ipc",
73145 + .data = &grsec_enable_harden_ipc,
73146 + .maxlen = sizeof(int),
73147 + .mode = 0600,
73148 + .proc_handler = &proc_dointvec,
73149 + },
73150 +#endif
73151 + {
73152 + .procname = "grsec_lock",
73153 + .data = &grsec_lock,
73154 + .maxlen = sizeof(int),
73155 + .mode = 0600,
73156 + .proc_handler = &proc_dointvec,
73157 + },
73158 +#endif
73159 +#ifdef CONFIG_GRKERNSEC_ROFS
73160 + {
73161 + .procname = "romount_protect",
73162 + .data = &grsec_enable_rofs,
73163 + .maxlen = sizeof(int),
73164 + .mode = 0600,
73165 + .proc_handler = &proc_dointvec_minmax,
73166 + .extra1 = &one,
73167 + .extra2 = &one,
73168 + },
73169 +#endif
73170 +#if defined(CONFIG_GRKERNSEC_DENYUSB) && !defined(CONFIG_GRKERNSEC_DENYUSB_FORCE)
73171 + {
73172 + .procname = "deny_new_usb",
73173 + .data = &grsec_deny_new_usb,
73174 + .maxlen = sizeof(int),
73175 + .mode = 0600,
73176 + .proc_handler = &proc_dointvec,
73177 + },
73178 +#endif
73179 + { }
73180 +};
73181 +#endif
73182 diff --git a/grsecurity/grsec_time.c b/grsecurity/grsec_time.c
73183 new file mode 100644
73184 index 0000000..0dc13c3
73185 --- /dev/null
73186 +++ b/grsecurity/grsec_time.c
73187 @@ -0,0 +1,16 @@
73188 +#include <linux/kernel.h>
73189 +#include <linux/sched.h>
73190 +#include <linux/grinternal.h>
73191 +#include <linux/module.h>
73192 +
73193 +void
73194 +gr_log_timechange(void)
73195 +{
73196 +#ifdef CONFIG_GRKERNSEC_TIME
73197 + if (grsec_enable_time)
73198 + gr_log_noargs(GR_DONT_AUDIT_GOOD, GR_TIME_MSG);
73199 +#endif
73200 + return;
73201 +}
73202 +
73203 +EXPORT_SYMBOL(gr_log_timechange);
73204 diff --git a/grsecurity/grsec_tpe.c b/grsecurity/grsec_tpe.c
73205 new file mode 100644
73206 index 0000000..ee57dcf
73207 --- /dev/null
73208 +++ b/grsecurity/grsec_tpe.c
73209 @@ -0,0 +1,73 @@
73210 +#include <linux/kernel.h>
73211 +#include <linux/sched.h>
73212 +#include <linux/file.h>
73213 +#include <linux/fs.h>
73214 +#include <linux/grinternal.h>
73215 +
73216 +extern int gr_acl_tpe_check(void);
73217 +
73218 +int
73219 +gr_tpe_allow(const struct file *file)
73220 +{
73221 +#ifdef CONFIG_GRKERNSEC
73222 + struct inode *inode = file->f_path.dentry->d_parent->d_inode;
73223 + const struct cred *cred = current_cred();
73224 + char *msg = NULL;
73225 + char *msg2 = NULL;
73226 +
73227 + // never restrict root
73228 + if (gr_is_global_root(cred->uid))
73229 + return 1;
73230 +
73231 + if (grsec_enable_tpe) {
73232 +#ifdef CONFIG_GRKERNSEC_TPE_INVERT
73233 + if (grsec_enable_tpe_invert && !in_group_p(grsec_tpe_gid))
73234 + msg = "not being in trusted group";
73235 + else if (!grsec_enable_tpe_invert && in_group_p(grsec_tpe_gid))
73236 + msg = "being in untrusted group";
73237 +#else
73238 + if (in_group_p(grsec_tpe_gid))
73239 + msg = "being in untrusted group";
73240 +#endif
73241 + }
73242 + if (!msg && gr_acl_tpe_check())
73243 + msg = "being in untrusted role";
73244 +
73245 + // not in any affected group/role
73246 + if (!msg)
73247 + goto next_check;
73248 +
73249 + if (gr_is_global_nonroot(inode->i_uid))
73250 + msg2 = "file in non-root-owned directory";
73251 + else if (inode->i_mode & S_IWOTH)
73252 + msg2 = "file in world-writable directory";
73253 + else if (inode->i_mode & S_IWGRP)
73254 + msg2 = "file in group-writable directory";
73255 +
73256 + if (msg && msg2) {
73257 + char fullmsg[70] = {0};
73258 + snprintf(fullmsg, sizeof(fullmsg)-1, "%s and %s", msg, msg2);
73259 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, fullmsg, file->f_path.dentry, file->f_path.mnt);
73260 + return 0;
73261 + }
73262 + msg = NULL;
73263 +next_check:
73264 +#ifdef CONFIG_GRKERNSEC_TPE_ALL
73265 + if (!grsec_enable_tpe || !grsec_enable_tpe_all)
73266 + return 1;
73267 +
73268 + if (gr_is_global_nonroot(inode->i_uid) && !uid_eq(inode->i_uid, cred->uid))
73269 + msg = "directory not owned by user";
73270 + else if (inode->i_mode & S_IWOTH)
73271 + msg = "file in world-writable directory";
73272 + else if (inode->i_mode & S_IWGRP)
73273 + msg = "file in group-writable directory";
73274 +
73275 + if (msg) {
73276 + gr_log_str_fs(GR_DONT_AUDIT, GR_EXEC_TPE_MSG, msg, file->f_path.dentry, file->f_path.mnt);
73277 + return 0;
73278 + }
73279 +#endif
73280 +#endif
73281 + return 1;
73282 +}
73283 diff --git a/grsecurity/grsec_usb.c b/grsecurity/grsec_usb.c
73284 new file mode 100644
73285 index 0000000..ae02d8e
73286 --- /dev/null
73287 +++ b/grsecurity/grsec_usb.c
73288 @@ -0,0 +1,15 @@
73289 +#include <linux/kernel.h>
73290 +#include <linux/grinternal.h>
73291 +#include <linux/module.h>
73292 +
73293 +int gr_handle_new_usb(void)
73294 +{
73295 +#ifdef CONFIG_GRKERNSEC_DENYUSB
73296 + if (grsec_deny_new_usb) {
73297 + printk(KERN_ALERT "grsec: denied insert of new USB device\n");
73298 + return 1;
73299 + }
73300 +#endif
73301 + return 0;
73302 +}
73303 +EXPORT_SYMBOL_GPL(gr_handle_new_usb);
73304 diff --git a/grsecurity/grsum.c b/grsecurity/grsum.c
73305 new file mode 100644
73306 index 0000000..9f7b1ac
73307 --- /dev/null
73308 +++ b/grsecurity/grsum.c
73309 @@ -0,0 +1,61 @@
73310 +#include <linux/err.h>
73311 +#include <linux/kernel.h>
73312 +#include <linux/sched.h>
73313 +#include <linux/mm.h>
73314 +#include <linux/scatterlist.h>
73315 +#include <linux/crypto.h>
73316 +#include <linux/gracl.h>
73317 +
73318 +
73319 +#if !defined(CONFIG_CRYPTO) || defined(CONFIG_CRYPTO_MODULE) || !defined(CONFIG_CRYPTO_SHA256) || defined(CONFIG_CRYPTO_SHA256_MODULE)
73320 +#error "crypto and sha256 must be built into the kernel"
73321 +#endif
73322 +
73323 +int
73324 +chkpw(struct gr_arg *entry, unsigned char *salt, unsigned char *sum)
73325 +{
73326 + char *p;
73327 + struct crypto_hash *tfm;
73328 + struct hash_desc desc;
73329 + struct scatterlist sg;
73330 + unsigned char temp_sum[GR_SHA_LEN];
73331 + volatile int retval = 0;
73332 + volatile int dummy = 0;
73333 + unsigned int i;
73334 +
73335 + sg_init_table(&sg, 1);
73336 +
73337 + tfm = crypto_alloc_hash("sha256", 0, CRYPTO_ALG_ASYNC);
73338 + if (IS_ERR(tfm)) {
73339 + /* should never happen, since sha256 should be built in */
73340 + return 1;
73341 + }
73342 +
73343 + desc.tfm = tfm;
73344 + desc.flags = 0;
73345 +
73346 + crypto_hash_init(&desc);
73347 +
73348 + p = salt;
73349 + sg_set_buf(&sg, p, GR_SALT_LEN);
73350 + crypto_hash_update(&desc, &sg, sg.length);
73351 +
73352 + p = entry->pw;
73353 + sg_set_buf(&sg, p, strlen(p));
73354 +
73355 + crypto_hash_update(&desc, &sg, sg.length);
73356 +
73357 + crypto_hash_final(&desc, temp_sum);
73358 +
73359 + memset(entry->pw, 0, GR_PW_LEN);
73360 +
73361 + for (i = 0; i < GR_SHA_LEN; i++)
73362 + if (sum[i] != temp_sum[i])
73363 + retval = 1;
73364 + else
73365 + dummy = 1; // waste a cycle
73366 +
73367 + crypto_free_hash(tfm);
73368 +
73369 + return retval;
73370 +}
73371 diff --git a/include/asm-generic/4level-fixup.h b/include/asm-generic/4level-fixup.h
73372 index 77ff547..181834f 100644
73373 --- a/include/asm-generic/4level-fixup.h
73374 +++ b/include/asm-generic/4level-fixup.h
73375 @@ -13,8 +13,10 @@
73376 #define pmd_alloc(mm, pud, address) \
73377 ((unlikely(pgd_none(*(pud))) && __pmd_alloc(mm, pud, address))? \
73378 NULL: pmd_offset(pud, address))
73379 +#define pmd_alloc_kernel(mm, pud, address) pmd_alloc((mm), (pud), (address))
73380
73381 #define pud_alloc(mm, pgd, address) (pgd)
73382 +#define pud_alloc_kernel(mm, pgd, address) pud_alloc((mm), (pgd), (address))
73383 #define pud_offset(pgd, start) (pgd)
73384 #define pud_none(pud) 0
73385 #define pud_bad(pud) 0
73386 diff --git a/include/asm-generic/atomic-long.h b/include/asm-generic/atomic-long.h
73387 index b7babf0..97f4c4f 100644
73388 --- a/include/asm-generic/atomic-long.h
73389 +++ b/include/asm-generic/atomic-long.h
73390 @@ -22,6 +22,12 @@
73391
73392 typedef atomic64_t atomic_long_t;
73393
73394 +#ifdef CONFIG_PAX_REFCOUNT
73395 +typedef atomic64_unchecked_t atomic_long_unchecked_t;
73396 +#else
73397 +typedef atomic64_t atomic_long_unchecked_t;
73398 +#endif
73399 +
73400 #define ATOMIC_LONG_INIT(i) ATOMIC64_INIT(i)
73401
73402 static inline long atomic_long_read(atomic_long_t *l)
73403 @@ -31,6 +37,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73404 return (long)atomic64_read(v);
73405 }
73406
73407 +#ifdef CONFIG_PAX_REFCOUNT
73408 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73409 +{
73410 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73411 +
73412 + return (long)atomic64_read_unchecked(v);
73413 +}
73414 +#endif
73415 +
73416 static inline void atomic_long_set(atomic_long_t *l, long i)
73417 {
73418 atomic64_t *v = (atomic64_t *)l;
73419 @@ -38,6 +53,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73420 atomic64_set(v, i);
73421 }
73422
73423 +#ifdef CONFIG_PAX_REFCOUNT
73424 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73425 +{
73426 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73427 +
73428 + atomic64_set_unchecked(v, i);
73429 +}
73430 +#endif
73431 +
73432 static inline void atomic_long_inc(atomic_long_t *l)
73433 {
73434 atomic64_t *v = (atomic64_t *)l;
73435 @@ -45,6 +69,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73436 atomic64_inc(v);
73437 }
73438
73439 +#ifdef CONFIG_PAX_REFCOUNT
73440 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73441 +{
73442 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73443 +
73444 + atomic64_inc_unchecked(v);
73445 +}
73446 +#endif
73447 +
73448 static inline void atomic_long_dec(atomic_long_t *l)
73449 {
73450 atomic64_t *v = (atomic64_t *)l;
73451 @@ -52,6 +85,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73452 atomic64_dec(v);
73453 }
73454
73455 +#ifdef CONFIG_PAX_REFCOUNT
73456 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73457 +{
73458 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73459 +
73460 + atomic64_dec_unchecked(v);
73461 +}
73462 +#endif
73463 +
73464 static inline void atomic_long_add(long i, atomic_long_t *l)
73465 {
73466 atomic64_t *v = (atomic64_t *)l;
73467 @@ -59,6 +101,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73468 atomic64_add(i, v);
73469 }
73470
73471 +#ifdef CONFIG_PAX_REFCOUNT
73472 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73473 +{
73474 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73475 +
73476 + atomic64_add_unchecked(i, v);
73477 +}
73478 +#endif
73479 +
73480 static inline void atomic_long_sub(long i, atomic_long_t *l)
73481 {
73482 atomic64_t *v = (atomic64_t *)l;
73483 @@ -66,6 +117,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73484 atomic64_sub(i, v);
73485 }
73486
73487 +#ifdef CONFIG_PAX_REFCOUNT
73488 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73489 +{
73490 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73491 +
73492 + atomic64_sub_unchecked(i, v);
73493 +}
73494 +#endif
73495 +
73496 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73497 {
73498 atomic64_t *v = (atomic64_t *)l;
73499 @@ -94,13 +154,22 @@ static inline int atomic_long_add_negative(long i, atomic_long_t *l)
73500 return atomic64_add_negative(i, v);
73501 }
73502
73503 -static inline long atomic_long_add_return(long i, atomic_long_t *l)
73504 +static inline long __intentional_overflow(-1) atomic_long_add_return(long i, atomic_long_t *l)
73505 {
73506 atomic64_t *v = (atomic64_t *)l;
73507
73508 return (long)atomic64_add_return(i, v);
73509 }
73510
73511 +#ifdef CONFIG_PAX_REFCOUNT
73512 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73513 +{
73514 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73515 +
73516 + return (long)atomic64_add_return_unchecked(i, v);
73517 +}
73518 +#endif
73519 +
73520 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73521 {
73522 atomic64_t *v = (atomic64_t *)l;
73523 @@ -115,6 +184,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73524 return (long)atomic64_inc_return(v);
73525 }
73526
73527 +#ifdef CONFIG_PAX_REFCOUNT
73528 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73529 +{
73530 + atomic64_unchecked_t *v = (atomic64_unchecked_t *)l;
73531 +
73532 + return (long)atomic64_inc_return_unchecked(v);
73533 +}
73534 +#endif
73535 +
73536 static inline long atomic_long_dec_return(atomic_long_t *l)
73537 {
73538 atomic64_t *v = (atomic64_t *)l;
73539 @@ -140,6 +218,12 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73540
73541 typedef atomic_t atomic_long_t;
73542
73543 +#ifdef CONFIG_PAX_REFCOUNT
73544 +typedef atomic_unchecked_t atomic_long_unchecked_t;
73545 +#else
73546 +typedef atomic_t atomic_long_unchecked_t;
73547 +#endif
73548 +
73549 #define ATOMIC_LONG_INIT(i) ATOMIC_INIT(i)
73550 static inline long atomic_long_read(atomic_long_t *l)
73551 {
73552 @@ -148,6 +232,15 @@ static inline long atomic_long_read(atomic_long_t *l)
73553 return (long)atomic_read(v);
73554 }
73555
73556 +#ifdef CONFIG_PAX_REFCOUNT
73557 +static inline long atomic_long_read_unchecked(atomic_long_unchecked_t *l)
73558 +{
73559 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73560 +
73561 + return (long)atomic_read_unchecked(v);
73562 +}
73563 +#endif
73564 +
73565 static inline void atomic_long_set(atomic_long_t *l, long i)
73566 {
73567 atomic_t *v = (atomic_t *)l;
73568 @@ -155,6 +248,15 @@ static inline void atomic_long_set(atomic_long_t *l, long i)
73569 atomic_set(v, i);
73570 }
73571
73572 +#ifdef CONFIG_PAX_REFCOUNT
73573 +static inline void atomic_long_set_unchecked(atomic_long_unchecked_t *l, long i)
73574 +{
73575 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73576 +
73577 + atomic_set_unchecked(v, i);
73578 +}
73579 +#endif
73580 +
73581 static inline void atomic_long_inc(atomic_long_t *l)
73582 {
73583 atomic_t *v = (atomic_t *)l;
73584 @@ -162,6 +264,15 @@ static inline void atomic_long_inc(atomic_long_t *l)
73585 atomic_inc(v);
73586 }
73587
73588 +#ifdef CONFIG_PAX_REFCOUNT
73589 +static inline void atomic_long_inc_unchecked(atomic_long_unchecked_t *l)
73590 +{
73591 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73592 +
73593 + atomic_inc_unchecked(v);
73594 +}
73595 +#endif
73596 +
73597 static inline void atomic_long_dec(atomic_long_t *l)
73598 {
73599 atomic_t *v = (atomic_t *)l;
73600 @@ -169,6 +280,15 @@ static inline void atomic_long_dec(atomic_long_t *l)
73601 atomic_dec(v);
73602 }
73603
73604 +#ifdef CONFIG_PAX_REFCOUNT
73605 +static inline void atomic_long_dec_unchecked(atomic_long_unchecked_t *l)
73606 +{
73607 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73608 +
73609 + atomic_dec_unchecked(v);
73610 +}
73611 +#endif
73612 +
73613 static inline void atomic_long_add(long i, atomic_long_t *l)
73614 {
73615 atomic_t *v = (atomic_t *)l;
73616 @@ -176,6 +296,15 @@ static inline void atomic_long_add(long i, atomic_long_t *l)
73617 atomic_add(i, v);
73618 }
73619
73620 +#ifdef CONFIG_PAX_REFCOUNT
73621 +static inline void atomic_long_add_unchecked(long i, atomic_long_unchecked_t *l)
73622 +{
73623 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73624 +
73625 + atomic_add_unchecked(i, v);
73626 +}
73627 +#endif
73628 +
73629 static inline void atomic_long_sub(long i, atomic_long_t *l)
73630 {
73631 atomic_t *v = (atomic_t *)l;
73632 @@ -183,6 +312,15 @@ static inline void atomic_long_sub(long i, atomic_long_t *l)
73633 atomic_sub(i, v);
73634 }
73635
73636 +#ifdef CONFIG_PAX_REFCOUNT
73637 +static inline void atomic_long_sub_unchecked(long i, atomic_long_unchecked_t *l)
73638 +{
73639 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73640 +
73641 + atomic_sub_unchecked(i, v);
73642 +}
73643 +#endif
73644 +
73645 static inline int atomic_long_sub_and_test(long i, atomic_long_t *l)
73646 {
73647 atomic_t *v = (atomic_t *)l;
73648 @@ -218,6 +356,16 @@ static inline long atomic_long_add_return(long i, atomic_long_t *l)
73649 return (long)atomic_add_return(i, v);
73650 }
73651
73652 +#ifdef CONFIG_PAX_REFCOUNT
73653 +static inline long atomic_long_add_return_unchecked(long i, atomic_long_unchecked_t *l)
73654 +{
73655 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73656 +
73657 + return (long)atomic_add_return_unchecked(i, v);
73658 +}
73659 +
73660 +#endif
73661 +
73662 static inline long atomic_long_sub_return(long i, atomic_long_t *l)
73663 {
73664 atomic_t *v = (atomic_t *)l;
73665 @@ -232,6 +380,15 @@ static inline long atomic_long_inc_return(atomic_long_t *l)
73666 return (long)atomic_inc_return(v);
73667 }
73668
73669 +#ifdef CONFIG_PAX_REFCOUNT
73670 +static inline long atomic_long_inc_return_unchecked(atomic_long_unchecked_t *l)
73671 +{
73672 + atomic_unchecked_t *v = (atomic_unchecked_t *)l;
73673 +
73674 + return (long)atomic_inc_return_unchecked(v);
73675 +}
73676 +#endif
73677 +
73678 static inline long atomic_long_dec_return(atomic_long_t *l)
73679 {
73680 atomic_t *v = (atomic_t *)l;
73681 @@ -255,4 +412,57 @@ static inline long atomic_long_add_unless(atomic_long_t *l, long a, long u)
73682
73683 #endif /* BITS_PER_LONG == 64 */
73684
73685 +#ifdef CONFIG_PAX_REFCOUNT
73686 +static inline void pax_refcount_needs_these_functions(void)
73687 +{
73688 + atomic_read_unchecked((atomic_unchecked_t *)NULL);
73689 + atomic_set_unchecked((atomic_unchecked_t *)NULL, 0);
73690 + atomic_add_unchecked(0, (atomic_unchecked_t *)NULL);
73691 + atomic_sub_unchecked(0, (atomic_unchecked_t *)NULL);
73692 + atomic_inc_unchecked((atomic_unchecked_t *)NULL);
73693 + (void)atomic_inc_and_test_unchecked((atomic_unchecked_t *)NULL);
73694 + atomic_inc_return_unchecked((atomic_unchecked_t *)NULL);
73695 + atomic_add_return_unchecked(0, (atomic_unchecked_t *)NULL);
73696 + atomic_dec_unchecked((atomic_unchecked_t *)NULL);
73697 + atomic_cmpxchg_unchecked((atomic_unchecked_t *)NULL, 0, 0);
73698 + (void)atomic_xchg_unchecked((atomic_unchecked_t *)NULL, 0);
73699 +#ifdef CONFIG_X86
73700 + atomic_clear_mask_unchecked(0, NULL);
73701 + atomic_set_mask_unchecked(0, NULL);
73702 +#endif
73703 +
73704 + atomic_long_read_unchecked((atomic_long_unchecked_t *)NULL);
73705 + atomic_long_set_unchecked((atomic_long_unchecked_t *)NULL, 0);
73706 + atomic_long_add_unchecked(0, (atomic_long_unchecked_t *)NULL);
73707 + atomic_long_sub_unchecked(0, (atomic_long_unchecked_t *)NULL);
73708 + atomic_long_inc_unchecked((atomic_long_unchecked_t *)NULL);
73709 + atomic_long_add_return_unchecked(0, (atomic_long_unchecked_t *)NULL);
73710 + atomic_long_inc_return_unchecked((atomic_long_unchecked_t *)NULL);
73711 + atomic_long_dec_unchecked((atomic_long_unchecked_t *)NULL);
73712 +}
73713 +#else
73714 +#define atomic_read_unchecked(v) atomic_read(v)
73715 +#define atomic_set_unchecked(v, i) atomic_set((v), (i))
73716 +#define atomic_add_unchecked(i, v) atomic_add((i), (v))
73717 +#define atomic_sub_unchecked(i, v) atomic_sub((i), (v))
73718 +#define atomic_inc_unchecked(v) atomic_inc(v)
73719 +#define atomic_inc_and_test_unchecked(v) atomic_inc_and_test(v)
73720 +#define atomic_inc_return_unchecked(v) atomic_inc_return(v)
73721 +#define atomic_add_return_unchecked(i, v) atomic_add_return((i), (v))
73722 +#define atomic_dec_unchecked(v) atomic_dec(v)
73723 +#define atomic_cmpxchg_unchecked(v, o, n) atomic_cmpxchg((v), (o), (n))
73724 +#define atomic_xchg_unchecked(v, i) atomic_xchg((v), (i))
73725 +#define atomic_clear_mask_unchecked(mask, v) atomic_clear_mask((mask), (v))
73726 +#define atomic_set_mask_unchecked(mask, v) atomic_set_mask((mask), (v))
73727 +
73728 +#define atomic_long_read_unchecked(v) atomic_long_read(v)
73729 +#define atomic_long_set_unchecked(v, i) atomic_long_set((v), (i))
73730 +#define atomic_long_add_unchecked(i, v) atomic_long_add((i), (v))
73731 +#define atomic_long_sub_unchecked(i, v) atomic_long_sub((i), (v))
73732 +#define atomic_long_inc_unchecked(v) atomic_long_inc(v)
73733 +#define atomic_long_add_return_unchecked(i, v) atomic_long_add_return((i), (v))
73734 +#define atomic_long_inc_return_unchecked(v) atomic_long_inc_return(v)
73735 +#define atomic_long_dec_unchecked(v) atomic_long_dec(v)
73736 +#endif
73737 +
73738 #endif /* _ASM_GENERIC_ATOMIC_LONG_H */
73739 diff --git a/include/asm-generic/atomic.h b/include/asm-generic/atomic.h
73740 index 33bd2de..f31bff97 100644
73741 --- a/include/asm-generic/atomic.h
73742 +++ b/include/asm-generic/atomic.h
73743 @@ -153,7 +153,7 @@ static inline int __atomic_add_unless(atomic_t *v, int a, int u)
73744 * Atomically clears the bits set in @mask from @v
73745 */
73746 #ifndef atomic_clear_mask
73747 -static inline void atomic_clear_mask(unsigned long mask, atomic_t *v)
73748 +static inline void atomic_clear_mask(unsigned int mask, atomic_t *v)
73749 {
73750 unsigned long flags;
73751
73752 diff --git a/include/asm-generic/atomic64.h b/include/asm-generic/atomic64.h
73753 index b18ce4f..2ee2843 100644
73754 --- a/include/asm-generic/atomic64.h
73755 +++ b/include/asm-generic/atomic64.h
73756 @@ -16,6 +16,8 @@ typedef struct {
73757 long long counter;
73758 } atomic64_t;
73759
73760 +typedef atomic64_t atomic64_unchecked_t;
73761 +
73762 #define ATOMIC64_INIT(i) { (i) }
73763
73764 extern long long atomic64_read(const atomic64_t *v);
73765 @@ -39,4 +41,14 @@ extern int atomic64_add_unless(atomic64_t *v, long long a, long long u);
73766 #define atomic64_dec_and_test(v) (atomic64_dec_return((v)) == 0)
73767 #define atomic64_inc_not_zero(v) atomic64_add_unless((v), 1LL, 0LL)
73768
73769 +#define atomic64_read_unchecked(v) atomic64_read(v)
73770 +#define atomic64_set_unchecked(v, i) atomic64_set((v), (i))
73771 +#define atomic64_add_unchecked(a, v) atomic64_add((a), (v))
73772 +#define atomic64_add_return_unchecked(a, v) atomic64_add_return((a), (v))
73773 +#define atomic64_sub_unchecked(a, v) atomic64_sub((a), (v))
73774 +#define atomic64_inc_unchecked(v) atomic64_inc(v)
73775 +#define atomic64_inc_return_unchecked(v) atomic64_inc_return(v)
73776 +#define atomic64_dec_unchecked(v) atomic64_dec(v)
73777 +#define atomic64_cmpxchg_unchecked(v, o, n) atomic64_cmpxchg((v), (o), (n))
73778 +
73779 #endif /* _ASM_GENERIC_ATOMIC64_H */
73780 diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h
73781 index a60a7cc..0fe12f2 100644
73782 --- a/include/asm-generic/bitops/__fls.h
73783 +++ b/include/asm-generic/bitops/__fls.h
73784 @@ -9,7 +9,7 @@
73785 *
73786 * Undefined if no set bit exists, so code should check against 0 first.
73787 */
73788 -static __always_inline unsigned long __fls(unsigned long word)
73789 +static __always_inline unsigned long __intentional_overflow(-1) __fls(unsigned long word)
73790 {
73791 int num = BITS_PER_LONG - 1;
73792
73793 diff --git a/include/asm-generic/bitops/fls.h b/include/asm-generic/bitops/fls.h
73794 index 0576d1f..dad6c71 100644
73795 --- a/include/asm-generic/bitops/fls.h
73796 +++ b/include/asm-generic/bitops/fls.h
73797 @@ -9,7 +9,7 @@
73798 * Note fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.
73799 */
73800
73801 -static __always_inline int fls(int x)
73802 +static __always_inline int __intentional_overflow(-1) fls(int x)
73803 {
73804 int r = 32;
73805
73806 diff --git a/include/asm-generic/bitops/fls64.h b/include/asm-generic/bitops/fls64.h
73807 index b097cf8..3d40e14 100644
73808 --- a/include/asm-generic/bitops/fls64.h
73809 +++ b/include/asm-generic/bitops/fls64.h
73810 @@ -15,7 +15,7 @@
73811 * at position 64.
73812 */
73813 #if BITS_PER_LONG == 32
73814 -static __always_inline int fls64(__u64 x)
73815 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
73816 {
73817 __u32 h = x >> 32;
73818 if (h)
73819 @@ -23,7 +23,7 @@ static __always_inline int fls64(__u64 x)
73820 return fls(x);
73821 }
73822 #elif BITS_PER_LONG == 64
73823 -static __always_inline int fls64(__u64 x)
73824 +static __always_inline int __intentional_overflow(-1) fls64(__u64 x)
73825 {
73826 if (x == 0)
73827 return 0;
73828 diff --git a/include/asm-generic/cache.h b/include/asm-generic/cache.h
73829 index 1bfcfe5..e04c5c9 100644
73830 --- a/include/asm-generic/cache.h
73831 +++ b/include/asm-generic/cache.h
73832 @@ -6,7 +6,7 @@
73833 * cache lines need to provide their own cache.h.
73834 */
73835
73836 -#define L1_CACHE_SHIFT 5
73837 -#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
73838 +#define L1_CACHE_SHIFT 5UL
73839 +#define L1_CACHE_BYTES (1UL << L1_CACHE_SHIFT)
73840
73841 #endif /* __ASM_GENERIC_CACHE_H */
73842 diff --git a/include/asm-generic/emergency-restart.h b/include/asm-generic/emergency-restart.h
73843 index 0d68a1e..b74a761 100644
73844 --- a/include/asm-generic/emergency-restart.h
73845 +++ b/include/asm-generic/emergency-restart.h
73846 @@ -1,7 +1,7 @@
73847 #ifndef _ASM_GENERIC_EMERGENCY_RESTART_H
73848 #define _ASM_GENERIC_EMERGENCY_RESTART_H
73849
73850 -static inline void machine_emergency_restart(void)
73851 +static inline __noreturn void machine_emergency_restart(void)
73852 {
73853 machine_restart(NULL);
73854 }
73855 diff --git a/include/asm-generic/kmap_types.h b/include/asm-generic/kmap_types.h
73856 index 90f99c7..00ce236 100644
73857 --- a/include/asm-generic/kmap_types.h
73858 +++ b/include/asm-generic/kmap_types.h
73859 @@ -2,9 +2,9 @@
73860 #define _ASM_GENERIC_KMAP_TYPES_H
73861
73862 #ifdef __WITH_KM_FENCE
73863 -# define KM_TYPE_NR 41
73864 +# define KM_TYPE_NR 42
73865 #else
73866 -# define KM_TYPE_NR 20
73867 +# define KM_TYPE_NR 21
73868 #endif
73869
73870 #endif
73871 diff --git a/include/asm-generic/local.h b/include/asm-generic/local.h
73872 index 9ceb03b..62b0b8f 100644
73873 --- a/include/asm-generic/local.h
73874 +++ b/include/asm-generic/local.h
73875 @@ -23,24 +23,37 @@ typedef struct
73876 atomic_long_t a;
73877 } local_t;
73878
73879 +typedef struct {
73880 + atomic_long_unchecked_t a;
73881 +} local_unchecked_t;
73882 +
73883 #define LOCAL_INIT(i) { ATOMIC_LONG_INIT(i) }
73884
73885 #define local_read(l) atomic_long_read(&(l)->a)
73886 +#define local_read_unchecked(l) atomic_long_read_unchecked(&(l)->a)
73887 #define local_set(l,i) atomic_long_set((&(l)->a),(i))
73888 +#define local_set_unchecked(l,i) atomic_long_set_unchecked((&(l)->a),(i))
73889 #define local_inc(l) atomic_long_inc(&(l)->a)
73890 +#define local_inc_unchecked(l) atomic_long_inc_unchecked(&(l)->a)
73891 #define local_dec(l) atomic_long_dec(&(l)->a)
73892 +#define local_dec_unchecked(l) atomic_long_dec_unchecked(&(l)->a)
73893 #define local_add(i,l) atomic_long_add((i),(&(l)->a))
73894 +#define local_add_unchecked(i,l) atomic_long_add_unchecked((i),(&(l)->a))
73895 #define local_sub(i,l) atomic_long_sub((i),(&(l)->a))
73896 +#define local_sub_unchecked(i,l) atomic_long_sub_unchecked((i),(&(l)->a))
73897
73898 #define local_sub_and_test(i, l) atomic_long_sub_and_test((i), (&(l)->a))
73899 #define local_dec_and_test(l) atomic_long_dec_and_test(&(l)->a)
73900 #define local_inc_and_test(l) atomic_long_inc_and_test(&(l)->a)
73901 #define local_add_negative(i, l) atomic_long_add_negative((i), (&(l)->a))
73902 #define local_add_return(i, l) atomic_long_add_return((i), (&(l)->a))
73903 +#define local_add_return_unchecked(i, l) atomic_long_add_return_unchecked((i), (&(l)->a))
73904 #define local_sub_return(i, l) atomic_long_sub_return((i), (&(l)->a))
73905 #define local_inc_return(l) atomic_long_inc_return(&(l)->a)
73906 +#define local_dec_return(l) atomic_long_dec_return(&(l)->a)
73907
73908 #define local_cmpxchg(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73909 +#define local_cmpxchg_unchecked(l, o, n) atomic_long_cmpxchg((&(l)->a), (o), (n))
73910 #define local_xchg(l, n) atomic_long_xchg((&(l)->a), (n))
73911 #define local_add_unless(l, _a, u) atomic_long_add_unless((&(l)->a), (_a), (u))
73912 #define local_inc_not_zero(l) atomic_long_inc_not_zero(&(l)->a)
73913 diff --git a/include/asm-generic/pgtable-nopmd.h b/include/asm-generic/pgtable-nopmd.h
73914 index 725612b..9cc513a 100644
73915 --- a/include/asm-generic/pgtable-nopmd.h
73916 +++ b/include/asm-generic/pgtable-nopmd.h
73917 @@ -1,14 +1,19 @@
73918 #ifndef _PGTABLE_NOPMD_H
73919 #define _PGTABLE_NOPMD_H
73920
73921 -#ifndef __ASSEMBLY__
73922 -
73923 #include <asm-generic/pgtable-nopud.h>
73924
73925 -struct mm_struct;
73926 -
73927 #define __PAGETABLE_PMD_FOLDED
73928
73929 +#define PMD_SHIFT PUD_SHIFT
73930 +#define PTRS_PER_PMD 1
73931 +#define PMD_SIZE (_AC(1,UL) << PMD_SHIFT)
73932 +#define PMD_MASK (~(PMD_SIZE-1))
73933 +
73934 +#ifndef __ASSEMBLY__
73935 +
73936 +struct mm_struct;
73937 +
73938 /*
73939 * Having the pmd type consist of a pud gets the size right, and allows
73940 * us to conceptually access the pud entry that this pmd is folded into
73941 @@ -16,11 +21,6 @@ struct mm_struct;
73942 */
73943 typedef struct { pud_t pud; } pmd_t;
73944
73945 -#define PMD_SHIFT PUD_SHIFT
73946 -#define PTRS_PER_PMD 1
73947 -#define PMD_SIZE (1UL << PMD_SHIFT)
73948 -#define PMD_MASK (~(PMD_SIZE-1))
73949 -
73950 /*
73951 * The "pud_xxx()" functions here are trivial for a folded two-level
73952 * setup: the pmd is never bad, and a pmd always exists (as it's folded
73953 diff --git a/include/asm-generic/pgtable-nopud.h b/include/asm-generic/pgtable-nopud.h
73954 index 810431d..0ec4804f 100644
73955 --- a/include/asm-generic/pgtable-nopud.h
73956 +++ b/include/asm-generic/pgtable-nopud.h
73957 @@ -1,10 +1,15 @@
73958 #ifndef _PGTABLE_NOPUD_H
73959 #define _PGTABLE_NOPUD_H
73960
73961 -#ifndef __ASSEMBLY__
73962 -
73963 #define __PAGETABLE_PUD_FOLDED
73964
73965 +#define PUD_SHIFT PGDIR_SHIFT
73966 +#define PTRS_PER_PUD 1
73967 +#define PUD_SIZE (_AC(1,UL) << PUD_SHIFT)
73968 +#define PUD_MASK (~(PUD_SIZE-1))
73969 +
73970 +#ifndef __ASSEMBLY__
73971 +
73972 /*
73973 * Having the pud type consist of a pgd gets the size right, and allows
73974 * us to conceptually access the pgd entry that this pud is folded into
73975 @@ -12,11 +17,6 @@
73976 */
73977 typedef struct { pgd_t pgd; } pud_t;
73978
73979 -#define PUD_SHIFT PGDIR_SHIFT
73980 -#define PTRS_PER_PUD 1
73981 -#define PUD_SIZE (1UL << PUD_SHIFT)
73982 -#define PUD_MASK (~(PUD_SIZE-1))
73983 -
73984 /*
73985 * The "pgd_xxx()" functions here are trivial for a folded two-level
73986 * setup: the pud is never bad, and a pud always exists (as it's folded
73987 @@ -29,6 +29,7 @@ static inline void pgd_clear(pgd_t *pgd) { }
73988 #define pud_ERROR(pud) (pgd_ERROR((pud).pgd))
73989
73990 #define pgd_populate(mm, pgd, pud) do { } while (0)
73991 +#define pgd_populate_kernel(mm, pgd, pud) do { } while (0)
73992 /*
73993 * (puds are folded into pgds so this doesn't get actually called,
73994 * but the define is needed for a generic inline function.)
73995 diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h
73996 index b12079a..86683e3 100644
73997 --- a/include/asm-generic/pgtable.h
73998 +++ b/include/asm-generic/pgtable.h
73999 @@ -599,11 +599,10 @@ static inline int pmd_none_or_trans_huge_or_clear_bad(pmd_t *pmd)
74000 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
74001 barrier();
74002 #endif
74003 - if (pmd_none(pmdval))
74004 + if (pmd_none(pmdval) || pmd_trans_huge(pmdval))
74005 return 1;
74006 if (unlikely(pmd_bad(pmdval))) {
74007 - if (!pmd_trans_huge(pmdval))
74008 - pmd_clear_bad(pmd);
74009 + pmd_clear_bad(pmd);
74010 return 1;
74011 }
74012 return 0;
74013 @@ -737,6 +736,22 @@ static inline pmd_t pmd_mknuma(pmd_t pmd)
74014 }
74015 #endif /* CONFIG_NUMA_BALANCING */
74016
74017 +#ifndef __HAVE_ARCH_PAX_OPEN_KERNEL
74018 +#ifdef CONFIG_PAX_KERNEXEC
74019 +#error KERNEXEC requires pax_open_kernel
74020 +#else
74021 +static inline unsigned long pax_open_kernel(void) { return 0; }
74022 +#endif
74023 +#endif
74024 +
74025 +#ifndef __HAVE_ARCH_PAX_CLOSE_KERNEL
74026 +#ifdef CONFIG_PAX_KERNEXEC
74027 +#error KERNEXEC requires pax_close_kernel
74028 +#else
74029 +static inline unsigned long pax_close_kernel(void) { return 0; }
74030 +#endif
74031 +#endif
74032 +
74033 #endif /* CONFIG_MMU */
74034
74035 #endif /* !__ASSEMBLY__ */
74036 diff --git a/include/asm-generic/uaccess.h b/include/asm-generic/uaccess.h
74037 index dc1269c..48a4f51 100644
74038 --- a/include/asm-generic/uaccess.h
74039 +++ b/include/asm-generic/uaccess.h
74040 @@ -343,4 +343,20 @@ clear_user(void __user *to, unsigned long n)
74041 return __clear_user(to, n);
74042 }
74043
74044 +#ifndef __HAVE_ARCH_PAX_OPEN_USERLAND
74045 +#ifdef CONFIG_PAX_MEMORY_UDEREF
74046 +#error UDEREF requires pax_open_userland
74047 +#else
74048 +static inline unsigned long pax_open_userland(void) { return 0; }
74049 +#endif
74050 +#endif
74051 +
74052 +#ifndef __HAVE_ARCH_PAX_CLOSE_USERLAND
74053 +#ifdef CONFIG_PAX_MEMORY_UDEREF
74054 +#error UDEREF requires pax_close_userland
74055 +#else
74056 +static inline unsigned long pax_close_userland(void) { return 0; }
74057 +#endif
74058 +#endif
74059 +
74060 #endif /* __ASM_GENERIC_UACCESS_H */
74061 diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
74062 index 83e2c31..eeb4a04 100644
74063 --- a/include/asm-generic/vmlinux.lds.h
74064 +++ b/include/asm-generic/vmlinux.lds.h
74065 @@ -232,6 +232,7 @@
74066 .rodata : AT(ADDR(.rodata) - LOAD_OFFSET) { \
74067 VMLINUX_SYMBOL(__start_rodata) = .; \
74068 *(.rodata) *(.rodata.*) \
74069 + *(.data..read_only) \
74070 *(__vermagic) /* Kernel version magic */ \
74071 . = ALIGN(8); \
74072 VMLINUX_SYMBOL(__start___tracepoints_ptrs) = .; \
74073 @@ -715,17 +716,18 @@
74074 * section in the linker script will go there too. @phdr should have
74075 * a leading colon.
74076 *
74077 - * Note that this macros defines __per_cpu_load as an absolute symbol.
74078 + * Note that this macros defines per_cpu_load as an absolute symbol.
74079 * If there is no need to put the percpu section at a predetermined
74080 * address, use PERCPU_SECTION.
74081 */
74082 #define PERCPU_VADDR(cacheline, vaddr, phdr) \
74083 - VMLINUX_SYMBOL(__per_cpu_load) = .; \
74084 - .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
74085 + per_cpu_load = .; \
74086 + .data..percpu vaddr : AT(VMLINUX_SYMBOL(per_cpu_load) \
74087 - LOAD_OFFSET) { \
74088 + VMLINUX_SYMBOL(__per_cpu_load) = . + per_cpu_load; \
74089 PERCPU_INPUT(cacheline) \
74090 } phdr \
74091 - . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
74092 + . = VMLINUX_SYMBOL(per_cpu_load) + SIZEOF(.data..percpu);
74093
74094 /**
74095 * PERCPU_SECTION - define output section for percpu area, simple version
74096 diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h
74097 index 418d270..bfd2794 100644
74098 --- a/include/crypto/algapi.h
74099 +++ b/include/crypto/algapi.h
74100 @@ -34,7 +34,7 @@ struct crypto_type {
74101 unsigned int maskclear;
74102 unsigned int maskset;
74103 unsigned int tfmsize;
74104 -};
74105 +} __do_const;
74106
74107 struct crypto_instance {
74108 struct crypto_alg alg;
74109 diff --git a/include/drm/drmP.h b/include/drm/drmP.h
74110 index b46fb45..b30d6d5 100644
74111 --- a/include/drm/drmP.h
74112 +++ b/include/drm/drmP.h
74113 @@ -66,6 +66,7 @@
74114 #include <linux/workqueue.h>
74115 #include <linux/poll.h>
74116 #include <asm/pgalloc.h>
74117 +#include <asm/local.h>
74118 #include <drm/drm.h>
74119 #include <drm/drm_sarea.h>
74120 #include <drm/drm_vma_manager.h>
74121 @@ -277,10 +278,12 @@ do { \
74122 * \param cmd command.
74123 * \param arg argument.
74124 */
74125 -typedef int drm_ioctl_t(struct drm_device *dev, void *data,
74126 +typedef int (* const drm_ioctl_t)(struct drm_device *dev, void *data,
74127 + struct drm_file *file_priv);
74128 +typedef int (* drm_ioctl_no_const_t)(struct drm_device *dev, void *data,
74129 struct drm_file *file_priv);
74130
74131 -typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
74132 +typedef int (* const drm_ioctl_compat_t)(struct file *filp, unsigned int cmd,
74133 unsigned long arg);
74134
74135 #define DRM_IOCTL_NR(n) _IOC_NR(n)
74136 @@ -296,10 +299,10 @@ typedef int drm_ioctl_compat_t(struct file *filp, unsigned int cmd,
74137 struct drm_ioctl_desc {
74138 unsigned int cmd;
74139 int flags;
74140 - drm_ioctl_t *func;
74141 + drm_ioctl_t func;
74142 unsigned int cmd_drv;
74143 const char *name;
74144 -};
74145 +} __do_const;
74146
74147 /**
74148 * Creates a driver or general drm_ioctl_desc array entry for the given
74149 @@ -1027,7 +1030,7 @@ struct drm_info_list {
74150 int (*show)(struct seq_file*, void*); /** show callback */
74151 u32 driver_features; /**< Required driver features for this entry */
74152 void *data;
74153 -};
74154 +} __do_const;
74155
74156 /**
74157 * debugfs node structure. This structure represents a debugfs file.
74158 @@ -1098,7 +1101,7 @@ struct drm_device {
74159
74160 /** \name Usage Counters */
74161 /*@{ */
74162 - int open_count; /**< Outstanding files open */
74163 + local_t open_count; /**< Outstanding files open */
74164 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
74165 atomic_t vma_count; /**< Outstanding vma areas open */
74166 int buf_use; /**< Buffers in use -- cannot alloc */
74167 @@ -1109,7 +1112,7 @@ struct drm_device {
74168 /*@{ */
74169 unsigned long counters;
74170 enum drm_stat_type types[15];
74171 - atomic_t counts[15];
74172 + atomic_unchecked_t counts[15];
74173 /*@} */
74174
74175 struct list_head filelist;
74176 diff --git a/include/drm/drm_crtc_helper.h b/include/drm/drm_crtc_helper.h
74177 index f43d556..94d9343 100644
74178 --- a/include/drm/drm_crtc_helper.h
74179 +++ b/include/drm/drm_crtc_helper.h
74180 @@ -109,7 +109,7 @@ struct drm_encoder_helper_funcs {
74181 struct drm_connector *connector);
74182 /* disable encoder when not in use - more explicit than dpms off */
74183 void (*disable)(struct drm_encoder *encoder);
74184 -};
74185 +} __no_const;
74186
74187 /**
74188 * drm_connector_helper_funcs - helper operations for connectors
74189 diff --git a/include/drm/i915_pciids.h b/include/drm/i915_pciids.h
74190 index 8a10f5c..5de7f5c 100644
74191 --- a/include/drm/i915_pciids.h
74192 +++ b/include/drm/i915_pciids.h
74193 @@ -37,7 +37,7 @@
74194 */
74195 #define INTEL_VGA_DEVICE(id, info) { \
74196 0x8086, id, \
74197 - ~0, ~0, \
74198 + PCI_ANY_ID, PCI_ANY_ID, \
74199 0x030000, 0xff0000, \
74200 (unsigned long) info }
74201
74202 diff --git a/include/drm/ttm/ttm_memory.h b/include/drm/ttm/ttm_memory.h
74203 index 72dcbe8..8db58d7 100644
74204 --- a/include/drm/ttm/ttm_memory.h
74205 +++ b/include/drm/ttm/ttm_memory.h
74206 @@ -48,7 +48,7 @@
74207
74208 struct ttm_mem_shrink {
74209 int (*do_shrink) (struct ttm_mem_shrink *);
74210 -};
74211 +} __no_const;
74212
74213 /**
74214 * struct ttm_mem_global - Global memory accounting structure.
74215 diff --git a/include/keys/asymmetric-subtype.h b/include/keys/asymmetric-subtype.h
74216 index 4b840e8..155d235 100644
74217 --- a/include/keys/asymmetric-subtype.h
74218 +++ b/include/keys/asymmetric-subtype.h
74219 @@ -37,7 +37,7 @@ struct asymmetric_key_subtype {
74220 /* Verify the signature on a key of this subtype (optional) */
74221 int (*verify_signature)(const struct key *key,
74222 const struct public_key_signature *sig);
74223 -};
74224 +} __do_const;
74225
74226 /**
74227 * asymmetric_key_subtype - Get the subtype from an asymmetric key
74228 diff --git a/include/linux/atmdev.h b/include/linux/atmdev.h
74229 index c1da539..1dcec55 100644
74230 --- a/include/linux/atmdev.h
74231 +++ b/include/linux/atmdev.h
74232 @@ -28,7 +28,7 @@ struct compat_atm_iobuf {
74233 #endif
74234
74235 struct k_atm_aal_stats {
74236 -#define __HANDLE_ITEM(i) atomic_t i
74237 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
74238 __AAL_STAT_ITEMS
74239 #undef __HANDLE_ITEM
74240 };
74241 @@ -200,7 +200,7 @@ struct atmdev_ops { /* only send is required */
74242 int (*change_qos)(struct atm_vcc *vcc,struct atm_qos *qos,int flags);
74243 int (*proc_read)(struct atm_dev *dev,loff_t *pos,char *page);
74244 struct module *owner;
74245 -};
74246 +} __do_const ;
74247
74248 struct atmphy_ops {
74249 int (*start)(struct atm_dev *dev);
74250 diff --git a/include/linux/audit.h b/include/linux/audit.h
74251 index 729a4d1..9b304ae 100644
74252 --- a/include/linux/audit.h
74253 +++ b/include/linux/audit.h
74254 @@ -193,7 +193,7 @@ static inline void audit_ptrace(struct task_struct *t)
74255 extern unsigned int audit_serial(void);
74256 extern int auditsc_get_stamp(struct audit_context *ctx,
74257 struct timespec *t, unsigned int *serial);
74258 -extern int audit_set_loginuid(kuid_t loginuid);
74259 +extern int __intentional_overflow(-1) audit_set_loginuid(kuid_t loginuid);
74260
74261 static inline kuid_t audit_get_loginuid(struct task_struct *tsk)
74262 {
74263 diff --git a/include/linux/binfmts.h b/include/linux/binfmts.h
74264 index 7554fd4..0f86379 100644
74265 --- a/include/linux/binfmts.h
74266 +++ b/include/linux/binfmts.h
74267 @@ -73,8 +73,10 @@ struct linux_binfmt {
74268 int (*load_binary)(struct linux_binprm *);
74269 int (*load_shlib)(struct file *);
74270 int (*core_dump)(struct coredump_params *cprm);
74271 + void (*handle_mprotect)(struct vm_area_struct *vma, unsigned long newflags);
74272 + void (*handle_mmap)(struct file *);
74273 unsigned long min_coredump; /* minimal dump size */
74274 -};
74275 +} __do_const;
74276
74277 extern void __register_binfmt(struct linux_binfmt *fmt, int insert);
74278
74279 diff --git a/include/linux/bitops.h b/include/linux/bitops.h
74280 index a3b6b82..2a7d758 100644
74281 --- a/include/linux/bitops.h
74282 +++ b/include/linux/bitops.h
74283 @@ -91,7 +91,7 @@ static inline __u64 ror64(__u64 word, unsigned int shift)
74284 * @word: value to rotate
74285 * @shift: bits to roll
74286 */
74287 -static inline __u32 rol32(__u32 word, unsigned int shift)
74288 +static inline __u32 __intentional_overflow(-1) rol32(__u32 word, unsigned int shift)
74289 {
74290 return (word << shift) | (word >> (32 - shift));
74291 }
74292 @@ -101,7 +101,7 @@ static inline __u32 rol32(__u32 word, unsigned int shift)
74293 * @word: value to rotate
74294 * @shift: bits to roll
74295 */
74296 -static inline __u32 ror32(__u32 word, unsigned int shift)
74297 +static inline __u32 __intentional_overflow(-1) ror32(__u32 word, unsigned int shift)
74298 {
74299 return (word >> shift) | (word << (32 - shift));
74300 }
74301 @@ -157,7 +157,7 @@ static inline __s32 sign_extend32(__u32 value, int index)
74302 return (__s32)(value << shift) >> shift;
74303 }
74304
74305 -static inline unsigned fls_long(unsigned long l)
74306 +static inline unsigned __intentional_overflow(-1) fls_long(unsigned long l)
74307 {
74308 if (sizeof(l) == 4)
74309 return fls(l);
74310 diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
74311 index 0e6f765..885bb2b 100644
74312 --- a/include/linux/blkdev.h
74313 +++ b/include/linux/blkdev.h
74314 @@ -1537,7 +1537,7 @@ struct block_device_operations {
74315 /* this callback is with swap_lock and sometimes page table lock held */
74316 void (*swap_slot_free_notify) (struct block_device *, unsigned long);
74317 struct module *owner;
74318 -};
74319 +} __do_const;
74320
74321 extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
74322 unsigned long);
74323 diff --git a/include/linux/blktrace_api.h b/include/linux/blktrace_api.h
74324 index 7c2e030..b72475d 100644
74325 --- a/include/linux/blktrace_api.h
74326 +++ b/include/linux/blktrace_api.h
74327 @@ -23,7 +23,7 @@ struct blk_trace {
74328 struct dentry *dir;
74329 struct dentry *dropped_file;
74330 struct dentry *msg_file;
74331 - atomic_t dropped;
74332 + atomic_unchecked_t dropped;
74333 };
74334
74335 extern int blk_trace_ioctl(struct block_device *, unsigned, char __user *);
74336 diff --git a/include/linux/cache.h b/include/linux/cache.h
74337 index 4c57065..40346da 100644
74338 --- a/include/linux/cache.h
74339 +++ b/include/linux/cache.h
74340 @@ -16,6 +16,14 @@
74341 #define __read_mostly
74342 #endif
74343
74344 +#ifndef __read_only
74345 +#ifdef CONFIG_PAX_KERNEXEC
74346 +#error KERNEXEC requires __read_only
74347 +#else
74348 +#define __read_only __read_mostly
74349 +#endif
74350 +#endif
74351 +
74352 #ifndef ____cacheline_aligned
74353 #define ____cacheline_aligned __attribute__((__aligned__(SMP_CACHE_BYTES)))
74354 #endif
74355 diff --git a/include/linux/capability.h b/include/linux/capability.h
74356 index a6ee1f9..e1ca49d 100644
74357 --- a/include/linux/capability.h
74358 +++ b/include/linux/capability.h
74359 @@ -212,8 +212,13 @@ extern bool capable(int cap);
74360 extern bool ns_capable(struct user_namespace *ns, int cap);
74361 extern bool inode_capable(const struct inode *inode, int cap);
74362 extern bool file_ns_capable(const struct file *file, struct user_namespace *ns, int cap);
74363 +extern bool capable_nolog(int cap);
74364 +extern bool ns_capable_nolog(struct user_namespace *ns, int cap);
74365 +extern bool inode_capable_nolog(const struct inode *inode, int cap);
74366
74367 /* audit system wants to get cap info from files as well */
74368 extern int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data *cpu_caps);
74369
74370 +extern int is_privileged_binary(const struct dentry *dentry);
74371 +
74372 #endif /* !_LINUX_CAPABILITY_H */
74373 diff --git a/include/linux/cdrom.h b/include/linux/cdrom.h
74374 index 8609d57..86e4d79 100644
74375 --- a/include/linux/cdrom.h
74376 +++ b/include/linux/cdrom.h
74377 @@ -87,7 +87,6 @@ struct cdrom_device_ops {
74378
74379 /* driver specifications */
74380 const int capability; /* capability flags */
74381 - int n_minors; /* number of active minor devices */
74382 /* handle uniform packets for scsi type devices (scsi,atapi) */
74383 int (*generic_packet) (struct cdrom_device_info *,
74384 struct packet_command *);
74385 diff --git a/include/linux/cleancache.h b/include/linux/cleancache.h
74386 index 4ce9056..86caac6 100644
74387 --- a/include/linux/cleancache.h
74388 +++ b/include/linux/cleancache.h
74389 @@ -31,7 +31,7 @@ struct cleancache_ops {
74390 void (*invalidate_page)(int, struct cleancache_filekey, pgoff_t);
74391 void (*invalidate_inode)(int, struct cleancache_filekey);
74392 void (*invalidate_fs)(int);
74393 -};
74394 +} __no_const;
74395
74396 extern struct cleancache_ops *
74397 cleancache_register_ops(struct cleancache_ops *ops);
74398 diff --git a/include/linux/clk-provider.h b/include/linux/clk-provider.h
74399 index 73bdb69..d66d47a 100644
74400 --- a/include/linux/clk-provider.h
74401 +++ b/include/linux/clk-provider.h
74402 @@ -141,6 +141,7 @@ struct clk_ops {
74403 unsigned long);
74404 void (*init)(struct clk_hw *hw);
74405 };
74406 +typedef struct clk_ops __no_const clk_ops_no_const;
74407
74408 /**
74409 * struct clk_init_data - holds init data that's common to all clocks and is
74410 diff --git a/include/linux/compat.h b/include/linux/compat.h
74411 index 345da00..b6eff26 100644
74412 --- a/include/linux/compat.h
74413 +++ b/include/linux/compat.h
74414 @@ -313,7 +313,7 @@ compat_sys_get_robust_list(int pid, compat_uptr_t __user *head_ptr,
74415 compat_size_t __user *len_ptr);
74416
74417 asmlinkage long compat_sys_ipc(u32, int, int, u32, compat_uptr_t, u32);
74418 -asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg);
74419 +asmlinkage long compat_sys_shmat(int shmid, compat_uptr_t shmaddr, int shmflg) __intentional_overflow(0);
74420 asmlinkage long compat_sys_semctl(int semid, int semnum, int cmd, int arg);
74421 asmlinkage long compat_sys_msgsnd(int msqid, compat_uptr_t msgp,
74422 compat_ssize_t msgsz, int msgflg);
74423 @@ -420,7 +420,7 @@ extern int compat_ptrace_request(struct task_struct *child,
74424 extern long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
74425 compat_ulong_t addr, compat_ulong_t data);
74426 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
74427 - compat_long_t addr, compat_long_t data);
74428 + compat_ulong_t addr, compat_ulong_t data);
74429
74430 asmlinkage long compat_sys_lookup_dcookie(u32, u32, char __user *, size_t);
74431 /*
74432 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h
74433 index ded4299..da50e3b 100644
74434 --- a/include/linux/compiler-gcc4.h
74435 +++ b/include/linux/compiler-gcc4.h
74436 @@ -39,9 +39,29 @@
74437 # define __compiletime_warning(message) __attribute__((warning(message)))
74438 # define __compiletime_error(message) __attribute__((error(message)))
74439 #endif /* __CHECKER__ */
74440 +
74441 +#define __alloc_size(...) __attribute((alloc_size(__VA_ARGS__)))
74442 +#define __bos(ptr, arg) __builtin_object_size((ptr), (arg))
74443 +#define __bos0(ptr) __bos((ptr), 0)
74444 +#define __bos1(ptr) __bos((ptr), 1)
74445 #endif /* GCC_VERSION >= 40300 */
74446
74447 #if GCC_VERSION >= 40500
74448 +
74449 +#ifdef CONSTIFY_PLUGIN
74450 +#define __no_const __attribute__((no_const))
74451 +#define __do_const __attribute__((do_const))
74452 +#endif
74453 +
74454 +#ifdef SIZE_OVERFLOW_PLUGIN
74455 +#define __size_overflow(...) __attribute__((size_overflow(__VA_ARGS__)))
74456 +#define __intentional_overflow(...) __attribute__((intentional_overflow(__VA_ARGS__)))
74457 +#endif
74458 +
74459 +#ifdef LATENT_ENTROPY_PLUGIN
74460 +#define __latent_entropy __attribute__((latent_entropy))
74461 +#endif
74462 +
74463 /*
74464 * Mark a position in code as unreachable. This can be used to
74465 * suppress control flow warnings after asm blocks that transfer
74466 diff --git a/include/linux/compiler.h b/include/linux/compiler.h
74467 index 92669cd..1771a15 100644
74468 --- a/include/linux/compiler.h
74469 +++ b/include/linux/compiler.h
74470 @@ -5,11 +5,14 @@
74471
74472 #ifdef __CHECKER__
74473 # define __user __attribute__((noderef, address_space(1)))
74474 +# define __force_user __force __user
74475 # define __kernel __attribute__((address_space(0)))
74476 +# define __force_kernel __force __kernel
74477 # define __safe __attribute__((safe))
74478 # define __force __attribute__((force))
74479 # define __nocast __attribute__((nocast))
74480 # define __iomem __attribute__((noderef, address_space(2)))
74481 +# define __force_iomem __force __iomem
74482 # define __must_hold(x) __attribute__((context(x,1,1)))
74483 # define __acquires(x) __attribute__((context(x,0,1)))
74484 # define __releases(x) __attribute__((context(x,1,0)))
74485 @@ -17,20 +20,37 @@
74486 # define __release(x) __context__(x,-1)
74487 # define __cond_lock(x,c) ((c) ? ({ __acquire(x); 1; }) : 0)
74488 # define __percpu __attribute__((noderef, address_space(3)))
74489 +# define __force_percpu __force __percpu
74490 #ifdef CONFIG_SPARSE_RCU_POINTER
74491 # define __rcu __attribute__((noderef, address_space(4)))
74492 +# define __force_rcu __force __rcu
74493 #else
74494 # define __rcu
74495 +# define __force_rcu
74496 #endif
74497 extern void __chk_user_ptr(const volatile void __user *);
74498 extern void __chk_io_ptr(const volatile void __iomem *);
74499 #else
74500 -# define __user
74501 -# define __kernel
74502 +# ifdef CHECKER_PLUGIN
74503 +//# define __user
74504 +//# define __force_user
74505 +//# define __kernel
74506 +//# define __force_kernel
74507 +# else
74508 +# ifdef STRUCTLEAK_PLUGIN
74509 +# define __user __attribute__((user))
74510 +# else
74511 +# define __user
74512 +# endif
74513 +# define __force_user
74514 +# define __kernel
74515 +# define __force_kernel
74516 +# endif
74517 # define __safe
74518 # define __force
74519 # define __nocast
74520 # define __iomem
74521 +# define __force_iomem
74522 # define __chk_user_ptr(x) (void)0
74523 # define __chk_io_ptr(x) (void)0
74524 # define __builtin_warning(x, y...) (1)
74525 @@ -41,7 +61,9 @@ extern void __chk_io_ptr(const volatile void __iomem *);
74526 # define __release(x) (void)0
74527 # define __cond_lock(x,c) (c)
74528 # define __percpu
74529 +# define __force_percpu
74530 # define __rcu
74531 +# define __force_rcu
74532 #endif
74533
74534 /* Indirect macros required for expanded argument pasting, eg. __LINE__. */
74535 @@ -275,6 +297,26 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74536 # define __attribute_const__ /* unimplemented */
74537 #endif
74538
74539 +#ifndef __no_const
74540 +# define __no_const
74541 +#endif
74542 +
74543 +#ifndef __do_const
74544 +# define __do_const
74545 +#endif
74546 +
74547 +#ifndef __size_overflow
74548 +# define __size_overflow(...)
74549 +#endif
74550 +
74551 +#ifndef __intentional_overflow
74552 +# define __intentional_overflow(...)
74553 +#endif
74554 +
74555 +#ifndef __latent_entropy
74556 +# define __latent_entropy
74557 +#endif
74558 +
74559 /*
74560 * Tell gcc if a function is cold. The compiler will assume any path
74561 * directly leading to the call is unlikely.
74562 @@ -284,6 +326,22 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74563 #define __cold
74564 #endif
74565
74566 +#ifndef __alloc_size
74567 +#define __alloc_size(...)
74568 +#endif
74569 +
74570 +#ifndef __bos
74571 +#define __bos(ptr, arg)
74572 +#endif
74573 +
74574 +#ifndef __bos0
74575 +#define __bos0(ptr)
74576 +#endif
74577 +
74578 +#ifndef __bos1
74579 +#define __bos1(ptr)
74580 +#endif
74581 +
74582 /* Simple shorthand for a section definition */
74583 #ifndef __section
74584 # define __section(S) __attribute__ ((__section__(#S)))
74585 @@ -349,7 +407,8 @@ void ftrace_likely_update(struct ftrace_branch_data *f, int val, int expect);
74586 * use is to mediate communication between process-level code and irq/NMI
74587 * handlers, all running on the same CPU.
74588 */
74589 -#define ACCESS_ONCE(x) (*(volatile typeof(x) *)&(x))
74590 +#define ACCESS_ONCE(x) (*(volatile const typeof(x) *)&(x))
74591 +#define ACCESS_ONCE_RW(x) (*(volatile typeof(x) *)&(x))
74592
74593 /* Ignore/forbid kprobes attach on very low level functions marked by this attribute: */
74594 #ifdef CONFIG_KPROBES
74595 diff --git a/include/linux/completion.h b/include/linux/completion.h
74596 index 3cd574d..240dcb0 100644
74597 --- a/include/linux/completion.h
74598 +++ b/include/linux/completion.h
74599 @@ -78,16 +78,16 @@ static inline void init_completion(struct completion *x)
74600
74601 extern void wait_for_completion(struct completion *);
74602 extern void wait_for_completion_io(struct completion *);
74603 -extern int wait_for_completion_interruptible(struct completion *x);
74604 -extern int wait_for_completion_killable(struct completion *x);
74605 +extern int wait_for_completion_interruptible(struct completion *x) __intentional_overflow(-1);
74606 +extern int wait_for_completion_killable(struct completion *x) __intentional_overflow(-1);
74607 extern unsigned long wait_for_completion_timeout(struct completion *x,
74608 - unsigned long timeout);
74609 + unsigned long timeout) __intentional_overflow(-1);
74610 extern unsigned long wait_for_completion_io_timeout(struct completion *x,
74611 - unsigned long timeout);
74612 + unsigned long timeout) __intentional_overflow(-1);
74613 extern long wait_for_completion_interruptible_timeout(
74614 - struct completion *x, unsigned long timeout);
74615 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
74616 extern long wait_for_completion_killable_timeout(
74617 - struct completion *x, unsigned long timeout);
74618 + struct completion *x, unsigned long timeout) __intentional_overflow(-1);
74619 extern bool try_wait_for_completion(struct completion *x);
74620 extern bool completion_done(struct completion *x);
74621
74622 diff --git a/include/linux/configfs.h b/include/linux/configfs.h
74623 index 34025df..d94bbbc 100644
74624 --- a/include/linux/configfs.h
74625 +++ b/include/linux/configfs.h
74626 @@ -125,7 +125,7 @@ struct configfs_attribute {
74627 const char *ca_name;
74628 struct module *ca_owner;
74629 umode_t ca_mode;
74630 -};
74631 +} __do_const;
74632
74633 /*
74634 * Users often need to create attribute structures for their configurable
74635 diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h
74636 index fcabc42..cba5d93 100644
74637 --- a/include/linux/cpufreq.h
74638 +++ b/include/linux/cpufreq.h
74639 @@ -167,6 +167,7 @@ struct global_attr {
74640 ssize_t (*store)(struct kobject *a, struct attribute *b,
74641 const char *c, size_t count);
74642 };
74643 +typedef struct global_attr __no_const global_attr_no_const;
74644
74645 #define define_one_global_ro(_name) \
74646 static struct global_attr _name = \
74647 @@ -208,7 +209,7 @@ struct cpufreq_driver {
74648 int (*suspend) (struct cpufreq_policy *policy);
74649 int (*resume) (struct cpufreq_policy *policy);
74650 struct freq_attr **attr;
74651 -};
74652 +} __do_const;
74653
74654 /* flags */
74655 #define CPUFREQ_STICKY 0x01 /* the driver isn't removed even if
74656 diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
74657 index 781addc..d1e1fe6 100644
74658 --- a/include/linux/cpuidle.h
74659 +++ b/include/linux/cpuidle.h
74660 @@ -50,7 +50,8 @@ struct cpuidle_state {
74661 int index);
74662
74663 int (*enter_dead) (struct cpuidle_device *dev, int index);
74664 -};
74665 +} __do_const;
74666 +typedef struct cpuidle_state __no_const cpuidle_state_no_const;
74667
74668 /* Idle State Flags */
74669 #define CPUIDLE_FLAG_TIME_VALID (0x01) /* is residency time measurable? */
74670 @@ -192,7 +193,7 @@ struct cpuidle_governor {
74671 void (*reflect) (struct cpuidle_device *dev, int index);
74672
74673 struct module *owner;
74674 -};
74675 +} __do_const;
74676
74677 #ifdef CONFIG_CPU_IDLE
74678
74679 diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
74680 index d08e4d2..95fad61 100644
74681 --- a/include/linux/cpumask.h
74682 +++ b/include/linux/cpumask.h
74683 @@ -118,17 +118,17 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74684 }
74685
74686 /* Valid inputs for n are -1 and 0. */
74687 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74688 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74689 {
74690 return n+1;
74691 }
74692
74693 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74694 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74695 {
74696 return n+1;
74697 }
74698
74699 -static inline unsigned int cpumask_next_and(int n,
74700 +static inline unsigned int __intentional_overflow(-1) cpumask_next_and(int n,
74701 const struct cpumask *srcp,
74702 const struct cpumask *andp)
74703 {
74704 @@ -167,7 +167,7 @@ static inline unsigned int cpumask_first(const struct cpumask *srcp)
74705 *
74706 * Returns >= nr_cpu_ids if no further cpus set.
74707 */
74708 -static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74709 +static inline unsigned int __intentional_overflow(-1) cpumask_next(int n, const struct cpumask *srcp)
74710 {
74711 /* -1 is a legal arg here. */
74712 if (n != -1)
74713 @@ -182,7 +182,7 @@ static inline unsigned int cpumask_next(int n, const struct cpumask *srcp)
74714 *
74715 * Returns >= nr_cpu_ids if no further cpus unset.
74716 */
74717 -static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74718 +static inline unsigned int __intentional_overflow(-1) cpumask_next_zero(int n, const struct cpumask *srcp)
74719 {
74720 /* -1 is a legal arg here. */
74721 if (n != -1)
74722 @@ -190,7 +190,7 @@ static inline unsigned int cpumask_next_zero(int n, const struct cpumask *srcp)
74723 return find_next_zero_bit(cpumask_bits(srcp), nr_cpumask_bits, n+1);
74724 }
74725
74726 -int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *);
74727 +int cpumask_next_and(int n, const struct cpumask *, const struct cpumask *) __intentional_overflow(-1);
74728 int cpumask_any_but(const struct cpumask *mask, unsigned int cpu);
74729
74730 /**
74731 diff --git a/include/linux/cred.h b/include/linux/cred.h
74732 index 04421e8..6bce4ef 100644
74733 --- a/include/linux/cred.h
74734 +++ b/include/linux/cred.h
74735 @@ -194,6 +194,9 @@ static inline void validate_creds_for_do_exit(struct task_struct *tsk)
74736 static inline void validate_process_creds(void)
74737 {
74738 }
74739 +static inline void validate_task_creds(struct task_struct *task)
74740 +{
74741 +}
74742 #endif
74743
74744 /**
74745 diff --git a/include/linux/crypto.h b/include/linux/crypto.h
74746 index b92eadf..b4ecdc1 100644
74747 --- a/include/linux/crypto.h
74748 +++ b/include/linux/crypto.h
74749 @@ -373,7 +373,7 @@ struct cipher_tfm {
74750 const u8 *key, unsigned int keylen);
74751 void (*cit_encrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74752 void (*cit_decrypt_one)(struct crypto_tfm *tfm, u8 *dst, const u8 *src);
74753 -};
74754 +} __no_const;
74755
74756 struct hash_tfm {
74757 int (*init)(struct hash_desc *desc);
74758 @@ -394,13 +394,13 @@ struct compress_tfm {
74759 int (*cot_decompress)(struct crypto_tfm *tfm,
74760 const u8 *src, unsigned int slen,
74761 u8 *dst, unsigned int *dlen);
74762 -};
74763 +} __no_const;
74764
74765 struct rng_tfm {
74766 int (*rng_gen_random)(struct crypto_rng *tfm, u8 *rdata,
74767 unsigned int dlen);
74768 int (*rng_reset)(struct crypto_rng *tfm, u8 *seed, unsigned int slen);
74769 -};
74770 +} __no_const;
74771
74772 #define crt_ablkcipher crt_u.ablkcipher
74773 #define crt_aead crt_u.aead
74774 diff --git a/include/linux/ctype.h b/include/linux/ctype.h
74775 index 653589e..4ef254a 100644
74776 --- a/include/linux/ctype.h
74777 +++ b/include/linux/ctype.h
74778 @@ -56,7 +56,7 @@ static inline unsigned char __toupper(unsigned char c)
74779 * Fast implementation of tolower() for internal usage. Do not use in your
74780 * code.
74781 */
74782 -static inline char _tolower(const char c)
74783 +static inline unsigned char _tolower(const unsigned char c)
74784 {
74785 return c | 0x20;
74786 }
74787 diff --git a/include/linux/decompress/mm.h b/include/linux/decompress/mm.h
74788 index 7925bf0..d5143d2 100644
74789 --- a/include/linux/decompress/mm.h
74790 +++ b/include/linux/decompress/mm.h
74791 @@ -77,7 +77,7 @@ static void free(void *where)
74792 * warnings when not needed (indeed large_malloc / large_free are not
74793 * needed by inflate */
74794
74795 -#define malloc(a) kmalloc(a, GFP_KERNEL)
74796 +#define malloc(a) kmalloc((a), GFP_KERNEL)
74797 #define free(a) kfree(a)
74798
74799 #define large_malloc(a) vmalloc(a)
74800 diff --git a/include/linux/devfreq.h b/include/linux/devfreq.h
74801 index 5f1ab92..39c35ae 100644
74802 --- a/include/linux/devfreq.h
74803 +++ b/include/linux/devfreq.h
74804 @@ -114,7 +114,7 @@ struct devfreq_governor {
74805 int (*get_target_freq)(struct devfreq *this, unsigned long *freq);
74806 int (*event_handler)(struct devfreq *devfreq,
74807 unsigned int event, void *data);
74808 -};
74809 +} __do_const;
74810
74811 /**
74812 * struct devfreq - Device devfreq structure
74813 diff --git a/include/linux/device.h b/include/linux/device.h
74814 index 2a9d6ed..d14551e3 100644
74815 --- a/include/linux/device.h
74816 +++ b/include/linux/device.h
74817 @@ -313,7 +313,7 @@ struct subsys_interface {
74818 struct list_head node;
74819 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
74820 int (*remove_dev)(struct device *dev, struct subsys_interface *sif);
74821 -};
74822 +} __do_const;
74823
74824 int subsys_interface_register(struct subsys_interface *sif);
74825 void subsys_interface_unregister(struct subsys_interface *sif);
74826 @@ -501,7 +501,7 @@ struct device_type {
74827 void (*release)(struct device *dev);
74828
74829 const struct dev_pm_ops *pm;
74830 -};
74831 +} __do_const;
74832
74833 /* interface for exporting device attributes */
74834 struct device_attribute {
74835 @@ -511,11 +511,12 @@ struct device_attribute {
74836 ssize_t (*store)(struct device *dev, struct device_attribute *attr,
74837 const char *buf, size_t count);
74838 };
74839 +typedef struct device_attribute __no_const device_attribute_no_const;
74840
74841 struct dev_ext_attribute {
74842 struct device_attribute attr;
74843 void *var;
74844 -};
74845 +} __do_const;
74846
74847 ssize_t device_show_ulong(struct device *dev, struct device_attribute *attr,
74848 char *buf);
74849 diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h
74850 index 3a8d0a2..c762be2 100644
74851 --- a/include/linux/dma-mapping.h
74852 +++ b/include/linux/dma-mapping.h
74853 @@ -54,7 +54,7 @@ struct dma_map_ops {
74854 u64 (*get_required_mask)(struct device *dev);
74855 #endif
74856 int is_phys;
74857 -};
74858 +} __do_const;
74859
74860 #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
74861
74862 diff --git a/include/linux/dmaengine.h b/include/linux/dmaengine.h
74863 index 0bc7275..4ccbf11 100644
74864 --- a/include/linux/dmaengine.h
74865 +++ b/include/linux/dmaengine.h
74866 @@ -1078,9 +1078,9 @@ struct dma_pinned_list {
74867 struct dma_pinned_list *dma_pin_iovec_pages(struct iovec *iov, size_t len);
74868 void dma_unpin_iovec_pages(struct dma_pinned_list* pinned_list);
74869
74870 -dma_cookie_t dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74871 +dma_cookie_t __intentional_overflow(0) dma_memcpy_to_iovec(struct dma_chan *chan, struct iovec *iov,
74872 struct dma_pinned_list *pinned_list, unsigned char *kdata, size_t len);
74873 -dma_cookie_t dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74874 +dma_cookie_t __intentional_overflow(0) dma_memcpy_pg_to_iovec(struct dma_chan *chan, struct iovec *iov,
74875 struct dma_pinned_list *pinned_list, struct page *page,
74876 unsigned int offset, size_t len);
74877
74878 diff --git a/include/linux/efi.h b/include/linux/efi.h
74879 index 094ddd0..f1dfcd3 100644
74880 --- a/include/linux/efi.h
74881 +++ b/include/linux/efi.h
74882 @@ -745,6 +745,7 @@ struct efivar_operations {
74883 efi_set_variable_t *set_variable;
74884 efi_query_variable_store_t *query_variable_store;
74885 };
74886 +typedef struct efivar_operations __no_const efivar_operations_no_const;
74887
74888 struct efivars {
74889 /*
74890 diff --git a/include/linux/elf.h b/include/linux/elf.h
74891 index 40a3c0e0..4c45a38 100644
74892 --- a/include/linux/elf.h
74893 +++ b/include/linux/elf.h
74894 @@ -24,6 +24,7 @@ extern Elf32_Dyn _DYNAMIC [];
74895 #define elf_note elf32_note
74896 #define elf_addr_t Elf32_Off
74897 #define Elf_Half Elf32_Half
74898 +#define elf_dyn Elf32_Dyn
74899
74900 #else
74901
74902 @@ -34,6 +35,7 @@ extern Elf64_Dyn _DYNAMIC [];
74903 #define elf_note elf64_note
74904 #define elf_addr_t Elf64_Off
74905 #define Elf_Half Elf64_Half
74906 +#define elf_dyn Elf64_Dyn
74907
74908 #endif
74909
74910 diff --git a/include/linux/err.h b/include/linux/err.h
74911 index 15f92e0..e825a8e 100644
74912 --- a/include/linux/err.h
74913 +++ b/include/linux/err.h
74914 @@ -19,12 +19,12 @@
74915
74916 #define IS_ERR_VALUE(x) unlikely((x) >= (unsigned long)-MAX_ERRNO)
74917
74918 -static inline void * __must_check ERR_PTR(long error)
74919 +static inline void * __must_check __intentional_overflow(-1) ERR_PTR(long error)
74920 {
74921 return (void *) error;
74922 }
74923
74924 -static inline long __must_check PTR_ERR(__force const void *ptr)
74925 +static inline long __must_check __intentional_overflow(-1) PTR_ERR(__force const void *ptr)
74926 {
74927 return (long) ptr;
74928 }
74929 diff --git a/include/linux/extcon.h b/include/linux/extcon.h
74930 index fcb51c8..bdafcf6 100644
74931 --- a/include/linux/extcon.h
74932 +++ b/include/linux/extcon.h
74933 @@ -134,7 +134,7 @@ struct extcon_dev {
74934 /* /sys/class/extcon/.../mutually_exclusive/... */
74935 struct attribute_group attr_g_muex;
74936 struct attribute **attrs_muex;
74937 - struct device_attribute *d_attrs_muex;
74938 + device_attribute_no_const *d_attrs_muex;
74939 };
74940
74941 /**
74942 diff --git a/include/linux/fb.h b/include/linux/fb.h
74943 index ffac70a..ca3e711 100644
74944 --- a/include/linux/fb.h
74945 +++ b/include/linux/fb.h
74946 @@ -304,7 +304,7 @@ struct fb_ops {
74947 /* called at KDB enter and leave time to prepare the console */
74948 int (*fb_debug_enter)(struct fb_info *info);
74949 int (*fb_debug_leave)(struct fb_info *info);
74950 -};
74951 +} __do_const;
74952
74953 #ifdef CONFIG_FB_TILEBLITTING
74954 #define FB_TILE_CURSOR_NONE 0
74955 diff --git a/include/linux/fdtable.h b/include/linux/fdtable.h
74956 index 085197b..0fa6f0b 100644
74957 --- a/include/linux/fdtable.h
74958 +++ b/include/linux/fdtable.h
74959 @@ -95,7 +95,7 @@ struct files_struct *get_files_struct(struct task_struct *);
74960 void put_files_struct(struct files_struct *fs);
74961 void reset_files_struct(struct files_struct *);
74962 int unshare_files(struct files_struct **);
74963 -struct files_struct *dup_fd(struct files_struct *, int *);
74964 +struct files_struct *dup_fd(struct files_struct *, int *) __latent_entropy;
74965 void do_close_on_exec(struct files_struct *);
74966 int iterate_fd(struct files_struct *, unsigned,
74967 int (*)(const void *, struct file *, unsigned),
74968 diff --git a/include/linux/frontswap.h b/include/linux/frontswap.h
74969 index 8293262..2b3b8bd 100644
74970 --- a/include/linux/frontswap.h
74971 +++ b/include/linux/frontswap.h
74972 @@ -11,7 +11,7 @@ struct frontswap_ops {
74973 int (*load)(unsigned, pgoff_t, struct page *);
74974 void (*invalidate_page)(unsigned, pgoff_t);
74975 void (*invalidate_area)(unsigned);
74976 -};
74977 +} __no_const;
74978
74979 extern bool frontswap_enabled;
74980 extern struct frontswap_ops *
74981 diff --git a/include/linux/fs.h b/include/linux/fs.h
74982 index 164d2a9..0ffa41d0 100644
74983 --- a/include/linux/fs.h
74984 +++ b/include/linux/fs.h
74985 @@ -1552,7 +1552,8 @@ struct file_operations {
74986 long (*fallocate)(struct file *file, int mode, loff_t offset,
74987 loff_t len);
74988 int (*show_fdinfo)(struct seq_file *m, struct file *f);
74989 -};
74990 +} __do_const;
74991 +typedef struct file_operations __no_const file_operations_no_const;
74992
74993 struct inode_operations {
74994 struct dentry * (*lookup) (struct inode *,struct dentry *, unsigned int);
74995 @@ -2747,4 +2748,14 @@ static inline bool dir_relax(struct inode *inode)
74996 return !IS_DEADDIR(inode);
74997 }
74998
74999 +static inline bool is_sidechannel_device(const struct inode *inode)
75000 +{
75001 +#ifdef CONFIG_GRKERNSEC_DEVICE_SIDECHANNEL
75002 + umode_t mode = inode->i_mode;
75003 + return ((S_ISCHR(mode) || S_ISBLK(mode)) && (mode & (S_IROTH | S_IWOTH)));
75004 +#else
75005 + return false;
75006 +#endif
75007 +}
75008 +
75009 #endif /* _LINUX_FS_H */
75010 diff --git a/include/linux/fs_struct.h b/include/linux/fs_struct.h
75011 index 0efc3e6..e0e1e5f 100644
75012 --- a/include/linux/fs_struct.h
75013 +++ b/include/linux/fs_struct.h
75014 @@ -6,7 +6,7 @@
75015 #include <linux/seqlock.h>
75016
75017 struct fs_struct {
75018 - int users;
75019 + atomic_t users;
75020 spinlock_t lock;
75021 seqcount_t seq;
75022 int umask;
75023 diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
75024 index 7823e9e..56b6f2f 100644
75025 --- a/include/linux/fscache-cache.h
75026 +++ b/include/linux/fscache-cache.h
75027 @@ -113,7 +113,7 @@ struct fscache_operation {
75028 fscache_operation_release_t release;
75029 };
75030
75031 -extern atomic_t fscache_op_debug_id;
75032 +extern atomic_unchecked_t fscache_op_debug_id;
75033 extern void fscache_op_work_func(struct work_struct *work);
75034
75035 extern void fscache_enqueue_operation(struct fscache_operation *);
75036 @@ -135,7 +135,7 @@ static inline void fscache_operation_init(struct fscache_operation *op,
75037 INIT_WORK(&op->work, fscache_op_work_func);
75038 atomic_set(&op->usage, 1);
75039 op->state = FSCACHE_OP_ST_INITIALISED;
75040 - op->debug_id = atomic_inc_return(&fscache_op_debug_id);
75041 + op->debug_id = atomic_inc_return_unchecked(&fscache_op_debug_id);
75042 op->processor = processor;
75043 op->release = release;
75044 INIT_LIST_HEAD(&op->pend_link);
75045 diff --git a/include/linux/fscache.h b/include/linux/fscache.h
75046 index 19b4645..3b73dfc 100644
75047 --- a/include/linux/fscache.h
75048 +++ b/include/linux/fscache.h
75049 @@ -152,7 +152,7 @@ struct fscache_cookie_def {
75050 * - this is mandatory for any object that may have data
75051 */
75052 void (*now_uncached)(void *cookie_netfs_data);
75053 -};
75054 +} __do_const;
75055
75056 /*
75057 * fscache cached network filesystem type
75058 diff --git a/include/linux/fsnotify.h b/include/linux/fsnotify.h
75059 index 1c804b0..1432c2b 100644
75060 --- a/include/linux/fsnotify.h
75061 +++ b/include/linux/fsnotify.h
75062 @@ -195,6 +195,9 @@ static inline void fsnotify_access(struct file *file)
75063 struct inode *inode = file_inode(file);
75064 __u32 mask = FS_ACCESS;
75065
75066 + if (is_sidechannel_device(inode))
75067 + return;
75068 +
75069 if (S_ISDIR(inode->i_mode))
75070 mask |= FS_ISDIR;
75071
75072 @@ -213,6 +216,9 @@ static inline void fsnotify_modify(struct file *file)
75073 struct inode *inode = file_inode(file);
75074 __u32 mask = FS_MODIFY;
75075
75076 + if (is_sidechannel_device(inode))
75077 + return;
75078 +
75079 if (S_ISDIR(inode->i_mode))
75080 mask |= FS_ISDIR;
75081
75082 @@ -315,7 +321,7 @@ static inline void fsnotify_change(struct dentry *dentry, unsigned int ia_valid)
75083 */
75084 static inline const unsigned char *fsnotify_oldname_init(const unsigned char *name)
75085 {
75086 - return kstrdup(name, GFP_KERNEL);
75087 + return (const unsigned char *)kstrdup((const char *)name, GFP_KERNEL);
75088 }
75089
75090 /*
75091 diff --git a/include/linux/genhd.h b/include/linux/genhd.h
75092 index 9f3c275..8bdff5d 100644
75093 --- a/include/linux/genhd.h
75094 +++ b/include/linux/genhd.h
75095 @@ -194,7 +194,7 @@ struct gendisk {
75096 struct kobject *slave_dir;
75097
75098 struct timer_rand_state *random;
75099 - atomic_t sync_io; /* RAID */
75100 + atomic_unchecked_t sync_io; /* RAID */
75101 struct disk_events *ev;
75102 #ifdef CONFIG_BLK_DEV_INTEGRITY
75103 struct blk_integrity *integrity;
75104 @@ -435,7 +435,7 @@ extern void disk_flush_events(struct gendisk *disk, unsigned int mask);
75105 extern unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask);
75106
75107 /* drivers/char/random.c */
75108 -extern void add_disk_randomness(struct gendisk *disk);
75109 +extern void add_disk_randomness(struct gendisk *disk) __latent_entropy;
75110 extern void rand_initialize_disk(struct gendisk *disk);
75111
75112 static inline sector_t get_start_sect(struct block_device *bdev)
75113 diff --git a/include/linux/genl_magic_func.h b/include/linux/genl_magic_func.h
75114 index 023bc34..b02b46a 100644
75115 --- a/include/linux/genl_magic_func.h
75116 +++ b/include/linux/genl_magic_func.h
75117 @@ -246,7 +246,7 @@ const char *CONCAT_(GENL_MAGIC_FAMILY, _genl_cmd_to_str)(__u8 cmd)
75118 },
75119
75120 #define ZZZ_genl_ops CONCAT_(GENL_MAGIC_FAMILY, _genl_ops)
75121 -static struct genl_ops ZZZ_genl_ops[] __read_mostly = {
75122 +static struct genl_ops ZZZ_genl_ops[] = {
75123 #include GENL_MAGIC_INCLUDE_FILE
75124 };
75125
75126 diff --git a/include/linux/gfp.h b/include/linux/gfp.h
75127 index 9b4dd49..61fd41d 100644
75128 --- a/include/linux/gfp.h
75129 +++ b/include/linux/gfp.h
75130 @@ -35,6 +35,13 @@ struct vm_area_struct;
75131 #define ___GFP_NO_KSWAPD 0x400000u
75132 #define ___GFP_OTHER_NODE 0x800000u
75133 #define ___GFP_WRITE 0x1000000u
75134 +
75135 +#ifdef CONFIG_PAX_USERCOPY_SLABS
75136 +#define ___GFP_USERCOPY 0x2000000u
75137 +#else
75138 +#define ___GFP_USERCOPY 0
75139 +#endif
75140 +
75141 /* If the above are modified, __GFP_BITS_SHIFT may need updating */
75142
75143 /*
75144 @@ -92,6 +99,7 @@ struct vm_area_struct;
75145 #define __GFP_OTHER_NODE ((__force gfp_t)___GFP_OTHER_NODE) /* On behalf of other node */
75146 #define __GFP_KMEMCG ((__force gfp_t)___GFP_KMEMCG) /* Allocation comes from a memcg-accounted resource */
75147 #define __GFP_WRITE ((__force gfp_t)___GFP_WRITE) /* Allocator intends to dirty page */
75148 +#define __GFP_USERCOPY ((__force gfp_t)___GFP_USERCOPY)/* Allocator intends to copy page to/from userland */
75149
75150 /*
75151 * This may seem redundant, but it's a way of annotating false positives vs.
75152 @@ -99,7 +107,7 @@ struct vm_area_struct;
75153 */
75154 #define __GFP_NOTRACK_FALSE_POSITIVE (__GFP_NOTRACK)
75155
75156 -#define __GFP_BITS_SHIFT 25 /* Room for N __GFP_FOO bits */
75157 +#define __GFP_BITS_SHIFT 26 /* Room for N __GFP_FOO bits */
75158 #define __GFP_BITS_MASK ((__force gfp_t)((1 << __GFP_BITS_SHIFT) - 1))
75159
75160 /* This equals 0, but use constants in case they ever change */
75161 @@ -153,6 +161,8 @@ struct vm_area_struct;
75162 /* 4GB DMA on some platforms */
75163 #define GFP_DMA32 __GFP_DMA32
75164
75165 +#define GFP_USERCOPY __GFP_USERCOPY
75166 +
75167 /* Convert GFP flags to their corresponding migrate type */
75168 static inline int allocflags_to_migratetype(gfp_t gfp_flags)
75169 {
75170 diff --git a/include/linux/gracl.h b/include/linux/gracl.h
75171 new file mode 100644
75172 index 0000000..edb2cb6
75173 --- /dev/null
75174 +++ b/include/linux/gracl.h
75175 @@ -0,0 +1,340 @@
75176 +#ifndef GR_ACL_H
75177 +#define GR_ACL_H
75178 +
75179 +#include <linux/grdefs.h>
75180 +#include <linux/resource.h>
75181 +#include <linux/capability.h>
75182 +#include <linux/dcache.h>
75183 +#include <asm/resource.h>
75184 +
75185 +/* Major status information */
75186 +
75187 +#define GR_VERSION "grsecurity 3.0"
75188 +#define GRSECURITY_VERSION 0x3000
75189 +
75190 +enum {
75191 + GR_SHUTDOWN = 0,
75192 + GR_ENABLE = 1,
75193 + GR_SPROLE = 2,
75194 + GR_OLDRELOAD = 3,
75195 + GR_SEGVMOD = 4,
75196 + GR_STATUS = 5,
75197 + GR_UNSPROLE = 6,
75198 + GR_PASSSET = 7,
75199 + GR_SPROLEPAM = 8,
75200 + GR_RELOAD = 9,
75201 +};
75202 +
75203 +/* Password setup definitions
75204 + * kernel/grhash.c */
75205 +enum {
75206 + GR_PW_LEN = 128,
75207 + GR_SALT_LEN = 16,
75208 + GR_SHA_LEN = 32,
75209 +};
75210 +
75211 +enum {
75212 + GR_SPROLE_LEN = 64,
75213 +};
75214 +
75215 +enum {
75216 + GR_NO_GLOB = 0,
75217 + GR_REG_GLOB,
75218 + GR_CREATE_GLOB
75219 +};
75220 +
75221 +#define GR_NLIMITS 32
75222 +
75223 +/* Begin Data Structures */
75224 +
75225 +struct sprole_pw {
75226 + unsigned char *rolename;
75227 + unsigned char salt[GR_SALT_LEN];
75228 + unsigned char sum[GR_SHA_LEN]; /* 256-bit SHA hash of the password */
75229 +};
75230 +
75231 +struct name_entry {
75232 + __u32 key;
75233 + ino_t inode;
75234 + dev_t device;
75235 + char *name;
75236 + __u16 len;
75237 + __u8 deleted;
75238 + struct name_entry *prev;
75239 + struct name_entry *next;
75240 +};
75241 +
75242 +struct inodev_entry {
75243 + struct name_entry *nentry;
75244 + struct inodev_entry *prev;
75245 + struct inodev_entry *next;
75246 +};
75247 +
75248 +struct acl_role_db {
75249 + struct acl_role_label **r_hash;
75250 + __u32 r_size;
75251 +};
75252 +
75253 +struct inodev_db {
75254 + struct inodev_entry **i_hash;
75255 + __u32 i_size;
75256 +};
75257 +
75258 +struct name_db {
75259 + struct name_entry **n_hash;
75260 + __u32 n_size;
75261 +};
75262 +
75263 +struct crash_uid {
75264 + uid_t uid;
75265 + unsigned long expires;
75266 +};
75267 +
75268 +struct gr_hash_struct {
75269 + void **table;
75270 + void **nametable;
75271 + void *first;
75272 + __u32 table_size;
75273 + __u32 used_size;
75274 + int type;
75275 +};
75276 +
75277 +/* Userspace Grsecurity ACL data structures */
75278 +
75279 +struct acl_subject_label {
75280 + char *filename;
75281 + ino_t inode;
75282 + dev_t device;
75283 + __u32 mode;
75284 + kernel_cap_t cap_mask;
75285 + kernel_cap_t cap_lower;
75286 + kernel_cap_t cap_invert_audit;
75287 +
75288 + struct rlimit res[GR_NLIMITS];
75289 + __u32 resmask;
75290 +
75291 + __u8 user_trans_type;
75292 + __u8 group_trans_type;
75293 + uid_t *user_transitions;
75294 + gid_t *group_transitions;
75295 + __u16 user_trans_num;
75296 + __u16 group_trans_num;
75297 +
75298 + __u32 sock_families[2];
75299 + __u32 ip_proto[8];
75300 + __u32 ip_type;
75301 + struct acl_ip_label **ips;
75302 + __u32 ip_num;
75303 + __u32 inaddr_any_override;
75304 +
75305 + __u32 crashes;
75306 + unsigned long expires;
75307 +
75308 + struct acl_subject_label *parent_subject;
75309 + struct gr_hash_struct *hash;
75310 + struct acl_subject_label *prev;
75311 + struct acl_subject_label *next;
75312 +
75313 + struct acl_object_label **obj_hash;
75314 + __u32 obj_hash_size;
75315 + __u16 pax_flags;
75316 +};
75317 +
75318 +struct role_allowed_ip {
75319 + __u32 addr;
75320 + __u32 netmask;
75321 +
75322 + struct role_allowed_ip *prev;
75323 + struct role_allowed_ip *next;
75324 +};
75325 +
75326 +struct role_transition {
75327 + char *rolename;
75328 +
75329 + struct role_transition *prev;
75330 + struct role_transition *next;
75331 +};
75332 +
75333 +struct acl_role_label {
75334 + char *rolename;
75335 + uid_t uidgid;
75336 + __u16 roletype;
75337 +
75338 + __u16 auth_attempts;
75339 + unsigned long expires;
75340 +
75341 + struct acl_subject_label *root_label;
75342 + struct gr_hash_struct *hash;
75343 +
75344 + struct acl_role_label *prev;
75345 + struct acl_role_label *next;
75346 +
75347 + struct role_transition *transitions;
75348 + struct role_allowed_ip *allowed_ips;
75349 + uid_t *domain_children;
75350 + __u16 domain_child_num;
75351 +
75352 + umode_t umask;
75353 +
75354 + struct acl_subject_label **subj_hash;
75355 + __u32 subj_hash_size;
75356 +};
75357 +
75358 +struct user_acl_role_db {
75359 + struct acl_role_label **r_table;
75360 + __u32 num_pointers; /* Number of allocations to track */
75361 + __u32 num_roles; /* Number of roles */
75362 + __u32 num_domain_children; /* Number of domain children */
75363 + __u32 num_subjects; /* Number of subjects */
75364 + __u32 num_objects; /* Number of objects */
75365 +};
75366 +
75367 +struct acl_object_label {
75368 + char *filename;
75369 + ino_t inode;
75370 + dev_t device;
75371 + __u32 mode;
75372 +
75373 + struct acl_subject_label *nested;
75374 + struct acl_object_label *globbed;
75375 +
75376 + /* next two structures not used */
75377 +
75378 + struct acl_object_label *prev;
75379 + struct acl_object_label *next;
75380 +};
75381 +
75382 +struct acl_ip_label {
75383 + char *iface;
75384 + __u32 addr;
75385 + __u32 netmask;
75386 + __u16 low, high;
75387 + __u8 mode;
75388 + __u32 type;
75389 + __u32 proto[8];
75390 +
75391 + /* next two structures not used */
75392 +
75393 + struct acl_ip_label *prev;
75394 + struct acl_ip_label *next;
75395 +};
75396 +
75397 +struct gr_arg {
75398 + struct user_acl_role_db role_db;
75399 + unsigned char pw[GR_PW_LEN];
75400 + unsigned char salt[GR_SALT_LEN];
75401 + unsigned char sum[GR_SHA_LEN];
75402 + unsigned char sp_role[GR_SPROLE_LEN];
75403 + struct sprole_pw *sprole_pws;
75404 + dev_t segv_device;
75405 + ino_t segv_inode;
75406 + uid_t segv_uid;
75407 + __u16 num_sprole_pws;
75408 + __u16 mode;
75409 +};
75410 +
75411 +struct gr_arg_wrapper {
75412 + struct gr_arg *arg;
75413 + __u32 version;
75414 + __u32 size;
75415 +};
75416 +
75417 +struct subject_map {
75418 + struct acl_subject_label *user;
75419 + struct acl_subject_label *kernel;
75420 + struct subject_map *prev;
75421 + struct subject_map *next;
75422 +};
75423 +
75424 +struct acl_subj_map_db {
75425 + struct subject_map **s_hash;
75426 + __u32 s_size;
75427 +};
75428 +
75429 +struct gr_policy_state {
75430 + struct sprole_pw **acl_special_roles;
75431 + __u16 num_sprole_pws;
75432 + struct acl_role_label *kernel_role;
75433 + struct acl_role_label *role_list;
75434 + struct acl_role_label *default_role;
75435 + struct acl_role_db acl_role_set;
75436 + struct acl_subj_map_db subj_map_set;
75437 + struct name_db name_set;
75438 + struct inodev_db inodev_set;
75439 +};
75440 +
75441 +struct gr_alloc_state {
75442 + unsigned long alloc_stack_next;
75443 + unsigned long alloc_stack_size;
75444 + void **alloc_stack;
75445 +};
75446 +
75447 +struct gr_reload_state {
75448 + struct gr_policy_state oldpolicy;
75449 + struct gr_alloc_state oldalloc;
75450 + struct gr_policy_state newpolicy;
75451 + struct gr_alloc_state newalloc;
75452 + struct gr_policy_state *oldpolicy_ptr;
75453 + struct gr_alloc_state *oldalloc_ptr;
75454 + unsigned char oldmode;
75455 +};
75456 +
75457 +/* End Data Structures Section */
75458 +
75459 +/* Hash functions generated by empirical testing by Brad Spengler
75460 + Makes good use of the low bits of the inode. Generally 0-1 times
75461 + in loop for successful match. 0-3 for unsuccessful match.
75462 + Shift/add algorithm with modulus of table size and an XOR*/
75463 +
75464 +static __inline__ unsigned int
75465 +gr_rhash(const uid_t uid, const __u16 type, const unsigned int sz)
75466 +{
75467 + return ((((uid + type) << (16 + type)) ^ uid) % sz);
75468 +}
75469 +
75470 + static __inline__ unsigned int
75471 +gr_shash(const struct acl_subject_label *userp, const unsigned int sz)
75472 +{
75473 + return ((const unsigned long)userp % sz);
75474 +}
75475 +
75476 +static __inline__ unsigned int
75477 +gr_fhash(const ino_t ino, const dev_t dev, const unsigned int sz)
75478 +{
75479 + return (((ino + dev) ^ ((ino << 13) + (ino << 23) + (dev << 9))) % sz);
75480 +}
75481 +
75482 +static __inline__ unsigned int
75483 +gr_nhash(const char *name, const __u16 len, const unsigned int sz)
75484 +{
75485 + return full_name_hash((const unsigned char *)name, len) % sz;
75486 +}
75487 +
75488 +#define FOR_EACH_SUBJECT_START(role,subj,iter) \
75489 + subj = NULL; \
75490 + iter = 0; \
75491 + while (iter < role->subj_hash_size) { \
75492 + if (subj == NULL) \
75493 + subj = role->subj_hash[iter]; \
75494 + if (subj == NULL) { \
75495 + iter++; \
75496 + continue; \
75497 + }
75498 +
75499 +#define FOR_EACH_SUBJECT_END(subj,iter) \
75500 + subj = subj->next; \
75501 + if (subj == NULL) \
75502 + iter++; \
75503 + }
75504 +
75505 +
75506 +#define FOR_EACH_NESTED_SUBJECT_START(role,subj) \
75507 + subj = role->hash->first; \
75508 + while (subj != NULL) {
75509 +
75510 +#define FOR_EACH_NESTED_SUBJECT_END(subj) \
75511 + subj = subj->next; \
75512 + }
75513 +
75514 +#endif
75515 +
75516 diff --git a/include/linux/gracl_compat.h b/include/linux/gracl_compat.h
75517 new file mode 100644
75518 index 0000000..33ebd1f
75519 --- /dev/null
75520 +++ b/include/linux/gracl_compat.h
75521 @@ -0,0 +1,156 @@
75522 +#ifndef GR_ACL_COMPAT_H
75523 +#define GR_ACL_COMPAT_H
75524 +
75525 +#include <linux/resource.h>
75526 +#include <asm/resource.h>
75527 +
75528 +struct sprole_pw_compat {
75529 + compat_uptr_t rolename;
75530 + unsigned char salt[GR_SALT_LEN];
75531 + unsigned char sum[GR_SHA_LEN];
75532 +};
75533 +
75534 +struct gr_hash_struct_compat {
75535 + compat_uptr_t table;
75536 + compat_uptr_t nametable;
75537 + compat_uptr_t first;
75538 + __u32 table_size;
75539 + __u32 used_size;
75540 + int type;
75541 +};
75542 +
75543 +struct acl_subject_label_compat {
75544 + compat_uptr_t filename;
75545 + compat_ino_t inode;
75546 + __u32 device;
75547 + __u32 mode;
75548 + kernel_cap_t cap_mask;
75549 + kernel_cap_t cap_lower;
75550 + kernel_cap_t cap_invert_audit;
75551 +
75552 + struct compat_rlimit res[GR_NLIMITS];
75553 + __u32 resmask;
75554 +
75555 + __u8 user_trans_type;
75556 + __u8 group_trans_type;
75557 + compat_uptr_t user_transitions;
75558 + compat_uptr_t group_transitions;
75559 + __u16 user_trans_num;
75560 + __u16 group_trans_num;
75561 +
75562 + __u32 sock_families[2];
75563 + __u32 ip_proto[8];
75564 + __u32 ip_type;
75565 + compat_uptr_t ips;
75566 + __u32 ip_num;
75567 + __u32 inaddr_any_override;
75568 +
75569 + __u32 crashes;
75570 + compat_ulong_t expires;
75571 +
75572 + compat_uptr_t parent_subject;
75573 + compat_uptr_t hash;
75574 + compat_uptr_t prev;
75575 + compat_uptr_t next;
75576 +
75577 + compat_uptr_t obj_hash;
75578 + __u32 obj_hash_size;
75579 + __u16 pax_flags;
75580 +};
75581 +
75582 +struct role_allowed_ip_compat {
75583 + __u32 addr;
75584 + __u32 netmask;
75585 +
75586 + compat_uptr_t prev;
75587 + compat_uptr_t next;
75588 +};
75589 +
75590 +struct role_transition_compat {
75591 + compat_uptr_t rolename;
75592 +
75593 + compat_uptr_t prev;
75594 + compat_uptr_t next;
75595 +};
75596 +
75597 +struct acl_role_label_compat {
75598 + compat_uptr_t rolename;
75599 + uid_t uidgid;
75600 + __u16 roletype;
75601 +
75602 + __u16 auth_attempts;
75603 + compat_ulong_t expires;
75604 +
75605 + compat_uptr_t root_label;
75606 + compat_uptr_t hash;
75607 +
75608 + compat_uptr_t prev;
75609 + compat_uptr_t next;
75610 +
75611 + compat_uptr_t transitions;
75612 + compat_uptr_t allowed_ips;
75613 + compat_uptr_t domain_children;
75614 + __u16 domain_child_num;
75615 +
75616 + umode_t umask;
75617 +
75618 + compat_uptr_t subj_hash;
75619 + __u32 subj_hash_size;
75620 +};
75621 +
75622 +struct user_acl_role_db_compat {
75623 + compat_uptr_t r_table;
75624 + __u32 num_pointers;
75625 + __u32 num_roles;
75626 + __u32 num_domain_children;
75627 + __u32 num_subjects;
75628 + __u32 num_objects;
75629 +};
75630 +
75631 +struct acl_object_label_compat {
75632 + compat_uptr_t filename;
75633 + compat_ino_t inode;
75634 + __u32 device;
75635 + __u32 mode;
75636 +
75637 + compat_uptr_t nested;
75638 + compat_uptr_t globbed;
75639 +
75640 + compat_uptr_t prev;
75641 + compat_uptr_t next;
75642 +};
75643 +
75644 +struct acl_ip_label_compat {
75645 + compat_uptr_t iface;
75646 + __u32 addr;
75647 + __u32 netmask;
75648 + __u16 low, high;
75649 + __u8 mode;
75650 + __u32 type;
75651 + __u32 proto[8];
75652 +
75653 + compat_uptr_t prev;
75654 + compat_uptr_t next;
75655 +};
75656 +
75657 +struct gr_arg_compat {
75658 + struct user_acl_role_db_compat role_db;
75659 + unsigned char pw[GR_PW_LEN];
75660 + unsigned char salt[GR_SALT_LEN];
75661 + unsigned char sum[GR_SHA_LEN];
75662 + unsigned char sp_role[GR_SPROLE_LEN];
75663 + compat_uptr_t sprole_pws;
75664 + __u32 segv_device;
75665 + compat_ino_t segv_inode;
75666 + uid_t segv_uid;
75667 + __u16 num_sprole_pws;
75668 + __u16 mode;
75669 +};
75670 +
75671 +struct gr_arg_wrapper_compat {
75672 + compat_uptr_t arg;
75673 + __u32 version;
75674 + __u32 size;
75675 +};
75676 +
75677 +#endif
75678 diff --git a/include/linux/gralloc.h b/include/linux/gralloc.h
75679 new file mode 100644
75680 index 0000000..323ecf2
75681 --- /dev/null
75682 +++ b/include/linux/gralloc.h
75683 @@ -0,0 +1,9 @@
75684 +#ifndef __GRALLOC_H
75685 +#define __GRALLOC_H
75686 +
75687 +void acl_free_all(void);
75688 +int acl_alloc_stack_init(unsigned long size);
75689 +void *acl_alloc(unsigned long len);
75690 +void *acl_alloc_num(unsigned long num, unsigned long len);
75691 +
75692 +#endif
75693 diff --git a/include/linux/grdefs.h b/include/linux/grdefs.h
75694 new file mode 100644
75695 index 0000000..be66033
75696 --- /dev/null
75697 +++ b/include/linux/grdefs.h
75698 @@ -0,0 +1,140 @@
75699 +#ifndef GRDEFS_H
75700 +#define GRDEFS_H
75701 +
75702 +/* Begin grsecurity status declarations */
75703 +
75704 +enum {
75705 + GR_READY = 0x01,
75706 + GR_STATUS_INIT = 0x00 // disabled state
75707 +};
75708 +
75709 +/* Begin ACL declarations */
75710 +
75711 +/* Role flags */
75712 +
75713 +enum {
75714 + GR_ROLE_USER = 0x0001,
75715 + GR_ROLE_GROUP = 0x0002,
75716 + GR_ROLE_DEFAULT = 0x0004,
75717 + GR_ROLE_SPECIAL = 0x0008,
75718 + GR_ROLE_AUTH = 0x0010,
75719 + GR_ROLE_NOPW = 0x0020,
75720 + GR_ROLE_GOD = 0x0040,
75721 + GR_ROLE_LEARN = 0x0080,
75722 + GR_ROLE_TPE = 0x0100,
75723 + GR_ROLE_DOMAIN = 0x0200,
75724 + GR_ROLE_PAM = 0x0400,
75725 + GR_ROLE_PERSIST = 0x0800
75726 +};
75727 +
75728 +/* ACL Subject and Object mode flags */
75729 +enum {
75730 + GR_DELETED = 0x80000000
75731 +};
75732 +
75733 +/* ACL Object-only mode flags */
75734 +enum {
75735 + GR_READ = 0x00000001,
75736 + GR_APPEND = 0x00000002,
75737 + GR_WRITE = 0x00000004,
75738 + GR_EXEC = 0x00000008,
75739 + GR_FIND = 0x00000010,
75740 + GR_INHERIT = 0x00000020,
75741 + GR_SETID = 0x00000040,
75742 + GR_CREATE = 0x00000080,
75743 + GR_DELETE = 0x00000100,
75744 + GR_LINK = 0x00000200,
75745 + GR_AUDIT_READ = 0x00000400,
75746 + GR_AUDIT_APPEND = 0x00000800,
75747 + GR_AUDIT_WRITE = 0x00001000,
75748 + GR_AUDIT_EXEC = 0x00002000,
75749 + GR_AUDIT_FIND = 0x00004000,
75750 + GR_AUDIT_INHERIT= 0x00008000,
75751 + GR_AUDIT_SETID = 0x00010000,
75752 + GR_AUDIT_CREATE = 0x00020000,
75753 + GR_AUDIT_DELETE = 0x00040000,
75754 + GR_AUDIT_LINK = 0x00080000,
75755 + GR_PTRACERD = 0x00100000,
75756 + GR_NOPTRACE = 0x00200000,
75757 + GR_SUPPRESS = 0x00400000,
75758 + GR_NOLEARN = 0x00800000,
75759 + GR_INIT_TRANSFER= 0x01000000
75760 +};
75761 +
75762 +#define GR_AUDITS (GR_AUDIT_READ | GR_AUDIT_WRITE | GR_AUDIT_APPEND | GR_AUDIT_EXEC | \
75763 + GR_AUDIT_FIND | GR_AUDIT_INHERIT | GR_AUDIT_SETID | \
75764 + GR_AUDIT_CREATE | GR_AUDIT_DELETE | GR_AUDIT_LINK)
75765 +
75766 +/* ACL subject-only mode flags */
75767 +enum {
75768 + GR_KILL = 0x00000001,
75769 + GR_VIEW = 0x00000002,
75770 + GR_PROTECTED = 0x00000004,
75771 + GR_LEARN = 0x00000008,
75772 + GR_OVERRIDE = 0x00000010,
75773 + /* just a placeholder, this mode is only used in userspace */
75774 + GR_DUMMY = 0x00000020,
75775 + GR_PROTSHM = 0x00000040,
75776 + GR_KILLPROC = 0x00000080,
75777 + GR_KILLIPPROC = 0x00000100,
75778 + /* just a placeholder, this mode is only used in userspace */
75779 + GR_NOTROJAN = 0x00000200,
75780 + GR_PROTPROCFD = 0x00000400,
75781 + GR_PROCACCT = 0x00000800,
75782 + GR_RELAXPTRACE = 0x00001000,
75783 + //GR_NESTED = 0x00002000,
75784 + GR_INHERITLEARN = 0x00004000,
75785 + GR_PROCFIND = 0x00008000,
75786 + GR_POVERRIDE = 0x00010000,
75787 + GR_KERNELAUTH = 0x00020000,
75788 + GR_ATSECURE = 0x00040000,
75789 + GR_SHMEXEC = 0x00080000
75790 +};
75791 +
75792 +enum {
75793 + GR_PAX_ENABLE_SEGMEXEC = 0x0001,
75794 + GR_PAX_ENABLE_PAGEEXEC = 0x0002,
75795 + GR_PAX_ENABLE_MPROTECT = 0x0004,
75796 + GR_PAX_ENABLE_RANDMMAP = 0x0008,
75797 + GR_PAX_ENABLE_EMUTRAMP = 0x0010,
75798 + GR_PAX_DISABLE_SEGMEXEC = 0x0100,
75799 + GR_PAX_DISABLE_PAGEEXEC = 0x0200,
75800 + GR_PAX_DISABLE_MPROTECT = 0x0400,
75801 + GR_PAX_DISABLE_RANDMMAP = 0x0800,
75802 + GR_PAX_DISABLE_EMUTRAMP = 0x1000,
75803 +};
75804 +
75805 +enum {
75806 + GR_ID_USER = 0x01,
75807 + GR_ID_GROUP = 0x02,
75808 +};
75809 +
75810 +enum {
75811 + GR_ID_ALLOW = 0x01,
75812 + GR_ID_DENY = 0x02,
75813 +};
75814 +
75815 +#define GR_CRASH_RES 31
75816 +#define GR_UIDTABLE_MAX 500
75817 +
75818 +/* begin resource learning section */
75819 +enum {
75820 + GR_RLIM_CPU_BUMP = 60,
75821 + GR_RLIM_FSIZE_BUMP = 50000,
75822 + GR_RLIM_DATA_BUMP = 10000,
75823 + GR_RLIM_STACK_BUMP = 1000,
75824 + GR_RLIM_CORE_BUMP = 10000,
75825 + GR_RLIM_RSS_BUMP = 500000,
75826 + GR_RLIM_NPROC_BUMP = 1,
75827 + GR_RLIM_NOFILE_BUMP = 5,
75828 + GR_RLIM_MEMLOCK_BUMP = 50000,
75829 + GR_RLIM_AS_BUMP = 500000,
75830 + GR_RLIM_LOCKS_BUMP = 2,
75831 + GR_RLIM_SIGPENDING_BUMP = 5,
75832 + GR_RLIM_MSGQUEUE_BUMP = 10000,
75833 + GR_RLIM_NICE_BUMP = 1,
75834 + GR_RLIM_RTPRIO_BUMP = 1,
75835 + GR_RLIM_RTTIME_BUMP = 1000000
75836 +};
75837 +
75838 +#endif
75839 diff --git a/include/linux/grinternal.h b/include/linux/grinternal.h
75840 new file mode 100644
75841 index 0000000..d25522e
75842 --- /dev/null
75843 +++ b/include/linux/grinternal.h
75844 @@ -0,0 +1,229 @@
75845 +#ifndef __GRINTERNAL_H
75846 +#define __GRINTERNAL_H
75847 +
75848 +#ifdef CONFIG_GRKERNSEC
75849 +
75850 +#include <linux/fs.h>
75851 +#include <linux/mnt_namespace.h>
75852 +#include <linux/nsproxy.h>
75853 +#include <linux/gracl.h>
75854 +#include <linux/grdefs.h>
75855 +#include <linux/grmsg.h>
75856 +
75857 +void gr_add_learn_entry(const char *fmt, ...)
75858 + __attribute__ ((format (printf, 1, 2)));
75859 +__u32 gr_search_file(const struct dentry *dentry, const __u32 mode,
75860 + const struct vfsmount *mnt);
75861 +__u32 gr_check_create(const struct dentry *new_dentry,
75862 + const struct dentry *parent,
75863 + const struct vfsmount *mnt, const __u32 mode);
75864 +int gr_check_protected_task(const struct task_struct *task);
75865 +__u32 to_gr_audit(const __u32 reqmode);
75866 +int gr_set_acls(const int type);
75867 +int gr_acl_is_enabled(void);
75868 +char gr_roletype_to_char(void);
75869 +
75870 +void gr_handle_alertkill(struct task_struct *task);
75871 +char *gr_to_filename(const struct dentry *dentry,
75872 + const struct vfsmount *mnt);
75873 +char *gr_to_filename1(const struct dentry *dentry,
75874 + const struct vfsmount *mnt);
75875 +char *gr_to_filename2(const struct dentry *dentry,
75876 + const struct vfsmount *mnt);
75877 +char *gr_to_filename3(const struct dentry *dentry,
75878 + const struct vfsmount *mnt);
75879 +
75880 +extern int grsec_enable_ptrace_readexec;
75881 +extern int grsec_enable_harden_ptrace;
75882 +extern int grsec_enable_link;
75883 +extern int grsec_enable_fifo;
75884 +extern int grsec_enable_execve;
75885 +extern int grsec_enable_shm;
75886 +extern int grsec_enable_execlog;
75887 +extern int grsec_enable_signal;
75888 +extern int grsec_enable_audit_ptrace;
75889 +extern int grsec_enable_forkfail;
75890 +extern int grsec_enable_time;
75891 +extern int grsec_enable_rofs;
75892 +extern int grsec_deny_new_usb;
75893 +extern int grsec_enable_chroot_shmat;
75894 +extern int grsec_enable_chroot_mount;
75895 +extern int grsec_enable_chroot_double;
75896 +extern int grsec_enable_chroot_pivot;
75897 +extern int grsec_enable_chroot_chdir;
75898 +extern int grsec_enable_chroot_chmod;
75899 +extern int grsec_enable_chroot_mknod;
75900 +extern int grsec_enable_chroot_fchdir;
75901 +extern int grsec_enable_chroot_nice;
75902 +extern int grsec_enable_chroot_execlog;
75903 +extern int grsec_enable_chroot_caps;
75904 +extern int grsec_enable_chroot_sysctl;
75905 +extern int grsec_enable_chroot_unix;
75906 +extern int grsec_enable_symlinkown;
75907 +extern kgid_t grsec_symlinkown_gid;
75908 +extern int grsec_enable_tpe;
75909 +extern kgid_t grsec_tpe_gid;
75910 +extern int grsec_enable_tpe_all;
75911 +extern int grsec_enable_tpe_invert;
75912 +extern int grsec_enable_socket_all;
75913 +extern kgid_t grsec_socket_all_gid;
75914 +extern int grsec_enable_socket_client;
75915 +extern kgid_t grsec_socket_client_gid;
75916 +extern int grsec_enable_socket_server;
75917 +extern kgid_t grsec_socket_server_gid;
75918 +extern kgid_t grsec_audit_gid;
75919 +extern int grsec_enable_group;
75920 +extern int grsec_enable_log_rwxmaps;
75921 +extern int grsec_enable_mount;
75922 +extern int grsec_enable_chdir;
75923 +extern int grsec_resource_logging;
75924 +extern int grsec_enable_blackhole;
75925 +extern int grsec_lastack_retries;
75926 +extern int grsec_enable_brute;
75927 +extern int grsec_enable_harden_ipc;
75928 +extern int grsec_lock;
75929 +
75930 +extern spinlock_t grsec_alert_lock;
75931 +extern unsigned long grsec_alert_wtime;
75932 +extern unsigned long grsec_alert_fyet;
75933 +
75934 +extern spinlock_t grsec_audit_lock;
75935 +
75936 +extern rwlock_t grsec_exec_file_lock;
75937 +
75938 +#define gr_task_fullpath(tsk) ((tsk)->exec_file ? \
75939 + gr_to_filename2((tsk)->exec_file->f_path.dentry, \
75940 + (tsk)->exec_file->f_path.mnt) : "/")
75941 +
75942 +#define gr_parent_task_fullpath(tsk) ((tsk)->real_parent->exec_file ? \
75943 + gr_to_filename3((tsk)->real_parent->exec_file->f_path.dentry, \
75944 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75945 +
75946 +#define gr_task_fullpath0(tsk) ((tsk)->exec_file ? \
75947 + gr_to_filename((tsk)->exec_file->f_path.dentry, \
75948 + (tsk)->exec_file->f_path.mnt) : "/")
75949 +
75950 +#define gr_parent_task_fullpath0(tsk) ((tsk)->real_parent->exec_file ? \
75951 + gr_to_filename1((tsk)->real_parent->exec_file->f_path.dentry, \
75952 + (tsk)->real_parent->exec_file->f_path.mnt) : "/")
75953 +
75954 +#define proc_is_chrooted(tsk_a) ((tsk_a)->gr_is_chrooted)
75955 +
75956 +#define have_same_root(tsk_a,tsk_b) ((tsk_a)->gr_chroot_dentry == (tsk_b)->gr_chroot_dentry)
75957 +
75958 +static inline bool gr_is_same_file(const struct file *file1, const struct file *file2)
75959 +{
75960 + if (file1 && file2) {
75961 + const struct inode *inode1 = file1->f_path.dentry->d_inode;
75962 + const struct inode *inode2 = file2->f_path.dentry->d_inode;
75963 + if (inode1->i_ino == inode2->i_ino && inode1->i_sb->s_dev == inode2->i_sb->s_dev)
75964 + return true;
75965 + }
75966 +
75967 + return false;
75968 +}
75969 +
75970 +#define GR_CHROOT_CAPS {{ \
75971 + CAP_TO_MASK(CAP_LINUX_IMMUTABLE) | CAP_TO_MASK(CAP_NET_ADMIN) | \
75972 + CAP_TO_MASK(CAP_SYS_MODULE) | CAP_TO_MASK(CAP_SYS_RAWIO) | \
75973 + CAP_TO_MASK(CAP_SYS_PACCT) | CAP_TO_MASK(CAP_SYS_ADMIN) | \
75974 + CAP_TO_MASK(CAP_SYS_BOOT) | CAP_TO_MASK(CAP_SYS_TIME) | \
75975 + CAP_TO_MASK(CAP_NET_RAW) | CAP_TO_MASK(CAP_SYS_TTY_CONFIG) | \
75976 + CAP_TO_MASK(CAP_IPC_OWNER) | CAP_TO_MASK(CAP_SETFCAP), \
75977 + CAP_TO_MASK(CAP_SYSLOG) | CAP_TO_MASK(CAP_MAC_ADMIN) }}
75978 +
75979 +#define security_learn(normal_msg,args...) \
75980 +({ \
75981 + read_lock(&grsec_exec_file_lock); \
75982 + gr_add_learn_entry(normal_msg "\n", ## args); \
75983 + read_unlock(&grsec_exec_file_lock); \
75984 +})
75985 +
75986 +enum {
75987 + GR_DO_AUDIT,
75988 + GR_DONT_AUDIT,
75989 + /* used for non-audit messages that we shouldn't kill the task on */
75990 + GR_DONT_AUDIT_GOOD
75991 +};
75992 +
75993 +enum {
75994 + GR_TTYSNIFF,
75995 + GR_RBAC,
75996 + GR_RBAC_STR,
75997 + GR_STR_RBAC,
75998 + GR_RBAC_MODE2,
75999 + GR_RBAC_MODE3,
76000 + GR_FILENAME,
76001 + GR_SYSCTL_HIDDEN,
76002 + GR_NOARGS,
76003 + GR_ONE_INT,
76004 + GR_ONE_INT_TWO_STR,
76005 + GR_ONE_STR,
76006 + GR_STR_INT,
76007 + GR_TWO_STR_INT,
76008 + GR_TWO_INT,
76009 + GR_TWO_U64,
76010 + GR_THREE_INT,
76011 + GR_FIVE_INT_TWO_STR,
76012 + GR_TWO_STR,
76013 + GR_THREE_STR,
76014 + GR_FOUR_STR,
76015 + GR_STR_FILENAME,
76016 + GR_FILENAME_STR,
76017 + GR_FILENAME_TWO_INT,
76018 + GR_FILENAME_TWO_INT_STR,
76019 + GR_TEXTREL,
76020 + GR_PTRACE,
76021 + GR_RESOURCE,
76022 + GR_CAP,
76023 + GR_SIG,
76024 + GR_SIG2,
76025 + GR_CRASH1,
76026 + GR_CRASH2,
76027 + GR_PSACCT,
76028 + GR_RWXMAP,
76029 + GR_RWXMAPVMA
76030 +};
76031 +
76032 +#define gr_log_hidden_sysctl(audit, msg, str) gr_log_varargs(audit, msg, GR_SYSCTL_HIDDEN, str)
76033 +#define gr_log_ttysniff(audit, msg, task) gr_log_varargs(audit, msg, GR_TTYSNIFF, task)
76034 +#define gr_log_fs_rbac_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_RBAC, dentry, mnt)
76035 +#define gr_log_fs_rbac_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_RBAC_STR, dentry, mnt, str)
76036 +#define gr_log_fs_str_rbac(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_RBAC, str, dentry, mnt)
76037 +#define gr_log_fs_rbac_mode2(audit, msg, dentry, mnt, str1, str2) gr_log_varargs(audit, msg, GR_RBAC_MODE2, dentry, mnt, str1, str2)
76038 +#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)
76039 +#define gr_log_fs_generic(audit, msg, dentry, mnt) gr_log_varargs(audit, msg, GR_FILENAME, dentry, mnt)
76040 +#define gr_log_noargs(audit, msg) gr_log_varargs(audit, msg, GR_NOARGS)
76041 +#define gr_log_int(audit, msg, num) gr_log_varargs(audit, msg, GR_ONE_INT, num)
76042 +#define gr_log_int_str2(audit, msg, num, str1, str2) gr_log_varargs(audit, msg, GR_ONE_INT_TWO_STR, num, str1, str2)
76043 +#define gr_log_str(audit, msg, str) gr_log_varargs(audit, msg, GR_ONE_STR, str)
76044 +#define gr_log_str_int(audit, msg, str, num) gr_log_varargs(audit, msg, GR_STR_INT, str, num)
76045 +#define gr_log_int_int(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_INT, num1, num2)
76046 +#define gr_log_two_u64(audit, msg, num1, num2) gr_log_varargs(audit, msg, GR_TWO_U64, num1, num2)
76047 +#define gr_log_int3(audit, msg, num1, num2, num3) gr_log_varargs(audit, msg, GR_THREE_INT, num1, num2, num3)
76048 +#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)
76049 +#define gr_log_str_str(audit, msg, str1, str2) gr_log_varargs(audit, msg, GR_TWO_STR, str1, str2)
76050 +#define gr_log_str2_int(audit, msg, str1, str2, num) gr_log_varargs(audit, msg, GR_TWO_STR_INT, str1, str2, num)
76051 +#define gr_log_str3(audit, msg, str1, str2, str3) gr_log_varargs(audit, msg, GR_THREE_STR, str1, str2, str3)
76052 +#define gr_log_str4(audit, msg, str1, str2, str3, str4) gr_log_varargs(audit, msg, GR_FOUR_STR, str1, str2, str3, str4)
76053 +#define gr_log_str_fs(audit, msg, str, dentry, mnt) gr_log_varargs(audit, msg, GR_STR_FILENAME, str, dentry, mnt)
76054 +#define gr_log_fs_str(audit, msg, dentry, mnt, str) gr_log_varargs(audit, msg, GR_FILENAME_STR, dentry, mnt, str)
76055 +#define gr_log_fs_int2(audit, msg, dentry, mnt, num1, num2) gr_log_varargs(audit, msg, GR_FILENAME_TWO_INT, dentry, mnt, num1, num2)
76056 +#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)
76057 +#define gr_log_textrel_ulong_ulong(audit, msg, file, ulong1, ulong2) gr_log_varargs(audit, msg, GR_TEXTREL, file, ulong1, ulong2)
76058 +#define gr_log_ptrace(audit, msg, task) gr_log_varargs(audit, msg, GR_PTRACE, task)
76059 +#define gr_log_res_ulong2_str(audit, msg, task, ulong1, str, ulong2) gr_log_varargs(audit, msg, GR_RESOURCE, task, ulong1, str, ulong2)
76060 +#define gr_log_cap(audit, msg, task, str) gr_log_varargs(audit, msg, GR_CAP, task, str)
76061 +#define gr_log_sig_addr(audit, msg, str, addr) gr_log_varargs(audit, msg, GR_SIG, str, addr)
76062 +#define gr_log_sig_task(audit, msg, task, num) gr_log_varargs(audit, msg, GR_SIG2, task, num)
76063 +#define gr_log_crash1(audit, msg, task, ulong) gr_log_varargs(audit, msg, GR_CRASH1, task, ulong)
76064 +#define gr_log_crash2(audit, msg, task, ulong1) gr_log_varargs(audit, msg, GR_CRASH2, task, ulong1)
76065 +#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)
76066 +#define gr_log_rwxmap(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAP, str)
76067 +#define gr_log_rwxmap_vma(audit, msg, str) gr_log_varargs(audit, msg, GR_RWXMAPVMA, str)
76068 +
76069 +void gr_log_varargs(int audit, const char *msg, int argtypes, ...);
76070 +
76071 +#endif
76072 +
76073 +#endif
76074 diff --git a/include/linux/grmsg.h b/include/linux/grmsg.h
76075 new file mode 100644
76076 index 0000000..195cbe4
76077 --- /dev/null
76078 +++ b/include/linux/grmsg.h
76079 @@ -0,0 +1,115 @@
76080 +#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"
76081 +#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"
76082 +#define GR_PTRACE_ACL_MSG "denied ptrace of %.950s(%.16s:%d) by "
76083 +#define GR_STOPMOD_MSG "denied modification of module state by "
76084 +#define GR_ROFS_BLOCKWRITE_MSG "denied write to block device %.950s by "
76085 +#define GR_ROFS_MOUNT_MSG "denied writable mount of %.950s by "
76086 +#define GR_IOPERM_MSG "denied use of ioperm() by "
76087 +#define GR_IOPL_MSG "denied use of iopl() by "
76088 +#define GR_SHMAT_ACL_MSG "denied attach of shared memory of UID %u, PID %d, ID %u by "
76089 +#define GR_UNIX_CHROOT_MSG "denied connect() to abstract AF_UNIX socket outside of chroot by "
76090 +#define GR_SHMAT_CHROOT_MSG "denied attach of shared memory outside of chroot by "
76091 +#define GR_MEM_READWRITE_MSG "denied access of range %Lx -> %Lx in /dev/mem by "
76092 +#define GR_SYMLINK_MSG "not following symlink %.950s owned by %d.%d by "
76093 +#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"
76094 +#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"
76095 +#define GR_HIDDEN_ACL_MSG "%s access to hidden file %.950s by "
76096 +#define GR_OPEN_ACL_MSG "%s open of %.950s for%s%s by "
76097 +#define GR_CREATE_ACL_MSG "%s create of %.950s for%s%s by "
76098 +#define GR_FIFO_MSG "denied writing FIFO %.950s of %d.%d by "
76099 +#define GR_MKNOD_CHROOT_MSG "denied mknod of %.950s from chroot by "
76100 +#define GR_MKNOD_ACL_MSG "%s mknod of %.950s by "
76101 +#define GR_UNIXCONNECT_ACL_MSG "%s connect() to the unix domain socket %.950s by "
76102 +#define GR_TTYSNIFF_ACL_MSG "terminal being sniffed by IP:%pI4 %.480s[%.16s:%d], parent %.480s[%.16s:%d] against "
76103 +#define GR_MKDIR_ACL_MSG "%s mkdir of %.950s by "
76104 +#define GR_RMDIR_ACL_MSG "%s rmdir of %.950s by "
76105 +#define GR_UNLINK_ACL_MSG "%s unlink of %.950s by "
76106 +#define GR_SYMLINK_ACL_MSG "%s symlink from %.480s to %.480s by "
76107 +#define GR_HARDLINK_MSG "denied hardlink of %.930s (owned by %d.%d) to %.30s for "
76108 +#define GR_LINK_ACL_MSG "%s link of %.480s to %.480s by "
76109 +#define GR_INHERIT_ACL_MSG "successful inherit of %.480s's ACL for %.480s by "
76110 +#define GR_RENAME_ACL_MSG "%s rename of %.480s to %.480s by "
76111 +#define GR_UNSAFESHARE_EXEC_ACL_MSG "denied exec with cloned fs of %.950s by "
76112 +#define GR_PTRACE_EXEC_ACL_MSG "denied ptrace of %.950s by "
76113 +#define GR_EXEC_ACL_MSG "%s execution of %.950s by "
76114 +#define GR_EXEC_TPE_MSG "denied untrusted exec (due to %.70s) of %.950s by "
76115 +#define GR_SEGVSTART_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning uid %u from login for %lu seconds"
76116 +#define GR_SEGVNOSUID_ACL_MSG "possible exploit bruteforcing on " DEFAULTSECMSG " banning execution for %lu seconds"
76117 +#define GR_MOUNT_CHROOT_MSG "denied mount of %.256s as %.930s from chroot by "
76118 +#define GR_PIVOT_CHROOT_MSG "denied pivot_root from chroot by "
76119 +#define GR_TRUNCATE_ACL_MSG "%s truncate of %.950s by "
76120 +#define GR_ATIME_ACL_MSG "%s access time change of %.950s by "
76121 +#define GR_ACCESS_ACL_MSG "%s access of %.950s for%s%s%s by "
76122 +#define GR_CHROOT_CHROOT_MSG "denied double chroot to %.950s by "
76123 +#define GR_CHMOD_CHROOT_MSG "denied chmod +s of %.950s by "
76124 +#define GR_CHMOD_ACL_MSG "%s chmod of %.950s by "
76125 +#define GR_CHROOT_FCHDIR_MSG "denied fchdir outside of chroot to %.950s by "
76126 +#define GR_CHOWN_ACL_MSG "%s chown of %.950s by "
76127 +#define GR_SETXATTR_ACL_MSG "%s setting extended attribute of %.950s by "
76128 +#define GR_REMOVEXATTR_ACL_MSG "%s removing extended attribute of %.950s by "
76129 +#define GR_WRITLIB_ACL_MSG "denied load of writable library %.950s by "
76130 +#define GR_INITF_ACL_MSG "init_variables() failed %s by "
76131 +#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"
76132 +#define GR_DEV_ACL_MSG "/dev/grsec: %d bytes sent %d required, being fed garbage by "
76133 +#define GR_SHUTS_ACL_MSG "shutdown auth success for "
76134 +#define GR_SHUTF_ACL_MSG "shutdown auth failure for "
76135 +#define GR_SHUTI_ACL_MSG "ignoring shutdown for disabled RBAC system for "
76136 +#define GR_SEGVMODS_ACL_MSG "segvmod auth success for "
76137 +#define GR_SEGVMODF_ACL_MSG "segvmod auth failure for "
76138 +#define GR_SEGVMODI_ACL_MSG "ignoring segvmod for disabled RBAC system for "
76139 +#define GR_ENABLE_ACL_MSG "%s RBAC system loaded by "
76140 +#define GR_ENABLEF_ACL_MSG "unable to load %s for "
76141 +#define GR_RELOADI_ACL_MSG "ignoring reload request for disabled RBAC system"
76142 +#define GR_RELOAD_ACL_MSG "%s RBAC system reloaded by "
76143 +#define GR_RELOADF_ACL_MSG "failed reload of %s for "
76144 +#define GR_SPROLEI_ACL_MSG "ignoring change to special role for disabled RBAC system for "
76145 +#define GR_SPROLES_ACL_MSG "successful change to special role %s (id %d) by "
76146 +#define GR_SPROLEL_ACL_MSG "special role %s (id %d) exited by "
76147 +#define GR_SPROLEF_ACL_MSG "special role %s failure for "
76148 +#define GR_UNSPROLEI_ACL_MSG "ignoring unauth of special role for disabled RBAC system for "
76149 +#define GR_UNSPROLES_ACL_MSG "successful unauth of special role %s (id %d) by "
76150 +#define GR_INVMODE_ACL_MSG "invalid mode %d by "
76151 +#define GR_PRIORITY_CHROOT_MSG "denied priority change of process (%.16s:%d) by "
76152 +#define GR_FAILFORK_MSG "failed fork with errno %s by "
76153 +#define GR_NICE_CHROOT_MSG "denied priority change by "
76154 +#define GR_UNISIGLOG_MSG "%.32s occurred at %p in "
76155 +#define GR_DUALSIGLOG_MSG "signal %d sent to " DEFAULTSECMSG " by "
76156 +#define GR_SIG_ACL_MSG "denied send of signal %d to protected task " DEFAULTSECMSG " by "
76157 +#define GR_SYSCTL_MSG "denied modification of grsecurity sysctl value : %.32s by "
76158 +#define GR_SYSCTL_ACL_MSG "%s sysctl of %.950s for%s%s by "
76159 +#define GR_TIME_MSG "time set by "
76160 +#define GR_DEFACL_MSG "fatal: unable to find subject for (%.16s:%d), loaded by "
76161 +#define GR_MMAP_ACL_MSG "%s executable mmap of %.950s by "
76162 +#define GR_MPROTECT_ACL_MSG "%s executable mprotect of %.950s by "
76163 +#define GR_SOCK_MSG "denied socket(%.16s,%.16s,%.16s) by "
76164 +#define GR_SOCK_NOINET_MSG "denied socket(%.16s,%.16s,%d) by "
76165 +#define GR_BIND_MSG "denied bind() by "
76166 +#define GR_CONNECT_MSG "denied connect() by "
76167 +#define GR_BIND_ACL_MSG "denied bind() to %pI4 port %u sock type %.16s protocol %.16s by "
76168 +#define GR_CONNECT_ACL_MSG "denied connect() to %pI4 port %u sock type %.16s protocol %.16s by "
76169 +#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"
76170 +#define GR_EXEC_CHROOT_MSG "exec of %.980s within chroot by process "
76171 +#define GR_CAP_ACL_MSG "use of %s denied for "
76172 +#define GR_CAP_CHROOT_MSG "use of %s in chroot denied for "
76173 +#define GR_CAP_ACL_MSG2 "use of %s permitted for "
76174 +#define GR_USRCHANGE_ACL_MSG "change to uid %u denied for "
76175 +#define GR_GRPCHANGE_ACL_MSG "change to gid %u denied for "
76176 +#define GR_REMOUNT_AUDIT_MSG "remount of %.256s by "
76177 +#define GR_UNMOUNT_AUDIT_MSG "unmount of %.256s by "
76178 +#define GR_MOUNT_AUDIT_MSG "mount of %.256s to %.256s by "
76179 +#define GR_CHDIR_AUDIT_MSG "chdir to %.980s by "
76180 +#define GR_EXEC_AUDIT_MSG "exec of %.930s (%.128s) by "
76181 +#define GR_RESOURCE_MSG "denied resource overstep by requesting %lu for %.16s against limit %lu for "
76182 +#define GR_RWXMMAP_MSG "denied RWX mmap of %.950s by "
76183 +#define GR_RWXMPROTECT_MSG "denied RWX mprotect of %.950s by "
76184 +#define GR_TEXTREL_AUDIT_MSG "denied text relocation in %.950s, VMA:0x%08lx 0x%08lx by "
76185 +#define GR_PTGNUSTACK_MSG "denied marking stack executable as requested by PT_GNU_STACK marking in %.950s by "
76186 +#define GR_VM86_MSG "denied use of vm86 by "
76187 +#define GR_PTRACE_AUDIT_MSG "process %.950s(%.16s:%d) attached to via ptrace by "
76188 +#define GR_PTRACE_READEXEC_MSG "denied ptrace of unreadable binary %.950s by "
76189 +#define GR_INIT_TRANSFER_MSG "persistent special role transferred privilege to init by "
76190 +#define GR_BADPROCPID_MSG "denied read of sensitive /proc/pid/%s entry via fd passed across exec by "
76191 +#define GR_SYMLINKOWNER_MSG "denied following symlink %.950s since symlink owner %u does not match target owner %u, by "
76192 +#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 "
76193 +#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 "
76194 +#define GR_IPC_DENIED_MSG "denied %s of overly-permissive IPC object with creator uid %u by "
76195 diff --git a/include/linux/grsecurity.h b/include/linux/grsecurity.h
76196 new file mode 100644
76197 index 0000000..d8b5b48
76198 --- /dev/null
76199 +++ b/include/linux/grsecurity.h
76200 @@ -0,0 +1,245 @@
76201 +#ifndef GR_SECURITY_H
76202 +#define GR_SECURITY_H
76203 +#include <linux/fs.h>
76204 +#include <linux/fs_struct.h>
76205 +#include <linux/binfmts.h>
76206 +#include <linux/gracl.h>
76207 +
76208 +/* notify of brain-dead configs */
76209 +#if defined(CONFIG_GRKERNSEC_PROC_USER) && defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
76210 +#error "CONFIG_GRKERNSEC_PROC_USER and CONFIG_GRKERNSEC_PROC_USERGROUP cannot both be enabled."
76211 +#endif
76212 +#if defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_PAGEEXEC) && !defined(CONFIG_PAX_SEGMEXEC) && !defined(CONFIG_PAX_KERNEXEC)
76213 +#error "CONFIG_PAX_NOEXEC enabled, but PAGEEXEC, SEGMEXEC, and KERNEXEC are disabled."
76214 +#endif
76215 +#if defined(CONFIG_PAX_ASLR) && !defined(CONFIG_PAX_RANDKSTACK) && !defined(CONFIG_PAX_RANDUSTACK) && !defined(CONFIG_PAX_RANDMMAP)
76216 +#error "CONFIG_PAX_ASLR enabled, but RANDKSTACK, RANDUSTACK, and RANDMMAP are disabled."
76217 +#endif
76218 +#if defined(CONFIG_PAX) && !defined(CONFIG_PAX_NOEXEC) && !defined(CONFIG_PAX_ASLR)
76219 +#error "CONFIG_PAX enabled, but no PaX options are enabled."
76220 +#endif
76221 +
76222 +int gr_handle_new_usb(void);
76223 +
76224 +void gr_handle_brute_attach(int dumpable);
76225 +void gr_handle_brute_check(void);
76226 +void gr_handle_kernel_exploit(void);
76227 +
76228 +char gr_roletype_to_char(void);
76229 +
76230 +int gr_acl_enable_at_secure(void);
76231 +
76232 +int gr_check_user_change(kuid_t real, kuid_t effective, kuid_t fs);
76233 +int gr_check_group_change(kgid_t real, kgid_t effective, kgid_t fs);
76234 +
76235 +void gr_del_task_from_ip_table(struct task_struct *p);
76236 +
76237 +int gr_pid_is_chrooted(struct task_struct *p);
76238 +int gr_handle_chroot_fowner(struct pid *pid, enum pid_type type);
76239 +int gr_handle_chroot_nice(void);
76240 +int gr_handle_chroot_sysctl(const int op);
76241 +int gr_handle_chroot_setpriority(struct task_struct *p,
76242 + const int niceval);
76243 +int gr_chroot_fchdir(struct dentry *u_dentry, struct vfsmount *u_mnt);
76244 +int gr_handle_chroot_chroot(const struct dentry *dentry,
76245 + const struct vfsmount *mnt);
76246 +void gr_handle_chroot_chdir(const struct path *path);
76247 +int gr_handle_chroot_chmod(const struct dentry *dentry,
76248 + const struct vfsmount *mnt, const int mode);
76249 +int gr_handle_chroot_mknod(const struct dentry *dentry,
76250 + const struct vfsmount *mnt, const int mode);
76251 +int gr_handle_chroot_mount(const struct dentry *dentry,
76252 + const struct vfsmount *mnt,
76253 + const char *dev_name);
76254 +int gr_handle_chroot_pivot(void);
76255 +int gr_handle_chroot_unix(const pid_t pid);
76256 +
76257 +int gr_handle_rawio(const struct inode *inode);
76258 +
76259 +void gr_handle_ioperm(void);
76260 +void gr_handle_iopl(void);
76261 +
76262 +umode_t gr_acl_umask(void);
76263 +
76264 +int gr_tpe_allow(const struct file *file);
76265 +
76266 +void gr_set_chroot_entries(struct task_struct *task, const struct path *path);
76267 +void gr_clear_chroot_entries(struct task_struct *task);
76268 +
76269 +void gr_log_forkfail(const int retval);
76270 +void gr_log_timechange(void);
76271 +void gr_log_signal(const int sig, const void *addr, const struct task_struct *t);
76272 +void gr_log_chdir(const struct dentry *dentry,
76273 + const struct vfsmount *mnt);
76274 +void gr_log_chroot_exec(const struct dentry *dentry,
76275 + const struct vfsmount *mnt);
76276 +void gr_log_remount(const char *devname, const int retval);
76277 +void gr_log_unmount(const char *devname, const int retval);
76278 +void gr_log_mount(const char *from, const char *to, const int retval);
76279 +void gr_log_textrel(struct vm_area_struct *vma);
76280 +void gr_log_ptgnustack(struct file *file);
76281 +void gr_log_rwxmmap(struct file *file);
76282 +void gr_log_rwxmprotect(struct vm_area_struct *vma);
76283 +
76284 +int gr_handle_follow_link(const struct inode *parent,
76285 + const struct inode *inode,
76286 + const struct dentry *dentry,
76287 + const struct vfsmount *mnt);
76288 +int gr_handle_fifo(const struct dentry *dentry,
76289 + const struct vfsmount *mnt,
76290 + const struct dentry *dir, const int flag,
76291 + const int acc_mode);
76292 +int gr_handle_hardlink(const struct dentry *dentry,
76293 + const struct vfsmount *mnt,
76294 + struct inode *inode,
76295 + const int mode, const struct filename *to);
76296 +
76297 +int gr_is_capable(const int cap);
76298 +int gr_is_capable_nolog(const int cap);
76299 +int gr_task_is_capable(const struct task_struct *task, const struct cred *cred, const int cap);
76300 +int gr_task_is_capable_nolog(const struct task_struct *task, const int cap);
76301 +
76302 +void gr_copy_label(struct task_struct *tsk);
76303 +void gr_handle_crash(struct task_struct *task, const int sig);
76304 +int gr_handle_signal(const struct task_struct *p, const int sig);
76305 +int gr_check_crash_uid(const kuid_t uid);
76306 +int gr_check_protected_task(const struct task_struct *task);
76307 +int gr_check_protected_task_fowner(struct pid *pid, enum pid_type type);
76308 +int gr_acl_handle_mmap(const struct file *file,
76309 + const unsigned long prot);
76310 +int gr_acl_handle_mprotect(const struct file *file,
76311 + const unsigned long prot);
76312 +int gr_check_hidden_task(const struct task_struct *tsk);
76313 +__u32 gr_acl_handle_truncate(const struct dentry *dentry,
76314 + const struct vfsmount *mnt);
76315 +__u32 gr_acl_handle_utime(const struct dentry *dentry,
76316 + const struct vfsmount *mnt);
76317 +__u32 gr_acl_handle_access(const struct dentry *dentry,
76318 + const struct vfsmount *mnt, const int fmode);
76319 +__u32 gr_acl_handle_chmod(const struct dentry *dentry,
76320 + const struct vfsmount *mnt, umode_t *mode);
76321 +__u32 gr_acl_handle_chown(const struct dentry *dentry,
76322 + const struct vfsmount *mnt);
76323 +__u32 gr_acl_handle_setxattr(const struct dentry *dentry,
76324 + const struct vfsmount *mnt);
76325 +__u32 gr_acl_handle_removexattr(const struct dentry *dentry,
76326 + const struct vfsmount *mnt);
76327 +int gr_handle_ptrace(struct task_struct *task, const long request);
76328 +int gr_handle_proc_ptrace(struct task_struct *task);
76329 +__u32 gr_acl_handle_execve(const struct dentry *dentry,
76330 + const struct vfsmount *mnt);
76331 +int gr_check_crash_exec(const struct file *filp);
76332 +int gr_acl_is_enabled(void);
76333 +void gr_set_role_label(struct task_struct *task, const kuid_t uid,
76334 + const kgid_t gid);
76335 +int gr_set_proc_label(const struct dentry *dentry,
76336 + const struct vfsmount *mnt,
76337 + const int unsafe_flags);
76338 +__u32 gr_acl_handle_hidden_file(const struct dentry *dentry,
76339 + const struct vfsmount *mnt);
76340 +__u32 gr_acl_handle_open(const struct dentry *dentry,
76341 + const struct vfsmount *mnt, int acc_mode);
76342 +__u32 gr_acl_handle_creat(const struct dentry *dentry,
76343 + const struct dentry *p_dentry,
76344 + const struct vfsmount *p_mnt,
76345 + int open_flags, int acc_mode, const int imode);
76346 +void gr_handle_create(const struct dentry *dentry,
76347 + const struct vfsmount *mnt);
76348 +void gr_handle_proc_create(const struct dentry *dentry,
76349 + const struct inode *inode);
76350 +__u32 gr_acl_handle_mknod(const struct dentry *new_dentry,
76351 + const struct dentry *parent_dentry,
76352 + const struct vfsmount *parent_mnt,
76353 + const int mode);
76354 +__u32 gr_acl_handle_mkdir(const struct dentry *new_dentry,
76355 + const struct dentry *parent_dentry,
76356 + const struct vfsmount *parent_mnt);
76357 +__u32 gr_acl_handle_rmdir(const struct dentry *dentry,
76358 + const struct vfsmount *mnt);
76359 +void gr_handle_delete(const ino_t ino, const dev_t dev);
76360 +__u32 gr_acl_handle_unlink(const struct dentry *dentry,
76361 + const struct vfsmount *mnt);
76362 +__u32 gr_acl_handle_symlink(const struct dentry *new_dentry,
76363 + const struct dentry *parent_dentry,
76364 + const struct vfsmount *parent_mnt,
76365 + const struct filename *from);
76366 +__u32 gr_acl_handle_link(const struct dentry *new_dentry,
76367 + const struct dentry *parent_dentry,
76368 + const struct vfsmount *parent_mnt,
76369 + const struct dentry *old_dentry,
76370 + const struct vfsmount *old_mnt, const struct filename *to);
76371 +int gr_handle_symlink_owner(const struct path *link, const struct inode *target);
76372 +int gr_acl_handle_rename(struct dentry *new_dentry,
76373 + struct dentry *parent_dentry,
76374 + const struct vfsmount *parent_mnt,
76375 + struct dentry *old_dentry,
76376 + struct inode *old_parent_inode,
76377 + struct vfsmount *old_mnt, const struct filename *newname);
76378 +void gr_handle_rename(struct inode *old_dir, struct inode *new_dir,
76379 + struct dentry *old_dentry,
76380 + struct dentry *new_dentry,
76381 + struct vfsmount *mnt, const __u8 replace);
76382 +__u32 gr_check_link(const struct dentry *new_dentry,
76383 + const struct dentry *parent_dentry,
76384 + const struct vfsmount *parent_mnt,
76385 + const struct dentry *old_dentry,
76386 + const struct vfsmount *old_mnt);
76387 +int gr_acl_handle_filldir(const struct file *file, const char *name,
76388 + const unsigned int namelen, const ino_t ino);
76389 +
76390 +__u32 gr_acl_handle_unix(const struct dentry *dentry,
76391 + const struct vfsmount *mnt);
76392 +void gr_acl_handle_exit(void);
76393 +void gr_acl_handle_psacct(struct task_struct *task, const long code);
76394 +int gr_acl_handle_procpidmem(const struct task_struct *task);
76395 +int gr_handle_rofs_mount(struct dentry *dentry, struct vfsmount *mnt, int mnt_flags);
76396 +int gr_handle_rofs_blockwrite(struct dentry *dentry, struct vfsmount *mnt, int acc_mode);
76397 +void gr_audit_ptrace(struct task_struct *task);
76398 +dev_t gr_get_dev_from_dentry(struct dentry *dentry);
76399 +void gr_put_exec_file(struct task_struct *task);
76400 +
76401 +int gr_ptrace_readexec(struct file *file, int unsafe_flags);
76402 +
76403 +#if defined(CONFIG_GRKERNSEC) && (defined(CONFIG_GRKERNSEC_RESLOG) || !defined(CONFIG_GRKERNSEC_NO_RBAC))
76404 +extern void gr_learn_resource(const struct task_struct *task, const int res,
76405 + const unsigned long wanted, const int gt);
76406 +#else
76407 +static inline void gr_learn_resource(const struct task_struct *task, const int res,
76408 + const unsigned long wanted, const int gt)
76409 +{
76410 +}
76411 +#endif
76412 +
76413 +#ifdef CONFIG_GRKERNSEC_RESLOG
76414 +extern void gr_log_resource(const struct task_struct *task, const int res,
76415 + const unsigned long wanted, const int gt);
76416 +#else
76417 +static inline void gr_log_resource(const struct task_struct *task, const int res,
76418 + const unsigned long wanted, const int gt)
76419 +{
76420 +}
76421 +#endif
76422 +
76423 +#ifdef CONFIG_GRKERNSEC
76424 +void task_grsec_rbac(struct seq_file *m, struct task_struct *p);
76425 +void gr_handle_vm86(void);
76426 +void gr_handle_mem_readwrite(u64 from, u64 to);
76427 +
76428 +void gr_log_badprocpid(const char *entry);
76429 +
76430 +extern int grsec_enable_dmesg;
76431 +extern int grsec_disable_privio;
76432 +
76433 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
76434 +extern kgid_t grsec_proc_gid;
76435 +#endif
76436 +
76437 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
76438 +extern int grsec_enable_chroot_findtask;
76439 +#endif
76440 +#ifdef CONFIG_GRKERNSEC_SETXID
76441 +extern int grsec_enable_setxid;
76442 +#endif
76443 +#endif
76444 +
76445 +#endif
76446 diff --git a/include/linux/grsock.h b/include/linux/grsock.h
76447 new file mode 100644
76448 index 0000000..e7ffaaf
76449 --- /dev/null
76450 +++ b/include/linux/grsock.h
76451 @@ -0,0 +1,19 @@
76452 +#ifndef __GRSOCK_H
76453 +#define __GRSOCK_H
76454 +
76455 +extern void gr_attach_curr_ip(const struct sock *sk);
76456 +extern int gr_handle_sock_all(const int family, const int type,
76457 + const int protocol);
76458 +extern int gr_handle_sock_server(const struct sockaddr *sck);
76459 +extern int gr_handle_sock_server_other(const struct sock *sck);
76460 +extern int gr_handle_sock_client(const struct sockaddr *sck);
76461 +extern int gr_search_connect(struct socket * sock,
76462 + struct sockaddr_in * addr);
76463 +extern int gr_search_bind(struct socket * sock,
76464 + struct sockaddr_in * addr);
76465 +extern int gr_search_listen(struct socket * sock);
76466 +extern int gr_search_accept(struct socket * sock);
76467 +extern int gr_search_socket(const int domain, const int type,
76468 + const int protocol);
76469 +
76470 +#endif
76471 diff --git a/include/linux/highmem.h b/include/linux/highmem.h
76472 index 7fb31da..08b5114 100644
76473 --- a/include/linux/highmem.h
76474 +++ b/include/linux/highmem.h
76475 @@ -189,6 +189,18 @@ static inline void clear_highpage(struct page *page)
76476 kunmap_atomic(kaddr);
76477 }
76478
76479 +static inline void sanitize_highpage(struct page *page)
76480 +{
76481 + void *kaddr;
76482 + unsigned long flags;
76483 +
76484 + local_irq_save(flags);
76485 + kaddr = kmap_atomic(page);
76486 + clear_page(kaddr);
76487 + kunmap_atomic(kaddr);
76488 + local_irq_restore(flags);
76489 +}
76490 +
76491 static inline void zero_user_segments(struct page *page,
76492 unsigned start1, unsigned end1,
76493 unsigned start2, unsigned end2)
76494 diff --git a/include/linux/hwmon-sysfs.h b/include/linux/hwmon-sysfs.h
76495 index 1c7b89a..7dda400 100644
76496 --- a/include/linux/hwmon-sysfs.h
76497 +++ b/include/linux/hwmon-sysfs.h
76498 @@ -25,7 +25,8 @@
76499 struct sensor_device_attribute{
76500 struct device_attribute dev_attr;
76501 int index;
76502 -};
76503 +} __do_const;
76504 +typedef struct sensor_device_attribute __no_const sensor_device_attribute_no_const;
76505 #define to_sensor_dev_attr(_dev_attr) \
76506 container_of(_dev_attr, struct sensor_device_attribute, dev_attr)
76507
76508 @@ -41,7 +42,8 @@ struct sensor_device_attribute_2 {
76509 struct device_attribute dev_attr;
76510 u8 index;
76511 u8 nr;
76512 -};
76513 +} __do_const;
76514 +typedef struct sensor_device_attribute_2 __no_const sensor_device_attribute_2_no_const;
76515 #define to_sensor_dev_attr_2(_dev_attr) \
76516 container_of(_dev_attr, struct sensor_device_attribute_2, dev_attr)
76517
76518 diff --git a/include/linux/i2c.h b/include/linux/i2c.h
76519 index 2ab11dc..663a3f2 100644
76520 --- a/include/linux/i2c.h
76521 +++ b/include/linux/i2c.h
76522 @@ -366,6 +366,7 @@ struct i2c_algorithm {
76523 /* To determine what the adapter supports */
76524 u32 (*functionality) (struct i2c_adapter *);
76525 };
76526 +typedef struct i2c_algorithm __no_const i2c_algorithm_no_const;
76527
76528 /**
76529 * struct i2c_bus_recovery_info - I2C bus recovery information
76530 diff --git a/include/linux/i2o.h b/include/linux/i2o.h
76531 index d23c3c2..eb63c81 100644
76532 --- a/include/linux/i2o.h
76533 +++ b/include/linux/i2o.h
76534 @@ -565,7 +565,7 @@ struct i2o_controller {
76535 struct i2o_device *exec; /* Executive */
76536 #if BITS_PER_LONG == 64
76537 spinlock_t context_list_lock; /* lock for context_list */
76538 - atomic_t context_list_counter; /* needed for unique contexts */
76539 + atomic_unchecked_t context_list_counter; /* needed for unique contexts */
76540 struct list_head context_list; /* list of context id's
76541 and pointers */
76542 #endif
76543 diff --git a/include/linux/if_pppox.h b/include/linux/if_pppox.h
76544 index aff7ad8..3942bbd 100644
76545 --- a/include/linux/if_pppox.h
76546 +++ b/include/linux/if_pppox.h
76547 @@ -76,7 +76,7 @@ struct pppox_proto {
76548 int (*ioctl)(struct socket *sock, unsigned int cmd,
76549 unsigned long arg);
76550 struct module *owner;
76551 -};
76552 +} __do_const;
76553
76554 extern int register_pppox_proto(int proto_num, const struct pppox_proto *pp);
76555 extern void unregister_pppox_proto(int proto_num);
76556 diff --git a/include/linux/init.h b/include/linux/init.h
76557 index f1c27a71..7d6010e 100644
76558 --- a/include/linux/init.h
76559 +++ b/include/linux/init.h
76560 @@ -39,9 +39,17 @@
76561 * Also note, that this data cannot be "const".
76562 */
76563
76564 +#define add_init_latent_entropy __latent_entropy
76565 +
76566 +#ifdef CONFIG_MEMORY_HOTPLUG
76567 +#define add_meminit_latent_entropy
76568 +#else
76569 +#define add_meminit_latent_entropy __latent_entropy
76570 +#endif
76571 +
76572 /* These are for everybody (although not all archs will actually
76573 discard it in modules) */
76574 -#define __init __section(.init.text) __cold notrace
76575 +#define __init __section(.init.text) __cold notrace add_init_latent_entropy
76576 #define __initdata __section(.init.data)
76577 #define __initconst __constsection(.init.rodata)
76578 #define __exitdata __section(.exit.data)
76579 @@ -102,7 +110,7 @@
76580 #define __cpuexitconst
76581
76582 /* Used for MEMORY_HOTPLUG */
76583 -#define __meminit __section(.meminit.text) __cold notrace
76584 +#define __meminit __section(.meminit.text) __cold notrace add_meminit_latent_entropy
76585 #define __meminitdata __section(.meminit.data)
76586 #define __meminitconst __constsection(.meminit.rodata)
76587 #define __memexit __section(.memexit.text) __exitused __cold notrace
76588 diff --git a/include/linux/init_task.h b/include/linux/init_task.h
76589 index 5cd0f09..c9f67cc 100644
76590 --- a/include/linux/init_task.h
76591 +++ b/include/linux/init_task.h
76592 @@ -154,6 +154,12 @@ extern struct task_group root_task_group;
76593
76594 #define INIT_TASK_COMM "swapper"
76595
76596 +#ifdef CONFIG_X86
76597 +#define INIT_TASK_THREAD_INFO .tinfo = INIT_THREAD_INFO,
76598 +#else
76599 +#define INIT_TASK_THREAD_INFO
76600 +#endif
76601 +
76602 /*
76603 * INIT_TASK is used to set up the first task table, touch at
76604 * your own risk!. Base=0, limit=0x1fffff (=2MB)
76605 @@ -193,6 +199,7 @@ extern struct task_group root_task_group;
76606 RCU_POINTER_INITIALIZER(cred, &init_cred), \
76607 .comm = INIT_TASK_COMM, \
76608 .thread = INIT_THREAD, \
76609 + INIT_TASK_THREAD_INFO \
76610 .fs = &init_fs, \
76611 .files = &init_files, \
76612 .signal = &init_signals, \
76613 diff --git a/include/linux/interrupt.h b/include/linux/interrupt.h
76614 index 5e865b5..71bd258 100644
76615 --- a/include/linux/interrupt.h
76616 +++ b/include/linux/interrupt.h
76617 @@ -361,7 +361,7 @@ enum
76618 /* map softirq index to softirq name. update 'softirq_to_name' in
76619 * kernel/softirq.c when adding a new softirq.
76620 */
76621 -extern char *softirq_to_name[NR_SOFTIRQS];
76622 +extern const char * const softirq_to_name[NR_SOFTIRQS];
76623
76624 /* softirq mask and active fields moved to irq_cpustat_t in
76625 * asm/hardirq.h to get better cache usage. KAO
76626 @@ -369,12 +369,12 @@ extern char *softirq_to_name[NR_SOFTIRQS];
76627
76628 struct softirq_action
76629 {
76630 - void (*action)(struct softirq_action *);
76631 -};
76632 + void (*action)(void);
76633 +} __no_const;
76634
76635 asmlinkage void do_softirq(void);
76636 asmlinkage void __do_softirq(void);
76637 -extern void open_softirq(int nr, void (*action)(struct softirq_action *));
76638 +extern void open_softirq(int nr, void (*action)(void));
76639 extern void softirq_init(void);
76640 extern void __raise_softirq_irqoff(unsigned int nr);
76641
76642 diff --git a/include/linux/iommu.h b/include/linux/iommu.h
76643 index 7ea319e..f9e971d 100644
76644 --- a/include/linux/iommu.h
76645 +++ b/include/linux/iommu.h
76646 @@ -129,7 +129,7 @@ struct iommu_ops {
76647 u32 (*domain_get_windows)(struct iommu_domain *domain);
76648
76649 unsigned long pgsize_bitmap;
76650 -};
76651 +} __do_const;
76652
76653 #define IOMMU_GROUP_NOTIFY_ADD_DEVICE 1 /* Device added */
76654 #define IOMMU_GROUP_NOTIFY_DEL_DEVICE 2 /* Pre Device removed */
76655 diff --git a/include/linux/ioport.h b/include/linux/ioport.h
76656 index 89b7c24..382af74 100644
76657 --- a/include/linux/ioport.h
76658 +++ b/include/linux/ioport.h
76659 @@ -161,7 +161,7 @@ struct resource *lookup_resource(struct resource *root, resource_size_t start);
76660 int adjust_resource(struct resource *res, resource_size_t start,
76661 resource_size_t size);
76662 resource_size_t resource_alignment(struct resource *res);
76663 -static inline resource_size_t resource_size(const struct resource *res)
76664 +static inline resource_size_t __intentional_overflow(-1) resource_size(const struct resource *res)
76665 {
76666 return res->end - res->start + 1;
76667 }
76668 diff --git a/include/linux/irq.h b/include/linux/irq.h
76669 index 56bb0dc..8ae94d62 100644
76670 --- a/include/linux/irq.h
76671 +++ b/include/linux/irq.h
76672 @@ -333,7 +333,8 @@ struct irq_chip {
76673 void (*irq_print_chip)(struct irq_data *data, struct seq_file *p);
76674
76675 unsigned long flags;
76676 -};
76677 +} __do_const;
76678 +typedef struct irq_chip __no_const irq_chip_no_const;
76679
76680 /*
76681 * irq_chip specific flags
76682 diff --git a/include/linux/irqchip/arm-gic.h b/include/linux/irqchip/arm-gic.h
76683 index 0e5d9ec..46acb3a 100644
76684 --- a/include/linux/irqchip/arm-gic.h
76685 +++ b/include/linux/irqchip/arm-gic.h
76686 @@ -59,9 +59,11 @@
76687
76688 #ifndef __ASSEMBLY__
76689
76690 +#include <linux/irq.h>
76691 +
76692 struct device_node;
76693
76694 -extern struct irq_chip gic_arch_extn;
76695 +extern irq_chip_no_const gic_arch_extn;
76696
76697 void gic_init_bases(unsigned int, int, void __iomem *, void __iomem *,
76698 u32 offset, struct device_node *);
76699 diff --git a/include/linux/jiffies.h b/include/linux/jiffies.h
76700 index d235e88..8ccbe74 100644
76701 --- a/include/linux/jiffies.h
76702 +++ b/include/linux/jiffies.h
76703 @@ -292,14 +292,14 @@ extern unsigned long preset_lpj;
76704 /*
76705 * Convert various time units to each other:
76706 */
76707 -extern unsigned int jiffies_to_msecs(const unsigned long j);
76708 -extern unsigned int jiffies_to_usecs(const unsigned long j);
76709 -extern unsigned long msecs_to_jiffies(const unsigned int m);
76710 -extern unsigned long usecs_to_jiffies(const unsigned int u);
76711 -extern unsigned long timespec_to_jiffies(const struct timespec *value);
76712 +extern unsigned int jiffies_to_msecs(const unsigned long j) __intentional_overflow(-1);
76713 +extern unsigned int jiffies_to_usecs(const unsigned long j) __intentional_overflow(-1);
76714 +extern unsigned long msecs_to_jiffies(const unsigned int m) __intentional_overflow(-1);
76715 +extern unsigned long usecs_to_jiffies(const unsigned int u) __intentional_overflow(-1);
76716 +extern unsigned long timespec_to_jiffies(const struct timespec *value) __intentional_overflow(-1);
76717 extern void jiffies_to_timespec(const unsigned long jiffies,
76718 struct timespec *value);
76719 -extern unsigned long timeval_to_jiffies(const struct timeval *value);
76720 +extern unsigned long timeval_to_jiffies(const struct timeval *value) __intentional_overflow(-1);
76721 extern void jiffies_to_timeval(const unsigned long jiffies,
76722 struct timeval *value);
76723
76724 diff --git a/include/linux/kallsyms.h b/include/linux/kallsyms.h
76725 index 6883e19..e854fcb 100644
76726 --- a/include/linux/kallsyms.h
76727 +++ b/include/linux/kallsyms.h
76728 @@ -15,7 +15,8 @@
76729
76730 struct module;
76731
76732 -#ifdef CONFIG_KALLSYMS
76733 +#if !defined(__INCLUDED_BY_HIDESYM) || !defined(CONFIG_KALLSYMS)
76734 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
76735 /* Lookup the address for a symbol. Returns 0 if not found. */
76736 unsigned long kallsyms_lookup_name(const char *name);
76737
76738 @@ -106,6 +107,21 @@ static inline int lookup_symbol_attrs(unsigned long addr, unsigned long *size, u
76739 /* Stupid that this does nothing, but I didn't create this mess. */
76740 #define __print_symbol(fmt, addr)
76741 #endif /*CONFIG_KALLSYMS*/
76742 +#else /* when included by kallsyms.c, vsnprintf.c, kprobes.c, or
76743 + arch/x86/kernel/dumpstack.c, with HIDESYM enabled */
76744 +extern unsigned long kallsyms_lookup_name(const char *name);
76745 +extern void __print_symbol(const char *fmt, unsigned long address);
76746 +extern int sprint_backtrace(char *buffer, unsigned long address);
76747 +extern int sprint_symbol(char *buffer, unsigned long address);
76748 +extern int sprint_symbol_no_offset(char *buffer, unsigned long address);
76749 +const char *kallsyms_lookup(unsigned long addr,
76750 + unsigned long *symbolsize,
76751 + unsigned long *offset,
76752 + char **modname, char *namebuf);
76753 +extern int kallsyms_lookup_size_offset(unsigned long addr,
76754 + unsigned long *symbolsize,
76755 + unsigned long *offset);
76756 +#endif
76757
76758 /* This macro allows us to keep printk typechecking */
76759 static __printf(1, 2)
76760 diff --git a/include/linux/key-type.h b/include/linux/key-type.h
76761 index 518a53a..5e28358 100644
76762 --- a/include/linux/key-type.h
76763 +++ b/include/linux/key-type.h
76764 @@ -125,7 +125,7 @@ struct key_type {
76765 /* internal fields */
76766 struct list_head link; /* link in types list */
76767 struct lock_class_key lock_class; /* key->sem lock class */
76768 -};
76769 +} __do_const;
76770
76771 extern struct key_type key_type_keyring;
76772
76773 diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h
76774 index c6e091b..a940adf 100644
76775 --- a/include/linux/kgdb.h
76776 +++ b/include/linux/kgdb.h
76777 @@ -52,7 +52,7 @@ extern int kgdb_connected;
76778 extern int kgdb_io_module_registered;
76779
76780 extern atomic_t kgdb_setting_breakpoint;
76781 -extern atomic_t kgdb_cpu_doing_single_step;
76782 +extern atomic_unchecked_t kgdb_cpu_doing_single_step;
76783
76784 extern struct task_struct *kgdb_usethread;
76785 extern struct task_struct *kgdb_contthread;
76786 @@ -254,7 +254,7 @@ struct kgdb_arch {
76787 void (*correct_hw_break)(void);
76788
76789 void (*enable_nmi)(bool on);
76790 -};
76791 +} __do_const;
76792
76793 /**
76794 * struct kgdb_io - Describe the interface for an I/O driver to talk with KGDB.
76795 @@ -279,7 +279,7 @@ struct kgdb_io {
76796 void (*pre_exception) (void);
76797 void (*post_exception) (void);
76798 int is_console;
76799 -};
76800 +} __do_const;
76801
76802 extern struct kgdb_arch arch_kgdb_ops;
76803
76804 diff --git a/include/linux/kmod.h b/include/linux/kmod.h
76805 index 0555cc6..40116ce 100644
76806 --- a/include/linux/kmod.h
76807 +++ b/include/linux/kmod.h
76808 @@ -34,6 +34,8 @@ extern char modprobe_path[]; /* for sysctl */
76809 * usually useless though. */
76810 extern __printf(2, 3)
76811 int __request_module(bool wait, const char *name, ...);
76812 +extern __printf(3, 4)
76813 +int ___request_module(bool wait, char *param_name, const char *name, ...);
76814 #define request_module(mod...) __request_module(true, mod)
76815 #define request_module_nowait(mod...) __request_module(false, mod)
76816 #define try_then_request_module(x, mod...) \
76817 @@ -57,6 +59,9 @@ struct subprocess_info {
76818 struct work_struct work;
76819 struct completion *complete;
76820 char *path;
76821 +#ifdef CONFIG_GRKERNSEC
76822 + char *origpath;
76823 +#endif
76824 char **argv;
76825 char **envp;
76826 int wait;
76827 diff --git a/include/linux/kobject.h b/include/linux/kobject.h
76828 index de6dcbcc..4735f88 100644
76829 --- a/include/linux/kobject.h
76830 +++ b/include/linux/kobject.h
76831 @@ -115,7 +115,7 @@ struct kobj_type {
76832 struct attribute **default_attrs;
76833 const struct kobj_ns_type_operations *(*child_ns_type)(struct kobject *kobj);
76834 const void *(*namespace)(struct kobject *kobj);
76835 -};
76836 +} __do_const;
76837
76838 struct kobj_uevent_env {
76839 char *envp[UEVENT_NUM_ENVP];
76840 @@ -138,6 +138,7 @@ struct kobj_attribute {
76841 ssize_t (*store)(struct kobject *kobj, struct kobj_attribute *attr,
76842 const char *buf, size_t count);
76843 };
76844 +typedef struct kobj_attribute __no_const kobj_attribute_no_const;
76845
76846 extern const struct sysfs_ops kobj_sysfs_ops;
76847
76848 diff --git a/include/linux/kobject_ns.h b/include/linux/kobject_ns.h
76849 index df32d25..fb52e27 100644
76850 --- a/include/linux/kobject_ns.h
76851 +++ b/include/linux/kobject_ns.h
76852 @@ -44,7 +44,7 @@ struct kobj_ns_type_operations {
76853 const void *(*netlink_ns)(struct sock *sk);
76854 const void *(*initial_ns)(void);
76855 void (*drop_ns)(void *);
76856 -};
76857 +} __do_const;
76858
76859 int kobj_ns_type_register(const struct kobj_ns_type_operations *ops);
76860 int kobj_ns_type_registered(enum kobj_ns_type type);
76861 diff --git a/include/linux/kref.h b/include/linux/kref.h
76862 index 484604d..0f6c5b6 100644
76863 --- a/include/linux/kref.h
76864 +++ b/include/linux/kref.h
76865 @@ -68,7 +68,7 @@ static inline void kref_get(struct kref *kref)
76866 static inline int kref_sub(struct kref *kref, unsigned int count,
76867 void (*release)(struct kref *kref))
76868 {
76869 - WARN_ON(release == NULL);
76870 + BUG_ON(release == NULL);
76871
76872 if (atomic_sub_and_test((int) count, &kref->refcount)) {
76873 release(kref);
76874 diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h
76875 index 0fbbc7a..db081e3 100644
76876 --- a/include/linux/kvm_host.h
76877 +++ b/include/linux/kvm_host.h
76878 @@ -458,7 +458,7 @@ static inline void kvm_irqfd_exit(void)
76879 {
76880 }
76881 #endif
76882 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76883 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
76884 struct module *module);
76885 void kvm_exit(void);
76886
76887 @@ -632,7 +632,7 @@ int kvm_arch_vcpu_ioctl_set_guest_debug(struct kvm_vcpu *vcpu,
76888 struct kvm_guest_debug *dbg);
76889 int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu, struct kvm_run *kvm_run);
76890
76891 -int kvm_arch_init(void *opaque);
76892 +int kvm_arch_init(const void *opaque);
76893 void kvm_arch_exit(void);
76894
76895 int kvm_arch_vcpu_init(struct kvm_vcpu *vcpu);
76896 diff --git a/include/linux/libata.h b/include/linux/libata.h
76897 index 9b50337..712d748 100644
76898 --- a/include/linux/libata.h
76899 +++ b/include/linux/libata.h
76900 @@ -973,7 +973,7 @@ struct ata_port_operations {
76901 * fields must be pointers.
76902 */
76903 const struct ata_port_operations *inherits;
76904 -};
76905 +} __do_const;
76906
76907 struct ata_port_info {
76908 unsigned long flags;
76909 diff --git a/include/linux/linkage.h b/include/linux/linkage.h
76910 index d3e8ad2..a949f68 100644
76911 --- a/include/linux/linkage.h
76912 +++ b/include/linux/linkage.h
76913 @@ -31,6 +31,7 @@
76914 #endif
76915
76916 #define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
76917 +#define __page_aligned_rodata __read_only __aligned(PAGE_SIZE)
76918 #define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
76919
76920 /*
76921 diff --git a/include/linux/list.h b/include/linux/list.h
76922 index f4d8a2f..38e6e46 100644
76923 --- a/include/linux/list.h
76924 +++ b/include/linux/list.h
76925 @@ -112,6 +112,19 @@ extern void __list_del_entry(struct list_head *entry);
76926 extern void list_del(struct list_head *entry);
76927 #endif
76928
76929 +extern void __pax_list_add(struct list_head *new,
76930 + struct list_head *prev,
76931 + struct list_head *next);
76932 +static inline void pax_list_add(struct list_head *new, struct list_head *head)
76933 +{
76934 + __pax_list_add(new, head, head->next);
76935 +}
76936 +static inline void pax_list_add_tail(struct list_head *new, struct list_head *head)
76937 +{
76938 + __pax_list_add(new, head->prev, head);
76939 +}
76940 +extern void pax_list_del(struct list_head *entry);
76941 +
76942 /**
76943 * list_replace - replace old entry by new one
76944 * @old : the element to be replaced
76945 @@ -145,6 +158,8 @@ static inline void list_del_init(struct list_head *entry)
76946 INIT_LIST_HEAD(entry);
76947 }
76948
76949 +extern void pax_list_del_init(struct list_head *entry);
76950 +
76951 /**
76952 * list_move - delete from one list and add as another's head
76953 * @list: the entry to move
76954 diff --git a/include/linux/math64.h b/include/linux/math64.h
76955 index 69ed5f5..243ed51 100644
76956 --- a/include/linux/math64.h
76957 +++ b/include/linux/math64.h
76958 @@ -15,7 +15,7 @@
76959 * This is commonly provided by 32bit archs to provide an optimized 64bit
76960 * divide.
76961 */
76962 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76963 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76964 {
76965 *remainder = dividend % divisor;
76966 return dividend / divisor;
76967 @@ -42,7 +42,7 @@ static inline u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder)
76968 /**
76969 * div64_u64 - unsigned 64bit divide with 64bit divisor
76970 */
76971 -static inline u64 div64_u64(u64 dividend, u64 divisor)
76972 +static inline u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
76973 {
76974 return dividend / divisor;
76975 }
76976 @@ -61,7 +61,7 @@ static inline s64 div64_s64(s64 dividend, s64 divisor)
76977 #define div64_ul(x, y) div_u64((x), (y))
76978
76979 #ifndef div_u64_rem
76980 -static inline u64 div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76981 +static inline u64 __intentional_overflow(-1) div_u64_rem(u64 dividend, u32 divisor, u32 *remainder)
76982 {
76983 *remainder = do_div(dividend, divisor);
76984 return dividend;
76985 @@ -77,7 +77,7 @@ extern u64 div64_u64_rem(u64 dividend, u64 divisor, u64 *remainder);
76986 #endif
76987
76988 #ifndef div64_u64
76989 -extern u64 div64_u64(u64 dividend, u64 divisor);
76990 +extern u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor);
76991 #endif
76992
76993 #ifndef div64_s64
76994 @@ -94,7 +94,7 @@ extern s64 div64_s64(s64 dividend, s64 divisor);
76995 * divide.
76996 */
76997 #ifndef div_u64
76998 -static inline u64 div_u64(u64 dividend, u32 divisor)
76999 +static inline u64 __intentional_overflow(-1) div_u64(u64 dividend, u32 divisor)
77000 {
77001 u32 remainder;
77002 return div_u64_rem(dividend, divisor, &remainder);
77003 diff --git a/include/linux/mempolicy.h b/include/linux/mempolicy.h
77004 index da6716b..2e31db3 100644
77005 --- a/include/linux/mempolicy.h
77006 +++ b/include/linux/mempolicy.h
77007 @@ -91,6 +91,10 @@ static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
77008 }
77009
77010 #define vma_policy(vma) ((vma)->vm_policy)
77011 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
77012 +{
77013 + vma->vm_policy = pol;
77014 +}
77015
77016 static inline void mpol_get(struct mempolicy *pol)
77017 {
77018 @@ -240,6 +244,9 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx)
77019 }
77020
77021 #define vma_policy(vma) NULL
77022 +static inline void set_vma_policy(struct vm_area_struct *vma, struct mempolicy *pol)
77023 +{
77024 +}
77025
77026 static inline int
77027 vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst)
77028 diff --git a/include/linux/mm.h b/include/linux/mm.h
77029 index 8b6e55e..c4edf39 100644
77030 --- a/include/linux/mm.h
77031 +++ b/include/linux/mm.h
77032 @@ -113,6 +113,11 @@ extern unsigned int kobjsize(const void *objp);
77033 #define VM_HUGETLB 0x00400000 /* Huge TLB Page VM */
77034 #define VM_NONLINEAR 0x00800000 /* Is non-linear (remap_file_pages) */
77035 #define VM_ARCH_1 0x01000000 /* Architecture-specific flag */
77036 +
77037 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
77038 +#define VM_PAGEEXEC 0x02000000 /* vma->vm_page_prot needs special handling */
77039 +#endif
77040 +
77041 #define VM_DONTDUMP 0x04000000 /* Do not include in the core dump */
77042
77043 #ifdef CONFIG_MEM_SOFT_DIRTY
77044 @@ -215,8 +220,8 @@ struct vm_operations_struct {
77045 /* called by access_process_vm when get_user_pages() fails, typically
77046 * for use by special VMAs that can switch between memory and hardware
77047 */
77048 - int (*access)(struct vm_area_struct *vma, unsigned long addr,
77049 - void *buf, int len, int write);
77050 + ssize_t (*access)(struct vm_area_struct *vma, unsigned long addr,
77051 + void *buf, size_t len, int write);
77052 #ifdef CONFIG_NUMA
77053 /*
77054 * set_policy() op must add a reference to any non-NULL @new mempolicy
77055 @@ -246,6 +251,7 @@ struct vm_operations_struct {
77056 int (*remap_pages)(struct vm_area_struct *vma, unsigned long addr,
77057 unsigned long size, pgoff_t pgoff);
77058 };
77059 +typedef struct vm_operations_struct __no_const vm_operations_struct_no_const;
77060
77061 struct mmu_gather;
77062 struct inode;
77063 @@ -977,8 +983,8 @@ int follow_pfn(struct vm_area_struct *vma, unsigned long address,
77064 unsigned long *pfn);
77065 int follow_phys(struct vm_area_struct *vma, unsigned long address,
77066 unsigned int flags, unsigned long *prot, resource_size_t *phys);
77067 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
77068 - void *buf, int len, int write);
77069 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
77070 + void *buf, size_t len, int write);
77071
77072 static inline void unmap_shared_mapping_range(struct address_space *mapping,
77073 loff_t const holebegin, loff_t const holelen)
77074 @@ -1017,9 +1023,9 @@ static inline int fixup_user_fault(struct task_struct *tsk,
77075 }
77076 #endif
77077
77078 -extern int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write);
77079 -extern int access_remote_vm(struct mm_struct *mm, unsigned long addr,
77080 - void *buf, int len, int write);
77081 +extern ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write);
77082 +extern ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
77083 + void *buf, size_t len, int write);
77084
77085 long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
77086 unsigned long start, unsigned long nr_pages,
77087 @@ -1051,34 +1057,6 @@ int set_page_dirty(struct page *page);
77088 int set_page_dirty_lock(struct page *page);
77089 int clear_page_dirty_for_io(struct page *page);
77090
77091 -/* Is the vma a continuation of the stack vma above it? */
77092 -static inline int vma_growsdown(struct vm_area_struct *vma, unsigned long addr)
77093 -{
77094 - return vma && (vma->vm_end == addr) && (vma->vm_flags & VM_GROWSDOWN);
77095 -}
77096 -
77097 -static inline int stack_guard_page_start(struct vm_area_struct *vma,
77098 - unsigned long addr)
77099 -{
77100 - return (vma->vm_flags & VM_GROWSDOWN) &&
77101 - (vma->vm_start == addr) &&
77102 - !vma_growsdown(vma->vm_prev, addr);
77103 -}
77104 -
77105 -/* Is the vma a continuation of the stack vma below it? */
77106 -static inline int vma_growsup(struct vm_area_struct *vma, unsigned long addr)
77107 -{
77108 - return vma && (vma->vm_start == addr) && (vma->vm_flags & VM_GROWSUP);
77109 -}
77110 -
77111 -static inline int stack_guard_page_end(struct vm_area_struct *vma,
77112 - unsigned long addr)
77113 -{
77114 - return (vma->vm_flags & VM_GROWSUP) &&
77115 - (vma->vm_end == addr) &&
77116 - !vma_growsup(vma->vm_next, addr);
77117 -}
77118 -
77119 extern pid_t
77120 vm_is_stack(struct task_struct *task, struct vm_area_struct *vma, int in_group);
77121
77122 @@ -1178,6 +1156,15 @@ static inline void sync_mm_rss(struct mm_struct *mm)
77123 }
77124 #endif
77125
77126 +#ifdef CONFIG_MMU
77127 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags);
77128 +#else
77129 +static inline pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
77130 +{
77131 + return __pgprot(0);
77132 +}
77133 +#endif
77134 +
77135 int vma_wants_writenotify(struct vm_area_struct *vma);
77136
77137 extern pte_t *__get_locked_pte(struct mm_struct *mm, unsigned long addr,
77138 @@ -1196,8 +1183,15 @@ static inline int __pud_alloc(struct mm_struct *mm, pgd_t *pgd,
77139 {
77140 return 0;
77141 }
77142 +
77143 +static inline int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd,
77144 + unsigned long address)
77145 +{
77146 + return 0;
77147 +}
77148 #else
77149 int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
77150 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address);
77151 #endif
77152
77153 #ifdef __PAGETABLE_PMD_FOLDED
77154 @@ -1206,8 +1200,15 @@ static inline int __pmd_alloc(struct mm_struct *mm, pud_t *pud,
77155 {
77156 return 0;
77157 }
77158 +
77159 +static inline int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud,
77160 + unsigned long address)
77161 +{
77162 + return 0;
77163 +}
77164 #else
77165 int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address);
77166 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address);
77167 #endif
77168
77169 int __pte_alloc(struct mm_struct *mm, struct vm_area_struct *vma,
77170 @@ -1225,11 +1226,23 @@ static inline pud_t *pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long a
77171 NULL: pud_offset(pgd, address);
77172 }
77173
77174 +static inline pud_t *pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
77175 +{
77176 + return (unlikely(pgd_none(*pgd)) && __pud_alloc_kernel(mm, pgd, address))?
77177 + NULL: pud_offset(pgd, address);
77178 +}
77179 +
77180 static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
77181 {
77182 return (unlikely(pud_none(*pud)) && __pmd_alloc(mm, pud, address))?
77183 NULL: pmd_offset(pud, address);
77184 }
77185 +
77186 +static inline pmd_t *pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
77187 +{
77188 + return (unlikely(pud_none(*pud)) && __pmd_alloc_kernel(mm, pud, address))?
77189 + NULL: pmd_offset(pud, address);
77190 +}
77191 #endif /* CONFIG_MMU && !__ARCH_HAS_4LEVEL_HACK */
77192
77193 #if USE_SPLIT_PTLOCKS
77194 @@ -1517,7 +1530,7 @@ extern int install_special_mapping(struct mm_struct *mm,
77195 unsigned long addr, unsigned long len,
77196 unsigned long flags, struct page **pages);
77197
77198 -extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long);
77199 +extern unsigned long get_unmapped_area(struct file *, unsigned long, unsigned long, unsigned long, unsigned long) __intentional_overflow(-1);
77200
77201 extern unsigned long mmap_region(struct file *file, unsigned long addr,
77202 unsigned long len, vm_flags_t vm_flags, unsigned long pgoff);
77203 @@ -1525,6 +1538,7 @@ extern unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
77204 unsigned long len, unsigned long prot, unsigned long flags,
77205 unsigned long pgoff, unsigned long *populate);
77206 extern int do_munmap(struct mm_struct *, unsigned long, size_t);
77207 +extern int __do_munmap(struct mm_struct *, unsigned long, size_t);
77208
77209 #ifdef CONFIG_MMU
77210 extern int __mm_populate(unsigned long addr, unsigned long len,
77211 @@ -1553,10 +1567,11 @@ struct vm_unmapped_area_info {
77212 unsigned long high_limit;
77213 unsigned long align_mask;
77214 unsigned long align_offset;
77215 + unsigned long threadstack_offset;
77216 };
77217
77218 -extern unsigned long unmapped_area(struct vm_unmapped_area_info *info);
77219 -extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
77220 +extern unsigned long unmapped_area(const struct vm_unmapped_area_info *info);
77221 +extern unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info);
77222
77223 /*
77224 * Search for an unmapped address range.
77225 @@ -1568,7 +1583,7 @@ extern unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info);
77226 * - satisfies (begin_addr & align_mask) == (align_offset & align_mask)
77227 */
77228 static inline unsigned long
77229 -vm_unmapped_area(struct vm_unmapped_area_info *info)
77230 +vm_unmapped_area(const struct vm_unmapped_area_info *info)
77231 {
77232 if (!(info->flags & VM_UNMAPPED_AREA_TOPDOWN))
77233 return unmapped_area(info);
77234 @@ -1631,6 +1646,10 @@ extern struct vm_area_struct * find_vma(struct mm_struct * mm, unsigned long add
77235 extern struct vm_area_struct * find_vma_prev(struct mm_struct * mm, unsigned long addr,
77236 struct vm_area_struct **pprev);
77237
77238 +extern struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma);
77239 +extern __must_check long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma);
77240 +extern void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl);
77241 +
77242 /* Look up the first VMA which intersects the interval start_addr..end_addr-1,
77243 NULL if none. Assume start_addr < end_addr. */
77244 static inline struct vm_area_struct * find_vma_intersection(struct mm_struct * mm, unsigned long start_addr, unsigned long end_addr)
77245 @@ -1659,15 +1678,6 @@ static inline struct vm_area_struct *find_exact_vma(struct mm_struct *mm,
77246 return vma;
77247 }
77248
77249 -#ifdef CONFIG_MMU
77250 -pgprot_t vm_get_page_prot(unsigned long vm_flags);
77251 -#else
77252 -static inline pgprot_t vm_get_page_prot(unsigned long vm_flags)
77253 -{
77254 - return __pgprot(0);
77255 -}
77256 -#endif
77257 -
77258 #ifdef CONFIG_ARCH_USES_NUMA_PROT_NONE
77259 unsigned long change_prot_numa(struct vm_area_struct *vma,
77260 unsigned long start, unsigned long end);
77261 @@ -1719,6 +1729,11 @@ void vm_stat_account(struct mm_struct *, unsigned long, struct file *, long);
77262 static inline void vm_stat_account(struct mm_struct *mm,
77263 unsigned long flags, struct file *file, long pages)
77264 {
77265 +
77266 +#ifdef CONFIG_PAX_RANDMMAP
77267 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
77268 +#endif
77269 +
77270 mm->total_vm += pages;
77271 }
77272 #endif /* CONFIG_PROC_FS */
77273 @@ -1800,7 +1815,7 @@ extern int unpoison_memory(unsigned long pfn);
77274 extern int sysctl_memory_failure_early_kill;
77275 extern int sysctl_memory_failure_recovery;
77276 extern void shake_page(struct page *p, int access);
77277 -extern atomic_long_t num_poisoned_pages;
77278 +extern atomic_long_unchecked_t num_poisoned_pages;
77279 extern int soft_offline_page(struct page *page, int flags);
77280
77281 extern void dump_page(struct page *page);
77282 @@ -1837,5 +1852,11 @@ void __init setup_nr_node_ids(void);
77283 static inline void setup_nr_node_ids(void) {}
77284 #endif
77285
77286 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
77287 +extern void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot);
77288 +#else
77289 +static inline void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot) {}
77290 +#endif
77291 +
77292 #endif /* __KERNEL__ */
77293 #endif /* _LINUX_MM_H */
77294 diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
77295 index 8e082f1..f61f576 100644
77296 --- a/include/linux/mm_types.h
77297 +++ b/include/linux/mm_types.h
77298 @@ -289,6 +289,8 @@ struct vm_area_struct {
77299 #ifdef CONFIG_NUMA
77300 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
77301 #endif
77302 +
77303 + struct vm_area_struct *vm_mirror;/* PaX: mirror vma or NULL */
77304 };
77305
77306 struct core_thread {
77307 @@ -444,6 +446,24 @@ struct mm_struct {
77308 bool tlb_flush_pending;
77309 #endif
77310 struct uprobes_state uprobes_state;
77311 +
77312 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
77313 + unsigned long pax_flags;
77314 +#endif
77315 +
77316 +#ifdef CONFIG_PAX_DLRESOLVE
77317 + unsigned long call_dl_resolve;
77318 +#endif
77319 +
77320 +#if defined(CONFIG_PPC32) && defined(CONFIG_PAX_EMUSIGRT)
77321 + unsigned long call_syscall;
77322 +#endif
77323 +
77324 +#ifdef CONFIG_PAX_ASLR
77325 + unsigned long delta_mmap; /* randomized offset */
77326 + unsigned long delta_stack; /* randomized offset */
77327 +#endif
77328 +
77329 };
77330
77331 /* first nid will either be a valid NID or one of these values */
77332 diff --git a/include/linux/mmiotrace.h b/include/linux/mmiotrace.h
77333 index c5d5278..f0b68c8 100644
77334 --- a/include/linux/mmiotrace.h
77335 +++ b/include/linux/mmiotrace.h
77336 @@ -46,7 +46,7 @@ extern int kmmio_handler(struct pt_regs *regs, unsigned long addr);
77337 /* Called from ioremap.c */
77338 extern void mmiotrace_ioremap(resource_size_t offset, unsigned long size,
77339 void __iomem *addr);
77340 -extern void mmiotrace_iounmap(volatile void __iomem *addr);
77341 +extern void mmiotrace_iounmap(const volatile void __iomem *addr);
77342
77343 /* For anyone to insert markers. Remember trailing newline. */
77344 extern __printf(1, 2) int mmiotrace_printk(const char *fmt, ...);
77345 @@ -66,7 +66,7 @@ static inline void mmiotrace_ioremap(resource_size_t offset,
77346 {
77347 }
77348
77349 -static inline void mmiotrace_iounmap(volatile void __iomem *addr)
77350 +static inline void mmiotrace_iounmap(const volatile void __iomem *addr)
77351 {
77352 }
77353
77354 diff --git a/include/linux/mmzone.h b/include/linux/mmzone.h
77355 index bd791e4..8617c34f 100644
77356 --- a/include/linux/mmzone.h
77357 +++ b/include/linux/mmzone.h
77358 @@ -396,7 +396,7 @@ struct zone {
77359 unsigned long flags; /* zone flags, see below */
77360
77361 /* Zone statistics */
77362 - atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77363 + atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
77364
77365 /*
77366 * The target ratio of ACTIVE_ANON to INACTIVE_ANON pages on
77367 diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
77368 index 45e9214..a7227d6 100644
77369 --- a/include/linux/mod_devicetable.h
77370 +++ b/include/linux/mod_devicetable.h
77371 @@ -13,7 +13,7 @@
77372 typedef unsigned long kernel_ulong_t;
77373 #endif
77374
77375 -#define PCI_ANY_ID (~0)
77376 +#define PCI_ANY_ID ((__u16)~0)
77377
77378 struct pci_device_id {
77379 __u32 vendor, device; /* Vendor and device ID or PCI_ANY_ID*/
77380 @@ -139,7 +139,7 @@ struct usb_device_id {
77381 #define USB_DEVICE_ID_MATCH_INT_PROTOCOL 0x0200
77382 #define USB_DEVICE_ID_MATCH_INT_NUMBER 0x0400
77383
77384 -#define HID_ANY_ID (~0)
77385 +#define HID_ANY_ID (~0U)
77386 #define HID_BUS_ANY 0xffff
77387 #define HID_GROUP_ANY 0x0000
77388
77389 @@ -467,7 +467,7 @@ struct dmi_system_id {
77390 const char *ident;
77391 struct dmi_strmatch matches[4];
77392 void *driver_data;
77393 -};
77394 +} __do_const;
77395 /*
77396 * struct dmi_device_id appears during expansion of
77397 * "MODULE_DEVICE_TABLE(dmi, x)". Compiler doesn't look inside it
77398 diff --git a/include/linux/module.h b/include/linux/module.h
77399 index 05f2447..2aee07c 100644
77400 --- a/include/linux/module.h
77401 +++ b/include/linux/module.h
77402 @@ -17,9 +17,11 @@
77403 #include <linux/moduleparam.h>
77404 #include <linux/tracepoint.h>
77405 #include <linux/export.h>
77406 +#include <linux/fs.h>
77407
77408 #include <linux/percpu.h>
77409 #include <asm/module.h>
77410 +#include <asm/pgtable.h>
77411
77412 /* In stripped ARM and x86-64 modules, ~ is surprisingly rare. */
77413 #define MODULE_SIG_STRING "~Module signature appended~\n"
77414 @@ -55,12 +57,13 @@ struct module_attribute {
77415 int (*test)(struct module *);
77416 void (*free)(struct module *);
77417 };
77418 +typedef struct module_attribute __no_const module_attribute_no_const;
77419
77420 struct module_version_attribute {
77421 struct module_attribute mattr;
77422 const char *module_name;
77423 const char *version;
77424 -} __attribute__ ((__aligned__(sizeof(void *))));
77425 +} __do_const __attribute__ ((__aligned__(sizeof(void *))));
77426
77427 extern ssize_t __modver_version_show(struct module_attribute *,
77428 struct module_kobject *, char *);
77429 @@ -238,7 +241,7 @@ struct module
77430
77431 /* Sysfs stuff. */
77432 struct module_kobject mkobj;
77433 - struct module_attribute *modinfo_attrs;
77434 + module_attribute_no_const *modinfo_attrs;
77435 const char *version;
77436 const char *srcversion;
77437 struct kobject *holders_dir;
77438 @@ -287,19 +290,16 @@ struct module
77439 int (*init)(void);
77440
77441 /* If this is non-NULL, vfree after init() returns */
77442 - void *module_init;
77443 + void *module_init_rx, *module_init_rw;
77444
77445 /* Here is the actual code + data, vfree'd on unload. */
77446 - void *module_core;
77447 + void *module_core_rx, *module_core_rw;
77448
77449 /* Here are the sizes of the init and core sections */
77450 - unsigned int init_size, core_size;
77451 + unsigned int init_size_rw, core_size_rw;
77452
77453 /* The size of the executable code in each section. */
77454 - unsigned int init_text_size, core_text_size;
77455 -
77456 - /* Size of RO sections of the module (text+rodata) */
77457 - unsigned int init_ro_size, core_ro_size;
77458 + unsigned int init_size_rx, core_size_rx;
77459
77460 /* Arch-specific module values */
77461 struct mod_arch_specific arch;
77462 @@ -355,6 +355,10 @@ struct module
77463 #ifdef CONFIG_EVENT_TRACING
77464 struct ftrace_event_call **trace_events;
77465 unsigned int num_trace_events;
77466 + struct file_operations trace_id;
77467 + struct file_operations trace_enable;
77468 + struct file_operations trace_format;
77469 + struct file_operations trace_filter;
77470 #endif
77471 #ifdef CONFIG_FTRACE_MCOUNT_RECORD
77472 unsigned int num_ftrace_callsites;
77473 @@ -402,16 +406,46 @@ bool is_module_address(unsigned long addr);
77474 bool is_module_percpu_address(unsigned long addr);
77475 bool is_module_text_address(unsigned long addr);
77476
77477 +static inline int within_module_range(unsigned long addr, void *start, unsigned long size)
77478 +{
77479 +
77480 +#ifdef CONFIG_PAX_KERNEXEC
77481 + if (ktla_ktva(addr) >= (unsigned long)start &&
77482 + ktla_ktva(addr) < (unsigned long)start + size)
77483 + return 1;
77484 +#endif
77485 +
77486 + return ((void *)addr >= start && (void *)addr < start + size);
77487 +}
77488 +
77489 +static inline int within_module_core_rx(unsigned long addr, const struct module *mod)
77490 +{
77491 + return within_module_range(addr, mod->module_core_rx, mod->core_size_rx);
77492 +}
77493 +
77494 +static inline int within_module_core_rw(unsigned long addr, const struct module *mod)
77495 +{
77496 + return within_module_range(addr, mod->module_core_rw, mod->core_size_rw);
77497 +}
77498 +
77499 +static inline int within_module_init_rx(unsigned long addr, const struct module *mod)
77500 +{
77501 + return within_module_range(addr, mod->module_init_rx, mod->init_size_rx);
77502 +}
77503 +
77504 +static inline int within_module_init_rw(unsigned long addr, const struct module *mod)
77505 +{
77506 + return within_module_range(addr, mod->module_init_rw, mod->init_size_rw);
77507 +}
77508 +
77509 static inline int within_module_core(unsigned long addr, const struct module *mod)
77510 {
77511 - return (unsigned long)mod->module_core <= addr &&
77512 - addr < (unsigned long)mod->module_core + mod->core_size;
77513 + return within_module_core_rx(addr, mod) || within_module_core_rw(addr, mod);
77514 }
77515
77516 static inline int within_module_init(unsigned long addr, const struct module *mod)
77517 {
77518 - return (unsigned long)mod->module_init <= addr &&
77519 - addr < (unsigned long)mod->module_init + mod->init_size;
77520 + return within_module_init_rx(addr, mod) || within_module_init_rw(addr, mod);
77521 }
77522
77523 /* Search for module by name: must hold module_mutex. */
77524 diff --git a/include/linux/moduleloader.h b/include/linux/moduleloader.h
77525 index 560ca53..ef621ef 100644
77526 --- a/include/linux/moduleloader.h
77527 +++ b/include/linux/moduleloader.h
77528 @@ -25,9 +25,21 @@ unsigned int arch_mod_section_prepend(struct module *mod, unsigned int section);
77529 sections. Returns NULL on failure. */
77530 void *module_alloc(unsigned long size);
77531
77532 +#ifdef CONFIG_PAX_KERNEXEC
77533 +void *module_alloc_exec(unsigned long size);
77534 +#else
77535 +#define module_alloc_exec(x) module_alloc(x)
77536 +#endif
77537 +
77538 /* Free memory returned from module_alloc. */
77539 void module_free(struct module *mod, void *module_region);
77540
77541 +#ifdef CONFIG_PAX_KERNEXEC
77542 +void module_free_exec(struct module *mod, void *module_region);
77543 +#else
77544 +#define module_free_exec(x, y) module_free((x), (y))
77545 +#endif
77546 +
77547 /*
77548 * Apply the given relocation to the (simplified) ELF. Return -error
77549 * or 0.
77550 @@ -45,7 +57,9 @@ static inline int apply_relocate(Elf_Shdr *sechdrs,
77551 unsigned int relsec,
77552 struct module *me)
77553 {
77554 +#ifdef CONFIG_MODULES
77555 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
77556 +#endif
77557 return -ENOEXEC;
77558 }
77559 #endif
77560 @@ -67,7 +81,9 @@ static inline int apply_relocate_add(Elf_Shdr *sechdrs,
77561 unsigned int relsec,
77562 struct module *me)
77563 {
77564 +#ifdef CONFIG_MODULES
77565 printk(KERN_ERR "module %s: REL relocation unsupported\n", me->name);
77566 +#endif
77567 return -ENOEXEC;
77568 }
77569 #endif
77570 diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h
77571 index c3eb102..073c4a6 100644
77572 --- a/include/linux/moduleparam.h
77573 +++ b/include/linux/moduleparam.h
77574 @@ -295,7 +295,7 @@ static inline void __kernel_param_unlock(void)
77575 * @len is usually just sizeof(string).
77576 */
77577 #define module_param_string(name, string, len, perm) \
77578 - static const struct kparam_string __param_string_##name \
77579 + static const struct kparam_string __param_string_##name __used \
77580 = { len, string }; \
77581 __module_param_call(MODULE_PARAM_PREFIX, name, \
77582 &param_ops_string, \
77583 @@ -434,7 +434,7 @@ extern int param_set_bint(const char *val, const struct kernel_param *kp);
77584 */
77585 #define module_param_array_named(name, array, type, nump, perm) \
77586 param_check_##type(name, &(array)[0]); \
77587 - static const struct kparam_array __param_arr_##name \
77588 + static const struct kparam_array __param_arr_##name __used \
77589 = { .max = ARRAY_SIZE(array), .num = nump, \
77590 .ops = &param_ops_##type, \
77591 .elemsize = sizeof(array[0]), .elem = array }; \
77592 diff --git a/include/linux/namei.h b/include/linux/namei.h
77593 index 8e47bc7..c70fd73 100644
77594 --- a/include/linux/namei.h
77595 +++ b/include/linux/namei.h
77596 @@ -19,7 +19,7 @@ struct nameidata {
77597 unsigned seq;
77598 int last_type;
77599 unsigned depth;
77600 - char *saved_names[MAX_NESTED_LINKS + 1];
77601 + const char *saved_names[MAX_NESTED_LINKS + 1];
77602 };
77603
77604 /*
77605 @@ -83,12 +83,12 @@ extern void unlock_rename(struct dentry *, struct dentry *);
77606
77607 extern void nd_jump_link(struct nameidata *nd, struct path *path);
77608
77609 -static inline void nd_set_link(struct nameidata *nd, char *path)
77610 +static inline void nd_set_link(struct nameidata *nd, const char *path)
77611 {
77612 nd->saved_names[nd->depth] = path;
77613 }
77614
77615 -static inline char *nd_get_link(struct nameidata *nd)
77616 +static inline const char *nd_get_link(const struct nameidata *nd)
77617 {
77618 return nd->saved_names[nd->depth];
77619 }
77620 diff --git a/include/linux/net.h b/include/linux/net.h
77621 index 8bd9d92..08b1c20 100644
77622 --- a/include/linux/net.h
77623 +++ b/include/linux/net.h
77624 @@ -191,7 +191,7 @@ struct net_proto_family {
77625 int (*create)(struct net *net, struct socket *sock,
77626 int protocol, int kern);
77627 struct module *owner;
77628 -};
77629 +} __do_const;
77630
77631 struct iovec;
77632 struct kvec;
77633 diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
77634 index 25f5d2d1..5cf2120 100644
77635 --- a/include/linux/netdevice.h
77636 +++ b/include/linux/netdevice.h
77637 @@ -1098,6 +1098,7 @@ struct net_device_ops {
77638 sa_family_t sa_family,
77639 __be16 port);
77640 };
77641 +typedef struct net_device_ops __no_const net_device_ops_no_const;
77642
77643 /*
77644 * The DEVICE structure.
77645 @@ -1169,7 +1170,7 @@ struct net_device {
77646 int iflink;
77647
77648 struct net_device_stats stats;
77649 - atomic_long_t rx_dropped; /* dropped packets by core network
77650 + atomic_long_unchecked_t rx_dropped; /* dropped packets by core network
77651 * Do not use this in drivers.
77652 */
77653
77654 diff --git a/include/linux/netfilter.h b/include/linux/netfilter.h
77655 index 708fe72ab9..77084a3 100644
77656 --- a/include/linux/netfilter.h
77657 +++ b/include/linux/netfilter.h
77658 @@ -82,7 +82,7 @@ struct nf_sockopt_ops {
77659 #endif
77660 /* Use the module struct to lock set/get code in place */
77661 struct module *owner;
77662 -};
77663 +} __do_const;
77664
77665 /* Function to register/unregister hook points. */
77666 int nf_register_hook(struct nf_hook_ops *reg);
77667 diff --git a/include/linux/netfilter/nfnetlink.h b/include/linux/netfilter/nfnetlink.h
77668 index cadb740..d7c37c0 100644
77669 --- a/include/linux/netfilter/nfnetlink.h
77670 +++ b/include/linux/netfilter/nfnetlink.h
77671 @@ -16,7 +16,7 @@ struct nfnl_callback {
77672 const struct nlattr * const cda[]);
77673 const struct nla_policy *policy; /* netlink attribute policy */
77674 const u_int16_t attr_count; /* number of nlattr's */
77675 -};
77676 +} __do_const;
77677
77678 struct nfnetlink_subsystem {
77679 const char *name;
77680 diff --git a/include/linux/netfilter/xt_gradm.h b/include/linux/netfilter/xt_gradm.h
77681 new file mode 100644
77682 index 0000000..33f4af8
77683 --- /dev/null
77684 +++ b/include/linux/netfilter/xt_gradm.h
77685 @@ -0,0 +1,9 @@
77686 +#ifndef _LINUX_NETFILTER_XT_GRADM_H
77687 +#define _LINUX_NETFILTER_XT_GRADM_H 1
77688 +
77689 +struct xt_gradm_mtinfo {
77690 + __u16 flags;
77691 + __u16 invflags;
77692 +};
77693 +
77694 +#endif
77695 diff --git a/include/linux/nls.h b/include/linux/nls.h
77696 index 5dc635f..35f5e11 100644
77697 --- a/include/linux/nls.h
77698 +++ b/include/linux/nls.h
77699 @@ -31,7 +31,7 @@ struct nls_table {
77700 const unsigned char *charset2upper;
77701 struct module *owner;
77702 struct nls_table *next;
77703 -};
77704 +} __do_const;
77705
77706 /* this value hold the maximum octet of charset */
77707 #define NLS_MAX_CHARSET_SIZE 6 /* for UTF-8 */
77708 diff --git a/include/linux/notifier.h b/include/linux/notifier.h
77709 index d14a4c3..a078786 100644
77710 --- a/include/linux/notifier.h
77711 +++ b/include/linux/notifier.h
77712 @@ -54,7 +54,8 @@ struct notifier_block {
77713 notifier_fn_t notifier_call;
77714 struct notifier_block __rcu *next;
77715 int priority;
77716 -};
77717 +} __do_const;
77718 +typedef struct notifier_block __no_const notifier_block_no_const;
77719
77720 struct atomic_notifier_head {
77721 spinlock_t lock;
77722 diff --git a/include/linux/oprofile.h b/include/linux/oprofile.h
77723 index b2a0f15..4d7da32 100644
77724 --- a/include/linux/oprofile.h
77725 +++ b/include/linux/oprofile.h
77726 @@ -138,9 +138,9 @@ int oprofilefs_create_ulong(struct dentry * root,
77727 int oprofilefs_create_ro_ulong(struct dentry * root,
77728 char const * name, ulong * val);
77729
77730 -/** Create a file for read-only access to an atomic_t. */
77731 +/** Create a file for read-only access to an atomic_unchecked_t. */
77732 int oprofilefs_create_ro_atomic(struct dentry * root,
77733 - char const * name, atomic_t * val);
77734 + char const * name, atomic_unchecked_t * val);
77735
77736 /** create a directory */
77737 struct dentry *oprofilefs_mkdir(struct dentry *parent, char const *name);
77738 diff --git a/include/linux/pci_hotplug.h b/include/linux/pci_hotplug.h
77739 index 430dd96..544e26e 100644
77740 --- a/include/linux/pci_hotplug.h
77741 +++ b/include/linux/pci_hotplug.h
77742 @@ -71,7 +71,8 @@ struct hotplug_slot_ops {
77743 int (*get_latch_status) (struct hotplug_slot *slot, u8 *value);
77744 int (*get_adapter_status) (struct hotplug_slot *slot, u8 *value);
77745 int (*reset_slot) (struct hotplug_slot *slot, int probe);
77746 -};
77747 +} __do_const;
77748 +typedef struct hotplug_slot_ops __no_const hotplug_slot_ops_no_const;
77749
77750 /**
77751 * struct hotplug_slot_info - used to notify the hotplug pci core of the state of the slot
77752 diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
77753 index c8ba627..24bdfa8 100644
77754 --- a/include/linux/perf_event.h
77755 +++ b/include/linux/perf_event.h
77756 @@ -327,8 +327,8 @@ struct perf_event {
77757
77758 enum perf_event_active_state state;
77759 unsigned int attach_state;
77760 - local64_t count;
77761 - atomic64_t child_count;
77762 + local64_t count; /* PaX: fix it one day */
77763 + atomic64_unchecked_t child_count;
77764
77765 /*
77766 * These are the total time in nanoseconds that the event
77767 @@ -379,8 +379,8 @@ struct perf_event {
77768 * These accumulate total time (in nanoseconds) that children
77769 * events have been enabled and running, respectively.
77770 */
77771 - atomic64_t child_total_time_enabled;
77772 - atomic64_t child_total_time_running;
77773 + atomic64_unchecked_t child_total_time_enabled;
77774 + atomic64_unchecked_t child_total_time_running;
77775
77776 /*
77777 * Protect attach/detach and child_list:
77778 @@ -702,7 +702,7 @@ static inline void perf_callchain_store(struct perf_callchain_entry *entry, u64
77779 entry->ip[entry->nr++] = ip;
77780 }
77781
77782 -extern int sysctl_perf_event_paranoid;
77783 +extern int sysctl_perf_event_legitimately_concerned;
77784 extern int sysctl_perf_event_mlock;
77785 extern int sysctl_perf_event_sample_rate;
77786 extern int sysctl_perf_cpu_time_max_percent;
77787 @@ -717,19 +717,24 @@ extern int perf_cpu_time_max_percent_handler(struct ctl_table *table, int write,
77788 loff_t *ppos);
77789
77790
77791 +static inline bool perf_paranoid_any(void)
77792 +{
77793 + return sysctl_perf_event_legitimately_concerned > 2;
77794 +}
77795 +
77796 static inline bool perf_paranoid_tracepoint_raw(void)
77797 {
77798 - return sysctl_perf_event_paranoid > -1;
77799 + return sysctl_perf_event_legitimately_concerned > -1;
77800 }
77801
77802 static inline bool perf_paranoid_cpu(void)
77803 {
77804 - return sysctl_perf_event_paranoid > 0;
77805 + return sysctl_perf_event_legitimately_concerned > 0;
77806 }
77807
77808 static inline bool perf_paranoid_kernel(void)
77809 {
77810 - return sysctl_perf_event_paranoid > 1;
77811 + return sysctl_perf_event_legitimately_concerned > 1;
77812 }
77813
77814 extern void perf_event_init(void);
77815 @@ -845,7 +850,7 @@ struct perf_pmu_events_attr {
77816 struct device_attribute attr;
77817 u64 id;
77818 const char *event_str;
77819 -};
77820 +} __do_const;
77821
77822 #define PMU_EVENT_ATTR(_name, _var, _id, _show) \
77823 static struct perf_pmu_events_attr _var = { \
77824 diff --git a/include/linux/pipe_fs_i.h b/include/linux/pipe_fs_i.h
77825 index b8809fe..ae4ccd0 100644
77826 --- a/include/linux/pipe_fs_i.h
77827 +++ b/include/linux/pipe_fs_i.h
77828 @@ -47,10 +47,10 @@ struct pipe_inode_info {
77829 struct mutex mutex;
77830 wait_queue_head_t wait;
77831 unsigned int nrbufs, curbuf, buffers;
77832 - unsigned int readers;
77833 - unsigned int writers;
77834 - unsigned int files;
77835 - unsigned int waiting_writers;
77836 + atomic_t readers;
77837 + atomic_t writers;
77838 + atomic_t files;
77839 + atomic_t waiting_writers;
77840 unsigned int r_counter;
77841 unsigned int w_counter;
77842 struct page *tmp_page;
77843 diff --git a/include/linux/platform_data/usb-ehci-s5p.h b/include/linux/platform_data/usb-ehci-s5p.h
77844 index 5f28cae..3d23723 100644
77845 --- a/include/linux/platform_data/usb-ehci-s5p.h
77846 +++ b/include/linux/platform_data/usb-ehci-s5p.h
77847 @@ -14,7 +14,7 @@
77848 struct s5p_ehci_platdata {
77849 int (*phy_init)(struct platform_device *pdev, int type);
77850 int (*phy_exit)(struct platform_device *pdev, int type);
77851 -};
77852 +} __no_const;
77853
77854 extern void s5p_ehci_set_platdata(struct s5p_ehci_platdata *pd);
77855
77856 diff --git a/include/linux/platform_data/usb-ohci-exynos.h b/include/linux/platform_data/usb-ohci-exynos.h
77857 index c256c59..8ea94c7 100644
77858 --- a/include/linux/platform_data/usb-ohci-exynos.h
77859 +++ b/include/linux/platform_data/usb-ohci-exynos.h
77860 @@ -14,7 +14,7 @@
77861 struct exynos4_ohci_platdata {
77862 int (*phy_init)(struct platform_device *pdev, int type);
77863 int (*phy_exit)(struct platform_device *pdev, int type);
77864 -};
77865 +} __no_const;
77866
77867 extern void exynos4_ohci_set_platdata(struct exynos4_ohci_platdata *pd);
77868
77869 diff --git a/include/linux/pm.h b/include/linux/pm.h
77870 index a224c7f..92d8a97 100644
77871 --- a/include/linux/pm.h
77872 +++ b/include/linux/pm.h
77873 @@ -576,6 +576,7 @@ extern int dev_pm_put_subsys_data(struct device *dev);
77874 struct dev_pm_domain {
77875 struct dev_pm_ops ops;
77876 };
77877 +typedef struct dev_pm_domain __no_const dev_pm_domain_no_const;
77878
77879 /*
77880 * The PM_EVENT_ messages are also used by drivers implementing the legacy
77881 diff --git a/include/linux/pm_domain.h b/include/linux/pm_domain.h
77882 index 7c1d252..c5c773e 100644
77883 --- a/include/linux/pm_domain.h
77884 +++ b/include/linux/pm_domain.h
77885 @@ -48,7 +48,7 @@ struct gpd_dev_ops {
77886
77887 struct gpd_cpu_data {
77888 unsigned int saved_exit_latency;
77889 - struct cpuidle_state *idle_state;
77890 + cpuidle_state_no_const *idle_state;
77891 };
77892
77893 struct generic_pm_domain {
77894 diff --git a/include/linux/pm_runtime.h b/include/linux/pm_runtime.h
77895 index 6fa7cea..7bf6415 100644
77896 --- a/include/linux/pm_runtime.h
77897 +++ b/include/linux/pm_runtime.h
77898 @@ -103,7 +103,7 @@ static inline bool pm_runtime_callbacks_present(struct device *dev)
77899
77900 static inline void pm_runtime_mark_last_busy(struct device *dev)
77901 {
77902 - ACCESS_ONCE(dev->power.last_busy) = jiffies;
77903 + ACCESS_ONCE_RW(dev->power.last_busy) = jiffies;
77904 }
77905
77906 #else /* !CONFIG_PM_RUNTIME */
77907 diff --git a/include/linux/pnp.h b/include/linux/pnp.h
77908 index 195aafc..49a7bc2 100644
77909 --- a/include/linux/pnp.h
77910 +++ b/include/linux/pnp.h
77911 @@ -297,7 +297,7 @@ static inline void pnp_set_drvdata(struct pnp_dev *pdev, void *data)
77912 struct pnp_fixup {
77913 char id[7];
77914 void (*quirk_function) (struct pnp_dev * dev); /* fixup function */
77915 -};
77916 +} __do_const;
77917
77918 /* config parameters */
77919 #define PNP_CONFIG_NORMAL 0x0001
77920 diff --git a/include/linux/poison.h b/include/linux/poison.h
77921 index 2110a81..13a11bb 100644
77922 --- a/include/linux/poison.h
77923 +++ b/include/linux/poison.h
77924 @@ -19,8 +19,8 @@
77925 * under normal circumstances, used to verify that nobody uses
77926 * non-initialized list entries.
77927 */
77928 -#define LIST_POISON1 ((void *) 0x00100100 + POISON_POINTER_DELTA)
77929 -#define LIST_POISON2 ((void *) 0x00200200 + POISON_POINTER_DELTA)
77930 +#define LIST_POISON1 ((void *) (long)0xFFFFFF01)
77931 +#define LIST_POISON2 ((void *) (long)0xFFFFFF02)
77932
77933 /********** include/linux/timer.h **********/
77934 /*
77935 diff --git a/include/linux/power/smartreflex.h b/include/linux/power/smartreflex.h
77936 index d8b187c3..9a9257a 100644
77937 --- a/include/linux/power/smartreflex.h
77938 +++ b/include/linux/power/smartreflex.h
77939 @@ -238,7 +238,7 @@ struct omap_sr_class_data {
77940 int (*notify)(struct omap_sr *sr, u32 status);
77941 u8 notify_flags;
77942 u8 class_type;
77943 -};
77944 +} __do_const;
77945
77946 /**
77947 * struct omap_sr_nvalue_table - Smartreflex n-target value info
77948 diff --git a/include/linux/ppp-comp.h b/include/linux/ppp-comp.h
77949 index 4ea1d37..80f4b33 100644
77950 --- a/include/linux/ppp-comp.h
77951 +++ b/include/linux/ppp-comp.h
77952 @@ -84,7 +84,7 @@ struct compressor {
77953 struct module *owner;
77954 /* Extra skb space needed by the compressor algorithm */
77955 unsigned int comp_extra;
77956 -};
77957 +} __do_const;
77958
77959 /*
77960 * The return value from decompress routine is the length of the
77961 diff --git a/include/linux/preempt.h b/include/linux/preempt.h
77962 index f5d4723..a6ea2fa 100644
77963 --- a/include/linux/preempt.h
77964 +++ b/include/linux/preempt.h
77965 @@ -18,8 +18,13 @@
77966 # define sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77967 #endif
77968
77969 +#define raw_add_preempt_count(val) do { preempt_count() += (val); } while (0)
77970 +#define raw_sub_preempt_count(val) do { preempt_count() -= (val); } while (0)
77971 +
77972 #define inc_preempt_count() add_preempt_count(1)
77973 +#define raw_inc_preempt_count() raw_add_preempt_count(1)
77974 #define dec_preempt_count() sub_preempt_count(1)
77975 +#define raw_dec_preempt_count() raw_sub_preempt_count(1)
77976
77977 #define preempt_count() (current_thread_info()->preempt_count)
77978
77979 @@ -64,6 +69,12 @@ do { \
77980 barrier(); \
77981 } while (0)
77982
77983 +#define raw_preempt_disable() \
77984 +do { \
77985 + raw_inc_preempt_count(); \
77986 + barrier(); \
77987 +} while (0)
77988 +
77989 #define sched_preempt_enable_no_resched() \
77990 do { \
77991 barrier(); \
77992 @@ -72,6 +83,12 @@ do { \
77993
77994 #define preempt_enable_no_resched() sched_preempt_enable_no_resched()
77995
77996 +#define raw_preempt_enable_no_resched() \
77997 +do { \
77998 + barrier(); \
77999 + raw_dec_preempt_count(); \
78000 +} while (0)
78001 +
78002 #define preempt_enable() \
78003 do { \
78004 preempt_enable_no_resched(); \
78005 @@ -116,8 +133,10 @@ do { \
78006 * region.
78007 */
78008 #define preempt_disable() barrier()
78009 +#define raw_preempt_disable() barrier()
78010 #define sched_preempt_enable_no_resched() barrier()
78011 #define preempt_enable_no_resched() barrier()
78012 +#define raw_preempt_enable_no_resched() barrier()
78013 #define preempt_enable() barrier()
78014
78015 #define preempt_disable_notrace() barrier()
78016 diff --git a/include/linux/printk.h b/include/linux/printk.h
78017 index e6131a78..8e9fb61 100644
78018 --- a/include/linux/printk.h
78019 +++ b/include/linux/printk.h
78020 @@ -106,6 +106,8 @@ static inline __printf(1, 2) __cold
78021 void early_printk(const char *s, ...) { }
78022 #endif
78023
78024 +extern int kptr_restrict;
78025 +
78026 #ifdef CONFIG_PRINTK
78027 asmlinkage __printf(5, 0)
78028 int vprintk_emit(int facility, int level,
78029 @@ -140,7 +142,6 @@ extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
78030
78031 extern int printk_delay_msec;
78032 extern int dmesg_restrict;
78033 -extern int kptr_restrict;
78034
78035 extern void wake_up_klogd(void);
78036
78037 diff --git a/include/linux/proc_fs.h b/include/linux/proc_fs.h
78038 index 608e60a..c26f864 100644
78039 --- a/include/linux/proc_fs.h
78040 +++ b/include/linux/proc_fs.h
78041 @@ -34,6 +34,19 @@ static inline struct proc_dir_entry *proc_create(
78042 return proc_create_data(name, mode, parent, proc_fops, NULL);
78043 }
78044
78045 +static inline struct proc_dir_entry *proc_create_grsec(const char *name, umode_t mode,
78046 + struct proc_dir_entry *parent, const struct file_operations *proc_fops)
78047 +{
78048 +#ifdef CONFIG_GRKERNSEC_PROC_USER
78049 + return proc_create_data(name, S_IRUSR, parent, proc_fops, NULL);
78050 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
78051 + return proc_create_data(name, S_IRUSR | S_IRGRP, parent, proc_fops, NULL);
78052 +#else
78053 + return proc_create_data(name, mode, parent, proc_fops, NULL);
78054 +#endif
78055 +}
78056 +
78057 +
78058 extern void proc_set_size(struct proc_dir_entry *, loff_t);
78059 extern void proc_set_user(struct proc_dir_entry *, kuid_t, kgid_t);
78060 extern void *PDE_DATA(const struct inode *);
78061 diff --git a/include/linux/proc_ns.h b/include/linux/proc_ns.h
78062 index 34a1e10..03a6d03 100644
78063 --- a/include/linux/proc_ns.h
78064 +++ b/include/linux/proc_ns.h
78065 @@ -14,7 +14,7 @@ struct proc_ns_operations {
78066 void (*put)(void *ns);
78067 int (*install)(struct nsproxy *nsproxy, void *ns);
78068 unsigned int (*inum)(void *ns);
78069 -};
78070 +} __do_const;
78071
78072 struct proc_ns {
78073 void *ns;
78074 diff --git a/include/linux/quota.h b/include/linux/quota.h
78075 index cc7494a..1e27036 100644
78076 --- a/include/linux/quota.h
78077 +++ b/include/linux/quota.h
78078 @@ -70,7 +70,7 @@ struct kqid { /* Type in which we store the quota identifier */
78079
78080 extern bool qid_eq(struct kqid left, struct kqid right);
78081 extern bool qid_lt(struct kqid left, struct kqid right);
78082 -extern qid_t from_kqid(struct user_namespace *to, struct kqid qid);
78083 +extern qid_t from_kqid(struct user_namespace *to, struct kqid qid) __intentional_overflow(-1);
78084 extern qid_t from_kqid_munged(struct user_namespace *to, struct kqid qid);
78085 extern bool qid_valid(struct kqid qid);
78086
78087 diff --git a/include/linux/random.h b/include/linux/random.h
78088 index bf9085e..1e8bbcf 100644
78089 --- a/include/linux/random.h
78090 +++ b/include/linux/random.h
78091 @@ -10,9 +10,19 @@
78092
78093
78094 extern void add_device_randomness(const void *, unsigned int);
78095 +
78096 +static inline void add_latent_entropy(void)
78097 +{
78098 +
78099 +#ifdef LATENT_ENTROPY_PLUGIN
78100 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
78101 +#endif
78102 +
78103 +}
78104 +
78105 extern void add_input_randomness(unsigned int type, unsigned int code,
78106 - unsigned int value);
78107 -extern void add_interrupt_randomness(int irq, int irq_flags);
78108 + unsigned int value) __latent_entropy;
78109 +extern void add_interrupt_randomness(int irq, int irq_flags) __latent_entropy;
78110
78111 extern void get_random_bytes(void *buf, int nbytes);
78112 extern void get_random_bytes_arch(void *buf, int nbytes);
78113 @@ -23,16 +33,21 @@ extern int random_int_secret_init(void);
78114 extern const struct file_operations random_fops, urandom_fops;
78115 #endif
78116
78117 -unsigned int get_random_int(void);
78118 +unsigned int __intentional_overflow(-1) get_random_int(void);
78119 unsigned long randomize_range(unsigned long start, unsigned long end, unsigned long len);
78120
78121 -u32 prandom_u32(void);
78122 +u32 prandom_u32(void) __intentional_overflow(-1);
78123 void prandom_bytes(void *buf, int nbytes);
78124 void prandom_seed(u32 seed);
78125
78126 u32 prandom_u32_state(struct rnd_state *);
78127 void prandom_bytes_state(struct rnd_state *state, void *buf, int nbytes);
78128
78129 +static inline unsigned long __intentional_overflow(-1) pax_get_random_long(void)
78130 +{
78131 + return prandom_u32() + (sizeof(long) > 4 ? (unsigned long)prandom_u32() << 32 : 0);
78132 +}
78133 +
78134 /*
78135 * Handle minimum values for seeds
78136 */
78137 diff --git a/include/linux/rculist.h b/include/linux/rculist.h
78138 index 4106721..132d42c 100644
78139 --- a/include/linux/rculist.h
78140 +++ b/include/linux/rculist.h
78141 @@ -44,6 +44,9 @@ extern void __list_add_rcu(struct list_head *new,
78142 struct list_head *prev, struct list_head *next);
78143 #endif
78144
78145 +extern void __pax_list_add_rcu(struct list_head *new,
78146 + struct list_head *prev, struct list_head *next);
78147 +
78148 /**
78149 * list_add_rcu - add a new entry to rcu-protected list
78150 * @new: new entry to be added
78151 @@ -65,6 +68,11 @@ static inline void list_add_rcu(struct list_head *new, struct list_head *head)
78152 __list_add_rcu(new, head, head->next);
78153 }
78154
78155 +static inline void pax_list_add_rcu(struct list_head *new, struct list_head *head)
78156 +{
78157 + __pax_list_add_rcu(new, head, head->next);
78158 +}
78159 +
78160 /**
78161 * list_add_tail_rcu - add a new entry to rcu-protected list
78162 * @new: new entry to be added
78163 @@ -87,6 +95,12 @@ static inline void list_add_tail_rcu(struct list_head *new,
78164 __list_add_rcu(new, head->prev, head);
78165 }
78166
78167 +static inline void pax_list_add_tail_rcu(struct list_head *new,
78168 + struct list_head *head)
78169 +{
78170 + __pax_list_add_rcu(new, head->prev, head);
78171 +}
78172 +
78173 /**
78174 * list_del_rcu - deletes entry from list without re-initialization
78175 * @entry: the element to delete from the list.
78176 @@ -117,6 +131,8 @@ static inline void list_del_rcu(struct list_head *entry)
78177 entry->prev = LIST_POISON2;
78178 }
78179
78180 +extern void pax_list_del_rcu(struct list_head *entry);
78181 +
78182 /**
78183 * hlist_del_init_rcu - deletes entry from hash list with re-initialization
78184 * @n: the element to delete from the hash list.
78185 diff --git a/include/linux/reboot.h b/include/linux/reboot.h
78186 index 9e7db9e..7d4fd72 100644
78187 --- a/include/linux/reboot.h
78188 +++ b/include/linux/reboot.h
78189 @@ -44,9 +44,9 @@ extern int unregister_reboot_notifier(struct notifier_block *);
78190 */
78191
78192 extern void migrate_to_reboot_cpu(void);
78193 -extern void machine_restart(char *cmd);
78194 -extern void machine_halt(void);
78195 -extern void machine_power_off(void);
78196 +extern void machine_restart(char *cmd) __noreturn;
78197 +extern void machine_halt(void) __noreturn;
78198 +extern void machine_power_off(void) __noreturn;
78199
78200 extern void machine_shutdown(void);
78201 struct pt_regs;
78202 @@ -57,9 +57,9 @@ extern void machine_crash_shutdown(struct pt_regs *);
78203 */
78204
78205 extern void kernel_restart_prepare(char *cmd);
78206 -extern void kernel_restart(char *cmd);
78207 -extern void kernel_halt(void);
78208 -extern void kernel_power_off(void);
78209 +extern void kernel_restart(char *cmd) __noreturn;
78210 +extern void kernel_halt(void) __noreturn;
78211 +extern void kernel_power_off(void) __noreturn;
78212
78213 extern int C_A_D; /* for sysctl */
78214 void ctrl_alt_del(void);
78215 @@ -73,7 +73,7 @@ extern int orderly_poweroff(bool force);
78216 * Emergency restart, callable from an interrupt handler.
78217 */
78218
78219 -extern void emergency_restart(void);
78220 +extern void emergency_restart(void) __noreturn;
78221 #include <asm/emergency-restart.h>
78222
78223 #endif /* _LINUX_REBOOT_H */
78224 diff --git a/include/linux/regset.h b/include/linux/regset.h
78225 index 8e0c9fe..ac4d221 100644
78226 --- a/include/linux/regset.h
78227 +++ b/include/linux/regset.h
78228 @@ -161,7 +161,8 @@ struct user_regset {
78229 unsigned int align;
78230 unsigned int bias;
78231 unsigned int core_note_type;
78232 -};
78233 +} __do_const;
78234 +typedef struct user_regset __no_const user_regset_no_const;
78235
78236 /**
78237 * struct user_regset_view - available regsets
78238 diff --git a/include/linux/relay.h b/include/linux/relay.h
78239 index d7c8359..818daf5 100644
78240 --- a/include/linux/relay.h
78241 +++ b/include/linux/relay.h
78242 @@ -157,7 +157,7 @@ struct rchan_callbacks
78243 * The callback should return 0 if successful, negative if not.
78244 */
78245 int (*remove_buf_file)(struct dentry *dentry);
78246 -};
78247 +} __no_const;
78248
78249 /*
78250 * CONFIG_RELAY kernel API, kernel/relay.c
78251 diff --git a/include/linux/rio.h b/include/linux/rio.h
78252 index b71d573..2f940bd 100644
78253 --- a/include/linux/rio.h
78254 +++ b/include/linux/rio.h
78255 @@ -355,7 +355,7 @@ struct rio_ops {
78256 int (*map_inb)(struct rio_mport *mport, dma_addr_t lstart,
78257 u64 rstart, u32 size, u32 flags);
78258 void (*unmap_inb)(struct rio_mport *mport, dma_addr_t lstart);
78259 -};
78260 +} __no_const;
78261
78262 #define RIO_RESOURCE_MEM 0x00000100
78263 #define RIO_RESOURCE_DOORBELL 0x00000200
78264 diff --git a/include/linux/rmap.h b/include/linux/rmap.h
78265 index 6dacb93..6174423 100644
78266 --- a/include/linux/rmap.h
78267 +++ b/include/linux/rmap.h
78268 @@ -145,8 +145,8 @@ static inline void anon_vma_unlock_read(struct anon_vma *anon_vma)
78269 void anon_vma_init(void); /* create anon_vma_cachep */
78270 int anon_vma_prepare(struct vm_area_struct *);
78271 void unlink_anon_vmas(struct vm_area_struct *);
78272 -int anon_vma_clone(struct vm_area_struct *, struct vm_area_struct *);
78273 -int anon_vma_fork(struct vm_area_struct *, struct vm_area_struct *);
78274 +int anon_vma_clone(struct vm_area_struct *, const struct vm_area_struct *);
78275 +int anon_vma_fork(struct vm_area_struct *, const struct vm_area_struct *);
78276
78277 static inline void anon_vma_merge(struct vm_area_struct *vma,
78278 struct vm_area_struct *next)
78279 diff --git a/include/linux/sched.h b/include/linux/sched.h
78280 index b1e963e..114b8fd 100644
78281 --- a/include/linux/sched.h
78282 +++ b/include/linux/sched.h
78283 @@ -62,6 +62,7 @@ struct bio_list;
78284 struct fs_struct;
78285 struct perf_event_context;
78286 struct blk_plug;
78287 +struct linux_binprm;
78288
78289 /*
78290 * List of flags we want to share for kernel threads,
78291 @@ -295,7 +296,7 @@ extern char __sched_text_start[], __sched_text_end[];
78292 extern int in_sched_functions(unsigned long addr);
78293
78294 #define MAX_SCHEDULE_TIMEOUT LONG_MAX
78295 -extern signed long schedule_timeout(signed long timeout);
78296 +extern signed long schedule_timeout(signed long timeout) __intentional_overflow(-1);
78297 extern signed long schedule_timeout_interruptible(signed long timeout);
78298 extern signed long schedule_timeout_killable(signed long timeout);
78299 extern signed long schedule_timeout_uninterruptible(signed long timeout);
78300 @@ -306,6 +307,19 @@ struct nsproxy;
78301 struct user_namespace;
78302
78303 #ifdef CONFIG_MMU
78304 +
78305 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
78306 +extern unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags);
78307 +#else
78308 +static inline unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
78309 +{
78310 + return 0;
78311 +}
78312 +#endif
78313 +
78314 +extern bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset);
78315 +extern unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset);
78316 +
78317 extern void arch_pick_mmap_layout(struct mm_struct *mm);
78318 extern unsigned long
78319 arch_get_unmapped_area(struct file *, unsigned long, unsigned long,
78320 @@ -585,6 +599,17 @@ struct signal_struct {
78321 #ifdef CONFIG_TASKSTATS
78322 struct taskstats *stats;
78323 #endif
78324 +
78325 +#ifdef CONFIG_GRKERNSEC
78326 + u32 curr_ip;
78327 + u32 saved_ip;
78328 + u32 gr_saddr;
78329 + u32 gr_daddr;
78330 + u16 gr_sport;
78331 + u16 gr_dport;
78332 + u8 used_accept:1;
78333 +#endif
78334 +
78335 #ifdef CONFIG_AUDIT
78336 unsigned audit_tty;
78337 unsigned audit_tty_log_passwd;
78338 @@ -665,6 +690,14 @@ struct user_struct {
78339 struct key *session_keyring; /* UID's default session keyring */
78340 #endif
78341
78342 +#ifdef CONFIG_GRKERNSEC_KERN_LOCKOUT
78343 + unsigned char kernel_banned;
78344 +#endif
78345 +#ifdef CONFIG_GRKERNSEC_BRUTE
78346 + unsigned char suid_banned;
78347 + unsigned long suid_ban_expires;
78348 +#endif
78349 +
78350 /* Hash table maintenance information */
78351 struct hlist_node uidhash_node;
78352 kuid_t uid;
78353 @@ -1150,8 +1183,8 @@ struct task_struct {
78354 struct list_head thread_group;
78355
78356 struct completion *vfork_done; /* for vfork() */
78357 - int __user *set_child_tid; /* CLONE_CHILD_SETTID */
78358 - int __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
78359 + pid_t __user *set_child_tid; /* CLONE_CHILD_SETTID */
78360 + pid_t __user *clear_child_tid; /* CLONE_CHILD_CLEARTID */
78361
78362 cputime_t utime, stime, utimescaled, stimescaled;
78363 cputime_t gtime;
78364 @@ -1176,11 +1209,6 @@ struct task_struct {
78365 struct task_cputime cputime_expires;
78366 struct list_head cpu_timers[3];
78367
78368 -/* process credentials */
78369 - const struct cred __rcu *real_cred; /* objective and real subjective task
78370 - * credentials (COW) */
78371 - const struct cred __rcu *cred; /* effective (overridable) subjective task
78372 - * credentials (COW) */
78373 char comm[TASK_COMM_LEN]; /* executable name excluding path
78374 - access with [gs]et_task_comm (which lock
78375 it with task_lock())
78376 @@ -1197,6 +1225,10 @@ struct task_struct {
78377 #endif
78378 /* CPU-specific state of this task */
78379 struct thread_struct thread;
78380 +/* thread_info moved to task_struct */
78381 +#ifdef CONFIG_X86
78382 + struct thread_info tinfo;
78383 +#endif
78384 /* filesystem information */
78385 struct fs_struct *fs;
78386 /* open file information */
78387 @@ -1270,6 +1302,10 @@ struct task_struct {
78388 gfp_t lockdep_reclaim_gfp;
78389 #endif
78390
78391 +/* process credentials */
78392 + const struct cred __rcu *real_cred; /* objective and real subjective task
78393 + * credentials (COW) */
78394 +
78395 /* journalling filesystem info */
78396 void *journal_info;
78397
78398 @@ -1308,6 +1344,10 @@ struct task_struct {
78399 /* cg_list protected by css_set_lock and tsk->alloc_lock */
78400 struct list_head cg_list;
78401 #endif
78402 +
78403 + const struct cred __rcu *cred; /* effective (overridable) subjective task
78404 + * credentials (COW) */
78405 +
78406 #ifdef CONFIG_FUTEX
78407 struct robust_list_head __user *robust_list;
78408 #ifdef CONFIG_COMPAT
78409 @@ -1411,8 +1451,78 @@ struct task_struct {
78410 unsigned int sequential_io;
78411 unsigned int sequential_io_avg;
78412 #endif
78413 +
78414 +#ifdef CONFIG_GRKERNSEC
78415 + /* grsecurity */
78416 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
78417 + u64 exec_id;
78418 +#endif
78419 +#ifdef CONFIG_GRKERNSEC_SETXID
78420 + const struct cred *delayed_cred;
78421 +#endif
78422 + struct dentry *gr_chroot_dentry;
78423 + struct acl_subject_label *acl;
78424 + struct acl_subject_label *tmpacl;
78425 + struct acl_role_label *role;
78426 + struct file *exec_file;
78427 + unsigned long brute_expires;
78428 + u16 acl_role_id;
78429 + u8 inherited;
78430 + /* is this the task that authenticated to the special role */
78431 + u8 acl_sp_role;
78432 + u8 is_writable;
78433 + u8 brute;
78434 + u8 gr_is_chrooted;
78435 +#endif
78436 +
78437 };
78438
78439 +#define MF_PAX_PAGEEXEC 0x01000000 /* Paging based non-executable pages */
78440 +#define MF_PAX_EMUTRAMP 0x02000000 /* Emulate trampolines */
78441 +#define MF_PAX_MPROTECT 0x04000000 /* Restrict mprotect() */
78442 +#define MF_PAX_RANDMMAP 0x08000000 /* Randomize mmap() base */
78443 +/*#define MF_PAX_RANDEXEC 0x10000000*/ /* Randomize ET_EXEC base */
78444 +#define MF_PAX_SEGMEXEC 0x20000000 /* Segmentation based non-executable pages */
78445 +
78446 +#ifdef CONFIG_PAX_SOFTMODE
78447 +extern int pax_softmode;
78448 +#endif
78449 +
78450 +extern int pax_check_flags(unsigned long *);
78451 +
78452 +/* if tsk != current then task_lock must be held on it */
78453 +#if defined(CONFIG_PAX_NOEXEC) || defined(CONFIG_PAX_ASLR)
78454 +static inline unsigned long pax_get_flags(struct task_struct *tsk)
78455 +{
78456 + if (likely(tsk->mm))
78457 + return tsk->mm->pax_flags;
78458 + else
78459 + return 0UL;
78460 +}
78461 +
78462 +/* if tsk != current then task_lock must be held on it */
78463 +static inline long pax_set_flags(struct task_struct *tsk, unsigned long flags)
78464 +{
78465 + if (likely(tsk->mm)) {
78466 + tsk->mm->pax_flags = flags;
78467 + return 0;
78468 + }
78469 + return -EINVAL;
78470 +}
78471 +#endif
78472 +
78473 +#ifdef CONFIG_PAX_HAVE_ACL_FLAGS
78474 +extern void pax_set_initial_flags(struct linux_binprm *bprm);
78475 +#elif defined(CONFIG_PAX_HOOK_ACL_FLAGS)
78476 +extern void (*pax_set_initial_flags_func)(struct linux_binprm *bprm);
78477 +#endif
78478 +
78479 +struct path;
78480 +extern char *pax_get_path(const struct path *path, char *buf, int buflen);
78481 +extern void pax_report_fault(struct pt_regs *regs, void *pc, void *sp);
78482 +extern void pax_report_insns(struct pt_regs *regs, void *pc, void *sp);
78483 +extern void pax_report_refcount_overflow(struct pt_regs *regs);
78484 +
78485 /* Future-safe accessor for struct task_struct's cpus_allowed. */
78486 #define tsk_cpus_allowed(tsk) (&(tsk)->cpus_allowed)
78487
78488 @@ -1471,7 +1581,7 @@ struct pid_namespace;
78489 pid_t __task_pid_nr_ns(struct task_struct *task, enum pid_type type,
78490 struct pid_namespace *ns);
78491
78492 -static inline pid_t task_pid_nr(struct task_struct *tsk)
78493 +static inline pid_t task_pid_nr(const struct task_struct *tsk)
78494 {
78495 return tsk->pid;
78496 }
78497 @@ -1921,7 +2031,9 @@ void yield(void);
78498 extern struct exec_domain default_exec_domain;
78499
78500 union thread_union {
78501 +#ifndef CONFIG_X86
78502 struct thread_info thread_info;
78503 +#endif
78504 unsigned long stack[THREAD_SIZE/sizeof(long)];
78505 };
78506
78507 @@ -1954,6 +2066,7 @@ extern struct pid_namespace init_pid_ns;
78508 */
78509
78510 extern struct task_struct *find_task_by_vpid(pid_t nr);
78511 +extern struct task_struct *find_task_by_vpid_unrestricted(pid_t nr);
78512 extern struct task_struct *find_task_by_pid_ns(pid_t nr,
78513 struct pid_namespace *ns);
78514
78515 @@ -2118,7 +2231,7 @@ extern void __cleanup_sighand(struct sighand_struct *);
78516 extern void exit_itimers(struct signal_struct *);
78517 extern void flush_itimer_signals(void);
78518
78519 -extern void do_group_exit(int);
78520 +extern __noreturn void do_group_exit(int);
78521
78522 extern int allow_signal(int);
78523 extern int disallow_signal(int);
78524 @@ -2309,9 +2422,9 @@ static inline unsigned long *end_of_stack(struct task_struct *p)
78525
78526 #endif
78527
78528 -static inline int object_is_on_stack(void *obj)
78529 +static inline int object_starts_on_stack(void *obj)
78530 {
78531 - void *stack = task_stack_page(current);
78532 + const void *stack = task_stack_page(current);
78533
78534 return (obj >= stack) && (obj < (stack + THREAD_SIZE));
78535 }
78536 diff --git a/include/linux/sched/sysctl.h b/include/linux/sched/sysctl.h
78537 index bf8086b..962b035 100644
78538 --- a/include/linux/sched/sysctl.h
78539 +++ b/include/linux/sched/sysctl.h
78540 @@ -30,6 +30,7 @@ enum { sysctl_hung_task_timeout_secs = 0 };
78541 #define DEFAULT_MAX_MAP_COUNT (USHRT_MAX - MAPCOUNT_ELF_CORE_MARGIN)
78542
78543 extern int sysctl_max_map_count;
78544 +extern unsigned long sysctl_heap_stack_gap;
78545
78546 extern unsigned int sysctl_sched_latency;
78547 extern unsigned int sysctl_sched_min_granularity;
78548 diff --git a/include/linux/security.h b/include/linux/security.h
78549 index 9d37e2b..43368e4 100644
78550 --- a/include/linux/security.h
78551 +++ b/include/linux/security.h
78552 @@ -27,6 +27,7 @@
78553 #include <linux/slab.h>
78554 #include <linux/err.h>
78555 #include <linux/string.h>
78556 +#include <linux/grsecurity.h>
78557
78558 struct linux_binprm;
78559 struct cred;
78560 @@ -116,8 +117,6 @@ struct seq_file;
78561
78562 extern int cap_netlink_send(struct sock *sk, struct sk_buff *skb);
78563
78564 -void reset_security_ops(void);
78565 -
78566 #ifdef CONFIG_MMU
78567 extern unsigned long mmap_min_addr;
78568 extern unsigned long dac_mmap_min_addr;
78569 diff --git a/include/linux/semaphore.h b/include/linux/semaphore.h
78570 index dc368b8..e895209 100644
78571 --- a/include/linux/semaphore.h
78572 +++ b/include/linux/semaphore.h
78573 @@ -37,7 +37,7 @@ static inline void sema_init(struct semaphore *sem, int val)
78574 }
78575
78576 extern void down(struct semaphore *sem);
78577 -extern int __must_check down_interruptible(struct semaphore *sem);
78578 +extern int __must_check down_interruptible(struct semaphore *sem) __intentional_overflow(-1);
78579 extern int __must_check down_killable(struct semaphore *sem);
78580 extern int __must_check down_trylock(struct semaphore *sem);
78581 extern int __must_check down_timeout(struct semaphore *sem, long jiffies);
78582 diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h
78583 index 4e32edc..f8f2d18 100644
78584 --- a/include/linux/seq_file.h
78585 +++ b/include/linux/seq_file.h
78586 @@ -26,6 +26,9 @@ struct seq_file {
78587 struct mutex lock;
78588 const struct seq_operations *op;
78589 int poll_event;
78590 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
78591 + u64 exec_id;
78592 +#endif
78593 #ifdef CONFIG_USER_NS
78594 struct user_namespace *user_ns;
78595 #endif
78596 @@ -38,6 +41,7 @@ struct seq_operations {
78597 void * (*next) (struct seq_file *m, void *v, loff_t *pos);
78598 int (*show) (struct seq_file *m, void *v);
78599 };
78600 +typedef struct seq_operations __no_const seq_operations_no_const;
78601
78602 #define SEQ_SKIP 1
78603
78604 diff --git a/include/linux/shm.h b/include/linux/shm.h
78605 index 429c199..4d42e38 100644
78606 --- a/include/linux/shm.h
78607 +++ b/include/linux/shm.h
78608 @@ -21,6 +21,10 @@ struct shmid_kernel /* private to the kernel */
78609
78610 /* The task created the shm object. NULL if the task is dead. */
78611 struct task_struct *shm_creator;
78612 +#ifdef CONFIG_GRKERNSEC
78613 + time_t shm_createtime;
78614 + pid_t shm_lapid;
78615 +#endif
78616 };
78617
78618 /* shm_mode upper byte flags */
78619 diff --git a/include/linux/skbuff.h b/include/linux/skbuff.h
78620 index f66f346..2e304d5 100644
78621 --- a/include/linux/skbuff.h
78622 +++ b/include/linux/skbuff.h
78623 @@ -639,7 +639,7 @@ extern bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from,
78624 extern struct sk_buff *__alloc_skb(unsigned int size,
78625 gfp_t priority, int flags, int node);
78626 extern struct sk_buff *build_skb(void *data, unsigned int frag_size);
78627 -static inline struct sk_buff *alloc_skb(unsigned int size,
78628 +static inline struct sk_buff * __intentional_overflow(0) alloc_skb(unsigned int size,
78629 gfp_t priority)
78630 {
78631 return __alloc_skb(size, priority, 0, NUMA_NO_NODE);
78632 @@ -755,7 +755,7 @@ static inline struct skb_shared_hwtstamps *skb_hwtstamps(struct sk_buff *skb)
78633 */
78634 static inline int skb_queue_empty(const struct sk_buff_head *list)
78635 {
78636 - return list->next == (struct sk_buff *)list;
78637 + return list->next == (const struct sk_buff *)list;
78638 }
78639
78640 /**
78641 @@ -768,7 +768,7 @@ static inline int skb_queue_empty(const struct sk_buff_head *list)
78642 static inline bool skb_queue_is_last(const struct sk_buff_head *list,
78643 const struct sk_buff *skb)
78644 {
78645 - return skb->next == (struct sk_buff *)list;
78646 + return skb->next == (const struct sk_buff *)list;
78647 }
78648
78649 /**
78650 @@ -781,7 +781,7 @@ static inline bool skb_queue_is_last(const struct sk_buff_head *list,
78651 static inline bool skb_queue_is_first(const struct sk_buff_head *list,
78652 const struct sk_buff *skb)
78653 {
78654 - return skb->prev == (struct sk_buff *)list;
78655 + return skb->prev == (const struct sk_buff *)list;
78656 }
78657
78658 /**
78659 @@ -1741,7 +1741,7 @@ static inline int pskb_network_may_pull(struct sk_buff *skb, unsigned int len)
78660 * NET_IP_ALIGN(2) + ethernet_header(14) + IP_header(20/40) + ports(8)
78661 */
78662 #ifndef NET_SKB_PAD
78663 -#define NET_SKB_PAD max(32, L1_CACHE_BYTES)
78664 +#define NET_SKB_PAD max(_AC(32,UL), L1_CACHE_BYTES)
78665 #endif
78666
78667 extern int ___pskb_trim(struct sk_buff *skb, unsigned int len);
78668 @@ -2339,7 +2339,7 @@ extern struct sk_buff *skb_recv_datagram(struct sock *sk, unsigned flags,
78669 int noblock, int *err);
78670 extern unsigned int datagram_poll(struct file *file, struct socket *sock,
78671 struct poll_table_struct *wait);
78672 -extern int skb_copy_datagram_iovec(const struct sk_buff *from,
78673 +extern int __intentional_overflow(0) skb_copy_datagram_iovec(const struct sk_buff *from,
78674 int offset, struct iovec *to,
78675 int size);
78676 extern int skb_copy_and_csum_datagram_iovec(struct sk_buff *skb,
78677 @@ -2618,6 +2618,9 @@ static inline void nf_reset(struct sk_buff *skb)
78678 nf_bridge_put(skb->nf_bridge);
78679 skb->nf_bridge = NULL;
78680 #endif
78681 +#if IS_ENABLED(CONFIG_NETFILTER_XT_TARGET_TRACE)
78682 + skb->nf_trace = 0;
78683 +#endif
78684 }
78685
78686 static inline void nf_reset_trace(struct sk_buff *skb)
78687 diff --git a/include/linux/slab.h b/include/linux/slab.h
78688 index 74f1058..914b7da 100644
78689 --- a/include/linux/slab.h
78690 +++ b/include/linux/slab.h
78691 @@ -14,15 +14,29 @@
78692 #include <linux/gfp.h>
78693 #include <linux/types.h>
78694 #include <linux/workqueue.h>
78695 -
78696 +#include <linux/err.h>
78697
78698 /*
78699 * Flags to pass to kmem_cache_create().
78700 * The ones marked DEBUG are only valid if CONFIG_SLAB_DEBUG is set.
78701 */
78702 #define SLAB_DEBUG_FREE 0x00000100UL /* DEBUG: Perform (expensive) checks on free */
78703 +
78704 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78705 +#define SLAB_USERCOPY 0x00000200UL /* PaX: Allow copying objs to/from userland */
78706 +#else
78707 +#define SLAB_USERCOPY 0x00000000UL
78708 +#endif
78709 +
78710 #define SLAB_RED_ZONE 0x00000400UL /* DEBUG: Red zone objs in a cache */
78711 #define SLAB_POISON 0x00000800UL /* DEBUG: Poison objects */
78712 +
78713 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
78714 +#define SLAB_NO_SANITIZE 0x00001000UL /* PaX: Do not sanitize objs on free */
78715 +#else
78716 +#define SLAB_NO_SANITIZE 0x00000000UL
78717 +#endif
78718 +
78719 #define SLAB_HWCACHE_ALIGN 0x00002000UL /* Align objs on cache lines */
78720 #define SLAB_CACHE_DMA 0x00004000UL /* Use GFP_DMA memory */
78721 #define SLAB_STORE_USER 0x00010000UL /* DEBUG: Store the last owner for bug hunting */
78722 @@ -91,10 +105,13 @@
78723 * ZERO_SIZE_PTR can be passed to kfree though in the same way that NULL can.
78724 * Both make kfree a no-op.
78725 */
78726 -#define ZERO_SIZE_PTR ((void *)16)
78727 +#define ZERO_SIZE_PTR \
78728 +({ \
78729 + BUILD_BUG_ON(!(MAX_ERRNO & ~PAGE_MASK));\
78730 + (void *)(-MAX_ERRNO-1L); \
78731 +})
78732
78733 -#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) <= \
78734 - (unsigned long)ZERO_SIZE_PTR)
78735 +#define ZERO_OR_NULL_PTR(x) ((unsigned long)(x) - 1 >= (unsigned long)ZERO_SIZE_PTR - 1)
78736
78737 #include <linux/kmemleak.h>
78738
78739 @@ -135,6 +152,8 @@ void * __must_check krealloc(const void *, size_t, gfp_t);
78740 void kfree(const void *);
78741 void kzfree(const void *);
78742 size_t ksize(const void *);
78743 +const char *check_heap_object(const void *ptr, unsigned long n);
78744 +bool is_usercopy_object(const void *ptr);
78745
78746 /*
78747 * Some archs want to perform DMA into kmalloc caches and need a guaranteed
78748 @@ -167,7 +186,7 @@ struct kmem_cache {
78749 unsigned int align; /* Alignment as calculated */
78750 unsigned long flags; /* Active flags on the slab */
78751 const char *name; /* Slab name for sysfs */
78752 - int refcount; /* Use counter */
78753 + atomic_t refcount; /* Use counter */
78754 void (*ctor)(void *); /* Called on object slot creation */
78755 struct list_head list; /* List of all slab caches on the system */
78756 };
78757 @@ -241,6 +260,10 @@ extern struct kmem_cache *kmalloc_caches[KMALLOC_SHIFT_HIGH + 1];
78758 extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
78759 #endif
78760
78761 +#ifdef CONFIG_PAX_USERCOPY_SLABS
78762 +extern struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
78763 +#endif
78764 +
78765 /*
78766 * Figure out which kmalloc slab an allocation of a certain size
78767 * belongs to.
78768 @@ -249,7 +272,7 @@ extern struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
78769 * 2 = 120 .. 192 bytes
78770 * n = 2^(n-1) .. 2^n -1
78771 */
78772 -static __always_inline int kmalloc_index(size_t size)
78773 +static __always_inline __size_overflow(1) int kmalloc_index(size_t size)
78774 {
78775 if (!size)
78776 return 0;
78777 @@ -292,11 +315,11 @@ static __always_inline int kmalloc_index(size_t size)
78778 }
78779 #endif /* !CONFIG_SLOB */
78780
78781 -void *__kmalloc(size_t size, gfp_t flags);
78782 +void *__kmalloc(size_t size, gfp_t flags) __alloc_size(1);
78783 void *kmem_cache_alloc(struct kmem_cache *, gfp_t flags);
78784
78785 #ifdef CONFIG_NUMA
78786 -void *__kmalloc_node(size_t size, gfp_t flags, int node);
78787 +void *__kmalloc_node(size_t size, gfp_t flags, int node) __alloc_size(1);
78788 void *kmem_cache_alloc_node(struct kmem_cache *, gfp_t flags, int node);
78789 #else
78790 static __always_inline void *__kmalloc_node(size_t size, gfp_t flags, int node)
78791 diff --git a/include/linux/slab_def.h b/include/linux/slab_def.h
78792 index e9346b4..1494959 100644
78793 --- a/include/linux/slab_def.h
78794 +++ b/include/linux/slab_def.h
78795 @@ -36,7 +36,7 @@ struct kmem_cache {
78796 /* 4) cache creation/removal */
78797 const char *name;
78798 struct list_head list;
78799 - int refcount;
78800 + atomic_t refcount;
78801 int object_size;
78802 int align;
78803
78804 @@ -52,10 +52,14 @@ struct kmem_cache {
78805 unsigned long node_allocs;
78806 unsigned long node_frees;
78807 unsigned long node_overflow;
78808 - atomic_t allochit;
78809 - atomic_t allocmiss;
78810 - atomic_t freehit;
78811 - atomic_t freemiss;
78812 + atomic_unchecked_t allochit;
78813 + atomic_unchecked_t allocmiss;
78814 + atomic_unchecked_t freehit;
78815 + atomic_unchecked_t freemiss;
78816 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
78817 + atomic_unchecked_t sanitized;
78818 + atomic_unchecked_t not_sanitized;
78819 +#endif
78820
78821 /*
78822 * If debugging is enabled, then the allocator can add additional
78823 diff --git a/include/linux/slub_def.h b/include/linux/slub_def.h
78824 index cc0b67e..a0329b1 100644
78825 --- a/include/linux/slub_def.h
78826 +++ b/include/linux/slub_def.h
78827 @@ -74,7 +74,7 @@ struct kmem_cache {
78828 struct kmem_cache_order_objects max;
78829 struct kmem_cache_order_objects min;
78830 gfp_t allocflags; /* gfp flags to use on each alloc */
78831 - int refcount; /* Refcount for slab cache destroy */
78832 + atomic_t refcount; /* Refcount for slab cache destroy */
78833 void (*ctor)(void *);
78834 int inuse; /* Offset to metadata */
78835 int align; /* Alignment */
78836 diff --git a/include/linux/smp.h b/include/linux/smp.h
78837 index 731f523..3340268 100644
78838 --- a/include/linux/smp.h
78839 +++ b/include/linux/smp.h
78840 @@ -186,7 +186,9 @@ static inline void __smp_call_function_single(int cpuid,
78841 #endif
78842
78843 #define get_cpu() ({ preempt_disable(); smp_processor_id(); })
78844 +#define raw_get_cpu() ({ raw_preempt_disable(); raw_smp_processor_id(); })
78845 #define put_cpu() preempt_enable()
78846 +#define raw_put_cpu_no_resched() raw_preempt_enable_no_resched()
78847
78848 /*
78849 * Callback to arch code if there's nosmp or maxcpus=0 on the
78850 diff --git a/include/linux/sock_diag.h b/include/linux/sock_diag.h
78851 index 54f91d3..be2c379 100644
78852 --- a/include/linux/sock_diag.h
78853 +++ b/include/linux/sock_diag.h
78854 @@ -11,7 +11,7 @@ struct sock;
78855 struct sock_diag_handler {
78856 __u8 family;
78857 int (*dump)(struct sk_buff *skb, struct nlmsghdr *nlh);
78858 -};
78859 +} __do_const;
78860
78861 int sock_diag_register(const struct sock_diag_handler *h);
78862 void sock_diag_unregister(const struct sock_diag_handler *h);
78863 diff --git a/include/linux/sonet.h b/include/linux/sonet.h
78864 index 680f9a3..f13aeb0 100644
78865 --- a/include/linux/sonet.h
78866 +++ b/include/linux/sonet.h
78867 @@ -7,7 +7,7 @@
78868 #include <uapi/linux/sonet.h>
78869
78870 struct k_sonet_stats {
78871 -#define __HANDLE_ITEM(i) atomic_t i
78872 +#define __HANDLE_ITEM(i) atomic_unchecked_t i
78873 __SONET_ITEMS
78874 #undef __HANDLE_ITEM
78875 };
78876 diff --git a/include/linux/sunrpc/addr.h b/include/linux/sunrpc/addr.h
78877 index 07d8e53..dc934c9 100644
78878 --- a/include/linux/sunrpc/addr.h
78879 +++ b/include/linux/sunrpc/addr.h
78880 @@ -23,9 +23,9 @@ static inline unsigned short rpc_get_port(const struct sockaddr *sap)
78881 {
78882 switch (sap->sa_family) {
78883 case AF_INET:
78884 - return ntohs(((struct sockaddr_in *)sap)->sin_port);
78885 + return ntohs(((const struct sockaddr_in *)sap)->sin_port);
78886 case AF_INET6:
78887 - return ntohs(((struct sockaddr_in6 *)sap)->sin6_port);
78888 + return ntohs(((const struct sockaddr_in6 *)sap)->sin6_port);
78889 }
78890 return 0;
78891 }
78892 @@ -58,7 +58,7 @@ static inline bool __rpc_cmp_addr4(const struct sockaddr *sap1,
78893 static inline bool __rpc_copy_addr4(struct sockaddr *dst,
78894 const struct sockaddr *src)
78895 {
78896 - const struct sockaddr_in *ssin = (struct sockaddr_in *) src;
78897 + const struct sockaddr_in *ssin = (const struct sockaddr_in *) src;
78898 struct sockaddr_in *dsin = (struct sockaddr_in *) dst;
78899
78900 dsin->sin_family = ssin->sin_family;
78901 @@ -164,7 +164,7 @@ static inline u32 rpc_get_scope_id(const struct sockaddr *sa)
78902 if (sa->sa_family != AF_INET6)
78903 return 0;
78904
78905 - return ((struct sockaddr_in6 *) sa)->sin6_scope_id;
78906 + return ((const struct sockaddr_in6 *) sa)->sin6_scope_id;
78907 }
78908
78909 #endif /* _LINUX_SUNRPC_ADDR_H */
78910 diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h
78911 index 6740801..c535f27 100644
78912 --- a/include/linux/sunrpc/clnt.h
78913 +++ b/include/linux/sunrpc/clnt.h
78914 @@ -96,7 +96,7 @@ struct rpc_procinfo {
78915 unsigned int p_timer; /* Which RTT timer to use */
78916 u32 p_statidx; /* Which procedure to account */
78917 const char * p_name; /* name of procedure */
78918 -};
78919 +} __do_const;
78920
78921 #ifdef __KERNEL__
78922
78923 diff --git a/include/linux/sunrpc/svc.h b/include/linux/sunrpc/svc.h
78924 index 6eecfc2..7ada79d 100644
78925 --- a/include/linux/sunrpc/svc.h
78926 +++ b/include/linux/sunrpc/svc.h
78927 @@ -410,7 +410,7 @@ struct svc_procedure {
78928 unsigned int pc_count; /* call count */
78929 unsigned int pc_cachetype; /* cache info (NFS) */
78930 unsigned int pc_xdrressize; /* maximum size of XDR reply */
78931 -};
78932 +} __do_const;
78933
78934 /*
78935 * Function prototypes.
78936 diff --git a/include/linux/sunrpc/svc_rdma.h b/include/linux/sunrpc/svc_rdma.h
78937 index 0b8e3e6..33e0a01 100644
78938 --- a/include/linux/sunrpc/svc_rdma.h
78939 +++ b/include/linux/sunrpc/svc_rdma.h
78940 @@ -53,15 +53,15 @@ extern unsigned int svcrdma_ord;
78941 extern unsigned int svcrdma_max_requests;
78942 extern unsigned int svcrdma_max_req_size;
78943
78944 -extern atomic_t rdma_stat_recv;
78945 -extern atomic_t rdma_stat_read;
78946 -extern atomic_t rdma_stat_write;
78947 -extern atomic_t rdma_stat_sq_starve;
78948 -extern atomic_t rdma_stat_rq_starve;
78949 -extern atomic_t rdma_stat_rq_poll;
78950 -extern atomic_t rdma_stat_rq_prod;
78951 -extern atomic_t rdma_stat_sq_poll;
78952 -extern atomic_t rdma_stat_sq_prod;
78953 +extern atomic_unchecked_t rdma_stat_recv;
78954 +extern atomic_unchecked_t rdma_stat_read;
78955 +extern atomic_unchecked_t rdma_stat_write;
78956 +extern atomic_unchecked_t rdma_stat_sq_starve;
78957 +extern atomic_unchecked_t rdma_stat_rq_starve;
78958 +extern atomic_unchecked_t rdma_stat_rq_poll;
78959 +extern atomic_unchecked_t rdma_stat_rq_prod;
78960 +extern atomic_unchecked_t rdma_stat_sq_poll;
78961 +extern atomic_unchecked_t rdma_stat_sq_prod;
78962
78963 #define RPCRDMA_VERSION 1
78964
78965 diff --git a/include/linux/sunrpc/svcauth.h b/include/linux/sunrpc/svcauth.h
78966 index 8d71d65..f79586e 100644
78967 --- a/include/linux/sunrpc/svcauth.h
78968 +++ b/include/linux/sunrpc/svcauth.h
78969 @@ -120,7 +120,7 @@ struct auth_ops {
78970 int (*release)(struct svc_rqst *rq);
78971 void (*domain_release)(struct auth_domain *);
78972 int (*set_client)(struct svc_rqst *rq);
78973 -};
78974 +} __do_const;
78975
78976 #define SVC_GARBAGE 1
78977 #define SVC_SYSERR 2
78978 diff --git a/include/linux/swiotlb.h b/include/linux/swiotlb.h
78979 index a5ffd32..0935dea 100644
78980 --- a/include/linux/swiotlb.h
78981 +++ b/include/linux/swiotlb.h
78982 @@ -60,7 +60,8 @@ extern void
78983
78984 extern void
78985 swiotlb_free_coherent(struct device *hwdev, size_t size,
78986 - void *vaddr, dma_addr_t dma_handle);
78987 + void *vaddr, dma_addr_t dma_handle,
78988 + struct dma_attrs *attrs);
78989
78990 extern dma_addr_t swiotlb_map_page(struct device *dev, struct page *page,
78991 unsigned long offset, size_t size,
78992 diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
78993 index 7fac04e..de57300 100644
78994 --- a/include/linux/syscalls.h
78995 +++ b/include/linux/syscalls.h
78996 @@ -97,8 +97,14 @@ struct sigaltstack;
78997 #define __MAP(n,...) __MAP##n(__VA_ARGS__)
78998
78999 #define __SC_DECL(t, a) t a
79000 +#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))
79001 #define __TYPE_IS_LL(t) (__same_type((t)0, 0LL) || __same_type((t)0, 0ULL))
79002 -#define __SC_LONG(t, a) __typeof(__builtin_choose_expr(__TYPE_IS_LL(t), 0LL, 0L)) a
79003 +#define __SC_LONG(t, a) __typeof( \
79004 + __builtin_choose_expr( \
79005 + sizeof(t) > sizeof(int), \
79006 + (t) 0, \
79007 + __builtin_choose_expr(__TYPE_IS_U(t), 0UL, 0L) \
79008 + )) a
79009 #define __SC_CAST(t, a) (t) a
79010 #define __SC_ARGS(t, a) a
79011 #define __SC_TEST(t, a) (void)BUILD_BUG_ON_ZERO(!__TYPE_IS_LL(t) && sizeof(t) > sizeof(long))
79012 @@ -363,11 +369,11 @@ asmlinkage long sys_sync(void);
79013 asmlinkage long sys_fsync(unsigned int fd);
79014 asmlinkage long sys_fdatasync(unsigned int fd);
79015 asmlinkage long sys_bdflush(int func, long data);
79016 -asmlinkage long sys_mount(char __user *dev_name, char __user *dir_name,
79017 - char __user *type, unsigned long flags,
79018 +asmlinkage long sys_mount(const char __user *dev_name, const char __user *dir_name,
79019 + const char __user *type, unsigned long flags,
79020 void __user *data);
79021 -asmlinkage long sys_umount(char __user *name, int flags);
79022 -asmlinkage long sys_oldumount(char __user *name);
79023 +asmlinkage long sys_umount(const char __user *name, int flags);
79024 +asmlinkage long sys_oldumount(const char __user *name);
79025 asmlinkage long sys_truncate(const char __user *path, long length);
79026 asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length);
79027 asmlinkage long sys_stat(const char __user *filename,
79028 @@ -579,7 +585,7 @@ asmlinkage long sys_getsockname(int, struct sockaddr __user *, int __user *);
79029 asmlinkage long sys_getpeername(int, struct sockaddr __user *, int __user *);
79030 asmlinkage long sys_send(int, void __user *, size_t, unsigned);
79031 asmlinkage long sys_sendto(int, void __user *, size_t, unsigned,
79032 - struct sockaddr __user *, int);
79033 + struct sockaddr __user *, int) __intentional_overflow(0);
79034 asmlinkage long sys_sendmsg(int fd, struct msghdr __user *msg, unsigned flags);
79035 asmlinkage long sys_sendmmsg(int fd, struct mmsghdr __user *msg,
79036 unsigned int vlen, unsigned flags);
79037 diff --git a/include/linux/syscore_ops.h b/include/linux/syscore_ops.h
79038 index 27b3b0b..e093dd9 100644
79039 --- a/include/linux/syscore_ops.h
79040 +++ b/include/linux/syscore_ops.h
79041 @@ -16,7 +16,7 @@ struct syscore_ops {
79042 int (*suspend)(void);
79043 void (*resume)(void);
79044 void (*shutdown)(void);
79045 -};
79046 +} __do_const;
79047
79048 extern void register_syscore_ops(struct syscore_ops *ops);
79049 extern void unregister_syscore_ops(struct syscore_ops *ops);
79050 diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
79051 index 14a8ff2..af52bad 100644
79052 --- a/include/linux/sysctl.h
79053 +++ b/include/linux/sysctl.h
79054 @@ -34,13 +34,13 @@ struct ctl_table_root;
79055 struct ctl_table_header;
79056 struct ctl_dir;
79057
79058 -typedef struct ctl_table ctl_table;
79059 -
79060 typedef int proc_handler (struct ctl_table *ctl, int write,
79061 void __user *buffer, size_t *lenp, loff_t *ppos);
79062
79063 extern int proc_dostring(struct ctl_table *, int,
79064 void __user *, size_t *, loff_t *);
79065 +extern int proc_dostring_modpriv(struct ctl_table *, int,
79066 + void __user *, size_t *, loff_t *);
79067 extern int proc_dointvec(struct ctl_table *, int,
79068 void __user *, size_t *, loff_t *);
79069 extern int proc_dointvec_minmax(struct ctl_table *, int,
79070 @@ -115,7 +115,9 @@ struct ctl_table
79071 struct ctl_table_poll *poll;
79072 void *extra1;
79073 void *extra2;
79074 -};
79075 +} __do_const;
79076 +typedef struct ctl_table __no_const ctl_table_no_const;
79077 +typedef struct ctl_table ctl_table;
79078
79079 struct ctl_node {
79080 struct rb_node node;
79081 diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
79082 index 11baec7..706f99f 100644
79083 --- a/include/linux/sysfs.h
79084 +++ b/include/linux/sysfs.h
79085 @@ -33,7 +33,8 @@ struct attribute {
79086 struct lock_class_key *key;
79087 struct lock_class_key skey;
79088 #endif
79089 -};
79090 +} __do_const;
79091 +typedef struct attribute __no_const attribute_no_const;
79092
79093 /**
79094 * sysfs_attr_init - initialize a dynamically allocated sysfs attribute
79095 @@ -62,7 +63,8 @@ struct attribute_group {
79096 struct attribute *, int);
79097 struct attribute **attrs;
79098 struct bin_attribute **bin_attrs;
79099 -};
79100 +} __do_const;
79101 +typedef struct attribute_group __no_const attribute_group_no_const;
79102
79103 /**
79104 * Use these macros to make defining attributes easier. See include/linux/device.h
79105 @@ -126,7 +128,8 @@ struct bin_attribute {
79106 char *, loff_t, size_t);
79107 int (*mmap)(struct file *, struct kobject *, struct bin_attribute *attr,
79108 struct vm_area_struct *vma);
79109 -};
79110 +} __do_const;
79111 +typedef struct bin_attribute __no_const bin_attribute_no_const;
79112
79113 /**
79114 * sysfs_bin_attr_init - initialize a dynamically allocated bin_attribute
79115 diff --git a/include/linux/sysrq.h b/include/linux/sysrq.h
79116 index 7faf933..9b85a0c 100644
79117 --- a/include/linux/sysrq.h
79118 +++ b/include/linux/sysrq.h
79119 @@ -16,6 +16,7 @@
79120
79121 #include <linux/errno.h>
79122 #include <linux/types.h>
79123 +#include <linux/compiler.h>
79124
79125 /* Enable/disable SYSRQ support by default (0==no, 1==yes). */
79126 #define SYSRQ_DEFAULT_ENABLE 1
79127 @@ -36,7 +37,7 @@ struct sysrq_key_op {
79128 char *help_msg;
79129 char *action_msg;
79130 int enable_mask;
79131 -};
79132 +} __do_const;
79133
79134 #ifdef CONFIG_MAGIC_SYSRQ
79135
79136 diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
79137 index 4ae6f32..425d3e1 100644
79138 --- a/include/linux/thread_info.h
79139 +++ b/include/linux/thread_info.h
79140 @@ -150,6 +150,15 @@ static inline bool test_and_clear_restore_sigmask(void)
79141 #error "no set_restore_sigmask() provided and default one won't work"
79142 #endif
79143
79144 +extern void __check_object_size(const void *ptr, unsigned long n, bool to_user);
79145 +static inline void check_object_size(const void *ptr, unsigned long n, bool to_user)
79146 +{
79147 +#ifndef CONFIG_PAX_USERCOPY_DEBUG
79148 + if (!__builtin_constant_p(n))
79149 +#endif
79150 + __check_object_size(ptr, n, to_user);
79151 +}
79152 +
79153 #endif /* __KERNEL__ */
79154
79155 #endif /* _LINUX_THREAD_INFO_H */
79156 diff --git a/include/linux/tty.h b/include/linux/tty.h
79157 index 64f8646..1515fc7 100644
79158 --- a/include/linux/tty.h
79159 +++ b/include/linux/tty.h
79160 @@ -197,7 +197,7 @@ struct tty_port {
79161 const struct tty_port_operations *ops; /* Port operations */
79162 spinlock_t lock; /* Lock protecting tty field */
79163 int blocked_open; /* Waiting to open */
79164 - int count; /* Usage count */
79165 + atomic_t count; /* Usage count */
79166 wait_queue_head_t open_wait; /* Open waiters */
79167 wait_queue_head_t close_wait; /* Close waiters */
79168 wait_queue_head_t delta_msr_wait; /* Modem status change */
79169 @@ -546,7 +546,7 @@ extern int tty_port_open(struct tty_port *port,
79170 struct tty_struct *tty, struct file *filp);
79171 static inline int tty_port_users(struct tty_port *port)
79172 {
79173 - return port->count + port->blocked_open;
79174 + return atomic_read(&port->count) + port->blocked_open;
79175 }
79176
79177 extern int tty_register_ldisc(int disc, struct tty_ldisc_ops *new_ldisc);
79178 diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
79179 index 756a609..b302dd6 100644
79180 --- a/include/linux/tty_driver.h
79181 +++ b/include/linux/tty_driver.h
79182 @@ -285,7 +285,7 @@ struct tty_operations {
79183 void (*poll_put_char)(struct tty_driver *driver, int line, char ch);
79184 #endif
79185 const struct file_operations *proc_fops;
79186 -};
79187 +} __do_const;
79188
79189 struct tty_driver {
79190 int magic; /* magic number for this structure */
79191 diff --git a/include/linux/tty_ldisc.h b/include/linux/tty_ldisc.h
79192 index f15c898..207b7d1 100644
79193 --- a/include/linux/tty_ldisc.h
79194 +++ b/include/linux/tty_ldisc.h
79195 @@ -211,7 +211,7 @@ struct tty_ldisc_ops {
79196
79197 struct module *owner;
79198
79199 - int refcount;
79200 + atomic_t refcount;
79201 };
79202
79203 struct tty_ldisc {
79204 diff --git a/include/linux/types.h b/include/linux/types.h
79205 index 4d118ba..c3ee9bf 100644
79206 --- a/include/linux/types.h
79207 +++ b/include/linux/types.h
79208 @@ -176,10 +176,26 @@ typedef struct {
79209 int counter;
79210 } atomic_t;
79211
79212 +#ifdef CONFIG_PAX_REFCOUNT
79213 +typedef struct {
79214 + int counter;
79215 +} atomic_unchecked_t;
79216 +#else
79217 +typedef atomic_t atomic_unchecked_t;
79218 +#endif
79219 +
79220 #ifdef CONFIG_64BIT
79221 typedef struct {
79222 long counter;
79223 } atomic64_t;
79224 +
79225 +#ifdef CONFIG_PAX_REFCOUNT
79226 +typedef struct {
79227 + long counter;
79228 +} atomic64_unchecked_t;
79229 +#else
79230 +typedef atomic64_t atomic64_unchecked_t;
79231 +#endif
79232 #endif
79233
79234 struct list_head {
79235 diff --git a/include/linux/uaccess.h b/include/linux/uaccess.h
79236 index 5ca0951..ab496a5 100644
79237 --- a/include/linux/uaccess.h
79238 +++ b/include/linux/uaccess.h
79239 @@ -76,11 +76,11 @@ static inline unsigned long __copy_from_user_nocache(void *to,
79240 long ret; \
79241 mm_segment_t old_fs = get_fs(); \
79242 \
79243 - set_fs(KERNEL_DS); \
79244 pagefault_disable(); \
79245 - ret = __copy_from_user_inatomic(&(retval), (__force typeof(retval) __user *)(addr), sizeof(retval)); \
79246 - pagefault_enable(); \
79247 + set_fs(KERNEL_DS); \
79248 + ret = __copy_from_user_inatomic(&(retval), (typeof(retval) __force_user *)(addr), sizeof(retval)); \
79249 set_fs(old_fs); \
79250 + pagefault_enable(); \
79251 ret; \
79252 })
79253
79254 diff --git a/include/linux/uidgid.h b/include/linux/uidgid.h
79255 index 8e522cbc..aa8572d 100644
79256 --- a/include/linux/uidgid.h
79257 +++ b/include/linux/uidgid.h
79258 @@ -197,4 +197,9 @@ static inline bool kgid_has_mapping(struct user_namespace *ns, kgid_t gid)
79259
79260 #endif /* CONFIG_USER_NS */
79261
79262 +#define GR_GLOBAL_UID(x) from_kuid_munged(&init_user_ns, (x))
79263 +#define GR_GLOBAL_GID(x) from_kgid_munged(&init_user_ns, (x))
79264 +#define gr_is_global_root(x) uid_eq((x), GLOBAL_ROOT_UID)
79265 +#define gr_is_global_nonroot(x) (!uid_eq((x), GLOBAL_ROOT_UID))
79266 +
79267 #endif /* _LINUX_UIDGID_H */
79268 diff --git a/include/linux/unaligned/access_ok.h b/include/linux/unaligned/access_ok.h
79269 index 99c1b4d..562e6f3 100644
79270 --- a/include/linux/unaligned/access_ok.h
79271 +++ b/include/linux/unaligned/access_ok.h
79272 @@ -4,34 +4,34 @@
79273 #include <linux/kernel.h>
79274 #include <asm/byteorder.h>
79275
79276 -static inline u16 get_unaligned_le16(const void *p)
79277 +static inline u16 __intentional_overflow(-1) get_unaligned_le16(const void *p)
79278 {
79279 - return le16_to_cpup((__le16 *)p);
79280 + return le16_to_cpup((const __le16 *)p);
79281 }
79282
79283 -static inline u32 get_unaligned_le32(const void *p)
79284 +static inline u32 __intentional_overflow(-1) get_unaligned_le32(const void *p)
79285 {
79286 - return le32_to_cpup((__le32 *)p);
79287 + return le32_to_cpup((const __le32 *)p);
79288 }
79289
79290 -static inline u64 get_unaligned_le64(const void *p)
79291 +static inline u64 __intentional_overflow(-1) get_unaligned_le64(const void *p)
79292 {
79293 - return le64_to_cpup((__le64 *)p);
79294 + return le64_to_cpup((const __le64 *)p);
79295 }
79296
79297 -static inline u16 get_unaligned_be16(const void *p)
79298 +static inline u16 __intentional_overflow(-1) get_unaligned_be16(const void *p)
79299 {
79300 - return be16_to_cpup((__be16 *)p);
79301 + return be16_to_cpup((const __be16 *)p);
79302 }
79303
79304 -static inline u32 get_unaligned_be32(const void *p)
79305 +static inline u32 __intentional_overflow(-1) get_unaligned_be32(const void *p)
79306 {
79307 - return be32_to_cpup((__be32 *)p);
79308 + return be32_to_cpup((const __be32 *)p);
79309 }
79310
79311 -static inline u64 get_unaligned_be64(const void *p)
79312 +static inline u64 __intentional_overflow(-1) get_unaligned_be64(const void *p)
79313 {
79314 - return be64_to_cpup((__be64 *)p);
79315 + return be64_to_cpup((const __be64 *)p);
79316 }
79317
79318 static inline void put_unaligned_le16(u16 val, void *p)
79319 diff --git a/include/linux/usb.h b/include/linux/usb.h
79320 index 6b02370..2355ffa 100644
79321 --- a/include/linux/usb.h
79322 +++ b/include/linux/usb.h
79323 @@ -563,7 +563,7 @@ struct usb_device {
79324 int maxchild;
79325
79326 u32 quirks;
79327 - atomic_t urbnum;
79328 + atomic_unchecked_t urbnum;
79329
79330 unsigned long active_duration;
79331
79332 @@ -1639,7 +1639,7 @@ void usb_buffer_unmap_sg(const struct usb_device *dev, int is_in,
79333
79334 extern int usb_control_msg(struct usb_device *dev, unsigned int pipe,
79335 __u8 request, __u8 requesttype, __u16 value, __u16 index,
79336 - void *data, __u16 size, int timeout);
79337 + void *data, __u16 size, int timeout) __intentional_overflow(-1);
79338 extern int usb_interrupt_msg(struct usb_device *usb_dev, unsigned int pipe,
79339 void *data, int len, int *actual_length, int timeout);
79340 extern int usb_bulk_msg(struct usb_device *usb_dev, unsigned int pipe,
79341 diff --git a/include/linux/usb/renesas_usbhs.h b/include/linux/usb/renesas_usbhs.h
79342 index e452ba6..78f8e80 100644
79343 --- a/include/linux/usb/renesas_usbhs.h
79344 +++ b/include/linux/usb/renesas_usbhs.h
79345 @@ -39,7 +39,7 @@ enum {
79346 */
79347 struct renesas_usbhs_driver_callback {
79348 int (*notify_hotplug)(struct platform_device *pdev);
79349 -};
79350 +} __no_const;
79351
79352 /*
79353 * callback functions for platform
79354 diff --git a/include/linux/vermagic.h b/include/linux/vermagic.h
79355 index 6f8fbcf..8259001 100644
79356 --- a/include/linux/vermagic.h
79357 +++ b/include/linux/vermagic.h
79358 @@ -25,9 +25,35 @@
79359 #define MODULE_ARCH_VERMAGIC ""
79360 #endif
79361
79362 +#ifdef CONFIG_PAX_REFCOUNT
79363 +#define MODULE_PAX_REFCOUNT "REFCOUNT "
79364 +#else
79365 +#define MODULE_PAX_REFCOUNT ""
79366 +#endif
79367 +
79368 +#ifdef CONSTIFY_PLUGIN
79369 +#define MODULE_CONSTIFY_PLUGIN "CONSTIFY_PLUGIN "
79370 +#else
79371 +#define MODULE_CONSTIFY_PLUGIN ""
79372 +#endif
79373 +
79374 +#ifdef STACKLEAK_PLUGIN
79375 +#define MODULE_STACKLEAK_PLUGIN "STACKLEAK_PLUGIN "
79376 +#else
79377 +#define MODULE_STACKLEAK_PLUGIN ""
79378 +#endif
79379 +
79380 +#ifdef CONFIG_GRKERNSEC
79381 +#define MODULE_GRSEC "GRSEC "
79382 +#else
79383 +#define MODULE_GRSEC ""
79384 +#endif
79385 +
79386 #define VERMAGIC_STRING \
79387 UTS_RELEASE " " \
79388 MODULE_VERMAGIC_SMP MODULE_VERMAGIC_PREEMPT \
79389 MODULE_VERMAGIC_MODULE_UNLOAD MODULE_VERMAGIC_MODVERSIONS \
79390 - MODULE_ARCH_VERMAGIC
79391 + MODULE_ARCH_VERMAGIC \
79392 + MODULE_PAX_REFCOUNT MODULE_CONSTIFY_PLUGIN MODULE_STACKLEAK_PLUGIN \
79393 + MODULE_GRSEC
79394
79395 diff --git a/include/linux/vga_switcheroo.h b/include/linux/vga_switcheroo.h
79396 index 502073a..a7de024 100644
79397 --- a/include/linux/vga_switcheroo.h
79398 +++ b/include/linux/vga_switcheroo.h
79399 @@ -63,8 +63,8 @@ int vga_switcheroo_get_client_state(struct pci_dev *dev);
79400
79401 void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic);
79402
79403 -int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain);
79404 -int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain);
79405 +int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain);
79406 +int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain);
79407 #else
79408
79409 static inline void vga_switcheroo_unregister_client(struct pci_dev *dev) {}
79410 @@ -81,8 +81,8 @@ static inline int vga_switcheroo_get_client_state(struct pci_dev *dev) { return
79411
79412 static inline void vga_switcheroo_set_dynamic_switch(struct pci_dev *pdev, enum vga_switcheroo_state dynamic) {}
79413
79414 -static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
79415 -static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, struct dev_pm_domain *domain) { return -EINVAL; }
79416 +static inline int vga_switcheroo_init_domain_pm_ops(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
79417 +static inline int vga_switcheroo_init_domain_pm_optimus_hdmi_audio(struct device *dev, dev_pm_domain_no_const *domain) { return -EINVAL; }
79418
79419 #endif
79420 #endif /* _LINUX_VGA_SWITCHEROO_H_ */
79421 diff --git a/include/linux/vmalloc.h b/include/linux/vmalloc.h
79422 index 4b8a891..cb8df6e 100644
79423 --- a/include/linux/vmalloc.h
79424 +++ b/include/linux/vmalloc.h
79425 @@ -16,6 +16,11 @@ struct vm_area_struct; /* vma defining user mapping in mm_types.h */
79426 #define VM_USERMAP 0x00000008 /* suitable for remap_vmalloc_range */
79427 #define VM_VPAGES 0x00000010 /* buffer for pages was vmalloc'ed */
79428 #define VM_UNINITIALIZED 0x00000020 /* vm_struct is not fully initialized */
79429 +
79430 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
79431 +#define VM_KERNEXEC 0x00000040 /* allocate from executable kernel memory range */
79432 +#endif
79433 +
79434 /* bits [20..32] reserved for arch specific ioremap internals */
79435
79436 /*
79437 @@ -142,7 +147,7 @@ extern void free_vm_area(struct vm_struct *area);
79438
79439 /* for /dev/kmem */
79440 extern long vread(char *buf, char *addr, unsigned long count);
79441 -extern long vwrite(char *buf, char *addr, unsigned long count);
79442 +extern long vwrite(char *buf, char *addr, unsigned long count) __size_overflow(3);
79443
79444 /*
79445 * Internals. Dont't use..
79446 diff --git a/include/linux/vmstat.h b/include/linux/vmstat.h
79447 index e4b9480..5a5f65a 100644
79448 --- a/include/linux/vmstat.h
79449 +++ b/include/linux/vmstat.h
79450 @@ -90,18 +90,18 @@ static inline void vm_events_fold_cpu(int cpu)
79451 /*
79452 * Zone based page accounting with per cpu differentials.
79453 */
79454 -extern atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
79455 +extern atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS];
79456
79457 static inline void zone_page_state_add(long x, struct zone *zone,
79458 enum zone_stat_item item)
79459 {
79460 - atomic_long_add(x, &zone->vm_stat[item]);
79461 - atomic_long_add(x, &vm_stat[item]);
79462 + atomic_long_add_unchecked(x, &zone->vm_stat[item]);
79463 + atomic_long_add_unchecked(x, &vm_stat[item]);
79464 }
79465
79466 -static inline unsigned long global_page_state(enum zone_stat_item item)
79467 +static inline unsigned long __intentional_overflow(-1) global_page_state(enum zone_stat_item item)
79468 {
79469 - long x = atomic_long_read(&vm_stat[item]);
79470 + long x = atomic_long_read_unchecked(&vm_stat[item]);
79471 #ifdef CONFIG_SMP
79472 if (x < 0)
79473 x = 0;
79474 @@ -109,10 +109,10 @@ static inline unsigned long global_page_state(enum zone_stat_item item)
79475 return x;
79476 }
79477
79478 -static inline unsigned long zone_page_state(struct zone *zone,
79479 +static inline unsigned long __intentional_overflow(-1) zone_page_state(struct zone *zone,
79480 enum zone_stat_item item)
79481 {
79482 - long x = atomic_long_read(&zone->vm_stat[item]);
79483 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
79484 #ifdef CONFIG_SMP
79485 if (x < 0)
79486 x = 0;
79487 @@ -129,7 +129,7 @@ static inline unsigned long zone_page_state(struct zone *zone,
79488 static inline unsigned long zone_page_state_snapshot(struct zone *zone,
79489 enum zone_stat_item item)
79490 {
79491 - long x = atomic_long_read(&zone->vm_stat[item]);
79492 + long x = atomic_long_read_unchecked(&zone->vm_stat[item]);
79493
79494 #ifdef CONFIG_SMP
79495 int cpu;
79496 @@ -220,8 +220,8 @@ static inline void __mod_zone_page_state(struct zone *zone,
79497
79498 static inline void __inc_zone_state(struct zone *zone, enum zone_stat_item item)
79499 {
79500 - atomic_long_inc(&zone->vm_stat[item]);
79501 - atomic_long_inc(&vm_stat[item]);
79502 + atomic_long_inc_unchecked(&zone->vm_stat[item]);
79503 + atomic_long_inc_unchecked(&vm_stat[item]);
79504 }
79505
79506 static inline void __inc_zone_page_state(struct page *page,
79507 @@ -232,8 +232,8 @@ static inline void __inc_zone_page_state(struct page *page,
79508
79509 static inline void __dec_zone_state(struct zone *zone, enum zone_stat_item item)
79510 {
79511 - atomic_long_dec(&zone->vm_stat[item]);
79512 - atomic_long_dec(&vm_stat[item]);
79513 + atomic_long_dec_unchecked(&zone->vm_stat[item]);
79514 + atomic_long_dec_unchecked(&vm_stat[item]);
79515 }
79516
79517 static inline void __dec_zone_page_state(struct page *page,
79518 diff --git a/include/linux/xattr.h b/include/linux/xattr.h
79519 index 91b0a68..0e9adf6 100644
79520 --- a/include/linux/xattr.h
79521 +++ b/include/linux/xattr.h
79522 @@ -28,7 +28,7 @@ struct xattr_handler {
79523 size_t size, int handler_flags);
79524 int (*set)(struct dentry *dentry, const char *name, const void *buffer,
79525 size_t size, int flags, int handler_flags);
79526 -};
79527 +} __do_const;
79528
79529 struct xattr {
79530 const char *name;
79531 @@ -37,6 +37,9 @@ struct xattr {
79532 };
79533
79534 ssize_t xattr_getsecurity(struct inode *, const char *, void *, size_t);
79535 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
79536 +ssize_t pax_getxattr(struct dentry *, void *, size_t);
79537 +#endif
79538 ssize_t vfs_getxattr(struct dentry *, const char *, void *, size_t);
79539 ssize_t vfs_listxattr(struct dentry *d, char *list, size_t size);
79540 int __vfs_setxattr_noperm(struct dentry *, const char *, const void *, size_t, int);
79541 diff --git a/include/linux/zlib.h b/include/linux/zlib.h
79542 index 9c5a6b4..09c9438 100644
79543 --- a/include/linux/zlib.h
79544 +++ b/include/linux/zlib.h
79545 @@ -31,6 +31,7 @@
79546 #define _ZLIB_H
79547
79548 #include <linux/zconf.h>
79549 +#include <linux/compiler.h>
79550
79551 /* zlib deflate based on ZLIB_VERSION "1.1.3" */
79552 /* zlib inflate based on ZLIB_VERSION "1.2.3" */
79553 @@ -179,7 +180,7 @@ typedef z_stream *z_streamp;
79554
79555 /* basic functions */
79556
79557 -extern int zlib_deflate_workspacesize (int windowBits, int memLevel);
79558 +extern int zlib_deflate_workspacesize (int windowBits, int memLevel) __intentional_overflow(0);
79559 /*
79560 Returns the number of bytes that needs to be allocated for a per-
79561 stream workspace with the specified parameters. A pointer to this
79562 diff --git a/include/media/v4l2-dev.h b/include/media/v4l2-dev.h
79563 index c768c9f..bdcaa5a 100644
79564 --- a/include/media/v4l2-dev.h
79565 +++ b/include/media/v4l2-dev.h
79566 @@ -76,7 +76,7 @@ struct v4l2_file_operations {
79567 int (*mmap) (struct file *, struct vm_area_struct *);
79568 int (*open) (struct file *);
79569 int (*release) (struct file *);
79570 -};
79571 +} __do_const;
79572
79573 /*
79574 * Newer version of video_device, handled by videodev2.c
79575 diff --git a/include/media/v4l2-device.h b/include/media/v4l2-device.h
79576 index c9b1593..a572459 100644
79577 --- a/include/media/v4l2-device.h
79578 +++ b/include/media/v4l2-device.h
79579 @@ -95,7 +95,7 @@ int __must_check v4l2_device_register(struct device *dev, struct v4l2_device *v4
79580 this function returns 0. If the name ends with a digit (e.g. cx18),
79581 then the name will be set to cx18-0 since cx180 looks really odd. */
79582 int v4l2_device_set_name(struct v4l2_device *v4l2_dev, const char *basename,
79583 - atomic_t *instance);
79584 + atomic_unchecked_t *instance);
79585
79586 /* Set v4l2_dev->dev to NULL. Call when the USB parent disconnects.
79587 Since the parent disappears this ensures that v4l2_dev doesn't have an
79588 diff --git a/include/net/9p/transport.h b/include/net/9p/transport.h
79589 index 9a36d92..0aafe2a 100644
79590 --- a/include/net/9p/transport.h
79591 +++ b/include/net/9p/transport.h
79592 @@ -60,7 +60,7 @@ struct p9_trans_module {
79593 int (*cancel) (struct p9_client *, struct p9_req_t *req);
79594 int (*zc_request)(struct p9_client *, struct p9_req_t *,
79595 char *, char *, int , int, int, int);
79596 -};
79597 +} __do_const;
79598
79599 void v9fs_register_trans(struct p9_trans_module *m);
79600 void v9fs_unregister_trans(struct p9_trans_module *m);
79601 diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
79602 index 1a966af..2767cf6 100644
79603 --- a/include/net/bluetooth/l2cap.h
79604 +++ b/include/net/bluetooth/l2cap.h
79605 @@ -551,7 +551,7 @@ struct l2cap_ops {
79606 void (*defer) (struct l2cap_chan *chan);
79607 struct sk_buff *(*alloc_skb) (struct l2cap_chan *chan,
79608 unsigned long len, int nb);
79609 -};
79610 +} __do_const;
79611
79612 struct l2cap_conn {
79613 struct hci_conn *hcon;
79614 diff --git a/include/net/caif/cfctrl.h b/include/net/caif/cfctrl.h
79615 index f2ae33d..c457cf0 100644
79616 --- a/include/net/caif/cfctrl.h
79617 +++ b/include/net/caif/cfctrl.h
79618 @@ -52,7 +52,7 @@ struct cfctrl_rsp {
79619 void (*radioset_rsp)(void);
79620 void (*reject_rsp)(struct cflayer *layer, u8 linkid,
79621 struct cflayer *client_layer);
79622 -};
79623 +} __no_const;
79624
79625 /* Link Setup Parameters for CAIF-Links. */
79626 struct cfctrl_link_param {
79627 @@ -101,8 +101,8 @@ struct cfctrl_request_info {
79628 struct cfctrl {
79629 struct cfsrvl serv;
79630 struct cfctrl_rsp res;
79631 - atomic_t req_seq_no;
79632 - atomic_t rsp_seq_no;
79633 + atomic_unchecked_t req_seq_no;
79634 + atomic_unchecked_t rsp_seq_no;
79635 struct list_head list;
79636 /* Protects from simultaneous access to first_req list */
79637 spinlock_t info_list_lock;
79638 diff --git a/include/net/flow.h b/include/net/flow.h
79639 index 628e11b..4c475df 100644
79640 --- a/include/net/flow.h
79641 +++ b/include/net/flow.h
79642 @@ -221,6 +221,6 @@ extern struct flow_cache_object *flow_cache_lookup(
79643
79644 extern void flow_cache_flush(void);
79645 extern void flow_cache_flush_deferred(void);
79646 -extern atomic_t flow_cache_genid;
79647 +extern atomic_unchecked_t flow_cache_genid;
79648
79649 #endif
79650 diff --git a/include/net/genetlink.h b/include/net/genetlink.h
79651 index 8e0b6c8..73cf605 100644
79652 --- a/include/net/genetlink.h
79653 +++ b/include/net/genetlink.h
79654 @@ -120,7 +120,7 @@ struct genl_ops {
79655 struct netlink_callback *cb);
79656 int (*done)(struct netlink_callback *cb);
79657 struct list_head ops_list;
79658 -};
79659 +} __do_const;
79660
79661 extern int __genl_register_family(struct genl_family *family);
79662
79663 diff --git a/include/net/gro_cells.h b/include/net/gro_cells.h
79664 index 734d9b5..48a9a4b 100644
79665 --- a/include/net/gro_cells.h
79666 +++ b/include/net/gro_cells.h
79667 @@ -29,7 +29,7 @@ static inline void gro_cells_receive(struct gro_cells *gcells, struct sk_buff *s
79668 cell += skb_get_rx_queue(skb) & gcells->gro_cells_mask;
79669
79670 if (skb_queue_len(&cell->napi_skbs) > netdev_max_backlog) {
79671 - atomic_long_inc(&dev->rx_dropped);
79672 + atomic_long_inc_unchecked(&dev->rx_dropped);
79673 kfree_skb(skb);
79674 return;
79675 }
79676 diff --git a/include/net/inet_connection_sock.h b/include/net/inet_connection_sock.h
79677 index de2c785..0588a6b 100644
79678 --- a/include/net/inet_connection_sock.h
79679 +++ b/include/net/inet_connection_sock.h
79680 @@ -62,7 +62,7 @@ struct inet_connection_sock_af_ops {
79681 void (*addr2sockaddr)(struct sock *sk, struct sockaddr *);
79682 int (*bind_conflict)(const struct sock *sk,
79683 const struct inet_bind_bucket *tb, bool relax);
79684 -};
79685 +} __do_const;
79686
79687 /** inet_connection_sock - INET connection oriented sock
79688 *
79689 diff --git a/include/net/inetpeer.h b/include/net/inetpeer.h
79690 index 53f464d..0bd0b49 100644
79691 --- a/include/net/inetpeer.h
79692 +++ b/include/net/inetpeer.h
79693 @@ -47,8 +47,8 @@ struct inet_peer {
79694 */
79695 union {
79696 struct {
79697 - atomic_t rid; /* Frag reception counter */
79698 - atomic_t ip_id_count; /* IP ID for the next packet */
79699 + atomic_unchecked_t rid; /* Frag reception counter */
79700 + atomic_unchecked_t ip_id_count; /* IP ID for the next packet */
79701 };
79702 struct rcu_head rcu;
79703 struct inet_peer *gc_next;
79704 @@ -178,16 +178,13 @@ static inline void inet_peer_refcheck(const struct inet_peer *p)
79705 /* can be called with or without local BH being disabled */
79706 static inline int inet_getid(struct inet_peer *p, int more)
79707 {
79708 - int old, new;
79709 + int id;
79710 more++;
79711 inet_peer_refcheck(p);
79712 - do {
79713 - old = atomic_read(&p->ip_id_count);
79714 - new = old + more;
79715 - if (!new)
79716 - new = 1;
79717 - } while (atomic_cmpxchg(&p->ip_id_count, old, new) != old);
79718 - return new;
79719 + id = atomic_add_return_unchecked(more, &p->ip_id_count);
79720 + if (!id)
79721 + id = atomic_inc_return_unchecked(&p->ip_id_count);
79722 + return id;
79723 }
79724
79725 #endif /* _NET_INETPEER_H */
79726 diff --git a/include/net/ip.h b/include/net/ip.h
79727 index 301f10c..b52cdaf 100644
79728 --- a/include/net/ip.h
79729 +++ b/include/net/ip.h
79730 @@ -212,7 +212,7 @@ extern struct local_ports {
79731 } sysctl_local_ports;
79732 extern void inet_get_local_port_range(int *low, int *high);
79733
79734 -extern unsigned long *sysctl_local_reserved_ports;
79735 +extern unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
79736 static inline int inet_is_reserved_local_port(int port)
79737 {
79738 return test_bit(port, sysctl_local_reserved_ports);
79739 diff --git a/include/net/ip_fib.h b/include/net/ip_fib.h
79740 index cbf2be3..3683f6d 100644
79741 --- a/include/net/ip_fib.h
79742 +++ b/include/net/ip_fib.h
79743 @@ -169,7 +169,7 @@ extern __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh);
79744
79745 #define FIB_RES_SADDR(net, res) \
79746 ((FIB_RES_NH(res).nh_saddr_genid == \
79747 - atomic_read(&(net)->ipv4.dev_addr_genid)) ? \
79748 + atomic_read_unchecked(&(net)->ipv4.dev_addr_genid)) ? \
79749 FIB_RES_NH(res).nh_saddr : \
79750 fib_info_update_nh_saddr((net), &FIB_RES_NH(res)))
79751 #define FIB_RES_GW(res) (FIB_RES_NH(res).nh_gw)
79752 diff --git a/include/net/ip_vs.h b/include/net/ip_vs.h
79753 index 772252d..1e69799 100644
79754 --- a/include/net/ip_vs.h
79755 +++ b/include/net/ip_vs.h
79756 @@ -558,7 +558,7 @@ struct ip_vs_conn {
79757 struct ip_vs_conn *control; /* Master control connection */
79758 atomic_t n_control; /* Number of controlled ones */
79759 struct ip_vs_dest *dest; /* real server */
79760 - atomic_t in_pkts; /* incoming packet counter */
79761 + atomic_unchecked_t in_pkts; /* incoming packet counter */
79762
79763 /* packet transmitter for different forwarding methods. If it
79764 mangles the packet, it must return NF_DROP or better NF_STOLEN,
79765 @@ -705,7 +705,7 @@ struct ip_vs_dest {
79766 __be16 port; /* port number of the server */
79767 union nf_inet_addr addr; /* IP address of the server */
79768 volatile unsigned int flags; /* dest status flags */
79769 - atomic_t conn_flags; /* flags to copy to conn */
79770 + atomic_unchecked_t conn_flags; /* flags to copy to conn */
79771 atomic_t weight; /* server weight */
79772
79773 atomic_t refcnt; /* reference counter */
79774 @@ -960,11 +960,11 @@ struct netns_ipvs {
79775 /* ip_vs_lblc */
79776 int sysctl_lblc_expiration;
79777 struct ctl_table_header *lblc_ctl_header;
79778 - struct ctl_table *lblc_ctl_table;
79779 + ctl_table_no_const *lblc_ctl_table;
79780 /* ip_vs_lblcr */
79781 int sysctl_lblcr_expiration;
79782 struct ctl_table_header *lblcr_ctl_header;
79783 - struct ctl_table *lblcr_ctl_table;
79784 + ctl_table_no_const *lblcr_ctl_table;
79785 /* ip_vs_est */
79786 struct list_head est_list; /* estimator list */
79787 spinlock_t est_lock;
79788 diff --git a/include/net/irda/ircomm_tty.h b/include/net/irda/ircomm_tty.h
79789 index 80ffde3..968b0f4 100644
79790 --- a/include/net/irda/ircomm_tty.h
79791 +++ b/include/net/irda/ircomm_tty.h
79792 @@ -35,6 +35,7 @@
79793 #include <linux/termios.h>
79794 #include <linux/timer.h>
79795 #include <linux/tty.h> /* struct tty_struct */
79796 +#include <asm/local.h>
79797
79798 #include <net/irda/irias_object.h>
79799 #include <net/irda/ircomm_core.h>
79800 diff --git a/include/net/iucv/af_iucv.h b/include/net/iucv/af_iucv.h
79801 index 714cc9a..ea05f3e 100644
79802 --- a/include/net/iucv/af_iucv.h
79803 +++ b/include/net/iucv/af_iucv.h
79804 @@ -149,7 +149,7 @@ struct iucv_skb_cb {
79805 struct iucv_sock_list {
79806 struct hlist_head head;
79807 rwlock_t lock;
79808 - atomic_t autobind_name;
79809 + atomic_unchecked_t autobind_name;
79810 };
79811
79812 unsigned int iucv_sock_poll(struct file *file, struct socket *sock,
79813 diff --git a/include/net/llc_c_ac.h b/include/net/llc_c_ac.h
79814 index df83f69..9b640b8 100644
79815 --- a/include/net/llc_c_ac.h
79816 +++ b/include/net/llc_c_ac.h
79817 @@ -87,7 +87,7 @@
79818 #define LLC_CONN_AC_STOP_SENDACK_TMR 70
79819 #define LLC_CONN_AC_START_SENDACK_TMR_IF_NOT_RUNNING 71
79820
79821 -typedef int (*llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79822 +typedef int (* const llc_conn_action_t)(struct sock *sk, struct sk_buff *skb);
79823
79824 extern int llc_conn_ac_clear_remote_busy(struct sock *sk, struct sk_buff *skb);
79825 extern int llc_conn_ac_conn_ind(struct sock *sk, struct sk_buff *skb);
79826 diff --git a/include/net/llc_c_ev.h b/include/net/llc_c_ev.h
79827 index 6ca3113..f8026dd 100644
79828 --- a/include/net/llc_c_ev.h
79829 +++ b/include/net/llc_c_ev.h
79830 @@ -125,8 +125,8 @@ static __inline__ struct llc_conn_state_ev *llc_conn_ev(struct sk_buff *skb)
79831 return (struct llc_conn_state_ev *)skb->cb;
79832 }
79833
79834 -typedef int (*llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79835 -typedef int (*llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79836 +typedef int (* const llc_conn_ev_t)(struct sock *sk, struct sk_buff *skb);
79837 +typedef int (* const llc_conn_ev_qfyr_t)(struct sock *sk, struct sk_buff *skb);
79838
79839 extern int llc_conn_ev_conn_req(struct sock *sk, struct sk_buff *skb);
79840 extern int llc_conn_ev_data_req(struct sock *sk, struct sk_buff *skb);
79841 diff --git a/include/net/llc_c_st.h b/include/net/llc_c_st.h
79842 index 0e79cfb..f46db31 100644
79843 --- a/include/net/llc_c_st.h
79844 +++ b/include/net/llc_c_st.h
79845 @@ -37,7 +37,7 @@ struct llc_conn_state_trans {
79846 u8 next_state;
79847 llc_conn_ev_qfyr_t *ev_qualifiers;
79848 llc_conn_action_t *ev_actions;
79849 -};
79850 +} __do_const;
79851
79852 struct llc_conn_state {
79853 u8 current_state;
79854 diff --git a/include/net/llc_s_ac.h b/include/net/llc_s_ac.h
79855 index 37a3bbd..55a4241 100644
79856 --- a/include/net/llc_s_ac.h
79857 +++ b/include/net/llc_s_ac.h
79858 @@ -23,7 +23,7 @@
79859 #define SAP_ACT_TEST_IND 9
79860
79861 /* All action functions must look like this */
79862 -typedef int (*llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79863 +typedef int (* const llc_sap_action_t)(struct llc_sap *sap, struct sk_buff *skb);
79864
79865 extern int llc_sap_action_unitdata_ind(struct llc_sap *sap,
79866 struct sk_buff *skb);
79867 diff --git a/include/net/llc_s_st.h b/include/net/llc_s_st.h
79868 index 567c681..cd73ac0 100644
79869 --- a/include/net/llc_s_st.h
79870 +++ b/include/net/llc_s_st.h
79871 @@ -20,7 +20,7 @@ struct llc_sap_state_trans {
79872 llc_sap_ev_t ev;
79873 u8 next_state;
79874 llc_sap_action_t *ev_actions;
79875 -};
79876 +} __do_const;
79877
79878 struct llc_sap_state {
79879 u8 curr_state;
79880 diff --git a/include/net/mac80211.h b/include/net/mac80211.h
79881 index cc6035f..a8406fc 100644
79882 --- a/include/net/mac80211.h
79883 +++ b/include/net/mac80211.h
79884 @@ -4361,7 +4361,7 @@ struct rate_control_ops {
79885 void (*add_sta_debugfs)(void *priv, void *priv_sta,
79886 struct dentry *dir);
79887 void (*remove_sta_debugfs)(void *priv, void *priv_sta);
79888 -};
79889 +} __do_const;
79890
79891 static inline int rate_supported(struct ieee80211_sta *sta,
79892 enum ieee80211_band band,
79893 diff --git a/include/net/neighbour.h b/include/net/neighbour.h
79894 index 536501a..7c6193c 100644
79895 --- a/include/net/neighbour.h
79896 +++ b/include/net/neighbour.h
79897 @@ -123,7 +123,7 @@ struct neigh_ops {
79898 void (*error_report)(struct neighbour *, struct sk_buff *);
79899 int (*output)(struct neighbour *, struct sk_buff *);
79900 int (*connected_output)(struct neighbour *, struct sk_buff *);
79901 -};
79902 +} __do_const;
79903
79904 struct pneigh_entry {
79905 struct pneigh_entry *next;
79906 diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h
79907 index 9d22f08..980fbf8 100644
79908 --- a/include/net/net_namespace.h
79909 +++ b/include/net/net_namespace.h
79910 @@ -120,7 +120,7 @@ struct net {
79911 struct netns_ipvs *ipvs;
79912 #endif
79913 struct sock *diag_nlsk;
79914 - atomic_t fnhe_genid;
79915 + atomic_unchecked_t fnhe_genid;
79916 };
79917
79918 /*
79919 @@ -277,7 +277,11 @@ static inline struct net *read_pnet(struct net * const *pnet)
79920 #define __net_init __init
79921 #define __net_exit __exit_refok
79922 #define __net_initdata __initdata
79923 +#ifdef CONSTIFY_PLUGIN
79924 #define __net_initconst __initconst
79925 +#else
79926 +#define __net_initconst __initdata
79927 +#endif
79928 #endif
79929
79930 struct pernet_operations {
79931 @@ -287,7 +291,7 @@ struct pernet_operations {
79932 void (*exit_batch)(struct list_head *net_exit_list);
79933 int *id;
79934 size_t size;
79935 -};
79936 +} __do_const;
79937
79938 /*
79939 * Use these carefully. If you implement a network device and it
79940 @@ -335,23 +339,23 @@ static inline void unregister_net_sysctl_table(struct ctl_table_header *header)
79941
79942 static inline int rt_genid_ipv4(struct net *net)
79943 {
79944 - return atomic_read(&net->ipv4.rt_genid);
79945 + return atomic_read_unchecked(&net->ipv4.rt_genid);
79946 }
79947
79948 static inline void rt_genid_bump_ipv4(struct net *net)
79949 {
79950 - atomic_inc(&net->ipv4.rt_genid);
79951 + atomic_inc_unchecked(&net->ipv4.rt_genid);
79952 }
79953
79954 #if IS_ENABLED(CONFIG_IPV6)
79955 static inline int rt_genid_ipv6(struct net *net)
79956 {
79957 - return atomic_read(&net->ipv6.rt_genid);
79958 + return atomic_read_unchecked(&net->ipv6.rt_genid);
79959 }
79960
79961 static inline void rt_genid_bump_ipv6(struct net *net)
79962 {
79963 - atomic_inc(&net->ipv6.rt_genid);
79964 + atomic_inc_unchecked(&net->ipv6.rt_genid);
79965 }
79966 #else
79967 static inline int rt_genid_ipv6(struct net *net)
79968 @@ -373,12 +377,12 @@ static inline void rt_genid_bump_all(struct net *net)
79969
79970 static inline int fnhe_genid(struct net *net)
79971 {
79972 - return atomic_read(&net->fnhe_genid);
79973 + return atomic_read_unchecked(&net->fnhe_genid);
79974 }
79975
79976 static inline void fnhe_genid_bump(struct net *net)
79977 {
79978 - atomic_inc(&net->fnhe_genid);
79979 + atomic_inc_unchecked(&net->fnhe_genid);
79980 }
79981
79982 #endif /* __NET_NET_NAMESPACE_H */
79983 diff --git a/include/net/netdma.h b/include/net/netdma.h
79984 index 8ba8ce2..99b7fff 100644
79985 --- a/include/net/netdma.h
79986 +++ b/include/net/netdma.h
79987 @@ -24,7 +24,7 @@
79988 #include <linux/dmaengine.h>
79989 #include <linux/skbuff.h>
79990
79991 -int dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79992 +int __intentional_overflow(3,5) dma_skb_copy_datagram_iovec(struct dma_chan* chan,
79993 struct sk_buff *skb, int offset, struct iovec *to,
79994 size_t len, struct dma_pinned_list *pinned_list);
79995
79996 diff --git a/include/net/netlink.h b/include/net/netlink.h
79997 index 9690b0f..87aded7 100644
79998 --- a/include/net/netlink.h
79999 +++ b/include/net/netlink.h
80000 @@ -534,7 +534,7 @@ static inline void *nlmsg_get_pos(struct sk_buff *skb)
80001 static inline void nlmsg_trim(struct sk_buff *skb, const void *mark)
80002 {
80003 if (mark)
80004 - skb_trim(skb, (unsigned char *) mark - skb->data);
80005 + skb_trim(skb, (const unsigned char *) mark - skb->data);
80006 }
80007
80008 /**
80009 diff --git a/include/net/netns/conntrack.h b/include/net/netns/conntrack.h
80010 index c9c0c53..53f24c3 100644
80011 --- a/include/net/netns/conntrack.h
80012 +++ b/include/net/netns/conntrack.h
80013 @@ -12,10 +12,10 @@ struct nf_conntrack_ecache;
80014 struct nf_proto_net {
80015 #ifdef CONFIG_SYSCTL
80016 struct ctl_table_header *ctl_table_header;
80017 - struct ctl_table *ctl_table;
80018 + ctl_table_no_const *ctl_table;
80019 #ifdef CONFIG_NF_CONNTRACK_PROC_COMPAT
80020 struct ctl_table_header *ctl_compat_header;
80021 - struct ctl_table *ctl_compat_table;
80022 + ctl_table_no_const *ctl_compat_table;
80023 #endif
80024 #endif
80025 unsigned int users;
80026 @@ -58,7 +58,7 @@ struct nf_ip_net {
80027 struct nf_icmp_net icmpv6;
80028 #if defined(CONFIG_SYSCTL) && defined(CONFIG_NF_CONNTRACK_PROC_COMPAT)
80029 struct ctl_table_header *ctl_table_header;
80030 - struct ctl_table *ctl_table;
80031 + ctl_table_no_const *ctl_table;
80032 #endif
80033 };
80034
80035 diff --git a/include/net/netns/ipv4.h b/include/net/netns/ipv4.h
80036 index bf2ec22..5e7f9d9 100644
80037 --- a/include/net/netns/ipv4.h
80038 +++ b/include/net/netns/ipv4.h
80039 @@ -67,7 +67,7 @@ struct netns_ipv4 {
80040 kgid_t sysctl_ping_group_range[2];
80041 long sysctl_tcp_mem[3];
80042
80043 - atomic_t dev_addr_genid;
80044 + atomic_unchecked_t dev_addr_genid;
80045
80046 #ifdef CONFIG_IP_MROUTE
80047 #ifndef CONFIG_IP_MROUTE_MULTIPLE_TABLES
80048 @@ -77,6 +77,6 @@ struct netns_ipv4 {
80049 struct fib_rules_ops *mr_rules_ops;
80050 #endif
80051 #endif
80052 - atomic_t rt_genid;
80053 + atomic_unchecked_t rt_genid;
80054 };
80055 #endif
80056 diff --git a/include/net/netns/ipv6.h b/include/net/netns/ipv6.h
80057 index 0fb2401..477d81c 100644
80058 --- a/include/net/netns/ipv6.h
80059 +++ b/include/net/netns/ipv6.h
80060 @@ -71,8 +71,8 @@ struct netns_ipv6 {
80061 struct fib_rules_ops *mr6_rules_ops;
80062 #endif
80063 #endif
80064 - atomic_t dev_addr_genid;
80065 - atomic_t rt_genid;
80066 + atomic_unchecked_t dev_addr_genid;
80067 + atomic_unchecked_t rt_genid;
80068 };
80069
80070 #if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
80071 diff --git a/include/net/ping.h b/include/net/ping.h
80072 index 2b496e9..935fd8d 100644
80073 --- a/include/net/ping.h
80074 +++ b/include/net/ping.h
80075 @@ -56,7 +56,7 @@ struct ping_iter_state {
80076 extern struct proto ping_prot;
80077 extern struct ping_table ping_table;
80078 #if IS_ENABLED(CONFIG_IPV6)
80079 -extern struct pingv6_ops pingv6_ops;
80080 +extern struct pingv6_ops *pingv6_ops;
80081 #endif
80082
80083 struct pingfakehdr {
80084 diff --git a/include/net/protocol.h b/include/net/protocol.h
80085 index 047c047..b9dad15 100644
80086 --- a/include/net/protocol.h
80087 +++ b/include/net/protocol.h
80088 @@ -44,7 +44,7 @@ struct net_protocol {
80089 void (*err_handler)(struct sk_buff *skb, u32 info);
80090 unsigned int no_policy:1,
80091 netns_ok:1;
80092 -};
80093 +} __do_const;
80094
80095 #if IS_ENABLED(CONFIG_IPV6)
80096 struct inet6_protocol {
80097 @@ -57,7 +57,7 @@ struct inet6_protocol {
80098 u8 type, u8 code, int offset,
80099 __be32 info);
80100 unsigned int flags; /* INET6_PROTO_xxx */
80101 -};
80102 +} __do_const;
80103
80104 #define INET6_PROTO_NOPOLICY 0x1
80105 #define INET6_PROTO_FINAL 0x2
80106 diff --git a/include/net/rtnetlink.h b/include/net/rtnetlink.h
80107 index 7026648..584cc8c 100644
80108 --- a/include/net/rtnetlink.h
80109 +++ b/include/net/rtnetlink.h
80110 @@ -81,7 +81,7 @@ struct rtnl_link_ops {
80111 const struct net_device *dev);
80112 unsigned int (*get_num_tx_queues)(void);
80113 unsigned int (*get_num_rx_queues)(void);
80114 -};
80115 +} __do_const;
80116
80117 extern int __rtnl_link_register(struct rtnl_link_ops *ops);
80118 extern void __rtnl_link_unregister(struct rtnl_link_ops *ops);
80119 diff --git a/include/net/sctp/sm.h b/include/net/sctp/sm.h
80120 index 4ef75af..5aa073a 100644
80121 --- a/include/net/sctp/sm.h
80122 +++ b/include/net/sctp/sm.h
80123 @@ -81,7 +81,7 @@ typedef void (sctp_timer_event_t) (unsigned long);
80124 typedef struct {
80125 sctp_state_fn_t *fn;
80126 const char *name;
80127 -} sctp_sm_table_entry_t;
80128 +} __do_const sctp_sm_table_entry_t;
80129
80130 /* A naming convention of "sctp_sf_xxx" applies to all the state functions
80131 * currently in use.
80132 @@ -293,7 +293,7 @@ __u32 sctp_generate_tag(const struct sctp_endpoint *);
80133 __u32 sctp_generate_tsn(const struct sctp_endpoint *);
80134
80135 /* Extern declarations for major data structures. */
80136 -extern sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
80137 +extern sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES];
80138
80139
80140 /* Get the size of a DATA chunk payload. */
80141 diff --git a/include/net/sctp/structs.h b/include/net/sctp/structs.h
80142 index 2174d8d..71d5257 100644
80143 --- a/include/net/sctp/structs.h
80144 +++ b/include/net/sctp/structs.h
80145 @@ -508,7 +508,7 @@ struct sctp_pf {
80146 struct sctp_association *asoc);
80147 void (*addr_v4map) (struct sctp_sock *, union sctp_addr *);
80148 struct sctp_af *af;
80149 -};
80150 +} __do_const;
80151
80152
80153 /* Structure to track chunk fragments that have been acked, but peer
80154 diff --git a/include/net/sock.h b/include/net/sock.h
80155 index 808cbc2..8617e9c 100644
80156 --- a/include/net/sock.h
80157 +++ b/include/net/sock.h
80158 @@ -332,7 +332,7 @@ struct sock {
80159 unsigned int sk_napi_id;
80160 unsigned int sk_ll_usec;
80161 #endif
80162 - atomic_t sk_drops;
80163 + atomic_unchecked_t sk_drops;
80164 int sk_rcvbuf;
80165
80166 struct sk_filter __rcu *sk_filter;
80167 @@ -1194,7 +1194,7 @@ static inline u64 memcg_memory_allocated_read(struct cg_proto *prot)
80168 return ret >> PAGE_SHIFT;
80169 }
80170
80171 -static inline long
80172 +static inline long __intentional_overflow(-1)
80173 sk_memory_allocated(const struct sock *sk)
80174 {
80175 struct proto *prot = sk->sk_prot;
80176 @@ -1821,7 +1821,7 @@ static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
80177 }
80178
80179 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
80180 - char __user *from, char *to,
80181 + char __user *from, unsigned char *to,
80182 int copy, int offset)
80183 {
80184 if (skb->ip_summed == CHECKSUM_NONE) {
80185 @@ -2083,7 +2083,7 @@ static inline void sk_stream_moderate_sndbuf(struct sock *sk)
80186 }
80187 }
80188
80189 -struct sk_buff *sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
80190 +struct sk_buff * __intentional_overflow(0) sk_stream_alloc_skb(struct sock *sk, int size, gfp_t gfp);
80191
80192 /**
80193 * sk_page_frag - return an appropriate page_frag
80194 diff --git a/include/net/tcp.h b/include/net/tcp.h
80195 index b1aa324..b8530ea 100644
80196 --- a/include/net/tcp.h
80197 +++ b/include/net/tcp.h
80198 @@ -527,7 +527,7 @@ extern void tcp_retransmit_timer(struct sock *sk);
80199 extern void tcp_xmit_retransmit_queue(struct sock *);
80200 extern void tcp_simple_retransmit(struct sock *);
80201 extern int tcp_trim_head(struct sock *, struct sk_buff *, u32);
80202 -extern int tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
80203 +extern int __intentional_overflow(3) tcp_fragment(struct sock *, struct sk_buff *, u32, unsigned int);
80204
80205 extern void tcp_send_probe0(struct sock *);
80206 extern void tcp_send_partial(struct sock *);
80207 @@ -699,8 +699,8 @@ struct tcp_skb_cb {
80208 struct inet6_skb_parm h6;
80209 #endif
80210 } header; /* For incoming frames */
80211 - __u32 seq; /* Starting sequence number */
80212 - __u32 end_seq; /* SEQ + FIN + SYN + datalen */
80213 + __u32 seq __intentional_overflow(0); /* Starting sequence number */
80214 + __u32 end_seq __intentional_overflow(0); /* SEQ + FIN + SYN + datalen */
80215 __u32 when; /* used to compute rtt's */
80216 __u8 tcp_flags; /* TCP header flags. (tcp[13]) */
80217
80218 @@ -714,7 +714,7 @@ struct tcp_skb_cb {
80219
80220 __u8 ip_dsfield; /* IPv4 tos or IPv6 dsfield */
80221 /* 1 byte hole */
80222 - __u32 ack_seq; /* Sequence number ACK'd */
80223 + __u32 ack_seq __intentional_overflow(0); /* Sequence number ACK'd */
80224 };
80225
80226 #define TCP_SKB_CB(__skb) ((struct tcp_skb_cb *)&((__skb)->cb[0]))
80227 diff --git a/include/net/xfrm.h b/include/net/xfrm.h
80228 index e253bf0..2278b4b 100644
80229 --- a/include/net/xfrm.h
80230 +++ b/include/net/xfrm.h
80231 @@ -287,7 +287,6 @@ struct xfrm_dst;
80232 struct xfrm_policy_afinfo {
80233 unsigned short family;
80234 struct dst_ops *dst_ops;
80235 - void (*garbage_collect)(struct net *net);
80236 struct dst_entry *(*dst_lookup)(struct net *net, int tos,
80237 const xfrm_address_t *saddr,
80238 const xfrm_address_t *daddr);
80239 @@ -305,7 +304,7 @@ struct xfrm_policy_afinfo {
80240 struct net_device *dev,
80241 const struct flowi *fl);
80242 struct dst_entry *(*blackhole_route)(struct net *net, struct dst_entry *orig);
80243 -};
80244 +} __do_const;
80245
80246 extern int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo);
80247 extern int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo);
80248 @@ -342,7 +341,7 @@ struct xfrm_state_afinfo {
80249 int (*transport_finish)(struct sk_buff *skb,
80250 int async);
80251 void (*local_error)(struct sk_buff *skb, u32 mtu);
80252 -};
80253 +} __do_const;
80254
80255 extern int xfrm_state_register_afinfo(struct xfrm_state_afinfo *afinfo);
80256 extern int xfrm_state_unregister_afinfo(struct xfrm_state_afinfo *afinfo);
80257 @@ -427,7 +426,7 @@ struct xfrm_mode {
80258 struct module *owner;
80259 unsigned int encap;
80260 int flags;
80261 -};
80262 +} __do_const;
80263
80264 /* Flags for xfrm_mode. */
80265 enum {
80266 @@ -524,7 +523,7 @@ struct xfrm_policy {
80267 struct timer_list timer;
80268
80269 struct flow_cache_object flo;
80270 - atomic_t genid;
80271 + atomic_unchecked_t genid;
80272 u32 priority;
80273 u32 index;
80274 struct xfrm_mark mark;
80275 @@ -1164,6 +1163,7 @@ static inline void xfrm_sk_free_policy(struct sock *sk)
80276 }
80277
80278 extern void xfrm_garbage_collect(struct net *net);
80279 +extern void xfrm_garbage_collect_deferred(struct net *net);
80280
80281 #else
80282
80283 @@ -1202,6 +1202,9 @@ static inline int xfrm6_policy_check_reverse(struct sock *sk, int dir,
80284 static inline void xfrm_garbage_collect(struct net *net)
80285 {
80286 }
80287 +static inline void xfrm_garbage_collect_deferred(struct net *net)
80288 +{
80289 +}
80290 #endif
80291
80292 static __inline__
80293 diff --git a/include/rdma/iw_cm.h b/include/rdma/iw_cm.h
80294 index 1017e0b..227aa4d 100644
80295 --- a/include/rdma/iw_cm.h
80296 +++ b/include/rdma/iw_cm.h
80297 @@ -122,7 +122,7 @@ struct iw_cm_verbs {
80298 int backlog);
80299
80300 int (*destroy_listen)(struct iw_cm_id *cm_id);
80301 -};
80302 +} __no_const;
80303
80304 /**
80305 * iw_create_cm_id - Create an IW CM identifier.
80306 diff --git a/include/scsi/libfc.h b/include/scsi/libfc.h
80307 index e1379b4..67eafbe 100644
80308 --- a/include/scsi/libfc.h
80309 +++ b/include/scsi/libfc.h
80310 @@ -762,6 +762,7 @@ struct libfc_function_template {
80311 */
80312 void (*disc_stop_final) (struct fc_lport *);
80313 };
80314 +typedef struct libfc_function_template __no_const libfc_function_template_no_const;
80315
80316 /**
80317 * struct fc_disc - Discovery context
80318 @@ -866,7 +867,7 @@ struct fc_lport {
80319 struct fc_vport *vport;
80320
80321 /* Operational Information */
80322 - struct libfc_function_template tt;
80323 + libfc_function_template_no_const tt;
80324 u8 link_up;
80325 u8 qfull;
80326 enum fc_lport_state state;
80327 diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h
80328 index d65fbec..f80fef2 100644
80329 --- a/include/scsi/scsi_device.h
80330 +++ b/include/scsi/scsi_device.h
80331 @@ -180,9 +180,9 @@ struct scsi_device {
80332 unsigned int max_device_blocked; /* what device_blocked counts down from */
80333 #define SCSI_DEFAULT_DEVICE_BLOCKED 3
80334
80335 - atomic_t iorequest_cnt;
80336 - atomic_t iodone_cnt;
80337 - atomic_t ioerr_cnt;
80338 + atomic_unchecked_t iorequest_cnt;
80339 + atomic_unchecked_t iodone_cnt;
80340 + atomic_unchecked_t ioerr_cnt;
80341
80342 struct device sdev_gendev,
80343 sdev_dev;
80344 diff --git a/include/scsi/scsi_transport_fc.h b/include/scsi/scsi_transport_fc.h
80345 index b797e8f..8e2c3aa 100644
80346 --- a/include/scsi/scsi_transport_fc.h
80347 +++ b/include/scsi/scsi_transport_fc.h
80348 @@ -751,7 +751,8 @@ struct fc_function_template {
80349 unsigned long show_host_system_hostname:1;
80350
80351 unsigned long disable_target_scan:1;
80352 -};
80353 +} __do_const;
80354 +typedef struct fc_function_template __no_const fc_function_template_no_const;
80355
80356
80357 /**
80358 diff --git a/include/sound/compress_driver.h b/include/sound/compress_driver.h
80359 index ae6c3b8..fd748ac 100644
80360 --- a/include/sound/compress_driver.h
80361 +++ b/include/sound/compress_driver.h
80362 @@ -128,7 +128,7 @@ struct snd_compr_ops {
80363 struct snd_compr_caps *caps);
80364 int (*get_codec_caps) (struct snd_compr_stream *stream,
80365 struct snd_compr_codec_caps *codec);
80366 -};
80367 +} __no_const;
80368
80369 /**
80370 * struct snd_compr: Compressed device
80371 diff --git a/include/sound/soc.h b/include/sound/soc.h
80372 index d22cb0a..c6ba150 100644
80373 --- a/include/sound/soc.h
80374 +++ b/include/sound/soc.h
80375 @@ -780,7 +780,7 @@ struct snd_soc_codec_driver {
80376 /* probe ordering - for components with runtime dependencies */
80377 int probe_order;
80378 int remove_order;
80379 -};
80380 +} __do_const;
80381
80382 /* SoC platform interface */
80383 struct snd_soc_platform_driver {
80384 @@ -826,7 +826,7 @@ struct snd_soc_platform_driver {
80385 unsigned int (*read)(struct snd_soc_platform *, unsigned int);
80386 int (*write)(struct snd_soc_platform *, unsigned int, unsigned int);
80387 int (*bespoke_trigger)(struct snd_pcm_substream *, int);
80388 -};
80389 +} __do_const;
80390
80391 struct snd_soc_platform {
80392 const char *name;
80393 diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
80394 index 23bfd10..1ff3e35 100644
80395 --- a/include/target/target_core_base.h
80396 +++ b/include/target/target_core_base.h
80397 @@ -664,7 +664,7 @@ struct se_device {
80398 spinlock_t stats_lock;
80399 /* Active commands on this virtual SE device */
80400 atomic_t simple_cmds;
80401 - atomic_t dev_ordered_id;
80402 + atomic_unchecked_t dev_ordered_id;
80403 atomic_t dev_ordered_sync;
80404 atomic_t dev_qf_count;
80405 int export_count;
80406 diff --git a/include/trace/events/fs.h b/include/trace/events/fs.h
80407 new file mode 100644
80408 index 0000000..fb634b7
80409 --- /dev/null
80410 +++ b/include/trace/events/fs.h
80411 @@ -0,0 +1,53 @@
80412 +#undef TRACE_SYSTEM
80413 +#define TRACE_SYSTEM fs
80414 +
80415 +#if !defined(_TRACE_FS_H) || defined(TRACE_HEADER_MULTI_READ)
80416 +#define _TRACE_FS_H
80417 +
80418 +#include <linux/fs.h>
80419 +#include <linux/tracepoint.h>
80420 +
80421 +TRACE_EVENT(do_sys_open,
80422 +
80423 + TP_PROTO(const char *filename, int flags, int mode),
80424 +
80425 + TP_ARGS(filename, flags, mode),
80426 +
80427 + TP_STRUCT__entry(
80428 + __string( filename, filename )
80429 + __field( int, flags )
80430 + __field( int, mode )
80431 + ),
80432 +
80433 + TP_fast_assign(
80434 + __assign_str(filename, filename);
80435 + __entry->flags = flags;
80436 + __entry->mode = mode;
80437 + ),
80438 +
80439 + TP_printk("\"%s\" %x %o",
80440 + __get_str(filename), __entry->flags, __entry->mode)
80441 +);
80442 +
80443 +TRACE_EVENT(open_exec,
80444 +
80445 + TP_PROTO(const char *filename),
80446 +
80447 + TP_ARGS(filename),
80448 +
80449 + TP_STRUCT__entry(
80450 + __string( filename, filename )
80451 + ),
80452 +
80453 + TP_fast_assign(
80454 + __assign_str(filename, filename);
80455 + ),
80456 +
80457 + TP_printk("\"%s\"",
80458 + __get_str(filename))
80459 +);
80460 +
80461 +#endif /* _TRACE_FS_H */
80462 +
80463 +/* This part must be outside protection */
80464 +#include <trace/define_trace.h>
80465 diff --git a/include/trace/events/irq.h b/include/trace/events/irq.h
80466 index 1c09820..7f5ec79 100644
80467 --- a/include/trace/events/irq.h
80468 +++ b/include/trace/events/irq.h
80469 @@ -36,7 +36,7 @@ struct softirq_action;
80470 */
80471 TRACE_EVENT(irq_handler_entry,
80472
80473 - TP_PROTO(int irq, struct irqaction *action),
80474 + TP_PROTO(int irq, const struct irqaction *action),
80475
80476 TP_ARGS(irq, action),
80477
80478 @@ -66,7 +66,7 @@ TRACE_EVENT(irq_handler_entry,
80479 */
80480 TRACE_EVENT(irq_handler_exit,
80481
80482 - TP_PROTO(int irq, struct irqaction *action, int ret),
80483 + TP_PROTO(int irq, const struct irqaction *action, int ret),
80484
80485 TP_ARGS(irq, action, ret),
80486
80487 diff --git a/include/uapi/linux/a.out.h b/include/uapi/linux/a.out.h
80488 index 7caf44c..23c6f27 100644
80489 --- a/include/uapi/linux/a.out.h
80490 +++ b/include/uapi/linux/a.out.h
80491 @@ -39,6 +39,14 @@ enum machine_type {
80492 M_MIPS2 = 152 /* MIPS R6000/R4000 binary */
80493 };
80494
80495 +/* Constants for the N_FLAGS field */
80496 +#define F_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
80497 +#define F_PAX_EMUTRAMP 2 /* Emulate trampolines */
80498 +#define F_PAX_MPROTECT 4 /* Restrict mprotect() */
80499 +#define F_PAX_RANDMMAP 8 /* Randomize mmap() base */
80500 +/*#define F_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
80501 +#define F_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
80502 +
80503 #if !defined (N_MAGIC)
80504 #define N_MAGIC(exec) ((exec).a_info & 0xffff)
80505 #endif
80506 diff --git a/include/uapi/linux/byteorder/little_endian.h b/include/uapi/linux/byteorder/little_endian.h
80507 index d876736..ccce5c0 100644
80508 --- a/include/uapi/linux/byteorder/little_endian.h
80509 +++ b/include/uapi/linux/byteorder/little_endian.h
80510 @@ -42,51 +42,51 @@
80511
80512 static inline __le64 __cpu_to_le64p(const __u64 *p)
80513 {
80514 - return (__force __le64)*p;
80515 + return (__force const __le64)*p;
80516 }
80517 -static inline __u64 __le64_to_cpup(const __le64 *p)
80518 +static inline __u64 __intentional_overflow(-1) __le64_to_cpup(const __le64 *p)
80519 {
80520 - return (__force __u64)*p;
80521 + return (__force const __u64)*p;
80522 }
80523 static inline __le32 __cpu_to_le32p(const __u32 *p)
80524 {
80525 - return (__force __le32)*p;
80526 + return (__force const __le32)*p;
80527 }
80528 static inline __u32 __le32_to_cpup(const __le32 *p)
80529 {
80530 - return (__force __u32)*p;
80531 + return (__force const __u32)*p;
80532 }
80533 static inline __le16 __cpu_to_le16p(const __u16 *p)
80534 {
80535 - return (__force __le16)*p;
80536 + return (__force const __le16)*p;
80537 }
80538 static inline __u16 __le16_to_cpup(const __le16 *p)
80539 {
80540 - return (__force __u16)*p;
80541 + return (__force const __u16)*p;
80542 }
80543 static inline __be64 __cpu_to_be64p(const __u64 *p)
80544 {
80545 - return (__force __be64)__swab64p(p);
80546 + return (__force const __be64)__swab64p(p);
80547 }
80548 static inline __u64 __be64_to_cpup(const __be64 *p)
80549 {
80550 - return __swab64p((__u64 *)p);
80551 + return __swab64p((const __u64 *)p);
80552 }
80553 static inline __be32 __cpu_to_be32p(const __u32 *p)
80554 {
80555 - return (__force __be32)__swab32p(p);
80556 + return (__force const __be32)__swab32p(p);
80557 }
80558 -static inline __u32 __be32_to_cpup(const __be32 *p)
80559 +static inline __u32 __intentional_overflow(-1) __be32_to_cpup(const __be32 *p)
80560 {
80561 - return __swab32p((__u32 *)p);
80562 + return __swab32p((const __u32 *)p);
80563 }
80564 static inline __be16 __cpu_to_be16p(const __u16 *p)
80565 {
80566 - return (__force __be16)__swab16p(p);
80567 + return (__force const __be16)__swab16p(p);
80568 }
80569 static inline __u16 __be16_to_cpup(const __be16 *p)
80570 {
80571 - return __swab16p((__u16 *)p);
80572 + return __swab16p((const __u16 *)p);
80573 }
80574 #define __cpu_to_le64s(x) do { (void)(x); } while (0)
80575 #define __le64_to_cpus(x) do { (void)(x); } while (0)
80576 diff --git a/include/uapi/linux/elf.h b/include/uapi/linux/elf.h
80577 index ef6103b..d4e65dd 100644
80578 --- a/include/uapi/linux/elf.h
80579 +++ b/include/uapi/linux/elf.h
80580 @@ -37,6 +37,17 @@ typedef __s64 Elf64_Sxword;
80581 #define PT_GNU_EH_FRAME 0x6474e550
80582
80583 #define PT_GNU_STACK (PT_LOOS + 0x474e551)
80584 +#define PT_GNU_RELRO (PT_LOOS + 0x474e552)
80585 +
80586 +#define PT_PAX_FLAGS (PT_LOOS + 0x5041580)
80587 +
80588 +/* Constants for the e_flags field */
80589 +#define EF_PAX_PAGEEXEC 1 /* Paging based non-executable pages */
80590 +#define EF_PAX_EMUTRAMP 2 /* Emulate trampolines */
80591 +#define EF_PAX_MPROTECT 4 /* Restrict mprotect() */
80592 +#define EF_PAX_RANDMMAP 8 /* Randomize mmap() base */
80593 +/*#define EF_PAX_RANDEXEC 16*/ /* Randomize ET_EXEC base */
80594 +#define EF_PAX_SEGMEXEC 32 /* Segmentation based non-executable pages */
80595
80596 /*
80597 * Extended Numbering
80598 @@ -94,6 +105,8 @@ typedef __s64 Elf64_Sxword;
80599 #define DT_DEBUG 21
80600 #define DT_TEXTREL 22
80601 #define DT_JMPREL 23
80602 +#define DT_FLAGS 30
80603 + #define DF_TEXTREL 0x00000004
80604 #define DT_ENCODING 32
80605 #define OLD_DT_LOOS 0x60000000
80606 #define DT_LOOS 0x6000000d
80607 @@ -240,6 +253,19 @@ typedef struct elf64_hdr {
80608 #define PF_W 0x2
80609 #define PF_X 0x1
80610
80611 +#define PF_PAGEEXEC (1U << 4) /* Enable PAGEEXEC */
80612 +#define PF_NOPAGEEXEC (1U << 5) /* Disable PAGEEXEC */
80613 +#define PF_SEGMEXEC (1U << 6) /* Enable SEGMEXEC */
80614 +#define PF_NOSEGMEXEC (1U << 7) /* Disable SEGMEXEC */
80615 +#define PF_MPROTECT (1U << 8) /* Enable MPROTECT */
80616 +#define PF_NOMPROTECT (1U << 9) /* Disable MPROTECT */
80617 +/*#define PF_RANDEXEC (1U << 10)*/ /* Enable RANDEXEC */
80618 +/*#define PF_NORANDEXEC (1U << 11)*/ /* Disable RANDEXEC */
80619 +#define PF_EMUTRAMP (1U << 12) /* Enable EMUTRAMP */
80620 +#define PF_NOEMUTRAMP (1U << 13) /* Disable EMUTRAMP */
80621 +#define PF_RANDMMAP (1U << 14) /* Enable RANDMMAP */
80622 +#define PF_NORANDMMAP (1U << 15) /* Disable RANDMMAP */
80623 +
80624 typedef struct elf32_phdr{
80625 Elf32_Word p_type;
80626 Elf32_Off p_offset;
80627 @@ -332,6 +358,8 @@ typedef struct elf64_shdr {
80628 #define EI_OSABI 7
80629 #define EI_PAD 8
80630
80631 +#define EI_PAX 14
80632 +
80633 #define ELFMAG0 0x7f /* EI_MAG */
80634 #define ELFMAG1 'E'
80635 #define ELFMAG2 'L'
80636 diff --git a/include/uapi/linux/personality.h b/include/uapi/linux/personality.h
80637 index aa169c4..6a2771d 100644
80638 --- a/include/uapi/linux/personality.h
80639 +++ b/include/uapi/linux/personality.h
80640 @@ -30,6 +30,7 @@ enum {
80641 #define PER_CLEAR_ON_SETID (READ_IMPLIES_EXEC | \
80642 ADDR_NO_RANDOMIZE | \
80643 ADDR_COMPAT_LAYOUT | \
80644 + ADDR_LIMIT_3GB | \
80645 MMAP_PAGE_ZERO)
80646
80647 /*
80648 diff --git a/include/uapi/linux/screen_info.h b/include/uapi/linux/screen_info.h
80649 index 7530e74..e714828 100644
80650 --- a/include/uapi/linux/screen_info.h
80651 +++ b/include/uapi/linux/screen_info.h
80652 @@ -43,7 +43,8 @@ struct screen_info {
80653 __u16 pages; /* 0x32 */
80654 __u16 vesa_attributes; /* 0x34 */
80655 __u32 capabilities; /* 0x36 */
80656 - __u8 _reserved[6]; /* 0x3a */
80657 + __u16 vesapm_size; /* 0x3a */
80658 + __u8 _reserved[4]; /* 0x3c */
80659 } __attribute__((packed));
80660
80661 #define VIDEO_TYPE_MDA 0x10 /* Monochrome Text Display */
80662 diff --git a/include/uapi/linux/swab.h b/include/uapi/linux/swab.h
80663 index 0e011eb..82681b1 100644
80664 --- a/include/uapi/linux/swab.h
80665 +++ b/include/uapi/linux/swab.h
80666 @@ -43,7 +43,7 @@
80667 * ___swab16, ___swab32, ___swab64, ___swahw32, ___swahb32
80668 */
80669
80670 -static inline __attribute_const__ __u16 __fswab16(__u16 val)
80671 +static inline __intentional_overflow(-1) __attribute_const__ __u16 __fswab16(__u16 val)
80672 {
80673 #ifdef __HAVE_BUILTIN_BSWAP16__
80674 return __builtin_bswap16(val);
80675 @@ -54,7 +54,7 @@ static inline __attribute_const__ __u16 __fswab16(__u16 val)
80676 #endif
80677 }
80678
80679 -static inline __attribute_const__ __u32 __fswab32(__u32 val)
80680 +static inline __intentional_overflow(-1) __attribute_const__ __u32 __fswab32(__u32 val)
80681 {
80682 #ifdef __HAVE_BUILTIN_BSWAP32__
80683 return __builtin_bswap32(val);
80684 @@ -65,7 +65,7 @@ static inline __attribute_const__ __u32 __fswab32(__u32 val)
80685 #endif
80686 }
80687
80688 -static inline __attribute_const__ __u64 __fswab64(__u64 val)
80689 +static inline __intentional_overflow(-1) __attribute_const__ __u64 __fswab64(__u64 val)
80690 {
80691 #ifdef __HAVE_BUILTIN_BSWAP64__
80692 return __builtin_bswap64(val);
80693 diff --git a/include/uapi/linux/sysctl.h b/include/uapi/linux/sysctl.h
80694 index 6d67213..8dab561 100644
80695 --- a/include/uapi/linux/sysctl.h
80696 +++ b/include/uapi/linux/sysctl.h
80697 @@ -155,7 +155,11 @@ enum
80698 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
80699 };
80700
80701 -
80702 +#ifdef CONFIG_PAX_SOFTMODE
80703 +enum {
80704 + PAX_SOFTMODE=1 /* PaX: disable/enable soft mode */
80705 +};
80706 +#endif
80707
80708 /* CTL_VM names: */
80709 enum
80710 diff --git a/include/uapi/linux/xattr.h b/include/uapi/linux/xattr.h
80711 index e4629b9..6958086 100644
80712 --- a/include/uapi/linux/xattr.h
80713 +++ b/include/uapi/linux/xattr.h
80714 @@ -63,5 +63,9 @@
80715 #define XATTR_POSIX_ACL_DEFAULT "posix_acl_default"
80716 #define XATTR_NAME_POSIX_ACL_DEFAULT XATTR_SYSTEM_PREFIX XATTR_POSIX_ACL_DEFAULT
80717
80718 +/* User namespace */
80719 +#define XATTR_PAX_PREFIX XATTR_USER_PREFIX "pax."
80720 +#define XATTR_PAX_FLAGS_SUFFIX "flags"
80721 +#define XATTR_NAME_PAX_FLAGS XATTR_PAX_PREFIX XATTR_PAX_FLAGS_SUFFIX
80722
80723 #endif /* _UAPI_LINUX_XATTR_H */
80724 diff --git a/include/video/udlfb.h b/include/video/udlfb.h
80725 index f9466fa..f4e2b81 100644
80726 --- a/include/video/udlfb.h
80727 +++ b/include/video/udlfb.h
80728 @@ -53,10 +53,10 @@ struct dlfb_data {
80729 u32 pseudo_palette[256];
80730 int blank_mode; /*one of FB_BLANK_ */
80731 /* blit-only rendering path metrics, exposed through sysfs */
80732 - atomic_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80733 - atomic_t bytes_identical; /* saved effort with backbuffer comparison */
80734 - atomic_t bytes_sent; /* to usb, after compression including overhead */
80735 - atomic_t cpu_kcycles_used; /* transpired during pixel processing */
80736 + atomic_unchecked_t bytes_rendered; /* raw pixel-bytes driver asked to render */
80737 + atomic_unchecked_t bytes_identical; /* saved effort with backbuffer comparison */
80738 + atomic_unchecked_t bytes_sent; /* to usb, after compression including overhead */
80739 + atomic_unchecked_t cpu_kcycles_used; /* transpired during pixel processing */
80740 };
80741
80742 #define NR_USB_REQUEST_I2C_SUB_IO 0x02
80743 diff --git a/include/video/uvesafb.h b/include/video/uvesafb.h
80744 index 30f5362..8ed8ac9 100644
80745 --- a/include/video/uvesafb.h
80746 +++ b/include/video/uvesafb.h
80747 @@ -122,6 +122,7 @@ struct uvesafb_par {
80748 u8 ypan; /* 0 - nothing, 1 - ypan, 2 - ywrap */
80749 u8 pmi_setpal; /* PMI for palette changes */
80750 u16 *pmi_base; /* protected mode interface location */
80751 + u8 *pmi_code; /* protected mode code location */
80752 void *pmi_start;
80753 void *pmi_pal;
80754 u8 *vbe_state_orig; /*
80755 diff --git a/init/Kconfig b/init/Kconfig
80756 index 3ecd8a1..627843f 100644
80757 --- a/init/Kconfig
80758 +++ b/init/Kconfig
80759 @@ -1086,6 +1086,7 @@ endif # CGROUPS
80760
80761 config CHECKPOINT_RESTORE
80762 bool "Checkpoint/restore support" if EXPERT
80763 + depends on !GRKERNSEC
80764 default n
80765 help
80766 Enables additional kernel features in a sake of checkpoint/restore.
80767 @@ -1557,7 +1558,7 @@ config SLUB_DEBUG
80768
80769 config COMPAT_BRK
80770 bool "Disable heap randomization"
80771 - default y
80772 + default n
80773 help
80774 Randomizing heap placement makes heap exploits harder, but it
80775 also breaks ancient binaries (including anything libc5 based).
80776 @@ -1832,7 +1833,7 @@ config INIT_ALL_POSSIBLE
80777 config STOP_MACHINE
80778 bool
80779 default y
80780 - depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU
80781 + depends on (SMP && MODULE_UNLOAD) || HOTPLUG_CPU || GRKERNSEC
80782 help
80783 Need stop_machine() primitive.
80784
80785 diff --git a/init/Makefile b/init/Makefile
80786 index 7bc47ee..6da2dc7 100644
80787 --- a/init/Makefile
80788 +++ b/init/Makefile
80789 @@ -2,6 +2,9 @@
80790 # Makefile for the linux kernel.
80791 #
80792
80793 +ccflags-y := $(GCC_PLUGINS_CFLAGS)
80794 +asflags-y := $(GCC_PLUGINS_AFLAGS)
80795 +
80796 obj-y := main.o version.o mounts.o
80797 ifneq ($(CONFIG_BLK_DEV_INITRD),y)
80798 obj-y += noinitramfs.o
80799 diff --git a/init/do_mounts.c b/init/do_mounts.c
80800 index a51cddc..25c2768 100644
80801 --- a/init/do_mounts.c
80802 +++ b/init/do_mounts.c
80803 @@ -357,11 +357,11 @@ static void __init get_fs_names(char *page)
80804 static int __init do_mount_root(char *name, char *fs, int flags, void *data)
80805 {
80806 struct super_block *s;
80807 - int err = sys_mount(name, "/root", fs, flags, data);
80808 + int err = sys_mount((char __force_user *)name, (char __force_user *)"/root", (char __force_user *)fs, flags, (void __force_user *)data);
80809 if (err)
80810 return err;
80811
80812 - sys_chdir("/root");
80813 + sys_chdir((const char __force_user *)"/root");
80814 s = current->fs->pwd.dentry->d_sb;
80815 ROOT_DEV = s->s_dev;
80816 printk(KERN_INFO
80817 @@ -482,18 +482,18 @@ void __init change_floppy(char *fmt, ...)
80818 va_start(args, fmt);
80819 vsprintf(buf, fmt, args);
80820 va_end(args);
80821 - fd = sys_open("/dev/root", O_RDWR | O_NDELAY, 0);
80822 + fd = sys_open((char __user *)"/dev/root", O_RDWR | O_NDELAY, 0);
80823 if (fd >= 0) {
80824 sys_ioctl(fd, FDEJECT, 0);
80825 sys_close(fd);
80826 }
80827 printk(KERN_NOTICE "VFS: Insert %s and press ENTER\n", buf);
80828 - fd = sys_open("/dev/console", O_RDWR, 0);
80829 + fd = sys_open((__force const char __user *)"/dev/console", O_RDWR, 0);
80830 if (fd >= 0) {
80831 sys_ioctl(fd, TCGETS, (long)&termios);
80832 termios.c_lflag &= ~ICANON;
80833 sys_ioctl(fd, TCSETSF, (long)&termios);
80834 - sys_read(fd, &c, 1);
80835 + sys_read(fd, (char __user *)&c, 1);
80836 termios.c_lflag |= ICANON;
80837 sys_ioctl(fd, TCSETSF, (long)&termios);
80838 sys_close(fd);
80839 @@ -587,8 +587,8 @@ void __init prepare_namespace(void)
80840 mount_root();
80841 out:
80842 devtmpfs_mount("dev");
80843 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80844 - sys_chroot(".");
80845 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80846 + sys_chroot((const char __force_user *)".");
80847 }
80848
80849 static bool is_tmpfs;
80850 diff --git a/init/do_mounts.h b/init/do_mounts.h
80851 index f5b978a..69dbfe8 100644
80852 --- a/init/do_mounts.h
80853 +++ b/init/do_mounts.h
80854 @@ -15,15 +15,15 @@ extern int root_mountflags;
80855
80856 static inline int create_dev(char *name, dev_t dev)
80857 {
80858 - sys_unlink(name);
80859 - return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
80860 + sys_unlink((char __force_user *)name);
80861 + return sys_mknod((char __force_user *)name, S_IFBLK|0600, new_encode_dev(dev));
80862 }
80863
80864 #if BITS_PER_LONG == 32
80865 static inline u32 bstat(char *name)
80866 {
80867 struct stat64 stat;
80868 - if (sys_stat64(name, &stat) != 0)
80869 + if (sys_stat64((char __force_user *)name, (struct stat64 __force_user *)&stat) != 0)
80870 return 0;
80871 if (!S_ISBLK(stat.st_mode))
80872 return 0;
80873 @@ -35,7 +35,7 @@ static inline u32 bstat(char *name)
80874 static inline u32 bstat(char *name)
80875 {
80876 struct stat stat;
80877 - if (sys_newstat(name, &stat) != 0)
80878 + if (sys_newstat((const char __force_user *)name, (struct stat __force_user *)&stat) != 0)
80879 return 0;
80880 if (!S_ISBLK(stat.st_mode))
80881 return 0;
80882 diff --git a/init/do_mounts_initrd.c b/init/do_mounts_initrd.c
80883 index 3e0878e..8a9d7a0 100644
80884 --- a/init/do_mounts_initrd.c
80885 +++ b/init/do_mounts_initrd.c
80886 @@ -37,13 +37,13 @@ static int init_linuxrc(struct subprocess_info *info, struct cred *new)
80887 {
80888 sys_unshare(CLONE_FS | CLONE_FILES);
80889 /* stdin/stdout/stderr for /linuxrc */
80890 - sys_open("/dev/console", O_RDWR, 0);
80891 + sys_open((const char __force_user *)"/dev/console", O_RDWR, 0);
80892 sys_dup(0);
80893 sys_dup(0);
80894 /* move initrd over / and chdir/chroot in initrd root */
80895 - sys_chdir("/root");
80896 - sys_mount(".", "/", NULL, MS_MOVE, NULL);
80897 - sys_chroot(".");
80898 + sys_chdir((const char __force_user *)"/root");
80899 + sys_mount((char __force_user *)".", (char __force_user *)"/", NULL, MS_MOVE, NULL);
80900 + sys_chroot((const char __force_user *)".");
80901 sys_setsid();
80902 return 0;
80903 }
80904 @@ -59,8 +59,8 @@ static void __init handle_initrd(void)
80905 create_dev("/dev/root.old", Root_RAM0);
80906 /* mount initrd on rootfs' /root */
80907 mount_block_root("/dev/root.old", root_mountflags & ~MS_RDONLY);
80908 - sys_mkdir("/old", 0700);
80909 - sys_chdir("/old");
80910 + sys_mkdir((const char __force_user *)"/old", 0700);
80911 + sys_chdir((const char __force_user *)"/old");
80912
80913 /* try loading default modules from initrd */
80914 load_default_modules();
80915 @@ -80,31 +80,31 @@ static void __init handle_initrd(void)
80916 current->flags &= ~PF_FREEZER_SKIP;
80917
80918 /* move initrd to rootfs' /old */
80919 - sys_mount("..", ".", NULL, MS_MOVE, NULL);
80920 + sys_mount((char __force_user *)"..", (char __force_user *)".", NULL, MS_MOVE, NULL);
80921 /* switch root and cwd back to / of rootfs */
80922 - sys_chroot("..");
80923 + sys_chroot((const char __force_user *)"..");
80924
80925 if (new_decode_dev(real_root_dev) == Root_RAM0) {
80926 - sys_chdir("/old");
80927 + sys_chdir((const char __force_user *)"/old");
80928 return;
80929 }
80930
80931 - sys_chdir("/");
80932 + sys_chdir((const char __force_user *)"/");
80933 ROOT_DEV = new_decode_dev(real_root_dev);
80934 mount_root();
80935
80936 printk(KERN_NOTICE "Trying to move old root to /initrd ... ");
80937 - error = sys_mount("/old", "/root/initrd", NULL, MS_MOVE, NULL);
80938 + error = sys_mount((char __force_user *)"/old", (char __force_user *)"/root/initrd", NULL, MS_MOVE, NULL);
80939 if (!error)
80940 printk("okay\n");
80941 else {
80942 - int fd = sys_open("/dev/root.old", O_RDWR, 0);
80943 + int fd = sys_open((const char __force_user *)"/dev/root.old", O_RDWR, 0);
80944 if (error == -ENOENT)
80945 printk("/initrd does not exist. Ignored.\n");
80946 else
80947 printk("failed\n");
80948 printk(KERN_NOTICE "Unmounting old root\n");
80949 - sys_umount("/old", MNT_DETACH);
80950 + sys_umount((char __force_user *)"/old", MNT_DETACH);
80951 printk(KERN_NOTICE "Trying to free ramdisk memory ... ");
80952 if (fd < 0) {
80953 error = fd;
80954 @@ -127,11 +127,11 @@ int __init initrd_load(void)
80955 * mounted in the normal path.
80956 */
80957 if (rd_load_image("/initrd.image") && ROOT_DEV != Root_RAM0) {
80958 - sys_unlink("/initrd.image");
80959 + sys_unlink((const char __force_user *)"/initrd.image");
80960 handle_initrd();
80961 return 1;
80962 }
80963 }
80964 - sys_unlink("/initrd.image");
80965 + sys_unlink((const char __force_user *)"/initrd.image");
80966 return 0;
80967 }
80968 diff --git a/init/do_mounts_md.c b/init/do_mounts_md.c
80969 index 8cb6db5..d729f50 100644
80970 --- a/init/do_mounts_md.c
80971 +++ b/init/do_mounts_md.c
80972 @@ -180,7 +180,7 @@ static void __init md_setup_drive(void)
80973 partitioned ? "_d" : "", minor,
80974 md_setup_args[ent].device_names);
80975
80976 - fd = sys_open(name, 0, 0);
80977 + fd = sys_open((char __force_user *)name, 0, 0);
80978 if (fd < 0) {
80979 printk(KERN_ERR "md: open failed - cannot start "
80980 "array %s\n", name);
80981 @@ -243,7 +243,7 @@ static void __init md_setup_drive(void)
80982 * array without it
80983 */
80984 sys_close(fd);
80985 - fd = sys_open(name, 0, 0);
80986 + fd = sys_open((char __force_user *)name, 0, 0);
80987 sys_ioctl(fd, BLKRRPART, 0);
80988 }
80989 sys_close(fd);
80990 @@ -293,7 +293,7 @@ static void __init autodetect_raid(void)
80991
80992 wait_for_device_probe();
80993
80994 - fd = sys_open("/dev/md0", 0, 0);
80995 + fd = sys_open((const char __force_user *) "/dev/md0", 0, 0);
80996 if (fd >= 0) {
80997 sys_ioctl(fd, RAID_AUTORUN, raid_autopart);
80998 sys_close(fd);
80999 diff --git a/init/init_task.c b/init/init_task.c
81000 index ba0a7f36..2bcf1d5 100644
81001 --- a/init/init_task.c
81002 +++ b/init/init_task.c
81003 @@ -22,5 +22,9 @@ EXPORT_SYMBOL(init_task);
81004 * Initial thread structure. Alignment of this is handled by a special
81005 * linker map entry.
81006 */
81007 +#ifdef CONFIG_X86
81008 +union thread_union init_thread_union __init_task_data;
81009 +#else
81010 union thread_union init_thread_union __init_task_data =
81011 { INIT_THREAD_INFO(init_task) };
81012 +#endif
81013 diff --git a/init/initramfs.c b/init/initramfs.c
81014 index a67ef9d..2d17ed9 100644
81015 --- a/init/initramfs.c
81016 +++ b/init/initramfs.c
81017 @@ -84,7 +84,7 @@ static void __init free_hash(void)
81018 }
81019 }
81020
81021 -static long __init do_utime(char *filename, time_t mtime)
81022 +static long __init do_utime(char __force_user *filename, time_t mtime)
81023 {
81024 struct timespec t[2];
81025
81026 @@ -119,7 +119,7 @@ static void __init dir_utime(void)
81027 struct dir_entry *de, *tmp;
81028 list_for_each_entry_safe(de, tmp, &dir_list, list) {
81029 list_del(&de->list);
81030 - do_utime(de->name, de->mtime);
81031 + do_utime((char __force_user *)de->name, de->mtime);
81032 kfree(de->name);
81033 kfree(de);
81034 }
81035 @@ -281,7 +281,7 @@ static int __init maybe_link(void)
81036 if (nlink >= 2) {
81037 char *old = find_link(major, minor, ino, mode, collected);
81038 if (old)
81039 - return (sys_link(old, collected) < 0) ? -1 : 1;
81040 + return (sys_link((char __force_user *)old, (char __force_user *)collected) < 0) ? -1 : 1;
81041 }
81042 return 0;
81043 }
81044 @@ -290,11 +290,11 @@ static void __init clean_path(char *path, umode_t mode)
81045 {
81046 struct stat st;
81047
81048 - if (!sys_newlstat(path, &st) && (st.st_mode^mode) & S_IFMT) {
81049 + if (!sys_newlstat((char __force_user *)path, (struct stat __force_user *)&st) && (st.st_mode^mode) & S_IFMT) {
81050 if (S_ISDIR(st.st_mode))
81051 - sys_rmdir(path);
81052 + sys_rmdir((char __force_user *)path);
81053 else
81054 - sys_unlink(path);
81055 + sys_unlink((char __force_user *)path);
81056 }
81057 }
81058
81059 @@ -315,7 +315,7 @@ static int __init do_name(void)
81060 int openflags = O_WRONLY|O_CREAT;
81061 if (ml != 1)
81062 openflags |= O_TRUNC;
81063 - wfd = sys_open(collected, openflags, mode);
81064 + wfd = sys_open((char __force_user *)collected, openflags, mode);
81065
81066 if (wfd >= 0) {
81067 sys_fchown(wfd, uid, gid);
81068 @@ -327,17 +327,17 @@ static int __init do_name(void)
81069 }
81070 }
81071 } else if (S_ISDIR(mode)) {
81072 - sys_mkdir(collected, mode);
81073 - sys_chown(collected, uid, gid);
81074 - sys_chmod(collected, mode);
81075 + sys_mkdir((char __force_user *)collected, mode);
81076 + sys_chown((char __force_user *)collected, uid, gid);
81077 + sys_chmod((char __force_user *)collected, mode);
81078 dir_add(collected, mtime);
81079 } else if (S_ISBLK(mode) || S_ISCHR(mode) ||
81080 S_ISFIFO(mode) || S_ISSOCK(mode)) {
81081 if (maybe_link() == 0) {
81082 - sys_mknod(collected, mode, rdev);
81083 - sys_chown(collected, uid, gid);
81084 - sys_chmod(collected, mode);
81085 - do_utime(collected, mtime);
81086 + sys_mknod((char __force_user *)collected, mode, rdev);
81087 + sys_chown((char __force_user *)collected, uid, gid);
81088 + sys_chmod((char __force_user *)collected, mode);
81089 + do_utime((char __force_user *)collected, mtime);
81090 }
81091 }
81092 return 0;
81093 @@ -346,15 +346,15 @@ static int __init do_name(void)
81094 static int __init do_copy(void)
81095 {
81096 if (count >= body_len) {
81097 - sys_write(wfd, victim, body_len);
81098 + sys_write(wfd, (char __force_user *)victim, body_len);
81099 sys_close(wfd);
81100 - do_utime(vcollected, mtime);
81101 + do_utime((char __force_user *)vcollected, mtime);
81102 kfree(vcollected);
81103 eat(body_len);
81104 state = SkipIt;
81105 return 0;
81106 } else {
81107 - sys_write(wfd, victim, count);
81108 + sys_write(wfd, (char __force_user *)victim, count);
81109 body_len -= count;
81110 eat(count);
81111 return 1;
81112 @@ -365,9 +365,9 @@ static int __init do_symlink(void)
81113 {
81114 collected[N_ALIGN(name_len) + body_len] = '\0';
81115 clean_path(collected, 0);
81116 - sys_symlink(collected + N_ALIGN(name_len), collected);
81117 - sys_lchown(collected, uid, gid);
81118 - do_utime(collected, mtime);
81119 + sys_symlink((char __force_user *)collected + N_ALIGN(name_len), (char __force_user *)collected);
81120 + sys_lchown((char __force_user *)collected, uid, gid);
81121 + do_utime((char __force_user *)collected, mtime);
81122 state = SkipIt;
81123 next_state = Reset;
81124 return 0;
81125 @@ -583,7 +583,7 @@ static int __init populate_rootfs(void)
81126 {
81127 char *err = unpack_to_rootfs(__initramfs_start, __initramfs_size);
81128 if (err)
81129 - panic(err); /* Failed to decompress INTERNAL initramfs */
81130 + panic("%s", err); /* Failed to decompress INTERNAL initramfs */
81131 if (initrd_start) {
81132 #ifdef CONFIG_BLK_DEV_RAM
81133 int fd;
81134 diff --git a/init/main.c b/init/main.c
81135 index 63d3e8f..50bd5f8 100644
81136 --- a/init/main.c
81137 +++ b/init/main.c
81138 @@ -103,6 +103,8 @@ static inline void mark_rodata_ro(void) { }
81139 extern void tc_init(void);
81140 #endif
81141
81142 +extern void grsecurity_init(void);
81143 +
81144 /*
81145 * Debug helper: via this flag we know that we are in 'early bootup code'
81146 * where only the boot processor is running with IRQ disabled. This means
81147 @@ -156,6 +158,75 @@ static int __init set_reset_devices(char *str)
81148
81149 __setup("reset_devices", set_reset_devices);
81150
81151 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
81152 +kgid_t grsec_proc_gid = KGIDT_INIT(CONFIG_GRKERNSEC_PROC_GID);
81153 +static int __init setup_grsec_proc_gid(char *str)
81154 +{
81155 + grsec_proc_gid = KGIDT_INIT(simple_strtol(str, NULL, 0));
81156 + return 1;
81157 +}
81158 +__setup("grsec_proc_gid=", setup_grsec_proc_gid);
81159 +#endif
81160 +
81161 +#if defined(CONFIG_X86_64) && defined(CONFIG_PAX_MEMORY_UDEREF)
81162 +unsigned long pax_user_shadow_base __read_only;
81163 +EXPORT_SYMBOL(pax_user_shadow_base);
81164 +extern char pax_enter_kernel_user[];
81165 +extern char pax_exit_kernel_user[];
81166 +#endif
81167 +
81168 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_MEMORY_UDEREF)
81169 +static int __init setup_pax_nouderef(char *str)
81170 +{
81171 +#ifdef CONFIG_X86_32
81172 + unsigned int cpu;
81173 + struct desc_struct *gdt;
81174 +
81175 + for (cpu = 0; cpu < nr_cpu_ids; cpu++) {
81176 + gdt = get_cpu_gdt_table(cpu);
81177 + gdt[GDT_ENTRY_KERNEL_DS].type = 3;
81178 + gdt[GDT_ENTRY_KERNEL_DS].limit = 0xf;
81179 + gdt[GDT_ENTRY_DEFAULT_USER_CS].limit = 0xf;
81180 + gdt[GDT_ENTRY_DEFAULT_USER_DS].limit = 0xf;
81181 + }
81182 + loadsegment(ds, __KERNEL_DS);
81183 + loadsegment(es, __KERNEL_DS);
81184 + loadsegment(ss, __KERNEL_DS);
81185 +#else
81186 + memcpy(pax_enter_kernel_user, (unsigned char []){0xc3}, 1);
81187 + memcpy(pax_exit_kernel_user, (unsigned char []){0xc3}, 1);
81188 + clone_pgd_mask = ~(pgdval_t)0UL;
81189 + pax_user_shadow_base = 0UL;
81190 + setup_clear_cpu_cap(X86_FEATURE_PCID);
81191 + setup_clear_cpu_cap(X86_FEATURE_INVPCID);
81192 +#endif
81193 +
81194 + return 0;
81195 +}
81196 +early_param("pax_nouderef", setup_pax_nouderef);
81197 +
81198 +#ifdef CONFIG_X86_64
81199 +static int __init setup_pax_weakuderef(char *str)
81200 +{
81201 + if (clone_pgd_mask != ~(pgdval_t)0UL)
81202 + pax_user_shadow_base = 1UL << TASK_SIZE_MAX_SHIFT;
81203 + return 1;
81204 +}
81205 +__setup("pax_weakuderef", setup_pax_weakuderef);
81206 +#endif
81207 +#endif
81208 +
81209 +#ifdef CONFIG_PAX_SOFTMODE
81210 +int pax_softmode;
81211 +
81212 +static int __init setup_pax_softmode(char *str)
81213 +{
81214 + get_option(&str, &pax_softmode);
81215 + return 1;
81216 +}
81217 +__setup("pax_softmode=", setup_pax_softmode);
81218 +#endif
81219 +
81220 static const char * argv_init[MAX_INIT_ARGS+2] = { "init", NULL, };
81221 const char * envp_init[MAX_INIT_ENVS+2] = { "HOME=/", "TERM=linux", NULL, };
81222 static const char *panic_later, *panic_param;
81223 @@ -682,25 +753,24 @@ int __init_or_module do_one_initcall(initcall_t fn)
81224 {
81225 int count = preempt_count();
81226 int ret;
81227 - char msgbuf[64];
81228 + const char *msg1 = "", *msg2 = "";
81229
81230 if (initcall_debug)
81231 ret = do_one_initcall_debug(fn);
81232 else
81233 ret = fn();
81234
81235 - msgbuf[0] = 0;
81236 -
81237 if (preempt_count() != count) {
81238 - sprintf(msgbuf, "preemption imbalance ");
81239 + msg1 = " preemption imbalance";
81240 preempt_count() = count;
81241 }
81242 if (irqs_disabled()) {
81243 - strlcat(msgbuf, "disabled interrupts ", sizeof(msgbuf));
81244 + msg2 = " disabled interrupts";
81245 local_irq_enable();
81246 }
81247 - WARN(msgbuf[0], "initcall %pF returned with %s\n", fn, msgbuf);
81248 + WARN(*msg1 || *msg2, "initcall %pF returned with%s%s\n", fn, msg1, msg2);
81249
81250 + add_latent_entropy();
81251 return ret;
81252 }
81253
81254 @@ -807,10 +877,14 @@ static int run_init_process(const char *init_filename)
81255 {
81256 argv_init[0] = init_filename;
81257 return do_execve(init_filename,
81258 - (const char __user *const __user *)argv_init,
81259 - (const char __user *const __user *)envp_init);
81260 + (const char __user *const __force_user *)argv_init,
81261 + (const char __user *const __force_user *)envp_init);
81262 }
81263
81264 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
81265 +extern int gr_init_ran;
81266 +#endif
81267 +
81268 static noinline void __init kernel_init_freeable(void);
81269
81270 static int __ref kernel_init(void *unused)
81271 @@ -831,6 +905,11 @@ static int __ref kernel_init(void *unused)
81272 pr_err("Failed to execute %s\n", ramdisk_execute_command);
81273 }
81274
81275 +#ifdef CONFIG_GRKERNSEC_CHROOT_INITRD
81276 + /* if no initrd was used, be extra sure we enforce chroot restrictions */
81277 + gr_init_ran = 1;
81278 +#endif
81279 +
81280 /*
81281 * We try each of these until one succeeds.
81282 *
81283 @@ -885,7 +964,7 @@ static noinline void __init kernel_init_freeable(void)
81284 do_basic_setup();
81285
81286 /* Open the /dev/console on the rootfs, this should never fail */
81287 - if (sys_open((const char __user *) "/dev/console", O_RDWR, 0) < 0)
81288 + if (sys_open((const char __force_user *) "/dev/console", O_RDWR, 0) < 0)
81289 pr_err("Warning: unable to open an initial console.\n");
81290
81291 (void) sys_dup(0);
81292 @@ -898,11 +977,13 @@ static noinline void __init kernel_init_freeable(void)
81293 if (!ramdisk_execute_command)
81294 ramdisk_execute_command = "/init";
81295
81296 - if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
81297 + if (sys_access((const char __force_user *) ramdisk_execute_command, 0) != 0) {
81298 ramdisk_execute_command = NULL;
81299 prepare_namespace();
81300 }
81301
81302 + grsecurity_init();
81303 +
81304 /*
81305 * Ok, we have completed the initial bootup, and
81306 * we're essentially up and running. Get rid of the
81307 diff --git a/ipc/ipc_sysctl.c b/ipc/ipc_sysctl.c
81308 index b0e99de..09f385c 100644
81309 --- a/ipc/ipc_sysctl.c
81310 +++ b/ipc/ipc_sysctl.c
81311 @@ -30,7 +30,7 @@ static void *get_ipc(ctl_table *table)
81312 static int proc_ipc_dointvec(ctl_table *table, int write,
81313 void __user *buffer, size_t *lenp, loff_t *ppos)
81314 {
81315 - struct ctl_table ipc_table;
81316 + ctl_table_no_const ipc_table;
81317
81318 memcpy(&ipc_table, table, sizeof(ipc_table));
81319 ipc_table.data = get_ipc(table);
81320 @@ -41,7 +41,7 @@ static int proc_ipc_dointvec(ctl_table *table, int write,
81321 static int proc_ipc_dointvec_minmax(ctl_table *table, int write,
81322 void __user *buffer, size_t *lenp, loff_t *ppos)
81323 {
81324 - struct ctl_table ipc_table;
81325 + ctl_table_no_const ipc_table;
81326
81327 memcpy(&ipc_table, table, sizeof(ipc_table));
81328 ipc_table.data = get_ipc(table);
81329 @@ -65,7 +65,7 @@ static int proc_ipc_dointvec_minmax_orphans(ctl_table *table, int write,
81330 static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
81331 void __user *buffer, size_t *lenp, loff_t *ppos)
81332 {
81333 - struct ctl_table ipc_table;
81334 + ctl_table_no_const ipc_table;
81335 size_t lenp_bef = *lenp;
81336 int rc;
81337
81338 @@ -88,7 +88,7 @@ static int proc_ipc_callback_dointvec_minmax(ctl_table *table, int write,
81339 static int proc_ipc_doulongvec_minmax(ctl_table *table, int write,
81340 void __user *buffer, size_t *lenp, loff_t *ppos)
81341 {
81342 - struct ctl_table ipc_table;
81343 + ctl_table_no_const ipc_table;
81344 memcpy(&ipc_table, table, sizeof(ipc_table));
81345 ipc_table.data = get_ipc(table);
81346
81347 @@ -122,7 +122,7 @@ static void ipc_auto_callback(int val)
81348 static int proc_ipcauto_dointvec_minmax(ctl_table *table, int write,
81349 void __user *buffer, size_t *lenp, loff_t *ppos)
81350 {
81351 - struct ctl_table ipc_table;
81352 + ctl_table_no_const ipc_table;
81353 size_t lenp_bef = *lenp;
81354 int oldval;
81355 int rc;
81356 diff --git a/ipc/mq_sysctl.c b/ipc/mq_sysctl.c
81357 index 383d638..943fdbb 100644
81358 --- a/ipc/mq_sysctl.c
81359 +++ b/ipc/mq_sysctl.c
81360 @@ -25,7 +25,7 @@ static void *get_mq(ctl_table *table)
81361 static int proc_mq_dointvec_minmax(ctl_table *table, int write,
81362 void __user *buffer, size_t *lenp, loff_t *ppos)
81363 {
81364 - struct ctl_table mq_table;
81365 + ctl_table_no_const mq_table;
81366 memcpy(&mq_table, table, sizeof(mq_table));
81367 mq_table.data = get_mq(table);
81368
81369 diff --git a/ipc/mqueue.c b/ipc/mqueue.c
81370 index ae1996d..a35f2cc 100644
81371 --- a/ipc/mqueue.c
81372 +++ b/ipc/mqueue.c
81373 @@ -278,6 +278,7 @@ static struct inode *mqueue_get_inode(struct super_block *sb,
81374 mq_bytes = mq_treesize + (info->attr.mq_maxmsg *
81375 info->attr.mq_msgsize);
81376
81377 + gr_learn_resource(current, RLIMIT_MSGQUEUE, u->mq_bytes + mq_bytes, 1);
81378 spin_lock(&mq_lock);
81379 if (u->mq_bytes + mq_bytes < u->mq_bytes ||
81380 u->mq_bytes + mq_bytes > rlimit(RLIMIT_MSGQUEUE)) {
81381 diff --git a/ipc/msg.c b/ipc/msg.c
81382 index 558aa91..359e718 100644
81383 --- a/ipc/msg.c
81384 +++ b/ipc/msg.c
81385 @@ -297,18 +297,19 @@ static inline int msg_security(struct kern_ipc_perm *ipcp, int msgflg)
81386 return security_msg_queue_associate(msq, msgflg);
81387 }
81388
81389 +static struct ipc_ops msg_ops = {
81390 + .getnew = newque,
81391 + .associate = msg_security,
81392 + .more_checks = NULL
81393 +};
81394 +
81395 SYSCALL_DEFINE2(msgget, key_t, key, int, msgflg)
81396 {
81397 struct ipc_namespace *ns;
81398 - struct ipc_ops msg_ops;
81399 struct ipc_params msg_params;
81400
81401 ns = current->nsproxy->ipc_ns;
81402
81403 - msg_ops.getnew = newque;
81404 - msg_ops.associate = msg_security;
81405 - msg_ops.more_checks = NULL;
81406 -
81407 msg_params.key = key;
81408 msg_params.flg = msgflg;
81409
81410 diff --git a/ipc/sem.c b/ipc/sem.c
81411 index db9d241..bc8427c 100644
81412 --- a/ipc/sem.c
81413 +++ b/ipc/sem.c
81414 @@ -562,10 +562,15 @@ static inline int sem_more_checks(struct kern_ipc_perm *ipcp,
81415 return 0;
81416 }
81417
81418 +static struct ipc_ops sem_ops = {
81419 + .getnew = newary,
81420 + .associate = sem_security,
81421 + .more_checks = sem_more_checks
81422 +};
81423 +
81424 SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
81425 {
81426 struct ipc_namespace *ns;
81427 - struct ipc_ops sem_ops;
81428 struct ipc_params sem_params;
81429
81430 ns = current->nsproxy->ipc_ns;
81431 @@ -573,10 +578,6 @@ SYSCALL_DEFINE3(semget, key_t, key, int, nsems, int, semflg)
81432 if (nsems < 0 || nsems > ns->sc_semmsl)
81433 return -EINVAL;
81434
81435 - sem_ops.getnew = newary;
81436 - sem_ops.associate = sem_security;
81437 - sem_ops.more_checks = sem_more_checks;
81438 -
81439 sem_params.key = key;
81440 sem_params.flg = semflg;
81441 sem_params.u.nsems = nsems;
81442 diff --git a/ipc/shm.c b/ipc/shm.c
81443 index 7a51443..3a257d8 100644
81444 --- a/ipc/shm.c
81445 +++ b/ipc/shm.c
81446 @@ -72,6 +72,14 @@ static void shm_destroy (struct ipc_namespace *ns, struct shmid_kernel *shp);
81447 static int sysvipc_shm_proc_show(struct seq_file *s, void *it);
81448 #endif
81449
81450 +#ifdef CONFIG_GRKERNSEC
81451 +extern int gr_handle_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
81452 + const time_t shm_createtime, const kuid_t cuid,
81453 + const int shmid);
81454 +extern int gr_chroot_shmat(const pid_t shm_cprid, const pid_t shm_lapid,
81455 + const time_t shm_createtime);
81456 +#endif
81457 +
81458 void shm_init_ns(struct ipc_namespace *ns)
81459 {
81460 ns->shm_ctlmax = SHMMAX;
81461 @@ -554,6 +562,14 @@ static int newseg(struct ipc_namespace *ns, struct ipc_params *params)
81462 shp->shm_lprid = 0;
81463 shp->shm_atim = shp->shm_dtim = 0;
81464 shp->shm_ctim = get_seconds();
81465 +#ifdef CONFIG_GRKERNSEC
81466 + {
81467 + struct timespec timeval;
81468 + do_posix_clock_monotonic_gettime(&timeval);
81469 +
81470 + shp->shm_createtime = timeval.tv_sec;
81471 + }
81472 +#endif
81473 shp->shm_segsz = size;
81474 shp->shm_nattch = 0;
81475 shp->shm_file = file;
81476 @@ -607,18 +623,19 @@ static inline int shm_more_checks(struct kern_ipc_perm *ipcp,
81477 return 0;
81478 }
81479
81480 +static struct ipc_ops shm_ops = {
81481 + .getnew = newseg,
81482 + .associate = shm_security,
81483 + .more_checks = shm_more_checks
81484 +};
81485 +
81486 SYSCALL_DEFINE3(shmget, key_t, key, size_t, size, int, shmflg)
81487 {
81488 struct ipc_namespace *ns;
81489 - struct ipc_ops shm_ops;
81490 struct ipc_params shm_params;
81491
81492 ns = current->nsproxy->ipc_ns;
81493
81494 - shm_ops.getnew = newseg;
81495 - shm_ops.associate = shm_security;
81496 - shm_ops.more_checks = shm_more_checks;
81497 -
81498 shm_params.key = key;
81499 shm_params.flg = shmflg;
81500 shm_params.u.size = size;
81501 @@ -1089,6 +1106,12 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81502 f_mode = FMODE_READ | FMODE_WRITE;
81503 }
81504 if (shmflg & SHM_EXEC) {
81505 +
81506 +#ifdef CONFIG_PAX_MPROTECT
81507 + if (current->mm->pax_flags & MF_PAX_MPROTECT)
81508 + goto out;
81509 +#endif
81510 +
81511 prot |= PROT_EXEC;
81512 acc_mode |= S_IXUGO;
81513 }
81514 @@ -1113,6 +1136,15 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81515 if (err)
81516 goto out_unlock;
81517
81518 +#ifdef CONFIG_GRKERNSEC
81519 + if (!gr_handle_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime,
81520 + shp->shm_perm.cuid, shmid) ||
81521 + !gr_chroot_shmat(shp->shm_cprid, shp->shm_lapid, shp->shm_createtime)) {
81522 + err = -EACCES;
81523 + goto out_unlock;
81524 + }
81525 +#endif
81526 +
81527 ipc_lock_object(&shp->shm_perm);
81528
81529 /* check if shm_destroy() is tearing down shp */
81530 @@ -1125,6 +1157,9 @@ long do_shmat(int shmid, char __user *shmaddr, int shmflg, ulong *raddr,
81531 path = shp->shm_file->f_path;
81532 path_get(&path);
81533 shp->shm_nattch++;
81534 +#ifdef CONFIG_GRKERNSEC
81535 + shp->shm_lapid = current->pid;
81536 +#endif
81537 size = i_size_read(path.dentry->d_inode);
81538 ipc_unlock_object(&shp->shm_perm);
81539 rcu_read_unlock();
81540 diff --git a/ipc/util.c b/ipc/util.c
81541 index 7684f41..5bf1880 100644
81542 --- a/ipc/util.c
81543 +++ b/ipc/util.c
81544 @@ -71,6 +71,8 @@ struct ipc_proc_iface {
81545 int (*show)(struct seq_file *, void *);
81546 };
81547
81548 +extern int gr_ipc_permitted(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, int requested_mode, int granted_mode);
81549 +
81550 static void ipc_memory_notifier(struct work_struct *work)
81551 {
81552 ipcns_notify(IPCNS_MEMCHANGED);
81553 @@ -560,6 +562,10 @@ int ipcperms(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp, short flag)
81554 granted_mode >>= 6;
81555 else if (in_group_p(ipcp->cgid) || in_group_p(ipcp->gid))
81556 granted_mode >>= 3;
81557 +
81558 + if (!gr_ipc_permitted(ns, ipcp, requested_mode, granted_mode))
81559 + return -1;
81560 +
81561 /* is there some bit set in requested_mode but not in granted_mode? */
81562 if ((requested_mode & ~granted_mode & 0007) &&
81563 !ns_capable(ns->user_ns, CAP_IPC_OWNER))
81564 diff --git a/kernel/acct.c b/kernel/acct.c
81565 index 8d6e145..33e0b1e 100644
81566 --- a/kernel/acct.c
81567 +++ b/kernel/acct.c
81568 @@ -556,7 +556,7 @@ static void do_acct_process(struct bsd_acct_struct *acct,
81569 */
81570 flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
81571 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY;
81572 - file->f_op->write(file, (char *)&ac,
81573 + file->f_op->write(file, (char __force_user *)&ac,
81574 sizeof(acct_t), &file->f_pos);
81575 current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
81576 set_fs(fs);
81577 diff --git a/kernel/audit.c b/kernel/audit.c
81578 index 7ddfd8a..49766eb 100644
81579 --- a/kernel/audit.c
81580 +++ b/kernel/audit.c
81581 @@ -118,7 +118,7 @@ u32 audit_sig_sid = 0;
81582 3) suppressed due to audit_rate_limit
81583 4) suppressed due to audit_backlog_limit
81584 */
81585 -static atomic_t audit_lost = ATOMIC_INIT(0);
81586 +static atomic_unchecked_t audit_lost = ATOMIC_INIT(0);
81587
81588 /* The netlink socket. */
81589 static struct sock *audit_sock;
81590 @@ -240,7 +240,7 @@ void audit_log_lost(const char *message)
81591 unsigned long now;
81592 int print;
81593
81594 - atomic_inc(&audit_lost);
81595 + atomic_inc_unchecked(&audit_lost);
81596
81597 print = (audit_failure == AUDIT_FAIL_PANIC || !audit_rate_limit);
81598
81599 @@ -259,7 +259,7 @@ void audit_log_lost(const char *message)
81600 printk(KERN_WARNING
81601 "audit: audit_lost=%d audit_rate_limit=%d "
81602 "audit_backlog_limit=%d\n",
81603 - atomic_read(&audit_lost),
81604 + atomic_read_unchecked(&audit_lost),
81605 audit_rate_limit,
81606 audit_backlog_limit);
81607 audit_panic(message);
81608 @@ -665,7 +665,7 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
81609 status_set.pid = audit_pid;
81610 status_set.rate_limit = audit_rate_limit;
81611 status_set.backlog_limit = audit_backlog_limit;
81612 - status_set.lost = atomic_read(&audit_lost);
81613 + status_set.lost = atomic_read_unchecked(&audit_lost);
81614 status_set.backlog = skb_queue_len(&audit_skb_queue);
81615 audit_send_reply(NETLINK_CB(skb).portid, seq, AUDIT_GET, 0, 0,
81616 &status_set, sizeof(status_set));
81617 @@ -1252,7 +1252,7 @@ void audit_log_n_hex(struct audit_buffer *ab, const unsigned char *buf,
81618 int i, avail, new_len;
81619 unsigned char *ptr;
81620 struct sk_buff *skb;
81621 - static const unsigned char *hex = "0123456789ABCDEF";
81622 + static const unsigned char hex[] = "0123456789ABCDEF";
81623
81624 if (!ab)
81625 return;
81626 diff --git a/kernel/auditsc.c b/kernel/auditsc.c
81627 index 9845cb3..3ec9369 100644
81628 --- a/kernel/auditsc.c
81629 +++ b/kernel/auditsc.c
81630 @@ -1962,7 +1962,7 @@ int auditsc_get_stamp(struct audit_context *ctx,
81631 }
81632
81633 /* global counter which is incremented every time something logs in */
81634 -static atomic_t session_id = ATOMIC_INIT(0);
81635 +static atomic_unchecked_t session_id = ATOMIC_INIT(0);
81636
81637 /**
81638 * audit_set_loginuid - set current task's audit_context loginuid
81639 @@ -1986,7 +1986,7 @@ int audit_set_loginuid(kuid_t loginuid)
81640 return -EPERM;
81641 #endif /* CONFIG_AUDIT_LOGINUID_IMMUTABLE */
81642
81643 - sessionid = atomic_inc_return(&session_id);
81644 + sessionid = atomic_inc_return_unchecked(&session_id);
81645 if (context && context->in_syscall) {
81646 struct audit_buffer *ab;
81647
81648 diff --git a/kernel/capability.c b/kernel/capability.c
81649 index 4e66bf9..cdccecf 100644
81650 --- a/kernel/capability.c
81651 +++ b/kernel/capability.c
81652 @@ -202,6 +202,9 @@ SYSCALL_DEFINE2(capget, cap_user_header_t, header, cap_user_data_t, dataptr)
81653 * before modification is attempted and the application
81654 * fails.
81655 */
81656 + if (tocopy > ARRAY_SIZE(kdata))
81657 + return -EFAULT;
81658 +
81659 if (copy_to_user(dataptr, kdata, tocopy
81660 * sizeof(struct __user_cap_data_struct))) {
81661 return -EFAULT;
81662 @@ -303,10 +306,11 @@ bool has_ns_capability(struct task_struct *t,
81663 int ret;
81664
81665 rcu_read_lock();
81666 - ret = security_capable(__task_cred(t), ns, cap);
81667 + ret = security_capable(__task_cred(t), ns, cap) == 0 &&
81668 + gr_task_is_capable(t, __task_cred(t), cap);
81669 rcu_read_unlock();
81670
81671 - return (ret == 0);
81672 + return ret;
81673 }
81674
81675 /**
81676 @@ -343,10 +347,10 @@ bool has_ns_capability_noaudit(struct task_struct *t,
81677 int ret;
81678
81679 rcu_read_lock();
81680 - ret = security_capable_noaudit(__task_cred(t), ns, cap);
81681 + ret = security_capable_noaudit(__task_cred(t), ns, cap) == 0 && gr_task_is_capable_nolog(t, cap);
81682 rcu_read_unlock();
81683
81684 - return (ret == 0);
81685 + return ret;
81686 }
81687
81688 /**
81689 @@ -384,7 +388,7 @@ bool ns_capable(struct user_namespace *ns, int cap)
81690 BUG();
81691 }
81692
81693 - if (security_capable(current_cred(), ns, cap) == 0) {
81694 + if (security_capable(current_cred(), ns, cap) == 0 && gr_is_capable(cap)) {
81695 current->flags |= PF_SUPERPRIV;
81696 return true;
81697 }
81698 @@ -392,6 +396,21 @@ bool ns_capable(struct user_namespace *ns, int cap)
81699 }
81700 EXPORT_SYMBOL(ns_capable);
81701
81702 +bool ns_capable_nolog(struct user_namespace *ns, int cap)
81703 +{
81704 + if (unlikely(!cap_valid(cap))) {
81705 + printk(KERN_CRIT "capable_nolog() called with invalid cap=%u\n", cap);
81706 + BUG();
81707 + }
81708 +
81709 + if (security_capable_noaudit(current_cred(), ns, cap) == 0 && gr_is_capable_nolog(cap)) {
81710 + current->flags |= PF_SUPERPRIV;
81711 + return true;
81712 + }
81713 + return false;
81714 +}
81715 +EXPORT_SYMBOL(ns_capable_nolog);
81716 +
81717 /**
81718 * file_ns_capable - Determine if the file's opener had a capability in effect
81719 * @file: The file we want to check
81720 @@ -432,6 +451,12 @@ bool capable(int cap)
81721 }
81722 EXPORT_SYMBOL(capable);
81723
81724 +bool capable_nolog(int cap)
81725 +{
81726 + return ns_capable_nolog(&init_user_ns, cap);
81727 +}
81728 +EXPORT_SYMBOL(capable_nolog);
81729 +
81730 /**
81731 * inode_capable - Check superior capability over inode
81732 * @inode: The inode in question
81733 @@ -453,3 +478,11 @@ bool inode_capable(const struct inode *inode, int cap)
81734 return ns_capable(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81735 }
81736 EXPORT_SYMBOL(inode_capable);
81737 +
81738 +bool inode_capable_nolog(const struct inode *inode, int cap)
81739 +{
81740 + struct user_namespace *ns = current_user_ns();
81741 +
81742 + return ns_capable_nolog(ns, cap) && kuid_has_mapping(ns, inode->i_uid);
81743 +}
81744 +EXPORT_SYMBOL(inode_capable_nolog);
81745 diff --git a/kernel/cgroup.c b/kernel/cgroup.c
81746 index b6fd783..7f526b7 100644
81747 --- a/kernel/cgroup.c
81748 +++ b/kernel/cgroup.c
81749 @@ -5855,7 +5855,7 @@ static int cgroup_css_links_read(struct cgroup_subsys_state *css,
81750 struct css_set *cset = link->cset;
81751 struct task_struct *task;
81752 int count = 0;
81753 - seq_printf(seq, "css_set %p\n", cset);
81754 + seq_printf(seq, "css_set %pK\n", cset);
81755 list_for_each_entry(task, &cset->tasks, cg_list) {
81756 if (count++ > MAX_TASKS_SHOWN_PER_CSS) {
81757 seq_puts(seq, " ...\n");
81758 diff --git a/kernel/compat.c b/kernel/compat.c
81759 index 0a09e48..f44f3f0 100644
81760 --- a/kernel/compat.c
81761 +++ b/kernel/compat.c
81762 @@ -13,6 +13,7 @@
81763
81764 #include <linux/linkage.h>
81765 #include <linux/compat.h>
81766 +#include <linux/module.h>
81767 #include <linux/errno.h>
81768 #include <linux/time.h>
81769 #include <linux/signal.h>
81770 @@ -220,7 +221,7 @@ static long compat_nanosleep_restart(struct restart_block *restart)
81771 mm_segment_t oldfs;
81772 long ret;
81773
81774 - restart->nanosleep.rmtp = (struct timespec __user *) &rmt;
81775 + restart->nanosleep.rmtp = (struct timespec __force_user *) &rmt;
81776 oldfs = get_fs();
81777 set_fs(KERNEL_DS);
81778 ret = hrtimer_nanosleep_restart(restart);
81779 @@ -252,7 +253,7 @@ asmlinkage long compat_sys_nanosleep(struct compat_timespec __user *rqtp,
81780 oldfs = get_fs();
81781 set_fs(KERNEL_DS);
81782 ret = hrtimer_nanosleep(&tu,
81783 - rmtp ? (struct timespec __user *)&rmt : NULL,
81784 + rmtp ? (struct timespec __force_user *)&rmt : NULL,
81785 HRTIMER_MODE_REL, CLOCK_MONOTONIC);
81786 set_fs(oldfs);
81787
81788 @@ -361,7 +362,7 @@ asmlinkage long compat_sys_sigpending(compat_old_sigset_t __user *set)
81789 mm_segment_t old_fs = get_fs();
81790
81791 set_fs(KERNEL_DS);
81792 - ret = sys_sigpending((old_sigset_t __user *) &s);
81793 + ret = sys_sigpending((old_sigset_t __force_user *) &s);
81794 set_fs(old_fs);
81795 if (ret == 0)
81796 ret = put_user(s, set);
81797 @@ -451,7 +452,7 @@ asmlinkage long compat_sys_old_getrlimit(unsigned int resource,
81798 mm_segment_t old_fs = get_fs();
81799
81800 set_fs(KERNEL_DS);
81801 - ret = sys_old_getrlimit(resource, &r);
81802 + ret = sys_old_getrlimit(resource, (struct rlimit __force_user *)&r);
81803 set_fs(old_fs);
81804
81805 if (!ret) {
81806 @@ -533,8 +534,8 @@ COMPAT_SYSCALL_DEFINE4(wait4,
81807 set_fs (KERNEL_DS);
81808 ret = sys_wait4(pid,
81809 (stat_addr ?
81810 - (unsigned int __user *) &status : NULL),
81811 - options, (struct rusage __user *) &r);
81812 + (unsigned int __force_user *) &status : NULL),
81813 + options, (struct rusage __force_user *) &r);
81814 set_fs (old_fs);
81815
81816 if (ret > 0) {
81817 @@ -560,8 +561,8 @@ COMPAT_SYSCALL_DEFINE5(waitid,
81818 memset(&info, 0, sizeof(info));
81819
81820 set_fs(KERNEL_DS);
81821 - ret = sys_waitid(which, pid, (siginfo_t __user *)&info, options,
81822 - uru ? (struct rusage __user *)&ru : NULL);
81823 + ret = sys_waitid(which, pid, (siginfo_t __force_user *)&info, options,
81824 + uru ? (struct rusage __force_user *)&ru : NULL);
81825 set_fs(old_fs);
81826
81827 if ((ret < 0) || (info.si_signo == 0))
81828 @@ -695,8 +696,8 @@ long compat_sys_timer_settime(timer_t timer_id, int flags,
81829 oldfs = get_fs();
81830 set_fs(KERNEL_DS);
81831 err = sys_timer_settime(timer_id, flags,
81832 - (struct itimerspec __user *) &newts,
81833 - (struct itimerspec __user *) &oldts);
81834 + (struct itimerspec __force_user *) &newts,
81835 + (struct itimerspec __force_user *) &oldts);
81836 set_fs(oldfs);
81837 if (!err && old && put_compat_itimerspec(old, &oldts))
81838 return -EFAULT;
81839 @@ -713,7 +714,7 @@ long compat_sys_timer_gettime(timer_t timer_id,
81840 oldfs = get_fs();
81841 set_fs(KERNEL_DS);
81842 err = sys_timer_gettime(timer_id,
81843 - (struct itimerspec __user *) &ts);
81844 + (struct itimerspec __force_user *) &ts);
81845 set_fs(oldfs);
81846 if (!err && put_compat_itimerspec(setting, &ts))
81847 return -EFAULT;
81848 @@ -732,7 +733,7 @@ long compat_sys_clock_settime(clockid_t which_clock,
81849 oldfs = get_fs();
81850 set_fs(KERNEL_DS);
81851 err = sys_clock_settime(which_clock,
81852 - (struct timespec __user *) &ts);
81853 + (struct timespec __force_user *) &ts);
81854 set_fs(oldfs);
81855 return err;
81856 }
81857 @@ -747,7 +748,7 @@ long compat_sys_clock_gettime(clockid_t which_clock,
81858 oldfs = get_fs();
81859 set_fs(KERNEL_DS);
81860 err = sys_clock_gettime(which_clock,
81861 - (struct timespec __user *) &ts);
81862 + (struct timespec __force_user *) &ts);
81863 set_fs(oldfs);
81864 if (!err && put_compat_timespec(&ts, tp))
81865 return -EFAULT;
81866 @@ -767,7 +768,7 @@ long compat_sys_clock_adjtime(clockid_t which_clock,
81867
81868 oldfs = get_fs();
81869 set_fs(KERNEL_DS);
81870 - ret = sys_clock_adjtime(which_clock, (struct timex __user *) &txc);
81871 + ret = sys_clock_adjtime(which_clock, (struct timex __force_user *) &txc);
81872 set_fs(oldfs);
81873
81874 err = compat_put_timex(utp, &txc);
81875 @@ -787,7 +788,7 @@ long compat_sys_clock_getres(clockid_t which_clock,
81876 oldfs = get_fs();
81877 set_fs(KERNEL_DS);
81878 err = sys_clock_getres(which_clock,
81879 - (struct timespec __user *) &ts);
81880 + (struct timespec __force_user *) &ts);
81881 set_fs(oldfs);
81882 if (!err && tp && put_compat_timespec(&ts, tp))
81883 return -EFAULT;
81884 @@ -799,9 +800,9 @@ static long compat_clock_nanosleep_restart(struct restart_block *restart)
81885 long err;
81886 mm_segment_t oldfs;
81887 struct timespec tu;
81888 - struct compat_timespec *rmtp = restart->nanosleep.compat_rmtp;
81889 + struct compat_timespec __user *rmtp = restart->nanosleep.compat_rmtp;
81890
81891 - restart->nanosleep.rmtp = (struct timespec __user *) &tu;
81892 + restart->nanosleep.rmtp = (struct timespec __force_user *) &tu;
81893 oldfs = get_fs();
81894 set_fs(KERNEL_DS);
81895 err = clock_nanosleep_restart(restart);
81896 @@ -833,8 +834,8 @@ long compat_sys_clock_nanosleep(clockid_t which_clock, int flags,
81897 oldfs = get_fs();
81898 set_fs(KERNEL_DS);
81899 err = sys_clock_nanosleep(which_clock, flags,
81900 - (struct timespec __user *) &in,
81901 - (struct timespec __user *) &out);
81902 + (struct timespec __force_user *) &in,
81903 + (struct timespec __force_user *) &out);
81904 set_fs(oldfs);
81905
81906 if ((err == -ERESTART_RESTARTBLOCK) && rmtp &&
81907 diff --git a/kernel/configs.c b/kernel/configs.c
81908 index c18b1f1..b9a0132 100644
81909 --- a/kernel/configs.c
81910 +++ b/kernel/configs.c
81911 @@ -74,8 +74,19 @@ static int __init ikconfig_init(void)
81912 struct proc_dir_entry *entry;
81913
81914 /* create the current config file */
81915 +#if defined(CONFIG_GRKERNSEC_PROC_ADD) || defined(CONFIG_GRKERNSEC_HIDESYM)
81916 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_HIDESYM)
81917 + entry = proc_create("config.gz", S_IFREG | S_IRUSR, NULL,
81918 + &ikconfig_file_ops);
81919 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
81920 + entry = proc_create("config.gz", S_IFREG | S_IRUSR | S_IRGRP, NULL,
81921 + &ikconfig_file_ops);
81922 +#endif
81923 +#else
81924 entry = proc_create("config.gz", S_IFREG | S_IRUGO, NULL,
81925 &ikconfig_file_ops);
81926 +#endif
81927 +
81928 if (!entry)
81929 return -ENOMEM;
81930
81931 diff --git a/kernel/cred.c b/kernel/cred.c
81932 index e0573a4..3874e41 100644
81933 --- a/kernel/cred.c
81934 +++ b/kernel/cred.c
81935 @@ -164,6 +164,16 @@ void exit_creds(struct task_struct *tsk)
81936 validate_creds(cred);
81937 alter_cred_subscribers(cred, -1);
81938 put_cred(cred);
81939 +
81940 +#ifdef CONFIG_GRKERNSEC_SETXID
81941 + cred = (struct cred *) tsk->delayed_cred;
81942 + if (cred != NULL) {
81943 + tsk->delayed_cred = NULL;
81944 + validate_creds(cred);
81945 + alter_cred_subscribers(cred, -1);
81946 + put_cred(cred);
81947 + }
81948 +#endif
81949 }
81950
81951 /**
81952 @@ -411,7 +421,7 @@ static bool cred_cap_issubset(const struct cred *set, const struct cred *subset)
81953 * Always returns 0 thus allowing this function to be tail-called at the end
81954 * of, say, sys_setgid().
81955 */
81956 -int commit_creds(struct cred *new)
81957 +static int __commit_creds(struct cred *new)
81958 {
81959 struct task_struct *task = current;
81960 const struct cred *old = task->real_cred;
81961 @@ -430,6 +440,8 @@ int commit_creds(struct cred *new)
81962
81963 get_cred(new); /* we will require a ref for the subj creds too */
81964
81965 + gr_set_role_label(task, new->uid, new->gid);
81966 +
81967 /* dumpability changes */
81968 if (!uid_eq(old->euid, new->euid) ||
81969 !gid_eq(old->egid, new->egid) ||
81970 @@ -479,6 +491,102 @@ int commit_creds(struct cred *new)
81971 put_cred(old);
81972 return 0;
81973 }
81974 +#ifdef CONFIG_GRKERNSEC_SETXID
81975 +extern int set_user(struct cred *new);
81976 +
81977 +void gr_delayed_cred_worker(void)
81978 +{
81979 + const struct cred *new = current->delayed_cred;
81980 + struct cred *ncred;
81981 +
81982 + current->delayed_cred = NULL;
81983 +
81984 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID) && new != NULL) {
81985 + // from doing get_cred on it when queueing this
81986 + put_cred(new);
81987 + return;
81988 + } else if (new == NULL)
81989 + return;
81990 +
81991 + ncred = prepare_creds();
81992 + if (!ncred)
81993 + goto die;
81994 + // uids
81995 + ncred->uid = new->uid;
81996 + ncred->euid = new->euid;
81997 + ncred->suid = new->suid;
81998 + ncred->fsuid = new->fsuid;
81999 + // gids
82000 + ncred->gid = new->gid;
82001 + ncred->egid = new->egid;
82002 + ncred->sgid = new->sgid;
82003 + ncred->fsgid = new->fsgid;
82004 + // groups
82005 + if (set_groups(ncred, new->group_info) < 0) {
82006 + abort_creds(ncred);
82007 + goto die;
82008 + }
82009 + // caps
82010 + ncred->securebits = new->securebits;
82011 + ncred->cap_inheritable = new->cap_inheritable;
82012 + ncred->cap_permitted = new->cap_permitted;
82013 + ncred->cap_effective = new->cap_effective;
82014 + ncred->cap_bset = new->cap_bset;
82015 +
82016 + if (set_user(ncred)) {
82017 + abort_creds(ncred);
82018 + goto die;
82019 + }
82020 +
82021 + // from doing get_cred on it when queueing this
82022 + put_cred(new);
82023 +
82024 + __commit_creds(ncred);
82025 + return;
82026 +die:
82027 + // from doing get_cred on it when queueing this
82028 + put_cred(new);
82029 + do_group_exit(SIGKILL);
82030 +}
82031 +#endif
82032 +
82033 +int commit_creds(struct cred *new)
82034 +{
82035 +#ifdef CONFIG_GRKERNSEC_SETXID
82036 + int ret;
82037 + int schedule_it = 0;
82038 + struct task_struct *t;
82039 +
82040 + /* we won't get called with tasklist_lock held for writing
82041 + and interrupts disabled as the cred struct in that case is
82042 + init_cred
82043 + */
82044 + if (grsec_enable_setxid && !current_is_single_threaded() &&
82045 + uid_eq(current_uid(), GLOBAL_ROOT_UID) &&
82046 + !uid_eq(new->uid, GLOBAL_ROOT_UID)) {
82047 + schedule_it = 1;
82048 + }
82049 + ret = __commit_creds(new);
82050 + if (schedule_it) {
82051 + rcu_read_lock();
82052 + read_lock(&tasklist_lock);
82053 + for (t = next_thread(current); t != current;
82054 + t = next_thread(t)) {
82055 + if (t->delayed_cred == NULL) {
82056 + t->delayed_cred = get_cred(new);
82057 + set_tsk_thread_flag(t, TIF_GRSEC_SETXID);
82058 + set_tsk_need_resched(t);
82059 + }
82060 + }
82061 + read_unlock(&tasklist_lock);
82062 + rcu_read_unlock();
82063 + }
82064 + return ret;
82065 +#else
82066 + return __commit_creds(new);
82067 +#endif
82068 +}
82069 +
82070 EXPORT_SYMBOL(commit_creds);
82071
82072 /**
82073 diff --git a/kernel/debug/debug_core.c b/kernel/debug/debug_core.c
82074 index 0506d44..2c20034 100644
82075 --- a/kernel/debug/debug_core.c
82076 +++ b/kernel/debug/debug_core.c
82077 @@ -123,7 +123,7 @@ static DEFINE_RAW_SPINLOCK(dbg_slave_lock);
82078 */
82079 static atomic_t masters_in_kgdb;
82080 static atomic_t slaves_in_kgdb;
82081 -static atomic_t kgdb_break_tasklet_var;
82082 +static atomic_unchecked_t kgdb_break_tasklet_var;
82083 atomic_t kgdb_setting_breakpoint;
82084
82085 struct task_struct *kgdb_usethread;
82086 @@ -133,7 +133,7 @@ int kgdb_single_step;
82087 static pid_t kgdb_sstep_pid;
82088
82089 /* to keep track of the CPU which is doing the single stepping*/
82090 -atomic_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
82091 +atomic_unchecked_t kgdb_cpu_doing_single_step = ATOMIC_INIT(-1);
82092
82093 /*
82094 * If you are debugging a problem where roundup (the collection of
82095 @@ -541,7 +541,7 @@ return_normal:
82096 * kernel will only try for the value of sstep_tries before
82097 * giving up and continuing on.
82098 */
82099 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1 &&
82100 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1 &&
82101 (kgdb_info[cpu].task &&
82102 kgdb_info[cpu].task->pid != kgdb_sstep_pid) && --sstep_tries) {
82103 atomic_set(&kgdb_active, -1);
82104 @@ -635,8 +635,8 @@ cpu_master_loop:
82105 }
82106
82107 kgdb_restore:
82108 - if (atomic_read(&kgdb_cpu_doing_single_step) != -1) {
82109 - int sstep_cpu = atomic_read(&kgdb_cpu_doing_single_step);
82110 + if (atomic_read_unchecked(&kgdb_cpu_doing_single_step) != -1) {
82111 + int sstep_cpu = atomic_read_unchecked(&kgdb_cpu_doing_single_step);
82112 if (kgdb_info[sstep_cpu].task)
82113 kgdb_sstep_pid = kgdb_info[sstep_cpu].task->pid;
82114 else
82115 @@ -888,18 +888,18 @@ static void kgdb_unregister_callbacks(void)
82116 static void kgdb_tasklet_bpt(unsigned long ing)
82117 {
82118 kgdb_breakpoint();
82119 - atomic_set(&kgdb_break_tasklet_var, 0);
82120 + atomic_set_unchecked(&kgdb_break_tasklet_var, 0);
82121 }
82122
82123 static DECLARE_TASKLET(kgdb_tasklet_breakpoint, kgdb_tasklet_bpt, 0);
82124
82125 void kgdb_schedule_breakpoint(void)
82126 {
82127 - if (atomic_read(&kgdb_break_tasklet_var) ||
82128 + if (atomic_read_unchecked(&kgdb_break_tasklet_var) ||
82129 atomic_read(&kgdb_active) != -1 ||
82130 atomic_read(&kgdb_setting_breakpoint))
82131 return;
82132 - atomic_inc(&kgdb_break_tasklet_var);
82133 + atomic_inc_unchecked(&kgdb_break_tasklet_var);
82134 tasklet_schedule(&kgdb_tasklet_breakpoint);
82135 }
82136 EXPORT_SYMBOL_GPL(kgdb_schedule_breakpoint);
82137 diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c
82138 index 00eb8f7..d7e3244 100644
82139 --- a/kernel/debug/kdb/kdb_main.c
82140 +++ b/kernel/debug/kdb/kdb_main.c
82141 @@ -1974,7 +1974,7 @@ static int kdb_lsmod(int argc, const char **argv)
82142 continue;
82143
82144 kdb_printf("%-20s%8u 0x%p ", mod->name,
82145 - mod->core_size, (void *)mod);
82146 + mod->core_size_rx + mod->core_size_rw, (void *)mod);
82147 #ifdef CONFIG_MODULE_UNLOAD
82148 kdb_printf("%4ld ", module_refcount(mod));
82149 #endif
82150 @@ -1984,7 +1984,7 @@ static int kdb_lsmod(int argc, const char **argv)
82151 kdb_printf(" (Loading)");
82152 else
82153 kdb_printf(" (Live)");
82154 - kdb_printf(" 0x%p", mod->module_core);
82155 + kdb_printf(" 0x%p 0x%p", mod->module_core_rx, mod->module_core_rw);
82156
82157 #ifdef CONFIG_MODULE_UNLOAD
82158 {
82159 diff --git a/kernel/events/core.c b/kernel/events/core.c
82160 index 953c143..5646bb1 100644
82161 --- a/kernel/events/core.c
82162 +++ b/kernel/events/core.c
82163 @@ -157,8 +157,15 @@ static struct srcu_struct pmus_srcu;
82164 * 0 - disallow raw tracepoint access for unpriv
82165 * 1 - disallow cpu events for unpriv
82166 * 2 - disallow kernel profiling for unpriv
82167 + * 3 - disallow all unpriv perf event use
82168 */
82169 -int sysctl_perf_event_paranoid __read_mostly = 1;
82170 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
82171 +int sysctl_perf_event_legitimately_concerned __read_mostly = 3;
82172 +#elif defined(CONFIG_GRKERNSEC_HIDESYM)
82173 +int sysctl_perf_event_legitimately_concerned __read_mostly = 2;
82174 +#else
82175 +int sysctl_perf_event_legitimately_concerned __read_mostly = 1;
82176 +#endif
82177
82178 /* Minimum for 512 kiB + 1 user control page */
82179 int sysctl_perf_event_mlock __read_mostly = 512 + (PAGE_SIZE / 1024); /* 'free' kiB per user */
82180 @@ -271,7 +278,7 @@ void perf_sample_event_took(u64 sample_len_ns)
82181 update_perf_cpu_limits();
82182 }
82183
82184 -static atomic64_t perf_event_id;
82185 +static atomic64_unchecked_t perf_event_id;
82186
82187 static void cpu_ctx_sched_out(struct perf_cpu_context *cpuctx,
82188 enum event_type_t event_type);
82189 @@ -2940,7 +2947,7 @@ static void __perf_event_read(void *info)
82190
82191 static inline u64 perf_event_count(struct perf_event *event)
82192 {
82193 - return local64_read(&event->count) + atomic64_read(&event->child_count);
82194 + return local64_read(&event->count) + atomic64_read_unchecked(&event->child_count);
82195 }
82196
82197 static u64 perf_event_read(struct perf_event *event)
82198 @@ -3308,9 +3315,9 @@ u64 perf_event_read_value(struct perf_event *event, u64 *enabled, u64 *running)
82199 mutex_lock(&event->child_mutex);
82200 total += perf_event_read(event);
82201 *enabled += event->total_time_enabled +
82202 - atomic64_read(&event->child_total_time_enabled);
82203 + atomic64_read_unchecked(&event->child_total_time_enabled);
82204 *running += event->total_time_running +
82205 - atomic64_read(&event->child_total_time_running);
82206 + atomic64_read_unchecked(&event->child_total_time_running);
82207
82208 list_for_each_entry(child, &event->child_list, child_list) {
82209 total += perf_event_read(child);
82210 @@ -3725,10 +3732,10 @@ void perf_event_update_userpage(struct perf_event *event)
82211 userpg->offset -= local64_read(&event->hw.prev_count);
82212
82213 userpg->time_enabled = enabled +
82214 - atomic64_read(&event->child_total_time_enabled);
82215 + atomic64_read_unchecked(&event->child_total_time_enabled);
82216
82217 userpg->time_running = running +
82218 - atomic64_read(&event->child_total_time_running);
82219 + atomic64_read_unchecked(&event->child_total_time_running);
82220
82221 arch_perf_update_userpage(userpg, now);
82222
82223 @@ -4279,7 +4286,7 @@ perf_output_sample_ustack(struct perf_output_handle *handle, u64 dump_size,
82224
82225 /* Data. */
82226 sp = perf_user_stack_pointer(regs);
82227 - rem = __output_copy_user(handle, (void *) sp, dump_size);
82228 + rem = __output_copy_user(handle, (void __user *) sp, dump_size);
82229 dyn_size = dump_size - rem;
82230
82231 perf_output_skip(handle, rem);
82232 @@ -4370,11 +4377,11 @@ static void perf_output_read_one(struct perf_output_handle *handle,
82233 values[n++] = perf_event_count(event);
82234 if (read_format & PERF_FORMAT_TOTAL_TIME_ENABLED) {
82235 values[n++] = enabled +
82236 - atomic64_read(&event->child_total_time_enabled);
82237 + atomic64_read_unchecked(&event->child_total_time_enabled);
82238 }
82239 if (read_format & PERF_FORMAT_TOTAL_TIME_RUNNING) {
82240 values[n++] = running +
82241 - atomic64_read(&event->child_total_time_running);
82242 + atomic64_read_unchecked(&event->child_total_time_running);
82243 }
82244 if (read_format & PERF_FORMAT_ID)
82245 values[n++] = primary_event_id(event);
82246 @@ -5112,12 +5119,12 @@ static void perf_event_mmap_event(struct perf_mmap_event *mmap_event)
82247 * need to add enough zero bytes after the string to handle
82248 * the 64bit alignment we do later.
82249 */
82250 - buf = kzalloc(PATH_MAX + sizeof(u64), GFP_KERNEL);
82251 + buf = kzalloc(PATH_MAX, GFP_KERNEL);
82252 if (!buf) {
82253 name = strncpy(tmp, "//enomem", sizeof(tmp));
82254 goto got_name;
82255 }
82256 - name = d_path(&file->f_path, buf, PATH_MAX);
82257 + name = d_path(&file->f_path, buf, PATH_MAX - sizeof(u64));
82258 if (IS_ERR(name)) {
82259 name = strncpy(tmp, "//toolong", sizeof(tmp));
82260 goto got_name;
82261 @@ -6639,7 +6646,7 @@ perf_event_alloc(struct perf_event_attr *attr, int cpu,
82262 event->parent = parent_event;
82263
82264 event->ns = get_pid_ns(task_active_pid_ns(current));
82265 - event->id = atomic64_inc_return(&perf_event_id);
82266 + event->id = atomic64_inc_return_unchecked(&perf_event_id);
82267
82268 event->state = PERF_EVENT_STATE_INACTIVE;
82269
82270 @@ -6938,6 +6945,11 @@ SYSCALL_DEFINE5(perf_event_open,
82271 if (flags & ~PERF_FLAG_ALL)
82272 return -EINVAL;
82273
82274 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
82275 + if (perf_paranoid_any() && !capable(CAP_SYS_ADMIN))
82276 + return -EACCES;
82277 +#endif
82278 +
82279 err = perf_copy_attr(attr_uptr, &attr);
82280 if (err)
82281 return err;
82282 @@ -7271,10 +7283,10 @@ static void sync_child_event(struct perf_event *child_event,
82283 /*
82284 * Add back the child's count to the parent's count:
82285 */
82286 - atomic64_add(child_val, &parent_event->child_count);
82287 - atomic64_add(child_event->total_time_enabled,
82288 + atomic64_add_unchecked(child_val, &parent_event->child_count);
82289 + atomic64_add_unchecked(child_event->total_time_enabled,
82290 &parent_event->child_total_time_enabled);
82291 - atomic64_add(child_event->total_time_running,
82292 + atomic64_add_unchecked(child_event->total_time_running,
82293 &parent_event->child_total_time_running);
82294
82295 /*
82296 diff --git a/kernel/events/internal.h b/kernel/events/internal.h
82297 index ca65997..60df03d 100644
82298 --- a/kernel/events/internal.h
82299 +++ b/kernel/events/internal.h
82300 @@ -81,10 +81,10 @@ static inline unsigned long perf_data_size(struct ring_buffer *rb)
82301 return rb->nr_pages << (PAGE_SHIFT + page_order(rb));
82302 }
82303
82304 -#define DEFINE_OUTPUT_COPY(func_name, memcpy_func) \
82305 -static inline unsigned int \
82306 +#define DEFINE_OUTPUT_COPY(func_name, memcpy_func, user) \
82307 +static inline unsigned long \
82308 func_name(struct perf_output_handle *handle, \
82309 - const void *buf, unsigned int len) \
82310 + const void user *buf, unsigned long len) \
82311 { \
82312 unsigned long size, written; \
82313 \
82314 @@ -116,17 +116,17 @@ static inline int memcpy_common(void *dst, const void *src, size_t n)
82315 return n;
82316 }
82317
82318 -DEFINE_OUTPUT_COPY(__output_copy, memcpy_common)
82319 +DEFINE_OUTPUT_COPY(__output_copy, memcpy_common, )
82320
82321 #define MEMCPY_SKIP(dst, src, n) (n)
82322
82323 -DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP)
82324 +DEFINE_OUTPUT_COPY(__output_skip, MEMCPY_SKIP, )
82325
82326 #ifndef arch_perf_out_copy_user
82327 #define arch_perf_out_copy_user __copy_from_user_inatomic
82328 #endif
82329
82330 -DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user)
82331 +DEFINE_OUTPUT_COPY(__output_copy_user, arch_perf_out_copy_user, __user)
82332
82333 /* Callchain handling */
82334 extern struct perf_callchain_entry *
82335 diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c
82336 index ad8e1bd..fed7ba9 100644
82337 --- a/kernel/events/uprobes.c
82338 +++ b/kernel/events/uprobes.c
82339 @@ -1556,7 +1556,7 @@ static int is_trap_at_addr(struct mm_struct *mm, unsigned long vaddr)
82340 {
82341 struct page *page;
82342 uprobe_opcode_t opcode;
82343 - int result;
82344 + long result;
82345
82346 pagefault_disable();
82347 result = __copy_from_user_inatomic(&opcode, (void __user*)vaddr,
82348 diff --git a/kernel/exit.c b/kernel/exit.c
82349 index a949819..a5f127d 100644
82350 --- a/kernel/exit.c
82351 +++ b/kernel/exit.c
82352 @@ -172,6 +172,10 @@ void release_task(struct task_struct * p)
82353 struct task_struct *leader;
82354 int zap_leader;
82355 repeat:
82356 +#ifdef CONFIG_NET
82357 + gr_del_task_from_ip_table(p);
82358 +#endif
82359 +
82360 /* don't need to get the RCU readlock here - the process is dead and
82361 * can't be modifying its own credentials. But shut RCU-lockdep up */
82362 rcu_read_lock();
82363 @@ -329,7 +333,7 @@ int allow_signal(int sig)
82364 * know it'll be handled, so that they don't get converted to
82365 * SIGKILL or just silently dropped.
82366 */
82367 - current->sighand->action[(sig)-1].sa.sa_handler = (void __user *)2;
82368 + current->sighand->action[(sig)-1].sa.sa_handler = (__force void __user *)2;
82369 recalc_sigpending();
82370 spin_unlock_irq(&current->sighand->siglock);
82371 return 0;
82372 @@ -698,6 +702,8 @@ void do_exit(long code)
82373 struct task_struct *tsk = current;
82374 int group_dead;
82375
82376 + set_fs(USER_DS);
82377 +
82378 profile_task_exit(tsk);
82379
82380 WARN_ON(blk_needs_flush_plug(tsk));
82381 @@ -714,7 +720,6 @@ void do_exit(long code)
82382 * mm_release()->clear_child_tid() from writing to a user-controlled
82383 * kernel address.
82384 */
82385 - set_fs(USER_DS);
82386
82387 ptrace_event(PTRACE_EVENT_EXIT, code);
82388
82389 @@ -773,6 +778,9 @@ void do_exit(long code)
82390 tsk->exit_code = code;
82391 taskstats_exit(tsk, group_dead);
82392
82393 + gr_acl_handle_psacct(tsk, code);
82394 + gr_acl_handle_exit();
82395 +
82396 exit_mm(tsk);
82397
82398 if (group_dead)
82399 @@ -894,7 +902,7 @@ SYSCALL_DEFINE1(exit, int, error_code)
82400 * Take down every thread in the group. This is called by fatal signals
82401 * as well as by sys_exit_group (below).
82402 */
82403 -void
82404 +__noreturn void
82405 do_group_exit(int exit_code)
82406 {
82407 struct signal_struct *sig = current->signal;
82408 diff --git a/kernel/fork.c b/kernel/fork.c
82409 index 690cfac..3be2d98 100644
82410 --- a/kernel/fork.c
82411 +++ b/kernel/fork.c
82412 @@ -319,7 +319,7 @@ static struct task_struct *dup_task_struct(struct task_struct *orig)
82413 *stackend = STACK_END_MAGIC; /* for overflow detection */
82414
82415 #ifdef CONFIG_CC_STACKPROTECTOR
82416 - tsk->stack_canary = get_random_int();
82417 + tsk->stack_canary = pax_get_random_long();
82418 #endif
82419
82420 /*
82421 @@ -345,12 +345,80 @@ free_tsk:
82422 }
82423
82424 #ifdef CONFIG_MMU
82425 -static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82426 +static struct vm_area_struct *dup_vma(struct mm_struct *mm, struct mm_struct *oldmm, struct vm_area_struct *mpnt)
82427 +{
82428 + struct vm_area_struct *tmp;
82429 + unsigned long charge;
82430 + struct file *file;
82431 + int retval;
82432 +
82433 + charge = 0;
82434 + if (mpnt->vm_flags & VM_ACCOUNT) {
82435 + unsigned long len = vma_pages(mpnt);
82436 +
82437 + if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
82438 + goto fail_nomem;
82439 + charge = len;
82440 + }
82441 + tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82442 + if (!tmp)
82443 + goto fail_nomem;
82444 + *tmp = *mpnt;
82445 + tmp->vm_mm = mm;
82446 + INIT_LIST_HEAD(&tmp->anon_vma_chain);
82447 + retval = vma_dup_policy(mpnt, tmp);
82448 + if (retval)
82449 + goto fail_nomem_policy;
82450 + if (anon_vma_fork(tmp, mpnt))
82451 + goto fail_nomem_anon_vma_fork;
82452 + tmp->vm_flags &= ~VM_LOCKED;
82453 + tmp->vm_next = tmp->vm_prev = NULL;
82454 + tmp->vm_mirror = NULL;
82455 + file = tmp->vm_file;
82456 + if (file) {
82457 + struct inode *inode = file_inode(file);
82458 + struct address_space *mapping = file->f_mapping;
82459 +
82460 + get_file(file);
82461 + if (tmp->vm_flags & VM_DENYWRITE)
82462 + atomic_dec(&inode->i_writecount);
82463 + mutex_lock(&mapping->i_mmap_mutex);
82464 + if (tmp->vm_flags & VM_SHARED)
82465 + mapping->i_mmap_writable++;
82466 + flush_dcache_mmap_lock(mapping);
82467 + /* insert tmp into the share list, just after mpnt */
82468 + if (unlikely(tmp->vm_flags & VM_NONLINEAR))
82469 + vma_nonlinear_insert(tmp, &mapping->i_mmap_nonlinear);
82470 + else
82471 + vma_interval_tree_insert_after(tmp, mpnt, &mapping->i_mmap);
82472 + flush_dcache_mmap_unlock(mapping);
82473 + mutex_unlock(&mapping->i_mmap_mutex);
82474 + }
82475 +
82476 + /*
82477 + * Clear hugetlb-related page reserves for children. This only
82478 + * affects MAP_PRIVATE mappings. Faults generated by the child
82479 + * are not guaranteed to succeed, even if read-only
82480 + */
82481 + if (is_vm_hugetlb_page(tmp))
82482 + reset_vma_resv_huge_pages(tmp);
82483 +
82484 + return tmp;
82485 +
82486 +fail_nomem_anon_vma_fork:
82487 + mpol_put(vma_policy(tmp));
82488 +fail_nomem_policy:
82489 + kmem_cache_free(vm_area_cachep, tmp);
82490 +fail_nomem:
82491 + vm_unacct_memory(charge);
82492 + return NULL;
82493 +}
82494 +
82495 +static __latent_entropy int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82496 {
82497 struct vm_area_struct *mpnt, *tmp, *prev, **pprev;
82498 struct rb_node **rb_link, *rb_parent;
82499 int retval;
82500 - unsigned long charge;
82501
82502 uprobe_start_dup_mmap();
82503 down_write(&oldmm->mmap_sem);
82504 @@ -379,55 +447,15 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82505
82506 prev = NULL;
82507 for (mpnt = oldmm->mmap; mpnt; mpnt = mpnt->vm_next) {
82508 - struct file *file;
82509 -
82510 if (mpnt->vm_flags & VM_DONTCOPY) {
82511 vm_stat_account(mm, mpnt->vm_flags, mpnt->vm_file,
82512 -vma_pages(mpnt));
82513 continue;
82514 }
82515 - charge = 0;
82516 - if (mpnt->vm_flags & VM_ACCOUNT) {
82517 - unsigned long len = vma_pages(mpnt);
82518 -
82519 - if (security_vm_enough_memory_mm(oldmm, len)) /* sic */
82520 - goto fail_nomem;
82521 - charge = len;
82522 - }
82523 - tmp = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
82524 - if (!tmp)
82525 - goto fail_nomem;
82526 - *tmp = *mpnt;
82527 - INIT_LIST_HEAD(&tmp->anon_vma_chain);
82528 - retval = vma_dup_policy(mpnt, tmp);
82529 - if (retval)
82530 - goto fail_nomem_policy;
82531 - tmp->vm_mm = mm;
82532 - if (anon_vma_fork(tmp, mpnt))
82533 - goto fail_nomem_anon_vma_fork;
82534 - tmp->vm_flags &= ~VM_LOCKED;
82535 - tmp->vm_next = tmp->vm_prev = NULL;
82536 - file = tmp->vm_file;
82537 - if (file) {
82538 - struct inode *inode = file_inode(file);
82539 - struct address_space *mapping = file->f_mapping;
82540 -
82541 - get_file(file);
82542 - if (tmp->vm_flags & VM_DENYWRITE)
82543 - atomic_dec(&inode->i_writecount);
82544 - mutex_lock(&mapping->i_mmap_mutex);
82545 - if (tmp->vm_flags & VM_SHARED)
82546 - mapping->i_mmap_writable++;
82547 - flush_dcache_mmap_lock(mapping);
82548 - /* insert tmp into the share list, just after mpnt */
82549 - if (unlikely(tmp->vm_flags & VM_NONLINEAR))
82550 - vma_nonlinear_insert(tmp,
82551 - &mapping->i_mmap_nonlinear);
82552 - else
82553 - vma_interval_tree_insert_after(tmp, mpnt,
82554 - &mapping->i_mmap);
82555 - flush_dcache_mmap_unlock(mapping);
82556 - mutex_unlock(&mapping->i_mmap_mutex);
82557 + tmp = dup_vma(mm, oldmm, mpnt);
82558 + if (!tmp) {
82559 + retval = -ENOMEM;
82560 + goto out;
82561 }
82562
82563 /*
82564 @@ -459,6 +487,31 @@ static int dup_mmap(struct mm_struct *mm, struct mm_struct *oldmm)
82565 if (retval)
82566 goto out;
82567 }
82568 +
82569 +#ifdef CONFIG_PAX_SEGMEXEC
82570 + if (oldmm->pax_flags & MF_PAX_SEGMEXEC) {
82571 + struct vm_area_struct *mpnt_m;
82572 +
82573 + for (mpnt = oldmm->mmap, mpnt_m = mm->mmap; mpnt; mpnt = mpnt->vm_next, mpnt_m = mpnt_m->vm_next) {
82574 + BUG_ON(!mpnt_m || mpnt_m->vm_mirror || mpnt->vm_mm != oldmm || mpnt_m->vm_mm != mm);
82575 +
82576 + if (!mpnt->vm_mirror)
82577 + continue;
82578 +
82579 + if (mpnt->vm_end <= SEGMEXEC_TASK_SIZE) {
82580 + BUG_ON(mpnt->vm_mirror->vm_mirror != mpnt);
82581 + mpnt->vm_mirror = mpnt_m;
82582 + } else {
82583 + BUG_ON(mpnt->vm_mirror->vm_mirror == mpnt || mpnt->vm_mirror->vm_mirror->vm_mm != mm);
82584 + mpnt_m->vm_mirror = mpnt->vm_mirror->vm_mirror;
82585 + mpnt_m->vm_mirror->vm_mirror = mpnt_m;
82586 + mpnt->vm_mirror->vm_mirror = mpnt;
82587 + }
82588 + }
82589 + BUG_ON(mpnt_m);
82590 + }
82591 +#endif
82592 +
82593 /* a new mm has just been created */
82594 arch_dup_mmap(oldmm, mm);
82595 retval = 0;
82596 @@ -468,14 +521,6 @@ out:
82597 up_write(&oldmm->mmap_sem);
82598 uprobe_end_dup_mmap();
82599 return retval;
82600 -fail_nomem_anon_vma_fork:
82601 - mpol_put(vma_policy(tmp));
82602 -fail_nomem_policy:
82603 - kmem_cache_free(vm_area_cachep, tmp);
82604 -fail_nomem:
82605 - retval = -ENOMEM;
82606 - vm_unacct_memory(charge);
82607 - goto out;
82608 }
82609
82610 static inline int mm_alloc_pgd(struct mm_struct *mm)
82611 @@ -689,8 +734,8 @@ struct mm_struct *mm_access(struct task_struct *task, unsigned int mode)
82612 return ERR_PTR(err);
82613
82614 mm = get_task_mm(task);
82615 - if (mm && mm != current->mm &&
82616 - !ptrace_may_access(task, mode)) {
82617 + if (mm && ((mm != current->mm && !ptrace_may_access(task, mode)) ||
82618 + (mode == PTRACE_MODE_ATTACH && (gr_handle_proc_ptrace(task) || gr_acl_handle_procpidmem(task))))) {
82619 mmput(mm);
82620 mm = ERR_PTR(-EACCES);
82621 }
82622 @@ -912,13 +957,20 @@ static int copy_fs(unsigned long clone_flags, struct task_struct *tsk)
82623 spin_unlock(&fs->lock);
82624 return -EAGAIN;
82625 }
82626 - fs->users++;
82627 + atomic_inc(&fs->users);
82628 spin_unlock(&fs->lock);
82629 return 0;
82630 }
82631 tsk->fs = copy_fs_struct(fs);
82632 if (!tsk->fs)
82633 return -ENOMEM;
82634 + /* Carry through gr_chroot_dentry and is_chrooted instead
82635 + of recomputing it here. Already copied when the task struct
82636 + is duplicated. This allows pivot_root to not be treated as
82637 + a chroot
82638 + */
82639 + //gr_set_chroot_entries(tsk, &tsk->fs->root);
82640 +
82641 return 0;
82642 }
82643
82644 @@ -1129,7 +1181,7 @@ init_task_pid(struct task_struct *task, enum pid_type type, struct pid *pid)
82645 * parts of the process environment (as per the clone
82646 * flags). The actual kick-off is left to the caller.
82647 */
82648 -static struct task_struct *copy_process(unsigned long clone_flags,
82649 +static __latent_entropy struct task_struct *copy_process(unsigned long clone_flags,
82650 unsigned long stack_start,
82651 unsigned long stack_size,
82652 int __user *child_tidptr,
82653 @@ -1201,6 +1253,9 @@ static struct task_struct *copy_process(unsigned long clone_flags,
82654 DEBUG_LOCKS_WARN_ON(!p->softirqs_enabled);
82655 #endif
82656 retval = -EAGAIN;
82657 +
82658 + gr_learn_resource(p, RLIMIT_NPROC, atomic_read(&p->real_cred->user->processes), 0);
82659 +
82660 if (atomic_read(&p->real_cred->user->processes) >=
82661 task_rlimit(p, RLIMIT_NPROC)) {
82662 if (p->real_cred->user != INIT_USER &&
82663 @@ -1450,6 +1505,11 @@ static struct task_struct *copy_process(unsigned long clone_flags,
82664 goto bad_fork_free_pid;
82665 }
82666
82667 + /* synchronizes with gr_set_acls()
82668 + we need to call this past the point of no return for fork()
82669 + */
82670 + gr_copy_label(p);
82671 +
82672 if (likely(p->pid)) {
82673 ptrace_init_task(p, (clone_flags & CLONE_PTRACE) || trace);
82674
82675 @@ -1535,6 +1595,8 @@ bad_fork_cleanup_count:
82676 bad_fork_free:
82677 free_task(p);
82678 fork_out:
82679 + gr_log_forkfail(retval);
82680 +
82681 return ERR_PTR(retval);
82682 }
82683
82684 @@ -1596,6 +1658,7 @@ long do_fork(unsigned long clone_flags,
82685
82686 p = copy_process(clone_flags, stack_start, stack_size,
82687 child_tidptr, NULL, trace);
82688 + add_latent_entropy();
82689 /*
82690 * Do this prior waking up the new thread - the thread pointer
82691 * might get invalid after that point, if the thread exits quickly.
82692 @@ -1610,6 +1673,8 @@ long do_fork(unsigned long clone_flags,
82693 if (clone_flags & CLONE_PARENT_SETTID)
82694 put_user(nr, parent_tidptr);
82695
82696 + gr_handle_brute_check();
82697 +
82698 if (clone_flags & CLONE_VFORK) {
82699 p->vfork_done = &vfork;
82700 init_completion(&vfork);
82701 @@ -1726,7 +1791,7 @@ void __init proc_caches_init(void)
82702 mm_cachep = kmem_cache_create("mm_struct",
82703 sizeof(struct mm_struct), ARCH_MIN_MMSTRUCT_ALIGN,
82704 SLAB_HWCACHE_ALIGN|SLAB_PANIC|SLAB_NOTRACK, NULL);
82705 - vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC);
82706 + vm_area_cachep = KMEM_CACHE(vm_area_struct, SLAB_PANIC | SLAB_NO_SANITIZE);
82707 mmap_init();
82708 nsproxy_cache_init();
82709 }
82710 @@ -1766,7 +1831,7 @@ static int unshare_fs(unsigned long unshare_flags, struct fs_struct **new_fsp)
82711 return 0;
82712
82713 /* don't need lock here; in the worst case we'll do useless copy */
82714 - if (fs->users == 1)
82715 + if (atomic_read(&fs->users) == 1)
82716 return 0;
82717
82718 *new_fsp = copy_fs_struct(fs);
82719 @@ -1873,7 +1938,8 @@ SYSCALL_DEFINE1(unshare, unsigned long, unshare_flags)
82720 fs = current->fs;
82721 spin_lock(&fs->lock);
82722 current->fs = new_fs;
82723 - if (--fs->users)
82724 + gr_set_chroot_entries(current, &current->fs->root);
82725 + if (atomic_dec_return(&fs->users))
82726 new_fs = NULL;
82727 else
82728 new_fs = fs;
82729 diff --git a/kernel/futex.c b/kernel/futex.c
82730 index 221a58f..1b8cfce 100644
82731 --- a/kernel/futex.c
82732 +++ b/kernel/futex.c
82733 @@ -54,6 +54,7 @@
82734 #include <linux/mount.h>
82735 #include <linux/pagemap.h>
82736 #include <linux/syscalls.h>
82737 +#include <linux/ptrace.h>
82738 #include <linux/signal.h>
82739 #include <linux/export.h>
82740 #include <linux/magic.h>
82741 @@ -243,6 +244,11 @@ get_futex_key(u32 __user *uaddr, int fshared, union futex_key *key, int rw)
82742 struct page *page, *page_head;
82743 int err, ro = 0;
82744
82745 +#ifdef CONFIG_PAX_SEGMEXEC
82746 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && address >= SEGMEXEC_TASK_SIZE)
82747 + return -EFAULT;
82748 +#endif
82749 +
82750 /*
82751 * The futex address must be "naturally" aligned.
82752 */
82753 @@ -441,7 +447,7 @@ static int cmpxchg_futex_value_locked(u32 *curval, u32 __user *uaddr,
82754
82755 static int get_futex_value_locked(u32 *dest, u32 __user *from)
82756 {
82757 - int ret;
82758 + unsigned long ret;
82759
82760 pagefault_disable();
82761 ret = __copy_from_user_inatomic(dest, from, sizeof(u32));
82762 @@ -2734,6 +2740,7 @@ static int __init futex_init(void)
82763 {
82764 u32 curval;
82765 int i;
82766 + mm_segment_t oldfs;
82767
82768 /*
82769 * This will fail and we want it. Some arch implementations do
82770 @@ -2745,8 +2752,11 @@ static int __init futex_init(void)
82771 * implementation, the non-functional ones will return
82772 * -ENOSYS.
82773 */
82774 + oldfs = get_fs();
82775 + set_fs(USER_DS);
82776 if (cmpxchg_futex_value_locked(&curval, NULL, 0, 0) == -EFAULT)
82777 futex_cmpxchg_enabled = 1;
82778 + set_fs(oldfs);
82779
82780 for (i = 0; i < ARRAY_SIZE(futex_queues); i++) {
82781 plist_head_init(&futex_queues[i].chain);
82782 diff --git a/kernel/futex_compat.c b/kernel/futex_compat.c
82783 index f9f44fd..29885e4 100644
82784 --- a/kernel/futex_compat.c
82785 +++ b/kernel/futex_compat.c
82786 @@ -32,7 +32,7 @@ fetch_robust_entry(compat_uptr_t *uentry, struct robust_list __user **entry,
82787 return 0;
82788 }
82789
82790 -static void __user *futex_uaddr(struct robust_list __user *entry,
82791 +static void __user __intentional_overflow(-1) *futex_uaddr(struct robust_list __user *entry,
82792 compat_long_t futex_offset)
82793 {
82794 compat_uptr_t base = ptr_to_compat(entry);
82795 diff --git a/kernel/gcov/base.c b/kernel/gcov/base.c
82796 index 9b22d03..6295b62 100644
82797 --- a/kernel/gcov/base.c
82798 +++ b/kernel/gcov/base.c
82799 @@ -102,11 +102,6 @@ void gcov_enable_events(void)
82800 }
82801
82802 #ifdef CONFIG_MODULES
82803 -static inline int within(void *addr, void *start, unsigned long size)
82804 -{
82805 - return ((addr >= start) && (addr < start + size));
82806 -}
82807 -
82808 /* Update list and generate events when modules are unloaded. */
82809 static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
82810 void *data)
82811 @@ -121,7 +116,7 @@ static int gcov_module_notifier(struct notifier_block *nb, unsigned long event,
82812 prev = NULL;
82813 /* Remove entries located in module from linked list. */
82814 for (info = gcov_info_head; info; info = info->next) {
82815 - if (within(info, mod->module_core, mod->core_size)) {
82816 + if (within_module_core_rw((unsigned long)info, mod)) {
82817 if (prev)
82818 prev->next = info->next;
82819 else
82820 diff --git a/kernel/hrtimer.c b/kernel/hrtimer.c
82821 index 383319b..56ebb13 100644
82822 --- a/kernel/hrtimer.c
82823 +++ b/kernel/hrtimer.c
82824 @@ -1438,7 +1438,7 @@ void hrtimer_peek_ahead_timers(void)
82825 local_irq_restore(flags);
82826 }
82827
82828 -static void run_hrtimer_softirq(struct softirq_action *h)
82829 +static __latent_entropy void run_hrtimer_softirq(void)
82830 {
82831 hrtimer_peek_ahead_timers();
82832 }
82833 diff --git a/kernel/irq_work.c b/kernel/irq_work.c
82834 index 55fcce6..0e4cf34 100644
82835 --- a/kernel/irq_work.c
82836 +++ b/kernel/irq_work.c
82837 @@ -189,12 +189,13 @@ static int irq_work_cpu_notify(struct notifier_block *self,
82838 return NOTIFY_OK;
82839 }
82840
82841 -static struct notifier_block cpu_notify;
82842 +static struct notifier_block cpu_notify = {
82843 + .notifier_call = irq_work_cpu_notify,
82844 + .priority = 0,
82845 +};
82846
82847 static __init int irq_work_init_cpu_notifier(void)
82848 {
82849 - cpu_notify.notifier_call = irq_work_cpu_notify;
82850 - cpu_notify.priority = 0;
82851 register_cpu_notifier(&cpu_notify);
82852 return 0;
82853 }
82854 diff --git a/kernel/jump_label.c b/kernel/jump_label.c
82855 index 297a924..7290070 100644
82856 --- a/kernel/jump_label.c
82857 +++ b/kernel/jump_label.c
82858 @@ -14,6 +14,7 @@
82859 #include <linux/err.h>
82860 #include <linux/static_key.h>
82861 #include <linux/jump_label_ratelimit.h>
82862 +#include <linux/mm.h>
82863
82864 #ifdef HAVE_JUMP_LABEL
82865
82866 @@ -51,7 +52,9 @@ jump_label_sort_entries(struct jump_entry *start, struct jump_entry *stop)
82867
82868 size = (((unsigned long)stop - (unsigned long)start)
82869 / sizeof(struct jump_entry));
82870 + pax_open_kernel();
82871 sort(start, size, sizeof(struct jump_entry), jump_label_cmp, NULL);
82872 + pax_close_kernel();
82873 }
82874
82875 static void jump_label_update(struct static_key *key, int enable);
82876 @@ -358,10 +361,12 @@ static void jump_label_invalidate_module_init(struct module *mod)
82877 struct jump_entry *iter_stop = iter_start + mod->num_jump_entries;
82878 struct jump_entry *iter;
82879
82880 + pax_open_kernel();
82881 for (iter = iter_start; iter < iter_stop; iter++) {
82882 if (within_module_init(iter->code, mod))
82883 iter->code = 0;
82884 }
82885 + pax_close_kernel();
82886 }
82887
82888 static int
82889 diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c
82890 index 3127ad5..159d880 100644
82891 --- a/kernel/kallsyms.c
82892 +++ b/kernel/kallsyms.c
82893 @@ -11,6 +11,9 @@
82894 * Changed the compression method from stem compression to "table lookup"
82895 * compression (see scripts/kallsyms.c for a more complete description)
82896 */
82897 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82898 +#define __INCLUDED_BY_HIDESYM 1
82899 +#endif
82900 #include <linux/kallsyms.h>
82901 #include <linux/module.h>
82902 #include <linux/init.h>
82903 @@ -53,12 +56,33 @@ extern const unsigned long kallsyms_markers[] __attribute__((weak));
82904
82905 static inline int is_kernel_inittext(unsigned long addr)
82906 {
82907 + if (system_state != SYSTEM_BOOTING)
82908 + return 0;
82909 +
82910 if (addr >= (unsigned long)_sinittext
82911 && addr <= (unsigned long)_einittext)
82912 return 1;
82913 return 0;
82914 }
82915
82916 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82917 +#ifdef CONFIG_MODULES
82918 +static inline int is_module_text(unsigned long addr)
82919 +{
82920 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END)
82921 + return 1;
82922 +
82923 + addr = ktla_ktva(addr);
82924 + return (unsigned long)MODULES_EXEC_VADDR <= addr && addr <= (unsigned long)MODULES_EXEC_END;
82925 +}
82926 +#else
82927 +static inline int is_module_text(unsigned long addr)
82928 +{
82929 + return 0;
82930 +}
82931 +#endif
82932 +#endif
82933 +
82934 static inline int is_kernel_text(unsigned long addr)
82935 {
82936 if ((addr >= (unsigned long)_stext && addr <= (unsigned long)_etext) ||
82937 @@ -69,13 +93,28 @@ static inline int is_kernel_text(unsigned long addr)
82938
82939 static inline int is_kernel(unsigned long addr)
82940 {
82941 +
82942 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82943 + if (is_kernel_text(addr) || is_kernel_inittext(addr))
82944 + return 1;
82945 +
82946 + if (ktla_ktva((unsigned long)_text) <= addr && addr < (unsigned long)_end)
82947 +#else
82948 if (addr >= (unsigned long)_stext && addr <= (unsigned long)_end)
82949 +#endif
82950 +
82951 return 1;
82952 return in_gate_area_no_mm(addr);
82953 }
82954
82955 static int is_ksym_addr(unsigned long addr)
82956 {
82957 +
82958 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
82959 + if (is_module_text(addr))
82960 + return 0;
82961 +#endif
82962 +
82963 if (all_var)
82964 return is_kernel(addr);
82965
82966 @@ -480,7 +519,6 @@ static unsigned long get_ksymbol_core(struct kallsym_iter *iter)
82967
82968 static void reset_iter(struct kallsym_iter *iter, loff_t new_pos)
82969 {
82970 - iter->name[0] = '\0';
82971 iter->nameoff = get_symbol_offset(new_pos);
82972 iter->pos = new_pos;
82973 }
82974 @@ -528,6 +566,11 @@ static int s_show(struct seq_file *m, void *p)
82975 {
82976 struct kallsym_iter *iter = m->private;
82977
82978 +#ifdef CONFIG_GRKERNSEC_HIDESYM
82979 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID))
82980 + return 0;
82981 +#endif
82982 +
82983 /* Some debugging symbols have no name. Ignore them. */
82984 if (!iter->name[0])
82985 return 0;
82986 @@ -541,6 +584,7 @@ static int s_show(struct seq_file *m, void *p)
82987 */
82988 type = iter->exported ? toupper(iter->type) :
82989 tolower(iter->type);
82990 +
82991 seq_printf(m, "%pK %c %s\t[%s]\n", (void *)iter->value,
82992 type, iter->name, iter->module_name);
82993 } else
82994 @@ -566,7 +610,7 @@ static int kallsyms_open(struct inode *inode, struct file *file)
82995 struct kallsym_iter *iter;
82996 int ret;
82997
82998 - iter = kmalloc(sizeof(*iter), GFP_KERNEL);
82999 + iter = kzalloc(sizeof(*iter), GFP_KERNEL);
83000 if (!iter)
83001 return -ENOMEM;
83002 reset_iter(iter, 0);
83003 diff --git a/kernel/kcmp.c b/kernel/kcmp.c
83004 index e30ac0f..3528cac 100644
83005 --- a/kernel/kcmp.c
83006 +++ b/kernel/kcmp.c
83007 @@ -99,6 +99,10 @@ SYSCALL_DEFINE5(kcmp, pid_t, pid1, pid_t, pid2, int, type,
83008 struct task_struct *task1, *task2;
83009 int ret;
83010
83011 +#ifdef CONFIG_GRKERNSEC
83012 + return -ENOSYS;
83013 +#endif
83014 +
83015 rcu_read_lock();
83016
83017 /*
83018 diff --git a/kernel/kexec.c b/kernel/kexec.c
83019 index 355e13a..06b25d2 100644
83020 --- a/kernel/kexec.c
83021 +++ b/kernel/kexec.c
83022 @@ -1044,7 +1044,8 @@ asmlinkage long compat_sys_kexec_load(unsigned long entry,
83023 unsigned long flags)
83024 {
83025 struct compat_kexec_segment in;
83026 - struct kexec_segment out, __user *ksegments;
83027 + struct kexec_segment out;
83028 + struct kexec_segment __user *ksegments;
83029 unsigned long i, result;
83030
83031 /* Don't allow clients that don't understand the native
83032 diff --git a/kernel/kmod.c b/kernel/kmod.c
83033 index b086006..6d2e579 100644
83034 --- a/kernel/kmod.c
83035 +++ b/kernel/kmod.c
83036 @@ -75,7 +75,7 @@ static void free_modprobe_argv(struct subprocess_info *info)
83037 kfree(info->argv);
83038 }
83039
83040 -static int call_modprobe(char *module_name, int wait)
83041 +static int call_modprobe(char *module_name, char *module_param, int wait)
83042 {
83043 struct subprocess_info *info;
83044 static char *envp[] = {
83045 @@ -85,7 +85,7 @@ static int call_modprobe(char *module_name, int wait)
83046 NULL
83047 };
83048
83049 - char **argv = kmalloc(sizeof(char *[5]), GFP_KERNEL);
83050 + char **argv = kmalloc(sizeof(char *[6]), GFP_KERNEL);
83051 if (!argv)
83052 goto out;
83053
83054 @@ -97,7 +97,8 @@ static int call_modprobe(char *module_name, int wait)
83055 argv[1] = "-q";
83056 argv[2] = "--";
83057 argv[3] = module_name; /* check free_modprobe_argv() */
83058 - argv[4] = NULL;
83059 + argv[4] = module_param;
83060 + argv[5] = NULL;
83061
83062 info = call_usermodehelper_setup(modprobe_path, argv, envp, GFP_KERNEL,
83063 NULL, free_modprobe_argv, NULL);
83064 @@ -129,9 +130,8 @@ out:
83065 * If module auto-loading support is disabled then this function
83066 * becomes a no-operation.
83067 */
83068 -int __request_module(bool wait, const char *fmt, ...)
83069 +static int ____request_module(bool wait, char *module_param, const char *fmt, va_list ap)
83070 {
83071 - va_list args;
83072 char module_name[MODULE_NAME_LEN];
83073 unsigned int max_modprobes;
83074 int ret;
83075 @@ -150,9 +150,7 @@ int __request_module(bool wait, const char *fmt, ...)
83076 if (!modprobe_path[0])
83077 return 0;
83078
83079 - va_start(args, fmt);
83080 - ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, args);
83081 - va_end(args);
83082 + ret = vsnprintf(module_name, MODULE_NAME_LEN, fmt, ap);
83083 if (ret >= MODULE_NAME_LEN)
83084 return -ENAMETOOLONG;
83085
83086 @@ -160,6 +158,20 @@ int __request_module(bool wait, const char *fmt, ...)
83087 if (ret)
83088 return ret;
83089
83090 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83091 + if (uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
83092 + /* hack to workaround consolekit/udisks stupidity */
83093 + read_lock(&tasklist_lock);
83094 + if (!strcmp(current->comm, "mount") &&
83095 + current->real_parent && !strncmp(current->real_parent->comm, "udisk", 5)) {
83096 + read_unlock(&tasklist_lock);
83097 + printk(KERN_ALERT "grsec: denied attempt to auto-load fs module %.64s by udisks\n", module_name);
83098 + return -EPERM;
83099 + }
83100 + read_unlock(&tasklist_lock);
83101 + }
83102 +#endif
83103 +
83104 /* If modprobe needs a service that is in a module, we get a recursive
83105 * loop. Limit the number of running kmod threads to max_threads/2 or
83106 * MAX_KMOD_CONCURRENT, whichever is the smaller. A cleaner method
83107 @@ -188,11 +200,52 @@ int __request_module(bool wait, const char *fmt, ...)
83108
83109 trace_module_request(module_name, wait, _RET_IP_);
83110
83111 - ret = call_modprobe(module_name, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
83112 + ret = call_modprobe(module_name, module_param, wait ? UMH_WAIT_PROC : UMH_WAIT_EXEC);
83113
83114 atomic_dec(&kmod_concurrent);
83115 return ret;
83116 }
83117 +
83118 +int ___request_module(bool wait, char *module_param, const char *fmt, ...)
83119 +{
83120 + va_list args;
83121 + int ret;
83122 +
83123 + va_start(args, fmt);
83124 + ret = ____request_module(wait, module_param, fmt, args);
83125 + va_end(args);
83126 +
83127 + return ret;
83128 +}
83129 +
83130 +int __request_module(bool wait, const char *fmt, ...)
83131 +{
83132 + va_list args;
83133 + int ret;
83134 +
83135 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83136 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)) {
83137 + char module_param[MODULE_NAME_LEN];
83138 +
83139 + memset(module_param, 0, sizeof(module_param));
83140 +
83141 + snprintf(module_param, sizeof(module_param) - 1, "grsec_modharden_normal%u_", GR_GLOBAL_UID(current_uid()));
83142 +
83143 + va_start(args, fmt);
83144 + ret = ____request_module(wait, module_param, fmt, args);
83145 + va_end(args);
83146 +
83147 + return ret;
83148 + }
83149 +#endif
83150 +
83151 + va_start(args, fmt);
83152 + ret = ____request_module(wait, NULL, fmt, args);
83153 + va_end(args);
83154 +
83155 + return ret;
83156 +}
83157 +
83158 EXPORT_SYMBOL(__request_module);
83159 #endif /* CONFIG_MODULES */
83160
83161 @@ -218,6 +271,19 @@ static int ____call_usermodehelper(void *data)
83162 */
83163 set_user_nice(current, 0);
83164
83165 +#ifdef CONFIG_GRKERNSEC
83166 + /* this is race-free as far as userland is concerned as we copied
83167 + out the path to be used prior to this point and are now operating
83168 + on that copy
83169 + */
83170 + if ((strncmp(sub_info->path, "/sbin/", 6) && strncmp(sub_info->path, "/usr/lib/", 9) &&
83171 + strncmp(sub_info->path, "/lib/", 5) && strncmp(sub_info->path, "/lib64/", 7)) || strstr(sub_info->path, "..")) {
83172 + printk(KERN_ALERT "grsec: denied exec of usermode helper binary %.950s located outside of /sbin and system library paths\n", sub_info->path);
83173 + retval = -EPERM;
83174 + goto fail;
83175 + }
83176 +#endif
83177 +
83178 retval = -ENOMEM;
83179 new = prepare_kernel_cred(current);
83180 if (!new)
83181 @@ -260,6 +326,10 @@ static int call_helper(void *data)
83182
83183 static void call_usermodehelper_freeinfo(struct subprocess_info *info)
83184 {
83185 +#ifdef CONFIG_GRKERNSEC
83186 + kfree(info->path);
83187 + info->path = info->origpath;
83188 +#endif
83189 if (info->cleanup)
83190 (*info->cleanup)(info);
83191 kfree(info);
83192 @@ -303,7 +373,7 @@ static int wait_for_helper(void *data)
83193 *
83194 * Thus the __user pointer cast is valid here.
83195 */
83196 - sys_wait4(pid, (int __user *)&ret, 0, NULL);
83197 + sys_wait4(pid, (int __force_user *)&ret, 0, NULL);
83198
83199 /*
83200 * If ret is 0, either ____call_usermodehelper failed and the
83201 @@ -542,7 +612,12 @@ struct subprocess_info *call_usermodehelper_setup(char *path, char **argv,
83202 goto out;
83203
83204 INIT_WORK(&sub_info->work, __call_usermodehelper);
83205 +#ifdef CONFIG_GRKERNSEC
83206 + sub_info->origpath = path;
83207 + sub_info->path = kstrdup(path, gfp_mask);
83208 +#else
83209 sub_info->path = path;
83210 +#endif
83211 sub_info->argv = argv;
83212 sub_info->envp = envp;
83213
83214 @@ -650,7 +725,7 @@ EXPORT_SYMBOL(call_usermodehelper);
83215 static int proc_cap_handler(struct ctl_table *table, int write,
83216 void __user *buffer, size_t *lenp, loff_t *ppos)
83217 {
83218 - struct ctl_table t;
83219 + ctl_table_no_const t;
83220 unsigned long cap_array[_KERNEL_CAPABILITY_U32S];
83221 kernel_cap_t new_cap;
83222 int err, i;
83223 diff --git a/kernel/kprobes.c b/kernel/kprobes.c
83224 index a0d367a..11c18b6 100644
83225 --- a/kernel/kprobes.c
83226 +++ b/kernel/kprobes.c
83227 @@ -31,6 +31,9 @@
83228 * <jkenisto@us.ibm.com> and Prasanna S Panchamukhi
83229 * <prasanna@in.ibm.com> added function-return probes.
83230 */
83231 +#ifdef CONFIG_GRKERNSEC_HIDESYM
83232 +#define __INCLUDED_BY_HIDESYM 1
83233 +#endif
83234 #include <linux/kprobes.h>
83235 #include <linux/hash.h>
83236 #include <linux/init.h>
83237 @@ -135,12 +138,12 @@ enum kprobe_slot_state {
83238
83239 static void *alloc_insn_page(void)
83240 {
83241 - return module_alloc(PAGE_SIZE);
83242 + return module_alloc_exec(PAGE_SIZE);
83243 }
83244
83245 static void free_insn_page(void *page)
83246 {
83247 - module_free(NULL, page);
83248 + module_free_exec(NULL, page);
83249 }
83250
83251 struct kprobe_insn_cache kprobe_insn_slots = {
83252 @@ -2066,7 +2069,7 @@ static int __init init_kprobes(void)
83253 {
83254 int i, err = 0;
83255 unsigned long offset = 0, size = 0;
83256 - char *modname, namebuf[128];
83257 + char *modname, namebuf[KSYM_NAME_LEN];
83258 const char *symbol_name;
83259 void *addr;
83260 struct kprobe_blackpoint *kb;
83261 @@ -2151,11 +2154,11 @@ static void __kprobes report_probe(struct seq_file *pi, struct kprobe *p,
83262 kprobe_type = "k";
83263
83264 if (sym)
83265 - seq_printf(pi, "%p %s %s+0x%x %s ",
83266 + seq_printf(pi, "%pK %s %s+0x%x %s ",
83267 p->addr, kprobe_type, sym, offset,
83268 (modname ? modname : " "));
83269 else
83270 - seq_printf(pi, "%p %s %p ",
83271 + seq_printf(pi, "%pK %s %pK ",
83272 p->addr, kprobe_type, p->addr);
83273
83274 if (!pp)
83275 @@ -2192,7 +2195,7 @@ static int __kprobes show_kprobe_addr(struct seq_file *pi, void *v)
83276 const char *sym = NULL;
83277 unsigned int i = *(loff_t *) v;
83278 unsigned long offset = 0;
83279 - char *modname, namebuf[128];
83280 + char *modname, namebuf[KSYM_NAME_LEN];
83281
83282 head = &kprobe_table[i];
83283 preempt_disable();
83284 diff --git a/kernel/ksysfs.c b/kernel/ksysfs.c
83285 index 9659d38..bffd520 100644
83286 --- a/kernel/ksysfs.c
83287 +++ b/kernel/ksysfs.c
83288 @@ -46,6 +46,8 @@ static ssize_t uevent_helper_store(struct kobject *kobj,
83289 {
83290 if (count+1 > UEVENT_HELPER_PATH_LEN)
83291 return -ENOENT;
83292 + if (!capable(CAP_SYS_ADMIN))
83293 + return -EPERM;
83294 memcpy(uevent_helper, buf, count);
83295 uevent_helper[count] = '\0';
83296 if (count && uevent_helper[count-1] == '\n')
83297 @@ -172,7 +174,7 @@ static ssize_t notes_read(struct file *filp, struct kobject *kobj,
83298 return count;
83299 }
83300
83301 -static struct bin_attribute notes_attr = {
83302 +static bin_attribute_no_const notes_attr __read_only = {
83303 .attr = {
83304 .name = "notes",
83305 .mode = S_IRUGO,
83306 diff --git a/kernel/lockdep.c b/kernel/lockdep.c
83307 index e16c45b..6f49c48 100644
83308 --- a/kernel/lockdep.c
83309 +++ b/kernel/lockdep.c
83310 @@ -596,6 +596,10 @@ static int static_obj(void *obj)
83311 end = (unsigned long) &_end,
83312 addr = (unsigned long) obj;
83313
83314 +#ifdef CONFIG_PAX_KERNEXEC
83315 + start = ktla_ktva(start);
83316 +#endif
83317 +
83318 /*
83319 * static variable?
83320 */
83321 @@ -736,6 +740,7 @@ register_lock_class(struct lockdep_map *lock, unsigned int subclass, int force)
83322 if (!static_obj(lock->key)) {
83323 debug_locks_off();
83324 printk("INFO: trying to register non-static key.\n");
83325 + printk("lock:%pS key:%pS.\n", lock, lock->key);
83326 printk("the code is fine but needs lockdep annotation.\n");
83327 printk("turning off the locking correctness validator.\n");
83328 dump_stack();
83329 @@ -3080,7 +3085,7 @@ static int __lock_acquire(struct lockdep_map *lock, unsigned int subclass,
83330 if (!class)
83331 return 0;
83332 }
83333 - atomic_inc((atomic_t *)&class->ops);
83334 + atomic_inc_unchecked((atomic_unchecked_t *)&class->ops);
83335 if (very_verbose(class)) {
83336 printk("\nacquire class [%p] %s", class->key, class->name);
83337 if (class->name_version > 1)
83338 diff --git a/kernel/lockdep_proc.c b/kernel/lockdep_proc.c
83339 index b2c71c5..7b88d63 100644
83340 --- a/kernel/lockdep_proc.c
83341 +++ b/kernel/lockdep_proc.c
83342 @@ -65,7 +65,7 @@ static int l_show(struct seq_file *m, void *v)
83343 return 0;
83344 }
83345
83346 - seq_printf(m, "%p", class->key);
83347 + seq_printf(m, "%pK", class->key);
83348 #ifdef CONFIG_DEBUG_LOCKDEP
83349 seq_printf(m, " OPS:%8ld", class->ops);
83350 #endif
83351 @@ -83,7 +83,7 @@ static int l_show(struct seq_file *m, void *v)
83352
83353 list_for_each_entry(entry, &class->locks_after, entry) {
83354 if (entry->distance == 1) {
83355 - seq_printf(m, " -> [%p] ", entry->class->key);
83356 + seq_printf(m, " -> [%pK] ", entry->class->key);
83357 print_name(m, entry->class);
83358 seq_puts(m, "\n");
83359 }
83360 @@ -152,7 +152,7 @@ static int lc_show(struct seq_file *m, void *v)
83361 if (!class->key)
83362 continue;
83363
83364 - seq_printf(m, "[%p] ", class->key);
83365 + seq_printf(m, "[%pK] ", class->key);
83366 print_name(m, class);
83367 seq_puts(m, "\n");
83368 }
83369 @@ -495,7 +495,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
83370 if (!i)
83371 seq_line(m, '-', 40-namelen, namelen);
83372
83373 - snprintf(ip, sizeof(ip), "[<%p>]",
83374 + snprintf(ip, sizeof(ip), "[<%pK>]",
83375 (void *)class->contention_point[i]);
83376 seq_printf(m, "%40s %14lu %29s %pS\n",
83377 name, stats->contention_point[i],
83378 @@ -510,7 +510,7 @@ static void seq_stats(struct seq_file *m, struct lock_stat_data *data)
83379 if (!i)
83380 seq_line(m, '-', 40-namelen, namelen);
83381
83382 - snprintf(ip, sizeof(ip), "[<%p>]",
83383 + snprintf(ip, sizeof(ip), "[<%pK>]",
83384 (void *)class->contending_point[i]);
83385 seq_printf(m, "%40s %14lu %29s %pS\n",
83386 name, stats->contending_point[i],
83387 diff --git a/kernel/module.c b/kernel/module.c
83388 index dc58274..3ddfa55 100644
83389 --- a/kernel/module.c
83390 +++ b/kernel/module.c
83391 @@ -61,6 +61,7 @@
83392 #include <linux/pfn.h>
83393 #include <linux/bsearch.h>
83394 #include <linux/fips.h>
83395 +#include <linux/grsecurity.h>
83396 #include <uapi/linux/module.h>
83397 #include "module-internal.h"
83398
83399 @@ -157,7 +158,8 @@ static BLOCKING_NOTIFIER_HEAD(module_notify_list);
83400
83401 /* Bounds of module allocation, for speeding __module_address.
83402 * Protected by module_mutex. */
83403 -static unsigned long module_addr_min = -1UL, module_addr_max = 0;
83404 +static unsigned long module_addr_min_rw = -1UL, module_addr_max_rw = 0;
83405 +static unsigned long module_addr_min_rx = -1UL, module_addr_max_rx = 0;
83406
83407 int register_module_notifier(struct notifier_block * nb)
83408 {
83409 @@ -324,7 +326,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
83410 return true;
83411
83412 list_for_each_entry_rcu(mod, &modules, list) {
83413 - struct symsearch arr[] = {
83414 + struct symsearch modarr[] = {
83415 { mod->syms, mod->syms + mod->num_syms, mod->crcs,
83416 NOT_GPL_ONLY, false },
83417 { mod->gpl_syms, mod->gpl_syms + mod->num_gpl_syms,
83418 @@ -349,7 +351,7 @@ bool each_symbol_section(bool (*fn)(const struct symsearch *arr,
83419 if (mod->state == MODULE_STATE_UNFORMED)
83420 continue;
83421
83422 - if (each_symbol_in_section(arr, ARRAY_SIZE(arr), mod, fn, data))
83423 + if (each_symbol_in_section(modarr, ARRAY_SIZE(modarr), mod, fn, data))
83424 return true;
83425 }
83426 return false;
83427 @@ -491,7 +493,7 @@ static int percpu_modalloc(struct module *mod, struct load_info *info)
83428 if (!pcpusec->sh_size)
83429 return 0;
83430
83431 - if (align > PAGE_SIZE) {
83432 + if (align-1 >= PAGE_SIZE) {
83433 printk(KERN_WARNING "%s: per-cpu alignment %li > %li\n",
83434 mod->name, align, PAGE_SIZE);
83435 align = PAGE_SIZE;
83436 @@ -1097,7 +1099,7 @@ struct module_attribute module_uevent =
83437 static ssize_t show_coresize(struct module_attribute *mattr,
83438 struct module_kobject *mk, char *buffer)
83439 {
83440 - return sprintf(buffer, "%u\n", mk->mod->core_size);
83441 + return sprintf(buffer, "%u\n", mk->mod->core_size_rx + mk->mod->core_size_rw);
83442 }
83443
83444 static struct module_attribute modinfo_coresize =
83445 @@ -1106,7 +1108,7 @@ static struct module_attribute modinfo_coresize =
83446 static ssize_t show_initsize(struct module_attribute *mattr,
83447 struct module_kobject *mk, char *buffer)
83448 {
83449 - return sprintf(buffer, "%u\n", mk->mod->init_size);
83450 + return sprintf(buffer, "%u\n", mk->mod->init_size_rx + mk->mod->init_size_rw);
83451 }
83452
83453 static struct module_attribute modinfo_initsize =
83454 @@ -1321,7 +1323,7 @@ resolve_symbol_wait(struct module *mod,
83455 */
83456 #ifdef CONFIG_SYSFS
83457
83458 -#ifdef CONFIG_KALLSYMS
83459 +#if defined(CONFIG_KALLSYMS) && !defined(CONFIG_GRKERNSEC_HIDESYM)
83460 static inline bool sect_empty(const Elf_Shdr *sect)
83461 {
83462 return !(sect->sh_flags & SHF_ALLOC) || sect->sh_size == 0;
83463 @@ -1461,7 +1463,7 @@ static void add_notes_attrs(struct module *mod, const struct load_info *info)
83464 {
83465 unsigned int notes, loaded, i;
83466 struct module_notes_attrs *notes_attrs;
83467 - struct bin_attribute *nattr;
83468 + bin_attribute_no_const *nattr;
83469
83470 /* failed to create section attributes, so can't create notes */
83471 if (!mod->sect_attrs)
83472 @@ -1573,7 +1575,7 @@ static void del_usage_links(struct module *mod)
83473 static int module_add_modinfo_attrs(struct module *mod)
83474 {
83475 struct module_attribute *attr;
83476 - struct module_attribute *temp_attr;
83477 + module_attribute_no_const *temp_attr;
83478 int error = 0;
83479 int i;
83480
83481 @@ -1795,21 +1797,21 @@ static void set_section_ro_nx(void *base,
83482
83483 static void unset_module_core_ro_nx(struct module *mod)
83484 {
83485 - set_page_attributes(mod->module_core + mod->core_text_size,
83486 - mod->module_core + mod->core_size,
83487 + set_page_attributes(mod->module_core_rw,
83488 + mod->module_core_rw + mod->core_size_rw,
83489 set_memory_x);
83490 - set_page_attributes(mod->module_core,
83491 - mod->module_core + mod->core_ro_size,
83492 + set_page_attributes(mod->module_core_rx,
83493 + mod->module_core_rx + mod->core_size_rx,
83494 set_memory_rw);
83495 }
83496
83497 static void unset_module_init_ro_nx(struct module *mod)
83498 {
83499 - set_page_attributes(mod->module_init + mod->init_text_size,
83500 - mod->module_init + mod->init_size,
83501 + set_page_attributes(mod->module_init_rw,
83502 + mod->module_init_rw + mod->init_size_rw,
83503 set_memory_x);
83504 - set_page_attributes(mod->module_init,
83505 - mod->module_init + mod->init_ro_size,
83506 + set_page_attributes(mod->module_init_rx,
83507 + mod->module_init_rx + mod->init_size_rx,
83508 set_memory_rw);
83509 }
83510
83511 @@ -1822,14 +1824,14 @@ void set_all_modules_text_rw(void)
83512 list_for_each_entry_rcu(mod, &modules, list) {
83513 if (mod->state == MODULE_STATE_UNFORMED)
83514 continue;
83515 - if ((mod->module_core) && (mod->core_text_size)) {
83516 - set_page_attributes(mod->module_core,
83517 - mod->module_core + mod->core_text_size,
83518 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
83519 + set_page_attributes(mod->module_core_rx,
83520 + mod->module_core_rx + mod->core_size_rx,
83521 set_memory_rw);
83522 }
83523 - if ((mod->module_init) && (mod->init_text_size)) {
83524 - set_page_attributes(mod->module_init,
83525 - mod->module_init + mod->init_text_size,
83526 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
83527 + set_page_attributes(mod->module_init_rx,
83528 + mod->module_init_rx + mod->init_size_rx,
83529 set_memory_rw);
83530 }
83531 }
83532 @@ -1845,14 +1847,14 @@ void set_all_modules_text_ro(void)
83533 list_for_each_entry_rcu(mod, &modules, list) {
83534 if (mod->state == MODULE_STATE_UNFORMED)
83535 continue;
83536 - if ((mod->module_core) && (mod->core_text_size)) {
83537 - set_page_attributes(mod->module_core,
83538 - mod->module_core + mod->core_text_size,
83539 + if ((mod->module_core_rx) && (mod->core_size_rx)) {
83540 + set_page_attributes(mod->module_core_rx,
83541 + mod->module_core_rx + mod->core_size_rx,
83542 set_memory_ro);
83543 }
83544 - if ((mod->module_init) && (mod->init_text_size)) {
83545 - set_page_attributes(mod->module_init,
83546 - mod->module_init + mod->init_text_size,
83547 + if ((mod->module_init_rx) && (mod->init_size_rx)) {
83548 + set_page_attributes(mod->module_init_rx,
83549 + mod->module_init_rx + mod->init_size_rx,
83550 set_memory_ro);
83551 }
83552 }
83553 @@ -1903,16 +1905,19 @@ static void free_module(struct module *mod)
83554
83555 /* This may be NULL, but that's OK */
83556 unset_module_init_ro_nx(mod);
83557 - module_free(mod, mod->module_init);
83558 + module_free(mod, mod->module_init_rw);
83559 + module_free_exec(mod, mod->module_init_rx);
83560 kfree(mod->args);
83561 percpu_modfree(mod);
83562
83563 /* Free lock-classes: */
83564 - lockdep_free_key_range(mod->module_core, mod->core_size);
83565 + lockdep_free_key_range(mod->module_core_rx, mod->core_size_rx);
83566 + lockdep_free_key_range(mod->module_core_rw, mod->core_size_rw);
83567
83568 /* Finally, free the core (containing the module structure) */
83569 unset_module_core_ro_nx(mod);
83570 - module_free(mod, mod->module_core);
83571 + module_free_exec(mod, mod->module_core_rx);
83572 + module_free(mod, mod->module_core_rw);
83573
83574 #ifdef CONFIG_MPU
83575 update_protections(current->mm);
83576 @@ -1982,9 +1987,31 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83577 int ret = 0;
83578 const struct kernel_symbol *ksym;
83579
83580 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83581 + int is_fs_load = 0;
83582 + int register_filesystem_found = 0;
83583 + char *p;
83584 +
83585 + p = strstr(mod->args, "grsec_modharden_fs");
83586 + if (p) {
83587 + char *endptr = p + sizeof("grsec_modharden_fs") - 1;
83588 + /* copy \0 as well */
83589 + memmove(p, endptr, strlen(mod->args) - (unsigned int)(endptr - mod->args) + 1);
83590 + is_fs_load = 1;
83591 + }
83592 +#endif
83593 +
83594 for (i = 1; i < symsec->sh_size / sizeof(Elf_Sym); i++) {
83595 const char *name = info->strtab + sym[i].st_name;
83596
83597 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83598 + /* it's a real shame this will never get ripped and copied
83599 + upstream! ;(
83600 + */
83601 + if (is_fs_load && !strcmp(name, "register_filesystem"))
83602 + register_filesystem_found = 1;
83603 +#endif
83604 +
83605 switch (sym[i].st_shndx) {
83606 case SHN_COMMON:
83607 /* We compiled with -fno-common. These are not
83608 @@ -2005,7 +2032,9 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83609 ksym = resolve_symbol_wait(mod, info, name);
83610 /* Ok if resolved. */
83611 if (ksym && !IS_ERR(ksym)) {
83612 + pax_open_kernel();
83613 sym[i].st_value = ksym->value;
83614 + pax_close_kernel();
83615 break;
83616 }
83617
83618 @@ -2024,11 +2053,20 @@ static int simplify_symbols(struct module *mod, const struct load_info *info)
83619 secbase = (unsigned long)mod_percpu(mod);
83620 else
83621 secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
83622 + pax_open_kernel();
83623 sym[i].st_value += secbase;
83624 + pax_close_kernel();
83625 break;
83626 }
83627 }
83628
83629 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
83630 + if (is_fs_load && !register_filesystem_found) {
83631 + printk(KERN_ALERT "grsec: Denied attempt to load non-fs module %.64s through mount\n", mod->name);
83632 + ret = -EPERM;
83633 + }
83634 +#endif
83635 +
83636 return ret;
83637 }
83638
83639 @@ -2112,22 +2150,12 @@ static void layout_sections(struct module *mod, struct load_info *info)
83640 || s->sh_entsize != ~0UL
83641 || strstarts(sname, ".init"))
83642 continue;
83643 - s->sh_entsize = get_offset(mod, &mod->core_size, s, i);
83644 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
83645 + s->sh_entsize = get_offset(mod, &mod->core_size_rw, s, i);
83646 + else
83647 + s->sh_entsize = get_offset(mod, &mod->core_size_rx, s, i);
83648 pr_debug("\t%s\n", sname);
83649 }
83650 - switch (m) {
83651 - case 0: /* executable */
83652 - mod->core_size = debug_align(mod->core_size);
83653 - mod->core_text_size = mod->core_size;
83654 - break;
83655 - case 1: /* RO: text and ro-data */
83656 - mod->core_size = debug_align(mod->core_size);
83657 - mod->core_ro_size = mod->core_size;
83658 - break;
83659 - case 3: /* whole core */
83660 - mod->core_size = debug_align(mod->core_size);
83661 - break;
83662 - }
83663 }
83664
83665 pr_debug("Init section allocation order:\n");
83666 @@ -2141,23 +2169,13 @@ static void layout_sections(struct module *mod, struct load_info *info)
83667 || s->sh_entsize != ~0UL
83668 || !strstarts(sname, ".init"))
83669 continue;
83670 - s->sh_entsize = (get_offset(mod, &mod->init_size, s, i)
83671 - | INIT_OFFSET_MASK);
83672 + if ((s->sh_flags & SHF_WRITE) || !(s->sh_flags & SHF_ALLOC))
83673 + s->sh_entsize = get_offset(mod, &mod->init_size_rw, s, i);
83674 + else
83675 + s->sh_entsize = get_offset(mod, &mod->init_size_rx, s, i);
83676 + s->sh_entsize |= INIT_OFFSET_MASK;
83677 pr_debug("\t%s\n", sname);
83678 }
83679 - switch (m) {
83680 - case 0: /* executable */
83681 - mod->init_size = debug_align(mod->init_size);
83682 - mod->init_text_size = mod->init_size;
83683 - break;
83684 - case 1: /* RO: text and ro-data */
83685 - mod->init_size = debug_align(mod->init_size);
83686 - mod->init_ro_size = mod->init_size;
83687 - break;
83688 - case 3: /* whole init */
83689 - mod->init_size = debug_align(mod->init_size);
83690 - break;
83691 - }
83692 }
83693 }
83694
83695 @@ -2330,7 +2348,7 @@ static void layout_symtab(struct module *mod, struct load_info *info)
83696
83697 /* Put symbol section at end of init part of module. */
83698 symsect->sh_flags |= SHF_ALLOC;
83699 - symsect->sh_entsize = get_offset(mod, &mod->init_size, symsect,
83700 + symsect->sh_entsize = get_offset(mod, &mod->init_size_rx, symsect,
83701 info->index.sym) | INIT_OFFSET_MASK;
83702 pr_debug("\t%s\n", info->secstrings + symsect->sh_name);
83703
83704 @@ -2347,13 +2365,13 @@ static void layout_symtab(struct module *mod, struct load_info *info)
83705 }
83706
83707 /* Append room for core symbols at end of core part. */
83708 - info->symoffs = ALIGN(mod->core_size, symsect->sh_addralign ?: 1);
83709 - info->stroffs = mod->core_size = info->symoffs + ndst * sizeof(Elf_Sym);
83710 - mod->core_size += strtab_size;
83711 + info->symoffs = ALIGN(mod->core_size_rx, symsect->sh_addralign ?: 1);
83712 + info->stroffs = mod->core_size_rx = info->symoffs + ndst * sizeof(Elf_Sym);
83713 + mod->core_size_rx += strtab_size;
83714
83715 /* Put string table section at end of init part of module. */
83716 strsect->sh_flags |= SHF_ALLOC;
83717 - strsect->sh_entsize = get_offset(mod, &mod->init_size, strsect,
83718 + strsect->sh_entsize = get_offset(mod, &mod->init_size_rx, strsect,
83719 info->index.str) | INIT_OFFSET_MASK;
83720 pr_debug("\t%s\n", info->secstrings + strsect->sh_name);
83721 }
83722 @@ -2371,12 +2389,14 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
83723 /* Make sure we get permanent strtab: don't use info->strtab. */
83724 mod->strtab = (void *)info->sechdrs[info->index.str].sh_addr;
83725
83726 + pax_open_kernel();
83727 +
83728 /* Set types up while we still have access to sections. */
83729 for (i = 0; i < mod->num_symtab; i++)
83730 mod->symtab[i].st_info = elf_type(&mod->symtab[i], info);
83731
83732 - mod->core_symtab = dst = mod->module_core + info->symoffs;
83733 - mod->core_strtab = s = mod->module_core + info->stroffs;
83734 + mod->core_symtab = dst = mod->module_core_rx + info->symoffs;
83735 + mod->core_strtab = s = mod->module_core_rx + info->stroffs;
83736 src = mod->symtab;
83737 for (ndst = i = 0; i < mod->num_symtab; i++) {
83738 if (i == 0 ||
83739 @@ -2388,6 +2408,8 @@ static void add_kallsyms(struct module *mod, const struct load_info *info)
83740 }
83741 }
83742 mod->core_num_syms = ndst;
83743 +
83744 + pax_close_kernel();
83745 }
83746 #else
83747 static inline void layout_symtab(struct module *mod, struct load_info *info)
83748 @@ -2421,17 +2443,33 @@ void * __weak module_alloc(unsigned long size)
83749 return vmalloc_exec(size);
83750 }
83751
83752 -static void *module_alloc_update_bounds(unsigned long size)
83753 +static void *module_alloc_update_bounds_rw(unsigned long size)
83754 {
83755 void *ret = module_alloc(size);
83756
83757 if (ret) {
83758 mutex_lock(&module_mutex);
83759 /* Update module bounds. */
83760 - if ((unsigned long)ret < module_addr_min)
83761 - module_addr_min = (unsigned long)ret;
83762 - if ((unsigned long)ret + size > module_addr_max)
83763 - module_addr_max = (unsigned long)ret + size;
83764 + if ((unsigned long)ret < module_addr_min_rw)
83765 + module_addr_min_rw = (unsigned long)ret;
83766 + if ((unsigned long)ret + size > module_addr_max_rw)
83767 + module_addr_max_rw = (unsigned long)ret + size;
83768 + mutex_unlock(&module_mutex);
83769 + }
83770 + return ret;
83771 +}
83772 +
83773 +static void *module_alloc_update_bounds_rx(unsigned long size)
83774 +{
83775 + void *ret = module_alloc_exec(size);
83776 +
83777 + if (ret) {
83778 + mutex_lock(&module_mutex);
83779 + /* Update module bounds. */
83780 + if ((unsigned long)ret < module_addr_min_rx)
83781 + module_addr_min_rx = (unsigned long)ret;
83782 + if ((unsigned long)ret + size > module_addr_max_rx)
83783 + module_addr_max_rx = (unsigned long)ret + size;
83784 mutex_unlock(&module_mutex);
83785 }
83786 return ret;
83787 @@ -2706,8 +2744,14 @@ static struct module *setup_load_info(struct load_info *info, int flags)
83788 static int check_modinfo(struct module *mod, struct load_info *info, int flags)
83789 {
83790 const char *modmagic = get_modinfo(info, "vermagic");
83791 + const char *license = get_modinfo(info, "license");
83792 int err;
83793
83794 +#ifdef CONFIG_PAX_KERNEXEC_PLUGIN_METHOD_OR
83795 + if (!license || !license_is_gpl_compatible(license))
83796 + return -ENOEXEC;
83797 +#endif
83798 +
83799 if (flags & MODULE_INIT_IGNORE_VERMAGIC)
83800 modmagic = NULL;
83801
83802 @@ -2733,7 +2777,7 @@ static int check_modinfo(struct module *mod, struct load_info *info, int flags)
83803 }
83804
83805 /* Set up license info based on the info section */
83806 - set_license(mod, get_modinfo(info, "license"));
83807 + set_license(mod, license);
83808
83809 return 0;
83810 }
83811 @@ -2814,7 +2858,7 @@ static int move_module(struct module *mod, struct load_info *info)
83812 void *ptr;
83813
83814 /* Do the allocs. */
83815 - ptr = module_alloc_update_bounds(mod->core_size);
83816 + ptr = module_alloc_update_bounds_rw(mod->core_size_rw);
83817 /*
83818 * The pointer to this block is stored in the module structure
83819 * which is inside the block. Just mark it as not being a
83820 @@ -2824,11 +2868,11 @@ static int move_module(struct module *mod, struct load_info *info)
83821 if (!ptr)
83822 return -ENOMEM;
83823
83824 - memset(ptr, 0, mod->core_size);
83825 - mod->module_core = ptr;
83826 + memset(ptr, 0, mod->core_size_rw);
83827 + mod->module_core_rw = ptr;
83828
83829 - if (mod->init_size) {
83830 - ptr = module_alloc_update_bounds(mod->init_size);
83831 + if (mod->init_size_rw) {
83832 + ptr = module_alloc_update_bounds_rw(mod->init_size_rw);
83833 /*
83834 * The pointer to this block is stored in the module structure
83835 * which is inside the block. This block doesn't need to be
83836 @@ -2837,13 +2881,45 @@ static int move_module(struct module *mod, struct load_info *info)
83837 */
83838 kmemleak_ignore(ptr);
83839 if (!ptr) {
83840 - module_free(mod, mod->module_core);
83841 + module_free(mod, mod->module_core_rw);
83842 return -ENOMEM;
83843 }
83844 - memset(ptr, 0, mod->init_size);
83845 - mod->module_init = ptr;
83846 + memset(ptr, 0, mod->init_size_rw);
83847 + mod->module_init_rw = ptr;
83848 } else
83849 - mod->module_init = NULL;
83850 + mod->module_init_rw = NULL;
83851 +
83852 + ptr = module_alloc_update_bounds_rx(mod->core_size_rx);
83853 + kmemleak_not_leak(ptr);
83854 + if (!ptr) {
83855 + if (mod->module_init_rw)
83856 + module_free(mod, mod->module_init_rw);
83857 + module_free(mod, mod->module_core_rw);
83858 + return -ENOMEM;
83859 + }
83860 +
83861 + pax_open_kernel();
83862 + memset(ptr, 0, mod->core_size_rx);
83863 + pax_close_kernel();
83864 + mod->module_core_rx = ptr;
83865 +
83866 + if (mod->init_size_rx) {
83867 + ptr = module_alloc_update_bounds_rx(mod->init_size_rx);
83868 + kmemleak_ignore(ptr);
83869 + if (!ptr && mod->init_size_rx) {
83870 + module_free_exec(mod, mod->module_core_rx);
83871 + if (mod->module_init_rw)
83872 + module_free(mod, mod->module_init_rw);
83873 + module_free(mod, mod->module_core_rw);
83874 + return -ENOMEM;
83875 + }
83876 +
83877 + pax_open_kernel();
83878 + memset(ptr, 0, mod->init_size_rx);
83879 + pax_close_kernel();
83880 + mod->module_init_rx = ptr;
83881 + } else
83882 + mod->module_init_rx = NULL;
83883
83884 /* Transfer each section which specifies SHF_ALLOC */
83885 pr_debug("final section addresses:\n");
83886 @@ -2854,16 +2930,45 @@ static int move_module(struct module *mod, struct load_info *info)
83887 if (!(shdr->sh_flags & SHF_ALLOC))
83888 continue;
83889
83890 - if (shdr->sh_entsize & INIT_OFFSET_MASK)
83891 - dest = mod->module_init
83892 - + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83893 - else
83894 - dest = mod->module_core + shdr->sh_entsize;
83895 + if (shdr->sh_entsize & INIT_OFFSET_MASK) {
83896 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83897 + dest = mod->module_init_rw
83898 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83899 + else
83900 + dest = mod->module_init_rx
83901 + + (shdr->sh_entsize & ~INIT_OFFSET_MASK);
83902 + } else {
83903 + if ((shdr->sh_flags & SHF_WRITE) || !(shdr->sh_flags & SHF_ALLOC))
83904 + dest = mod->module_core_rw + shdr->sh_entsize;
83905 + else
83906 + dest = mod->module_core_rx + shdr->sh_entsize;
83907 + }
83908 +
83909 + if (shdr->sh_type != SHT_NOBITS) {
83910 +
83911 +#ifdef CONFIG_PAX_KERNEXEC
83912 +#ifdef CONFIG_X86_64
83913 + if ((shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_EXECINSTR))
83914 + set_memory_x((unsigned long)dest, (shdr->sh_size + PAGE_SIZE) >> PAGE_SHIFT);
83915 +#endif
83916 + if (!(shdr->sh_flags & SHF_WRITE) && (shdr->sh_flags & SHF_ALLOC)) {
83917 + pax_open_kernel();
83918 + memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83919 + pax_close_kernel();
83920 + } else
83921 +#endif
83922
83923 - if (shdr->sh_type != SHT_NOBITS)
83924 memcpy(dest, (void *)shdr->sh_addr, shdr->sh_size);
83925 + }
83926 /* Update sh_addr to point to copy in image. */
83927 - shdr->sh_addr = (unsigned long)dest;
83928 +
83929 +#ifdef CONFIG_PAX_KERNEXEC
83930 + if (shdr->sh_flags & SHF_EXECINSTR)
83931 + shdr->sh_addr = ktva_ktla((unsigned long)dest);
83932 + else
83933 +#endif
83934 +
83935 + shdr->sh_addr = (unsigned long)dest;
83936 pr_debug("\t0x%lx %s\n",
83937 (long)shdr->sh_addr, info->secstrings + shdr->sh_name);
83938 }
83939 @@ -2920,12 +3025,12 @@ static void flush_module_icache(const struct module *mod)
83940 * Do it before processing of module parameters, so the module
83941 * can provide parameter accessor functions of its own.
83942 */
83943 - if (mod->module_init)
83944 - flush_icache_range((unsigned long)mod->module_init,
83945 - (unsigned long)mod->module_init
83946 - + mod->init_size);
83947 - flush_icache_range((unsigned long)mod->module_core,
83948 - (unsigned long)mod->module_core + mod->core_size);
83949 + if (mod->module_init_rx)
83950 + flush_icache_range((unsigned long)mod->module_init_rx,
83951 + (unsigned long)mod->module_init_rx
83952 + + mod->init_size_rx);
83953 + flush_icache_range((unsigned long)mod->module_core_rx,
83954 + (unsigned long)mod->module_core_rx + mod->core_size_rx);
83955
83956 set_fs(old_fs);
83957 }
83958 @@ -2982,8 +3087,10 @@ static struct module *layout_and_allocate(struct load_info *info, int flags)
83959 static void module_deallocate(struct module *mod, struct load_info *info)
83960 {
83961 percpu_modfree(mod);
83962 - module_free(mod, mod->module_init);
83963 - module_free(mod, mod->module_core);
83964 + module_free_exec(mod, mod->module_init_rx);
83965 + module_free_exec(mod, mod->module_core_rx);
83966 + module_free(mod, mod->module_init_rw);
83967 + module_free(mod, mod->module_core_rw);
83968 }
83969
83970 int __weak module_finalize(const Elf_Ehdr *hdr,
83971 @@ -2996,7 +3103,9 @@ int __weak module_finalize(const Elf_Ehdr *hdr,
83972 static int post_relocation(struct module *mod, const struct load_info *info)
83973 {
83974 /* Sort exception table now relocations are done. */
83975 + pax_open_kernel();
83976 sort_extable(mod->extable, mod->extable + mod->num_exentries);
83977 + pax_close_kernel();
83978
83979 /* Copy relocated percpu area over. */
83980 percpu_modcopy(mod, (void *)info->sechdrs[info->index.pcpu].sh_addr,
83981 @@ -3050,16 +3159,16 @@ static int do_init_module(struct module *mod)
83982 MODULE_STATE_COMING, mod);
83983
83984 /* Set RO and NX regions for core */
83985 - set_section_ro_nx(mod->module_core,
83986 - mod->core_text_size,
83987 - mod->core_ro_size,
83988 - mod->core_size);
83989 + set_section_ro_nx(mod->module_core_rx,
83990 + mod->core_size_rx,
83991 + mod->core_size_rx,
83992 + mod->core_size_rx);
83993
83994 /* Set RO and NX regions for init */
83995 - set_section_ro_nx(mod->module_init,
83996 - mod->init_text_size,
83997 - mod->init_ro_size,
83998 - mod->init_size);
83999 + set_section_ro_nx(mod->module_init_rx,
84000 + mod->init_size_rx,
84001 + mod->init_size_rx,
84002 + mod->init_size_rx);
84003
84004 do_mod_ctors(mod);
84005 /* Start the module */
84006 @@ -3121,11 +3230,12 @@ static int do_init_module(struct module *mod)
84007 mod->strtab = mod->core_strtab;
84008 #endif
84009 unset_module_init_ro_nx(mod);
84010 - module_free(mod, mod->module_init);
84011 - mod->module_init = NULL;
84012 - mod->init_size = 0;
84013 - mod->init_ro_size = 0;
84014 - mod->init_text_size = 0;
84015 + module_free(mod, mod->module_init_rw);
84016 + module_free_exec(mod, mod->module_init_rx);
84017 + mod->module_init_rw = NULL;
84018 + mod->module_init_rx = NULL;
84019 + mod->init_size_rw = 0;
84020 + mod->init_size_rx = 0;
84021 mutex_unlock(&module_mutex);
84022 wake_up_all(&module_wq);
84023
84024 @@ -3269,9 +3379,38 @@ static int load_module(struct load_info *info, const char __user *uargs,
84025 if (err)
84026 goto free_unload;
84027
84028 + /* Now copy in args */
84029 + mod->args = strndup_user(uargs, ~0UL >> 1);
84030 + if (IS_ERR(mod->args)) {
84031 + err = PTR_ERR(mod->args);
84032 + goto free_unload;
84033 + }
84034 +
84035 /* Set up MODINFO_ATTR fields */
84036 setup_modinfo(mod, info);
84037
84038 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
84039 + {
84040 + char *p, *p2;
84041 +
84042 + if (strstr(mod->args, "grsec_modharden_netdev")) {
84043 + 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);
84044 + err = -EPERM;
84045 + goto free_modinfo;
84046 + } else if ((p = strstr(mod->args, "grsec_modharden_normal"))) {
84047 + p += sizeof("grsec_modharden_normal") - 1;
84048 + p2 = strstr(p, "_");
84049 + if (p2) {
84050 + *p2 = '\0';
84051 + printk(KERN_ALERT "grsec: denied kernel module auto-load of %.64s by uid %.9s\n", mod->name, p);
84052 + *p2 = '_';
84053 + }
84054 + err = -EPERM;
84055 + goto free_modinfo;
84056 + }
84057 + }
84058 +#endif
84059 +
84060 /* Fix up syms, so that st_value is a pointer to location. */
84061 err = simplify_symbols(mod, info);
84062 if (err < 0)
84063 @@ -3287,13 +3426,6 @@ static int load_module(struct load_info *info, const char __user *uargs,
84064
84065 flush_module_icache(mod);
84066
84067 - /* Now copy in args */
84068 - mod->args = strndup_user(uargs, ~0UL >> 1);
84069 - if (IS_ERR(mod->args)) {
84070 - err = PTR_ERR(mod->args);
84071 - goto free_arch_cleanup;
84072 - }
84073 -
84074 dynamic_debug_setup(info->debug, info->num_debug);
84075
84076 /* Finally it's fully formed, ready to start executing. */
84077 @@ -3328,11 +3460,10 @@ static int load_module(struct load_info *info, const char __user *uargs,
84078 ddebug_cleanup:
84079 dynamic_debug_remove(info->debug);
84080 synchronize_sched();
84081 - kfree(mod->args);
84082 - free_arch_cleanup:
84083 module_arch_cleanup(mod);
84084 free_modinfo:
84085 free_modinfo(mod);
84086 + kfree(mod->args);
84087 free_unload:
84088 module_unload_free(mod);
84089 unlink_mod:
84090 @@ -3415,10 +3546,16 @@ static const char *get_ksymbol(struct module *mod,
84091 unsigned long nextval;
84092
84093 /* At worse, next value is at end of module */
84094 - if (within_module_init(addr, mod))
84095 - nextval = (unsigned long)mod->module_init+mod->init_text_size;
84096 + if (within_module_init_rx(addr, mod))
84097 + nextval = (unsigned long)mod->module_init_rx+mod->init_size_rx;
84098 + else if (within_module_init_rw(addr, mod))
84099 + nextval = (unsigned long)mod->module_init_rw+mod->init_size_rw;
84100 + else if (within_module_core_rx(addr, mod))
84101 + nextval = (unsigned long)mod->module_core_rx+mod->core_size_rx;
84102 + else if (within_module_core_rw(addr, mod))
84103 + nextval = (unsigned long)mod->module_core_rw+mod->core_size_rw;
84104 else
84105 - nextval = (unsigned long)mod->module_core+mod->core_text_size;
84106 + return NULL;
84107
84108 /* Scan for closest preceding symbol, and next symbol. (ELF
84109 starts real symbols at 1). */
84110 @@ -3669,7 +3806,7 @@ static int m_show(struct seq_file *m, void *p)
84111 return 0;
84112
84113 seq_printf(m, "%s %u",
84114 - mod->name, mod->init_size + mod->core_size);
84115 + mod->name, mod->init_size_rx + mod->init_size_rw + mod->core_size_rx + mod->core_size_rw);
84116 print_unload_info(m, mod);
84117
84118 /* Informative for users. */
84119 @@ -3678,7 +3815,7 @@ static int m_show(struct seq_file *m, void *p)
84120 mod->state == MODULE_STATE_COMING ? "Loading":
84121 "Live");
84122 /* Used by oprofile and other similar tools. */
84123 - seq_printf(m, " 0x%pK", mod->module_core);
84124 + seq_printf(m, " 0x%pK 0x%pK", mod->module_core_rx, mod->module_core_rw);
84125
84126 /* Taints info */
84127 if (mod->taints)
84128 @@ -3714,7 +3851,17 @@ static const struct file_operations proc_modules_operations = {
84129
84130 static int __init proc_modules_init(void)
84131 {
84132 +#ifndef CONFIG_GRKERNSEC_HIDESYM
84133 +#ifdef CONFIG_GRKERNSEC_PROC_USER
84134 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
84135 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
84136 + proc_create("modules", S_IRUSR | S_IRGRP, NULL, &proc_modules_operations);
84137 +#else
84138 proc_create("modules", 0, NULL, &proc_modules_operations);
84139 +#endif
84140 +#else
84141 + proc_create("modules", S_IRUSR, NULL, &proc_modules_operations);
84142 +#endif
84143 return 0;
84144 }
84145 module_init(proc_modules_init);
84146 @@ -3775,14 +3922,14 @@ struct module *__module_address(unsigned long addr)
84147 {
84148 struct module *mod;
84149
84150 - if (addr < module_addr_min || addr > module_addr_max)
84151 + if ((addr < module_addr_min_rx || addr > module_addr_max_rx) &&
84152 + (addr < module_addr_min_rw || addr > module_addr_max_rw))
84153 return NULL;
84154
84155 list_for_each_entry_rcu(mod, &modules, list) {
84156 if (mod->state == MODULE_STATE_UNFORMED)
84157 continue;
84158 - if (within_module_core(addr, mod)
84159 - || within_module_init(addr, mod))
84160 + if (within_module_init(addr, mod) || within_module_core(addr, mod))
84161 return mod;
84162 }
84163 return NULL;
84164 @@ -3817,11 +3964,20 @@ bool is_module_text_address(unsigned long addr)
84165 */
84166 struct module *__module_text_address(unsigned long addr)
84167 {
84168 - struct module *mod = __module_address(addr);
84169 + struct module *mod;
84170 +
84171 +#ifdef CONFIG_X86_32
84172 + addr = ktla_ktva(addr);
84173 +#endif
84174 +
84175 + if (addr < module_addr_min_rx || addr > module_addr_max_rx)
84176 + return NULL;
84177 +
84178 + mod = __module_address(addr);
84179 +
84180 if (mod) {
84181 /* Make sure it's within the text section. */
84182 - if (!within(addr, mod->module_init, mod->init_text_size)
84183 - && !within(addr, mod->module_core, mod->core_text_size))
84184 + if (!within_module_init_rx(addr, mod) && !within_module_core_rx(addr, mod))
84185 mod = NULL;
84186 }
84187 return mod;
84188 diff --git a/kernel/mutex-debug.c b/kernel/mutex-debug.c
84189 index 7e3443f..b2a1e6b 100644
84190 --- a/kernel/mutex-debug.c
84191 +++ b/kernel/mutex-debug.c
84192 @@ -49,21 +49,21 @@ void debug_mutex_free_waiter(struct mutex_waiter *waiter)
84193 }
84194
84195 void debug_mutex_add_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84196 - struct thread_info *ti)
84197 + struct task_struct *task)
84198 {
84199 SMP_DEBUG_LOCKS_WARN_ON(!spin_is_locked(&lock->wait_lock));
84200
84201 /* Mark the current thread as blocked on the lock: */
84202 - ti->task->blocked_on = waiter;
84203 + task->blocked_on = waiter;
84204 }
84205
84206 void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84207 - struct thread_info *ti)
84208 + struct task_struct *task)
84209 {
84210 DEBUG_LOCKS_WARN_ON(list_empty(&waiter->list));
84211 - DEBUG_LOCKS_WARN_ON(waiter->task != ti->task);
84212 - DEBUG_LOCKS_WARN_ON(ti->task->blocked_on != waiter);
84213 - ti->task->blocked_on = NULL;
84214 + DEBUG_LOCKS_WARN_ON(waiter->task != task);
84215 + DEBUG_LOCKS_WARN_ON(task->blocked_on != waiter);
84216 + task->blocked_on = NULL;
84217
84218 list_del_init(&waiter->list);
84219 waiter->task = NULL;
84220 diff --git a/kernel/mutex-debug.h b/kernel/mutex-debug.h
84221 index 0799fd3..d06ae3b 100644
84222 --- a/kernel/mutex-debug.h
84223 +++ b/kernel/mutex-debug.h
84224 @@ -20,9 +20,9 @@ extern void debug_mutex_wake_waiter(struct mutex *lock,
84225 extern void debug_mutex_free_waiter(struct mutex_waiter *waiter);
84226 extern void debug_mutex_add_waiter(struct mutex *lock,
84227 struct mutex_waiter *waiter,
84228 - struct thread_info *ti);
84229 + struct task_struct *task);
84230 extern void mutex_remove_waiter(struct mutex *lock, struct mutex_waiter *waiter,
84231 - struct thread_info *ti);
84232 + struct task_struct *task);
84233 extern void debug_mutex_unlock(struct mutex *lock);
84234 extern void debug_mutex_init(struct mutex *lock, const char *name,
84235 struct lock_class_key *key);
84236 diff --git a/kernel/mutex.c b/kernel/mutex.c
84237 index d24105b..15648eb 100644
84238 --- a/kernel/mutex.c
84239 +++ b/kernel/mutex.c
84240 @@ -135,7 +135,7 @@ void mspin_lock(struct mspin_node **lock, struct mspin_node *node)
84241 node->locked = 1;
84242 return;
84243 }
84244 - ACCESS_ONCE(prev->next) = node;
84245 + ACCESS_ONCE_RW(prev->next) = node;
84246 smp_wmb();
84247 /* Wait until the lock holder passes the lock down */
84248 while (!ACCESS_ONCE(node->locked))
84249 @@ -156,7 +156,7 @@ static void mspin_unlock(struct mspin_node **lock, struct mspin_node *node)
84250 while (!(next = ACCESS_ONCE(node->next)))
84251 arch_mutex_cpu_relax();
84252 }
84253 - ACCESS_ONCE(next->locked) = 1;
84254 + ACCESS_ONCE_RW(next->locked) = 1;
84255 smp_wmb();
84256 }
84257
84258 @@ -520,7 +520,7 @@ slowpath:
84259 goto skip_wait;
84260
84261 debug_mutex_lock_common(lock, &waiter);
84262 - debug_mutex_add_waiter(lock, &waiter, task_thread_info(task));
84263 + debug_mutex_add_waiter(lock, &waiter, task);
84264
84265 /* add waiting tasks to the end of the waitqueue (FIFO): */
84266 list_add_tail(&waiter.list, &lock->wait_list);
84267 @@ -564,7 +564,7 @@ slowpath:
84268 schedule_preempt_disabled();
84269 spin_lock_mutex(&lock->wait_lock, flags);
84270 }
84271 - mutex_remove_waiter(lock, &waiter, current_thread_info());
84272 + mutex_remove_waiter(lock, &waiter, task);
84273 /* set it to 0 if there are no waiters left: */
84274 if (likely(list_empty(&lock->wait_list)))
84275 atomic_set(&lock->count, 0);
84276 @@ -601,7 +601,7 @@ skip_wait:
84277 return 0;
84278
84279 err:
84280 - mutex_remove_waiter(lock, &waiter, task_thread_info(task));
84281 + mutex_remove_waiter(lock, &waiter, task);
84282 spin_unlock_mutex(&lock->wait_lock, flags);
84283 debug_mutex_free_waiter(&waiter);
84284 mutex_release(&lock->dep_map, 1, ip);
84285 diff --git a/kernel/notifier.c b/kernel/notifier.c
84286 index 2d5cc4c..d9ea600 100644
84287 --- a/kernel/notifier.c
84288 +++ b/kernel/notifier.c
84289 @@ -5,6 +5,7 @@
84290 #include <linux/rcupdate.h>
84291 #include <linux/vmalloc.h>
84292 #include <linux/reboot.h>
84293 +#include <linux/mm.h>
84294
84295 /*
84296 * Notifier list for kernel code which wants to be called
84297 @@ -24,10 +25,12 @@ static int notifier_chain_register(struct notifier_block **nl,
84298 while ((*nl) != NULL) {
84299 if (n->priority > (*nl)->priority)
84300 break;
84301 - nl = &((*nl)->next);
84302 + nl = (struct notifier_block **)&((*nl)->next);
84303 }
84304 - n->next = *nl;
84305 + pax_open_kernel();
84306 + *(const void **)&n->next = *nl;
84307 rcu_assign_pointer(*nl, n);
84308 + pax_close_kernel();
84309 return 0;
84310 }
84311
84312 @@ -39,10 +42,12 @@ static int notifier_chain_cond_register(struct notifier_block **nl,
84313 return 0;
84314 if (n->priority > (*nl)->priority)
84315 break;
84316 - nl = &((*nl)->next);
84317 + nl = (struct notifier_block **)&((*nl)->next);
84318 }
84319 - n->next = *nl;
84320 + pax_open_kernel();
84321 + *(const void **)&n->next = *nl;
84322 rcu_assign_pointer(*nl, n);
84323 + pax_close_kernel();
84324 return 0;
84325 }
84326
84327 @@ -51,10 +56,12 @@ static int notifier_chain_unregister(struct notifier_block **nl,
84328 {
84329 while ((*nl) != NULL) {
84330 if ((*nl) == n) {
84331 + pax_open_kernel();
84332 rcu_assign_pointer(*nl, n->next);
84333 + pax_close_kernel();
84334 return 0;
84335 }
84336 - nl = &((*nl)->next);
84337 + nl = (struct notifier_block **)&((*nl)->next);
84338 }
84339 return -ENOENT;
84340 }
84341 diff --git a/kernel/panic.c b/kernel/panic.c
84342 index b6c482c..5578061 100644
84343 --- a/kernel/panic.c
84344 +++ b/kernel/panic.c
84345 @@ -407,7 +407,7 @@ static void warn_slowpath_common(const char *file, int line, void *caller,
84346 disable_trace_on_warning();
84347
84348 pr_warn("------------[ cut here ]------------\n");
84349 - pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pS()\n",
84350 + pr_warn("WARNING: CPU: %d PID: %d at %s:%d %pA()\n",
84351 raw_smp_processor_id(), current->pid, file, line, caller);
84352
84353 if (args)
84354 @@ -461,7 +461,8 @@ EXPORT_SYMBOL(warn_slowpath_null);
84355 */
84356 void __stack_chk_fail(void)
84357 {
84358 - panic("stack-protector: Kernel stack is corrupted in: %p\n",
84359 + dump_stack();
84360 + panic("stack-protector: Kernel stack is corrupted in: %pA\n",
84361 __builtin_return_address(0));
84362 }
84363 EXPORT_SYMBOL(__stack_chk_fail);
84364 diff --git a/kernel/pid.c b/kernel/pid.c
84365 index 9b9a266..c20ef80 100644
84366 --- a/kernel/pid.c
84367 +++ b/kernel/pid.c
84368 @@ -33,6 +33,7 @@
84369 #include <linux/rculist.h>
84370 #include <linux/bootmem.h>
84371 #include <linux/hash.h>
84372 +#include <linux/security.h>
84373 #include <linux/pid_namespace.h>
84374 #include <linux/init_task.h>
84375 #include <linux/syscalls.h>
84376 @@ -47,7 +48,7 @@ struct pid init_struct_pid = INIT_STRUCT_PID;
84377
84378 int pid_max = PID_MAX_DEFAULT;
84379
84380 -#define RESERVED_PIDS 300
84381 +#define RESERVED_PIDS 500
84382
84383 int pid_max_min = RESERVED_PIDS + 1;
84384 int pid_max_max = PID_MAX_LIMIT;
84385 @@ -445,10 +446,18 @@ EXPORT_SYMBOL(pid_task);
84386 */
84387 struct task_struct *find_task_by_pid_ns(pid_t nr, struct pid_namespace *ns)
84388 {
84389 + struct task_struct *task;
84390 +
84391 rcu_lockdep_assert(rcu_read_lock_held(),
84392 "find_task_by_pid_ns() needs rcu_read_lock()"
84393 " protection");
84394 - return pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
84395 +
84396 + task = pid_task(find_pid_ns(nr, ns), PIDTYPE_PID);
84397 +
84398 + if (gr_pid_is_chrooted(task))
84399 + return NULL;
84400 +
84401 + return task;
84402 }
84403
84404 struct task_struct *find_task_by_vpid(pid_t vnr)
84405 @@ -456,6 +465,14 @@ struct task_struct *find_task_by_vpid(pid_t vnr)
84406 return find_task_by_pid_ns(vnr, task_active_pid_ns(current));
84407 }
84408
84409 +struct task_struct *find_task_by_vpid_unrestricted(pid_t vnr)
84410 +{
84411 + rcu_lockdep_assert(rcu_read_lock_held(),
84412 + "find_task_by_pid_ns() needs rcu_read_lock()"
84413 + " protection");
84414 + return pid_task(find_pid_ns(vnr, task_active_pid_ns(current)), PIDTYPE_PID);
84415 +}
84416 +
84417 struct pid *get_task_pid(struct task_struct *task, enum pid_type type)
84418 {
84419 struct pid *pid;
84420 diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
84421 index 4208655..19f36a5 100644
84422 --- a/kernel/pid_namespace.c
84423 +++ b/kernel/pid_namespace.c
84424 @@ -247,7 +247,7 @@ static int pid_ns_ctl_handler(struct ctl_table *table, int write,
84425 void __user *buffer, size_t *lenp, loff_t *ppos)
84426 {
84427 struct pid_namespace *pid_ns = task_active_pid_ns(current);
84428 - struct ctl_table tmp = *table;
84429 + ctl_table_no_const tmp = *table;
84430
84431 if (write && !ns_capable(pid_ns->user_ns, CAP_SYS_ADMIN))
84432 return -EPERM;
84433 diff --git a/kernel/posix-cpu-timers.c b/kernel/posix-cpu-timers.c
84434 index c7f31aa..2b44977 100644
84435 --- a/kernel/posix-cpu-timers.c
84436 +++ b/kernel/posix-cpu-timers.c
84437 @@ -1521,14 +1521,14 @@ struct k_clock clock_posix_cpu = {
84438
84439 static __init int init_posix_cpu_timers(void)
84440 {
84441 - struct k_clock process = {
84442 + static struct k_clock process = {
84443 .clock_getres = process_cpu_clock_getres,
84444 .clock_get = process_cpu_clock_get,
84445 .timer_create = process_cpu_timer_create,
84446 .nsleep = process_cpu_nsleep,
84447 .nsleep_restart = process_cpu_nsleep_restart,
84448 };
84449 - struct k_clock thread = {
84450 + static struct k_clock thread = {
84451 .clock_getres = thread_cpu_clock_getres,
84452 .clock_get = thread_cpu_clock_get,
84453 .timer_create = thread_cpu_timer_create,
84454 diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c
84455 index 424c2d4..679242f 100644
84456 --- a/kernel/posix-timers.c
84457 +++ b/kernel/posix-timers.c
84458 @@ -43,6 +43,7 @@
84459 #include <linux/hash.h>
84460 #include <linux/posix-clock.h>
84461 #include <linux/posix-timers.h>
84462 +#include <linux/grsecurity.h>
84463 #include <linux/syscalls.h>
84464 #include <linux/wait.h>
84465 #include <linux/workqueue.h>
84466 @@ -122,7 +123,7 @@ static DEFINE_SPINLOCK(hash_lock);
84467 * which we beg off on and pass to do_sys_settimeofday().
84468 */
84469
84470 -static struct k_clock posix_clocks[MAX_CLOCKS];
84471 +static struct k_clock *posix_clocks[MAX_CLOCKS];
84472
84473 /*
84474 * These ones are defined below.
84475 @@ -275,7 +276,7 @@ static int posix_get_tai(clockid_t which_clock, struct timespec *tp)
84476 */
84477 static __init int init_posix_timers(void)
84478 {
84479 - struct k_clock clock_realtime = {
84480 + static struct k_clock clock_realtime = {
84481 .clock_getres = hrtimer_get_res,
84482 .clock_get = posix_clock_realtime_get,
84483 .clock_set = posix_clock_realtime_set,
84484 @@ -287,7 +288,7 @@ static __init int init_posix_timers(void)
84485 .timer_get = common_timer_get,
84486 .timer_del = common_timer_del,
84487 };
84488 - struct k_clock clock_monotonic = {
84489 + static struct k_clock clock_monotonic = {
84490 .clock_getres = hrtimer_get_res,
84491 .clock_get = posix_ktime_get_ts,
84492 .nsleep = common_nsleep,
84493 @@ -297,19 +298,19 @@ static __init int init_posix_timers(void)
84494 .timer_get = common_timer_get,
84495 .timer_del = common_timer_del,
84496 };
84497 - struct k_clock clock_monotonic_raw = {
84498 + static struct k_clock clock_monotonic_raw = {
84499 .clock_getres = hrtimer_get_res,
84500 .clock_get = posix_get_monotonic_raw,
84501 };
84502 - struct k_clock clock_realtime_coarse = {
84503 + static struct k_clock clock_realtime_coarse = {
84504 .clock_getres = posix_get_coarse_res,
84505 .clock_get = posix_get_realtime_coarse,
84506 };
84507 - struct k_clock clock_monotonic_coarse = {
84508 + static struct k_clock clock_monotonic_coarse = {
84509 .clock_getres = posix_get_coarse_res,
84510 .clock_get = posix_get_monotonic_coarse,
84511 };
84512 - struct k_clock clock_tai = {
84513 + static struct k_clock clock_tai = {
84514 .clock_getres = hrtimer_get_res,
84515 .clock_get = posix_get_tai,
84516 .nsleep = common_nsleep,
84517 @@ -319,7 +320,7 @@ static __init int init_posix_timers(void)
84518 .timer_get = common_timer_get,
84519 .timer_del = common_timer_del,
84520 };
84521 - struct k_clock clock_boottime = {
84522 + static struct k_clock clock_boottime = {
84523 .clock_getres = hrtimer_get_res,
84524 .clock_get = posix_get_boottime,
84525 .nsleep = common_nsleep,
84526 @@ -531,7 +532,7 @@ void posix_timers_register_clock(const clockid_t clock_id,
84527 return;
84528 }
84529
84530 - posix_clocks[clock_id] = *new_clock;
84531 + posix_clocks[clock_id] = new_clock;
84532 }
84533 EXPORT_SYMBOL_GPL(posix_timers_register_clock);
84534
84535 @@ -577,9 +578,9 @@ static struct k_clock *clockid_to_kclock(const clockid_t id)
84536 return (id & CLOCKFD_MASK) == CLOCKFD ?
84537 &clock_posix_dynamic : &clock_posix_cpu;
84538
84539 - if (id >= MAX_CLOCKS || !posix_clocks[id].clock_getres)
84540 + if (id >= MAX_CLOCKS || !posix_clocks[id] || !posix_clocks[id]->clock_getres)
84541 return NULL;
84542 - return &posix_clocks[id];
84543 + return posix_clocks[id];
84544 }
84545
84546 static int common_timer_create(struct k_itimer *new_timer)
84547 @@ -597,7 +598,7 @@ SYSCALL_DEFINE3(timer_create, const clockid_t, which_clock,
84548 struct k_clock *kc = clockid_to_kclock(which_clock);
84549 struct k_itimer *new_timer;
84550 int error, new_timer_id;
84551 - sigevent_t event;
84552 + sigevent_t event = { };
84553 int it_id_set = IT_ID_NOT_SET;
84554
84555 if (!kc)
84556 @@ -1011,6 +1012,13 @@ SYSCALL_DEFINE2(clock_settime, const clockid_t, which_clock,
84557 if (copy_from_user(&new_tp, tp, sizeof (*tp)))
84558 return -EFAULT;
84559
84560 + /* only the CLOCK_REALTIME clock can be set, all other clocks
84561 + have their clock_set fptr set to a nosettime dummy function
84562 + CLOCK_REALTIME has a NULL clock_set fptr which causes it to
84563 + call common_clock_set, which calls do_sys_settimeofday, which
84564 + we hook
84565 + */
84566 +
84567 return kc->clock_set(which_clock, &new_tp);
84568 }
84569
84570 diff --git a/kernel/power/Kconfig b/kernel/power/Kconfig
84571 index d444c4e..bc3de51 100644
84572 --- a/kernel/power/Kconfig
84573 +++ b/kernel/power/Kconfig
84574 @@ -24,6 +24,8 @@ config HIBERNATE_CALLBACKS
84575 config HIBERNATION
84576 bool "Hibernation (aka 'suspend to disk')"
84577 depends on SWAP && ARCH_HIBERNATION_POSSIBLE
84578 + depends on !GRKERNSEC_KMEM
84579 + depends on !PAX_MEMORY_SANITIZE
84580 select HIBERNATE_CALLBACKS
84581 select LZO_COMPRESS
84582 select LZO_DECOMPRESS
84583 diff --git a/kernel/power/process.c b/kernel/power/process.c
84584 index 06ec886..9dba35e 100644
84585 --- a/kernel/power/process.c
84586 +++ b/kernel/power/process.c
84587 @@ -34,6 +34,7 @@ static int try_to_freeze_tasks(bool user_only)
84588 unsigned int elapsed_msecs;
84589 bool wakeup = false;
84590 int sleep_usecs = USEC_PER_MSEC;
84591 + bool timedout = false;
84592
84593 do_gettimeofday(&start);
84594
84595 @@ -44,13 +45,20 @@ static int try_to_freeze_tasks(bool user_only)
84596
84597 while (true) {
84598 todo = 0;
84599 + if (time_after(jiffies, end_time))
84600 + timedout = true;
84601 read_lock(&tasklist_lock);
84602 do_each_thread(g, p) {
84603 if (p == current || !freeze_task(p))
84604 continue;
84605
84606 - if (!freezer_should_skip(p))
84607 + if (!freezer_should_skip(p)) {
84608 todo++;
84609 + if (timedout) {
84610 + printk(KERN_ERR "Task refusing to freeze:\n");
84611 + sched_show_task(p);
84612 + }
84613 + }
84614 } while_each_thread(g, p);
84615 read_unlock(&tasklist_lock);
84616
84617 @@ -59,7 +67,7 @@ static int try_to_freeze_tasks(bool user_only)
84618 todo += wq_busy;
84619 }
84620
84621 - if (!todo || time_after(jiffies, end_time))
84622 + if (!todo || timedout)
84623 break;
84624
84625 if (pm_wakeup_pending()) {
84626 diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
84627 index b4e8500..b457a6c 100644
84628 --- a/kernel/printk/printk.c
84629 +++ b/kernel/printk/printk.c
84630 @@ -385,6 +385,11 @@ static int check_syslog_permissions(int type, bool from_file)
84631 if (from_file && type != SYSLOG_ACTION_OPEN)
84632 return 0;
84633
84634 +#ifdef CONFIG_GRKERNSEC_DMESG
84635 + if (grsec_enable_dmesg && !capable(CAP_SYSLOG) && !capable_nolog(CAP_SYS_ADMIN))
84636 + return -EPERM;
84637 +#endif
84638 +
84639 if (syslog_action_restricted(type)) {
84640 if (capable(CAP_SYSLOG))
84641 return 0;
84642 diff --git a/kernel/profile.c b/kernel/profile.c
84643 index 6631e1e..310c266 100644
84644 --- a/kernel/profile.c
84645 +++ b/kernel/profile.c
84646 @@ -37,7 +37,7 @@ struct profile_hit {
84647 #define NR_PROFILE_HIT (PAGE_SIZE/sizeof(struct profile_hit))
84648 #define NR_PROFILE_GRP (NR_PROFILE_HIT/PROFILE_GRPSZ)
84649
84650 -static atomic_t *prof_buffer;
84651 +static atomic_unchecked_t *prof_buffer;
84652 static unsigned long prof_len, prof_shift;
84653
84654 int prof_on __read_mostly;
84655 @@ -260,7 +260,7 @@ static void profile_flip_buffers(void)
84656 hits[i].pc = 0;
84657 continue;
84658 }
84659 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
84660 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
84661 hits[i].hits = hits[i].pc = 0;
84662 }
84663 }
84664 @@ -321,9 +321,9 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
84665 * Add the current hit(s) and flush the write-queue out
84666 * to the global buffer:
84667 */
84668 - atomic_add(nr_hits, &prof_buffer[pc]);
84669 + atomic_add_unchecked(nr_hits, &prof_buffer[pc]);
84670 for (i = 0; i < NR_PROFILE_HIT; ++i) {
84671 - atomic_add(hits[i].hits, &prof_buffer[hits[i].pc]);
84672 + atomic_add_unchecked(hits[i].hits, &prof_buffer[hits[i].pc]);
84673 hits[i].pc = hits[i].hits = 0;
84674 }
84675 out:
84676 @@ -398,7 +398,7 @@ static void do_profile_hits(int type, void *__pc, unsigned int nr_hits)
84677 {
84678 unsigned long pc;
84679 pc = ((unsigned long)__pc - (unsigned long)_stext) >> prof_shift;
84680 - atomic_add(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
84681 + atomic_add_unchecked(nr_hits, &prof_buffer[min(pc, prof_len - 1)]);
84682 }
84683 #endif /* !CONFIG_SMP */
84684
84685 @@ -494,7 +494,7 @@ read_profile(struct file *file, char __user *buf, size_t count, loff_t *ppos)
84686 return -EFAULT;
84687 buf++; p++; count--; read++;
84688 }
84689 - pnt = (char *)prof_buffer + p - sizeof(atomic_t);
84690 + pnt = (char *)prof_buffer + p - sizeof(atomic_unchecked_t);
84691 if (copy_to_user(buf, (void *)pnt, count))
84692 return -EFAULT;
84693 read += count;
84694 @@ -525,7 +525,7 @@ static ssize_t write_profile(struct file *file, const char __user *buf,
84695 }
84696 #endif
84697 profile_discard_flip_buffers();
84698 - memset(prof_buffer, 0, prof_len * sizeof(atomic_t));
84699 + memset(prof_buffer, 0, prof_len * sizeof(atomic_unchecked_t));
84700 return count;
84701 }
84702
84703 diff --git a/kernel/ptrace.c b/kernel/ptrace.c
84704 index 1f4bcb3..99cf7ab 100644
84705 --- a/kernel/ptrace.c
84706 +++ b/kernel/ptrace.c
84707 @@ -327,7 +327,7 @@ static int ptrace_attach(struct task_struct *task, long request,
84708 if (seize)
84709 flags |= PT_SEIZED;
84710 rcu_read_lock();
84711 - if (ns_capable(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
84712 + if (ns_capable_nolog(__task_cred(task)->user_ns, CAP_SYS_PTRACE))
84713 flags |= PT_PTRACE_CAP;
84714 rcu_read_unlock();
84715 task->ptrace = flags;
84716 @@ -538,7 +538,7 @@ int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst
84717 break;
84718 return -EIO;
84719 }
84720 - if (copy_to_user(dst, buf, retval))
84721 + if (retval > sizeof(buf) || copy_to_user(dst, buf, retval))
84722 return -EFAULT;
84723 copied += retval;
84724 src += retval;
84725 @@ -806,7 +806,7 @@ int ptrace_request(struct task_struct *child, long request,
84726 bool seized = child->ptrace & PT_SEIZED;
84727 int ret = -EIO;
84728 siginfo_t siginfo, *si;
84729 - void __user *datavp = (void __user *) data;
84730 + void __user *datavp = (__force void __user *) data;
84731 unsigned long __user *datalp = datavp;
84732 unsigned long flags;
84733
84734 @@ -1052,14 +1052,21 @@ SYSCALL_DEFINE4(ptrace, long, request, long, pid, unsigned long, addr,
84735 goto out;
84736 }
84737
84738 + if (gr_handle_ptrace(child, request)) {
84739 + ret = -EPERM;
84740 + goto out_put_task_struct;
84741 + }
84742 +
84743 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
84744 ret = ptrace_attach(child, request, addr, data);
84745 /*
84746 * Some architectures need to do book-keeping after
84747 * a ptrace attach.
84748 */
84749 - if (!ret)
84750 + if (!ret) {
84751 arch_ptrace_attach(child);
84752 + gr_audit_ptrace(child);
84753 + }
84754 goto out_put_task_struct;
84755 }
84756
84757 @@ -1087,7 +1094,7 @@ int generic_ptrace_peekdata(struct task_struct *tsk, unsigned long addr,
84758 copied = access_process_vm(tsk, addr, &tmp, sizeof(tmp), 0);
84759 if (copied != sizeof(tmp))
84760 return -EIO;
84761 - return put_user(tmp, (unsigned long __user *)data);
84762 + return put_user(tmp, (__force unsigned long __user *)data);
84763 }
84764
84765 int generic_ptrace_pokedata(struct task_struct *tsk, unsigned long addr,
84766 @@ -1181,7 +1188,7 @@ int compat_ptrace_request(struct task_struct *child, compat_long_t request,
84767 }
84768
84769 asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
84770 - compat_long_t addr, compat_long_t data)
84771 + compat_ulong_t addr, compat_ulong_t data)
84772 {
84773 struct task_struct *child;
84774 long ret;
84775 @@ -1197,14 +1204,21 @@ asmlinkage long compat_sys_ptrace(compat_long_t request, compat_long_t pid,
84776 goto out;
84777 }
84778
84779 + if (gr_handle_ptrace(child, request)) {
84780 + ret = -EPERM;
84781 + goto out_put_task_struct;
84782 + }
84783 +
84784 if (request == PTRACE_ATTACH || request == PTRACE_SEIZE) {
84785 ret = ptrace_attach(child, request, addr, data);
84786 /*
84787 * Some architectures need to do book-keeping after
84788 * a ptrace attach.
84789 */
84790 - if (!ret)
84791 + if (!ret) {
84792 arch_ptrace_attach(child);
84793 + gr_audit_ptrace(child);
84794 + }
84795 goto out_put_task_struct;
84796 }
84797
84798 diff --git a/kernel/rcupdate.c b/kernel/rcupdate.c
84799 index b02a339..ce2d20c 100644
84800 --- a/kernel/rcupdate.c
84801 +++ b/kernel/rcupdate.c
84802 @@ -312,10 +312,10 @@ int rcu_jiffies_till_stall_check(void)
84803 * for CONFIG_RCU_CPU_STALL_TIMEOUT.
84804 */
84805 if (till_stall_check < 3) {
84806 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 3;
84807 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 3;
84808 till_stall_check = 3;
84809 } else if (till_stall_check > 300) {
84810 - ACCESS_ONCE(rcu_cpu_stall_timeout) = 300;
84811 + ACCESS_ONCE_RW(rcu_cpu_stall_timeout) = 300;
84812 till_stall_check = 300;
84813 }
84814 return till_stall_check * HZ + RCU_STALL_DELAY_DELTA;
84815 diff --git a/kernel/rcutiny.c b/kernel/rcutiny.c
84816 index 9ed6075..c9e8a63 100644
84817 --- a/kernel/rcutiny.c
84818 +++ b/kernel/rcutiny.c
84819 @@ -45,7 +45,7 @@
84820 /* Forward declarations for rcutiny_plugin.h. */
84821 struct rcu_ctrlblk;
84822 static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp);
84823 -static void rcu_process_callbacks(struct softirq_action *unused);
84824 +static void rcu_process_callbacks(void);
84825 static void __call_rcu(struct rcu_head *head,
84826 void (*func)(struct rcu_head *rcu),
84827 struct rcu_ctrlblk *rcp);
84828 @@ -309,7 +309,7 @@ static void __rcu_process_callbacks(struct rcu_ctrlblk *rcp)
84829 false));
84830 }
84831
84832 -static void rcu_process_callbacks(struct softirq_action *unused)
84833 +static __latent_entropy void rcu_process_callbacks(void)
84834 {
84835 __rcu_process_callbacks(&rcu_sched_ctrlblk);
84836 __rcu_process_callbacks(&rcu_bh_ctrlblk);
84837 diff --git a/kernel/rcutorture.c b/kernel/rcutorture.c
84838 index be63101..05cf721 100644
84839 --- a/kernel/rcutorture.c
84840 +++ b/kernel/rcutorture.c
84841 @@ -170,12 +170,12 @@ static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_count) =
84842 { 0 };
84843 static DEFINE_PER_CPU(long [RCU_TORTURE_PIPE_LEN + 1], rcu_torture_batch) =
84844 { 0 };
84845 -static atomic_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
84846 -static atomic_t n_rcu_torture_alloc;
84847 -static atomic_t n_rcu_torture_alloc_fail;
84848 -static atomic_t n_rcu_torture_free;
84849 -static atomic_t n_rcu_torture_mberror;
84850 -static atomic_t n_rcu_torture_error;
84851 +static atomic_unchecked_t rcu_torture_wcount[RCU_TORTURE_PIPE_LEN + 1];
84852 +static atomic_unchecked_t n_rcu_torture_alloc;
84853 +static atomic_unchecked_t n_rcu_torture_alloc_fail;
84854 +static atomic_unchecked_t n_rcu_torture_free;
84855 +static atomic_unchecked_t n_rcu_torture_mberror;
84856 +static atomic_unchecked_t n_rcu_torture_error;
84857 static long n_rcu_torture_barrier_error;
84858 static long n_rcu_torture_boost_ktrerror;
84859 static long n_rcu_torture_boost_rterror;
84860 @@ -293,11 +293,11 @@ rcu_torture_alloc(void)
84861
84862 spin_lock_bh(&rcu_torture_lock);
84863 if (list_empty(&rcu_torture_freelist)) {
84864 - atomic_inc(&n_rcu_torture_alloc_fail);
84865 + atomic_inc_unchecked(&n_rcu_torture_alloc_fail);
84866 spin_unlock_bh(&rcu_torture_lock);
84867 return NULL;
84868 }
84869 - atomic_inc(&n_rcu_torture_alloc);
84870 + atomic_inc_unchecked(&n_rcu_torture_alloc);
84871 p = rcu_torture_freelist.next;
84872 list_del_init(p);
84873 spin_unlock_bh(&rcu_torture_lock);
84874 @@ -310,7 +310,7 @@ rcu_torture_alloc(void)
84875 static void
84876 rcu_torture_free(struct rcu_torture *p)
84877 {
84878 - atomic_inc(&n_rcu_torture_free);
84879 + atomic_inc_unchecked(&n_rcu_torture_free);
84880 spin_lock_bh(&rcu_torture_lock);
84881 list_add_tail(&p->rtort_free, &rcu_torture_freelist);
84882 spin_unlock_bh(&rcu_torture_lock);
84883 @@ -431,7 +431,7 @@ rcu_torture_cb(struct rcu_head *p)
84884 i = rp->rtort_pipe_count;
84885 if (i > RCU_TORTURE_PIPE_LEN)
84886 i = RCU_TORTURE_PIPE_LEN;
84887 - atomic_inc(&rcu_torture_wcount[i]);
84888 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84889 if (++rp->rtort_pipe_count >= RCU_TORTURE_PIPE_LEN) {
84890 rp->rtort_mbtest = 0;
84891 rcu_torture_free(rp);
84892 @@ -821,7 +821,7 @@ rcu_torture_writer(void *arg)
84893 i = old_rp->rtort_pipe_count;
84894 if (i > RCU_TORTURE_PIPE_LEN)
84895 i = RCU_TORTURE_PIPE_LEN;
84896 - atomic_inc(&rcu_torture_wcount[i]);
84897 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84898 old_rp->rtort_pipe_count++;
84899 if (gp_normal == gp_exp)
84900 exp = !!(rcu_random(&rand) & 0x80);
84901 @@ -839,7 +839,7 @@ rcu_torture_writer(void *arg)
84902 i = rp->rtort_pipe_count;
84903 if (i > RCU_TORTURE_PIPE_LEN)
84904 i = RCU_TORTURE_PIPE_LEN;
84905 - atomic_inc(&rcu_torture_wcount[i]);
84906 + atomic_inc_unchecked(&rcu_torture_wcount[i]);
84907 if (++rp->rtort_pipe_count >=
84908 RCU_TORTURE_PIPE_LEN) {
84909 rp->rtort_mbtest = 0;
84910 @@ -938,7 +938,7 @@ static void rcu_torture_timer(unsigned long unused)
84911 return;
84912 }
84913 if (p->rtort_mbtest == 0)
84914 - atomic_inc(&n_rcu_torture_mberror);
84915 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84916 spin_lock(&rand_lock);
84917 cur_ops->read_delay(&rand);
84918 n_rcu_torture_timers++;
84919 @@ -1008,7 +1008,7 @@ rcu_torture_reader(void *arg)
84920 continue;
84921 }
84922 if (p->rtort_mbtest == 0)
84923 - atomic_inc(&n_rcu_torture_mberror);
84924 + atomic_inc_unchecked(&n_rcu_torture_mberror);
84925 cur_ops->read_delay(&rand);
84926 preempt_disable();
84927 pipe_count = p->rtort_pipe_count;
84928 @@ -1071,11 +1071,11 @@ rcu_torture_printk(char *page)
84929 rcu_torture_current,
84930 rcu_torture_current_version,
84931 list_empty(&rcu_torture_freelist),
84932 - atomic_read(&n_rcu_torture_alloc),
84933 - atomic_read(&n_rcu_torture_alloc_fail),
84934 - atomic_read(&n_rcu_torture_free));
84935 + atomic_read_unchecked(&n_rcu_torture_alloc),
84936 + atomic_read_unchecked(&n_rcu_torture_alloc_fail),
84937 + atomic_read_unchecked(&n_rcu_torture_free));
84938 cnt += sprintf(&page[cnt], "rtmbe: %d rtbke: %ld rtbre: %ld ",
84939 - atomic_read(&n_rcu_torture_mberror),
84940 + atomic_read_unchecked(&n_rcu_torture_mberror),
84941 n_rcu_torture_boost_ktrerror,
84942 n_rcu_torture_boost_rterror);
84943 cnt += sprintf(&page[cnt], "rtbf: %ld rtb: %ld nt: %ld ",
84944 @@ -1094,14 +1094,14 @@ rcu_torture_printk(char *page)
84945 n_barrier_attempts,
84946 n_rcu_torture_barrier_error);
84947 cnt += sprintf(&page[cnt], "\n%s%s ", torture_type, TORTURE_FLAG);
84948 - if (atomic_read(&n_rcu_torture_mberror) != 0 ||
84949 + if (atomic_read_unchecked(&n_rcu_torture_mberror) != 0 ||
84950 n_rcu_torture_barrier_error != 0 ||
84951 n_rcu_torture_boost_ktrerror != 0 ||
84952 n_rcu_torture_boost_rterror != 0 ||
84953 n_rcu_torture_boost_failure != 0 ||
84954 i > 1) {
84955 cnt += sprintf(&page[cnt], "!!! ");
84956 - atomic_inc(&n_rcu_torture_error);
84957 + atomic_inc_unchecked(&n_rcu_torture_error);
84958 WARN_ON_ONCE(1);
84959 }
84960 cnt += sprintf(&page[cnt], "Reader Pipe: ");
84961 @@ -1115,7 +1115,7 @@ rcu_torture_printk(char *page)
84962 cnt += sprintf(&page[cnt], "Free-Block Circulation: ");
84963 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
84964 cnt += sprintf(&page[cnt], " %d",
84965 - atomic_read(&rcu_torture_wcount[i]));
84966 + atomic_read_unchecked(&rcu_torture_wcount[i]));
84967 }
84968 cnt += sprintf(&page[cnt], "\n");
84969 if (cur_ops->stats)
84970 @@ -1830,7 +1830,7 @@ rcu_torture_cleanup(void)
84971
84972 rcu_torture_stats_print(); /* -After- the stats thread is stopped! */
84973
84974 - if (atomic_read(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84975 + if (atomic_read_unchecked(&n_rcu_torture_error) || n_rcu_torture_barrier_error)
84976 rcu_torture_print_module_parms(cur_ops, "End of test: FAILURE");
84977 else if (n_online_successes != n_online_attempts ||
84978 n_offline_successes != n_offline_attempts)
84979 @@ -1952,18 +1952,18 @@ rcu_torture_init(void)
84980
84981 rcu_torture_current = NULL;
84982 rcu_torture_current_version = 0;
84983 - atomic_set(&n_rcu_torture_alloc, 0);
84984 - atomic_set(&n_rcu_torture_alloc_fail, 0);
84985 - atomic_set(&n_rcu_torture_free, 0);
84986 - atomic_set(&n_rcu_torture_mberror, 0);
84987 - atomic_set(&n_rcu_torture_error, 0);
84988 + atomic_set_unchecked(&n_rcu_torture_alloc, 0);
84989 + atomic_set_unchecked(&n_rcu_torture_alloc_fail, 0);
84990 + atomic_set_unchecked(&n_rcu_torture_free, 0);
84991 + atomic_set_unchecked(&n_rcu_torture_mberror, 0);
84992 + atomic_set_unchecked(&n_rcu_torture_error, 0);
84993 n_rcu_torture_barrier_error = 0;
84994 n_rcu_torture_boost_ktrerror = 0;
84995 n_rcu_torture_boost_rterror = 0;
84996 n_rcu_torture_boost_failure = 0;
84997 n_rcu_torture_boosts = 0;
84998 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++)
84999 - atomic_set(&rcu_torture_wcount[i], 0);
85000 + atomic_set_unchecked(&rcu_torture_wcount[i], 0);
85001 for_each_possible_cpu(cpu) {
85002 for (i = 0; i < RCU_TORTURE_PIPE_LEN + 1; i++) {
85003 per_cpu(rcu_torture_count, cpu)[i] = 0;
85004 diff --git a/kernel/rcutree.c b/kernel/rcutree.c
85005 index 32618b3..c1fb822 100644
85006 --- a/kernel/rcutree.c
85007 +++ b/kernel/rcutree.c
85008 @@ -382,9 +382,9 @@ static void rcu_eqs_enter_common(struct rcu_dynticks *rdtp, long long oldval,
85009 rcu_prepare_for_idle(smp_processor_id());
85010 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
85011 smp_mb__before_atomic_inc(); /* See above. */
85012 - atomic_inc(&rdtp->dynticks);
85013 + atomic_inc_unchecked(&rdtp->dynticks);
85014 smp_mb__after_atomic_inc(); /* Force ordering with next sojourn. */
85015 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
85016 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
85017
85018 /*
85019 * It is illegal to enter an extended quiescent state while
85020 @@ -501,10 +501,10 @@ static void rcu_eqs_exit_common(struct rcu_dynticks *rdtp, long long oldval,
85021 int user)
85022 {
85023 smp_mb__before_atomic_inc(); /* Force ordering w/previous sojourn. */
85024 - atomic_inc(&rdtp->dynticks);
85025 + atomic_inc_unchecked(&rdtp->dynticks);
85026 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
85027 smp_mb__after_atomic_inc(); /* See above. */
85028 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
85029 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
85030 rcu_cleanup_after_idle(smp_processor_id());
85031 trace_rcu_dyntick(TPS("End"), oldval, rdtp->dynticks_nesting);
85032 if (!user && !is_idle_task(current)) {
85033 @@ -623,14 +623,14 @@ void rcu_nmi_enter(void)
85034 struct rcu_dynticks *rdtp = &__get_cpu_var(rcu_dynticks);
85035
85036 if (rdtp->dynticks_nmi_nesting == 0 &&
85037 - (atomic_read(&rdtp->dynticks) & 0x1))
85038 + (atomic_read_unchecked(&rdtp->dynticks) & 0x1))
85039 return;
85040 rdtp->dynticks_nmi_nesting++;
85041 smp_mb__before_atomic_inc(); /* Force delay from prior write. */
85042 - atomic_inc(&rdtp->dynticks);
85043 + atomic_inc_unchecked(&rdtp->dynticks);
85044 /* CPUs seeing atomic_inc() must see later RCU read-side crit sects */
85045 smp_mb__after_atomic_inc(); /* See above. */
85046 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks) & 0x1));
85047 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks) & 0x1));
85048 }
85049
85050 /**
85051 @@ -649,9 +649,9 @@ void rcu_nmi_exit(void)
85052 return;
85053 /* CPUs seeing atomic_inc() must see prior RCU read-side crit sects */
85054 smp_mb__before_atomic_inc(); /* See above. */
85055 - atomic_inc(&rdtp->dynticks);
85056 + atomic_inc_unchecked(&rdtp->dynticks);
85057 smp_mb__after_atomic_inc(); /* Force delay to next write. */
85058 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks) & 0x1);
85059 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks) & 0x1);
85060 }
85061
85062 /**
85063 @@ -665,7 +665,7 @@ int rcu_is_cpu_idle(void)
85064 int ret;
85065
85066 preempt_disable();
85067 - ret = (atomic_read(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
85068 + ret = (atomic_read_unchecked(&__get_cpu_var(rcu_dynticks).dynticks) & 0x1) == 0;
85069 preempt_enable();
85070 return ret;
85071 }
85072 @@ -734,7 +734,7 @@ static int rcu_is_cpu_rrupt_from_idle(void)
85073 static int dyntick_save_progress_counter(struct rcu_data *rdp,
85074 bool *isidle, unsigned long *maxj)
85075 {
85076 - rdp->dynticks_snap = atomic_add_return(0, &rdp->dynticks->dynticks);
85077 + rdp->dynticks_snap = atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
85078 rcu_sysidle_check_cpu(rdp, isidle, maxj);
85079 return (rdp->dynticks_snap & 0x1) == 0;
85080 }
85081 @@ -751,7 +751,7 @@ static int rcu_implicit_dynticks_qs(struct rcu_data *rdp,
85082 unsigned int curr;
85083 unsigned int snap;
85084
85085 - curr = (unsigned int)atomic_add_return(0, &rdp->dynticks->dynticks);
85086 + curr = (unsigned int)atomic_add_return_unchecked(0, &rdp->dynticks->dynticks);
85087 snap = (unsigned int)rdp->dynticks_snap;
85088
85089 /*
85090 @@ -1341,9 +1341,9 @@ static int rcu_gp_init(struct rcu_state *rsp)
85091 rdp = this_cpu_ptr(rsp->rda);
85092 rcu_preempt_check_blocked_tasks(rnp);
85093 rnp->qsmask = rnp->qsmaskinit;
85094 - ACCESS_ONCE(rnp->gpnum) = rsp->gpnum;
85095 + ACCESS_ONCE_RW(rnp->gpnum) = rsp->gpnum;
85096 WARN_ON_ONCE(rnp->completed != rsp->completed);
85097 - ACCESS_ONCE(rnp->completed) = rsp->completed;
85098 + ACCESS_ONCE_RW(rnp->completed) = rsp->completed;
85099 if (rnp == rdp->mynode)
85100 __note_gp_changes(rsp, rnp, rdp);
85101 rcu_preempt_boost_start_gp(rnp);
85102 @@ -1434,7 +1434,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
85103 */
85104 rcu_for_each_node_breadth_first(rsp, rnp) {
85105 raw_spin_lock_irq(&rnp->lock);
85106 - ACCESS_ONCE(rnp->completed) = rsp->gpnum;
85107 + ACCESS_ONCE_RW(rnp->completed) = rsp->gpnum;
85108 rdp = this_cpu_ptr(rsp->rda);
85109 if (rnp == rdp->mynode)
85110 __note_gp_changes(rsp, rnp, rdp);
85111 @@ -1766,7 +1766,7 @@ rcu_send_cbs_to_orphanage(int cpu, struct rcu_state *rsp,
85112 rsp->qlen += rdp->qlen;
85113 rdp->n_cbs_orphaned += rdp->qlen;
85114 rdp->qlen_lazy = 0;
85115 - ACCESS_ONCE(rdp->qlen) = 0;
85116 + ACCESS_ONCE_RW(rdp->qlen) = 0;
85117 }
85118
85119 /*
85120 @@ -2012,7 +2012,7 @@ static void rcu_do_batch(struct rcu_state *rsp, struct rcu_data *rdp)
85121 }
85122 smp_mb(); /* List handling before counting for rcu_barrier(). */
85123 rdp->qlen_lazy -= count_lazy;
85124 - ACCESS_ONCE(rdp->qlen) -= count;
85125 + ACCESS_ONCE_RW(rdp->qlen) -= count;
85126 rdp->n_cbs_invoked += count;
85127
85128 /* Reinstate batch limit if we have worked down the excess. */
85129 @@ -2209,7 +2209,7 @@ __rcu_process_callbacks(struct rcu_state *rsp)
85130 /*
85131 * Do RCU core processing for the current CPU.
85132 */
85133 -static void rcu_process_callbacks(struct softirq_action *unused)
85134 +static __latent_entropy void rcu_process_callbacks(void)
85135 {
85136 struct rcu_state *rsp;
85137
85138 @@ -2316,7 +2316,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
85139 WARN_ON_ONCE((unsigned long)head & 0x3); /* Misaligned rcu_head! */
85140 if (debug_rcu_head_queue(head)) {
85141 /* Probable double call_rcu(), so leak the callback. */
85142 - ACCESS_ONCE(head->func) = rcu_leak_callback;
85143 + ACCESS_ONCE_RW(head->func) = rcu_leak_callback;
85144 WARN_ONCE(1, "__call_rcu(): Leaked duplicate callback\n");
85145 return;
85146 }
85147 @@ -2344,7 +2344,7 @@ __call_rcu(struct rcu_head *head, void (*func)(struct rcu_head *rcu),
85148 local_irq_restore(flags);
85149 return;
85150 }
85151 - ACCESS_ONCE(rdp->qlen)++;
85152 + ACCESS_ONCE_RW(rdp->qlen)++;
85153 if (lazy)
85154 rdp->qlen_lazy++;
85155 else
85156 @@ -2553,11 +2553,11 @@ void synchronize_sched_expedited(void)
85157 * counter wrap on a 32-bit system. Quite a few more CPUs would of
85158 * course be required on a 64-bit system.
85159 */
85160 - if (ULONG_CMP_GE((ulong)atomic_long_read(&rsp->expedited_start),
85161 + if (ULONG_CMP_GE((ulong)atomic_long_read_unchecked(&rsp->expedited_start),
85162 (ulong)atomic_long_read(&rsp->expedited_done) +
85163 ULONG_MAX / 8)) {
85164 synchronize_sched();
85165 - atomic_long_inc(&rsp->expedited_wrap);
85166 + atomic_long_inc_unchecked(&rsp->expedited_wrap);
85167 return;
85168 }
85169
85170 @@ -2565,7 +2565,7 @@ void synchronize_sched_expedited(void)
85171 * Take a ticket. Note that atomic_inc_return() implies a
85172 * full memory barrier.
85173 */
85174 - snap = atomic_long_inc_return(&rsp->expedited_start);
85175 + snap = atomic_long_inc_return_unchecked(&rsp->expedited_start);
85176 firstsnap = snap;
85177 get_online_cpus();
85178 WARN_ON_ONCE(cpu_is_offline(raw_smp_processor_id()));
85179 @@ -2578,14 +2578,14 @@ void synchronize_sched_expedited(void)
85180 synchronize_sched_expedited_cpu_stop,
85181 NULL) == -EAGAIN) {
85182 put_online_cpus();
85183 - atomic_long_inc(&rsp->expedited_tryfail);
85184 + atomic_long_inc_unchecked(&rsp->expedited_tryfail);
85185
85186 /* Check to see if someone else did our work for us. */
85187 s = atomic_long_read(&rsp->expedited_done);
85188 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
85189 /* ensure test happens before caller kfree */
85190 smp_mb__before_atomic_inc(); /* ^^^ */
85191 - atomic_long_inc(&rsp->expedited_workdone1);
85192 + atomic_long_inc_unchecked(&rsp->expedited_workdone1);
85193 return;
85194 }
85195
85196 @@ -2594,7 +2594,7 @@ void synchronize_sched_expedited(void)
85197 udelay(trycount * num_online_cpus());
85198 } else {
85199 wait_rcu_gp(call_rcu_sched);
85200 - atomic_long_inc(&rsp->expedited_normal);
85201 + atomic_long_inc_unchecked(&rsp->expedited_normal);
85202 return;
85203 }
85204
85205 @@ -2603,7 +2603,7 @@ void synchronize_sched_expedited(void)
85206 if (ULONG_CMP_GE((ulong)s, (ulong)firstsnap)) {
85207 /* ensure test happens before caller kfree */
85208 smp_mb__before_atomic_inc(); /* ^^^ */
85209 - atomic_long_inc(&rsp->expedited_workdone2);
85210 + atomic_long_inc_unchecked(&rsp->expedited_workdone2);
85211 return;
85212 }
85213
85214 @@ -2615,10 +2615,10 @@ void synchronize_sched_expedited(void)
85215 * period works for us.
85216 */
85217 get_online_cpus();
85218 - snap = atomic_long_read(&rsp->expedited_start);
85219 + snap = atomic_long_read_unchecked(&rsp->expedited_start);
85220 smp_mb(); /* ensure read is before try_stop_cpus(). */
85221 }
85222 - atomic_long_inc(&rsp->expedited_stoppedcpus);
85223 + atomic_long_inc_unchecked(&rsp->expedited_stoppedcpus);
85224
85225 /*
85226 * Everyone up to our most recent fetch is covered by our grace
85227 @@ -2627,16 +2627,16 @@ void synchronize_sched_expedited(void)
85228 * than we did already did their update.
85229 */
85230 do {
85231 - atomic_long_inc(&rsp->expedited_done_tries);
85232 + atomic_long_inc_unchecked(&rsp->expedited_done_tries);
85233 s = atomic_long_read(&rsp->expedited_done);
85234 if (ULONG_CMP_GE((ulong)s, (ulong)snap)) {
85235 /* ensure test happens before caller kfree */
85236 smp_mb__before_atomic_inc(); /* ^^^ */
85237 - atomic_long_inc(&rsp->expedited_done_lost);
85238 + atomic_long_inc_unchecked(&rsp->expedited_done_lost);
85239 break;
85240 }
85241 } while (atomic_long_cmpxchg(&rsp->expedited_done, s, snap) != s);
85242 - atomic_long_inc(&rsp->expedited_done_exit);
85243 + atomic_long_inc_unchecked(&rsp->expedited_done_exit);
85244
85245 put_online_cpus();
85246 }
85247 @@ -2829,7 +2829,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
85248 * ACCESS_ONCE() to prevent the compiler from speculating
85249 * the increment to precede the early-exit check.
85250 */
85251 - ACCESS_ONCE(rsp->n_barrier_done)++;
85252 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
85253 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 1);
85254 _rcu_barrier_trace(rsp, "Inc1", -1, rsp->n_barrier_done);
85255 smp_mb(); /* Order ->n_barrier_done increment with below mechanism. */
85256 @@ -2879,7 +2879,7 @@ static void _rcu_barrier(struct rcu_state *rsp)
85257
85258 /* Increment ->n_barrier_done to prevent duplicate work. */
85259 smp_mb(); /* Keep increment after above mechanism. */
85260 - ACCESS_ONCE(rsp->n_barrier_done)++;
85261 + ACCESS_ONCE_RW(rsp->n_barrier_done)++;
85262 WARN_ON_ONCE((rsp->n_barrier_done & 0x1) != 0);
85263 _rcu_barrier_trace(rsp, "Inc2", -1, rsp->n_barrier_done);
85264 smp_mb(); /* Keep increment before caller's subsequent code. */
85265 @@ -2924,10 +2924,10 @@ rcu_boot_init_percpu_data(int cpu, struct rcu_state *rsp)
85266 rdp->grpmask = 1UL << (cpu - rdp->mynode->grplo);
85267 init_callback_list(rdp);
85268 rdp->qlen_lazy = 0;
85269 - ACCESS_ONCE(rdp->qlen) = 0;
85270 + ACCESS_ONCE_RW(rdp->qlen) = 0;
85271 rdp->dynticks = &per_cpu(rcu_dynticks, cpu);
85272 WARN_ON_ONCE(rdp->dynticks->dynticks_nesting != DYNTICK_TASK_EXIT_IDLE);
85273 - WARN_ON_ONCE(atomic_read(&rdp->dynticks->dynticks) != 1);
85274 + WARN_ON_ONCE(atomic_read_unchecked(&rdp->dynticks->dynticks) != 1);
85275 rdp->cpu = cpu;
85276 rdp->rsp = rsp;
85277 rcu_boot_init_nocb_percpu_data(rdp);
85278 @@ -2961,8 +2961,8 @@ rcu_init_percpu_data(int cpu, struct rcu_state *rsp, int preemptible)
85279 init_callback_list(rdp); /* Re-enable callbacks on this CPU. */
85280 rdp->dynticks->dynticks_nesting = DYNTICK_TASK_EXIT_IDLE;
85281 rcu_sysidle_init_percpu_data(rdp->dynticks);
85282 - atomic_set(&rdp->dynticks->dynticks,
85283 - (atomic_read(&rdp->dynticks->dynticks) & ~0x1) + 1);
85284 + atomic_set_unchecked(&rdp->dynticks->dynticks,
85285 + (atomic_read_unchecked(&rdp->dynticks->dynticks) & ~0x1) + 1);
85286 raw_spin_unlock(&rnp->lock); /* irqs remain disabled. */
85287
85288 /* Add CPU to rcu_node bitmasks. */
85289 diff --git a/kernel/rcutree.h b/kernel/rcutree.h
85290 index 5f97eab..db8f687 100644
85291 --- a/kernel/rcutree.h
85292 +++ b/kernel/rcutree.h
85293 @@ -87,11 +87,11 @@ struct rcu_dynticks {
85294 long long dynticks_nesting; /* Track irq/process nesting level. */
85295 /* Process level is worth LLONG_MAX/2. */
85296 int dynticks_nmi_nesting; /* Track NMI nesting level. */
85297 - atomic_t dynticks; /* Even value for idle, else odd. */
85298 + atomic_unchecked_t dynticks;/* Even value for idle, else odd. */
85299 #ifdef CONFIG_NO_HZ_FULL_SYSIDLE
85300 long long dynticks_idle_nesting;
85301 /* irq/process nesting level from idle. */
85302 - atomic_t dynticks_idle; /* Even value for idle, else odd. */
85303 + atomic_unchecked_t dynticks_idle; /* Even value for idle, else odd. */
85304 /* "Idle" excludes userspace execution. */
85305 unsigned long dynticks_idle_jiffies;
85306 /* End of last non-NMI non-idle period. */
85307 @@ -427,17 +427,17 @@ struct rcu_state {
85308 /* _rcu_barrier(). */
85309 /* End of fields guarded by barrier_mutex. */
85310
85311 - atomic_long_t expedited_start; /* Starting ticket. */
85312 - atomic_long_t expedited_done; /* Done ticket. */
85313 - atomic_long_t expedited_wrap; /* # near-wrap incidents. */
85314 - atomic_long_t expedited_tryfail; /* # acquisition failures. */
85315 - atomic_long_t expedited_workdone1; /* # done by others #1. */
85316 - atomic_long_t expedited_workdone2; /* # done by others #2. */
85317 - atomic_long_t expedited_normal; /* # fallbacks to normal. */
85318 - atomic_long_t expedited_stoppedcpus; /* # successful stop_cpus. */
85319 - atomic_long_t expedited_done_tries; /* # tries to update _done. */
85320 - atomic_long_t expedited_done_lost; /* # times beaten to _done. */
85321 - atomic_long_t expedited_done_exit; /* # times exited _done loop. */
85322 + atomic_long_unchecked_t expedited_start; /* Starting ticket. */
85323 + atomic_long_t expedited_done; /* Done ticket. */
85324 + atomic_long_unchecked_t expedited_wrap; /* # near-wrap incidents. */
85325 + atomic_long_unchecked_t expedited_tryfail; /* # acquisition failures. */
85326 + atomic_long_unchecked_t expedited_workdone1; /* # done by others #1. */
85327 + atomic_long_unchecked_t expedited_workdone2; /* # done by others #2. */
85328 + atomic_long_unchecked_t expedited_normal; /* # fallbacks to normal. */
85329 + atomic_long_unchecked_t expedited_stoppedcpus; /* # successful stop_cpus. */
85330 + atomic_long_unchecked_t expedited_done_tries; /* # tries to update _done. */
85331 + atomic_long_unchecked_t expedited_done_lost; /* # times beaten to _done. */
85332 + atomic_long_unchecked_t expedited_done_exit; /* # times exited _done loop. */
85333
85334 unsigned long jiffies_force_qs; /* Time at which to invoke */
85335 /* force_quiescent_state(). */
85336 diff --git a/kernel/rcutree_plugin.h b/kernel/rcutree_plugin.h
85337 index 130c97b..bcbe7f7 100644
85338 --- a/kernel/rcutree_plugin.h
85339 +++ b/kernel/rcutree_plugin.h
85340 @@ -744,7 +744,7 @@ static int rcu_preempted_readers_exp(struct rcu_node *rnp)
85341 static int sync_rcu_preempt_exp_done(struct rcu_node *rnp)
85342 {
85343 return !rcu_preempted_readers_exp(rnp) &&
85344 - ACCESS_ONCE(rnp->expmask) == 0;
85345 + ACCESS_ONCE_RW(rnp->expmask) == 0;
85346 }
85347
85348 /*
85349 @@ -900,7 +900,7 @@ void synchronize_rcu_expedited(void)
85350
85351 /* Clean up and exit. */
85352 smp_mb(); /* ensure expedited GP seen before counter increment. */
85353 - ACCESS_ONCE(sync_rcu_preempt_exp_count)++;
85354 + ACCESS_ONCE_RW(sync_rcu_preempt_exp_count)++;
85355 unlock_mb_ret:
85356 mutex_unlock(&sync_rcu_preempt_exp_mutex);
85357 mb_ret:
85358 @@ -1474,7 +1474,7 @@ static void rcu_boost_kthread_setaffinity(struct rcu_node *rnp, int outgoingcpu)
85359 free_cpumask_var(cm);
85360 }
85361
85362 -static struct smp_hotplug_thread rcu_cpu_thread_spec = {
85363 +static struct smp_hotplug_thread rcu_cpu_thread_spec __read_only = {
85364 .store = &rcu_cpu_kthread_task,
85365 .thread_should_run = rcu_cpu_kthread_should_run,
85366 .thread_fn = rcu_cpu_kthread,
85367 @@ -1939,7 +1939,7 @@ static void print_cpu_stall_info(struct rcu_state *rsp, int cpu)
85368 print_cpu_stall_fast_no_hz(fast_no_hz, cpu);
85369 pr_err("\t%d: (%lu %s) idle=%03x/%llx/%d softirq=%u/%u %s\n",
85370 cpu, ticks_value, ticks_title,
85371 - atomic_read(&rdtp->dynticks) & 0xfff,
85372 + atomic_read_unchecked(&rdtp->dynticks) & 0xfff,
85373 rdtp->dynticks_nesting, rdtp->dynticks_nmi_nesting,
85374 rdp->softirq_snap, kstat_softirqs_cpu(RCU_SOFTIRQ, cpu),
85375 fast_no_hz);
85376 @@ -2102,7 +2102,7 @@ static void __call_rcu_nocb_enqueue(struct rcu_data *rdp,
85377
85378 /* Enqueue the callback on the nocb list and update counts. */
85379 old_rhpp = xchg(&rdp->nocb_tail, rhtp);
85380 - ACCESS_ONCE(*old_rhpp) = rhp;
85381 + ACCESS_ONCE_RW(*old_rhpp) = rhp;
85382 atomic_long_add(rhcount, &rdp->nocb_q_count);
85383 atomic_long_add(rhcount_lazy, &rdp->nocb_q_count_lazy);
85384
85385 @@ -2242,12 +2242,12 @@ static int rcu_nocb_kthread(void *arg)
85386 * Extract queued callbacks, update counts, and wait
85387 * for a grace period to elapse.
85388 */
85389 - ACCESS_ONCE(rdp->nocb_head) = NULL;
85390 + ACCESS_ONCE_RW(rdp->nocb_head) = NULL;
85391 tail = xchg(&rdp->nocb_tail, &rdp->nocb_head);
85392 c = atomic_long_xchg(&rdp->nocb_q_count, 0);
85393 cl = atomic_long_xchg(&rdp->nocb_q_count_lazy, 0);
85394 - ACCESS_ONCE(rdp->nocb_p_count) += c;
85395 - ACCESS_ONCE(rdp->nocb_p_count_lazy) += cl;
85396 + ACCESS_ONCE_RW(rdp->nocb_p_count) += c;
85397 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) += cl;
85398 rcu_nocb_wait_gp(rdp);
85399
85400 /* Each pass through the following loop invokes a callback. */
85401 @@ -2269,8 +2269,8 @@ static int rcu_nocb_kthread(void *arg)
85402 list = next;
85403 }
85404 trace_rcu_batch_end(rdp->rsp->name, c, !!list, 0, 0, 1);
85405 - ACCESS_ONCE(rdp->nocb_p_count) -= c;
85406 - ACCESS_ONCE(rdp->nocb_p_count_lazy) -= cl;
85407 + ACCESS_ONCE_RW(rdp->nocb_p_count) -= c;
85408 + ACCESS_ONCE_RW(rdp->nocb_p_count_lazy) -= cl;
85409 rdp->n_nocbs_invoked += c;
85410 }
85411 return 0;
85412 @@ -2297,7 +2297,7 @@ static void __init rcu_spawn_nocb_kthreads(struct rcu_state *rsp)
85413 t = kthread_run(rcu_nocb_kthread, rdp,
85414 "rcuo%c/%d", rsp->abbr, cpu);
85415 BUG_ON(IS_ERR(t));
85416 - ACCESS_ONCE(rdp->nocb_kthread) = t;
85417 + ACCESS_ONCE_RW(rdp->nocb_kthread) = t;
85418 }
85419 }
85420
85421 @@ -2423,11 +2423,11 @@ static void rcu_sysidle_enter(struct rcu_dynticks *rdtp, int irq)
85422
85423 /* Record start of fully idle period. */
85424 j = jiffies;
85425 - ACCESS_ONCE(rdtp->dynticks_idle_jiffies) = j;
85426 + ACCESS_ONCE_RW(rdtp->dynticks_idle_jiffies) = j;
85427 smp_mb__before_atomic_inc();
85428 - atomic_inc(&rdtp->dynticks_idle);
85429 + atomic_inc_unchecked(&rdtp->dynticks_idle);
85430 smp_mb__after_atomic_inc();
85431 - WARN_ON_ONCE(atomic_read(&rdtp->dynticks_idle) & 0x1);
85432 + WARN_ON_ONCE(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1);
85433 }
85434
85435 /*
85436 @@ -2492,9 +2492,9 @@ static void rcu_sysidle_exit(struct rcu_dynticks *rdtp, int irq)
85437
85438 /* Record end of idle period. */
85439 smp_mb__before_atomic_inc();
85440 - atomic_inc(&rdtp->dynticks_idle);
85441 + atomic_inc_unchecked(&rdtp->dynticks_idle);
85442 smp_mb__after_atomic_inc();
85443 - WARN_ON_ONCE(!(atomic_read(&rdtp->dynticks_idle) & 0x1));
85444 + WARN_ON_ONCE(!(atomic_read_unchecked(&rdtp->dynticks_idle) & 0x1));
85445
85446 /*
85447 * If we are the timekeeping CPU, we are permitted to be non-idle
85448 @@ -2535,7 +2535,7 @@ static void rcu_sysidle_check_cpu(struct rcu_data *rdp, bool *isidle,
85449 WARN_ON_ONCE(smp_processor_id() != tick_do_timer_cpu);
85450
85451 /* Pick up current idle and NMI-nesting counter and check. */
85452 - cur = atomic_read(&rdtp->dynticks_idle);
85453 + cur = atomic_read_unchecked(&rdtp->dynticks_idle);
85454 if (cur & 0x1) {
85455 *isidle = false; /* We are not idle! */
85456 return;
85457 @@ -2598,7 +2598,7 @@ static void rcu_sysidle(unsigned long j)
85458 case RCU_SYSIDLE_NOT:
85459
85460 /* First time all are idle, so note a short idle period. */
85461 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_SHORT;
85462 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_SHORT;
85463 break;
85464
85465 case RCU_SYSIDLE_SHORT:
85466 @@ -2635,7 +2635,7 @@ static void rcu_sysidle(unsigned long j)
85467 static void rcu_sysidle_cancel(void)
85468 {
85469 smp_mb();
85470 - ACCESS_ONCE(full_sysidle_state) = RCU_SYSIDLE_NOT;
85471 + ACCESS_ONCE_RW(full_sysidle_state) = RCU_SYSIDLE_NOT;
85472 }
85473
85474 /*
85475 @@ -2683,7 +2683,7 @@ static void rcu_sysidle_cb(struct rcu_head *rhp)
85476 smp_mb(); /* grace period precedes setting inuse. */
85477
85478 rshp = container_of(rhp, struct rcu_sysidle_head, rh);
85479 - ACCESS_ONCE(rshp->inuse) = 0;
85480 + ACCESS_ONCE_RW(rshp->inuse) = 0;
85481 }
85482
85483 /*
85484 diff --git a/kernel/rcutree_trace.c b/kernel/rcutree_trace.c
85485 index cf6c174..a8f4b50 100644
85486 --- a/kernel/rcutree_trace.c
85487 +++ b/kernel/rcutree_trace.c
85488 @@ -121,7 +121,7 @@ static void print_one_rcu_data(struct seq_file *m, struct rcu_data *rdp)
85489 ulong2long(rdp->completed), ulong2long(rdp->gpnum),
85490 rdp->passed_quiesce, rdp->qs_pending);
85491 seq_printf(m, " dt=%d/%llx/%d df=%lu",
85492 - atomic_read(&rdp->dynticks->dynticks),
85493 + atomic_read_unchecked(&rdp->dynticks->dynticks),
85494 rdp->dynticks->dynticks_nesting,
85495 rdp->dynticks->dynticks_nmi_nesting,
85496 rdp->dynticks_fqs);
85497 @@ -182,17 +182,17 @@ static int show_rcuexp(struct seq_file *m, void *v)
85498 struct rcu_state *rsp = (struct rcu_state *)m->private;
85499
85500 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",
85501 - atomic_long_read(&rsp->expedited_start),
85502 + atomic_long_read_unchecked(&rsp->expedited_start),
85503 atomic_long_read(&rsp->expedited_done),
85504 - atomic_long_read(&rsp->expedited_wrap),
85505 - atomic_long_read(&rsp->expedited_tryfail),
85506 - atomic_long_read(&rsp->expedited_workdone1),
85507 - atomic_long_read(&rsp->expedited_workdone2),
85508 - atomic_long_read(&rsp->expedited_normal),
85509 - atomic_long_read(&rsp->expedited_stoppedcpus),
85510 - atomic_long_read(&rsp->expedited_done_tries),
85511 - atomic_long_read(&rsp->expedited_done_lost),
85512 - atomic_long_read(&rsp->expedited_done_exit));
85513 + atomic_long_read_unchecked(&rsp->expedited_wrap),
85514 + atomic_long_read_unchecked(&rsp->expedited_tryfail),
85515 + atomic_long_read_unchecked(&rsp->expedited_workdone1),
85516 + atomic_long_read_unchecked(&rsp->expedited_workdone2),
85517 + atomic_long_read_unchecked(&rsp->expedited_normal),
85518 + atomic_long_read_unchecked(&rsp->expedited_stoppedcpus),
85519 + atomic_long_read_unchecked(&rsp->expedited_done_tries),
85520 + atomic_long_read_unchecked(&rsp->expedited_done_lost),
85521 + atomic_long_read_unchecked(&rsp->expedited_done_exit));
85522 return 0;
85523 }
85524
85525 diff --git a/kernel/resource.c b/kernel/resource.c
85526 index 3f285dc..5755f62 100644
85527 --- a/kernel/resource.c
85528 +++ b/kernel/resource.c
85529 @@ -152,8 +152,18 @@ static const struct file_operations proc_iomem_operations = {
85530
85531 static int __init ioresources_init(void)
85532 {
85533 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
85534 +#ifdef CONFIG_GRKERNSEC_PROC_USER
85535 + proc_create("ioports", S_IRUSR, NULL, &proc_ioports_operations);
85536 + proc_create("iomem", S_IRUSR, NULL, &proc_iomem_operations);
85537 +#elif defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
85538 + proc_create("ioports", S_IRUSR | S_IRGRP, NULL, &proc_ioports_operations);
85539 + proc_create("iomem", S_IRUSR | S_IRGRP, NULL, &proc_iomem_operations);
85540 +#endif
85541 +#else
85542 proc_create("ioports", 0, NULL, &proc_ioports_operations);
85543 proc_create("iomem", 0, NULL, &proc_iomem_operations);
85544 +#endif
85545 return 0;
85546 }
85547 __initcall(ioresources_init);
85548 diff --git a/kernel/rtmutex-tester.c b/kernel/rtmutex-tester.c
85549 index 1d96dd0..994ff19 100644
85550 --- a/kernel/rtmutex-tester.c
85551 +++ b/kernel/rtmutex-tester.c
85552 @@ -22,7 +22,7 @@
85553 #define MAX_RT_TEST_MUTEXES 8
85554
85555 static spinlock_t rttest_lock;
85556 -static atomic_t rttest_event;
85557 +static atomic_unchecked_t rttest_event;
85558
85559 struct test_thread_data {
85560 int opcode;
85561 @@ -63,7 +63,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85562
85563 case RTTEST_LOCKCONT:
85564 td->mutexes[td->opdata] = 1;
85565 - td->event = atomic_add_return(1, &rttest_event);
85566 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85567 return 0;
85568
85569 case RTTEST_RESET:
85570 @@ -76,7 +76,7 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85571 return 0;
85572
85573 case RTTEST_RESETEVENT:
85574 - atomic_set(&rttest_event, 0);
85575 + atomic_set_unchecked(&rttest_event, 0);
85576 return 0;
85577
85578 default:
85579 @@ -93,9 +93,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85580 return ret;
85581
85582 td->mutexes[id] = 1;
85583 - td->event = atomic_add_return(1, &rttest_event);
85584 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85585 rt_mutex_lock(&mutexes[id]);
85586 - td->event = atomic_add_return(1, &rttest_event);
85587 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85588 td->mutexes[id] = 4;
85589 return 0;
85590
85591 @@ -106,9 +106,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85592 return ret;
85593
85594 td->mutexes[id] = 1;
85595 - td->event = atomic_add_return(1, &rttest_event);
85596 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85597 ret = rt_mutex_lock_interruptible(&mutexes[id], 0);
85598 - td->event = atomic_add_return(1, &rttest_event);
85599 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85600 td->mutexes[id] = ret ? 0 : 4;
85601 return ret ? -EINTR : 0;
85602
85603 @@ -117,9 +117,9 @@ static int handle_op(struct test_thread_data *td, int lockwakeup)
85604 if (id < 0 || id >= MAX_RT_TEST_MUTEXES || td->mutexes[id] != 4)
85605 return ret;
85606
85607 - td->event = atomic_add_return(1, &rttest_event);
85608 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85609 rt_mutex_unlock(&mutexes[id]);
85610 - td->event = atomic_add_return(1, &rttest_event);
85611 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85612 td->mutexes[id] = 0;
85613 return 0;
85614
85615 @@ -166,7 +166,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85616 break;
85617
85618 td->mutexes[dat] = 2;
85619 - td->event = atomic_add_return(1, &rttest_event);
85620 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85621 break;
85622
85623 default:
85624 @@ -186,7 +186,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85625 return;
85626
85627 td->mutexes[dat] = 3;
85628 - td->event = atomic_add_return(1, &rttest_event);
85629 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85630 break;
85631
85632 case RTTEST_LOCKNOWAIT:
85633 @@ -198,7 +198,7 @@ void schedule_rt_mutex_test(struct rt_mutex *mutex)
85634 return;
85635
85636 td->mutexes[dat] = 1;
85637 - td->event = atomic_add_return(1, &rttest_event);
85638 + td->event = atomic_add_return_unchecked(1, &rttest_event);
85639 return;
85640
85641 default:
85642 diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
85643 index 4a07353..66b5291 100644
85644 --- a/kernel/sched/auto_group.c
85645 +++ b/kernel/sched/auto_group.c
85646 @@ -11,7 +11,7 @@
85647
85648 unsigned int __read_mostly sysctl_sched_autogroup_enabled = 1;
85649 static struct autogroup autogroup_default;
85650 -static atomic_t autogroup_seq_nr;
85651 +static atomic_unchecked_t autogroup_seq_nr;
85652
85653 void __init autogroup_init(struct task_struct *init_task)
85654 {
85655 @@ -79,7 +79,7 @@ static inline struct autogroup *autogroup_create(void)
85656
85657 kref_init(&ag->kref);
85658 init_rwsem(&ag->lock);
85659 - ag->id = atomic_inc_return(&autogroup_seq_nr);
85660 + ag->id = atomic_inc_return_unchecked(&autogroup_seq_nr);
85661 ag->tg = tg;
85662 #ifdef CONFIG_RT_GROUP_SCHED
85663 /*
85664 diff --git a/kernel/sched/core.c b/kernel/sched/core.c
85665 index 5ac63c9..d912786 100644
85666 --- a/kernel/sched/core.c
85667 +++ b/kernel/sched/core.c
85668 @@ -2868,7 +2868,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible);
85669 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
85670 * or number of jiffies left till timeout) if completed.
85671 */
85672 -long __sched
85673 +long __sched __intentional_overflow(-1)
85674 wait_for_completion_interruptible_timeout(struct completion *x,
85675 unsigned long timeout)
85676 {
85677 @@ -2885,7 +2885,7 @@ EXPORT_SYMBOL(wait_for_completion_interruptible_timeout);
85678 *
85679 * Return: -ERESTARTSYS if interrupted, 0 if completed.
85680 */
85681 -int __sched wait_for_completion_killable(struct completion *x)
85682 +int __sched __intentional_overflow(-1) wait_for_completion_killable(struct completion *x)
85683 {
85684 long t = wait_for_common(x, MAX_SCHEDULE_TIMEOUT, TASK_KILLABLE);
85685 if (t == -ERESTARTSYS)
85686 @@ -2906,7 +2906,7 @@ EXPORT_SYMBOL(wait_for_completion_killable);
85687 * Return: -ERESTARTSYS if interrupted, 0 if timed out, positive (at least 1,
85688 * or number of jiffies left till timeout) if completed.
85689 */
85690 -long __sched
85691 +long __sched __intentional_overflow(-1)
85692 wait_for_completion_killable_timeout(struct completion *x,
85693 unsigned long timeout)
85694 {
85695 @@ -3132,6 +3132,8 @@ int can_nice(const struct task_struct *p, const int nice)
85696 /* convert nice value [19,-20] to rlimit style value [1,40] */
85697 int nice_rlim = 20 - nice;
85698
85699 + gr_learn_resource(p, RLIMIT_NICE, nice_rlim, 1);
85700 +
85701 return (nice_rlim <= task_rlimit(p, RLIMIT_NICE) ||
85702 capable(CAP_SYS_NICE));
85703 }
85704 @@ -3165,7 +3167,8 @@ SYSCALL_DEFINE1(nice, int, increment)
85705 if (nice > 19)
85706 nice = 19;
85707
85708 - if (increment < 0 && !can_nice(current, nice))
85709 + if (increment < 0 && (!can_nice(current, nice) ||
85710 + gr_handle_chroot_nice()))
85711 return -EPERM;
85712
85713 retval = security_task_setnice(current, nice);
85714 @@ -3327,6 +3330,7 @@ recheck:
85715 unsigned long rlim_rtprio =
85716 task_rlimit(p, RLIMIT_RTPRIO);
85717
85718 + gr_learn_resource(p, RLIMIT_RTPRIO, param->sched_priority, 1);
85719 /* can't set/change the rt policy */
85720 if (policy != p->policy && !rlim_rtprio)
85721 return -EPERM;
85722 @@ -4456,7 +4460,7 @@ static void migrate_tasks(unsigned int dead_cpu)
85723
85724 #if defined(CONFIG_SCHED_DEBUG) && defined(CONFIG_SYSCTL)
85725
85726 -static struct ctl_table sd_ctl_dir[] = {
85727 +static ctl_table_no_const sd_ctl_dir[] __read_only = {
85728 {
85729 .procname = "sched_domain",
85730 .mode = 0555,
85731 @@ -4473,17 +4477,17 @@ static struct ctl_table sd_ctl_root[] = {
85732 {}
85733 };
85734
85735 -static struct ctl_table *sd_alloc_ctl_entry(int n)
85736 +static ctl_table_no_const *sd_alloc_ctl_entry(int n)
85737 {
85738 - struct ctl_table *entry =
85739 + ctl_table_no_const *entry =
85740 kcalloc(n, sizeof(struct ctl_table), GFP_KERNEL);
85741
85742 return entry;
85743 }
85744
85745 -static void sd_free_ctl_entry(struct ctl_table **tablep)
85746 +static void sd_free_ctl_entry(ctl_table_no_const *tablep)
85747 {
85748 - struct ctl_table *entry;
85749 + ctl_table_no_const *entry;
85750
85751 /*
85752 * In the intermediate directories, both the child directory and
85753 @@ -4491,22 +4495,25 @@ static void sd_free_ctl_entry(struct ctl_table **tablep)
85754 * will always be set. In the lowest directory the names are
85755 * static strings and all have proc handlers.
85756 */
85757 - for (entry = *tablep; entry->mode; entry++) {
85758 - if (entry->child)
85759 - sd_free_ctl_entry(&entry->child);
85760 + for (entry = tablep; entry->mode; entry++) {
85761 + if (entry->child) {
85762 + sd_free_ctl_entry(entry->child);
85763 + pax_open_kernel();
85764 + entry->child = NULL;
85765 + pax_close_kernel();
85766 + }
85767 if (entry->proc_handler == NULL)
85768 kfree(entry->procname);
85769 }
85770
85771 - kfree(*tablep);
85772 - *tablep = NULL;
85773 + kfree(tablep);
85774 }
85775
85776 static int min_load_idx = 0;
85777 static int max_load_idx = CPU_LOAD_IDX_MAX-1;
85778
85779 static void
85780 -set_table_entry(struct ctl_table *entry,
85781 +set_table_entry(ctl_table_no_const *entry,
85782 const char *procname, void *data, int maxlen,
85783 umode_t mode, proc_handler *proc_handler,
85784 bool load_idx)
85785 @@ -4526,7 +4533,7 @@ set_table_entry(struct ctl_table *entry,
85786 static struct ctl_table *
85787 sd_alloc_ctl_domain_table(struct sched_domain *sd)
85788 {
85789 - struct ctl_table *table = sd_alloc_ctl_entry(13);
85790 + ctl_table_no_const *table = sd_alloc_ctl_entry(13);
85791
85792 if (table == NULL)
85793 return NULL;
85794 @@ -4561,9 +4568,9 @@ sd_alloc_ctl_domain_table(struct sched_domain *sd)
85795 return table;
85796 }
85797
85798 -static struct ctl_table *sd_alloc_ctl_cpu_table(int cpu)
85799 +static ctl_table_no_const *sd_alloc_ctl_cpu_table(int cpu)
85800 {
85801 - struct ctl_table *entry, *table;
85802 + ctl_table_no_const *entry, *table;
85803 struct sched_domain *sd;
85804 int domain_num = 0, i;
85805 char buf[32];
85806 @@ -4590,11 +4597,13 @@ static struct ctl_table_header *sd_sysctl_header;
85807 static void register_sched_domain_sysctl(void)
85808 {
85809 int i, cpu_num = num_possible_cpus();
85810 - struct ctl_table *entry = sd_alloc_ctl_entry(cpu_num + 1);
85811 + ctl_table_no_const *entry = sd_alloc_ctl_entry(cpu_num + 1);
85812 char buf[32];
85813
85814 WARN_ON(sd_ctl_dir[0].child);
85815 + pax_open_kernel();
85816 sd_ctl_dir[0].child = entry;
85817 + pax_close_kernel();
85818
85819 if (entry == NULL)
85820 return;
85821 @@ -4617,8 +4626,12 @@ static void unregister_sched_domain_sysctl(void)
85822 if (sd_sysctl_header)
85823 unregister_sysctl_table(sd_sysctl_header);
85824 sd_sysctl_header = NULL;
85825 - if (sd_ctl_dir[0].child)
85826 - sd_free_ctl_entry(&sd_ctl_dir[0].child);
85827 + if (sd_ctl_dir[0].child) {
85828 + sd_free_ctl_entry(sd_ctl_dir[0].child);
85829 + pax_open_kernel();
85830 + sd_ctl_dir[0].child = NULL;
85831 + pax_close_kernel();
85832 + }
85833 }
85834 #else
85835 static void register_sched_domain_sysctl(void)
85836 diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
85837 index 7765ad8..774519f 100644
85838 --- a/kernel/sched/fair.c
85839 +++ b/kernel/sched/fair.c
85840 @@ -869,7 +869,7 @@ void task_numa_fault(int node, int pages, bool migrated)
85841
85842 static void reset_ptenuma_scan(struct task_struct *p)
85843 {
85844 - ACCESS_ONCE(p->mm->numa_scan_seq)++;
85845 + ACCESS_ONCE_RW(p->mm->numa_scan_seq)++;
85846 p->mm->numa_scan_offset = 0;
85847 }
85848
85849 @@ -5847,7 +5847,7 @@ static void nohz_idle_balance(int this_cpu, enum cpu_idle_type idle) { }
85850 * run_rebalance_domains is triggered when needed from the scheduler tick.
85851 * Also triggered for nohz idle balancing (with nohz_balancing_kick set).
85852 */
85853 -static void run_rebalance_domains(struct softirq_action *h)
85854 +static __latent_entropy void run_rebalance_domains(void)
85855 {
85856 int this_cpu = smp_processor_id();
85857 struct rq *this_rq = cpu_rq(this_cpu);
85858 diff --git a/kernel/sched/sched.h b/kernel/sched/sched.h
85859 index b3c5653..a4d192a 100644
85860 --- a/kernel/sched/sched.h
85861 +++ b/kernel/sched/sched.h
85862 @@ -1004,7 +1004,7 @@ struct sched_class {
85863 #ifdef CONFIG_FAIR_GROUP_SCHED
85864 void (*task_move_group) (struct task_struct *p, int on_rq);
85865 #endif
85866 -};
85867 +} __do_const;
85868
85869 #define sched_class_highest (&stop_sched_class)
85870 #define for_each_class(class) \
85871 diff --git a/kernel/signal.c b/kernel/signal.c
85872 index ded28b9..6886c08 100644
85873 --- a/kernel/signal.c
85874 +++ b/kernel/signal.c
85875 @@ -51,12 +51,12 @@ static struct kmem_cache *sigqueue_cachep;
85876
85877 int print_fatal_signals __read_mostly;
85878
85879 -static void __user *sig_handler(struct task_struct *t, int sig)
85880 +static __sighandler_t sig_handler(struct task_struct *t, int sig)
85881 {
85882 return t->sighand->action[sig - 1].sa.sa_handler;
85883 }
85884
85885 -static int sig_handler_ignored(void __user *handler, int sig)
85886 +static int sig_handler_ignored(__sighandler_t handler, int sig)
85887 {
85888 /* Is it explicitly or implicitly ignored? */
85889 return handler == SIG_IGN ||
85890 @@ -65,7 +65,7 @@ static int sig_handler_ignored(void __user *handler, int sig)
85891
85892 static int sig_task_ignored(struct task_struct *t, int sig, bool force)
85893 {
85894 - void __user *handler;
85895 + __sighandler_t handler;
85896
85897 handler = sig_handler(t, sig);
85898
85899 @@ -369,6 +369,9 @@ __sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimi
85900 atomic_inc(&user->sigpending);
85901 rcu_read_unlock();
85902
85903 + if (!override_rlimit)
85904 + gr_learn_resource(t, RLIMIT_SIGPENDING, atomic_read(&user->sigpending), 1);
85905 +
85906 if (override_rlimit ||
85907 atomic_read(&user->sigpending) <=
85908 task_rlimit(t, RLIMIT_SIGPENDING)) {
85909 @@ -496,7 +499,7 @@ flush_signal_handlers(struct task_struct *t, int force_default)
85910
85911 int unhandled_signal(struct task_struct *tsk, int sig)
85912 {
85913 - void __user *handler = tsk->sighand->action[sig-1].sa.sa_handler;
85914 + __sighandler_t handler = tsk->sighand->action[sig-1].sa.sa_handler;
85915 if (is_global_init(tsk))
85916 return 1;
85917 if (handler != SIG_IGN && handler != SIG_DFL)
85918 @@ -816,6 +819,13 @@ static int check_kill_permission(int sig, struct siginfo *info,
85919 }
85920 }
85921
85922 + /* allow glibc communication via tgkill to other threads in our
85923 + thread group */
85924 + if ((info == SEND_SIG_NOINFO || info->si_code != SI_TKILL ||
85925 + sig != (SIGRTMIN+1) || task_tgid_vnr(t) != info->si_pid)
85926 + && gr_handle_signal(t, sig))
85927 + return -EPERM;
85928 +
85929 return security_task_kill(t, info, sig, 0);
85930 }
85931
85932 @@ -1199,7 +1209,7 @@ __group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85933 return send_signal(sig, info, p, 1);
85934 }
85935
85936 -static int
85937 +int
85938 specific_send_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85939 {
85940 return send_signal(sig, info, t, 0);
85941 @@ -1236,6 +1246,7 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85942 unsigned long int flags;
85943 int ret, blocked, ignored;
85944 struct k_sigaction *action;
85945 + int is_unhandled = 0;
85946
85947 spin_lock_irqsave(&t->sighand->siglock, flags);
85948 action = &t->sighand->action[sig-1];
85949 @@ -1250,9 +1261,18 @@ force_sig_info(int sig, struct siginfo *info, struct task_struct *t)
85950 }
85951 if (action->sa.sa_handler == SIG_DFL)
85952 t->signal->flags &= ~SIGNAL_UNKILLABLE;
85953 + if (action->sa.sa_handler == SIG_IGN || action->sa.sa_handler == SIG_DFL)
85954 + is_unhandled = 1;
85955 ret = specific_send_sig_info(sig, info, t);
85956 spin_unlock_irqrestore(&t->sighand->siglock, flags);
85957
85958 + /* only deal with unhandled signals, java etc trigger SIGSEGV during
85959 + normal operation */
85960 + if (is_unhandled) {
85961 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, t);
85962 + gr_handle_crash(t, sig);
85963 + }
85964 +
85965 return ret;
85966 }
85967
85968 @@ -1319,8 +1339,11 @@ int group_send_sig_info(int sig, struct siginfo *info, struct task_struct *p)
85969 ret = check_kill_permission(sig, info, p);
85970 rcu_read_unlock();
85971
85972 - if (!ret && sig)
85973 + if (!ret && sig) {
85974 ret = do_send_sig_info(sig, info, p, true);
85975 + if (!ret)
85976 + gr_log_signal(sig, !is_si_special(info) ? info->si_addr : NULL, p);
85977 + }
85978
85979 return ret;
85980 }
85981 @@ -2926,7 +2949,15 @@ do_send_specific(pid_t tgid, pid_t pid, int sig, struct siginfo *info)
85982 int error = -ESRCH;
85983
85984 rcu_read_lock();
85985 - p = find_task_by_vpid(pid);
85986 +#ifdef CONFIG_GRKERNSEC_CHROOT_FINDTASK
85987 + /* allow glibc communication via tgkill to other threads in our
85988 + thread group */
85989 + if (grsec_enable_chroot_findtask && info->si_code == SI_TKILL &&
85990 + sig == (SIGRTMIN+1) && tgid == info->si_pid)
85991 + p = find_task_by_vpid_unrestricted(pid);
85992 + else
85993 +#endif
85994 + p = find_task_by_vpid(pid);
85995 if (p && (tgid <= 0 || task_tgid_vnr(p) == tgid)) {
85996 error = check_kill_permission(sig, info, p);
85997 /*
85998 @@ -3240,8 +3271,8 @@ COMPAT_SYSCALL_DEFINE2(sigaltstack,
85999 }
86000 seg = get_fs();
86001 set_fs(KERNEL_DS);
86002 - ret = do_sigaltstack((stack_t __force __user *) (uss_ptr ? &uss : NULL),
86003 - (stack_t __force __user *) &uoss,
86004 + ret = do_sigaltstack((stack_t __force_user *) (uss_ptr ? &uss : NULL),
86005 + (stack_t __force_user *) &uoss,
86006 compat_user_stack_pointer());
86007 set_fs(seg);
86008 if (ret >= 0 && uoss_ptr) {
86009 diff --git a/kernel/smpboot.c b/kernel/smpboot.c
86010 index eb89e18..a4e6792 100644
86011 --- a/kernel/smpboot.c
86012 +++ b/kernel/smpboot.c
86013 @@ -288,7 +288,7 @@ int smpboot_register_percpu_thread(struct smp_hotplug_thread *plug_thread)
86014 }
86015 smpboot_unpark_thread(plug_thread, cpu);
86016 }
86017 - list_add(&plug_thread->list, &hotplug_threads);
86018 + pax_list_add(&plug_thread->list, &hotplug_threads);
86019 out:
86020 mutex_unlock(&smpboot_threads_lock);
86021 return ret;
86022 @@ -305,7 +305,7 @@ void smpboot_unregister_percpu_thread(struct smp_hotplug_thread *plug_thread)
86023 {
86024 get_online_cpus();
86025 mutex_lock(&smpboot_threads_lock);
86026 - list_del(&plug_thread->list);
86027 + pax_list_del(&plug_thread->list);
86028 smpboot_destroy_threads(plug_thread);
86029 mutex_unlock(&smpboot_threads_lock);
86030 put_online_cpus();
86031 diff --git a/kernel/softirq.c b/kernel/softirq.c
86032 index d7d498d..94fe0f7 100644
86033 --- a/kernel/softirq.c
86034 +++ b/kernel/softirq.c
86035 @@ -53,11 +53,11 @@ irq_cpustat_t irq_stat[NR_CPUS] ____cacheline_aligned;
86036 EXPORT_SYMBOL(irq_stat);
86037 #endif
86038
86039 -static struct softirq_action softirq_vec[NR_SOFTIRQS] __cacheline_aligned_in_smp;
86040 +static struct softirq_action softirq_vec[NR_SOFTIRQS] __read_only __aligned(PAGE_SIZE);
86041
86042 DEFINE_PER_CPU(struct task_struct *, ksoftirqd);
86043
86044 -char *softirq_to_name[NR_SOFTIRQS] = {
86045 +const char * const softirq_to_name[NR_SOFTIRQS] = {
86046 "HI", "TIMER", "NET_TX", "NET_RX", "BLOCK", "BLOCK_IOPOLL",
86047 "TASKLET", "SCHED", "HRTIMER", "RCU"
86048 };
86049 @@ -248,7 +248,7 @@ restart:
86050 kstat_incr_softirqs_this_cpu(vec_nr);
86051
86052 trace_softirq_entry(vec_nr);
86053 - h->action(h);
86054 + h->action();
86055 trace_softirq_exit(vec_nr);
86056 if (unlikely(prev_count != preempt_count())) {
86057 printk(KERN_ERR "huh, entered softirq %u %s %p"
86058 @@ -412,7 +412,7 @@ void __raise_softirq_irqoff(unsigned int nr)
86059 or_softirq_pending(1UL << nr);
86060 }
86061
86062 -void open_softirq(int nr, void (*action)(struct softirq_action *))
86063 +void __init open_softirq(int nr, void (*action)(void))
86064 {
86065 softirq_vec[nr].action = action;
86066 }
86067 @@ -468,7 +468,7 @@ void __tasklet_hi_schedule_first(struct tasklet_struct *t)
86068
86069 EXPORT_SYMBOL(__tasklet_hi_schedule_first);
86070
86071 -static void tasklet_action(struct softirq_action *a)
86072 +static __latent_entropy void tasklet_action(void)
86073 {
86074 struct tasklet_struct *list;
86075
86076 @@ -503,7 +503,7 @@ static void tasklet_action(struct softirq_action *a)
86077 }
86078 }
86079
86080 -static void tasklet_hi_action(struct softirq_action *a)
86081 +static __latent_entropy void tasklet_hi_action(void)
86082 {
86083 struct tasklet_struct *list;
86084
86085 @@ -858,7 +858,7 @@ static struct notifier_block cpu_nfb = {
86086 .notifier_call = cpu_callback
86087 };
86088
86089 -static struct smp_hotplug_thread softirq_threads = {
86090 +static struct smp_hotplug_thread softirq_threads __read_only = {
86091 .store = &ksoftirqd,
86092 .thread_should_run = ksoftirqd_should_run,
86093 .thread_fn = run_ksoftirqd,
86094 diff --git a/kernel/srcu.c b/kernel/srcu.c
86095 index 01d5ccb..cdcbee6 100644
86096 --- a/kernel/srcu.c
86097 +++ b/kernel/srcu.c
86098 @@ -300,9 +300,9 @@ int __srcu_read_lock(struct srcu_struct *sp)
86099
86100 idx = ACCESS_ONCE(sp->completed) & 0x1;
86101 preempt_disable();
86102 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
86103 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->c[idx]) += 1;
86104 smp_mb(); /* B */ /* Avoid leaking the critical section. */
86105 - ACCESS_ONCE(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
86106 + ACCESS_ONCE_RW(this_cpu_ptr(sp->per_cpu_ref)->seq[idx]) += 1;
86107 preempt_enable();
86108 return idx;
86109 }
86110 diff --git a/kernel/sys.c b/kernel/sys.c
86111 index c18ecca..b3c2dd2 100644
86112 --- a/kernel/sys.c
86113 +++ b/kernel/sys.c
86114 @@ -149,6 +149,12 @@ static int set_one_prio(struct task_struct *p, int niceval, int error)
86115 error = -EACCES;
86116 goto out;
86117 }
86118 +
86119 + if (gr_handle_chroot_setpriority(p, niceval)) {
86120 + error = -EACCES;
86121 + goto out;
86122 + }
86123 +
86124 no_nice = security_task_setnice(p, niceval);
86125 if (no_nice) {
86126 error = no_nice;
86127 @@ -352,6 +358,9 @@ SYSCALL_DEFINE2(setregid, gid_t, rgid, gid_t, egid)
86128 goto error;
86129 }
86130
86131 + if (gr_check_group_change(new->gid, new->egid, INVALID_GID))
86132 + goto error;
86133 +
86134 if (rgid != (gid_t) -1 ||
86135 (egid != (gid_t) -1 && !gid_eq(kegid, old->gid)))
86136 new->sgid = new->egid;
86137 @@ -387,6 +396,10 @@ SYSCALL_DEFINE1(setgid, gid_t, gid)
86138 old = current_cred();
86139
86140 retval = -EPERM;
86141 +
86142 + if (gr_check_group_change(kgid, kgid, kgid))
86143 + goto error;
86144 +
86145 if (ns_capable(old->user_ns, CAP_SETGID))
86146 new->gid = new->egid = new->sgid = new->fsgid = kgid;
86147 else if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->sgid))
86148 @@ -404,7 +417,7 @@ error:
86149 /*
86150 * change the user struct in a credentials set to match the new UID
86151 */
86152 -static int set_user(struct cred *new)
86153 +int set_user(struct cred *new)
86154 {
86155 struct user_struct *new_user;
86156
86157 @@ -484,6 +497,9 @@ SYSCALL_DEFINE2(setreuid, uid_t, ruid, uid_t, euid)
86158 goto error;
86159 }
86160
86161 + if (gr_check_user_change(new->uid, new->euid, INVALID_UID))
86162 + goto error;
86163 +
86164 if (!uid_eq(new->uid, old->uid)) {
86165 retval = set_user(new);
86166 if (retval < 0)
86167 @@ -534,6 +550,12 @@ SYSCALL_DEFINE1(setuid, uid_t, uid)
86168 old = current_cred();
86169
86170 retval = -EPERM;
86171 +
86172 + if (gr_check_crash_uid(kuid))
86173 + goto error;
86174 + if (gr_check_user_change(kuid, kuid, kuid))
86175 + goto error;
86176 +
86177 if (ns_capable(old->user_ns, CAP_SETUID)) {
86178 new->suid = new->uid = kuid;
86179 if (!uid_eq(kuid, old->uid)) {
86180 @@ -603,6 +625,9 @@ SYSCALL_DEFINE3(setresuid, uid_t, ruid, uid_t, euid, uid_t, suid)
86181 goto error;
86182 }
86183
86184 + if (gr_check_user_change(kruid, keuid, INVALID_UID))
86185 + goto error;
86186 +
86187 if (ruid != (uid_t) -1) {
86188 new->uid = kruid;
86189 if (!uid_eq(kruid, old->uid)) {
86190 @@ -685,6 +710,9 @@ SYSCALL_DEFINE3(setresgid, gid_t, rgid, gid_t, egid, gid_t, sgid)
86191 goto error;
86192 }
86193
86194 + if (gr_check_group_change(krgid, kegid, INVALID_GID))
86195 + goto error;
86196 +
86197 if (rgid != (gid_t) -1)
86198 new->gid = krgid;
86199 if (egid != (gid_t) -1)
86200 @@ -746,12 +774,16 @@ SYSCALL_DEFINE1(setfsuid, uid_t, uid)
86201 uid_eq(kuid, old->suid) || uid_eq(kuid, old->fsuid) ||
86202 ns_capable(old->user_ns, CAP_SETUID)) {
86203 if (!uid_eq(kuid, old->fsuid)) {
86204 + if (gr_check_user_change(INVALID_UID, INVALID_UID, kuid))
86205 + goto error;
86206 +
86207 new->fsuid = kuid;
86208 if (security_task_fix_setuid(new, old, LSM_SETID_FS) == 0)
86209 goto change_okay;
86210 }
86211 }
86212
86213 +error:
86214 abort_creds(new);
86215 return old_fsuid;
86216
86217 @@ -784,12 +816,16 @@ SYSCALL_DEFINE1(setfsgid, gid_t, gid)
86218 if (gid_eq(kgid, old->gid) || gid_eq(kgid, old->egid) ||
86219 gid_eq(kgid, old->sgid) || gid_eq(kgid, old->fsgid) ||
86220 ns_capable(old->user_ns, CAP_SETGID)) {
86221 + if (gr_check_group_change(INVALID_GID, INVALID_GID, kgid))
86222 + goto error;
86223 +
86224 if (!gid_eq(kgid, old->fsgid)) {
86225 new->fsgid = kgid;
86226 goto change_okay;
86227 }
86228 }
86229
86230 +error:
86231 abort_creds(new);
86232 return old_fsgid;
86233
86234 @@ -1169,19 +1205,19 @@ SYSCALL_DEFINE1(olduname, struct oldold_utsname __user *, name)
86235 return -EFAULT;
86236
86237 down_read(&uts_sem);
86238 - error = __copy_to_user(&name->sysname, &utsname()->sysname,
86239 + error = __copy_to_user(name->sysname, &utsname()->sysname,
86240 __OLD_UTS_LEN);
86241 error |= __put_user(0, name->sysname + __OLD_UTS_LEN);
86242 - error |= __copy_to_user(&name->nodename, &utsname()->nodename,
86243 + error |= __copy_to_user(name->nodename, &utsname()->nodename,
86244 __OLD_UTS_LEN);
86245 error |= __put_user(0, name->nodename + __OLD_UTS_LEN);
86246 - error |= __copy_to_user(&name->release, &utsname()->release,
86247 + error |= __copy_to_user(name->release, &utsname()->release,
86248 __OLD_UTS_LEN);
86249 error |= __put_user(0, name->release + __OLD_UTS_LEN);
86250 - error |= __copy_to_user(&name->version, &utsname()->version,
86251 + error |= __copy_to_user(name->version, &utsname()->version,
86252 __OLD_UTS_LEN);
86253 error |= __put_user(0, name->version + __OLD_UTS_LEN);
86254 - error |= __copy_to_user(&name->machine, &utsname()->machine,
86255 + error |= __copy_to_user(name->machine, &utsname()->machine,
86256 __OLD_UTS_LEN);
86257 error |= __put_user(0, name->machine + __OLD_UTS_LEN);
86258 up_read(&uts_sem);
86259 @@ -1383,6 +1419,13 @@ int do_prlimit(struct task_struct *tsk, unsigned int resource,
86260 */
86261 new_rlim->rlim_cur = 1;
86262 }
86263 + /* Handle the case where a fork and setuid occur and then RLIMIT_NPROC
86264 + is changed to a lower value. Since tasks can be created by the same
86265 + user in between this limit change and an execve by this task, force
86266 + a recheck only for this task by setting PF_NPROC_EXCEEDED
86267 + */
86268 + if (resource == RLIMIT_NPROC && tsk->real_cred->user != INIT_USER)
86269 + tsk->flags |= PF_NPROC_EXCEEDED;
86270 }
86271 if (!retval) {
86272 if (old_rlim)
86273 diff --git a/kernel/sysctl.c b/kernel/sysctl.c
86274 index b2f06f3..e6354ab 100644
86275 --- a/kernel/sysctl.c
86276 +++ b/kernel/sysctl.c
86277 @@ -93,7 +93,6 @@
86278
86279
86280 #if defined(CONFIG_SYSCTL)
86281 -
86282 /* External variables not in a header file. */
86283 extern int sysctl_overcommit_memory;
86284 extern int sysctl_overcommit_ratio;
86285 @@ -119,17 +118,18 @@ extern int blk_iopoll_enabled;
86286
86287 /* Constants used for minimum and maximum */
86288 #ifdef CONFIG_LOCKUP_DETECTOR
86289 -static int sixty = 60;
86290 +static int sixty __read_only = 60;
86291 #endif
86292
86293 -static int zero;
86294 -static int __maybe_unused one = 1;
86295 -static int __maybe_unused two = 2;
86296 -static int __maybe_unused three = 3;
86297 -static unsigned long one_ul = 1;
86298 -static int one_hundred = 100;
86299 +static int neg_one __read_only = -1;
86300 +static int zero __read_only = 0;
86301 +static int __maybe_unused one __read_only = 1;
86302 +static int __maybe_unused two __read_only = 2;
86303 +static int __maybe_unused three __read_only = 3;
86304 +static unsigned long one_ul __read_only = 1;
86305 +static int one_hundred __read_only = 100;
86306 #ifdef CONFIG_PRINTK
86307 -static int ten_thousand = 10000;
86308 +static int ten_thousand __read_only = 10000;
86309 #endif
86310
86311 /* this is needed for the proc_doulongvec_minmax of vm_dirty_bytes */
86312 @@ -176,10 +176,8 @@ static int proc_taint(struct ctl_table *table, int write,
86313 void __user *buffer, size_t *lenp, loff_t *ppos);
86314 #endif
86315
86316 -#ifdef CONFIG_PRINTK
86317 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86318 void __user *buffer, size_t *lenp, loff_t *ppos);
86319 -#endif
86320
86321 static int proc_dointvec_minmax_coredump(struct ctl_table *table, int write,
86322 void __user *buffer, size_t *lenp, loff_t *ppos);
86323 @@ -210,6 +208,8 @@ static int sysrq_sysctl_handler(ctl_table *table, int write,
86324
86325 #endif
86326
86327 +extern struct ctl_table grsecurity_table[];
86328 +
86329 static struct ctl_table kern_table[];
86330 static struct ctl_table vm_table[];
86331 static struct ctl_table fs_table[];
86332 @@ -224,6 +224,20 @@ extern struct ctl_table epoll_table[];
86333 int sysctl_legacy_va_layout;
86334 #endif
86335
86336 +#ifdef CONFIG_PAX_SOFTMODE
86337 +static ctl_table pax_table[] = {
86338 + {
86339 + .procname = "softmode",
86340 + .data = &pax_softmode,
86341 + .maxlen = sizeof(unsigned int),
86342 + .mode = 0600,
86343 + .proc_handler = &proc_dointvec,
86344 + },
86345 +
86346 + { }
86347 +};
86348 +#endif
86349 +
86350 /* The default sysctl tables: */
86351
86352 static struct ctl_table sysctl_base_table[] = {
86353 @@ -272,6 +286,22 @@ static int max_extfrag_threshold = 1000;
86354 #endif
86355
86356 static struct ctl_table kern_table[] = {
86357 +#if defined(CONFIG_GRKERNSEC_SYSCTL) || defined(CONFIG_GRKERNSEC_ROFS)
86358 + {
86359 + .procname = "grsecurity",
86360 + .mode = 0500,
86361 + .child = grsecurity_table,
86362 + },
86363 +#endif
86364 +
86365 +#ifdef CONFIG_PAX_SOFTMODE
86366 + {
86367 + .procname = "pax",
86368 + .mode = 0500,
86369 + .child = pax_table,
86370 + },
86371 +#endif
86372 +
86373 {
86374 .procname = "sched_child_runs_first",
86375 .data = &sysctl_sched_child_runs_first,
86376 @@ -613,7 +643,7 @@ static struct ctl_table kern_table[] = {
86377 .data = &modprobe_path,
86378 .maxlen = KMOD_PATH_LEN,
86379 .mode = 0644,
86380 - .proc_handler = proc_dostring,
86381 + .proc_handler = proc_dostring_modpriv,
86382 },
86383 {
86384 .procname = "modules_disabled",
86385 @@ -780,16 +810,20 @@ static struct ctl_table kern_table[] = {
86386 .extra1 = &zero,
86387 .extra2 = &one,
86388 },
86389 +#endif
86390 {
86391 .procname = "kptr_restrict",
86392 .data = &kptr_restrict,
86393 .maxlen = sizeof(int),
86394 .mode = 0644,
86395 .proc_handler = proc_dointvec_minmax_sysadmin,
86396 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86397 + .extra1 = &two,
86398 +#else
86399 .extra1 = &zero,
86400 +#endif
86401 .extra2 = &two,
86402 },
86403 -#endif
86404 {
86405 .procname = "ngroups_max",
86406 .data = &ngroups_max,
86407 @@ -1031,10 +1065,17 @@ static struct ctl_table kern_table[] = {
86408 */
86409 {
86410 .procname = "perf_event_paranoid",
86411 - .data = &sysctl_perf_event_paranoid,
86412 - .maxlen = sizeof(sysctl_perf_event_paranoid),
86413 + .data = &sysctl_perf_event_legitimately_concerned,
86414 + .maxlen = sizeof(sysctl_perf_event_legitimately_concerned),
86415 .mode = 0644,
86416 - .proc_handler = proc_dointvec,
86417 + /* go ahead, be a hero */
86418 + .proc_handler = proc_dointvec_minmax_sysadmin,
86419 + .extra1 = &neg_one,
86420 +#ifdef CONFIG_GRKERNSEC_PERF_HARDEN
86421 + .extra2 = &three,
86422 +#else
86423 + .extra2 = &two,
86424 +#endif
86425 },
86426 {
86427 .procname = "perf_event_mlock_kb",
86428 @@ -1297,6 +1338,13 @@ static struct ctl_table vm_table[] = {
86429 .proc_handler = proc_dointvec_minmax,
86430 .extra1 = &zero,
86431 },
86432 + {
86433 + .procname = "heap_stack_gap",
86434 + .data = &sysctl_heap_stack_gap,
86435 + .maxlen = sizeof(sysctl_heap_stack_gap),
86436 + .mode = 0644,
86437 + .proc_handler = proc_doulongvec_minmax,
86438 + },
86439 #else
86440 {
86441 .procname = "nr_trim_pages",
86442 @@ -1761,6 +1809,16 @@ int proc_dostring(struct ctl_table *table, int write,
86443 buffer, lenp, ppos);
86444 }
86445
86446 +int proc_dostring_modpriv(struct ctl_table *table, int write,
86447 + void __user *buffer, size_t *lenp, loff_t *ppos)
86448 +{
86449 + if (write && !capable(CAP_SYS_MODULE))
86450 + return -EPERM;
86451 +
86452 + return _proc_do_string(table->data, table->maxlen, write,
86453 + buffer, lenp, ppos);
86454 +}
86455 +
86456 static size_t proc_skip_spaces(char **buf)
86457 {
86458 size_t ret;
86459 @@ -1866,6 +1924,8 @@ static int proc_put_long(void __user **buf, size_t *size, unsigned long val,
86460 len = strlen(tmp);
86461 if (len > *size)
86462 len = *size;
86463 + if (len > sizeof(tmp))
86464 + len = sizeof(tmp);
86465 if (copy_to_user(*buf, tmp, len))
86466 return -EFAULT;
86467 *size -= len;
86468 @@ -2030,7 +2090,7 @@ int proc_dointvec(struct ctl_table *table, int write,
86469 static int proc_taint(struct ctl_table *table, int write,
86470 void __user *buffer, size_t *lenp, loff_t *ppos)
86471 {
86472 - struct ctl_table t;
86473 + ctl_table_no_const t;
86474 unsigned long tmptaint = get_taint();
86475 int err;
86476
86477 @@ -2058,7 +2118,6 @@ static int proc_taint(struct ctl_table *table, int write,
86478 return err;
86479 }
86480
86481 -#ifdef CONFIG_PRINTK
86482 static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86483 void __user *buffer, size_t *lenp, loff_t *ppos)
86484 {
86485 @@ -2067,7 +2126,6 @@ static int proc_dointvec_minmax_sysadmin(struct ctl_table *table, int write,
86486
86487 return proc_dointvec_minmax(table, write, buffer, lenp, ppos);
86488 }
86489 -#endif
86490
86491 struct do_proc_dointvec_minmax_conv_param {
86492 int *min;
86493 @@ -2214,8 +2272,11 @@ static int __do_proc_doulongvec_minmax(void *data, struct ctl_table *table, int
86494 *i = val;
86495 } else {
86496 val = convdiv * (*i) / convmul;
86497 - if (!first)
86498 + if (!first) {
86499 err = proc_put_char(&buffer, &left, '\t');
86500 + if (err)
86501 + break;
86502 + }
86503 err = proc_put_long(&buffer, &left, val, false);
86504 if (err)
86505 break;
86506 @@ -2611,6 +2672,12 @@ int proc_dostring(struct ctl_table *table, int write,
86507 return -ENOSYS;
86508 }
86509
86510 +int proc_dostring_modpriv(struct ctl_table *table, int write,
86511 + void __user *buffer, size_t *lenp, loff_t *ppos)
86512 +{
86513 + return -ENOSYS;
86514 +}
86515 +
86516 int proc_dointvec(struct ctl_table *table, int write,
86517 void __user *buffer, size_t *lenp, loff_t *ppos)
86518 {
86519 @@ -2667,5 +2734,6 @@ EXPORT_SYMBOL(proc_dointvec_minmax);
86520 EXPORT_SYMBOL(proc_dointvec_userhz_jiffies);
86521 EXPORT_SYMBOL(proc_dointvec_ms_jiffies);
86522 EXPORT_SYMBOL(proc_dostring);
86523 +EXPORT_SYMBOL(proc_dostring_modpriv);
86524 EXPORT_SYMBOL(proc_doulongvec_minmax);
86525 EXPORT_SYMBOL(proc_doulongvec_ms_jiffies_minmax);
86526 diff --git a/kernel/taskstats.c b/kernel/taskstats.c
86527 index 145bb4d..b2aa969 100644
86528 --- a/kernel/taskstats.c
86529 +++ b/kernel/taskstats.c
86530 @@ -28,9 +28,12 @@
86531 #include <linux/fs.h>
86532 #include <linux/file.h>
86533 #include <linux/pid_namespace.h>
86534 +#include <linux/grsecurity.h>
86535 #include <net/genetlink.h>
86536 #include <linux/atomic.h>
86537
86538 +extern int gr_is_taskstats_denied(int pid);
86539 +
86540 /*
86541 * Maximum length of a cpumask that can be specified in
86542 * the TASKSTATS_CMD_ATTR_REGISTER/DEREGISTER_CPUMASK attribute
86543 @@ -570,6 +573,9 @@ err:
86544
86545 static int taskstats_user_cmd(struct sk_buff *skb, struct genl_info *info)
86546 {
86547 + if (gr_is_taskstats_denied(current->pid))
86548 + return -EACCES;
86549 +
86550 if (info->attrs[TASKSTATS_CMD_ATTR_REGISTER_CPUMASK])
86551 return cmd_attr_register_cpumask(info);
86552 else if (info->attrs[TASKSTATS_CMD_ATTR_DEREGISTER_CPUMASK])
86553 diff --git a/kernel/time.c b/kernel/time.c
86554 index 7c7964c..2a0d412 100644
86555 --- a/kernel/time.c
86556 +++ b/kernel/time.c
86557 @@ -172,6 +172,11 @@ int do_sys_settimeofday(const struct timespec *tv, const struct timezone *tz)
86558 return error;
86559
86560 if (tz) {
86561 + /* we log in do_settimeofday called below, so don't log twice
86562 + */
86563 + if (!tv)
86564 + gr_log_timechange();
86565 +
86566 sys_tz = *tz;
86567 update_vsyscall_tz();
86568 if (firsttime) {
86569 diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c
86570 index 88c9c65..7497ebc 100644
86571 --- a/kernel/time/alarmtimer.c
86572 +++ b/kernel/time/alarmtimer.c
86573 @@ -795,7 +795,7 @@ static int __init alarmtimer_init(void)
86574 struct platform_device *pdev;
86575 int error = 0;
86576 int i;
86577 - struct k_clock alarm_clock = {
86578 + static struct k_clock alarm_clock = {
86579 .clock_getres = alarm_clock_getres,
86580 .clock_get = alarm_clock_get,
86581 .timer_create = alarm_timer_create,
86582 diff --git a/kernel/time/timekeeping.c b/kernel/time/timekeeping.c
86583 index 5cf6c70..ac341b0 100644
86584 --- a/kernel/time/timekeeping.c
86585 +++ b/kernel/time/timekeeping.c
86586 @@ -15,6 +15,7 @@
86587 #include <linux/init.h>
86588 #include <linux/mm.h>
86589 #include <linux/sched.h>
86590 +#include <linux/grsecurity.h>
86591 #include <linux/syscore_ops.h>
86592 #include <linux/clocksource.h>
86593 #include <linux/jiffies.h>
86594 @@ -500,6 +501,8 @@ int do_settimeofday(const struct timespec *tv)
86595 if (!timespec_valid_strict(tv))
86596 return -EINVAL;
86597
86598 + gr_log_timechange();
86599 +
86600 raw_spin_lock_irqsave(&timekeeper_lock, flags);
86601 write_seqcount_begin(&timekeeper_seq);
86602
86603 diff --git a/kernel/time/timer_list.c b/kernel/time/timer_list.c
86604 index 61ed862..3b52c65 100644
86605 --- a/kernel/time/timer_list.c
86606 +++ b/kernel/time/timer_list.c
86607 @@ -45,12 +45,16 @@ DECLARE_PER_CPU(struct hrtimer_cpu_base, hrtimer_bases);
86608
86609 static void print_name_offset(struct seq_file *m, void *sym)
86610 {
86611 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86612 + SEQ_printf(m, "<%p>", NULL);
86613 +#else
86614 char symname[KSYM_NAME_LEN];
86615
86616 if (lookup_symbol_name((unsigned long)sym, symname) < 0)
86617 SEQ_printf(m, "<%pK>", sym);
86618 else
86619 SEQ_printf(m, "%s", symname);
86620 +#endif
86621 }
86622
86623 static void
86624 @@ -119,7 +123,11 @@ next_one:
86625 static void
86626 print_base(struct seq_file *m, struct hrtimer_clock_base *base, u64 now)
86627 {
86628 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86629 + SEQ_printf(m, " .base: %p\n", NULL);
86630 +#else
86631 SEQ_printf(m, " .base: %pK\n", base);
86632 +#endif
86633 SEQ_printf(m, " .index: %d\n",
86634 base->index);
86635 SEQ_printf(m, " .resolution: %Lu nsecs\n",
86636 @@ -362,7 +370,11 @@ static int __init init_timer_list_procfs(void)
86637 {
86638 struct proc_dir_entry *pe;
86639
86640 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86641 + pe = proc_create("timer_list", 0400, NULL, &timer_list_fops);
86642 +#else
86643 pe = proc_create("timer_list", 0444, NULL, &timer_list_fops);
86644 +#endif
86645 if (!pe)
86646 return -ENOMEM;
86647 return 0;
86648 diff --git a/kernel/time/timer_stats.c b/kernel/time/timer_stats.c
86649 index 0b537f2..40d6c20 100644
86650 --- a/kernel/time/timer_stats.c
86651 +++ b/kernel/time/timer_stats.c
86652 @@ -116,7 +116,7 @@ static ktime_t time_start, time_stop;
86653 static unsigned long nr_entries;
86654 static struct entry entries[MAX_ENTRIES];
86655
86656 -static atomic_t overflow_count;
86657 +static atomic_unchecked_t overflow_count;
86658
86659 /*
86660 * The entries are in a hash-table, for fast lookup:
86661 @@ -140,7 +140,7 @@ static void reset_entries(void)
86662 nr_entries = 0;
86663 memset(entries, 0, sizeof(entries));
86664 memset(tstat_hash_table, 0, sizeof(tstat_hash_table));
86665 - atomic_set(&overflow_count, 0);
86666 + atomic_set_unchecked(&overflow_count, 0);
86667 }
86668
86669 static struct entry *alloc_entry(void)
86670 @@ -261,7 +261,7 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
86671 if (likely(entry))
86672 entry->count++;
86673 else
86674 - atomic_inc(&overflow_count);
86675 + atomic_inc_unchecked(&overflow_count);
86676
86677 out_unlock:
86678 raw_spin_unlock_irqrestore(lock, flags);
86679 @@ -269,12 +269,16 @@ void timer_stats_update_stats(void *timer, pid_t pid, void *startf,
86680
86681 static void print_name_offset(struct seq_file *m, unsigned long addr)
86682 {
86683 +#ifdef CONFIG_GRKERNSEC_HIDESYM
86684 + seq_printf(m, "<%p>", NULL);
86685 +#else
86686 char symname[KSYM_NAME_LEN];
86687
86688 if (lookup_symbol_name(addr, symname) < 0)
86689 - seq_printf(m, "<%p>", (void *)addr);
86690 + seq_printf(m, "<%pK>", (void *)addr);
86691 else
86692 seq_printf(m, "%s", symname);
86693 +#endif
86694 }
86695
86696 static int tstats_show(struct seq_file *m, void *v)
86697 @@ -300,9 +304,9 @@ static int tstats_show(struct seq_file *m, void *v)
86698
86699 seq_puts(m, "Timer Stats Version: v0.2\n");
86700 seq_printf(m, "Sample period: %ld.%03ld s\n", period.tv_sec, ms);
86701 - if (atomic_read(&overflow_count))
86702 + if (atomic_read_unchecked(&overflow_count))
86703 seq_printf(m, "Overflow: %d entries\n",
86704 - atomic_read(&overflow_count));
86705 + atomic_read_unchecked(&overflow_count));
86706
86707 for (i = 0; i < nr_entries; i++) {
86708 entry = entries + i;
86709 @@ -417,7 +421,11 @@ static int __init init_tstats_procfs(void)
86710 {
86711 struct proc_dir_entry *pe;
86712
86713 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
86714 + pe = proc_create("timer_stats", 0600, NULL, &tstats_fops);
86715 +#else
86716 pe = proc_create("timer_stats", 0644, NULL, &tstats_fops);
86717 +#endif
86718 if (!pe)
86719 return -ENOMEM;
86720 return 0;
86721 diff --git a/kernel/timer.c b/kernel/timer.c
86722 index 4296d13..0164b04 100644
86723 --- a/kernel/timer.c
86724 +++ b/kernel/timer.c
86725 @@ -1366,7 +1366,7 @@ void update_process_times(int user_tick)
86726 /*
86727 * This function runs timers and the timer-tq in bottom half context.
86728 */
86729 -static void run_timer_softirq(struct softirq_action *h)
86730 +static __latent_entropy void run_timer_softirq(void)
86731 {
86732 struct tvec_base *base = __this_cpu_read(tvec_bases);
86733
86734 @@ -1429,7 +1429,7 @@ static void process_timeout(unsigned long __data)
86735 *
86736 * In all cases the return value is guaranteed to be non-negative.
86737 */
86738 -signed long __sched schedule_timeout(signed long timeout)
86739 +signed long __sched __intentional_overflow(-1) schedule_timeout(signed long timeout)
86740 {
86741 struct timer_list timer;
86742 unsigned long expire;
86743 diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c
86744 index b8b8560..75b1a09 100644
86745 --- a/kernel/trace/blktrace.c
86746 +++ b/kernel/trace/blktrace.c
86747 @@ -317,7 +317,7 @@ static ssize_t blk_dropped_read(struct file *filp, char __user *buffer,
86748 struct blk_trace *bt = filp->private_data;
86749 char buf[16];
86750
86751 - snprintf(buf, sizeof(buf), "%u\n", atomic_read(&bt->dropped));
86752 + snprintf(buf, sizeof(buf), "%u\n", atomic_read_unchecked(&bt->dropped));
86753
86754 return simple_read_from_buffer(buffer, count, ppos, buf, strlen(buf));
86755 }
86756 @@ -375,7 +375,7 @@ static int blk_subbuf_start_callback(struct rchan_buf *buf, void *subbuf,
86757 return 1;
86758
86759 bt = buf->chan->private_data;
86760 - atomic_inc(&bt->dropped);
86761 + atomic_inc_unchecked(&bt->dropped);
86762 return 0;
86763 }
86764
86765 @@ -476,7 +476,7 @@ int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev,
86766
86767 bt->dir = dir;
86768 bt->dev = dev;
86769 - atomic_set(&bt->dropped, 0);
86770 + atomic_set_unchecked(&bt->dropped, 0);
86771
86772 ret = -EIO;
86773 bt->dropped_file = debugfs_create_file("dropped", 0444, dir, bt,
86774 diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
86775 index 1345d9f..db46efe 100644
86776 --- a/kernel/trace/ftrace.c
86777 +++ b/kernel/trace/ftrace.c
86778 @@ -1944,12 +1944,17 @@ ftrace_code_disable(struct module *mod, struct dyn_ftrace *rec)
86779 if (unlikely(ftrace_disabled))
86780 return 0;
86781
86782 + ret = ftrace_arch_code_modify_prepare();
86783 + FTRACE_WARN_ON(ret);
86784 + if (ret)
86785 + return 0;
86786 +
86787 ret = ftrace_make_nop(mod, rec, MCOUNT_ADDR);
86788 + FTRACE_WARN_ON(ftrace_arch_code_modify_post_process());
86789 if (ret) {
86790 ftrace_bug(ret, ip);
86791 - return 0;
86792 }
86793 - return 1;
86794 + return ret ? 0 : 1;
86795 }
86796
86797 /*
86798 @@ -4043,8 +4048,10 @@ static int ftrace_process_locs(struct module *mod,
86799 if (!count)
86800 return 0;
86801
86802 + pax_open_kernel();
86803 sort(start, count, sizeof(*start),
86804 ftrace_cmp_ips, ftrace_swap_ips);
86805 + pax_close_kernel();
86806
86807 start_pg = ftrace_allocate_pages(count);
86808 if (!start_pg)
86809 @@ -4766,8 +4773,6 @@ ftrace_enable_sysctl(struct ctl_table *table, int write,
86810 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
86811
86812 static int ftrace_graph_active;
86813 -static struct notifier_block ftrace_suspend_notifier;
86814 -
86815 int ftrace_graph_entry_stub(struct ftrace_graph_ent *trace)
86816 {
86817 return 0;
86818 @@ -4918,6 +4923,10 @@ static struct ftrace_ops fgraph_ops __read_mostly = {
86819 FTRACE_OPS_FL_RECURSION_SAFE,
86820 };
86821
86822 +static struct notifier_block ftrace_suspend_notifier = {
86823 + .notifier_call = ftrace_suspend_notifier_call
86824 +};
86825 +
86826 int register_ftrace_graph(trace_func_graph_ret_t retfunc,
86827 trace_func_graph_ent_t entryfunc)
86828 {
86829 @@ -4931,7 +4940,6 @@ int register_ftrace_graph(trace_func_graph_ret_t retfunc,
86830 goto out;
86831 }
86832
86833 - ftrace_suspend_notifier.notifier_call = ftrace_suspend_notifier_call;
86834 register_pm_notifier(&ftrace_suspend_notifier);
86835
86836 ftrace_graph_active++;
86837 diff --git a/kernel/trace/ring_buffer.c b/kernel/trace/ring_buffer.c
86838 index cc2f66f..05edd54 100644
86839 --- a/kernel/trace/ring_buffer.c
86840 +++ b/kernel/trace/ring_buffer.c
86841 @@ -352,9 +352,9 @@ struct buffer_data_page {
86842 */
86843 struct buffer_page {
86844 struct list_head list; /* list of buffer pages */
86845 - local_t write; /* index for next write */
86846 + local_unchecked_t write; /* index for next write */
86847 unsigned read; /* index for next read */
86848 - local_t entries; /* entries on this page */
86849 + local_unchecked_t entries; /* entries on this page */
86850 unsigned long real_end; /* real end of data */
86851 struct buffer_data_page *page; /* Actual data page */
86852 };
86853 @@ -473,8 +473,8 @@ struct ring_buffer_per_cpu {
86854 unsigned long last_overrun;
86855 local_t entries_bytes;
86856 local_t entries;
86857 - local_t overrun;
86858 - local_t commit_overrun;
86859 + local_unchecked_t overrun;
86860 + local_unchecked_t commit_overrun;
86861 local_t dropped_events;
86862 local_t committing;
86863 local_t commits;
86864 @@ -992,8 +992,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86865 *
86866 * We add a counter to the write field to denote this.
86867 */
86868 - old_write = local_add_return(RB_WRITE_INTCNT, &next_page->write);
86869 - old_entries = local_add_return(RB_WRITE_INTCNT, &next_page->entries);
86870 + old_write = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->write);
86871 + old_entries = local_add_return_unchecked(RB_WRITE_INTCNT, &next_page->entries);
86872
86873 /*
86874 * Just make sure we have seen our old_write and synchronize
86875 @@ -1021,8 +1021,8 @@ static int rb_tail_page_update(struct ring_buffer_per_cpu *cpu_buffer,
86876 * cmpxchg to only update if an interrupt did not already
86877 * do it for us. If the cmpxchg fails, we don't care.
86878 */
86879 - (void)local_cmpxchg(&next_page->write, old_write, val);
86880 - (void)local_cmpxchg(&next_page->entries, old_entries, eval);
86881 + (void)local_cmpxchg_unchecked(&next_page->write, old_write, val);
86882 + (void)local_cmpxchg_unchecked(&next_page->entries, old_entries, eval);
86883
86884 /*
86885 * No need to worry about races with clearing out the commit.
86886 @@ -1386,12 +1386,12 @@ static void rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer);
86887
86888 static inline unsigned long rb_page_entries(struct buffer_page *bpage)
86889 {
86890 - return local_read(&bpage->entries) & RB_WRITE_MASK;
86891 + return local_read_unchecked(&bpage->entries) & RB_WRITE_MASK;
86892 }
86893
86894 static inline unsigned long rb_page_write(struct buffer_page *bpage)
86895 {
86896 - return local_read(&bpage->write) & RB_WRITE_MASK;
86897 + return local_read_unchecked(&bpage->write) & RB_WRITE_MASK;
86898 }
86899
86900 static int
86901 @@ -1486,7 +1486,7 @@ rb_remove_pages(struct ring_buffer_per_cpu *cpu_buffer, unsigned int nr_pages)
86902 * bytes consumed in ring buffer from here.
86903 * Increment overrun to account for the lost events.
86904 */
86905 - local_add(page_entries, &cpu_buffer->overrun);
86906 + local_add_unchecked(page_entries, &cpu_buffer->overrun);
86907 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86908 }
86909
86910 @@ -2064,7 +2064,7 @@ rb_handle_head_page(struct ring_buffer_per_cpu *cpu_buffer,
86911 * it is our responsibility to update
86912 * the counters.
86913 */
86914 - local_add(entries, &cpu_buffer->overrun);
86915 + local_add_unchecked(entries, &cpu_buffer->overrun);
86916 local_sub(BUF_PAGE_SIZE, &cpu_buffer->entries_bytes);
86917
86918 /*
86919 @@ -2214,7 +2214,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86920 if (tail == BUF_PAGE_SIZE)
86921 tail_page->real_end = 0;
86922
86923 - local_sub(length, &tail_page->write);
86924 + local_sub_unchecked(length, &tail_page->write);
86925 return;
86926 }
86927
86928 @@ -2249,7 +2249,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86929 rb_event_set_padding(event);
86930
86931 /* Set the write back to the previous setting */
86932 - local_sub(length, &tail_page->write);
86933 + local_sub_unchecked(length, &tail_page->write);
86934 return;
86935 }
86936
86937 @@ -2261,7 +2261,7 @@ rb_reset_tail(struct ring_buffer_per_cpu *cpu_buffer,
86938
86939 /* Set write to end of buffer */
86940 length = (tail + length) - BUF_PAGE_SIZE;
86941 - local_sub(length, &tail_page->write);
86942 + local_sub_unchecked(length, &tail_page->write);
86943 }
86944
86945 /*
86946 @@ -2287,7 +2287,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86947 * about it.
86948 */
86949 if (unlikely(next_page == commit_page)) {
86950 - local_inc(&cpu_buffer->commit_overrun);
86951 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86952 goto out_reset;
86953 }
86954
86955 @@ -2343,7 +2343,7 @@ rb_move_tail(struct ring_buffer_per_cpu *cpu_buffer,
86956 cpu_buffer->tail_page) &&
86957 (cpu_buffer->commit_page ==
86958 cpu_buffer->reader_page))) {
86959 - local_inc(&cpu_buffer->commit_overrun);
86960 + local_inc_unchecked(&cpu_buffer->commit_overrun);
86961 goto out_reset;
86962 }
86963 }
86964 @@ -2391,7 +2391,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86965 length += RB_LEN_TIME_EXTEND;
86966
86967 tail_page = cpu_buffer->tail_page;
86968 - write = local_add_return(length, &tail_page->write);
86969 + write = local_add_return_unchecked(length, &tail_page->write);
86970
86971 /* set write to only the index of the write */
86972 write &= RB_WRITE_MASK;
86973 @@ -2408,7 +2408,7 @@ __rb_reserve_next(struct ring_buffer_per_cpu *cpu_buffer,
86974 kmemcheck_annotate_bitfield(event, bitfield);
86975 rb_update_event(cpu_buffer, event, length, add_timestamp, delta);
86976
86977 - local_inc(&tail_page->entries);
86978 + local_inc_unchecked(&tail_page->entries);
86979
86980 /*
86981 * If this is the first commit on the page, then update
86982 @@ -2441,7 +2441,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86983
86984 if (bpage->page == (void *)addr && rb_page_write(bpage) == old_index) {
86985 unsigned long write_mask =
86986 - local_read(&bpage->write) & ~RB_WRITE_MASK;
86987 + local_read_unchecked(&bpage->write) & ~RB_WRITE_MASK;
86988 unsigned long event_length = rb_event_length(event);
86989 /*
86990 * This is on the tail page. It is possible that
86991 @@ -2451,7 +2451,7 @@ rb_try_to_discard(struct ring_buffer_per_cpu *cpu_buffer,
86992 */
86993 old_index += write_mask;
86994 new_index += write_mask;
86995 - index = local_cmpxchg(&bpage->write, old_index, new_index);
86996 + index = local_cmpxchg_unchecked(&bpage->write, old_index, new_index);
86997 if (index == old_index) {
86998 /* update counters */
86999 local_sub(event_length, &cpu_buffer->entries_bytes);
87000 @@ -2843,7 +2843,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
87001
87002 /* Do the likely case first */
87003 if (likely(bpage->page == (void *)addr)) {
87004 - local_dec(&bpage->entries);
87005 + local_dec_unchecked(&bpage->entries);
87006 return;
87007 }
87008
87009 @@ -2855,7 +2855,7 @@ rb_decrement_entry(struct ring_buffer_per_cpu *cpu_buffer,
87010 start = bpage;
87011 do {
87012 if (bpage->page == (void *)addr) {
87013 - local_dec(&bpage->entries);
87014 + local_dec_unchecked(&bpage->entries);
87015 return;
87016 }
87017 rb_inc_page(cpu_buffer, &bpage);
87018 @@ -3139,7 +3139,7 @@ static inline unsigned long
87019 rb_num_of_entries(struct ring_buffer_per_cpu *cpu_buffer)
87020 {
87021 return local_read(&cpu_buffer->entries) -
87022 - (local_read(&cpu_buffer->overrun) + cpu_buffer->read);
87023 + (local_read_unchecked(&cpu_buffer->overrun) + cpu_buffer->read);
87024 }
87025
87026 /**
87027 @@ -3228,7 +3228,7 @@ unsigned long ring_buffer_overrun_cpu(struct ring_buffer *buffer, int cpu)
87028 return 0;
87029
87030 cpu_buffer = buffer->buffers[cpu];
87031 - ret = local_read(&cpu_buffer->overrun);
87032 + ret = local_read_unchecked(&cpu_buffer->overrun);
87033
87034 return ret;
87035 }
87036 @@ -3251,7 +3251,7 @@ ring_buffer_commit_overrun_cpu(struct ring_buffer *buffer, int cpu)
87037 return 0;
87038
87039 cpu_buffer = buffer->buffers[cpu];
87040 - ret = local_read(&cpu_buffer->commit_overrun);
87041 + ret = local_read_unchecked(&cpu_buffer->commit_overrun);
87042
87043 return ret;
87044 }
87045 @@ -3336,7 +3336,7 @@ unsigned long ring_buffer_overruns(struct ring_buffer *buffer)
87046 /* if you care about this being correct, lock the buffer */
87047 for_each_buffer_cpu(buffer, cpu) {
87048 cpu_buffer = buffer->buffers[cpu];
87049 - overruns += local_read(&cpu_buffer->overrun);
87050 + overruns += local_read_unchecked(&cpu_buffer->overrun);
87051 }
87052
87053 return overruns;
87054 @@ -3512,8 +3512,8 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
87055 /*
87056 * Reset the reader page to size zero.
87057 */
87058 - local_set(&cpu_buffer->reader_page->write, 0);
87059 - local_set(&cpu_buffer->reader_page->entries, 0);
87060 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
87061 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
87062 local_set(&cpu_buffer->reader_page->page->commit, 0);
87063 cpu_buffer->reader_page->real_end = 0;
87064
87065 @@ -3547,7 +3547,7 @@ rb_get_reader_page(struct ring_buffer_per_cpu *cpu_buffer)
87066 * want to compare with the last_overrun.
87067 */
87068 smp_mb();
87069 - overwrite = local_read(&(cpu_buffer->overrun));
87070 + overwrite = local_read_unchecked(&(cpu_buffer->overrun));
87071
87072 /*
87073 * Here's the tricky part.
87074 @@ -4117,8 +4117,8 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
87075
87076 cpu_buffer->head_page
87077 = list_entry(cpu_buffer->pages, struct buffer_page, list);
87078 - local_set(&cpu_buffer->head_page->write, 0);
87079 - local_set(&cpu_buffer->head_page->entries, 0);
87080 + local_set_unchecked(&cpu_buffer->head_page->write, 0);
87081 + local_set_unchecked(&cpu_buffer->head_page->entries, 0);
87082 local_set(&cpu_buffer->head_page->page->commit, 0);
87083
87084 cpu_buffer->head_page->read = 0;
87085 @@ -4128,14 +4128,14 @@ rb_reset_cpu(struct ring_buffer_per_cpu *cpu_buffer)
87086
87087 INIT_LIST_HEAD(&cpu_buffer->reader_page->list);
87088 INIT_LIST_HEAD(&cpu_buffer->new_pages);
87089 - local_set(&cpu_buffer->reader_page->write, 0);
87090 - local_set(&cpu_buffer->reader_page->entries, 0);
87091 + local_set_unchecked(&cpu_buffer->reader_page->write, 0);
87092 + local_set_unchecked(&cpu_buffer->reader_page->entries, 0);
87093 local_set(&cpu_buffer->reader_page->page->commit, 0);
87094 cpu_buffer->reader_page->read = 0;
87095
87096 local_set(&cpu_buffer->entries_bytes, 0);
87097 - local_set(&cpu_buffer->overrun, 0);
87098 - local_set(&cpu_buffer->commit_overrun, 0);
87099 + local_set_unchecked(&cpu_buffer->overrun, 0);
87100 + local_set_unchecked(&cpu_buffer->commit_overrun, 0);
87101 local_set(&cpu_buffer->dropped_events, 0);
87102 local_set(&cpu_buffer->entries, 0);
87103 local_set(&cpu_buffer->committing, 0);
87104 @@ -4540,8 +4540,8 @@ int ring_buffer_read_page(struct ring_buffer *buffer,
87105 rb_init_page(bpage);
87106 bpage = reader->page;
87107 reader->page = *data_page;
87108 - local_set(&reader->write, 0);
87109 - local_set(&reader->entries, 0);
87110 + local_set_unchecked(&reader->write, 0);
87111 + local_set_unchecked(&reader->entries, 0);
87112 reader->read = 0;
87113 *data_page = bpage;
87114
87115 diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
87116 index b778e96..4e84621 100644
87117 --- a/kernel/trace/trace.c
87118 +++ b/kernel/trace/trace.c
87119 @@ -3335,7 +3335,7 @@ int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set)
87120 return 0;
87121 }
87122
87123 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled)
87124 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled)
87125 {
87126 /* do nothing if flag is already set */
87127 if (!!(trace_flags & mask) == !!enabled)
87128 diff --git a/kernel/trace/trace.h b/kernel/trace/trace.h
87129 index 10c86fb..645ab0a 100644
87130 --- a/kernel/trace/trace.h
87131 +++ b/kernel/trace/trace.h
87132 @@ -1029,7 +1029,7 @@ extern const char *__stop___tracepoint_str[];
87133 void trace_printk_init_buffers(void);
87134 void trace_printk_start_comm(void);
87135 int trace_keep_overwrite(struct tracer *tracer, u32 mask, int set);
87136 -int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled);
87137 +int set_tracer_flag(struct trace_array *tr, unsigned long mask, int enabled);
87138
87139 /*
87140 * Normal trace_printk() and friends allocates special buffers
87141 diff --git a/kernel/trace/trace_clock.c b/kernel/trace/trace_clock.c
87142 index 26dc348..8708ca7 100644
87143 --- a/kernel/trace/trace_clock.c
87144 +++ b/kernel/trace/trace_clock.c
87145 @@ -123,7 +123,7 @@ u64 notrace trace_clock_global(void)
87146 return now;
87147 }
87148
87149 -static atomic64_t trace_counter;
87150 +static atomic64_unchecked_t trace_counter;
87151
87152 /*
87153 * trace_clock_counter(): simply an atomic counter.
87154 @@ -132,5 +132,5 @@ static atomic64_t trace_counter;
87155 */
87156 u64 notrace trace_clock_counter(void)
87157 {
87158 - return atomic64_add_return(1, &trace_counter);
87159 + return atomic64_inc_return_unchecked(&trace_counter);
87160 }
87161 diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
87162 index 368a4d5..7b6d1d5 100644
87163 --- a/kernel/trace/trace_events.c
87164 +++ b/kernel/trace/trace_events.c
87165 @@ -1673,7 +1673,6 @@ __trace_early_add_new_event(struct ftrace_event_call *call,
87166 return 0;
87167 }
87168
87169 -struct ftrace_module_file_ops;
87170 static void __add_event_to_tracers(struct ftrace_event_call *call);
87171
87172 /* Add an additional event_call dynamically */
87173 diff --git a/kernel/trace/trace_mmiotrace.c b/kernel/trace/trace_mmiotrace.c
87174 index b3dcfb2..ebee344 100644
87175 --- a/kernel/trace/trace_mmiotrace.c
87176 +++ b/kernel/trace/trace_mmiotrace.c
87177 @@ -24,7 +24,7 @@ struct header_iter {
87178 static struct trace_array *mmio_trace_array;
87179 static bool overrun_detected;
87180 static unsigned long prev_overruns;
87181 -static atomic_t dropped_count;
87182 +static atomic_unchecked_t dropped_count;
87183
87184 static void mmio_reset_data(struct trace_array *tr)
87185 {
87186 @@ -127,7 +127,7 @@ static void mmio_close(struct trace_iterator *iter)
87187
87188 static unsigned long count_overruns(struct trace_iterator *iter)
87189 {
87190 - unsigned long cnt = atomic_xchg(&dropped_count, 0);
87191 + unsigned long cnt = atomic_xchg_unchecked(&dropped_count, 0);
87192 unsigned long over = ring_buffer_overruns(iter->trace_buffer->buffer);
87193
87194 if (over > prev_overruns)
87195 @@ -317,7 +317,7 @@ static void __trace_mmiotrace_rw(struct trace_array *tr,
87196 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_RW,
87197 sizeof(*entry), 0, pc);
87198 if (!event) {
87199 - atomic_inc(&dropped_count);
87200 + atomic_inc_unchecked(&dropped_count);
87201 return;
87202 }
87203 entry = ring_buffer_event_data(event);
87204 @@ -347,7 +347,7 @@ static void __trace_mmiotrace_map(struct trace_array *tr,
87205 event = trace_buffer_lock_reserve(buffer, TRACE_MMIO_MAP,
87206 sizeof(*entry), 0, pc);
87207 if (!event) {
87208 - atomic_inc(&dropped_count);
87209 + atomic_inc_unchecked(&dropped_count);
87210 return;
87211 }
87212 entry = ring_buffer_event_data(event);
87213 diff --git a/kernel/trace/trace_output.c b/kernel/trace/trace_output.c
87214 index 34e7cba..6f9a729 100644
87215 --- a/kernel/trace/trace_output.c
87216 +++ b/kernel/trace/trace_output.c
87217 @@ -294,7 +294,7 @@ int trace_seq_path(struct trace_seq *s, const struct path *path)
87218
87219 p = d_path(path, s->buffer + s->len, PAGE_SIZE - s->len);
87220 if (!IS_ERR(p)) {
87221 - p = mangle_path(s->buffer + s->len, p, "\n");
87222 + p = mangle_path(s->buffer + s->len, p, "\n\\");
87223 if (p) {
87224 s->len = p - s->buffer;
87225 return 1;
87226 @@ -893,14 +893,16 @@ int register_ftrace_event(struct trace_event *event)
87227 goto out;
87228 }
87229
87230 + pax_open_kernel();
87231 if (event->funcs->trace == NULL)
87232 - event->funcs->trace = trace_nop_print;
87233 + *(void **)&event->funcs->trace = trace_nop_print;
87234 if (event->funcs->raw == NULL)
87235 - event->funcs->raw = trace_nop_print;
87236 + *(void **)&event->funcs->raw = trace_nop_print;
87237 if (event->funcs->hex == NULL)
87238 - event->funcs->hex = trace_nop_print;
87239 + *(void **)&event->funcs->hex = trace_nop_print;
87240 if (event->funcs->binary == NULL)
87241 - event->funcs->binary = trace_nop_print;
87242 + *(void **)&event->funcs->binary = trace_nop_print;
87243 + pax_close_kernel();
87244
87245 key = event->type & (EVENT_HASHSIZE - 1);
87246
87247 diff --git a/kernel/trace/trace_stack.c b/kernel/trace/trace_stack.c
87248 index b20428c..4845a10 100644
87249 --- a/kernel/trace/trace_stack.c
87250 +++ b/kernel/trace/trace_stack.c
87251 @@ -68,7 +68,7 @@ check_stack(unsigned long ip, unsigned long *stack)
87252 return;
87253
87254 /* we do not handle interrupt stacks yet */
87255 - if (!object_is_on_stack(stack))
87256 + if (!object_starts_on_stack(stack))
87257 return;
87258
87259 local_irq_save(flags);
87260 diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c
87261 index 13fb113..a6ced3f 100644
87262 --- a/kernel/user_namespace.c
87263 +++ b/kernel/user_namespace.c
87264 @@ -82,6 +82,21 @@ int create_user_ns(struct cred *new)
87265 !kgid_has_mapping(parent_ns, group))
87266 return -EPERM;
87267
87268 +#ifdef CONFIG_GRKERNSEC
87269 + /*
87270 + * This doesn't really inspire confidence:
87271 + * http://marc.info/?l=linux-kernel&m=135543612731939&w=2
87272 + * http://marc.info/?l=linux-kernel&m=135545831607095&w=2
87273 + * Increases kernel attack surface in areas developers
87274 + * previously cared little about ("low importance due
87275 + * to requiring "root" capability")
87276 + * To be removed when this code receives *proper* review
87277 + */
87278 + if (!capable(CAP_SYS_ADMIN) || !capable(CAP_SETUID) ||
87279 + !capable(CAP_SETGID))
87280 + return -EPERM;
87281 +#endif
87282 +
87283 ns = kmem_cache_zalloc(user_ns_cachep, GFP_KERNEL);
87284 if (!ns)
87285 return -ENOMEM;
87286 @@ -860,7 +875,7 @@ static int userns_install(struct nsproxy *nsproxy, void *ns)
87287 if (atomic_read(&current->mm->mm_users) > 1)
87288 return -EINVAL;
87289
87290 - if (current->fs->users != 1)
87291 + if (atomic_read(&current->fs->users) != 1)
87292 return -EINVAL;
87293
87294 if (!ns_capable(user_ns, CAP_SYS_ADMIN))
87295 diff --git a/kernel/utsname_sysctl.c b/kernel/utsname_sysctl.c
87296 index 4f69f9a..7c6f8f8 100644
87297 --- a/kernel/utsname_sysctl.c
87298 +++ b/kernel/utsname_sysctl.c
87299 @@ -47,7 +47,7 @@ static void put_uts(ctl_table *table, int write, void *which)
87300 static int proc_do_uts_string(ctl_table *table, int write,
87301 void __user *buffer, size_t *lenp, loff_t *ppos)
87302 {
87303 - struct ctl_table uts_table;
87304 + ctl_table_no_const uts_table;
87305 int r;
87306 memcpy(&uts_table, table, sizeof(uts_table));
87307 uts_table.data = get_uts(table, write);
87308 diff --git a/kernel/watchdog.c b/kernel/watchdog.c
87309 index 4431610..4265616 100644
87310 --- a/kernel/watchdog.c
87311 +++ b/kernel/watchdog.c
87312 @@ -475,7 +475,7 @@ static int watchdog_nmi_enable(unsigned int cpu) { return 0; }
87313 static void watchdog_nmi_disable(unsigned int cpu) { return; }
87314 #endif /* CONFIG_HARDLOCKUP_DETECTOR */
87315
87316 -static struct smp_hotplug_thread watchdog_threads = {
87317 +static struct smp_hotplug_thread watchdog_threads __read_only = {
87318 .store = &softlockup_watchdog,
87319 .thread_should_run = watchdog_should_run,
87320 .thread_fn = watchdog,
87321 diff --git a/kernel/workqueue.c b/kernel/workqueue.c
87322 index 93c2652..66a1cfd 100644
87323 --- a/kernel/workqueue.c
87324 +++ b/kernel/workqueue.c
87325 @@ -4668,7 +4668,7 @@ static void rebind_workers(struct worker_pool *pool)
87326 WARN_ON_ONCE(!(worker_flags & WORKER_UNBOUND));
87327 worker_flags |= WORKER_REBOUND;
87328 worker_flags &= ~WORKER_UNBOUND;
87329 - ACCESS_ONCE(worker->flags) = worker_flags;
87330 + ACCESS_ONCE_RW(worker->flags) = worker_flags;
87331 }
87332
87333 spin_unlock_irq(&pool->lock);
87334 diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug
87335 index 094f315..244a824 100644
87336 --- a/lib/Kconfig.debug
87337 +++ b/lib/Kconfig.debug
87338 @@ -836,7 +836,7 @@ config DEBUG_MUTEXES
87339
87340 config DEBUG_WW_MUTEX_SLOWPATH
87341 bool "Wait/wound mutex debugging: Slowpath testing"
87342 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87343 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87344 select DEBUG_LOCK_ALLOC
87345 select DEBUG_SPINLOCK
87346 select DEBUG_MUTEXES
87347 @@ -849,7 +849,7 @@ config DEBUG_WW_MUTEX_SLOWPATH
87348
87349 config DEBUG_LOCK_ALLOC
87350 bool "Lock debugging: detect incorrect freeing of live locks"
87351 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87352 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87353 select DEBUG_SPINLOCK
87354 select DEBUG_MUTEXES
87355 select LOCKDEP
87356 @@ -863,7 +863,7 @@ config DEBUG_LOCK_ALLOC
87357
87358 config PROVE_LOCKING
87359 bool "Lock debugging: prove locking correctness"
87360 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87361 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87362 select LOCKDEP
87363 select DEBUG_SPINLOCK
87364 select DEBUG_MUTEXES
87365 @@ -914,7 +914,7 @@ config LOCKDEP
87366
87367 config LOCK_STAT
87368 bool "Lock usage statistics"
87369 - depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
87370 + depends on DEBUG_KERNEL && TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT && !PAX_CONSTIFY_PLUGIN
87371 select LOCKDEP
87372 select DEBUG_SPINLOCK
87373 select DEBUG_MUTEXES
87374 @@ -1376,6 +1376,7 @@ config LATENCYTOP
87375 depends on DEBUG_KERNEL
87376 depends on STACKTRACE_SUPPORT
87377 depends on PROC_FS
87378 + depends on !GRKERNSEC_HIDESYM
87379 select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC
87380 select KALLSYMS
87381 select KALLSYMS_ALL
87382 @@ -1392,7 +1393,7 @@ config ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
87383 config DEBUG_STRICT_USER_COPY_CHECKS
87384 bool "Strict user copy size checks"
87385 depends on ARCH_HAS_DEBUG_STRICT_USER_COPY_CHECKS
87386 - depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING
87387 + depends on DEBUG_KERNEL && !TRACE_BRANCH_PROFILING && !PAX_SIZE_OVERFLOW
87388 help
87389 Enabling this option turns a certain set of sanity checks for user
87390 copy operations into compile time failures.
87391 @@ -1502,7 +1503,7 @@ endmenu # runtime tests
87392
87393 config PROVIDE_OHCI1394_DMA_INIT
87394 bool "Remote debugging over FireWire early on boot"
87395 - depends on PCI && X86
87396 + depends on PCI && X86 && !GRKERNSEC
87397 help
87398 If you want to debug problems which hang or crash the kernel early
87399 on boot and the crashing machine has a FireWire port, you can use
87400 @@ -1531,7 +1532,7 @@ config PROVIDE_OHCI1394_DMA_INIT
87401
87402 config FIREWIRE_OHCI_REMOTE_DMA
87403 bool "Remote debugging over FireWire with firewire-ohci"
87404 - depends on FIREWIRE_OHCI
87405 + depends on FIREWIRE_OHCI && !GRKERNSEC
87406 help
87407 This option lets you use the FireWire bus for remote debugging
87408 with help of the firewire-ohci driver. It enables unfiltered
87409 diff --git a/lib/Makefile b/lib/Makefile
87410 index f3bb2cb..b358ace 100644
87411 --- a/lib/Makefile
87412 +++ b/lib/Makefile
87413 @@ -52,7 +52,7 @@ obj-$(CONFIG_GENERIC_HWEIGHT) += hweight.o
87414
87415 obj-$(CONFIG_BTREE) += btree.o
87416 obj-$(CONFIG_DEBUG_PREEMPT) += smp_processor_id.o
87417 -obj-$(CONFIG_DEBUG_LIST) += list_debug.o
87418 +obj-y += list_debug.o
87419 obj-$(CONFIG_DEBUG_OBJECTS) += debugobjects.o
87420
87421 ifneq ($(CONFIG_HAVE_DEC_LOCK),y)
87422 diff --git a/lib/bitmap.c b/lib/bitmap.c
87423 index 06f7e4f..f3cf2b0 100644
87424 --- a/lib/bitmap.c
87425 +++ b/lib/bitmap.c
87426 @@ -422,7 +422,7 @@ int __bitmap_parse(const char *buf, unsigned int buflen,
87427 {
87428 int c, old_c, totaldigits, ndigits, nchunks, nbits;
87429 u32 chunk;
87430 - const char __user __force *ubuf = (const char __user __force *)buf;
87431 + const char __user *ubuf = (const char __force_user *)buf;
87432
87433 bitmap_zero(maskp, nmaskbits);
87434
87435 @@ -507,7 +507,7 @@ int bitmap_parse_user(const char __user *ubuf,
87436 {
87437 if (!access_ok(VERIFY_READ, ubuf, ulen))
87438 return -EFAULT;
87439 - return __bitmap_parse((const char __force *)ubuf,
87440 + return __bitmap_parse((const char __force_kernel *)ubuf,
87441 ulen, 1, maskp, nmaskbits);
87442
87443 }
87444 @@ -598,7 +598,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen,
87445 {
87446 unsigned a, b;
87447 int c, old_c, totaldigits;
87448 - const char __user __force *ubuf = (const char __user __force *)buf;
87449 + const char __user *ubuf = (const char __force_user *)buf;
87450 int exp_digit, in_range;
87451
87452 totaldigits = c = 0;
87453 @@ -698,7 +698,7 @@ int bitmap_parselist_user(const char __user *ubuf,
87454 {
87455 if (!access_ok(VERIFY_READ, ubuf, ulen))
87456 return -EFAULT;
87457 - return __bitmap_parselist((const char __force *)ubuf,
87458 + return __bitmap_parselist((const char __force_kernel *)ubuf,
87459 ulen, 1, maskp, nmaskbits);
87460 }
87461 EXPORT_SYMBOL(bitmap_parselist_user);
87462 diff --git a/lib/bug.c b/lib/bug.c
87463 index 1686034..a9c00c8 100644
87464 --- a/lib/bug.c
87465 +++ b/lib/bug.c
87466 @@ -134,6 +134,8 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs)
87467 return BUG_TRAP_TYPE_NONE;
87468
87469 bug = find_bug(bugaddr);
87470 + if (!bug)
87471 + return BUG_TRAP_TYPE_NONE;
87472
87473 file = NULL;
87474 line = 0;
87475 diff --git a/lib/debugobjects.c b/lib/debugobjects.c
87476 index bf2c8b1..1d00ccf 100644
87477 --- a/lib/debugobjects.c
87478 +++ b/lib/debugobjects.c
87479 @@ -286,7 +286,7 @@ static void debug_object_is_on_stack(void *addr, int onstack)
87480 if (limit > 4)
87481 return;
87482
87483 - is_on_stack = object_is_on_stack(addr);
87484 + is_on_stack = object_starts_on_stack(addr);
87485 if (is_on_stack == onstack)
87486 return;
87487
87488 diff --git a/lib/devres.c b/lib/devres.c
87489 index 8235331..5881053 100644
87490 --- a/lib/devres.c
87491 +++ b/lib/devres.c
87492 @@ -81,7 +81,7 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
87493 void devm_iounmap(struct device *dev, void __iomem *addr)
87494 {
87495 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
87496 - (void *)addr));
87497 + (void __force *)addr));
87498 iounmap(addr);
87499 }
87500 EXPORT_SYMBOL(devm_iounmap);
87501 @@ -224,7 +224,7 @@ void devm_ioport_unmap(struct device *dev, void __iomem *addr)
87502 {
87503 ioport_unmap(addr);
87504 WARN_ON(devres_destroy(dev, devm_ioport_map_release,
87505 - devm_ioport_map_match, (void *)addr));
87506 + devm_ioport_map_match, (void __force *)addr));
87507 }
87508 EXPORT_SYMBOL(devm_ioport_unmap);
87509 #endif /* CONFIG_HAS_IOPORT */
87510 diff --git a/lib/div64.c b/lib/div64.c
87511 index 4382ad7..08aa558 100644
87512 --- a/lib/div64.c
87513 +++ b/lib/div64.c
87514 @@ -59,7 +59,7 @@ uint32_t __attribute__((weak)) __div64_32(uint64_t *n, uint32_t base)
87515 EXPORT_SYMBOL(__div64_32);
87516
87517 #ifndef div_s64_rem
87518 -s64 div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
87519 +s64 __intentional_overflow(-1) div_s64_rem(s64 dividend, s32 divisor, s32 *remainder)
87520 {
87521 u64 quotient;
87522
87523 @@ -130,7 +130,7 @@ EXPORT_SYMBOL(div64_u64_rem);
87524 * 'http://www.hackersdelight.org/HDcode/newCode/divDouble.c.txt'
87525 */
87526 #ifndef div64_u64
87527 -u64 div64_u64(u64 dividend, u64 divisor)
87528 +u64 __intentional_overflow(-1) div64_u64(u64 dividend, u64 divisor)
87529 {
87530 u32 high = divisor >> 32;
87531 u64 quot;
87532 diff --git a/lib/dma-debug.c b/lib/dma-debug.c
87533 index d87a17a..ac0d79a 100644
87534 --- a/lib/dma-debug.c
87535 +++ b/lib/dma-debug.c
87536 @@ -768,7 +768,7 @@ static int dma_debug_device_change(struct notifier_block *nb, unsigned long acti
87537
87538 void dma_debug_add_bus(struct bus_type *bus)
87539 {
87540 - struct notifier_block *nb;
87541 + notifier_block_no_const *nb;
87542
87543 if (global_disable)
87544 return;
87545 @@ -945,7 +945,7 @@ static void check_unmap(struct dma_debug_entry *ref)
87546
87547 static void check_for_stack(struct device *dev, void *addr)
87548 {
87549 - if (object_is_on_stack(addr))
87550 + if (object_starts_on_stack(addr))
87551 err_printk(dev, NULL, "DMA-API: device driver maps memory from"
87552 "stack [addr=%p]\n", addr);
87553 }
87554 diff --git a/lib/inflate.c b/lib/inflate.c
87555 index 013a761..c28f3fc 100644
87556 --- a/lib/inflate.c
87557 +++ b/lib/inflate.c
87558 @@ -269,7 +269,7 @@ static void free(void *where)
87559 malloc_ptr = free_mem_ptr;
87560 }
87561 #else
87562 -#define malloc(a) kmalloc(a, GFP_KERNEL)
87563 +#define malloc(a) kmalloc((a), GFP_KERNEL)
87564 #define free(a) kfree(a)
87565 #endif
87566
87567 diff --git a/lib/ioremap.c b/lib/ioremap.c
87568 index 0c9216c..863bd89 100644
87569 --- a/lib/ioremap.c
87570 +++ b/lib/ioremap.c
87571 @@ -38,7 +38,7 @@ static inline int ioremap_pmd_range(pud_t *pud, unsigned long addr,
87572 unsigned long next;
87573
87574 phys_addr -= addr;
87575 - pmd = pmd_alloc(&init_mm, pud, addr);
87576 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
87577 if (!pmd)
87578 return -ENOMEM;
87579 do {
87580 @@ -56,7 +56,7 @@ static inline int ioremap_pud_range(pgd_t *pgd, unsigned long addr,
87581 unsigned long next;
87582
87583 phys_addr -= addr;
87584 - pud = pud_alloc(&init_mm, pgd, addr);
87585 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
87586 if (!pud)
87587 return -ENOMEM;
87588 do {
87589 diff --git a/lib/is_single_threaded.c b/lib/is_single_threaded.c
87590 index bd2bea9..6b3c95e 100644
87591 --- a/lib/is_single_threaded.c
87592 +++ b/lib/is_single_threaded.c
87593 @@ -22,6 +22,9 @@ bool current_is_single_threaded(void)
87594 struct task_struct *p, *t;
87595 bool ret;
87596
87597 + if (!mm)
87598 + return true;
87599 +
87600 if (atomic_read(&task->signal->live) != 1)
87601 return false;
87602
87603 diff --git a/lib/kobject.c b/lib/kobject.c
87604 index 084f7b1..d265b8a 100644
87605 --- a/lib/kobject.c
87606 +++ b/lib/kobject.c
87607 @@ -875,9 +875,9 @@ EXPORT_SYMBOL_GPL(kset_create_and_add);
87608
87609
87610 static DEFINE_SPINLOCK(kobj_ns_type_lock);
87611 -static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES];
87612 +static const struct kobj_ns_type_operations *kobj_ns_ops_tbl[KOBJ_NS_TYPES] __read_only;
87613
87614 -int kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
87615 +int __init kobj_ns_type_register(const struct kobj_ns_type_operations *ops)
87616 {
87617 enum kobj_ns_type type = ops->type;
87618 int error;
87619 diff --git a/lib/list_debug.c b/lib/list_debug.c
87620 index c24c2f7..f0296f4 100644
87621 --- a/lib/list_debug.c
87622 +++ b/lib/list_debug.c
87623 @@ -11,7 +11,9 @@
87624 #include <linux/bug.h>
87625 #include <linux/kernel.h>
87626 #include <linux/rculist.h>
87627 +#include <linux/mm.h>
87628
87629 +#ifdef CONFIG_DEBUG_LIST
87630 /*
87631 * Insert a new entry between two known consecutive entries.
87632 *
87633 @@ -19,21 +21,40 @@
87634 * the prev/next entries already!
87635 */
87636
87637 +static bool __list_add_debug(struct list_head *new,
87638 + struct list_head *prev,
87639 + struct list_head *next)
87640 +{
87641 + if (unlikely(next->prev != prev)) {
87642 + printk(KERN_ERR "list_add corruption. next->prev should be "
87643 + "prev (%p), but was %p. (next=%p).\n",
87644 + prev, next->prev, next);
87645 + BUG();
87646 + return false;
87647 + }
87648 + if (unlikely(prev->next != next)) {
87649 + printk(KERN_ERR "list_add corruption. prev->next should be "
87650 + "next (%p), but was %p. (prev=%p).\n",
87651 + next, prev->next, prev);
87652 + BUG();
87653 + return false;
87654 + }
87655 + if (unlikely(new == prev || new == next)) {
87656 + printk(KERN_ERR "list_add double add: new=%p, prev=%p, next=%p.\n",
87657 + new, prev, next);
87658 + BUG();
87659 + return false;
87660 + }
87661 + return true;
87662 +}
87663 +
87664 void __list_add(struct list_head *new,
87665 - struct list_head *prev,
87666 - struct list_head *next)
87667 + struct list_head *prev,
87668 + struct list_head *next)
87669 {
87670 - WARN(next->prev != prev,
87671 - "list_add corruption. next->prev should be "
87672 - "prev (%p), but was %p. (next=%p).\n",
87673 - prev, next->prev, next);
87674 - WARN(prev->next != next,
87675 - "list_add corruption. prev->next should be "
87676 - "next (%p), but was %p. (prev=%p).\n",
87677 - next, prev->next, prev);
87678 - WARN(new == prev || new == next,
87679 - "list_add double add: new=%p, prev=%p, next=%p.\n",
87680 - new, prev, next);
87681 + if (!__list_add_debug(new, prev, next))
87682 + return;
87683 +
87684 next->prev = new;
87685 new->next = next;
87686 new->prev = prev;
87687 @@ -41,28 +62,46 @@ void __list_add(struct list_head *new,
87688 }
87689 EXPORT_SYMBOL(__list_add);
87690
87691 -void __list_del_entry(struct list_head *entry)
87692 +static bool __list_del_entry_debug(struct list_head *entry)
87693 {
87694 struct list_head *prev, *next;
87695
87696 prev = entry->prev;
87697 next = entry->next;
87698
87699 - if (WARN(next == LIST_POISON1,
87700 - "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
87701 - entry, LIST_POISON1) ||
87702 - WARN(prev == LIST_POISON2,
87703 - "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
87704 - entry, LIST_POISON2) ||
87705 - WARN(prev->next != entry,
87706 - "list_del corruption. prev->next should be %p, "
87707 - "but was %p\n", entry, prev->next) ||
87708 - WARN(next->prev != entry,
87709 - "list_del corruption. next->prev should be %p, "
87710 - "but was %p\n", entry, next->prev))
87711 + if (unlikely(next == LIST_POISON1)) {
87712 + printk(KERN_ERR "list_del corruption, %p->next is LIST_POISON1 (%p)\n",
87713 + entry, LIST_POISON1);
87714 + BUG();
87715 + return false;
87716 + }
87717 + if (unlikely(prev == LIST_POISON2)) {
87718 + printk(KERN_ERR "list_del corruption, %p->prev is LIST_POISON2 (%p)\n",
87719 + entry, LIST_POISON2);
87720 + BUG();
87721 + return false;
87722 + }
87723 + if (unlikely(entry->prev->next != entry)) {
87724 + printk(KERN_ERR "list_del corruption. prev->next should be %p, "
87725 + "but was %p\n", entry, prev->next);
87726 + BUG();
87727 + return false;
87728 + }
87729 + if (unlikely(entry->next->prev != entry)) {
87730 + printk(KERN_ERR "list_del corruption. next->prev should be %p, "
87731 + "but was %p\n", entry, next->prev);
87732 + BUG();
87733 + return false;
87734 + }
87735 + return true;
87736 +}
87737 +
87738 +void __list_del_entry(struct list_head *entry)
87739 +{
87740 + if (!__list_del_entry_debug(entry))
87741 return;
87742
87743 - __list_del(prev, next);
87744 + __list_del(entry->prev, entry->next);
87745 }
87746 EXPORT_SYMBOL(__list_del_entry);
87747
87748 @@ -86,15 +125,85 @@ EXPORT_SYMBOL(list_del);
87749 void __list_add_rcu(struct list_head *new,
87750 struct list_head *prev, struct list_head *next)
87751 {
87752 - WARN(next->prev != prev,
87753 - "list_add_rcu corruption. next->prev should be prev (%p), but was %p. (next=%p).\n",
87754 - prev, next->prev, next);
87755 - WARN(prev->next != next,
87756 - "list_add_rcu corruption. prev->next should be next (%p), but was %p. (prev=%p).\n",
87757 - next, prev->next, prev);
87758 + if (!__list_add_debug(new, prev, next))
87759 + return;
87760 +
87761 new->next = next;
87762 new->prev = prev;
87763 rcu_assign_pointer(list_next_rcu(prev), new);
87764 next->prev = new;
87765 }
87766 EXPORT_SYMBOL(__list_add_rcu);
87767 +#endif
87768 +
87769 +void __pax_list_add(struct list_head *new, struct list_head *prev, struct list_head *next)
87770 +{
87771 +#ifdef CONFIG_DEBUG_LIST
87772 + if (!__list_add_debug(new, prev, next))
87773 + return;
87774 +#endif
87775 +
87776 + pax_open_kernel();
87777 + next->prev = new;
87778 + new->next = next;
87779 + new->prev = prev;
87780 + prev->next = new;
87781 + pax_close_kernel();
87782 +}
87783 +EXPORT_SYMBOL(__pax_list_add);
87784 +
87785 +void pax_list_del(struct list_head *entry)
87786 +{
87787 +#ifdef CONFIG_DEBUG_LIST
87788 + if (!__list_del_entry_debug(entry))
87789 + return;
87790 +#endif
87791 +
87792 + pax_open_kernel();
87793 + __list_del(entry->prev, entry->next);
87794 + entry->next = LIST_POISON1;
87795 + entry->prev = LIST_POISON2;
87796 + pax_close_kernel();
87797 +}
87798 +EXPORT_SYMBOL(pax_list_del);
87799 +
87800 +void pax_list_del_init(struct list_head *entry)
87801 +{
87802 + pax_open_kernel();
87803 + __list_del(entry->prev, entry->next);
87804 + INIT_LIST_HEAD(entry);
87805 + pax_close_kernel();
87806 +}
87807 +EXPORT_SYMBOL(pax_list_del_init);
87808 +
87809 +void __pax_list_add_rcu(struct list_head *new,
87810 + struct list_head *prev, struct list_head *next)
87811 +{
87812 +#ifdef CONFIG_DEBUG_LIST
87813 + if (!__list_add_debug(new, prev, next))
87814 + return;
87815 +#endif
87816 +
87817 + pax_open_kernel();
87818 + new->next = next;
87819 + new->prev = prev;
87820 + rcu_assign_pointer(list_next_rcu(prev), new);
87821 + next->prev = new;
87822 + pax_close_kernel();
87823 +}
87824 +EXPORT_SYMBOL(__pax_list_add_rcu);
87825 +
87826 +void pax_list_del_rcu(struct list_head *entry)
87827 +{
87828 +#ifdef CONFIG_DEBUG_LIST
87829 + if (!__list_del_entry_debug(entry))
87830 + return;
87831 +#endif
87832 +
87833 + pax_open_kernel();
87834 + __list_del(entry->prev, entry->next);
87835 + entry->next = LIST_POISON1;
87836 + entry->prev = LIST_POISON2;
87837 + pax_close_kernel();
87838 +}
87839 +EXPORT_SYMBOL(pax_list_del_rcu);
87840 diff --git a/lib/percpu-refcount.c b/lib/percpu-refcount.c
87841 index 1a53d49..ace934c 100644
87842 --- a/lib/percpu-refcount.c
87843 +++ b/lib/percpu-refcount.c
87844 @@ -29,7 +29,7 @@
87845 * can't hit 0 before we've added up all the percpu refs.
87846 */
87847
87848 -#define PCPU_COUNT_BIAS (1U << 31)
87849 +#define PCPU_COUNT_BIAS (1U << 30)
87850
87851 /**
87852 * percpu_ref_init - initialize a percpu refcount
87853 diff --git a/lib/radix-tree.c b/lib/radix-tree.c
87854 index 7811ed3..f80ca19 100644
87855 --- a/lib/radix-tree.c
87856 +++ b/lib/radix-tree.c
87857 @@ -93,7 +93,7 @@ struct radix_tree_preload {
87858 int nr;
87859 struct radix_tree_node *nodes[RADIX_TREE_PRELOAD_SIZE];
87860 };
87861 -static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads) = { 0, };
87862 +static DEFINE_PER_CPU(struct radix_tree_preload, radix_tree_preloads);
87863
87864 static inline void *ptr_to_indirect(void *ptr)
87865 {
87866 diff --git a/lib/strncpy_from_user.c b/lib/strncpy_from_user.c
87867 index bb2b201..46abaf9 100644
87868 --- a/lib/strncpy_from_user.c
87869 +++ b/lib/strncpy_from_user.c
87870 @@ -21,7 +21,7 @@
87871 */
87872 static inline long do_strncpy_from_user(char *dst, const char __user *src, long count, unsigned long max)
87873 {
87874 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87875 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87876 long res = 0;
87877
87878 /*
87879 diff --git a/lib/strnlen_user.c b/lib/strnlen_user.c
87880 index a28df52..3d55877 100644
87881 --- a/lib/strnlen_user.c
87882 +++ b/lib/strnlen_user.c
87883 @@ -26,7 +26,7 @@
87884 */
87885 static inline long do_strnlen_user(const char __user *src, unsigned long count, unsigned long max)
87886 {
87887 - const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87888 + static const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS;
87889 long align, res = 0;
87890 unsigned long c;
87891
87892 diff --git a/lib/swiotlb.c b/lib/swiotlb.c
87893 index 4e8686c..3e8c92f 100644
87894 --- a/lib/swiotlb.c
87895 +++ b/lib/swiotlb.c
87896 @@ -664,7 +664,7 @@ EXPORT_SYMBOL(swiotlb_alloc_coherent);
87897
87898 void
87899 swiotlb_free_coherent(struct device *hwdev, size_t size, void *vaddr,
87900 - dma_addr_t dev_addr)
87901 + dma_addr_t dev_addr, struct dma_attrs *attrs)
87902 {
87903 phys_addr_t paddr = dma_to_phys(hwdev, dev_addr);
87904
87905 diff --git a/lib/usercopy.c b/lib/usercopy.c
87906 index 4f5b1dd..7cab418 100644
87907 --- a/lib/usercopy.c
87908 +++ b/lib/usercopy.c
87909 @@ -7,3 +7,9 @@ void copy_from_user_overflow(void)
87910 WARN(1, "Buffer overflow detected!\n");
87911 }
87912 EXPORT_SYMBOL(copy_from_user_overflow);
87913 +
87914 +void copy_to_user_overflow(void)
87915 +{
87916 + WARN(1, "Buffer overflow detected!\n");
87917 +}
87918 +EXPORT_SYMBOL(copy_to_user_overflow);
87919 diff --git a/lib/vsprintf.c b/lib/vsprintf.c
87920 index d76555c..62d4bfe 100644
87921 --- a/lib/vsprintf.c
87922 +++ b/lib/vsprintf.c
87923 @@ -16,6 +16,9 @@
87924 * - scnprintf and vscnprintf
87925 */
87926
87927 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87928 +#define __INCLUDED_BY_HIDESYM 1
87929 +#endif
87930 #include <stdarg.h>
87931 #include <linux/module.h> /* for KSYM_SYMBOL_LEN */
87932 #include <linux/types.h>
87933 @@ -1155,7 +1158,11 @@ char *netdev_feature_string(char *buf, char *end, const u8 *addr,
87934 return number(buf, end, *(const netdev_features_t *)addr, spec);
87935 }
87936
87937 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87938 +int kptr_restrict __read_mostly = 2;
87939 +#else
87940 int kptr_restrict __read_mostly;
87941 +#endif
87942
87943 /*
87944 * Show a '%p' thing. A kernel extension is that the '%p' is followed
87945 @@ -1168,6 +1175,7 @@ int kptr_restrict __read_mostly;
87946 * - 'f' For simple symbolic function names without offset
87947 * - 'S' For symbolic direct pointers with offset
87948 * - 's' For symbolic direct pointers without offset
87949 + * - 'A' For symbolic direct pointers with offset approved for use with GRKERNSEC_HIDESYM
87950 * - '[FfSs]R' as above with __builtin_extract_return_addr() translation
87951 * - 'B' For backtraced symbolic direct pointers with offset
87952 * - 'R' For decoded struct resource, e.g., [mem 0x0-0x1f 64bit pref]
87953 @@ -1232,12 +1240,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87954
87955 if (!ptr && *fmt != 'K') {
87956 /*
87957 - * Print (null) with the same width as a pointer so it makes
87958 + * Print (nil) with the same width as a pointer so it makes
87959 * tabular output look nice.
87960 */
87961 if (spec.field_width == -1)
87962 spec.field_width = default_width;
87963 - return string(buf, end, "(null)", spec);
87964 + return string(buf, end, "(nil)", spec);
87965 }
87966
87967 switch (*fmt) {
87968 @@ -1247,6 +1255,12 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87969 /* Fallthrough */
87970 case 'S':
87971 case 's':
87972 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87973 + break;
87974 +#else
87975 + return symbol_string(buf, end, ptr, spec, fmt);
87976 +#endif
87977 + case 'A':
87978 case 'B':
87979 return symbol_string(buf, end, ptr, spec, fmt);
87980 case 'R':
87981 @@ -1302,6 +1316,8 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87982 va_end(va);
87983 return buf;
87984 }
87985 + case 'P':
87986 + break;
87987 case 'K':
87988 /*
87989 * %pK cannot be used in IRQ context because its test
87990 @@ -1363,6 +1379,21 @@ char *pointer(const char *fmt, char *buf, char *end, void *ptr,
87991 ((const struct file *)ptr)->f_path.dentry,
87992 spec, fmt);
87993 }
87994 +
87995 +#ifdef CONFIG_GRKERNSEC_HIDESYM
87996 + /* 'P' = approved pointers to copy to userland,
87997 + as in the /proc/kallsyms case, as we make it display nothing
87998 + for non-root users, and the real contents for root users
87999 + Also ignore 'K' pointers, since we force their NULLing for non-root users
88000 + above
88001 + */
88002 + if ((unsigned long)ptr > TASK_SIZE && *fmt != 'P' && *fmt != 'K' && is_usercopy_object(buf)) {
88003 + printk(KERN_ALERT "grsec: kernel infoleak detected! Please report this log to spender@grsecurity.net.\n");
88004 + dump_stack();
88005 + ptr = NULL;
88006 + }
88007 +#endif
88008 +
88009 spec.flags |= SMALL;
88010 if (spec.field_width == -1) {
88011 spec.field_width = default_width;
88012 @@ -2086,11 +2117,11 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
88013 typeof(type) value; \
88014 if (sizeof(type) == 8) { \
88015 args = PTR_ALIGN(args, sizeof(u32)); \
88016 - *(u32 *)&value = *(u32 *)args; \
88017 - *((u32 *)&value + 1) = *(u32 *)(args + 4); \
88018 + *(u32 *)&value = *(const u32 *)args; \
88019 + *((u32 *)&value + 1) = *(const u32 *)(args + 4); \
88020 } else { \
88021 args = PTR_ALIGN(args, sizeof(type)); \
88022 - value = *(typeof(type) *)args; \
88023 + value = *(const typeof(type) *)args; \
88024 } \
88025 args += sizeof(type); \
88026 value; \
88027 @@ -2153,7 +2184,7 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
88028 case FORMAT_TYPE_STR: {
88029 const char *str_arg = args;
88030 args += strlen(str_arg) + 1;
88031 - str = string(str, end, (char *)str_arg, spec);
88032 + str = string(str, end, str_arg, spec);
88033 break;
88034 }
88035
88036 diff --git a/localversion-grsec b/localversion-grsec
88037 new file mode 100644
88038 index 0000000..7cd6065
88039 --- /dev/null
88040 +++ b/localversion-grsec
88041 @@ -0,0 +1 @@
88042 +-grsec
88043 diff --git a/mm/Kconfig b/mm/Kconfig
88044 index 394838f..0e5f816 100644
88045 --- a/mm/Kconfig
88046 +++ b/mm/Kconfig
88047 @@ -317,10 +317,11 @@ config KSM
88048 root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
88049
88050 config DEFAULT_MMAP_MIN_ADDR
88051 - int "Low address space to protect from user allocation"
88052 + int "Low address space to protect from user allocation"
88053 depends on MMU
88054 - default 4096
88055 - help
88056 + default 32768 if ALPHA || ARM || PARISC || SPARC32
88057 + default 65536
88058 + help
88059 This is the portion of low virtual memory which should be protected
88060 from userspace allocation. Keeping a user from writing to low pages
88061 can help reduce the impact of kernel NULL pointer bugs.
88062 @@ -351,7 +352,7 @@ config MEMORY_FAILURE
88063
88064 config HWPOISON_INJECT
88065 tristate "HWPoison pages injector"
88066 - depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS
88067 + depends on MEMORY_FAILURE && DEBUG_KERNEL && PROC_FS && !GRKERNSEC
88068 select PROC_PAGE_MONITOR
88069
88070 config NOMMU_INITIAL_TRIM_EXCESS
88071 diff --git a/mm/backing-dev.c b/mm/backing-dev.c
88072 index ce682f7..1fb54f9 100644
88073 --- a/mm/backing-dev.c
88074 +++ b/mm/backing-dev.c
88075 @@ -12,7 +12,7 @@
88076 #include <linux/device.h>
88077 #include <trace/events/writeback.h>
88078
88079 -static atomic_long_t bdi_seq = ATOMIC_LONG_INIT(0);
88080 +static atomic_long_unchecked_t bdi_seq = ATOMIC_LONG_INIT(0);
88081
88082 struct backing_dev_info default_backing_dev_info = {
88083 .name = "default",
88084 @@ -525,7 +525,7 @@ int bdi_setup_and_register(struct backing_dev_info *bdi, char *name,
88085 return err;
88086
88087 err = bdi_register(bdi, NULL, "%.28s-%ld", name,
88088 - atomic_long_inc_return(&bdi_seq));
88089 + atomic_long_inc_return_unchecked(&bdi_seq));
88090 if (err) {
88091 bdi_destroy(bdi);
88092 return err;
88093 diff --git a/mm/filemap.c b/mm/filemap.c
88094 index ae4846f..b0acebe 100644
88095 --- a/mm/filemap.c
88096 +++ b/mm/filemap.c
88097 @@ -1768,7 +1768,7 @@ int generic_file_mmap(struct file * file, struct vm_area_struct * vma)
88098 struct address_space *mapping = file->f_mapping;
88099
88100 if (!mapping->a_ops->readpage)
88101 - return -ENOEXEC;
88102 + return -ENODEV;
88103 file_accessed(file);
88104 vma->vm_ops = &generic_file_vm_ops;
88105 return 0;
88106 @@ -1950,7 +1950,7 @@ static size_t __iovec_copy_from_user_inatomic(char *vaddr,
88107
88108 while (bytes) {
88109 char __user *buf = iov->iov_base + base;
88110 - int copy = min(bytes, iov->iov_len - base);
88111 + size_t copy = min(bytes, iov->iov_len - base);
88112
88113 base = 0;
88114 left = __copy_from_user_inatomic(vaddr, buf, copy);
88115 @@ -1979,7 +1979,7 @@ size_t iov_iter_copy_from_user_atomic(struct page *page,
88116 BUG_ON(!in_atomic());
88117 kaddr = kmap_atomic(page);
88118 if (likely(i->nr_segs == 1)) {
88119 - int left;
88120 + size_t left;
88121 char __user *buf = i->iov->iov_base + i->iov_offset;
88122 left = __copy_from_user_inatomic(kaddr + offset, buf, bytes);
88123 copied = bytes - left;
88124 @@ -2007,7 +2007,7 @@ size_t iov_iter_copy_from_user(struct page *page,
88125
88126 kaddr = kmap(page);
88127 if (likely(i->nr_segs == 1)) {
88128 - int left;
88129 + size_t left;
88130 char __user *buf = i->iov->iov_base + i->iov_offset;
88131 left = __copy_from_user(kaddr + offset, buf, bytes);
88132 copied = bytes - left;
88133 @@ -2037,7 +2037,7 @@ void iov_iter_advance(struct iov_iter *i, size_t bytes)
88134 * zero-length segments (without overruning the iovec).
88135 */
88136 while (bytes || unlikely(i->count && !iov->iov_len)) {
88137 - int copy;
88138 + size_t copy;
88139
88140 copy = min(bytes, iov->iov_len - base);
88141 BUG_ON(!i->count || i->count < copy);
88142 @@ -2108,6 +2108,7 @@ inline int generic_write_checks(struct file *file, loff_t *pos, size_t *count, i
88143 *pos = i_size_read(inode);
88144
88145 if (limit != RLIM_INFINITY) {
88146 + gr_learn_resource(current, RLIMIT_FSIZE,*pos, 0);
88147 if (*pos >= limit) {
88148 send_sig(SIGXFSZ, current, 0);
88149 return -EFBIG;
88150 diff --git a/mm/fremap.c b/mm/fremap.c
88151 index bbc4d66..117b798 100644
88152 --- a/mm/fremap.c
88153 +++ b/mm/fremap.c
88154 @@ -163,6 +163,11 @@ SYSCALL_DEFINE5(remap_file_pages, unsigned long, start, unsigned long, size,
88155 retry:
88156 vma = find_vma(mm, start);
88157
88158 +#ifdef CONFIG_PAX_SEGMEXEC
88159 + if (vma && (mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_MAYEXEC))
88160 + goto out;
88161 +#endif
88162 +
88163 /*
88164 * Make sure the vma is shared, that it supports prefaulting,
88165 * and that the remapped range is valid and fully within
88166 diff --git a/mm/highmem.c b/mm/highmem.c
88167 index b32b70c..e512eb0 100644
88168 --- a/mm/highmem.c
88169 +++ b/mm/highmem.c
88170 @@ -138,8 +138,9 @@ static void flush_all_zero_pkmaps(void)
88171 * So no dangers, even with speculative execution.
88172 */
88173 page = pte_page(pkmap_page_table[i]);
88174 + pax_open_kernel();
88175 pte_clear(&init_mm, PKMAP_ADDR(i), &pkmap_page_table[i]);
88176 -
88177 + pax_close_kernel();
88178 set_page_address(page, NULL);
88179 need_flush = 1;
88180 }
88181 @@ -198,9 +199,11 @@ start:
88182 }
88183 }
88184 vaddr = PKMAP_ADDR(last_pkmap_nr);
88185 +
88186 + pax_open_kernel();
88187 set_pte_at(&init_mm, vaddr,
88188 &(pkmap_page_table[last_pkmap_nr]), mk_pte(page, kmap_prot));
88189 -
88190 + pax_close_kernel();
88191 pkmap_count[last_pkmap_nr] = 1;
88192 set_page_address(page, (void *)vaddr);
88193
88194 diff --git a/mm/hugetlb.c b/mm/hugetlb.c
88195 index 0b7656e..d21cefc 100644
88196 --- a/mm/hugetlb.c
88197 +++ b/mm/hugetlb.c
88198 @@ -2094,15 +2094,17 @@ static int hugetlb_sysctl_handler_common(bool obey_mempolicy,
88199 struct hstate *h = &default_hstate;
88200 unsigned long tmp;
88201 int ret;
88202 + ctl_table_no_const hugetlb_table;
88203
88204 tmp = h->max_huge_pages;
88205
88206 if (write && h->order >= MAX_ORDER)
88207 return -EINVAL;
88208
88209 - table->data = &tmp;
88210 - table->maxlen = sizeof(unsigned long);
88211 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
88212 + hugetlb_table = *table;
88213 + hugetlb_table.data = &tmp;
88214 + hugetlb_table.maxlen = sizeof(unsigned long);
88215 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
88216 if (ret)
88217 goto out;
88218
88219 @@ -2147,15 +2149,17 @@ int hugetlb_overcommit_handler(struct ctl_table *table, int write,
88220 struct hstate *h = &default_hstate;
88221 unsigned long tmp;
88222 int ret;
88223 + ctl_table_no_const hugetlb_table;
88224
88225 tmp = h->nr_overcommit_huge_pages;
88226
88227 if (write && h->order >= MAX_ORDER)
88228 return -EINVAL;
88229
88230 - table->data = &tmp;
88231 - table->maxlen = sizeof(unsigned long);
88232 - ret = proc_doulongvec_minmax(table, write, buffer, length, ppos);
88233 + hugetlb_table = *table;
88234 + hugetlb_table.data = &tmp;
88235 + hugetlb_table.maxlen = sizeof(unsigned long);
88236 + ret = proc_doulongvec_minmax(&hugetlb_table, write, buffer, length, ppos);
88237 if (ret)
88238 goto out;
88239
88240 @@ -2605,6 +2609,27 @@ static int unmap_ref_private(struct mm_struct *mm, struct vm_area_struct *vma,
88241 return 1;
88242 }
88243
88244 +#ifdef CONFIG_PAX_SEGMEXEC
88245 +static void pax_mirror_huge_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m)
88246 +{
88247 + struct mm_struct *mm = vma->vm_mm;
88248 + struct vm_area_struct *vma_m;
88249 + unsigned long address_m;
88250 + pte_t *ptep_m;
88251 +
88252 + vma_m = pax_find_mirror_vma(vma);
88253 + if (!vma_m)
88254 + return;
88255 +
88256 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88257 + address_m = address + SEGMEXEC_TASK_SIZE;
88258 + ptep_m = huge_pte_offset(mm, address_m & HPAGE_MASK);
88259 + get_page(page_m);
88260 + hugepage_add_anon_rmap(page_m, vma_m, address_m);
88261 + set_huge_pte_at(mm, address_m, ptep_m, make_huge_pte(vma_m, page_m, 0));
88262 +}
88263 +#endif
88264 +
88265 /*
88266 * Hugetlb_cow() should be called with page lock of the original hugepage held.
88267 * Called with hugetlb_instantiation_mutex held and pte_page locked so we
88268 @@ -2721,6 +2746,11 @@ retry_avoidcopy:
88269 make_huge_pte(vma, new_page, 1));
88270 page_remove_rmap(old_page);
88271 hugepage_add_new_anon_rmap(new_page, vma, address);
88272 +
88273 +#ifdef CONFIG_PAX_SEGMEXEC
88274 + pax_mirror_huge_pte(vma, address, new_page);
88275 +#endif
88276 +
88277 /* Make the old page be freed below */
88278 new_page = old_page;
88279 }
88280 @@ -2883,6 +2913,10 @@ retry:
88281 && (vma->vm_flags & VM_SHARED)));
88282 set_huge_pte_at(mm, address, ptep, new_pte);
88283
88284 +#ifdef CONFIG_PAX_SEGMEXEC
88285 + pax_mirror_huge_pte(vma, address, page);
88286 +#endif
88287 +
88288 if ((flags & FAULT_FLAG_WRITE) && !(vma->vm_flags & VM_SHARED)) {
88289 /* Optimization, do the COW without a second fault */
88290 ret = hugetlb_cow(mm, vma, address, ptep, new_pte, page);
88291 @@ -2912,6 +2946,10 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88292 static DEFINE_MUTEX(hugetlb_instantiation_mutex);
88293 struct hstate *h = hstate_vma(vma);
88294
88295 +#ifdef CONFIG_PAX_SEGMEXEC
88296 + struct vm_area_struct *vma_m;
88297 +#endif
88298 +
88299 address &= huge_page_mask(h);
88300
88301 ptep = huge_pte_offset(mm, address);
88302 @@ -2925,6 +2963,26 @@ int hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,
88303 VM_FAULT_SET_HINDEX(hstate_index(h));
88304 }
88305
88306 +#ifdef CONFIG_PAX_SEGMEXEC
88307 + vma_m = pax_find_mirror_vma(vma);
88308 + if (vma_m) {
88309 + unsigned long address_m;
88310 +
88311 + if (vma->vm_start > vma_m->vm_start) {
88312 + address_m = address;
88313 + address -= SEGMEXEC_TASK_SIZE;
88314 + vma = vma_m;
88315 + h = hstate_vma(vma);
88316 + } else
88317 + address_m = address + SEGMEXEC_TASK_SIZE;
88318 +
88319 + if (!huge_pte_alloc(mm, address_m, huge_page_size(h)))
88320 + return VM_FAULT_OOM;
88321 + address_m &= HPAGE_MASK;
88322 + unmap_hugepage_range(vma, address_m, address_m + HPAGE_SIZE, NULL);
88323 + }
88324 +#endif
88325 +
88326 ptep = huge_pte_alloc(mm, address, huge_page_size(h));
88327 if (!ptep)
88328 return VM_FAULT_OOM;
88329 diff --git a/mm/internal.h b/mm/internal.h
88330 index 684f7aa..9eb9edc 100644
88331 --- a/mm/internal.h
88332 +++ b/mm/internal.h
88333 @@ -97,6 +97,7 @@ extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
88334 * in mm/page_alloc.c
88335 */
88336 extern void __free_pages_bootmem(struct page *page, unsigned int order);
88337 +extern void free_compound_page(struct page *page);
88338 extern void prep_compound_page(struct page *page, unsigned long order);
88339 #ifdef CONFIG_MEMORY_FAILURE
88340 extern bool is_free_buddy_page(struct page *page);
88341 @@ -352,7 +353,7 @@ extern u32 hwpoison_filter_enable;
88342
88343 extern unsigned long vm_mmap_pgoff(struct file *, unsigned long,
88344 unsigned long, unsigned long,
88345 - unsigned long, unsigned long);
88346 + unsigned long, unsigned long) __intentional_overflow(-1);
88347
88348 extern void set_pageblock_order(void);
88349 unsigned long reclaim_clean_pages_from_list(struct zone *zone,
88350 diff --git a/mm/kmemleak.c b/mm/kmemleak.c
88351 index e126b0e..e986018 100644
88352 --- a/mm/kmemleak.c
88353 +++ b/mm/kmemleak.c
88354 @@ -363,7 +363,7 @@ static void print_unreferenced(struct seq_file *seq,
88355
88356 for (i = 0; i < object->trace_len; i++) {
88357 void *ptr = (void *)object->trace[i];
88358 - seq_printf(seq, " [<%p>] %pS\n", ptr, ptr);
88359 + seq_printf(seq, " [<%pP>] %pA\n", ptr, ptr);
88360 }
88361 }
88362
88363 @@ -1851,7 +1851,7 @@ static int __init kmemleak_late_init(void)
88364 return -ENOMEM;
88365 }
88366
88367 - dentry = debugfs_create_file("kmemleak", S_IRUGO, NULL, NULL,
88368 + dentry = debugfs_create_file("kmemleak", S_IRUSR, NULL, NULL,
88369 &kmemleak_fops);
88370 if (!dentry)
88371 pr_warning("Failed to create the debugfs kmemleak file\n");
88372 diff --git a/mm/maccess.c b/mm/maccess.c
88373 index d53adf9..03a24bf 100644
88374 --- a/mm/maccess.c
88375 +++ b/mm/maccess.c
88376 @@ -26,7 +26,7 @@ long __probe_kernel_read(void *dst, const void *src, size_t size)
88377 set_fs(KERNEL_DS);
88378 pagefault_disable();
88379 ret = __copy_from_user_inatomic(dst,
88380 - (__force const void __user *)src, size);
88381 + (const void __force_user *)src, size);
88382 pagefault_enable();
88383 set_fs(old_fs);
88384
88385 @@ -53,7 +53,7 @@ long __probe_kernel_write(void *dst, const void *src, size_t size)
88386
88387 set_fs(KERNEL_DS);
88388 pagefault_disable();
88389 - ret = __copy_to_user_inatomic((__force void __user *)dst, src, size);
88390 + ret = __copy_to_user_inatomic((void __force_user *)dst, src, size);
88391 pagefault_enable();
88392 set_fs(old_fs);
88393
88394 diff --git a/mm/madvise.c b/mm/madvise.c
88395 index 539eeb9..e24a987 100644
88396 --- a/mm/madvise.c
88397 +++ b/mm/madvise.c
88398 @@ -51,6 +51,10 @@ static long madvise_behavior(struct vm_area_struct *vma,
88399 pgoff_t pgoff;
88400 unsigned long new_flags = vma->vm_flags;
88401
88402 +#ifdef CONFIG_PAX_SEGMEXEC
88403 + struct vm_area_struct *vma_m;
88404 +#endif
88405 +
88406 switch (behavior) {
88407 case MADV_NORMAL:
88408 new_flags = new_flags & ~VM_RAND_READ & ~VM_SEQ_READ;
88409 @@ -126,6 +130,13 @@ success:
88410 /*
88411 * vm_flags is protected by the mmap_sem held in write mode.
88412 */
88413 +
88414 +#ifdef CONFIG_PAX_SEGMEXEC
88415 + vma_m = pax_find_mirror_vma(vma);
88416 + if (vma_m)
88417 + vma_m->vm_flags = new_flags & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT);
88418 +#endif
88419 +
88420 vma->vm_flags = new_flags;
88421
88422 out:
88423 @@ -274,6 +285,11 @@ static long madvise_dontneed(struct vm_area_struct *vma,
88424 struct vm_area_struct **prev,
88425 unsigned long start, unsigned long end)
88426 {
88427 +
88428 +#ifdef CONFIG_PAX_SEGMEXEC
88429 + struct vm_area_struct *vma_m;
88430 +#endif
88431 +
88432 *prev = vma;
88433 if (vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP))
88434 return -EINVAL;
88435 @@ -286,6 +302,21 @@ static long madvise_dontneed(struct vm_area_struct *vma,
88436 zap_page_range(vma, start, end - start, &details);
88437 } else
88438 zap_page_range(vma, start, end - start, NULL);
88439 +
88440 +#ifdef CONFIG_PAX_SEGMEXEC
88441 + vma_m = pax_find_mirror_vma(vma);
88442 + if (vma_m) {
88443 + if (unlikely(vma->vm_flags & VM_NONLINEAR)) {
88444 + struct zap_details details = {
88445 + .nonlinear_vma = vma_m,
88446 + .last_index = ULONG_MAX,
88447 + };
88448 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, &details);
88449 + } else
88450 + zap_page_range(vma, start + SEGMEXEC_TASK_SIZE, end - start, NULL);
88451 + }
88452 +#endif
88453 +
88454 return 0;
88455 }
88456
88457 @@ -491,6 +522,16 @@ SYSCALL_DEFINE3(madvise, unsigned long, start, size_t, len_in, int, behavior)
88458 if (end < start)
88459 return error;
88460
88461 +#ifdef CONFIG_PAX_SEGMEXEC
88462 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
88463 + if (end > SEGMEXEC_TASK_SIZE)
88464 + return error;
88465 + } else
88466 +#endif
88467 +
88468 + if (end > TASK_SIZE)
88469 + return error;
88470 +
88471 error = 0;
88472 if (end == start)
88473 return error;
88474 diff --git a/mm/memory-failure.c b/mm/memory-failure.c
88475 index 9aea53f..f239c30 100644
88476 --- a/mm/memory-failure.c
88477 +++ b/mm/memory-failure.c
88478 @@ -61,7 +61,7 @@ int sysctl_memory_failure_early_kill __read_mostly = 0;
88479
88480 int sysctl_memory_failure_recovery __read_mostly = 1;
88481
88482 -atomic_long_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
88483 +atomic_long_unchecked_t num_poisoned_pages __read_mostly = ATOMIC_LONG_INIT(0);
88484
88485 #if defined(CONFIG_HWPOISON_INJECT) || defined(CONFIG_HWPOISON_INJECT_MODULE)
88486
88487 @@ -202,7 +202,7 @@ static int kill_proc(struct task_struct *t, unsigned long addr, int trapno,
88488 pfn, t->comm, t->pid);
88489 si.si_signo = SIGBUS;
88490 si.si_errno = 0;
88491 - si.si_addr = (void *)addr;
88492 + si.si_addr = (void __user *)addr;
88493 #ifdef __ARCH_SI_TRAPNO
88494 si.si_trapno = trapno;
88495 #endif
88496 @@ -762,7 +762,7 @@ static struct page_state {
88497 unsigned long res;
88498 char *msg;
88499 int (*action)(struct page *p, unsigned long pfn);
88500 -} error_states[] = {
88501 +} __do_const error_states[] = {
88502 { reserved, reserved, "reserved kernel", me_kernel },
88503 /*
88504 * free pages are specially detected outside this table:
88505 @@ -1063,7 +1063,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88506 nr_pages = 1 << compound_order(hpage);
88507 else /* normal page or thp */
88508 nr_pages = 1;
88509 - atomic_long_add(nr_pages, &num_poisoned_pages);
88510 + atomic_long_add_unchecked(nr_pages, &num_poisoned_pages);
88511
88512 /*
88513 * We need/can do nothing about count=0 pages.
88514 @@ -1093,7 +1093,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88515 if (!PageHWPoison(hpage)
88516 || (hwpoison_filter(p) && TestClearPageHWPoison(p))
88517 || (p != hpage && TestSetPageHWPoison(hpage))) {
88518 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88519 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88520 return 0;
88521 }
88522 set_page_hwpoison_huge_page(hpage);
88523 @@ -1162,7 +1162,7 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
88524 }
88525 if (hwpoison_filter(p)) {
88526 if (TestClearPageHWPoison(p))
88527 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88528 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88529 unlock_page(hpage);
88530 put_page(hpage);
88531 return 0;
88532 @@ -1380,7 +1380,7 @@ int unpoison_memory(unsigned long pfn)
88533 return 0;
88534 }
88535 if (TestClearPageHWPoison(p))
88536 - atomic_long_dec(&num_poisoned_pages);
88537 + atomic_long_dec_unchecked(&num_poisoned_pages);
88538 pr_info("MCE: Software-unpoisoned free page %#lx\n", pfn);
88539 return 0;
88540 }
88541 @@ -1394,7 +1394,7 @@ int unpoison_memory(unsigned long pfn)
88542 */
88543 if (TestClearPageHWPoison(page)) {
88544 pr_info("MCE: Software-unpoisoned page %#lx\n", pfn);
88545 - atomic_long_sub(nr_pages, &num_poisoned_pages);
88546 + atomic_long_sub_unchecked(nr_pages, &num_poisoned_pages);
88547 freeit = 1;
88548 if (PageHuge(page))
88549 clear_page_hwpoison_huge_page(page);
88550 @@ -1533,11 +1533,11 @@ static int soft_offline_huge_page(struct page *page, int flags)
88551 if (PageHuge(page)) {
88552 set_page_hwpoison_huge_page(hpage);
88553 dequeue_hwpoisoned_huge_page(hpage);
88554 - atomic_long_add(1 << compound_order(hpage),
88555 + atomic_long_add_unchecked(1 << compound_order(hpage),
88556 &num_poisoned_pages);
88557 } else {
88558 SetPageHWPoison(page);
88559 - atomic_long_inc(&num_poisoned_pages);
88560 + atomic_long_inc_unchecked(&num_poisoned_pages);
88561 }
88562 }
88563 return ret;
88564 @@ -1576,7 +1576,7 @@ static int __soft_offline_page(struct page *page, int flags)
88565 put_page(page);
88566 pr_info("soft_offline: %#lx: invalidated\n", pfn);
88567 SetPageHWPoison(page);
88568 - atomic_long_inc(&num_poisoned_pages);
88569 + atomic_long_inc_unchecked(&num_poisoned_pages);
88570 return 0;
88571 }
88572
88573 @@ -1621,7 +1621,7 @@ static int __soft_offline_page(struct page *page, int flags)
88574 if (!is_free_buddy_page(page))
88575 pr_info("soft offline: %#lx: page leaked\n",
88576 pfn);
88577 - atomic_long_inc(&num_poisoned_pages);
88578 + atomic_long_inc_unchecked(&num_poisoned_pages);
88579 }
88580 } else {
88581 pr_info("soft offline: %#lx: isolation failed: %d, page count %d, type %lx\n",
88582 @@ -1682,11 +1682,11 @@ int soft_offline_page(struct page *page, int flags)
88583 if (PageHuge(page)) {
88584 set_page_hwpoison_huge_page(hpage);
88585 dequeue_hwpoisoned_huge_page(hpage);
88586 - atomic_long_add(1 << compound_order(hpage),
88587 + atomic_long_add_unchecked(1 << compound_order(hpage),
88588 &num_poisoned_pages);
88589 } else {
88590 SetPageHWPoison(page);
88591 - atomic_long_inc(&num_poisoned_pages);
88592 + atomic_long_inc_unchecked(&num_poisoned_pages);
88593 }
88594 }
88595 unset:
88596 diff --git a/mm/memory.c b/mm/memory.c
88597 index d176154..cd1b387 100644
88598 --- a/mm/memory.c
88599 +++ b/mm/memory.c
88600 @@ -402,6 +402,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
88601 free_pte_range(tlb, pmd, addr);
88602 } while (pmd++, addr = next, addr != end);
88603
88604 +#if !defined(CONFIG_X86_32) || !defined(CONFIG_PAX_PER_CPU_PGD)
88605 start &= PUD_MASK;
88606 if (start < floor)
88607 return;
88608 @@ -416,6 +417,8 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
88609 pmd = pmd_offset(pud, start);
88610 pud_clear(pud);
88611 pmd_free_tlb(tlb, pmd, start);
88612 +#endif
88613 +
88614 }
88615
88616 static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88617 @@ -435,6 +438,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88618 free_pmd_range(tlb, pud, addr, next, floor, ceiling);
88619 } while (pud++, addr = next, addr != end);
88620
88621 +#if !defined(CONFIG_X86_64) || !defined(CONFIG_PAX_PER_CPU_PGD)
88622 start &= PGDIR_MASK;
88623 if (start < floor)
88624 return;
88625 @@ -449,6 +453,8 @@ static inline void free_pud_range(struct mmu_gather *tlb, pgd_t *pgd,
88626 pud = pud_offset(pgd, start);
88627 pgd_clear(pgd);
88628 pud_free_tlb(tlb, pud, start);
88629 +#endif
88630 +
88631 }
88632
88633 /*
88634 @@ -1636,12 +1642,6 @@ no_page_table:
88635 return page;
88636 }
88637
88638 -static inline int stack_guard_page(struct vm_area_struct *vma, unsigned long addr)
88639 -{
88640 - return stack_guard_page_start(vma, addr) ||
88641 - stack_guard_page_end(vma, addr+PAGE_SIZE);
88642 -}
88643 -
88644 /**
88645 * __get_user_pages() - pin user pages in memory
88646 * @tsk: task_struct of target task
88647 @@ -1728,10 +1728,10 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88648
88649 i = 0;
88650
88651 - do {
88652 + while (nr_pages) {
88653 struct vm_area_struct *vma;
88654
88655 - vma = find_extend_vma(mm, start);
88656 + vma = find_vma(mm, start);
88657 if (!vma && in_gate_area(mm, start)) {
88658 unsigned long pg = start & PAGE_MASK;
88659 pgd_t *pgd;
88660 @@ -1780,7 +1780,7 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88661 goto next_page;
88662 }
88663
88664 - if (!vma ||
88665 + if (!vma || start < vma->vm_start ||
88666 (vma->vm_flags & (VM_IO | VM_PFNMAP)) ||
88667 !(vm_flags & vma->vm_flags))
88668 return i ? : -EFAULT;
88669 @@ -1809,11 +1809,6 @@ long __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
88670 int ret;
88671 unsigned int fault_flags = 0;
88672
88673 - /* For mlock, just skip the stack guard page. */
88674 - if (foll_flags & FOLL_MLOCK) {
88675 - if (stack_guard_page(vma, start))
88676 - goto next_page;
88677 - }
88678 if (foll_flags & FOLL_WRITE)
88679 fault_flags |= FAULT_FLAG_WRITE;
88680 if (nonblocking)
88681 @@ -1893,7 +1888,7 @@ next_page:
88682 start += page_increm * PAGE_SIZE;
88683 nr_pages -= page_increm;
88684 } while (nr_pages && start < vma->vm_end);
88685 - } while (nr_pages);
88686 + }
88687 return i;
88688 }
88689 EXPORT_SYMBOL(__get_user_pages);
88690 @@ -2100,6 +2095,10 @@ static int insert_page(struct vm_area_struct *vma, unsigned long addr,
88691 page_add_file_rmap(page);
88692 set_pte_at(mm, addr, pte, mk_pte(page, prot));
88693
88694 +#ifdef CONFIG_PAX_SEGMEXEC
88695 + pax_mirror_file_pte(vma, addr, page, ptl);
88696 +#endif
88697 +
88698 retval = 0;
88699 pte_unmap_unlock(pte, ptl);
88700 return retval;
88701 @@ -2144,9 +2143,21 @@ int vm_insert_page(struct vm_area_struct *vma, unsigned long addr,
88702 if (!page_count(page))
88703 return -EINVAL;
88704 if (!(vma->vm_flags & VM_MIXEDMAP)) {
88705 +
88706 +#ifdef CONFIG_PAX_SEGMEXEC
88707 + struct vm_area_struct *vma_m;
88708 +#endif
88709 +
88710 BUG_ON(down_read_trylock(&vma->vm_mm->mmap_sem));
88711 BUG_ON(vma->vm_flags & VM_PFNMAP);
88712 vma->vm_flags |= VM_MIXEDMAP;
88713 +
88714 +#ifdef CONFIG_PAX_SEGMEXEC
88715 + vma_m = pax_find_mirror_vma(vma);
88716 + if (vma_m)
88717 + vma_m->vm_flags |= VM_MIXEDMAP;
88718 +#endif
88719 +
88720 }
88721 return insert_page(vma, addr, page, vma->vm_page_prot);
88722 }
88723 @@ -2229,6 +2240,7 @@ int vm_insert_mixed(struct vm_area_struct *vma, unsigned long addr,
88724 unsigned long pfn)
88725 {
88726 BUG_ON(!(vma->vm_flags & VM_MIXEDMAP));
88727 + BUG_ON(vma->vm_mirror);
88728
88729 if (addr < vma->vm_start || addr >= vma->vm_end)
88730 return -EFAULT;
88731 @@ -2476,7 +2488,9 @@ static int apply_to_pmd_range(struct mm_struct *mm, pud_t *pud,
88732
88733 BUG_ON(pud_huge(*pud));
88734
88735 - pmd = pmd_alloc(mm, pud, addr);
88736 + pmd = (mm == &init_mm) ?
88737 + pmd_alloc_kernel(mm, pud, addr) :
88738 + pmd_alloc(mm, pud, addr);
88739 if (!pmd)
88740 return -ENOMEM;
88741 do {
88742 @@ -2496,7 +2510,9 @@ static int apply_to_pud_range(struct mm_struct *mm, pgd_t *pgd,
88743 unsigned long next;
88744 int err;
88745
88746 - pud = pud_alloc(mm, pgd, addr);
88747 + pud = (mm == &init_mm) ?
88748 + pud_alloc_kernel(mm, pgd, addr) :
88749 + pud_alloc(mm, pgd, addr);
88750 if (!pud)
88751 return -ENOMEM;
88752 do {
88753 @@ -2584,6 +2600,186 @@ static inline void cow_user_page(struct page *dst, struct page *src, unsigned lo
88754 copy_user_highpage(dst, src, va, vma);
88755 }
88756
88757 +#ifdef CONFIG_PAX_SEGMEXEC
88758 +static void pax_unmap_mirror_pte(struct vm_area_struct *vma, unsigned long address, pmd_t *pmd)
88759 +{
88760 + struct mm_struct *mm = vma->vm_mm;
88761 + spinlock_t *ptl;
88762 + pte_t *pte, entry;
88763 +
88764 + pte = pte_offset_map_lock(mm, pmd, address, &ptl);
88765 + entry = *pte;
88766 + if (!pte_present(entry)) {
88767 + if (!pte_none(entry)) {
88768 + BUG_ON(pte_file(entry));
88769 + free_swap_and_cache(pte_to_swp_entry(entry));
88770 + pte_clear_not_present_full(mm, address, pte, 0);
88771 + }
88772 + } else {
88773 + struct page *page;
88774 +
88775 + flush_cache_page(vma, address, pte_pfn(entry));
88776 + entry = ptep_clear_flush(vma, address, pte);
88777 + BUG_ON(pte_dirty(entry));
88778 + page = vm_normal_page(vma, address, entry);
88779 + if (page) {
88780 + update_hiwater_rss(mm);
88781 + if (PageAnon(page))
88782 + dec_mm_counter_fast(mm, MM_ANONPAGES);
88783 + else
88784 + dec_mm_counter_fast(mm, MM_FILEPAGES);
88785 + page_remove_rmap(page);
88786 + page_cache_release(page);
88787 + }
88788 + }
88789 + pte_unmap_unlock(pte, ptl);
88790 +}
88791 +
88792 +/* PaX: if vma is mirrored, synchronize the mirror's PTE
88793 + *
88794 + * the ptl of the lower mapped page is held on entry and is not released on exit
88795 + * or inside to ensure atomic changes to the PTE states (swapout, mremap, munmap, etc)
88796 + */
88797 +static void pax_mirror_anon_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
88798 +{
88799 + struct mm_struct *mm = vma->vm_mm;
88800 + unsigned long address_m;
88801 + spinlock_t *ptl_m;
88802 + struct vm_area_struct *vma_m;
88803 + pmd_t *pmd_m;
88804 + pte_t *pte_m, entry_m;
88805 +
88806 + BUG_ON(!page_m || !PageAnon(page_m));
88807 +
88808 + vma_m = pax_find_mirror_vma(vma);
88809 + if (!vma_m)
88810 + return;
88811 +
88812 + BUG_ON(!PageLocked(page_m));
88813 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88814 + address_m = address + SEGMEXEC_TASK_SIZE;
88815 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88816 + pte_m = pte_offset_map(pmd_m, address_m);
88817 + ptl_m = pte_lockptr(mm, pmd_m);
88818 + if (ptl != ptl_m) {
88819 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88820 + if (!pte_none(*pte_m))
88821 + goto out;
88822 + }
88823 +
88824 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
88825 + page_cache_get(page_m);
88826 + page_add_anon_rmap(page_m, vma_m, address_m);
88827 + inc_mm_counter_fast(mm, MM_ANONPAGES);
88828 + set_pte_at(mm, address_m, pte_m, entry_m);
88829 + update_mmu_cache(vma_m, address_m, pte_m);
88830 +out:
88831 + if (ptl != ptl_m)
88832 + spin_unlock(ptl_m);
88833 + pte_unmap(pte_m);
88834 + unlock_page(page_m);
88835 +}
88836 +
88837 +void pax_mirror_file_pte(struct vm_area_struct *vma, unsigned long address, struct page *page_m, spinlock_t *ptl)
88838 +{
88839 + struct mm_struct *mm = vma->vm_mm;
88840 + unsigned long address_m;
88841 + spinlock_t *ptl_m;
88842 + struct vm_area_struct *vma_m;
88843 + pmd_t *pmd_m;
88844 + pte_t *pte_m, entry_m;
88845 +
88846 + BUG_ON(!page_m || PageAnon(page_m));
88847 +
88848 + vma_m = pax_find_mirror_vma(vma);
88849 + if (!vma_m)
88850 + return;
88851 +
88852 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88853 + address_m = address + SEGMEXEC_TASK_SIZE;
88854 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88855 + pte_m = pte_offset_map(pmd_m, address_m);
88856 + ptl_m = pte_lockptr(mm, pmd_m);
88857 + if (ptl != ptl_m) {
88858 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88859 + if (!pte_none(*pte_m))
88860 + goto out;
88861 + }
88862 +
88863 + entry_m = pfn_pte(page_to_pfn(page_m), vma_m->vm_page_prot);
88864 + page_cache_get(page_m);
88865 + page_add_file_rmap(page_m);
88866 + inc_mm_counter_fast(mm, MM_FILEPAGES);
88867 + set_pte_at(mm, address_m, pte_m, entry_m);
88868 + update_mmu_cache(vma_m, address_m, pte_m);
88869 +out:
88870 + if (ptl != ptl_m)
88871 + spin_unlock(ptl_m);
88872 + pte_unmap(pte_m);
88873 +}
88874 +
88875 +static void pax_mirror_pfn_pte(struct vm_area_struct *vma, unsigned long address, unsigned long pfn_m, spinlock_t *ptl)
88876 +{
88877 + struct mm_struct *mm = vma->vm_mm;
88878 + unsigned long address_m;
88879 + spinlock_t *ptl_m;
88880 + struct vm_area_struct *vma_m;
88881 + pmd_t *pmd_m;
88882 + pte_t *pte_m, entry_m;
88883 +
88884 + vma_m = pax_find_mirror_vma(vma);
88885 + if (!vma_m)
88886 + return;
88887 +
88888 + BUG_ON(address >= SEGMEXEC_TASK_SIZE);
88889 + address_m = address + SEGMEXEC_TASK_SIZE;
88890 + pmd_m = pmd_offset(pud_offset(pgd_offset(mm, address_m), address_m), address_m);
88891 + pte_m = pte_offset_map(pmd_m, address_m);
88892 + ptl_m = pte_lockptr(mm, pmd_m);
88893 + if (ptl != ptl_m) {
88894 + spin_lock_nested(ptl_m, SINGLE_DEPTH_NESTING);
88895 + if (!pte_none(*pte_m))
88896 + goto out;
88897 + }
88898 +
88899 + entry_m = pfn_pte(pfn_m, vma_m->vm_page_prot);
88900 + set_pte_at(mm, address_m, pte_m, entry_m);
88901 +out:
88902 + if (ptl != ptl_m)
88903 + spin_unlock(ptl_m);
88904 + pte_unmap(pte_m);
88905 +}
88906 +
88907 +static void pax_mirror_pte(struct vm_area_struct *vma, unsigned long address, pte_t *pte, pmd_t *pmd, spinlock_t *ptl)
88908 +{
88909 + struct page *page_m;
88910 + pte_t entry;
88911 +
88912 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC))
88913 + goto out;
88914 +
88915 + entry = *pte;
88916 + page_m = vm_normal_page(vma, address, entry);
88917 + if (!page_m)
88918 + pax_mirror_pfn_pte(vma, address, pte_pfn(entry), ptl);
88919 + else if (PageAnon(page_m)) {
88920 + if (pax_find_mirror_vma(vma)) {
88921 + pte_unmap_unlock(pte, ptl);
88922 + lock_page(page_m);
88923 + pte = pte_offset_map_lock(vma->vm_mm, pmd, address, &ptl);
88924 + if (pte_same(entry, *pte))
88925 + pax_mirror_anon_pte(vma, address, page_m, ptl);
88926 + else
88927 + unlock_page(page_m);
88928 + }
88929 + } else
88930 + pax_mirror_file_pte(vma, address, page_m, ptl);
88931 +
88932 +out:
88933 + pte_unmap_unlock(pte, ptl);
88934 +}
88935 +#endif
88936 +
88937 /*
88938 * This routine handles present pages, when users try to write
88939 * to a shared page. It is done by copying the page to a new address
88940 @@ -2800,6 +2996,12 @@ gotten:
88941 */
88942 page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
88943 if (likely(pte_same(*page_table, orig_pte))) {
88944 +
88945 +#ifdef CONFIG_PAX_SEGMEXEC
88946 + if (pax_find_mirror_vma(vma))
88947 + BUG_ON(!trylock_page(new_page));
88948 +#endif
88949 +
88950 if (old_page) {
88951 if (!PageAnon(old_page)) {
88952 dec_mm_counter_fast(mm, MM_FILEPAGES);
88953 @@ -2851,6 +3053,10 @@ gotten:
88954 page_remove_rmap(old_page);
88955 }
88956
88957 +#ifdef CONFIG_PAX_SEGMEXEC
88958 + pax_mirror_anon_pte(vma, address, new_page, ptl);
88959 +#endif
88960 +
88961 /* Free the old page.. */
88962 new_page = old_page;
88963 ret |= VM_FAULT_WRITE;
88964 @@ -3128,6 +3334,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88965 swap_free(entry);
88966 if (vm_swap_full() || (vma->vm_flags & VM_LOCKED) || PageMlocked(page))
88967 try_to_free_swap(page);
88968 +
88969 +#ifdef CONFIG_PAX_SEGMEXEC
88970 + if ((flags & FAULT_FLAG_WRITE) || !pax_find_mirror_vma(vma))
88971 +#endif
88972 +
88973 unlock_page(page);
88974 if (page != swapcache) {
88975 /*
88976 @@ -3151,6 +3362,11 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma,
88977
88978 /* No need to invalidate - it was non-present before */
88979 update_mmu_cache(vma, address, page_table);
88980 +
88981 +#ifdef CONFIG_PAX_SEGMEXEC
88982 + pax_mirror_anon_pte(vma, address, page, ptl);
88983 +#endif
88984 +
88985 unlock:
88986 pte_unmap_unlock(page_table, ptl);
88987 out:
88988 @@ -3170,40 +3386,6 @@ out_release:
88989 }
88990
88991 /*
88992 - * This is like a special single-page "expand_{down|up}wards()",
88993 - * except we must first make sure that 'address{-|+}PAGE_SIZE'
88994 - * doesn't hit another vma.
88995 - */
88996 -static inline int check_stack_guard_page(struct vm_area_struct *vma, unsigned long address)
88997 -{
88998 - address &= PAGE_MASK;
88999 - if ((vma->vm_flags & VM_GROWSDOWN) && address == vma->vm_start) {
89000 - struct vm_area_struct *prev = vma->vm_prev;
89001 -
89002 - /*
89003 - * Is there a mapping abutting this one below?
89004 - *
89005 - * That's only ok if it's the same stack mapping
89006 - * that has gotten split..
89007 - */
89008 - if (prev && prev->vm_end == address)
89009 - return prev->vm_flags & VM_GROWSDOWN ? 0 : -ENOMEM;
89010 -
89011 - expand_downwards(vma, address - PAGE_SIZE);
89012 - }
89013 - if ((vma->vm_flags & VM_GROWSUP) && address + PAGE_SIZE == vma->vm_end) {
89014 - struct vm_area_struct *next = vma->vm_next;
89015 -
89016 - /* As VM_GROWSDOWN but s/below/above/ */
89017 - if (next && next->vm_start == address + PAGE_SIZE)
89018 - return next->vm_flags & VM_GROWSUP ? 0 : -ENOMEM;
89019 -
89020 - expand_upwards(vma, address + PAGE_SIZE);
89021 - }
89022 - return 0;
89023 -}
89024 -
89025 -/*
89026 * We enter with non-exclusive mmap_sem (to exclude vma changes,
89027 * but allow concurrent faults), and pte mapped but not yet locked.
89028 * We return with mmap_sem still held, but pte unmapped and unlocked.
89029 @@ -3212,27 +3394,23 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
89030 unsigned long address, pte_t *page_table, pmd_t *pmd,
89031 unsigned int flags)
89032 {
89033 - struct page *page;
89034 + struct page *page = NULL;
89035 spinlock_t *ptl;
89036 pte_t entry;
89037
89038 - pte_unmap(page_table);
89039 -
89040 - /* Check if we need to add a guard page to the stack */
89041 - if (check_stack_guard_page(vma, address) < 0)
89042 - return VM_FAULT_SIGBUS;
89043 -
89044 - /* Use the zero-page for reads */
89045 if (!(flags & FAULT_FLAG_WRITE)) {
89046 entry = pte_mkspecial(pfn_pte(my_zero_pfn(address),
89047 vma->vm_page_prot));
89048 - page_table = pte_offset_map_lock(mm, pmd, address, &ptl);
89049 + ptl = pte_lockptr(mm, pmd);
89050 + spin_lock(ptl);
89051 if (!pte_none(*page_table))
89052 goto unlock;
89053 goto setpte;
89054 }
89055
89056 /* Allocate our own private page. */
89057 + pte_unmap(page_table);
89058 +
89059 if (unlikely(anon_vma_prepare(vma)))
89060 goto oom;
89061 page = alloc_zeroed_user_highpage_movable(vma, address);
89062 @@ -3256,6 +3434,11 @@ static int do_anonymous_page(struct mm_struct *mm, struct vm_area_struct *vma,
89063 if (!pte_none(*page_table))
89064 goto release;
89065
89066 +#ifdef CONFIG_PAX_SEGMEXEC
89067 + if (pax_find_mirror_vma(vma))
89068 + BUG_ON(!trylock_page(page));
89069 +#endif
89070 +
89071 inc_mm_counter_fast(mm, MM_ANONPAGES);
89072 page_add_new_anon_rmap(page, vma, address);
89073 setpte:
89074 @@ -3263,6 +3446,12 @@ setpte:
89075
89076 /* No need to invalidate - it was non-present before */
89077 update_mmu_cache(vma, address, page_table);
89078 +
89079 +#ifdef CONFIG_PAX_SEGMEXEC
89080 + if (page)
89081 + pax_mirror_anon_pte(vma, address, page, ptl);
89082 +#endif
89083 +
89084 unlock:
89085 pte_unmap_unlock(page_table, ptl);
89086 return 0;
89087 @@ -3406,6 +3595,12 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89088 */
89089 /* Only go through if we didn't race with anybody else... */
89090 if (likely(pte_same(*page_table, orig_pte))) {
89091 +
89092 +#ifdef CONFIG_PAX_SEGMEXEC
89093 + if (anon && pax_find_mirror_vma(vma))
89094 + BUG_ON(!trylock_page(page));
89095 +#endif
89096 +
89097 flush_icache_page(vma, page);
89098 entry = mk_pte(page, vma->vm_page_prot);
89099 if (flags & FAULT_FLAG_WRITE)
89100 @@ -3427,6 +3622,14 @@ static int __do_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89101
89102 /* no need to invalidate: a not-present page won't be cached */
89103 update_mmu_cache(vma, address, page_table);
89104 +
89105 +#ifdef CONFIG_PAX_SEGMEXEC
89106 + if (anon)
89107 + pax_mirror_anon_pte(vma, address, page, ptl);
89108 + else
89109 + pax_mirror_file_pte(vma, address, page, ptl);
89110 +#endif
89111 +
89112 } else {
89113 if (cow_page)
89114 mem_cgroup_uncharge_page(cow_page);
89115 @@ -3737,6 +3940,12 @@ static int handle_pte_fault(struct mm_struct *mm,
89116 if (flags & FAULT_FLAG_WRITE)
89117 flush_tlb_fix_spurious_fault(vma, address);
89118 }
89119 +
89120 +#ifdef CONFIG_PAX_SEGMEXEC
89121 + pax_mirror_pte(vma, address, pte, pmd, ptl);
89122 + return 0;
89123 +#endif
89124 +
89125 unlock:
89126 pte_unmap_unlock(pte, ptl);
89127 return 0;
89128 @@ -3753,9 +3962,41 @@ static int __handle_mm_fault(struct mm_struct *mm, struct vm_area_struct *vma,
89129 pmd_t *pmd;
89130 pte_t *pte;
89131
89132 +#ifdef CONFIG_PAX_SEGMEXEC
89133 + struct vm_area_struct *vma_m;
89134 +#endif
89135 +
89136 if (unlikely(is_vm_hugetlb_page(vma)))
89137 return hugetlb_fault(mm, vma, address, flags);
89138
89139 +#ifdef CONFIG_PAX_SEGMEXEC
89140 + vma_m = pax_find_mirror_vma(vma);
89141 + if (vma_m) {
89142 + unsigned long address_m;
89143 + pgd_t *pgd_m;
89144 + pud_t *pud_m;
89145 + pmd_t *pmd_m;
89146 +
89147 + if (vma->vm_start > vma_m->vm_start) {
89148 + address_m = address;
89149 + address -= SEGMEXEC_TASK_SIZE;
89150 + vma = vma_m;
89151 + } else
89152 + address_m = address + SEGMEXEC_TASK_SIZE;
89153 +
89154 + pgd_m = pgd_offset(mm, address_m);
89155 + pud_m = pud_alloc(mm, pgd_m, address_m);
89156 + if (!pud_m)
89157 + return VM_FAULT_OOM;
89158 + pmd_m = pmd_alloc(mm, pud_m, address_m);
89159 + if (!pmd_m)
89160 + return VM_FAULT_OOM;
89161 + if (!pmd_present(*pmd_m) && __pte_alloc(mm, vma_m, pmd_m, address_m))
89162 + return VM_FAULT_OOM;
89163 + pax_unmap_mirror_pte(vma_m, address_m, pmd_m);
89164 + }
89165 +#endif
89166 +
89167 retry:
89168 pgd = pgd_offset(mm, address);
89169 pud = pud_alloc(mm, pgd, address);
89170 @@ -3894,6 +4135,23 @@ int __pud_alloc(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
89171 spin_unlock(&mm->page_table_lock);
89172 return 0;
89173 }
89174 +
89175 +int __pud_alloc_kernel(struct mm_struct *mm, pgd_t *pgd, unsigned long address)
89176 +{
89177 + pud_t *new = pud_alloc_one(mm, address);
89178 + if (!new)
89179 + return -ENOMEM;
89180 +
89181 + smp_wmb(); /* See comment in __pte_alloc */
89182 +
89183 + spin_lock(&mm->page_table_lock);
89184 + if (pgd_present(*pgd)) /* Another has populated it */
89185 + pud_free(mm, new);
89186 + else
89187 + pgd_populate_kernel(mm, pgd, new);
89188 + spin_unlock(&mm->page_table_lock);
89189 + return 0;
89190 +}
89191 #endif /* __PAGETABLE_PUD_FOLDED */
89192
89193 #ifndef __PAGETABLE_PMD_FOLDED
89194 @@ -3924,6 +4182,30 @@ int __pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long address)
89195 spin_unlock(&mm->page_table_lock);
89196 return 0;
89197 }
89198 +
89199 +int __pmd_alloc_kernel(struct mm_struct *mm, pud_t *pud, unsigned long address)
89200 +{
89201 + pmd_t *new = pmd_alloc_one(mm, address);
89202 + if (!new)
89203 + return -ENOMEM;
89204 +
89205 + smp_wmb(); /* See comment in __pte_alloc */
89206 +
89207 + spin_lock(&mm->page_table_lock);
89208 +#ifndef __ARCH_HAS_4LEVEL_HACK
89209 + if (pud_present(*pud)) /* Another has populated it */
89210 + pmd_free(mm, new);
89211 + else
89212 + pud_populate_kernel(mm, pud, new);
89213 +#else
89214 + if (pgd_present(*pud)) /* Another has populated it */
89215 + pmd_free(mm, new);
89216 + else
89217 + pgd_populate_kernel(mm, pud, new);
89218 +#endif /* __ARCH_HAS_4LEVEL_HACK */
89219 + spin_unlock(&mm->page_table_lock);
89220 + return 0;
89221 +}
89222 #endif /* __PAGETABLE_PMD_FOLDED */
89223
89224 #if !defined(__HAVE_ARCH_GATE_AREA)
89225 @@ -3937,7 +4219,7 @@ static int __init gate_vma_init(void)
89226 gate_vma.vm_start = FIXADDR_USER_START;
89227 gate_vma.vm_end = FIXADDR_USER_END;
89228 gate_vma.vm_flags = VM_READ | VM_MAYREAD | VM_EXEC | VM_MAYEXEC;
89229 - gate_vma.vm_page_prot = __P101;
89230 + gate_vma.vm_page_prot = vm_get_page_prot(gate_vma.vm_flags);
89231
89232 return 0;
89233 }
89234 @@ -4071,8 +4353,8 @@ out:
89235 return ret;
89236 }
89237
89238 -int generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
89239 - void *buf, int len, int write)
89240 +ssize_t generic_access_phys(struct vm_area_struct *vma, unsigned long addr,
89241 + void *buf, size_t len, int write)
89242 {
89243 resource_size_t phys_addr;
89244 unsigned long prot = 0;
89245 @@ -4098,8 +4380,8 @@ EXPORT_SYMBOL_GPL(generic_access_phys);
89246 * Access another process' address space as given in mm. If non-NULL, use the
89247 * given task for page fault accounting.
89248 */
89249 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89250 - unsigned long addr, void *buf, int len, int write)
89251 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89252 + unsigned long addr, void *buf, size_t len, int write)
89253 {
89254 struct vm_area_struct *vma;
89255 void *old_buf = buf;
89256 @@ -4107,7 +4389,7 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89257 down_read(&mm->mmap_sem);
89258 /* ignore errors, just check how much was successfully transferred */
89259 while (len) {
89260 - int bytes, ret, offset;
89261 + ssize_t bytes, ret, offset;
89262 void *maddr;
89263 struct page *page = NULL;
89264
89265 @@ -4166,8 +4448,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
89266 *
89267 * The caller must hold a reference on @mm.
89268 */
89269 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89270 - void *buf, int len, int write)
89271 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
89272 + void *buf, size_t len, int write)
89273 {
89274 return __access_remote_vm(NULL, mm, addr, buf, len, write);
89275 }
89276 @@ -4177,11 +4459,11 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
89277 * Source/target buffer must be kernel space,
89278 * Do not walk the page table directly, use get_user_pages
89279 */
89280 -int access_process_vm(struct task_struct *tsk, unsigned long addr,
89281 - void *buf, int len, int write)
89282 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr,
89283 + void *buf, size_t len, int write)
89284 {
89285 struct mm_struct *mm;
89286 - int ret;
89287 + ssize_t ret;
89288
89289 mm = get_task_mm(tsk);
89290 if (!mm)
89291 diff --git a/mm/mempolicy.c b/mm/mempolicy.c
89292 index 6b22d8f9..8b5f6cf 100644
89293 --- a/mm/mempolicy.c
89294 +++ b/mm/mempolicy.c
89295 @@ -746,6 +746,10 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
89296 unsigned long vmstart;
89297 unsigned long vmend;
89298
89299 +#ifdef CONFIG_PAX_SEGMEXEC
89300 + struct vm_area_struct *vma_m;
89301 +#endif
89302 +
89303 vma = find_vma(mm, start);
89304 if (!vma || vma->vm_start > start)
89305 return -EFAULT;
89306 @@ -789,6 +793,16 @@ static int mbind_range(struct mm_struct *mm, unsigned long start,
89307 err = vma_replace_policy(vma, new_pol);
89308 if (err)
89309 goto out;
89310 +
89311 +#ifdef CONFIG_PAX_SEGMEXEC
89312 + vma_m = pax_find_mirror_vma(vma);
89313 + if (vma_m) {
89314 + err = vma_replace_policy(vma_m, new_pol);
89315 + if (err)
89316 + goto out;
89317 + }
89318 +#endif
89319 +
89320 }
89321
89322 out:
89323 @@ -1252,6 +1266,17 @@ static long do_mbind(unsigned long start, unsigned long len,
89324
89325 if (end < start)
89326 return -EINVAL;
89327 +
89328 +#ifdef CONFIG_PAX_SEGMEXEC
89329 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
89330 + if (end > SEGMEXEC_TASK_SIZE)
89331 + return -EINVAL;
89332 + } else
89333 +#endif
89334 +
89335 + if (end > TASK_SIZE)
89336 + return -EINVAL;
89337 +
89338 if (end == start)
89339 return 0;
89340
89341 @@ -1480,8 +1505,7 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
89342 */
89343 tcred = __task_cred(task);
89344 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
89345 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
89346 - !capable(CAP_SYS_NICE)) {
89347 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
89348 rcu_read_unlock();
89349 err = -EPERM;
89350 goto out_put;
89351 @@ -1512,6 +1536,15 @@ SYSCALL_DEFINE4(migrate_pages, pid_t, pid, unsigned long, maxnode,
89352 goto out;
89353 }
89354
89355 +#ifdef CONFIG_GRKERNSEC_PROC_MEMMAP
89356 + if (mm != current->mm &&
89357 + (mm->pax_flags & MF_PAX_RANDMMAP || mm->pax_flags & MF_PAX_SEGMEXEC)) {
89358 + mmput(mm);
89359 + err = -EPERM;
89360 + goto out;
89361 + }
89362 +#endif
89363 +
89364 err = do_migrate_pages(mm, old, new,
89365 capable(CAP_SYS_NICE) ? MPOL_MF_MOVE_ALL : MPOL_MF_MOVE);
89366
89367 diff --git a/mm/migrate.c b/mm/migrate.c
89368 index e3cf71d..c94506c 100644
89369 --- a/mm/migrate.c
89370 +++ b/mm/migrate.c
89371 @@ -1406,8 +1406,7 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
89372 */
89373 tcred = __task_cred(task);
89374 if (!uid_eq(cred->euid, tcred->suid) && !uid_eq(cred->euid, tcred->uid) &&
89375 - !uid_eq(cred->uid, tcred->suid) && !uid_eq(cred->uid, tcred->uid) &&
89376 - !capable(CAP_SYS_NICE)) {
89377 + !uid_eq(cred->uid, tcred->suid) && !capable(CAP_SYS_NICE)) {
89378 rcu_read_unlock();
89379 err = -EPERM;
89380 goto out;
89381 diff --git a/mm/mlock.c b/mm/mlock.c
89382 index 192e6ee..b044449 100644
89383 --- a/mm/mlock.c
89384 +++ b/mm/mlock.c
89385 @@ -14,6 +14,7 @@
89386 #include <linux/pagevec.h>
89387 #include <linux/mempolicy.h>
89388 #include <linux/syscalls.h>
89389 +#include <linux/security.h>
89390 #include <linux/sched.h>
89391 #include <linux/export.h>
89392 #include <linux/rmap.h>
89393 @@ -588,7 +589,7 @@ static int do_mlock(unsigned long start, size_t len, int on)
89394 {
89395 unsigned long nstart, end, tmp;
89396 struct vm_area_struct * vma, * prev;
89397 - int error;
89398 + int error = 0;
89399
89400 VM_BUG_ON(start & ~PAGE_MASK);
89401 VM_BUG_ON(len != PAGE_ALIGN(len));
89402 @@ -597,6 +598,9 @@ static int do_mlock(unsigned long start, size_t len, int on)
89403 return -EINVAL;
89404 if (end == start)
89405 return 0;
89406 + if (end > TASK_SIZE)
89407 + return -EINVAL;
89408 +
89409 vma = find_vma(current->mm, start);
89410 if (!vma || vma->vm_start > start)
89411 return -ENOMEM;
89412 @@ -608,6 +612,11 @@ static int do_mlock(unsigned long start, size_t len, int on)
89413 for (nstart = start ; ; ) {
89414 vm_flags_t newflags;
89415
89416 +#ifdef CONFIG_PAX_SEGMEXEC
89417 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
89418 + break;
89419 +#endif
89420 +
89421 /* Here we know that vma->vm_start <= nstart < vma->vm_end. */
89422
89423 newflags = vma->vm_flags & ~VM_LOCKED;
89424 @@ -720,6 +729,7 @@ SYSCALL_DEFINE2(mlock, unsigned long, start, size_t, len)
89425 lock_limit >>= PAGE_SHIFT;
89426
89427 /* check against resource limits */
89428 + gr_learn_resource(current, RLIMIT_MEMLOCK, (current->mm->locked_vm << PAGE_SHIFT) + len, 1);
89429 if ((locked <= lock_limit) || capable(CAP_IPC_LOCK))
89430 error = do_mlock(start, len, 1);
89431 up_write(&current->mm->mmap_sem);
89432 @@ -754,6 +764,11 @@ static int do_mlockall(int flags)
89433 for (vma = current->mm->mmap; vma ; vma = prev->vm_next) {
89434 vm_flags_t newflags;
89435
89436 +#ifdef CONFIG_PAX_SEGMEXEC
89437 + if ((current->mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE))
89438 + break;
89439 +#endif
89440 +
89441 newflags = vma->vm_flags & ~VM_LOCKED;
89442 if (flags & MCL_CURRENT)
89443 newflags |= VM_LOCKED;
89444 @@ -787,6 +802,7 @@ SYSCALL_DEFINE1(mlockall, int, flags)
89445 lock_limit >>= PAGE_SHIFT;
89446
89447 ret = -ENOMEM;
89448 + gr_learn_resource(current, RLIMIT_MEMLOCK, current->mm->total_vm << PAGE_SHIFT, 1);
89449 if (!(flags & MCL_CURRENT) || (current->mm->total_vm <= lock_limit) ||
89450 capable(CAP_IPC_LOCK))
89451 ret = do_mlockall(flags);
89452 diff --git a/mm/mmap.c b/mm/mmap.c
89453 index 362e5f1..8968e02 100644
89454 --- a/mm/mmap.c
89455 +++ b/mm/mmap.c
89456 @@ -36,6 +36,7 @@
89457 #include <linux/sched/sysctl.h>
89458 #include <linux/notifier.h>
89459 #include <linux/memory.h>
89460 +#include <linux/random.h>
89461
89462 #include <asm/uaccess.h>
89463 #include <asm/cacheflush.h>
89464 @@ -52,6 +53,16 @@
89465 #define arch_rebalance_pgtables(addr, len) (addr)
89466 #endif
89467
89468 +static inline void verify_mm_writelocked(struct mm_struct *mm)
89469 +{
89470 +#if defined(CONFIG_DEBUG_VM) || defined(CONFIG_PAX)
89471 + if (unlikely(down_read_trylock(&mm->mmap_sem))) {
89472 + up_read(&mm->mmap_sem);
89473 + BUG();
89474 + }
89475 +#endif
89476 +}
89477 +
89478 static void unmap_region(struct mm_struct *mm,
89479 struct vm_area_struct *vma, struct vm_area_struct *prev,
89480 unsigned long start, unsigned long end);
89481 @@ -71,16 +82,25 @@ static void unmap_region(struct mm_struct *mm,
89482 * x: (no) no x: (no) yes x: (no) yes x: (yes) yes
89483 *
89484 */
89485 -pgprot_t protection_map[16] = {
89486 +pgprot_t protection_map[16] __read_only = {
89487 __P000, __P001, __P010, __P011, __P100, __P101, __P110, __P111,
89488 __S000, __S001, __S010, __S011, __S100, __S101, __S110, __S111
89489 };
89490
89491 -pgprot_t vm_get_page_prot(unsigned long vm_flags)
89492 +pgprot_t vm_get_page_prot(vm_flags_t vm_flags)
89493 {
89494 - return __pgprot(pgprot_val(protection_map[vm_flags &
89495 + pgprot_t prot = __pgprot(pgprot_val(protection_map[vm_flags &
89496 (VM_READ|VM_WRITE|VM_EXEC|VM_SHARED)]) |
89497 pgprot_val(arch_vm_get_page_prot(vm_flags)));
89498 +
89499 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89500 + if (!(__supported_pte_mask & _PAGE_NX) &&
89501 + (vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC &&
89502 + (vm_flags & (VM_READ | VM_WRITE)))
89503 + prot = __pgprot(pte_val(pte_exprotect(__pte(pgprot_val(prot)))));
89504 +#endif
89505 +
89506 + return prot;
89507 }
89508 EXPORT_SYMBOL(vm_get_page_prot);
89509
89510 @@ -89,6 +109,7 @@ int sysctl_overcommit_ratio __read_mostly = 50; /* default is 50% */
89511 int sysctl_max_map_count __read_mostly = DEFAULT_MAX_MAP_COUNT;
89512 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
89513 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
89514 +unsigned long sysctl_heap_stack_gap __read_mostly = 64*1024;
89515 /*
89516 * Make sure vm_committed_as in one cacheline and not cacheline shared with
89517 * other variables. It can be updated by several CPUs frequently.
89518 @@ -247,6 +268,7 @@ static struct vm_area_struct *remove_vma(struct vm_area_struct *vma)
89519 struct vm_area_struct *next = vma->vm_next;
89520
89521 might_sleep();
89522 + BUG_ON(vma->vm_mirror);
89523 if (vma->vm_ops && vma->vm_ops->close)
89524 vma->vm_ops->close(vma);
89525 if (vma->vm_file)
89526 @@ -291,6 +313,7 @@ SYSCALL_DEFINE1(brk, unsigned long, brk)
89527 * not page aligned -Ram Gupta
89528 */
89529 rlim = rlimit(RLIMIT_DATA);
89530 + gr_learn_resource(current, RLIMIT_DATA, (brk - mm->start_brk) + (mm->end_data - mm->start_data), 1);
89531 if (rlim < RLIM_INFINITY && (brk - mm->start_brk) +
89532 (mm->end_data - mm->start_data) > rlim)
89533 goto out;
89534 @@ -933,6 +956,12 @@ static int
89535 can_vma_merge_before(struct vm_area_struct *vma, unsigned long vm_flags,
89536 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
89537 {
89538 +
89539 +#ifdef CONFIG_PAX_SEGMEXEC
89540 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_start == SEGMEXEC_TASK_SIZE)
89541 + return 0;
89542 +#endif
89543 +
89544 if (is_mergeable_vma(vma, file, vm_flags) &&
89545 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
89546 if (vma->vm_pgoff == vm_pgoff)
89547 @@ -952,6 +981,12 @@ static int
89548 can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
89549 struct anon_vma *anon_vma, struct file *file, pgoff_t vm_pgoff)
89550 {
89551 +
89552 +#ifdef CONFIG_PAX_SEGMEXEC
89553 + if ((vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) && vma->vm_end == SEGMEXEC_TASK_SIZE)
89554 + return 0;
89555 +#endif
89556 +
89557 if (is_mergeable_vma(vma, file, vm_flags) &&
89558 is_mergeable_anon_vma(anon_vma, vma->anon_vma, vma)) {
89559 pgoff_t vm_pglen;
89560 @@ -994,13 +1029,20 @@ can_vma_merge_after(struct vm_area_struct *vma, unsigned long vm_flags,
89561 struct vm_area_struct *vma_merge(struct mm_struct *mm,
89562 struct vm_area_struct *prev, unsigned long addr,
89563 unsigned long end, unsigned long vm_flags,
89564 - struct anon_vma *anon_vma, struct file *file,
89565 + struct anon_vma *anon_vma, struct file *file,
89566 pgoff_t pgoff, struct mempolicy *policy)
89567 {
89568 pgoff_t pglen = (end - addr) >> PAGE_SHIFT;
89569 struct vm_area_struct *area, *next;
89570 int err;
89571
89572 +#ifdef CONFIG_PAX_SEGMEXEC
89573 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE, end_m = end + SEGMEXEC_TASK_SIZE;
89574 + struct vm_area_struct *area_m = NULL, *next_m = NULL, *prev_m = NULL;
89575 +
89576 + BUG_ON((mm->pax_flags & MF_PAX_SEGMEXEC) && SEGMEXEC_TASK_SIZE < end);
89577 +#endif
89578 +
89579 /*
89580 * We later require that vma->vm_flags == vm_flags,
89581 * so this tests vma->vm_flags & VM_SPECIAL, too.
89582 @@ -1016,6 +1058,15 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89583 if (next && next->vm_end == end) /* cases 6, 7, 8 */
89584 next = next->vm_next;
89585
89586 +#ifdef CONFIG_PAX_SEGMEXEC
89587 + if (prev)
89588 + prev_m = pax_find_mirror_vma(prev);
89589 + if (area)
89590 + area_m = pax_find_mirror_vma(area);
89591 + if (next)
89592 + next_m = pax_find_mirror_vma(next);
89593 +#endif
89594 +
89595 /*
89596 * Can it merge with the predecessor?
89597 */
89598 @@ -1035,9 +1086,24 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89599 /* cases 1, 6 */
89600 err = vma_adjust(prev, prev->vm_start,
89601 next->vm_end, prev->vm_pgoff, NULL);
89602 - } else /* cases 2, 5, 7 */
89603 +
89604 +#ifdef CONFIG_PAX_SEGMEXEC
89605 + if (!err && prev_m)
89606 + err = vma_adjust(prev_m, prev_m->vm_start,
89607 + next_m->vm_end, prev_m->vm_pgoff, NULL);
89608 +#endif
89609 +
89610 + } else { /* cases 2, 5, 7 */
89611 err = vma_adjust(prev, prev->vm_start,
89612 end, prev->vm_pgoff, NULL);
89613 +
89614 +#ifdef CONFIG_PAX_SEGMEXEC
89615 + if (!err && prev_m)
89616 + err = vma_adjust(prev_m, prev_m->vm_start,
89617 + end_m, prev_m->vm_pgoff, NULL);
89618 +#endif
89619 +
89620 + }
89621 if (err)
89622 return NULL;
89623 khugepaged_enter_vma_merge(prev);
89624 @@ -1051,12 +1117,27 @@ struct vm_area_struct *vma_merge(struct mm_struct *mm,
89625 mpol_equal(policy, vma_policy(next)) &&
89626 can_vma_merge_before(next, vm_flags,
89627 anon_vma, file, pgoff+pglen)) {
89628 - if (prev && addr < prev->vm_end) /* case 4 */
89629 + if (prev && addr < prev->vm_end) { /* case 4 */
89630 err = vma_adjust(prev, prev->vm_start,
89631 addr, prev->vm_pgoff, NULL);
89632 - else /* cases 3, 8 */
89633 +
89634 +#ifdef CONFIG_PAX_SEGMEXEC
89635 + if (!err && prev_m)
89636 + err = vma_adjust(prev_m, prev_m->vm_start,
89637 + addr_m, prev_m->vm_pgoff, NULL);
89638 +#endif
89639 +
89640 + } else { /* cases 3, 8 */
89641 err = vma_adjust(area, addr, next->vm_end,
89642 next->vm_pgoff - pglen, NULL);
89643 +
89644 +#ifdef CONFIG_PAX_SEGMEXEC
89645 + if (!err && area_m)
89646 + err = vma_adjust(area_m, addr_m, next_m->vm_end,
89647 + next_m->vm_pgoff - pglen, NULL);
89648 +#endif
89649 +
89650 + }
89651 if (err)
89652 return NULL;
89653 khugepaged_enter_vma_merge(area);
89654 @@ -1165,8 +1246,10 @@ none:
89655 void vm_stat_account(struct mm_struct *mm, unsigned long flags,
89656 struct file *file, long pages)
89657 {
89658 - const unsigned long stack_flags
89659 - = VM_STACK_FLAGS & (VM_GROWSUP|VM_GROWSDOWN);
89660 +
89661 +#ifdef CONFIG_PAX_RANDMMAP
89662 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
89663 +#endif
89664
89665 mm->total_vm += pages;
89666
89667 @@ -1174,7 +1257,7 @@ void vm_stat_account(struct mm_struct *mm, unsigned long flags,
89668 mm->shared_vm += pages;
89669 if ((flags & (VM_EXEC|VM_WRITE)) == VM_EXEC)
89670 mm->exec_vm += pages;
89671 - } else if (flags & stack_flags)
89672 + } else if (flags & (VM_GROWSUP|VM_GROWSDOWN))
89673 mm->stack_vm += pages;
89674 }
89675 #endif /* CONFIG_PROC_FS */
89676 @@ -1212,7 +1295,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89677 * (the exception is when the underlying filesystem is noexec
89678 * mounted, in which case we dont add PROT_EXEC.)
89679 */
89680 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
89681 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
89682 if (!(file && (file->f_path.mnt->mnt_flags & MNT_NOEXEC)))
89683 prot |= PROT_EXEC;
89684
89685 @@ -1238,7 +1321,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89686 /* Obtain the address to map to. we verify (or select) it and ensure
89687 * that it represents a valid section of the address space.
89688 */
89689 - addr = get_unmapped_area(file, addr, len, pgoff, flags);
89690 + addr = get_unmapped_area(file, addr, len, pgoff, flags | ((prot & PROT_EXEC) ? MAP_EXECUTABLE : 0));
89691 if (addr & ~PAGE_MASK)
89692 return addr;
89693
89694 @@ -1249,6 +1332,43 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89695 vm_flags = calc_vm_prot_bits(prot) | calc_vm_flag_bits(flags) |
89696 mm->def_flags | VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC;
89697
89698 +#ifdef CONFIG_PAX_MPROTECT
89699 + if (mm->pax_flags & MF_PAX_MPROTECT) {
89700 +
89701 +#ifdef CONFIG_GRKERNSEC_RWXMAP_LOG
89702 + if (file && !pgoff && (vm_flags & VM_EXEC) && mm->binfmt &&
89703 + mm->binfmt->handle_mmap)
89704 + mm->binfmt->handle_mmap(file);
89705 +#endif
89706 +
89707 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
89708 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC)) {
89709 + gr_log_rwxmmap(file);
89710 +
89711 +#ifdef CONFIG_PAX_EMUPLT
89712 + vm_flags &= ~VM_EXEC;
89713 +#else
89714 + return -EPERM;
89715 +#endif
89716 +
89717 + }
89718 +
89719 + if (!(vm_flags & VM_EXEC))
89720 + vm_flags &= ~VM_MAYEXEC;
89721 +#else
89722 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
89723 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
89724 +#endif
89725 + else
89726 + vm_flags &= ~VM_MAYWRITE;
89727 + }
89728 +#endif
89729 +
89730 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89731 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && file)
89732 + vm_flags &= ~VM_PAGEEXEC;
89733 +#endif
89734 +
89735 if (flags & MAP_LOCKED)
89736 if (!can_do_mlock())
89737 return -EPERM;
89738 @@ -1260,6 +1380,7 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89739 locked += mm->locked_vm;
89740 lock_limit = rlimit(RLIMIT_MEMLOCK);
89741 lock_limit >>= PAGE_SHIFT;
89742 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
89743 if (locked > lock_limit && !capable(CAP_IPC_LOCK))
89744 return -EAGAIN;
89745 }
89746 @@ -1344,6 +1465,9 @@ unsigned long do_mmap_pgoff(struct file *file, unsigned long addr,
89747 vm_flags |= VM_NORESERVE;
89748 }
89749
89750 + if (!gr_acl_handle_mmap(file, prot))
89751 + return -EACCES;
89752 +
89753 addr = mmap_region(file, addr, len, vm_flags, pgoff);
89754 if (!IS_ERR_VALUE(addr) &&
89755 ((vm_flags & VM_LOCKED) ||
89756 @@ -1437,7 +1561,7 @@ int vma_wants_writenotify(struct vm_area_struct *vma)
89757 vm_flags_t vm_flags = vma->vm_flags;
89758
89759 /* If it was private or non-writable, the write bit is already clear */
89760 - if ((vm_flags & (VM_WRITE|VM_SHARED)) != ((VM_WRITE|VM_SHARED)))
89761 + if ((vm_flags & (VM_WRITE|VM_SHARED)) != (VM_WRITE|VM_SHARED))
89762 return 0;
89763
89764 /* The backer wishes to know when pages are first written to? */
89765 @@ -1483,7 +1607,22 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
89766 struct rb_node **rb_link, *rb_parent;
89767 unsigned long charged = 0;
89768
89769 +#ifdef CONFIG_PAX_SEGMEXEC
89770 + struct vm_area_struct *vma_m = NULL;
89771 +#endif
89772 +
89773 + /*
89774 + * mm->mmap_sem is required to protect against another thread
89775 + * changing the mappings in case we sleep.
89776 + */
89777 + verify_mm_writelocked(mm);
89778 +
89779 /* Check against address space limit. */
89780 +
89781 +#ifdef CONFIG_PAX_RANDMMAP
89782 + if (!(mm->pax_flags & MF_PAX_RANDMMAP) || (vm_flags & (VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC)))
89783 +#endif
89784 +
89785 if (!may_expand_vm(mm, len >> PAGE_SHIFT)) {
89786 unsigned long nr_pages;
89787
89788 @@ -1502,11 +1641,10 @@ unsigned long mmap_region(struct file *file, unsigned long addr,
89789
89790 /* Clear old maps */
89791 error = -ENOMEM;
89792 -munmap_back:
89793 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
89794 if (do_munmap(mm, addr, len))
89795 return -ENOMEM;
89796 - goto munmap_back;
89797 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
89798 }
89799
89800 /*
89801 @@ -1537,6 +1675,16 @@ munmap_back:
89802 goto unacct_error;
89803 }
89804
89805 +#ifdef CONFIG_PAX_SEGMEXEC
89806 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vm_flags & VM_EXEC)) {
89807 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
89808 + if (!vma_m) {
89809 + error = -ENOMEM;
89810 + goto free_vma;
89811 + }
89812 + }
89813 +#endif
89814 +
89815 vma->vm_mm = mm;
89816 vma->vm_start = addr;
89817 vma->vm_end = addr + len;
89818 @@ -1556,6 +1704,13 @@ munmap_back:
89819 if (error)
89820 goto unmap_and_free_vma;
89821
89822 +#if defined(CONFIG_PAX_PAGEEXEC) && defined(CONFIG_X86_32)
89823 + if ((mm->pax_flags & MF_PAX_PAGEEXEC) && !(vma->vm_flags & VM_SPECIAL)) {
89824 + vma->vm_flags |= VM_PAGEEXEC;
89825 + vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
89826 + }
89827 +#endif
89828 +
89829 /* Can addr have changed??
89830 *
89831 * Answer: Yes, several device drivers can do it in their
89832 @@ -1589,6 +1744,12 @@ munmap_back:
89833 }
89834
89835 vma_link(mm, vma, prev, rb_link, rb_parent);
89836 +
89837 +#ifdef CONFIG_PAX_SEGMEXEC
89838 + if (vma_m)
89839 + BUG_ON(pax_mirror_vma(vma_m, vma));
89840 +#endif
89841 +
89842 /* Once vma denies write, undo our temporary denial count */
89843 if (vm_flags & VM_DENYWRITE)
89844 allow_write_access(file);
89845 @@ -1597,6 +1758,7 @@ out:
89846 perf_event_mmap(vma);
89847
89848 vm_stat_account(mm, vm_flags, file, len >> PAGE_SHIFT);
89849 + track_exec_limit(mm, addr, addr + len, vm_flags);
89850 if (vm_flags & VM_LOCKED) {
89851 if (!((vm_flags & VM_SPECIAL) || is_vm_hugetlb_page(vma) ||
89852 vma == get_gate_vma(current->mm)))
89853 @@ -1629,6 +1791,12 @@ unmap_and_free_vma:
89854 unmap_region(mm, vma, prev, vma->vm_start, vma->vm_end);
89855 charged = 0;
89856 free_vma:
89857 +
89858 +#ifdef CONFIG_PAX_SEGMEXEC
89859 + if (vma_m)
89860 + kmem_cache_free(vm_area_cachep, vma_m);
89861 +#endif
89862 +
89863 kmem_cache_free(vm_area_cachep, vma);
89864 unacct_error:
89865 if (charged)
89866 @@ -1636,7 +1804,63 @@ unacct_error:
89867 return error;
89868 }
89869
89870 -unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89871 +#ifdef CONFIG_GRKERNSEC_RAND_THREADSTACK
89872 +unsigned long gr_rand_threadstack_offset(const struct mm_struct *mm, const struct file *filp, unsigned long flags)
89873 +{
89874 + if ((mm->pax_flags & MF_PAX_RANDMMAP) && !filp && (flags & MAP_STACK))
89875 + return ((prandom_u32() & 0xFF) + 1) << PAGE_SHIFT;
89876 +
89877 + return 0;
89878 +}
89879 +#endif
89880 +
89881 +bool check_heap_stack_gap(const struct vm_area_struct *vma, unsigned long addr, unsigned long len, unsigned long offset)
89882 +{
89883 + if (!vma) {
89884 +#ifdef CONFIG_STACK_GROWSUP
89885 + if (addr > sysctl_heap_stack_gap)
89886 + vma = find_vma(current->mm, addr - sysctl_heap_stack_gap);
89887 + else
89888 + vma = find_vma(current->mm, 0);
89889 + if (vma && (vma->vm_flags & VM_GROWSUP))
89890 + return false;
89891 +#endif
89892 + return true;
89893 + }
89894 +
89895 + if (addr + len > vma->vm_start)
89896 + return false;
89897 +
89898 + if (vma->vm_flags & VM_GROWSDOWN)
89899 + return sysctl_heap_stack_gap <= vma->vm_start - addr - len;
89900 +#ifdef CONFIG_STACK_GROWSUP
89901 + else if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP))
89902 + return addr - vma->vm_prev->vm_end >= sysctl_heap_stack_gap;
89903 +#endif
89904 + else if (offset)
89905 + return offset <= vma->vm_start - addr - len;
89906 +
89907 + return true;
89908 +}
89909 +
89910 +unsigned long skip_heap_stack_gap(const struct vm_area_struct *vma, unsigned long len, unsigned long offset)
89911 +{
89912 + if (vma->vm_start < len)
89913 + return -ENOMEM;
89914 +
89915 + if (!(vma->vm_flags & VM_GROWSDOWN)) {
89916 + if (offset <= vma->vm_start - len)
89917 + return vma->vm_start - len - offset;
89918 + else
89919 + return -ENOMEM;
89920 + }
89921 +
89922 + if (sysctl_heap_stack_gap <= vma->vm_start - len)
89923 + return vma->vm_start - len - sysctl_heap_stack_gap;
89924 + return -ENOMEM;
89925 +}
89926 +
89927 +unsigned long unmapped_area(const struct vm_unmapped_area_info *info)
89928 {
89929 /*
89930 * We implement the search by looking for an rbtree node that
89931 @@ -1684,11 +1908,29 @@ unsigned long unmapped_area(struct vm_unmapped_area_info *info)
89932 }
89933 }
89934
89935 - gap_start = vma->vm_prev ? vma->vm_prev->vm_end : 0;
89936 + gap_start = vma->vm_prev ? vma->vm_prev->vm_end: 0;
89937 check_current:
89938 /* Check if current node has a suitable gap */
89939 if (gap_start > high_limit)
89940 return -ENOMEM;
89941 +
89942 + if (gap_end - gap_start > info->threadstack_offset)
89943 + gap_start += info->threadstack_offset;
89944 + else
89945 + gap_start = gap_end;
89946 +
89947 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89948 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89949 + gap_start += sysctl_heap_stack_gap;
89950 + else
89951 + gap_start = gap_end;
89952 + }
89953 + if (vma->vm_flags & VM_GROWSDOWN) {
89954 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89955 + gap_end -= sysctl_heap_stack_gap;
89956 + else
89957 + gap_end = gap_start;
89958 + }
89959 if (gap_end >= low_limit && gap_end - gap_start >= length)
89960 goto found;
89961
89962 @@ -1738,7 +1980,7 @@ found:
89963 return gap_start;
89964 }
89965
89966 -unsigned long unmapped_area_topdown(struct vm_unmapped_area_info *info)
89967 +unsigned long unmapped_area_topdown(const struct vm_unmapped_area_info *info)
89968 {
89969 struct mm_struct *mm = current->mm;
89970 struct vm_area_struct *vma;
89971 @@ -1792,6 +2034,24 @@ check_current:
89972 gap_end = vma->vm_start;
89973 if (gap_end < low_limit)
89974 return -ENOMEM;
89975 +
89976 + if (gap_end - gap_start > info->threadstack_offset)
89977 + gap_end -= info->threadstack_offset;
89978 + else
89979 + gap_end = gap_start;
89980 +
89981 + if (vma->vm_prev && (vma->vm_prev->vm_flags & VM_GROWSUP)) {
89982 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89983 + gap_start += sysctl_heap_stack_gap;
89984 + else
89985 + gap_start = gap_end;
89986 + }
89987 + if (vma->vm_flags & VM_GROWSDOWN) {
89988 + if (gap_end - gap_start > sysctl_heap_stack_gap)
89989 + gap_end -= sysctl_heap_stack_gap;
89990 + else
89991 + gap_end = gap_start;
89992 + }
89993 if (gap_start <= high_limit && gap_end - gap_start >= length)
89994 goto found;
89995
89996 @@ -1855,6 +2115,7 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
89997 struct mm_struct *mm = current->mm;
89998 struct vm_area_struct *vma;
89999 struct vm_unmapped_area_info info;
90000 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
90001
90002 if (len > TASK_SIZE - mmap_min_addr)
90003 return -ENOMEM;
90004 @@ -1862,19 +2123,30 @@ arch_get_unmapped_area(struct file *filp, unsigned long addr,
90005 if (flags & MAP_FIXED)
90006 return addr;
90007
90008 +#ifdef CONFIG_PAX_RANDMMAP
90009 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
90010 +#endif
90011 +
90012 if (addr) {
90013 addr = PAGE_ALIGN(addr);
90014 vma = find_vma(mm, addr);
90015 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
90016 - (!vma || addr + len <= vma->vm_start))
90017 + check_heap_stack_gap(vma, addr, len, offset))
90018 return addr;
90019 }
90020
90021 info.flags = 0;
90022 info.length = len;
90023 info.low_limit = TASK_UNMAPPED_BASE;
90024 +
90025 +#ifdef CONFIG_PAX_RANDMMAP
90026 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90027 + info.low_limit += mm->delta_mmap;
90028 +#endif
90029 +
90030 info.high_limit = TASK_SIZE;
90031 info.align_mask = 0;
90032 + info.threadstack_offset = offset;
90033 return vm_unmapped_area(&info);
90034 }
90035 #endif
90036 @@ -1893,6 +2165,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90037 struct mm_struct *mm = current->mm;
90038 unsigned long addr = addr0;
90039 struct vm_unmapped_area_info info;
90040 + unsigned long offset = gr_rand_threadstack_offset(mm, filp, flags);
90041
90042 /* requested length too big for entire address space */
90043 if (len > TASK_SIZE - mmap_min_addr)
90044 @@ -1901,12 +2174,16 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90045 if (flags & MAP_FIXED)
90046 return addr;
90047
90048 +#ifdef CONFIG_PAX_RANDMMAP
90049 + if (!(mm->pax_flags & MF_PAX_RANDMMAP))
90050 +#endif
90051 +
90052 /* requesting a specific address */
90053 if (addr) {
90054 addr = PAGE_ALIGN(addr);
90055 vma = find_vma(mm, addr);
90056 if (TASK_SIZE - len >= addr && addr >= mmap_min_addr &&
90057 - (!vma || addr + len <= vma->vm_start))
90058 + check_heap_stack_gap(vma, addr, len, offset))
90059 return addr;
90060 }
90061
90062 @@ -1915,6 +2192,7 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90063 info.low_limit = max(PAGE_SIZE, mmap_min_addr);
90064 info.high_limit = mm->mmap_base;
90065 info.align_mask = 0;
90066 + info.threadstack_offset = offset;
90067 addr = vm_unmapped_area(&info);
90068
90069 /*
90070 @@ -1927,6 +2205,12 @@ arch_get_unmapped_area_topdown(struct file *filp, const unsigned long addr0,
90071 VM_BUG_ON(addr != -ENOMEM);
90072 info.flags = 0;
90073 info.low_limit = TASK_UNMAPPED_BASE;
90074 +
90075 +#ifdef CONFIG_PAX_RANDMMAP
90076 + if (mm->pax_flags & MF_PAX_RANDMMAP)
90077 + info.low_limit += mm->delta_mmap;
90078 +#endif
90079 +
90080 info.high_limit = TASK_SIZE;
90081 addr = vm_unmapped_area(&info);
90082 }
90083 @@ -2028,6 +2312,28 @@ find_vma_prev(struct mm_struct *mm, unsigned long addr,
90084 return vma;
90085 }
90086
90087 +#ifdef CONFIG_PAX_SEGMEXEC
90088 +struct vm_area_struct *pax_find_mirror_vma(struct vm_area_struct *vma)
90089 +{
90090 + struct vm_area_struct *vma_m;
90091 +
90092 + BUG_ON(!vma || vma->vm_start >= vma->vm_end);
90093 + if (!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC)) {
90094 + BUG_ON(vma->vm_mirror);
90095 + return NULL;
90096 + }
90097 + BUG_ON(vma->vm_start < SEGMEXEC_TASK_SIZE && SEGMEXEC_TASK_SIZE < vma->vm_end);
90098 + vma_m = vma->vm_mirror;
90099 + BUG_ON(!vma_m || vma_m->vm_mirror != vma);
90100 + BUG_ON(vma->vm_file != vma_m->vm_file);
90101 + BUG_ON(vma->vm_end - vma->vm_start != vma_m->vm_end - vma_m->vm_start);
90102 + BUG_ON(vma->vm_pgoff != vma_m->vm_pgoff);
90103 + BUG_ON(vma->anon_vma != vma_m->anon_vma && vma->anon_vma->root != vma_m->anon_vma->root);
90104 + BUG_ON((vma->vm_flags ^ vma_m->vm_flags) & ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED));
90105 + return vma_m;
90106 +}
90107 +#endif
90108 +
90109 /*
90110 * Verify that the stack growth is acceptable and
90111 * update accounting. This is shared with both the
90112 @@ -2044,6 +2350,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90113 return -ENOMEM;
90114
90115 /* Stack limit test */
90116 + gr_learn_resource(current, RLIMIT_STACK, size, 1);
90117 if (size > ACCESS_ONCE(rlim[RLIMIT_STACK].rlim_cur))
90118 return -ENOMEM;
90119
90120 @@ -2054,6 +2361,7 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90121 locked = mm->locked_vm + grow;
90122 limit = ACCESS_ONCE(rlim[RLIMIT_MEMLOCK].rlim_cur);
90123 limit >>= PAGE_SHIFT;
90124 + gr_learn_resource(current, RLIMIT_MEMLOCK, locked << PAGE_SHIFT, 1);
90125 if (locked > limit && !capable(CAP_IPC_LOCK))
90126 return -ENOMEM;
90127 }
90128 @@ -2083,37 +2391,48 @@ static int acct_stack_growth(struct vm_area_struct *vma, unsigned long size, uns
90129 * PA-RISC uses this for its stack; IA64 for its Register Backing Store.
90130 * vma is the last one with address > vma->vm_end. Have to extend vma.
90131 */
90132 +#ifndef CONFIG_IA64
90133 +static
90134 +#endif
90135 int expand_upwards(struct vm_area_struct *vma, unsigned long address)
90136 {
90137 int error;
90138 + bool locknext;
90139
90140 if (!(vma->vm_flags & VM_GROWSUP))
90141 return -EFAULT;
90142
90143 + /* Also guard against wrapping around to address 0. */
90144 + if (address < PAGE_ALIGN(address+1))
90145 + address = PAGE_ALIGN(address+1);
90146 + else
90147 + return -ENOMEM;
90148 +
90149 /*
90150 * We must make sure the anon_vma is allocated
90151 * so that the anon_vma locking is not a noop.
90152 */
90153 if (unlikely(anon_vma_prepare(vma)))
90154 return -ENOMEM;
90155 + locknext = vma->vm_next && (vma->vm_next->vm_flags & VM_GROWSDOWN);
90156 + if (locknext && anon_vma_prepare(vma->vm_next))
90157 + return -ENOMEM;
90158 vma_lock_anon_vma(vma);
90159 + if (locknext)
90160 + vma_lock_anon_vma(vma->vm_next);
90161
90162 /*
90163 * vma->vm_start/vm_end cannot change under us because the caller
90164 * is required to hold the mmap_sem in read mode. We need the
90165 - * anon_vma lock to serialize against concurrent expand_stacks.
90166 - * Also guard against wrapping around to address 0.
90167 + * anon_vma locks to serialize against concurrent expand_stacks
90168 + * and expand_upwards.
90169 */
90170 - if (address < PAGE_ALIGN(address+4))
90171 - address = PAGE_ALIGN(address+4);
90172 - else {
90173 - vma_unlock_anon_vma(vma);
90174 - return -ENOMEM;
90175 - }
90176 error = 0;
90177
90178 /* Somebody else might have raced and expanded it already */
90179 - if (address > vma->vm_end) {
90180 + 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)
90181 + error = -ENOMEM;
90182 + else if (address > vma->vm_end && (!locknext || vma->vm_next->vm_start >= address)) {
90183 unsigned long size, grow;
90184
90185 size = address - vma->vm_start;
90186 @@ -2148,6 +2467,8 @@ int expand_upwards(struct vm_area_struct *vma, unsigned long address)
90187 }
90188 }
90189 }
90190 + if (locknext)
90191 + vma_unlock_anon_vma(vma->vm_next);
90192 vma_unlock_anon_vma(vma);
90193 khugepaged_enter_vma_merge(vma);
90194 validate_mm(vma->vm_mm);
90195 @@ -2162,6 +2483,8 @@ int expand_downwards(struct vm_area_struct *vma,
90196 unsigned long address)
90197 {
90198 int error;
90199 + bool lockprev = false;
90200 + struct vm_area_struct *prev;
90201
90202 /*
90203 * We must make sure the anon_vma is allocated
90204 @@ -2175,6 +2498,15 @@ int expand_downwards(struct vm_area_struct *vma,
90205 if (error)
90206 return error;
90207
90208 + prev = vma->vm_prev;
90209 +#if defined(CONFIG_STACK_GROWSUP) || defined(CONFIG_IA64)
90210 + lockprev = prev && (prev->vm_flags & VM_GROWSUP);
90211 +#endif
90212 + if (lockprev && anon_vma_prepare(prev))
90213 + return -ENOMEM;
90214 + if (lockprev)
90215 + vma_lock_anon_vma(prev);
90216 +
90217 vma_lock_anon_vma(vma);
90218
90219 /*
90220 @@ -2184,9 +2516,17 @@ int expand_downwards(struct vm_area_struct *vma,
90221 */
90222
90223 /* Somebody else might have raced and expanded it already */
90224 - if (address < vma->vm_start) {
90225 + if (prev && (prev->vm_flags & (VM_READ | VM_WRITE | VM_EXEC)) && address - prev->vm_end < sysctl_heap_stack_gap)
90226 + error = -ENOMEM;
90227 + else if (address < vma->vm_start && (!lockprev || prev->vm_end <= address)) {
90228 unsigned long size, grow;
90229
90230 +#ifdef CONFIG_PAX_SEGMEXEC
90231 + struct vm_area_struct *vma_m;
90232 +
90233 + vma_m = pax_find_mirror_vma(vma);
90234 +#endif
90235 +
90236 size = vma->vm_end - address;
90237 grow = (vma->vm_start - address) >> PAGE_SHIFT;
90238
90239 @@ -2211,13 +2551,27 @@ int expand_downwards(struct vm_area_struct *vma,
90240 vma->vm_pgoff -= grow;
90241 anon_vma_interval_tree_post_update_vma(vma);
90242 vma_gap_update(vma);
90243 +
90244 +#ifdef CONFIG_PAX_SEGMEXEC
90245 + if (vma_m) {
90246 + anon_vma_interval_tree_pre_update_vma(vma_m);
90247 + vma_m->vm_start -= grow << PAGE_SHIFT;
90248 + vma_m->vm_pgoff -= grow;
90249 + anon_vma_interval_tree_post_update_vma(vma_m);
90250 + vma_gap_update(vma_m);
90251 + }
90252 +#endif
90253 +
90254 spin_unlock(&vma->vm_mm->page_table_lock);
90255
90256 + track_exec_limit(vma->vm_mm, vma->vm_start, vma->vm_end, vma->vm_flags);
90257 perf_event_mmap(vma);
90258 }
90259 }
90260 }
90261 vma_unlock_anon_vma(vma);
90262 + if (lockprev)
90263 + vma_unlock_anon_vma(prev);
90264 khugepaged_enter_vma_merge(vma);
90265 validate_mm(vma->vm_mm);
90266 return error;
90267 @@ -2315,6 +2669,13 @@ static void remove_vma_list(struct mm_struct *mm, struct vm_area_struct *vma)
90268 do {
90269 long nrpages = vma_pages(vma);
90270
90271 +#ifdef CONFIG_PAX_SEGMEXEC
90272 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_start >= SEGMEXEC_TASK_SIZE)) {
90273 + vma = remove_vma(vma);
90274 + continue;
90275 + }
90276 +#endif
90277 +
90278 if (vma->vm_flags & VM_ACCOUNT)
90279 nr_accounted += nrpages;
90280 vm_stat_account(mm, vma->vm_flags, vma->vm_file, -nrpages);
90281 @@ -2359,6 +2720,16 @@ detach_vmas_to_be_unmapped(struct mm_struct *mm, struct vm_area_struct *vma,
90282 insertion_point = (prev ? &prev->vm_next : &mm->mmap);
90283 vma->vm_prev = NULL;
90284 do {
90285 +
90286 +#ifdef CONFIG_PAX_SEGMEXEC
90287 + if (vma->vm_mirror) {
90288 + BUG_ON(!vma->vm_mirror->vm_mirror || vma->vm_mirror->vm_mirror != vma);
90289 + vma->vm_mirror->vm_mirror = NULL;
90290 + vma->vm_mirror->vm_flags &= ~VM_EXEC;
90291 + vma->vm_mirror = NULL;
90292 + }
90293 +#endif
90294 +
90295 vma_rb_erase(vma, &mm->mm_rb);
90296 mm->map_count--;
90297 tail_vma = vma;
90298 @@ -2384,14 +2755,33 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90299 struct vm_area_struct *new;
90300 int err = -ENOMEM;
90301
90302 +#ifdef CONFIG_PAX_SEGMEXEC
90303 + struct vm_area_struct *vma_m, *new_m = NULL;
90304 + unsigned long addr_m = addr + SEGMEXEC_TASK_SIZE;
90305 +#endif
90306 +
90307 if (is_vm_hugetlb_page(vma) && (addr &
90308 ~(huge_page_mask(hstate_vma(vma)))))
90309 return -EINVAL;
90310
90311 +#ifdef CONFIG_PAX_SEGMEXEC
90312 + vma_m = pax_find_mirror_vma(vma);
90313 +#endif
90314 +
90315 new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
90316 if (!new)
90317 goto out_err;
90318
90319 +#ifdef CONFIG_PAX_SEGMEXEC
90320 + if (vma_m) {
90321 + new_m = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
90322 + if (!new_m) {
90323 + kmem_cache_free(vm_area_cachep, new);
90324 + goto out_err;
90325 + }
90326 + }
90327 +#endif
90328 +
90329 /* most fields are the same, copy all, and then fixup */
90330 *new = *vma;
90331
90332 @@ -2404,6 +2794,22 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90333 new->vm_pgoff += ((addr - vma->vm_start) >> PAGE_SHIFT);
90334 }
90335
90336 +#ifdef CONFIG_PAX_SEGMEXEC
90337 + if (vma_m) {
90338 + *new_m = *vma_m;
90339 + INIT_LIST_HEAD(&new_m->anon_vma_chain);
90340 + new_m->vm_mirror = new;
90341 + new->vm_mirror = new_m;
90342 +
90343 + if (new_below)
90344 + new_m->vm_end = addr_m;
90345 + else {
90346 + new_m->vm_start = addr_m;
90347 + new_m->vm_pgoff += ((addr_m - vma_m->vm_start) >> PAGE_SHIFT);
90348 + }
90349 + }
90350 +#endif
90351 +
90352 err = vma_dup_policy(vma, new);
90353 if (err)
90354 goto out_free_vma;
90355 @@ -2423,6 +2829,38 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90356 else
90357 err = vma_adjust(vma, vma->vm_start, addr, vma->vm_pgoff, new);
90358
90359 +#ifdef CONFIG_PAX_SEGMEXEC
90360 + if (!err && vma_m) {
90361 + struct mempolicy *pol = vma_policy(new);
90362 +
90363 + if (anon_vma_clone(new_m, vma_m))
90364 + goto out_free_mpol;
90365 +
90366 + mpol_get(pol);
90367 + set_vma_policy(new_m, pol);
90368 +
90369 + if (new_m->vm_file)
90370 + get_file(new_m->vm_file);
90371 +
90372 + if (new_m->vm_ops && new_m->vm_ops->open)
90373 + new_m->vm_ops->open(new_m);
90374 +
90375 + if (new_below)
90376 + err = vma_adjust(vma_m, addr_m, vma_m->vm_end, vma_m->vm_pgoff +
90377 + ((addr_m - new_m->vm_start) >> PAGE_SHIFT), new_m);
90378 + else
90379 + err = vma_adjust(vma_m, vma_m->vm_start, addr_m, vma_m->vm_pgoff, new_m);
90380 +
90381 + if (err) {
90382 + if (new_m->vm_ops && new_m->vm_ops->close)
90383 + new_m->vm_ops->close(new_m);
90384 + if (new_m->vm_file)
90385 + fput(new_m->vm_file);
90386 + mpol_put(pol);
90387 + }
90388 + }
90389 +#endif
90390 +
90391 /* Success. */
90392 if (!err)
90393 return 0;
90394 @@ -2432,10 +2870,18 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90395 new->vm_ops->close(new);
90396 if (new->vm_file)
90397 fput(new->vm_file);
90398 - unlink_anon_vmas(new);
90399 out_free_mpol:
90400 mpol_put(vma_policy(new));
90401 out_free_vma:
90402 +
90403 +#ifdef CONFIG_PAX_SEGMEXEC
90404 + if (new_m) {
90405 + unlink_anon_vmas(new_m);
90406 + kmem_cache_free(vm_area_cachep, new_m);
90407 + }
90408 +#endif
90409 +
90410 + unlink_anon_vmas(new);
90411 kmem_cache_free(vm_area_cachep, new);
90412 out_err:
90413 return err;
90414 @@ -2448,6 +2894,15 @@ static int __split_vma(struct mm_struct * mm, struct vm_area_struct * vma,
90415 int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90416 unsigned long addr, int new_below)
90417 {
90418 +
90419 +#ifdef CONFIG_PAX_SEGMEXEC
90420 + if (mm->pax_flags & MF_PAX_SEGMEXEC) {
90421 + BUG_ON(vma->vm_end > SEGMEXEC_TASK_SIZE);
90422 + if (mm->map_count >= sysctl_max_map_count-1)
90423 + return -ENOMEM;
90424 + } else
90425 +#endif
90426 +
90427 if (mm->map_count >= sysctl_max_map_count)
90428 return -ENOMEM;
90429
90430 @@ -2459,11 +2914,30 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
90431 * work. This now handles partial unmappings.
90432 * Jeremy Fitzhardinge <jeremy@goop.org>
90433 */
90434 +#ifdef CONFIG_PAX_SEGMEXEC
90435 int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90436 {
90437 + int ret = __do_munmap(mm, start, len);
90438 + if (ret || !(mm->pax_flags & MF_PAX_SEGMEXEC))
90439 + return ret;
90440 +
90441 + return __do_munmap(mm, start + SEGMEXEC_TASK_SIZE, len);
90442 +}
90443 +
90444 +int __do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90445 +#else
90446 +int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90447 +#endif
90448 +{
90449 unsigned long end;
90450 struct vm_area_struct *vma, *prev, *last;
90451
90452 + /*
90453 + * mm->mmap_sem is required to protect against another thread
90454 + * changing the mappings in case we sleep.
90455 + */
90456 + verify_mm_writelocked(mm);
90457 +
90458 if ((start & ~PAGE_MASK) || start > TASK_SIZE || len > TASK_SIZE-start)
90459 return -EINVAL;
90460
90461 @@ -2538,6 +3012,8 @@ int do_munmap(struct mm_struct *mm, unsigned long start, size_t len)
90462 /* Fix up all other VM information */
90463 remove_vma_list(mm, vma);
90464
90465 + track_exec_limit(mm, start, end, 0UL);
90466 +
90467 return 0;
90468 }
90469
90470 @@ -2546,6 +3022,13 @@ int vm_munmap(unsigned long start, size_t len)
90471 int ret;
90472 struct mm_struct *mm = current->mm;
90473
90474 +
90475 +#ifdef CONFIG_PAX_SEGMEXEC
90476 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) &&
90477 + (len > SEGMEXEC_TASK_SIZE || start > SEGMEXEC_TASK_SIZE-len))
90478 + return -EINVAL;
90479 +#endif
90480 +
90481 down_write(&mm->mmap_sem);
90482 ret = do_munmap(mm, start, len);
90483 up_write(&mm->mmap_sem);
90484 @@ -2559,16 +3042,6 @@ SYSCALL_DEFINE2(munmap, unsigned long, addr, size_t, len)
90485 return vm_munmap(addr, len);
90486 }
90487
90488 -static inline void verify_mm_writelocked(struct mm_struct *mm)
90489 -{
90490 -#ifdef CONFIG_DEBUG_VM
90491 - if (unlikely(down_read_trylock(&mm->mmap_sem))) {
90492 - WARN_ON(1);
90493 - up_read(&mm->mmap_sem);
90494 - }
90495 -#endif
90496 -}
90497 -
90498 /*
90499 * this is really a simplified "do_mmap". it only handles
90500 * anonymous maps. eventually we may be able to do some
90501 @@ -2582,6 +3055,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90502 struct rb_node ** rb_link, * rb_parent;
90503 pgoff_t pgoff = addr >> PAGE_SHIFT;
90504 int error;
90505 + unsigned long charged;
90506
90507 len = PAGE_ALIGN(len);
90508 if (!len)
90509 @@ -2589,16 +3063,30 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90510
90511 flags = VM_DATA_DEFAULT_FLAGS | VM_ACCOUNT | mm->def_flags;
90512
90513 +#if defined(CONFIG_PAX_PAGEEXEC) || defined(CONFIG_PAX_SEGMEXEC)
90514 + if (mm->pax_flags & (MF_PAX_PAGEEXEC | MF_PAX_SEGMEXEC)) {
90515 + flags &= ~VM_EXEC;
90516 +
90517 +#ifdef CONFIG_PAX_MPROTECT
90518 + if (mm->pax_flags & MF_PAX_MPROTECT)
90519 + flags &= ~VM_MAYEXEC;
90520 +#endif
90521 +
90522 + }
90523 +#endif
90524 +
90525 error = get_unmapped_area(NULL, addr, len, 0, MAP_FIXED);
90526 if (error & ~PAGE_MASK)
90527 return error;
90528
90529 + charged = len >> PAGE_SHIFT;
90530 +
90531 /*
90532 * mlock MCL_FUTURE?
90533 */
90534 if (mm->def_flags & VM_LOCKED) {
90535 unsigned long locked, lock_limit;
90536 - locked = len >> PAGE_SHIFT;
90537 + locked = charged;
90538 locked += mm->locked_vm;
90539 lock_limit = rlimit(RLIMIT_MEMLOCK);
90540 lock_limit >>= PAGE_SHIFT;
90541 @@ -2615,21 +3103,20 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90542 /*
90543 * Clear old maps. this also does some error checking for us
90544 */
90545 - munmap_back:
90546 if (find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent)) {
90547 if (do_munmap(mm, addr, len))
90548 return -ENOMEM;
90549 - goto munmap_back;
90550 + BUG_ON(find_vma_links(mm, addr, addr + len, &prev, &rb_link, &rb_parent));
90551 }
90552
90553 /* Check against address space limits *after* clearing old maps... */
90554 - if (!may_expand_vm(mm, len >> PAGE_SHIFT))
90555 + if (!may_expand_vm(mm, charged))
90556 return -ENOMEM;
90557
90558 if (mm->map_count > sysctl_max_map_count)
90559 return -ENOMEM;
90560
90561 - if (security_vm_enough_memory_mm(mm, len >> PAGE_SHIFT))
90562 + if (security_vm_enough_memory_mm(mm, charged))
90563 return -ENOMEM;
90564
90565 /* Can we just expand an old private anonymous mapping? */
90566 @@ -2643,7 +3130,7 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90567 */
90568 vma = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90569 if (!vma) {
90570 - vm_unacct_memory(len >> PAGE_SHIFT);
90571 + vm_unacct_memory(charged);
90572 return -ENOMEM;
90573 }
90574
90575 @@ -2657,10 +3144,11 @@ static unsigned long do_brk(unsigned long addr, unsigned long len)
90576 vma_link(mm, vma, prev, rb_link, rb_parent);
90577 out:
90578 perf_event_mmap(vma);
90579 - mm->total_vm += len >> PAGE_SHIFT;
90580 + mm->total_vm += charged;
90581 if (flags & VM_LOCKED)
90582 - mm->locked_vm += (len >> PAGE_SHIFT);
90583 + mm->locked_vm += charged;
90584 vma->vm_flags |= VM_SOFTDIRTY;
90585 + track_exec_limit(mm, addr, addr + len, flags);
90586 return addr;
90587 }
90588
90589 @@ -2722,6 +3210,7 @@ void exit_mmap(struct mm_struct *mm)
90590 while (vma) {
90591 if (vma->vm_flags & VM_ACCOUNT)
90592 nr_accounted += vma_pages(vma);
90593 + vma->vm_mirror = NULL;
90594 vma = remove_vma(vma);
90595 }
90596 vm_unacct_memory(nr_accounted);
90597 @@ -2738,6 +3227,13 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
90598 struct vm_area_struct *prev;
90599 struct rb_node **rb_link, *rb_parent;
90600
90601 +#ifdef CONFIG_PAX_SEGMEXEC
90602 + struct vm_area_struct *vma_m = NULL;
90603 +#endif
90604 +
90605 + if (security_mmap_addr(vma->vm_start))
90606 + return -EPERM;
90607 +
90608 /*
90609 * The vm_pgoff of a purely anonymous vma should be irrelevant
90610 * until its first write fault, when page's anon_vma and index
90611 @@ -2761,7 +3257,21 @@ int insert_vm_struct(struct mm_struct *mm, struct vm_area_struct *vma)
90612 security_vm_enough_memory_mm(mm, vma_pages(vma)))
90613 return -ENOMEM;
90614
90615 +#ifdef CONFIG_PAX_SEGMEXEC
90616 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (vma->vm_flags & VM_EXEC)) {
90617 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90618 + if (!vma_m)
90619 + return -ENOMEM;
90620 + }
90621 +#endif
90622 +
90623 vma_link(mm, vma, prev, rb_link, rb_parent);
90624 +
90625 +#ifdef CONFIG_PAX_SEGMEXEC
90626 + if (vma_m)
90627 + BUG_ON(pax_mirror_vma(vma_m, vma));
90628 +#endif
90629 +
90630 return 0;
90631 }
90632
90633 @@ -2780,6 +3290,8 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
90634 struct rb_node **rb_link, *rb_parent;
90635 bool faulted_in_anon_vma = true;
90636
90637 + BUG_ON(vma->vm_mirror);
90638 +
90639 /*
90640 * If anonymous vma has not yet been faulted, update new pgoff
90641 * to match new location, to increase its chance of merging.
90642 @@ -2844,6 +3356,39 @@ struct vm_area_struct *copy_vma(struct vm_area_struct **vmap,
90643 return NULL;
90644 }
90645
90646 +#ifdef CONFIG_PAX_SEGMEXEC
90647 +long pax_mirror_vma(struct vm_area_struct *vma_m, struct vm_area_struct *vma)
90648 +{
90649 + struct vm_area_struct *prev_m;
90650 + struct rb_node **rb_link_m, *rb_parent_m;
90651 + struct mempolicy *pol_m;
90652 +
90653 + BUG_ON(!(vma->vm_mm->pax_flags & MF_PAX_SEGMEXEC) || !(vma->vm_flags & VM_EXEC));
90654 + BUG_ON(vma->vm_mirror || vma_m->vm_mirror);
90655 + BUG_ON(!mpol_equal(vma_policy(vma), vma_policy(vma_m)));
90656 + *vma_m = *vma;
90657 + INIT_LIST_HEAD(&vma_m->anon_vma_chain);
90658 + if (anon_vma_clone(vma_m, vma))
90659 + return -ENOMEM;
90660 + pol_m = vma_policy(vma_m);
90661 + mpol_get(pol_m);
90662 + set_vma_policy(vma_m, pol_m);
90663 + vma_m->vm_start += SEGMEXEC_TASK_SIZE;
90664 + vma_m->vm_end += SEGMEXEC_TASK_SIZE;
90665 + vma_m->vm_flags &= ~(VM_WRITE | VM_MAYWRITE | VM_ACCOUNT | VM_LOCKED);
90666 + vma_m->vm_page_prot = vm_get_page_prot(vma_m->vm_flags);
90667 + if (vma_m->vm_file)
90668 + get_file(vma_m->vm_file);
90669 + if (vma_m->vm_ops && vma_m->vm_ops->open)
90670 + vma_m->vm_ops->open(vma_m);
90671 + BUG_ON(find_vma_links(vma->vm_mm, vma_m->vm_start, vma_m->vm_end, &prev_m, &rb_link_m, &rb_parent_m));
90672 + vma_link(vma->vm_mm, vma_m, prev_m, rb_link_m, rb_parent_m);
90673 + vma_m->vm_mirror = vma;
90674 + vma->vm_mirror = vma_m;
90675 + return 0;
90676 +}
90677 +#endif
90678 +
90679 /*
90680 * Return true if the calling process may expand its vm space by the passed
90681 * number of pages
90682 @@ -2855,6 +3400,7 @@ int may_expand_vm(struct mm_struct *mm, unsigned long npages)
90683
90684 lim = rlimit(RLIMIT_AS) >> PAGE_SHIFT;
90685
90686 + gr_learn_resource(current, RLIMIT_AS, (cur + npages) << PAGE_SHIFT, 1);
90687 if (cur + npages > lim)
90688 return 0;
90689 return 1;
90690 @@ -2925,6 +3471,22 @@ int install_special_mapping(struct mm_struct *mm,
90691 vma->vm_start = addr;
90692 vma->vm_end = addr + len;
90693
90694 +#ifdef CONFIG_PAX_MPROTECT
90695 + if (mm->pax_flags & MF_PAX_MPROTECT) {
90696 +#ifndef CONFIG_PAX_MPROTECT_COMPAT
90697 + if ((vm_flags & (VM_WRITE | VM_EXEC)) == (VM_WRITE | VM_EXEC))
90698 + return -EPERM;
90699 + if (!(vm_flags & VM_EXEC))
90700 + vm_flags &= ~VM_MAYEXEC;
90701 +#else
90702 + if ((vm_flags & (VM_WRITE | VM_EXEC)) != VM_EXEC)
90703 + vm_flags &= ~(VM_EXEC | VM_MAYEXEC);
90704 +#endif
90705 + else
90706 + vm_flags &= ~VM_MAYWRITE;
90707 + }
90708 +#endif
90709 +
90710 vma->vm_flags = vm_flags | mm->def_flags | VM_DONTEXPAND | VM_SOFTDIRTY;
90711 vma->vm_page_prot = vm_get_page_prot(vma->vm_flags);
90712
90713 diff --git a/mm/mprotect.c b/mm/mprotect.c
90714 index 7651a57..d761c62 100644
90715 --- a/mm/mprotect.c
90716 +++ b/mm/mprotect.c
90717 @@ -23,10 +23,18 @@
90718 #include <linux/mmu_notifier.h>
90719 #include <linux/migrate.h>
90720 #include <linux/perf_event.h>
90721 +#include <linux/sched/sysctl.h>
90722 +
90723 +#ifdef CONFIG_PAX_MPROTECT
90724 +#include <linux/elf.h>
90725 +#include <linux/binfmts.h>
90726 +#endif
90727 +
90728 #include <asm/uaccess.h>
90729 #include <asm/pgtable.h>
90730 #include <asm/cacheflush.h>
90731 #include <asm/tlbflush.h>
90732 +#include <asm/mmu_context.h>
90733
90734 #ifndef pgprot_modify
90735 static inline pgprot_t pgprot_modify(pgprot_t oldprot, pgprot_t newprot)
90736 @@ -250,6 +258,48 @@ unsigned long change_protection(struct vm_area_struct *vma, unsigned long start,
90737 return pages;
90738 }
90739
90740 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90741 +/* called while holding the mmap semaphor for writing except stack expansion */
90742 +void track_exec_limit(struct mm_struct *mm, unsigned long start, unsigned long end, unsigned long prot)
90743 +{
90744 + unsigned long oldlimit, newlimit = 0UL;
90745 +
90746 + if (!(mm->pax_flags & MF_PAX_PAGEEXEC) || (__supported_pte_mask & _PAGE_NX))
90747 + return;
90748 +
90749 + spin_lock(&mm->page_table_lock);
90750 + oldlimit = mm->context.user_cs_limit;
90751 + if ((prot & VM_EXEC) && oldlimit < end)
90752 + /* USER_CS limit moved up */
90753 + newlimit = end;
90754 + else if (!(prot & VM_EXEC) && start < oldlimit && oldlimit <= end)
90755 + /* USER_CS limit moved down */
90756 + newlimit = start;
90757 +
90758 + if (newlimit) {
90759 + mm->context.user_cs_limit = newlimit;
90760 +
90761 +#ifdef CONFIG_SMP
90762 + wmb();
90763 + cpus_clear(mm->context.cpu_user_cs_mask);
90764 + cpu_set(smp_processor_id(), mm->context.cpu_user_cs_mask);
90765 +#endif
90766 +
90767 + set_user_cs(mm->context.user_cs_base, mm->context.user_cs_limit, smp_processor_id());
90768 + }
90769 + spin_unlock(&mm->page_table_lock);
90770 + if (newlimit == end) {
90771 + struct vm_area_struct *vma = find_vma(mm, oldlimit);
90772 +
90773 + for (; vma && vma->vm_start < end; vma = vma->vm_next)
90774 + if (is_vm_hugetlb_page(vma))
90775 + hugetlb_change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot);
90776 + else
90777 + change_protection(vma, vma->vm_start, vma->vm_end, vma->vm_page_prot, vma_wants_writenotify(vma), 0);
90778 + }
90779 +}
90780 +#endif
90781 +
90782 int
90783 mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90784 unsigned long start, unsigned long end, unsigned long newflags)
90785 @@ -262,11 +312,29 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90786 int error;
90787 int dirty_accountable = 0;
90788
90789 +#ifdef CONFIG_PAX_SEGMEXEC
90790 + struct vm_area_struct *vma_m = NULL;
90791 + unsigned long start_m, end_m;
90792 +
90793 + start_m = start + SEGMEXEC_TASK_SIZE;
90794 + end_m = end + SEGMEXEC_TASK_SIZE;
90795 +#endif
90796 +
90797 if (newflags == oldflags) {
90798 *pprev = vma;
90799 return 0;
90800 }
90801
90802 + if (newflags & (VM_READ | VM_WRITE | VM_EXEC)) {
90803 + struct vm_area_struct *prev = vma->vm_prev, *next = vma->vm_next;
90804 +
90805 + if (next && (next->vm_flags & VM_GROWSDOWN) && sysctl_heap_stack_gap > next->vm_start - end)
90806 + return -ENOMEM;
90807 +
90808 + if (prev && (prev->vm_flags & VM_GROWSUP) && sysctl_heap_stack_gap > start - prev->vm_end)
90809 + return -ENOMEM;
90810 + }
90811 +
90812 /*
90813 * If we make a private mapping writable we increase our commit;
90814 * but (without finer accounting) cannot reduce our commit if we
90815 @@ -283,6 +351,42 @@ mprotect_fixup(struct vm_area_struct *vma, struct vm_area_struct **pprev,
90816 }
90817 }
90818
90819 +#ifdef CONFIG_PAX_SEGMEXEC
90820 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && ((oldflags ^ newflags) & VM_EXEC)) {
90821 + if (start != vma->vm_start) {
90822 + error = split_vma(mm, vma, start, 1);
90823 + if (error)
90824 + goto fail;
90825 + BUG_ON(!*pprev || (*pprev)->vm_next == vma);
90826 + *pprev = (*pprev)->vm_next;
90827 + }
90828 +
90829 + if (end != vma->vm_end) {
90830 + error = split_vma(mm, vma, end, 0);
90831 + if (error)
90832 + goto fail;
90833 + }
90834 +
90835 + if (pax_find_mirror_vma(vma)) {
90836 + error = __do_munmap(mm, start_m, end_m - start_m);
90837 + if (error)
90838 + goto fail;
90839 + } else {
90840 + vma_m = kmem_cache_zalloc(vm_area_cachep, GFP_KERNEL);
90841 + if (!vma_m) {
90842 + error = -ENOMEM;
90843 + goto fail;
90844 + }
90845 + vma->vm_flags = newflags;
90846 + error = pax_mirror_vma(vma_m, vma);
90847 + if (error) {
90848 + vma->vm_flags = oldflags;
90849 + goto fail;
90850 + }
90851 + }
90852 + }
90853 +#endif
90854 +
90855 /*
90856 * First try to merge with previous and/or next vma.
90857 */
90858 @@ -313,9 +417,21 @@ success:
90859 * vm_flags and vm_page_prot are protected by the mmap_sem
90860 * held in write mode.
90861 */
90862 +
90863 +#ifdef CONFIG_PAX_SEGMEXEC
90864 + if ((mm->pax_flags & MF_PAX_SEGMEXEC) && (newflags & VM_EXEC) && ((vma->vm_flags ^ newflags) & VM_READ))
90865 + pax_find_mirror_vma(vma)->vm_flags ^= VM_READ;
90866 +#endif
90867 +
90868 vma->vm_flags = newflags;
90869 +
90870 +#ifdef CONFIG_PAX_MPROTECT
90871 + if (mm->binfmt && mm->binfmt->handle_mprotect)
90872 + mm->binfmt->handle_mprotect(vma, newflags);
90873 +#endif
90874 +
90875 vma->vm_page_prot = pgprot_modify(vma->vm_page_prot,
90876 - vm_get_page_prot(newflags));
90877 + vm_get_page_prot(vma->vm_flags));
90878
90879 if (vma_wants_writenotify(vma)) {
90880 vma->vm_page_prot = vm_get_page_prot(newflags & ~VM_SHARED);
90881 @@ -354,6 +470,17 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90882 end = start + len;
90883 if (end <= start)
90884 return -ENOMEM;
90885 +
90886 +#ifdef CONFIG_PAX_SEGMEXEC
90887 + if (current->mm->pax_flags & MF_PAX_SEGMEXEC) {
90888 + if (end > SEGMEXEC_TASK_SIZE)
90889 + return -EINVAL;
90890 + } else
90891 +#endif
90892 +
90893 + if (end > TASK_SIZE)
90894 + return -EINVAL;
90895 +
90896 if (!arch_validate_prot(prot))
90897 return -EINVAL;
90898
90899 @@ -361,7 +488,7 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90900 /*
90901 * Does the application expect PROT_READ to imply PROT_EXEC:
90902 */
90903 - if ((prot & PROT_READ) && (current->personality & READ_IMPLIES_EXEC))
90904 + if ((prot & (PROT_READ | PROT_WRITE)) && (current->personality & READ_IMPLIES_EXEC))
90905 prot |= PROT_EXEC;
90906
90907 vm_flags = calc_vm_prot_bits(prot);
90908 @@ -393,6 +520,11 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90909 if (start > vma->vm_start)
90910 prev = vma;
90911
90912 +#ifdef CONFIG_PAX_MPROTECT
90913 + if (current->mm->binfmt && current->mm->binfmt->handle_mprotect)
90914 + current->mm->binfmt->handle_mprotect(vma, vm_flags);
90915 +#endif
90916 +
90917 for (nstart = start ; ; ) {
90918 unsigned long newflags;
90919
90920 @@ -403,6 +535,14 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90921
90922 /* newflags >> 4 shift VM_MAY% in place of VM_% */
90923 if ((newflags & ~(newflags >> 4)) & (VM_READ | VM_WRITE | VM_EXEC)) {
90924 + if (prot & (PROT_WRITE | PROT_EXEC))
90925 + gr_log_rwxmprotect(vma);
90926 +
90927 + error = -EACCES;
90928 + goto out;
90929 + }
90930 +
90931 + if (!gr_acl_handle_mprotect(vma->vm_file, prot)) {
90932 error = -EACCES;
90933 goto out;
90934 }
90935 @@ -417,6 +557,9 @@ SYSCALL_DEFINE3(mprotect, unsigned long, start, size_t, len,
90936 error = mprotect_fixup(vma, &prev, nstart, tmp, newflags);
90937 if (error)
90938 goto out;
90939 +
90940 + track_exec_limit(current->mm, nstart, tmp, vm_flags);
90941 +
90942 nstart = tmp;
90943
90944 if (nstart < prev->vm_end)
90945 diff --git a/mm/mremap.c b/mm/mremap.c
90946 index 0843feb..4f5b2e6 100644
90947 --- a/mm/mremap.c
90948 +++ b/mm/mremap.c
90949 @@ -144,6 +144,12 @@ static void move_ptes(struct vm_area_struct *vma, pmd_t *old_pmd,
90950 continue;
90951 pte = ptep_get_and_clear(mm, old_addr, old_pte);
90952 pte = move_pte(pte, new_vma->vm_page_prot, old_addr, new_addr);
90953 +
90954 +#ifdef CONFIG_ARCH_TRACK_EXEC_LIMIT
90955 + if (!(__supported_pte_mask & _PAGE_NX) && pte_present(pte) && (new_vma->vm_flags & (VM_PAGEEXEC | VM_EXEC)) == VM_PAGEEXEC)
90956 + pte = pte_exprotect(pte);
90957 +#endif
90958 +
90959 pte = move_soft_dirty_pte(pte);
90960 set_pte_at(mm, new_addr, new_pte, pte);
90961 }
90962 @@ -337,6 +343,11 @@ static struct vm_area_struct *vma_to_resize(unsigned long addr,
90963 if (is_vm_hugetlb_page(vma))
90964 goto Einval;
90965
90966 +#ifdef CONFIG_PAX_SEGMEXEC
90967 + if (pax_find_mirror_vma(vma))
90968 + goto Einval;
90969 +#endif
90970 +
90971 /* We can't remap across vm area boundaries */
90972 if (old_len > vma->vm_end - addr)
90973 goto Efault;
90974 @@ -392,20 +403,25 @@ static unsigned long mremap_to(unsigned long addr, unsigned long old_len,
90975 unsigned long ret = -EINVAL;
90976 unsigned long charged = 0;
90977 unsigned long map_flags;
90978 + unsigned long pax_task_size = TASK_SIZE;
90979
90980 if (new_addr & ~PAGE_MASK)
90981 goto out;
90982
90983 - if (new_len > TASK_SIZE || new_addr > TASK_SIZE - new_len)
90984 +#ifdef CONFIG_PAX_SEGMEXEC
90985 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
90986 + pax_task_size = SEGMEXEC_TASK_SIZE;
90987 +#endif
90988 +
90989 + pax_task_size -= PAGE_SIZE;
90990 +
90991 + if (new_len > TASK_SIZE || new_addr > pax_task_size - new_len)
90992 goto out;
90993
90994 /* Check if the location we're moving into overlaps the
90995 * old location at all, and fail if it does.
90996 */
90997 - if ((new_addr <= addr) && (new_addr+new_len) > addr)
90998 - goto out;
90999 -
91000 - if ((addr <= new_addr) && (addr+old_len) > new_addr)
91001 + if (addr + old_len > new_addr && new_addr + new_len > addr)
91002 goto out;
91003
91004 ret = do_munmap(mm, new_addr, new_len);
91005 @@ -474,6 +490,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91006 unsigned long ret = -EINVAL;
91007 unsigned long charged = 0;
91008 bool locked = false;
91009 + unsigned long pax_task_size = TASK_SIZE;
91010
91011 if (flags & ~(MREMAP_FIXED | MREMAP_MAYMOVE))
91012 return ret;
91013 @@ -495,6 +512,17 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91014 if (!new_len)
91015 return ret;
91016
91017 +#ifdef CONFIG_PAX_SEGMEXEC
91018 + if (mm->pax_flags & MF_PAX_SEGMEXEC)
91019 + pax_task_size = SEGMEXEC_TASK_SIZE;
91020 +#endif
91021 +
91022 + pax_task_size -= PAGE_SIZE;
91023 +
91024 + if (new_len > pax_task_size || addr > pax_task_size-new_len ||
91025 + old_len > pax_task_size || addr > pax_task_size-old_len)
91026 + return ret;
91027 +
91028 down_write(&current->mm->mmap_sem);
91029
91030 if (flags & MREMAP_FIXED) {
91031 @@ -545,6 +573,7 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91032 new_addr = addr;
91033 }
91034 ret = addr;
91035 + track_exec_limit(vma->vm_mm, vma->vm_start, addr + new_len, vma->vm_flags);
91036 goto out;
91037 }
91038 }
91039 @@ -568,7 +597,12 @@ SYSCALL_DEFINE5(mremap, unsigned long, addr, unsigned long, old_len,
91040 goto out;
91041 }
91042
91043 + map_flags = vma->vm_flags;
91044 ret = move_vma(vma, addr, old_len, new_len, new_addr, &locked);
91045 + if (!(ret & ~PAGE_MASK)) {
91046 + track_exec_limit(current->mm, addr, addr + old_len, 0UL);
91047 + track_exec_limit(current->mm, new_addr, new_addr + new_len, map_flags);
91048 + }
91049 }
91050 out:
91051 if (ret & ~PAGE_MASK)
91052 diff --git a/mm/nommu.c b/mm/nommu.c
91053 index ecd1f15..77039bd 100644
91054 --- a/mm/nommu.c
91055 +++ b/mm/nommu.c
91056 @@ -64,7 +64,6 @@ int sysctl_max_map_count = DEFAULT_MAX_MAP_COUNT;
91057 int sysctl_nr_trim_pages = CONFIG_NOMMU_INITIAL_TRIM_EXCESS;
91058 unsigned long sysctl_user_reserve_kbytes __read_mostly = 1UL << 17; /* 128MB */
91059 unsigned long sysctl_admin_reserve_kbytes __read_mostly = 1UL << 13; /* 8MB */
91060 -int heap_stack_gap = 0;
91061
91062 atomic_long_t mmap_pages_allocated;
91063
91064 @@ -844,15 +843,6 @@ struct vm_area_struct *find_vma(struct mm_struct *mm, unsigned long addr)
91065 EXPORT_SYMBOL(find_vma);
91066
91067 /*
91068 - * find a VMA
91069 - * - we don't extend stack VMAs under NOMMU conditions
91070 - */
91071 -struct vm_area_struct *find_extend_vma(struct mm_struct *mm, unsigned long addr)
91072 -{
91073 - return find_vma(mm, addr);
91074 -}
91075 -
91076 -/*
91077 * expand a stack to a given address
91078 * - not supported under NOMMU conditions
91079 */
91080 @@ -1563,6 +1553,7 @@ int split_vma(struct mm_struct *mm, struct vm_area_struct *vma,
91081
91082 /* most fields are the same, copy all, and then fixup */
91083 *new = *vma;
91084 + INIT_LIST_HEAD(&new->anon_vma_chain);
91085 *region = *vma->vm_region;
91086 new->vm_region = region;
91087
91088 @@ -1993,8 +1984,8 @@ int generic_file_remap_pages(struct vm_area_struct *vma, unsigned long addr,
91089 }
91090 EXPORT_SYMBOL(generic_file_remap_pages);
91091
91092 -static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91093 - unsigned long addr, void *buf, int len, int write)
91094 +static ssize_t __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91095 + unsigned long addr, void *buf, size_t len, int write)
91096 {
91097 struct vm_area_struct *vma;
91098
91099 @@ -2035,8 +2026,8 @@ static int __access_remote_vm(struct task_struct *tsk, struct mm_struct *mm,
91100 *
91101 * The caller must hold a reference on @mm.
91102 */
91103 -int access_remote_vm(struct mm_struct *mm, unsigned long addr,
91104 - void *buf, int len, int write)
91105 +ssize_t access_remote_vm(struct mm_struct *mm, unsigned long addr,
91106 + void *buf, size_t len, int write)
91107 {
91108 return __access_remote_vm(NULL, mm, addr, buf, len, write);
91109 }
91110 @@ -2045,7 +2036,7 @@ int access_remote_vm(struct mm_struct *mm, unsigned long addr,
91111 * Access another process' address space.
91112 * - source/target buffer must be kernel space
91113 */
91114 -int access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, int len, int write)
91115 +ssize_t access_process_vm(struct task_struct *tsk, unsigned long addr, void *buf, size_t len, int write)
91116 {
91117 struct mm_struct *mm;
91118
91119 diff --git a/mm/page-writeback.c b/mm/page-writeback.c
91120 index 6380758..4064aec 100644
91121 --- a/mm/page-writeback.c
91122 +++ b/mm/page-writeback.c
91123 @@ -690,7 +690,7 @@ static inline long long pos_ratio_polynom(unsigned long setpoint,
91124 * card's bdi_dirty may rush to many times higher than bdi_setpoint.
91125 * - the bdi dirty thresh drops quickly due to change of JBOD workload
91126 */
91127 -static unsigned long bdi_position_ratio(struct backing_dev_info *bdi,
91128 +static unsigned long __intentional_overflow(-1) bdi_position_ratio(struct backing_dev_info *bdi,
91129 unsigned long thresh,
91130 unsigned long bg_thresh,
91131 unsigned long dirty,
91132 diff --git a/mm/page_alloc.c b/mm/page_alloc.c
91133 index 317ea74..a4a1977 100644
91134 --- a/mm/page_alloc.c
91135 +++ b/mm/page_alloc.c
91136 @@ -61,6 +61,7 @@
91137 #include <linux/page-debug-flags.h>
91138 #include <linux/hugetlb.h>
91139 #include <linux/sched/rt.h>
91140 +#include <linux/random.h>
91141
91142 #include <asm/sections.h>
91143 #include <asm/tlbflush.h>
91144 @@ -354,7 +355,7 @@ out:
91145 * This usage means that zero-order pages may not be compound.
91146 */
91147
91148 -static void free_compound_page(struct page *page)
91149 +void free_compound_page(struct page *page)
91150 {
91151 __free_pages_ok(page, compound_order(page));
91152 }
91153 @@ -712,6 +713,10 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
91154 int i;
91155 int bad = 0;
91156
91157 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91158 + unsigned long index = 1UL << order;
91159 +#endif
91160 +
91161 trace_mm_page_free(page, order);
91162 kmemcheck_free_shadow(page, order);
91163
91164 @@ -728,6 +733,12 @@ static bool free_pages_prepare(struct page *page, unsigned int order)
91165 debug_check_no_obj_freed(page_address(page),
91166 PAGE_SIZE << order);
91167 }
91168 +
91169 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91170 + for (; index; --index)
91171 + sanitize_highpage(page + index - 1);
91172 +#endif
91173 +
91174 arch_free_page(page, order);
91175 kernel_map_pages(page, 1 << order, 0);
91176
91177 @@ -750,6 +761,20 @@ static void __free_pages_ok(struct page *page, unsigned int order)
91178 local_irq_restore(flags);
91179 }
91180
91181 +#ifdef CONFIG_PAX_LATENT_ENTROPY
91182 +bool __meminitdata extra_latent_entropy;
91183 +
91184 +static int __init setup_pax_extra_latent_entropy(char *str)
91185 +{
91186 + extra_latent_entropy = true;
91187 + return 0;
91188 +}
91189 +early_param("pax_extra_latent_entropy", setup_pax_extra_latent_entropy);
91190 +
91191 +volatile u64 latent_entropy __latent_entropy;
91192 +EXPORT_SYMBOL(latent_entropy);
91193 +#endif
91194 +
91195 void __init __free_pages_bootmem(struct page *page, unsigned int order)
91196 {
91197 unsigned int nr_pages = 1 << order;
91198 @@ -765,6 +790,19 @@ void __init __free_pages_bootmem(struct page *page, unsigned int order)
91199 __ClearPageReserved(p);
91200 set_page_count(p, 0);
91201
91202 +#ifdef CONFIG_PAX_LATENT_ENTROPY
91203 + if (extra_latent_entropy && !PageHighMem(page) && page_to_pfn(page) < 0x100000) {
91204 + u64 hash = 0;
91205 + size_t index, end = PAGE_SIZE * nr_pages / sizeof hash;
91206 + const u64 *data = lowmem_page_address(page);
91207 +
91208 + for (index = 0; index < end; index++)
91209 + hash ^= hash + data[index];
91210 + latent_entropy ^= hash;
91211 + add_device_randomness((const void *)&latent_entropy, sizeof(latent_entropy));
91212 + }
91213 +#endif
91214 +
91215 page_zone(page)->managed_pages += nr_pages;
91216 set_page_refcounted(page);
91217 __free_pages(page, order);
91218 @@ -870,8 +908,10 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
91219 arch_alloc_page(page, order);
91220 kernel_map_pages(page, 1 << order, 1);
91221
91222 +#ifndef CONFIG_PAX_MEMORY_SANITIZE
91223 if (gfp_flags & __GFP_ZERO)
91224 prep_zero_page(page, order, gfp_flags);
91225 +#endif
91226
91227 if (order && (gfp_flags & __GFP_COMP))
91228 prep_compound_page(page, order);
91229 diff --git a/mm/page_io.c b/mm/page_io.c
91230 index 8c79a47..a689e0d 100644
91231 --- a/mm/page_io.c
91232 +++ b/mm/page_io.c
91233 @@ -260,7 +260,7 @@ int __swap_writepage(struct page *page, struct writeback_control *wbc,
91234 struct file *swap_file = sis->swap_file;
91235 struct address_space *mapping = swap_file->f_mapping;
91236 struct iovec iov = {
91237 - .iov_base = kmap(page),
91238 + .iov_base = (void __force_user *)kmap(page),
91239 .iov_len = PAGE_SIZE,
91240 };
91241
91242 diff --git a/mm/percpu.c b/mm/percpu.c
91243 index 8c8e08f..73a5cda 100644
91244 --- a/mm/percpu.c
91245 +++ b/mm/percpu.c
91246 @@ -122,7 +122,7 @@ static unsigned int pcpu_low_unit_cpu __read_mostly;
91247 static unsigned int pcpu_high_unit_cpu __read_mostly;
91248
91249 /* the address of the first chunk which starts with the kernel static area */
91250 -void *pcpu_base_addr __read_mostly;
91251 +void *pcpu_base_addr __read_only;
91252 EXPORT_SYMBOL_GPL(pcpu_base_addr);
91253
91254 static const int *pcpu_unit_map __read_mostly; /* cpu -> unit */
91255 diff --git a/mm/process_vm_access.c b/mm/process_vm_access.c
91256 index fd26d04..0cea1b0 100644
91257 --- a/mm/process_vm_access.c
91258 +++ b/mm/process_vm_access.c
91259 @@ -13,6 +13,7 @@
91260 #include <linux/uio.h>
91261 #include <linux/sched.h>
91262 #include <linux/highmem.h>
91263 +#include <linux/security.h>
91264 #include <linux/ptrace.h>
91265 #include <linux/slab.h>
91266 #include <linux/syscalls.h>
91267 @@ -258,19 +259,19 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
91268 size_t iov_l_curr_offset = 0;
91269 ssize_t iov_len;
91270
91271 + return -ENOSYS; // PaX: until properly audited
91272 +
91273 /*
91274 * Work out how many pages of struct pages we're going to need
91275 * when eventually calling get_user_pages
91276 */
91277 for (i = 0; i < riovcnt; i++) {
91278 iov_len = rvec[i].iov_len;
91279 - if (iov_len > 0) {
91280 - nr_pages_iov = ((unsigned long)rvec[i].iov_base
91281 - + iov_len)
91282 - / PAGE_SIZE - (unsigned long)rvec[i].iov_base
91283 - / PAGE_SIZE + 1;
91284 - nr_pages = max(nr_pages, nr_pages_iov);
91285 - }
91286 + if (iov_len <= 0)
91287 + continue;
91288 + nr_pages_iov = ((unsigned long)rvec[i].iov_base + iov_len) / PAGE_SIZE -
91289 + (unsigned long)rvec[i].iov_base / PAGE_SIZE + 1;
91290 + nr_pages = max(nr_pages, nr_pages_iov);
91291 }
91292
91293 if (nr_pages == 0)
91294 @@ -298,6 +299,11 @@ static ssize_t process_vm_rw_core(pid_t pid, const struct iovec *lvec,
91295 goto free_proc_pages;
91296 }
91297
91298 + if (gr_handle_ptrace(task, vm_write ? PTRACE_POKETEXT : PTRACE_ATTACH)) {
91299 + rc = -EPERM;
91300 + goto put_task_struct;
91301 + }
91302 +
91303 mm = mm_access(task, PTRACE_MODE_ATTACH);
91304 if (!mm || IS_ERR(mm)) {
91305 rc = IS_ERR(mm) ? PTR_ERR(mm) : -ESRCH;
91306 diff --git a/mm/rmap.c b/mm/rmap.c
91307 index b9d2222..e4baa1f 100644
91308 --- a/mm/rmap.c
91309 +++ b/mm/rmap.c
91310 @@ -163,6 +163,10 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91311 struct anon_vma *anon_vma = vma->anon_vma;
91312 struct anon_vma_chain *avc;
91313
91314 +#ifdef CONFIG_PAX_SEGMEXEC
91315 + struct anon_vma_chain *avc_m = NULL;
91316 +#endif
91317 +
91318 might_sleep();
91319 if (unlikely(!anon_vma)) {
91320 struct mm_struct *mm = vma->vm_mm;
91321 @@ -172,6 +176,12 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91322 if (!avc)
91323 goto out_enomem;
91324
91325 +#ifdef CONFIG_PAX_SEGMEXEC
91326 + avc_m = anon_vma_chain_alloc(GFP_KERNEL);
91327 + if (!avc_m)
91328 + goto out_enomem_free_avc;
91329 +#endif
91330 +
91331 anon_vma = find_mergeable_anon_vma(vma);
91332 allocated = NULL;
91333 if (!anon_vma) {
91334 @@ -185,6 +195,18 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91335 /* page_table_lock to protect against threads */
91336 spin_lock(&mm->page_table_lock);
91337 if (likely(!vma->anon_vma)) {
91338 +
91339 +#ifdef CONFIG_PAX_SEGMEXEC
91340 + struct vm_area_struct *vma_m = pax_find_mirror_vma(vma);
91341 +
91342 + if (vma_m) {
91343 + BUG_ON(vma_m->anon_vma);
91344 + vma_m->anon_vma = anon_vma;
91345 + anon_vma_chain_link(vma_m, avc_m, anon_vma);
91346 + avc_m = NULL;
91347 + }
91348 +#endif
91349 +
91350 vma->anon_vma = anon_vma;
91351 anon_vma_chain_link(vma, avc, anon_vma);
91352 allocated = NULL;
91353 @@ -195,12 +217,24 @@ int anon_vma_prepare(struct vm_area_struct *vma)
91354
91355 if (unlikely(allocated))
91356 put_anon_vma(allocated);
91357 +
91358 +#ifdef CONFIG_PAX_SEGMEXEC
91359 + if (unlikely(avc_m))
91360 + anon_vma_chain_free(avc_m);
91361 +#endif
91362 +
91363 if (unlikely(avc))
91364 anon_vma_chain_free(avc);
91365 }
91366 return 0;
91367
91368 out_enomem_free_avc:
91369 +
91370 +#ifdef CONFIG_PAX_SEGMEXEC
91371 + if (avc_m)
91372 + anon_vma_chain_free(avc_m);
91373 +#endif
91374 +
91375 anon_vma_chain_free(avc);
91376 out_enomem:
91377 return -ENOMEM;
91378 @@ -236,7 +270,7 @@ static inline void unlock_anon_vma_root(struct anon_vma *root)
91379 * Attach the anon_vmas from src to dst.
91380 * Returns 0 on success, -ENOMEM on failure.
91381 */
91382 -int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
91383 +int anon_vma_clone(struct vm_area_struct *dst, const struct vm_area_struct *src)
91384 {
91385 struct anon_vma_chain *avc, *pavc;
91386 struct anon_vma *root = NULL;
91387 @@ -269,7 +303,7 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
91388 * the corresponding VMA in the parent process is attached to.
91389 * Returns 0 on success, non-zero on failure.
91390 */
91391 -int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
91392 +int anon_vma_fork(struct vm_area_struct *vma, const struct vm_area_struct *pvma)
91393 {
91394 struct anon_vma_chain *avc;
91395 struct anon_vma *anon_vma;
91396 @@ -373,8 +407,10 @@ static void anon_vma_ctor(void *data)
91397 void __init anon_vma_init(void)
91398 {
91399 anon_vma_cachep = kmem_cache_create("anon_vma", sizeof(struct anon_vma),
91400 - 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC, anon_vma_ctor);
91401 - anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain, SLAB_PANIC);
91402 + 0, SLAB_DESTROY_BY_RCU|SLAB_PANIC|SLAB_NO_SANITIZE,
91403 + anon_vma_ctor);
91404 + anon_vma_chain_cachep = KMEM_CACHE(anon_vma_chain,
91405 + SLAB_PANIC|SLAB_NO_SANITIZE);
91406 }
91407
91408 /*
91409 diff --git a/mm/shmem.c b/mm/shmem.c
91410 index 8297623..6b9dfe9 100644
91411 --- a/mm/shmem.c
91412 +++ b/mm/shmem.c
91413 @@ -33,7 +33,7 @@
91414 #include <linux/swap.h>
91415 #include <linux/aio.h>
91416
91417 -static struct vfsmount *shm_mnt;
91418 +struct vfsmount *shm_mnt;
91419
91420 #ifdef CONFIG_SHMEM
91421 /*
91422 @@ -77,7 +77,7 @@ static struct vfsmount *shm_mnt;
91423 #define BOGO_DIRENT_SIZE 20
91424
91425 /* Symlink up to this size is kmalloc'ed instead of using a swappable page */
91426 -#define SHORT_SYMLINK_LEN 128
91427 +#define SHORT_SYMLINK_LEN 64
91428
91429 /*
91430 * shmem_fallocate and shmem_writepage communicate via inode->i_private
91431 @@ -2232,6 +2232,11 @@ static const struct xattr_handler *shmem_xattr_handlers[] = {
91432 static int shmem_xattr_validate(const char *name)
91433 {
91434 struct { const char *prefix; size_t len; } arr[] = {
91435 +
91436 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
91437 + { XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN},
91438 +#endif
91439 +
91440 { XATTR_SECURITY_PREFIX, XATTR_SECURITY_PREFIX_LEN },
91441 { XATTR_TRUSTED_PREFIX, XATTR_TRUSTED_PREFIX_LEN }
91442 };
91443 @@ -2287,6 +2292,15 @@ static int shmem_setxattr(struct dentry *dentry, const char *name,
91444 if (err)
91445 return err;
91446
91447 +#ifdef CONFIG_PAX_XATTR_PAX_FLAGS
91448 + if (!strncmp(name, XATTR_USER_PREFIX, XATTR_USER_PREFIX_LEN)) {
91449 + if (strcmp(name, XATTR_NAME_PAX_FLAGS))
91450 + return -EOPNOTSUPP;
91451 + if (size > 8)
91452 + return -EINVAL;
91453 + }
91454 +#endif
91455 +
91456 return simple_xattr_set(&info->xattrs, name, value, size, flags);
91457 }
91458
91459 @@ -2599,8 +2613,7 @@ int shmem_fill_super(struct super_block *sb, void *data, int silent)
91460 int err = -ENOMEM;
91461
91462 /* Round up to L1_CACHE_BYTES to resist false sharing */
91463 - sbinfo = kzalloc(max((int)sizeof(struct shmem_sb_info),
91464 - L1_CACHE_BYTES), GFP_KERNEL);
91465 + sbinfo = kzalloc(max(sizeof(struct shmem_sb_info), L1_CACHE_BYTES), GFP_KERNEL);
91466 if (!sbinfo)
91467 return -ENOMEM;
91468
91469 diff --git a/mm/slab.c b/mm/slab.c
91470 index 2580db0..0523956 100644
91471 --- a/mm/slab.c
91472 +++ b/mm/slab.c
91473 @@ -366,10 +366,12 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
91474 if ((x)->max_freeable < i) \
91475 (x)->max_freeable = i; \
91476 } while (0)
91477 -#define STATS_INC_ALLOCHIT(x) atomic_inc(&(x)->allochit)
91478 -#define STATS_INC_ALLOCMISS(x) atomic_inc(&(x)->allocmiss)
91479 -#define STATS_INC_FREEHIT(x) atomic_inc(&(x)->freehit)
91480 -#define STATS_INC_FREEMISS(x) atomic_inc(&(x)->freemiss)
91481 +#define STATS_INC_ALLOCHIT(x) atomic_inc_unchecked(&(x)->allochit)
91482 +#define STATS_INC_ALLOCMISS(x) atomic_inc_unchecked(&(x)->allocmiss)
91483 +#define STATS_INC_FREEHIT(x) atomic_inc_unchecked(&(x)->freehit)
91484 +#define STATS_INC_FREEMISS(x) atomic_inc_unchecked(&(x)->freemiss)
91485 +#define STATS_INC_SANITIZED(x) atomic_inc_unchecked(&(x)->sanitized)
91486 +#define STATS_INC_NOT_SANITIZED(x) atomic_inc_unchecked(&(x)->not_sanitized)
91487 #else
91488 #define STATS_INC_ACTIVE(x) do { } while (0)
91489 #define STATS_DEC_ACTIVE(x) do { } while (0)
91490 @@ -386,6 +388,8 @@ static void kmem_cache_node_init(struct kmem_cache_node *parent)
91491 #define STATS_INC_ALLOCMISS(x) do { } while (0)
91492 #define STATS_INC_FREEHIT(x) do { } while (0)
91493 #define STATS_INC_FREEMISS(x) do { } while (0)
91494 +#define STATS_INC_SANITIZED(x) do { } while (0)
91495 +#define STATS_INC_NOT_SANITIZED(x) do { } while (0)
91496 #endif
91497
91498 #if DEBUG
91499 @@ -477,7 +481,7 @@ static inline void *index_to_obj(struct kmem_cache *cache, struct slab *slab,
91500 * reciprocal_divide(offset, cache->reciprocal_buffer_size)
91501 */
91502 static inline unsigned int obj_to_index(const struct kmem_cache *cache,
91503 - const struct slab *slab, void *obj)
91504 + const struct slab *slab, const void *obj)
91505 {
91506 u32 offset = (obj - slab->s_mem);
91507 return reciprocal_divide(offset, cache->reciprocal_buffer_size);
91508 @@ -1571,12 +1575,12 @@ void __init kmem_cache_init(void)
91509 */
91510
91511 kmalloc_caches[INDEX_AC] = create_kmalloc_cache("kmalloc-ac",
91512 - kmalloc_size(INDEX_AC), ARCH_KMALLOC_FLAGS);
91513 + kmalloc_size(INDEX_AC), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
91514
91515 if (INDEX_AC != INDEX_NODE)
91516 kmalloc_caches[INDEX_NODE] =
91517 create_kmalloc_cache("kmalloc-node",
91518 - kmalloc_size(INDEX_NODE), ARCH_KMALLOC_FLAGS);
91519 + kmalloc_size(INDEX_NODE), SLAB_USERCOPY | ARCH_KMALLOC_FLAGS);
91520
91521 slab_early_init = 0;
91522
91523 @@ -3577,6 +3581,21 @@ static inline void __cache_free(struct kmem_cache *cachep, void *objp,
91524 struct array_cache *ac = cpu_cache_get(cachep);
91525
91526 check_irq_off();
91527 +
91528 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91529 + if (pax_sanitize_slab) {
91530 + if (!(cachep->flags & (SLAB_POISON | SLAB_NO_SANITIZE))) {
91531 + memset(objp, PAX_MEMORY_SANITIZE_VALUE, cachep->object_size);
91532 +
91533 + if (cachep->ctor)
91534 + cachep->ctor(objp);
91535 +
91536 + STATS_INC_SANITIZED(cachep);
91537 + } else
91538 + STATS_INC_NOT_SANITIZED(cachep);
91539 + }
91540 +#endif
91541 +
91542 kmemleak_free_recursive(objp, cachep->flags);
91543 objp = cache_free_debugcheck(cachep, objp, caller);
91544
91545 @@ -3805,6 +3824,7 @@ void kfree(const void *objp)
91546
91547 if (unlikely(ZERO_OR_NULL_PTR(objp)))
91548 return;
91549 + VM_BUG_ON(!virt_addr_valid(objp));
91550 local_irq_save(flags);
91551 kfree_debugcheck(objp);
91552 c = virt_to_cache(objp);
91553 @@ -4246,14 +4266,22 @@ void slabinfo_show_stats(struct seq_file *m, struct kmem_cache *cachep)
91554 }
91555 /* cpu stats */
91556 {
91557 - unsigned long allochit = atomic_read(&cachep->allochit);
91558 - unsigned long allocmiss = atomic_read(&cachep->allocmiss);
91559 - unsigned long freehit = atomic_read(&cachep->freehit);
91560 - unsigned long freemiss = atomic_read(&cachep->freemiss);
91561 + unsigned long allochit = atomic_read_unchecked(&cachep->allochit);
91562 + unsigned long allocmiss = atomic_read_unchecked(&cachep->allocmiss);
91563 + unsigned long freehit = atomic_read_unchecked(&cachep->freehit);
91564 + unsigned long freemiss = atomic_read_unchecked(&cachep->freemiss);
91565
91566 seq_printf(m, " : cpustat %6lu %6lu %6lu %6lu",
91567 allochit, allocmiss, freehit, freemiss);
91568 }
91569 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91570 + {
91571 + unsigned long sanitized = atomic_read_unchecked(&cachep->sanitized);
91572 + unsigned long not_sanitized = atomic_read_unchecked(&cachep->not_sanitized);
91573 +
91574 + seq_printf(m, " : pax %6lu %6lu", sanitized, not_sanitized);
91575 + }
91576 +#endif
91577 #endif
91578 }
91579
91580 @@ -4471,13 +4499,71 @@ static const struct file_operations proc_slabstats_operations = {
91581 static int __init slab_proc_init(void)
91582 {
91583 #ifdef CONFIG_DEBUG_SLAB_LEAK
91584 - proc_create("slab_allocators", 0, NULL, &proc_slabstats_operations);
91585 + proc_create("slab_allocators", S_IRUSR, NULL, &proc_slabstats_operations);
91586 #endif
91587 return 0;
91588 }
91589 module_init(slab_proc_init);
91590 #endif
91591
91592 +bool is_usercopy_object(const void *ptr)
91593 +{
91594 + struct page *page;
91595 + struct kmem_cache *cachep;
91596 +
91597 + if (ZERO_OR_NULL_PTR(ptr))
91598 + return false;
91599 +
91600 + if (!slab_is_available())
91601 + return false;
91602 +
91603 + if (!virt_addr_valid(ptr))
91604 + return false;
91605 +
91606 + page = virt_to_head_page(ptr);
91607 +
91608 + if (!PageSlab(page))
91609 + return false;
91610 +
91611 + cachep = page->slab_cache;
91612 + return cachep->flags & SLAB_USERCOPY;
91613 +}
91614 +
91615 +#ifdef CONFIG_PAX_USERCOPY
91616 +const char *check_heap_object(const void *ptr, unsigned long n)
91617 +{
91618 + struct page *page;
91619 + struct kmem_cache *cachep;
91620 + struct slab *slabp;
91621 + unsigned int objnr;
91622 + unsigned long offset;
91623 +
91624 + if (ZERO_OR_NULL_PTR(ptr))
91625 + return "<null>";
91626 +
91627 + if (!virt_addr_valid(ptr))
91628 + return NULL;
91629 +
91630 + page = virt_to_head_page(ptr);
91631 +
91632 + if (!PageSlab(page))
91633 + return NULL;
91634 +
91635 + cachep = page->slab_cache;
91636 + if (!(cachep->flags & SLAB_USERCOPY))
91637 + return cachep->name;
91638 +
91639 + slabp = page->slab_page;
91640 + objnr = obj_to_index(cachep, slabp, ptr);
91641 + BUG_ON(objnr >= cachep->num);
91642 + offset = ptr - index_to_obj(cachep, slabp, objnr) - obj_offset(cachep);
91643 + if (offset <= cachep->object_size && n <= cachep->object_size - offset)
91644 + return NULL;
91645 +
91646 + return cachep->name;
91647 +}
91648 +#endif
91649 +
91650 /**
91651 * ksize - get the actual amount of memory allocated for a given object
91652 * @objp: Pointer to the object
91653 diff --git a/mm/slab.h b/mm/slab.h
91654 index a535033..2f98fe5 100644
91655 --- a/mm/slab.h
91656 +++ b/mm/slab.h
91657 @@ -32,6 +32,15 @@ extern struct list_head slab_caches;
91658 /* The slab cache that manages slab cache information */
91659 extern struct kmem_cache *kmem_cache;
91660
91661 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91662 +#ifdef CONFIG_X86_64
91663 +#define PAX_MEMORY_SANITIZE_VALUE '\xfe'
91664 +#else
91665 +#define PAX_MEMORY_SANITIZE_VALUE '\xff'
91666 +#endif
91667 +extern bool pax_sanitize_slab;
91668 +#endif
91669 +
91670 unsigned long calculate_alignment(unsigned long flags,
91671 unsigned long align, unsigned long size);
91672
91673 @@ -67,7 +76,8 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
91674
91675 /* Legal flag mask for kmem_cache_create(), for various configurations */
91676 #define SLAB_CORE_FLAGS (SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA | SLAB_PANIC | \
91677 - SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS )
91678 + SLAB_DESTROY_BY_RCU | SLAB_DEBUG_OBJECTS | \
91679 + SLAB_USERCOPY | SLAB_NO_SANITIZE)
91680
91681 #if defined(CONFIG_DEBUG_SLAB)
91682 #define SLAB_DEBUG_FLAGS (SLAB_RED_ZONE | SLAB_POISON | SLAB_STORE_USER)
91683 @@ -231,6 +241,9 @@ static inline struct kmem_cache *cache_from_obj(struct kmem_cache *s, void *x)
91684 return s;
91685
91686 page = virt_to_head_page(x);
91687 +
91688 + BUG_ON(!PageSlab(page));
91689 +
91690 cachep = page->slab_cache;
91691 if (slab_equal_or_root(cachep, s))
91692 return cachep;
91693 diff --git a/mm/slab_common.c b/mm/slab_common.c
91694 index e2e98af..3b1a163 100644
91695 --- a/mm/slab_common.c
91696 +++ b/mm/slab_common.c
91697 @@ -23,11 +23,22 @@
91698
91699 #include "slab.h"
91700
91701 -enum slab_state slab_state;
91702 +enum slab_state slab_state __read_only;
91703 LIST_HEAD(slab_caches);
91704 DEFINE_MUTEX(slab_mutex);
91705 struct kmem_cache *kmem_cache;
91706
91707 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91708 +bool pax_sanitize_slab __read_only = true;
91709 +static int __init pax_sanitize_slab_setup(char *str)
91710 +{
91711 + pax_sanitize_slab = !!simple_strtol(str, NULL, 0);
91712 + printk("%sabled PaX slab sanitization\n", pax_sanitize_slab ? "En" : "Dis");
91713 + return 1;
91714 +}
91715 +__setup("pax_sanitize_slab=", pax_sanitize_slab_setup);
91716 +#endif
91717 +
91718 #ifdef CONFIG_DEBUG_VM
91719 static int kmem_cache_sanity_check(struct mem_cgroup *memcg, const char *name,
91720 size_t size)
91721 @@ -212,7 +223,7 @@ kmem_cache_create_memcg(struct mem_cgroup *memcg, const char *name, size_t size,
91722
91723 err = __kmem_cache_create(s, flags);
91724 if (!err) {
91725 - s->refcount = 1;
91726 + atomic_set(&s->refcount, 1);
91727 list_add(&s->list, &slab_caches);
91728 memcg_cache_list_add(memcg, s);
91729 } else {
91730 @@ -258,8 +269,7 @@ void kmem_cache_destroy(struct kmem_cache *s)
91731
91732 get_online_cpus();
91733 mutex_lock(&slab_mutex);
91734 - s->refcount--;
91735 - if (!s->refcount) {
91736 + if (atomic_dec_and_test(&s->refcount)) {
91737 list_del(&s->list);
91738
91739 if (!__kmem_cache_shutdown(s)) {
91740 @@ -305,7 +315,7 @@ void __init create_boot_cache(struct kmem_cache *s, const char *name, size_t siz
91741 panic("Creation of kmalloc slab %s size=%zu failed. Reason %d\n",
91742 name, size, err);
91743
91744 - s->refcount = -1; /* Exempt from merging for now */
91745 + atomic_set(&s->refcount, -1); /* Exempt from merging for now */
91746 }
91747
91748 struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
91749 @@ -318,7 +328,7 @@ struct kmem_cache *__init create_kmalloc_cache(const char *name, size_t size,
91750
91751 create_boot_cache(s, name, size, flags);
91752 list_add(&s->list, &slab_caches);
91753 - s->refcount = 1;
91754 + atomic_set(&s->refcount, 1);
91755 return s;
91756 }
91757
91758 @@ -330,6 +340,11 @@ struct kmem_cache *kmalloc_dma_caches[KMALLOC_SHIFT_HIGH + 1];
91759 EXPORT_SYMBOL(kmalloc_dma_caches);
91760 #endif
91761
91762 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91763 +struct kmem_cache *kmalloc_usercopy_caches[KMALLOC_SHIFT_HIGH + 1];
91764 +EXPORT_SYMBOL(kmalloc_usercopy_caches);
91765 +#endif
91766 +
91767 /*
91768 * Conversion table for small slabs sizes / 8 to the index in the
91769 * kmalloc array. This is necessary for slabs < 192 since we have non power
91770 @@ -394,6 +409,13 @@ struct kmem_cache *kmalloc_slab(size_t size, gfp_t flags)
91771 return kmalloc_dma_caches[index];
91772
91773 #endif
91774 +
91775 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91776 + if (unlikely((flags & GFP_USERCOPY)))
91777 + return kmalloc_usercopy_caches[index];
91778 +
91779 +#endif
91780 +
91781 return kmalloc_caches[index];
91782 }
91783
91784 @@ -450,7 +472,7 @@ void __init create_kmalloc_caches(unsigned long flags)
91785 for (i = KMALLOC_SHIFT_LOW; i <= KMALLOC_SHIFT_HIGH; i++) {
91786 if (!kmalloc_caches[i]) {
91787 kmalloc_caches[i] = create_kmalloc_cache(NULL,
91788 - 1 << i, flags);
91789 + 1 << i, SLAB_USERCOPY | flags);
91790 }
91791
91792 /*
91793 @@ -459,10 +481,10 @@ void __init create_kmalloc_caches(unsigned long flags)
91794 * earlier power of two caches
91795 */
91796 if (KMALLOC_MIN_SIZE <= 32 && !kmalloc_caches[1] && i == 6)
91797 - kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, flags);
91798 + kmalloc_caches[1] = create_kmalloc_cache(NULL, 96, SLAB_USERCOPY | flags);
91799
91800 if (KMALLOC_MIN_SIZE <= 64 && !kmalloc_caches[2] && i == 7)
91801 - kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, flags);
91802 + kmalloc_caches[2] = create_kmalloc_cache(NULL, 192, SLAB_USERCOPY | flags);
91803 }
91804
91805 /* Kmalloc array is now usable */
91806 @@ -495,6 +517,23 @@ void __init create_kmalloc_caches(unsigned long flags)
91807 }
91808 }
91809 #endif
91810 +
91811 +#ifdef CONFIG_PAX_USERCOPY_SLABS
91812 + for (i = 0; i <= KMALLOC_SHIFT_HIGH; i++) {
91813 + struct kmem_cache *s = kmalloc_caches[i];
91814 +
91815 + if (s) {
91816 + int size = kmalloc_size(i);
91817 + char *n = kasprintf(GFP_NOWAIT,
91818 + "usercopy-kmalloc-%d", size);
91819 +
91820 + BUG_ON(!n);
91821 + kmalloc_usercopy_caches[i] = create_kmalloc_cache(n,
91822 + size, SLAB_USERCOPY | flags);
91823 + }
91824 + }
91825 +#endif
91826 +
91827 }
91828 #endif /* !CONFIG_SLOB */
91829
91830 @@ -535,6 +574,9 @@ void print_slabinfo_header(struct seq_file *m)
91831 seq_puts(m, " : globalstat <listallocs> <maxobjs> <grown> <reaped> "
91832 "<error> <maxfreeable> <nodeallocs> <remotefrees> <alienoverflow>");
91833 seq_puts(m, " : cpustat <allochit> <allocmiss> <freehit> <freemiss>");
91834 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91835 + seq_puts(m, " : pax <sanitized> <not_sanitized>");
91836 +#endif
91837 #endif
91838 seq_putc(m, '\n');
91839 }
91840 diff --git a/mm/slob.c b/mm/slob.c
91841 index 4bf8809..98a6914 100644
91842 --- a/mm/slob.c
91843 +++ b/mm/slob.c
91844 @@ -157,7 +157,7 @@ static void set_slob(slob_t *s, slobidx_t size, slob_t *next)
91845 /*
91846 * Return the size of a slob block.
91847 */
91848 -static slobidx_t slob_units(slob_t *s)
91849 +static slobidx_t slob_units(const slob_t *s)
91850 {
91851 if (s->units > 0)
91852 return s->units;
91853 @@ -167,7 +167,7 @@ static slobidx_t slob_units(slob_t *s)
91854 /*
91855 * Return the next free slob block pointer after this one.
91856 */
91857 -static slob_t *slob_next(slob_t *s)
91858 +static slob_t *slob_next(const slob_t *s)
91859 {
91860 slob_t *base = (slob_t *)((unsigned long)s & PAGE_MASK);
91861 slobidx_t next;
91862 @@ -182,14 +182,14 @@ static slob_t *slob_next(slob_t *s)
91863 /*
91864 * Returns true if s is the last free block in its page.
91865 */
91866 -static int slob_last(slob_t *s)
91867 +static int slob_last(const slob_t *s)
91868 {
91869 return !((unsigned long)slob_next(s) & ~PAGE_MASK);
91870 }
91871
91872 -static void *slob_new_pages(gfp_t gfp, int order, int node)
91873 +static struct page *slob_new_pages(gfp_t gfp, unsigned int order, int node)
91874 {
91875 - void *page;
91876 + struct page *page;
91877
91878 #ifdef CONFIG_NUMA
91879 if (node != NUMA_NO_NODE)
91880 @@ -201,14 +201,18 @@ static void *slob_new_pages(gfp_t gfp, int order, int node)
91881 if (!page)
91882 return NULL;
91883
91884 - return page_address(page);
91885 + __SetPageSlab(page);
91886 + return page;
91887 }
91888
91889 -static void slob_free_pages(void *b, int order)
91890 +static void slob_free_pages(struct page *sp, int order)
91891 {
91892 if (current->reclaim_state)
91893 current->reclaim_state->reclaimed_slab += 1 << order;
91894 - free_pages((unsigned long)b, order);
91895 + __ClearPageSlab(sp);
91896 + page_mapcount_reset(sp);
91897 + sp->private = 0;
91898 + __free_pages(sp, order);
91899 }
91900
91901 /*
91902 @@ -313,15 +317,15 @@ static void *slob_alloc(size_t size, gfp_t gfp, int align, int node)
91903
91904 /* Not enough space: must allocate a new page */
91905 if (!b) {
91906 - b = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91907 - if (!b)
91908 + sp = slob_new_pages(gfp & ~__GFP_ZERO, 0, node);
91909 + if (!sp)
91910 return NULL;
91911 - sp = virt_to_page(b);
91912 - __SetPageSlab(sp);
91913 + b = page_address(sp);
91914
91915 spin_lock_irqsave(&slob_lock, flags);
91916 sp->units = SLOB_UNITS(PAGE_SIZE);
91917 sp->freelist = b;
91918 + sp->private = 0;
91919 INIT_LIST_HEAD(&sp->list);
91920 set_slob(b, SLOB_UNITS(PAGE_SIZE), b + SLOB_UNITS(PAGE_SIZE));
91921 set_slob_page_free(sp, slob_list);
91922 @@ -359,12 +363,15 @@ static void slob_free(void *block, int size)
91923 if (slob_page_free(sp))
91924 clear_slob_page_free(sp);
91925 spin_unlock_irqrestore(&slob_lock, flags);
91926 - __ClearPageSlab(sp);
91927 - page_mapcount_reset(sp);
91928 - slob_free_pages(b, 0);
91929 + slob_free_pages(sp, 0);
91930 return;
91931 }
91932
91933 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
91934 + if (pax_sanitize_slab)
91935 + memset(block, PAX_MEMORY_SANITIZE_VALUE, size);
91936 +#endif
91937 +
91938 if (!slob_page_free(sp)) {
91939 /* This slob page is about to become partially free. Easy! */
91940 sp->units = units;
91941 @@ -424,11 +431,10 @@ out:
91942 */
91943
91944 static __always_inline void *
91945 -__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91946 +__do_kmalloc_node_align(size_t size, gfp_t gfp, int node, unsigned long caller, int align)
91947 {
91948 - unsigned int *m;
91949 - int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91950 - void *ret;
91951 + slob_t *m;
91952 + void *ret = NULL;
91953
91954 gfp &= gfp_allowed_mask;
91955
91956 @@ -442,23 +448,41 @@ __do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91957
91958 if (!m)
91959 return NULL;
91960 - *m = size;
91961 + BUILD_BUG_ON(ARCH_KMALLOC_MINALIGN < 2 * SLOB_UNIT);
91962 + BUILD_BUG_ON(ARCH_SLAB_MINALIGN < 2 * SLOB_UNIT);
91963 + m[0].units = size;
91964 + m[1].units = align;
91965 ret = (void *)m + align;
91966
91967 trace_kmalloc_node(caller, ret,
91968 size, size + align, gfp, node);
91969 } else {
91970 unsigned int order = get_order(size);
91971 + struct page *page;
91972
91973 if (likely(order))
91974 gfp |= __GFP_COMP;
91975 - ret = slob_new_pages(gfp, order, node);
91976 + page = slob_new_pages(gfp, order, node);
91977 + if (page) {
91978 + ret = page_address(page);
91979 + page->private = size;
91980 + }
91981
91982 trace_kmalloc_node(caller, ret,
91983 size, PAGE_SIZE << order, gfp, node);
91984 }
91985
91986 - kmemleak_alloc(ret, size, 1, gfp);
91987 + return ret;
91988 +}
91989 +
91990 +static __always_inline void *
91991 +__do_kmalloc_node(size_t size, gfp_t gfp, int node, unsigned long caller)
91992 +{
91993 + int align = max(ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
91994 + void *ret = __do_kmalloc_node_align(size, gfp, node, caller, align);
91995 +
91996 + if (!ZERO_OR_NULL_PTR(ret))
91997 + kmemleak_alloc(ret, size, 1, gfp);
91998 return ret;
91999 }
92000
92001 @@ -493,34 +517,112 @@ void kfree(const void *block)
92002 return;
92003 kmemleak_free(block);
92004
92005 + VM_BUG_ON(!virt_addr_valid(block));
92006 sp = virt_to_page(block);
92007 - if (PageSlab(sp)) {
92008 + VM_BUG_ON(!PageSlab(sp));
92009 + if (!sp->private) {
92010 int align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
92011 - unsigned int *m = (unsigned int *)(block - align);
92012 - slob_free(m, *m + align);
92013 - } else
92014 + slob_t *m = (slob_t *)(block - align);
92015 + slob_free(m, m[0].units + align);
92016 + } else {
92017 + __ClearPageSlab(sp);
92018 + page_mapcount_reset(sp);
92019 + sp->private = 0;
92020 __free_pages(sp, compound_order(sp));
92021 + }
92022 }
92023 EXPORT_SYMBOL(kfree);
92024
92025 +bool is_usercopy_object(const void *ptr)
92026 +{
92027 + if (!slab_is_available())
92028 + return false;
92029 +
92030 + // PAX: TODO
92031 +
92032 + return false;
92033 +}
92034 +
92035 +#ifdef CONFIG_PAX_USERCOPY
92036 +const char *check_heap_object(const void *ptr, unsigned long n)
92037 +{
92038 + struct page *page;
92039 + const slob_t *free;
92040 + const void *base;
92041 + unsigned long flags;
92042 +
92043 + if (ZERO_OR_NULL_PTR(ptr))
92044 + return "<null>";
92045 +
92046 + if (!virt_addr_valid(ptr))
92047 + return NULL;
92048 +
92049 + page = virt_to_head_page(ptr);
92050 + if (!PageSlab(page))
92051 + return NULL;
92052 +
92053 + if (page->private) {
92054 + base = page;
92055 + if (base <= ptr && n <= page->private - (ptr - base))
92056 + return NULL;
92057 + return "<slob>";
92058 + }
92059 +
92060 + /* some tricky double walking to find the chunk */
92061 + spin_lock_irqsave(&slob_lock, flags);
92062 + base = (void *)((unsigned long)ptr & PAGE_MASK);
92063 + free = page->freelist;
92064 +
92065 + while (!slob_last(free) && (void *)free <= ptr) {
92066 + base = free + slob_units(free);
92067 + free = slob_next(free);
92068 + }
92069 +
92070 + while (base < (void *)free) {
92071 + slobidx_t m = ((slob_t *)base)[0].units, align = ((slob_t *)base)[1].units;
92072 + int size = SLOB_UNIT * SLOB_UNITS(m + align);
92073 + int offset;
92074 +
92075 + if (ptr < base + align)
92076 + break;
92077 +
92078 + offset = ptr - base - align;
92079 + if (offset >= m) {
92080 + base += size;
92081 + continue;
92082 + }
92083 +
92084 + if (n > m - offset)
92085 + break;
92086 +
92087 + spin_unlock_irqrestore(&slob_lock, flags);
92088 + return NULL;
92089 + }
92090 +
92091 + spin_unlock_irqrestore(&slob_lock, flags);
92092 + return "<slob>";
92093 +}
92094 +#endif
92095 +
92096 /* can't use ksize for kmem_cache_alloc memory, only kmalloc */
92097 size_t ksize(const void *block)
92098 {
92099 struct page *sp;
92100 int align;
92101 - unsigned int *m;
92102 + slob_t *m;
92103
92104 BUG_ON(!block);
92105 if (unlikely(block == ZERO_SIZE_PTR))
92106 return 0;
92107
92108 sp = virt_to_page(block);
92109 - if (unlikely(!PageSlab(sp)))
92110 - return PAGE_SIZE << compound_order(sp);
92111 + VM_BUG_ON(!PageSlab(sp));
92112 + if (sp->private)
92113 + return sp->private;
92114
92115 align = max_t(size_t, ARCH_KMALLOC_MINALIGN, ARCH_SLAB_MINALIGN);
92116 - m = (unsigned int *)(block - align);
92117 - return SLOB_UNITS(*m) * SLOB_UNIT;
92118 + m = (slob_t *)(block - align);
92119 + return SLOB_UNITS(m[0].units) * SLOB_UNIT;
92120 }
92121 EXPORT_SYMBOL(ksize);
92122
92123 @@ -536,23 +638,33 @@ int __kmem_cache_create(struct kmem_cache *c, unsigned long flags)
92124
92125 void *slob_alloc_node(struct kmem_cache *c, gfp_t flags, int node)
92126 {
92127 - void *b;
92128 + void *b = NULL;
92129
92130 flags &= gfp_allowed_mask;
92131
92132 lockdep_trace_alloc(flags);
92133
92134 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92135 + b = __do_kmalloc_node_align(c->size, flags, node, _RET_IP_, c->align);
92136 +#else
92137 if (c->size < PAGE_SIZE) {
92138 b = slob_alloc(c->size, flags, c->align, node);
92139 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
92140 SLOB_UNITS(c->size) * SLOB_UNIT,
92141 flags, node);
92142 } else {
92143 - b = slob_new_pages(flags, get_order(c->size), node);
92144 + struct page *sp;
92145 +
92146 + sp = slob_new_pages(flags, get_order(c->size), node);
92147 + if (sp) {
92148 + b = page_address(sp);
92149 + sp->private = c->size;
92150 + }
92151 trace_kmem_cache_alloc_node(_RET_IP_, b, c->object_size,
92152 PAGE_SIZE << get_order(c->size),
92153 flags, node);
92154 }
92155 +#endif
92156
92157 if (b && c->ctor)
92158 c->ctor(b);
92159 @@ -584,10 +696,14 @@ EXPORT_SYMBOL(kmem_cache_alloc_node);
92160
92161 static void __kmem_cache_free(void *b, int size)
92162 {
92163 - if (size < PAGE_SIZE)
92164 + struct page *sp;
92165 +
92166 + sp = virt_to_page(b);
92167 + BUG_ON(!PageSlab(sp));
92168 + if (!sp->private)
92169 slob_free(b, size);
92170 else
92171 - slob_free_pages(b, get_order(size));
92172 + slob_free_pages(sp, get_order(size));
92173 }
92174
92175 static void kmem_rcu_free(struct rcu_head *head)
92176 @@ -600,17 +716,31 @@ static void kmem_rcu_free(struct rcu_head *head)
92177
92178 void kmem_cache_free(struct kmem_cache *c, void *b)
92179 {
92180 + int size = c->size;
92181 +
92182 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92183 + if (size + c->align < PAGE_SIZE) {
92184 + size += c->align;
92185 + b -= c->align;
92186 + }
92187 +#endif
92188 +
92189 kmemleak_free_recursive(b, c->flags);
92190 if (unlikely(c->flags & SLAB_DESTROY_BY_RCU)) {
92191 struct slob_rcu *slob_rcu;
92192 - slob_rcu = b + (c->size - sizeof(struct slob_rcu));
92193 - slob_rcu->size = c->size;
92194 + slob_rcu = b + (size - sizeof(struct slob_rcu));
92195 + slob_rcu->size = size;
92196 call_rcu(&slob_rcu->head, kmem_rcu_free);
92197 } else {
92198 - __kmem_cache_free(b, c->size);
92199 + __kmem_cache_free(b, size);
92200 }
92201
92202 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92203 + trace_kfree(_RET_IP_, b);
92204 +#else
92205 trace_kmem_cache_free(_RET_IP_, b);
92206 +#endif
92207 +
92208 }
92209 EXPORT_SYMBOL(kmem_cache_free);
92210
92211 diff --git a/mm/slub.c b/mm/slub.c
92212 index 96f2169..9111a59 100644
92213 --- a/mm/slub.c
92214 +++ b/mm/slub.c
92215 @@ -207,7 +207,7 @@ struct track {
92216
92217 enum track_item { TRACK_ALLOC, TRACK_FREE };
92218
92219 -#ifdef CONFIG_SYSFS
92220 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92221 static int sysfs_slab_add(struct kmem_cache *);
92222 static int sysfs_slab_alias(struct kmem_cache *, const char *);
92223 static void sysfs_slab_remove(struct kmem_cache *);
92224 @@ -530,7 +530,7 @@ static void print_track(const char *s, struct track *t)
92225 if (!t->addr)
92226 return;
92227
92228 - printk(KERN_ERR "INFO: %s in %pS age=%lu cpu=%u pid=%d\n",
92229 + printk(KERN_ERR "INFO: %s in %pA age=%lu cpu=%u pid=%d\n",
92230 s, (void *)t->addr, jiffies - t->when, t->cpu, t->pid);
92231 #ifdef CONFIG_STACKTRACE
92232 {
92233 @@ -2616,6 +2616,14 @@ static __always_inline void slab_free(struct kmem_cache *s,
92234
92235 slab_free_hook(s, x);
92236
92237 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92238 + if (pax_sanitize_slab && !(s->flags & SLAB_NO_SANITIZE)) {
92239 + memset(x, PAX_MEMORY_SANITIZE_VALUE, s->object_size);
92240 + if (s->ctor)
92241 + s->ctor(x);
92242 + }
92243 +#endif
92244 +
92245 redo:
92246 /*
92247 * Determine the currently cpus per cpu slab.
92248 @@ -2683,7 +2691,7 @@ static int slub_min_objects;
92249 * Merge control. If this is set then no merging of slab caches will occur.
92250 * (Could be removed. This was introduced to pacify the merge skeptics.)
92251 */
92252 -static int slub_nomerge;
92253 +static int slub_nomerge = 1;
92254
92255 /*
92256 * Calculate the order of allocation given an slab object size.
92257 @@ -2960,6 +2968,9 @@ static int calculate_sizes(struct kmem_cache *s, int forced_order)
92258 s->inuse = size;
92259
92260 if (((flags & (SLAB_DESTROY_BY_RCU | SLAB_POISON)) ||
92261 +#ifdef CONFIG_PAX_MEMORY_SANITIZE
92262 + (pax_sanitize_slab && !(flags & SLAB_NO_SANITIZE)) ||
92263 +#endif
92264 s->ctor)) {
92265 /*
92266 * Relocate free pointer after the object if it is not
92267 @@ -3305,6 +3316,59 @@ void *__kmalloc_node(size_t size, gfp_t flags, int node)
92268 EXPORT_SYMBOL(__kmalloc_node);
92269 #endif
92270
92271 +bool is_usercopy_object(const void *ptr)
92272 +{
92273 + struct page *page;
92274 + struct kmem_cache *s;
92275 +
92276 + if (ZERO_OR_NULL_PTR(ptr))
92277 + return false;
92278 +
92279 + if (!slab_is_available())
92280 + return false;
92281 +
92282 + if (!virt_addr_valid(ptr))
92283 + return false;
92284 +
92285 + page = virt_to_head_page(ptr);
92286 +
92287 + if (!PageSlab(page))
92288 + return false;
92289 +
92290 + s = page->slab_cache;
92291 + return s->flags & SLAB_USERCOPY;
92292 +}
92293 +
92294 +#ifdef CONFIG_PAX_USERCOPY
92295 +const char *check_heap_object(const void *ptr, unsigned long n)
92296 +{
92297 + struct page *page;
92298 + struct kmem_cache *s;
92299 + unsigned long offset;
92300 +
92301 + if (ZERO_OR_NULL_PTR(ptr))
92302 + return "<null>";
92303 +
92304 + if (!virt_addr_valid(ptr))
92305 + return NULL;
92306 +
92307 + page = virt_to_head_page(ptr);
92308 +
92309 + if (!PageSlab(page))
92310 + return NULL;
92311 +
92312 + s = page->slab_cache;
92313 + if (!(s->flags & SLAB_USERCOPY))
92314 + return s->name;
92315 +
92316 + offset = (ptr - page_address(page)) % s->size;
92317 + if (offset <= s->object_size && n <= s->object_size - offset)
92318 + return NULL;
92319 +
92320 + return s->name;
92321 +}
92322 +#endif
92323 +
92324 size_t ksize(const void *object)
92325 {
92326 struct page *page;
92327 @@ -3333,6 +3397,7 @@ void kfree(const void *x)
92328 if (unlikely(ZERO_OR_NULL_PTR(x)))
92329 return;
92330
92331 + VM_BUG_ON(!virt_addr_valid(x));
92332 page = virt_to_head_page(x);
92333 if (unlikely(!PageSlab(page))) {
92334 BUG_ON(!PageCompound(page));
92335 @@ -3638,7 +3703,7 @@ static int slab_unmergeable(struct kmem_cache *s)
92336 /*
92337 * We may have set a slab to be unmergeable during bootstrap.
92338 */
92339 - if (s->refcount < 0)
92340 + if (atomic_read(&s->refcount) < 0)
92341 return 1;
92342
92343 return 0;
92344 @@ -3696,7 +3761,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
92345
92346 s = find_mergeable(memcg, size, align, flags, name, ctor);
92347 if (s) {
92348 - s->refcount++;
92349 + atomic_inc(&s->refcount);
92350 /*
92351 * Adjust the object sizes so that we clear
92352 * the complete object on kzalloc.
92353 @@ -3705,7 +3770,7 @@ __kmem_cache_alias(struct mem_cgroup *memcg, const char *name, size_t size,
92354 s->inuse = max_t(int, s->inuse, ALIGN(size, sizeof(void *)));
92355
92356 if (sysfs_slab_alias(s, name)) {
92357 - s->refcount--;
92358 + atomic_dec(&s->refcount);
92359 s = NULL;
92360 }
92361 }
92362 @@ -3825,7 +3890,7 @@ void *__kmalloc_node_track_caller(size_t size, gfp_t gfpflags,
92363 }
92364 #endif
92365
92366 -#ifdef CONFIG_SYSFS
92367 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92368 static int count_inuse(struct page *page)
92369 {
92370 return page->inuse;
92371 @@ -4214,12 +4279,12 @@ static void resiliency_test(void)
92372 validate_slab_cache(kmalloc_caches[9]);
92373 }
92374 #else
92375 -#ifdef CONFIG_SYSFS
92376 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92377 static void resiliency_test(void) {};
92378 #endif
92379 #endif
92380
92381 -#ifdef CONFIG_SYSFS
92382 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92383 enum slab_stat_type {
92384 SL_ALL, /* All slabs */
92385 SL_PARTIAL, /* Only partially allocated slabs */
92386 @@ -4459,7 +4524,7 @@ SLAB_ATTR_RO(ctor);
92387
92388 static ssize_t aliases_show(struct kmem_cache *s, char *buf)
92389 {
92390 - return sprintf(buf, "%d\n", s->refcount - 1);
92391 + return sprintf(buf, "%d\n", atomic_read(&s->refcount) - 1);
92392 }
92393 SLAB_ATTR_RO(aliases);
92394
92395 @@ -4547,6 +4612,14 @@ static ssize_t cache_dma_show(struct kmem_cache *s, char *buf)
92396 SLAB_ATTR_RO(cache_dma);
92397 #endif
92398
92399 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92400 +static ssize_t usercopy_show(struct kmem_cache *s, char *buf)
92401 +{
92402 + return sprintf(buf, "%d\n", !!(s->flags & SLAB_USERCOPY));
92403 +}
92404 +SLAB_ATTR_RO(usercopy);
92405 +#endif
92406 +
92407 static ssize_t destroy_by_rcu_show(struct kmem_cache *s, char *buf)
92408 {
92409 return sprintf(buf, "%d\n", !!(s->flags & SLAB_DESTROY_BY_RCU));
92410 @@ -4881,6 +4954,9 @@ static struct attribute *slab_attrs[] = {
92411 #ifdef CONFIG_ZONE_DMA
92412 &cache_dma_attr.attr,
92413 #endif
92414 +#ifdef CONFIG_PAX_USERCOPY_SLABS
92415 + &usercopy_attr.attr,
92416 +#endif
92417 #ifdef CONFIG_NUMA
92418 &remote_node_defrag_ratio_attr.attr,
92419 #endif
92420 @@ -5113,6 +5189,7 @@ static char *create_unique_id(struct kmem_cache *s)
92421 return name;
92422 }
92423
92424 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92425 static int sysfs_slab_add(struct kmem_cache *s)
92426 {
92427 int err;
92428 @@ -5136,7 +5213,7 @@ static int sysfs_slab_add(struct kmem_cache *s)
92429 }
92430
92431 s->kobj.kset = slab_kset;
92432 - err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, name);
92433 + err = kobject_init_and_add(&s->kobj, &slab_ktype, NULL, "%s", name);
92434 if (err) {
92435 kobject_put(&s->kobj);
92436 return err;
92437 @@ -5170,6 +5247,7 @@ static void sysfs_slab_remove(struct kmem_cache *s)
92438 kobject_del(&s->kobj);
92439 kobject_put(&s->kobj);
92440 }
92441 +#endif
92442
92443 /*
92444 * Need to buffer aliases during bootup until sysfs becomes
92445 @@ -5183,6 +5261,7 @@ struct saved_alias {
92446
92447 static struct saved_alias *alias_list;
92448
92449 +#if defined(CONFIG_SYSFS) && !defined(CONFIG_GRKERNSEC_PROC_ADD)
92450 static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
92451 {
92452 struct saved_alias *al;
92453 @@ -5205,6 +5284,7 @@ static int sysfs_slab_alias(struct kmem_cache *s, const char *name)
92454 alias_list = al;
92455 return 0;
92456 }
92457 +#endif
92458
92459 static int __init slab_sysfs_init(void)
92460 {
92461 diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c
92462 index 27eeab3..7c3f7f2 100644
92463 --- a/mm/sparse-vmemmap.c
92464 +++ b/mm/sparse-vmemmap.c
92465 @@ -130,7 +130,7 @@ pud_t * __meminit vmemmap_pud_populate(pgd_t *pgd, unsigned long addr, int node)
92466 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
92467 if (!p)
92468 return NULL;
92469 - pud_populate(&init_mm, pud, p);
92470 + pud_populate_kernel(&init_mm, pud, p);
92471 }
92472 return pud;
92473 }
92474 @@ -142,7 +142,7 @@ pgd_t * __meminit vmemmap_pgd_populate(unsigned long addr, int node)
92475 void *p = vmemmap_alloc_block(PAGE_SIZE, node);
92476 if (!p)
92477 return NULL;
92478 - pgd_populate(&init_mm, pgd, p);
92479 + pgd_populate_kernel(&init_mm, pgd, p);
92480 }
92481 return pgd;
92482 }
92483 diff --git a/mm/sparse.c b/mm/sparse.c
92484 index 4ac1d7e..bbfcb1f 100644
92485 --- a/mm/sparse.c
92486 +++ b/mm/sparse.c
92487 @@ -745,7 +745,7 @@ static void clear_hwpoisoned_pages(struct page *memmap, int nr_pages)
92488
92489 for (i = 0; i < PAGES_PER_SECTION; i++) {
92490 if (PageHWPoison(&memmap[i])) {
92491 - atomic_long_sub(1, &num_poisoned_pages);
92492 + atomic_long_sub_unchecked(1, &num_poisoned_pages);
92493 ClearPageHWPoison(&memmap[i]);
92494 }
92495 }
92496 diff --git a/mm/swap.c b/mm/swap.c
92497 index 759c3ca..7c1a5b4 100644
92498 --- a/mm/swap.c
92499 +++ b/mm/swap.c
92500 @@ -77,6 +77,8 @@ static void __put_compound_page(struct page *page)
92501
92502 __page_cache_release(page);
92503 dtor = get_compound_page_dtor(page);
92504 + if (!PageHuge(page))
92505 + BUG_ON(dtor != free_compound_page);
92506 (*dtor)(page);
92507 }
92508
92509 diff --git a/mm/swapfile.c b/mm/swapfile.c
92510 index de7c904..c84bf11 100644
92511 --- a/mm/swapfile.c
92512 +++ b/mm/swapfile.c
92513 @@ -66,7 +66,7 @@ static DEFINE_MUTEX(swapon_mutex);
92514
92515 static DECLARE_WAIT_QUEUE_HEAD(proc_poll_wait);
92516 /* Activity counter to indicate that a swapon or swapoff has occurred */
92517 -static atomic_t proc_poll_event = ATOMIC_INIT(0);
92518 +static atomic_unchecked_t proc_poll_event = ATOMIC_INIT(0);
92519
92520 static inline unsigned char swap_count(unsigned char ent)
92521 {
92522 @@ -1949,7 +1949,7 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
92523 }
92524 filp_close(swap_file, NULL);
92525 err = 0;
92526 - atomic_inc(&proc_poll_event);
92527 + atomic_inc_unchecked(&proc_poll_event);
92528 wake_up_interruptible(&proc_poll_wait);
92529
92530 out_dput:
92531 @@ -1966,8 +1966,8 @@ static unsigned swaps_poll(struct file *file, poll_table *wait)
92532
92533 poll_wait(file, &proc_poll_wait, wait);
92534
92535 - if (seq->poll_event != atomic_read(&proc_poll_event)) {
92536 - seq->poll_event = atomic_read(&proc_poll_event);
92537 + if (seq->poll_event != atomic_read_unchecked(&proc_poll_event)) {
92538 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
92539 return POLLIN | POLLRDNORM | POLLERR | POLLPRI;
92540 }
92541
92542 @@ -2065,7 +2065,7 @@ static int swaps_open(struct inode *inode, struct file *file)
92543 return ret;
92544
92545 seq = file->private_data;
92546 - seq->poll_event = atomic_read(&proc_poll_event);
92547 + seq->poll_event = atomic_read_unchecked(&proc_poll_event);
92548 return 0;
92549 }
92550
92551 @@ -2524,7 +2524,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
92552 (frontswap_map) ? "FS" : "");
92553
92554 mutex_unlock(&swapon_mutex);
92555 - atomic_inc(&proc_poll_event);
92556 + atomic_inc_unchecked(&proc_poll_event);
92557 wake_up_interruptible(&proc_poll_wait);
92558
92559 if (S_ISREG(inode->i_mode))
92560 diff --git a/mm/util.c b/mm/util.c
92561 index eaf63fc2..32b2629 100644
92562 --- a/mm/util.c
92563 +++ b/mm/util.c
92564 @@ -294,6 +294,12 @@ done:
92565 void arch_pick_mmap_layout(struct mm_struct *mm)
92566 {
92567 mm->mmap_base = TASK_UNMAPPED_BASE;
92568 +
92569 +#ifdef CONFIG_PAX_RANDMMAP
92570 + if (mm->pax_flags & MF_PAX_RANDMMAP)
92571 + mm->mmap_base += mm->delta_mmap;
92572 +#endif
92573 +
92574 mm->get_unmapped_area = arch_get_unmapped_area;
92575 }
92576 #endif
92577 diff --git a/mm/vmalloc.c b/mm/vmalloc.c
92578 index 1074543..136dbe0 100644
92579 --- a/mm/vmalloc.c
92580 +++ b/mm/vmalloc.c
92581 @@ -59,8 +59,19 @@ static void vunmap_pte_range(pmd_t *pmd, unsigned long addr, unsigned long end)
92582
92583 pte = pte_offset_kernel(pmd, addr);
92584 do {
92585 - pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
92586 - WARN_ON(!pte_none(ptent) && !pte_present(ptent));
92587 +
92588 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92589 + if ((unsigned long)MODULES_EXEC_VADDR <= addr && addr < (unsigned long)MODULES_EXEC_END) {
92590 + BUG_ON(!pte_exec(*pte));
92591 + set_pte_at(&init_mm, addr, pte, pfn_pte(__pa(addr) >> PAGE_SHIFT, PAGE_KERNEL_EXEC));
92592 + continue;
92593 + }
92594 +#endif
92595 +
92596 + {
92597 + pte_t ptent = ptep_get_and_clear(&init_mm, addr, pte);
92598 + WARN_ON(!pte_none(ptent) && !pte_present(ptent));
92599 + }
92600 } while (pte++, addr += PAGE_SIZE, addr != end);
92601 }
92602
92603 @@ -120,16 +131,29 @@ static int vmap_pte_range(pmd_t *pmd, unsigned long addr,
92604 pte = pte_alloc_kernel(pmd, addr);
92605 if (!pte)
92606 return -ENOMEM;
92607 +
92608 + pax_open_kernel();
92609 do {
92610 struct page *page = pages[*nr];
92611
92612 - if (WARN_ON(!pte_none(*pte)))
92613 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92614 + if (pgprot_val(prot) & _PAGE_NX)
92615 +#endif
92616 +
92617 + if (!pte_none(*pte)) {
92618 + pax_close_kernel();
92619 + WARN_ON(1);
92620 return -EBUSY;
92621 - if (WARN_ON(!page))
92622 + }
92623 + if (!page) {
92624 + pax_close_kernel();
92625 + WARN_ON(1);
92626 return -ENOMEM;
92627 + }
92628 set_pte_at(&init_mm, addr, pte, mk_pte(page, prot));
92629 (*nr)++;
92630 } while (pte++, addr += PAGE_SIZE, addr != end);
92631 + pax_close_kernel();
92632 return 0;
92633 }
92634
92635 @@ -139,7 +163,7 @@ static int vmap_pmd_range(pud_t *pud, unsigned long addr,
92636 pmd_t *pmd;
92637 unsigned long next;
92638
92639 - pmd = pmd_alloc(&init_mm, pud, addr);
92640 + pmd = pmd_alloc_kernel(&init_mm, pud, addr);
92641 if (!pmd)
92642 return -ENOMEM;
92643 do {
92644 @@ -156,7 +180,7 @@ static int vmap_pud_range(pgd_t *pgd, unsigned long addr,
92645 pud_t *pud;
92646 unsigned long next;
92647
92648 - pud = pud_alloc(&init_mm, pgd, addr);
92649 + pud = pud_alloc_kernel(&init_mm, pgd, addr);
92650 if (!pud)
92651 return -ENOMEM;
92652 do {
92653 @@ -216,6 +240,12 @@ int is_vmalloc_or_module_addr(const void *x)
92654 if (addr >= MODULES_VADDR && addr < MODULES_END)
92655 return 1;
92656 #endif
92657 +
92658 +#if defined(CONFIG_X86_32) && defined(CONFIG_PAX_KERNEXEC)
92659 + if (x >= (const void *)MODULES_EXEC_VADDR && x < (const void *)MODULES_EXEC_END)
92660 + return 1;
92661 +#endif
92662 +
92663 return is_vmalloc_addr(x);
92664 }
92665
92666 @@ -236,8 +266,14 @@ struct page *vmalloc_to_page(const void *vmalloc_addr)
92667
92668 if (!pgd_none(*pgd)) {
92669 pud_t *pud = pud_offset(pgd, addr);
92670 +#ifdef CONFIG_X86
92671 + if (!pud_large(*pud))
92672 +#endif
92673 if (!pud_none(*pud)) {
92674 pmd_t *pmd = pmd_offset(pud, addr);
92675 +#ifdef CONFIG_X86
92676 + if (!pmd_large(*pmd))
92677 +#endif
92678 if (!pmd_none(*pmd)) {
92679 pte_t *ptep, pte;
92680
92681 @@ -1303,6 +1339,16 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
92682 struct vm_struct *area;
92683
92684 BUG_ON(in_interrupt());
92685 +
92686 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92687 + if (flags & VM_KERNEXEC) {
92688 + if (start != VMALLOC_START || end != VMALLOC_END)
92689 + return NULL;
92690 + start = (unsigned long)MODULES_EXEC_VADDR;
92691 + end = (unsigned long)MODULES_EXEC_END;
92692 + }
92693 +#endif
92694 +
92695 if (flags & VM_IOREMAP)
92696 align = 1ul << clamp(fls(size), PAGE_SHIFT, IOREMAP_MAX_ORDER);
92697
92698 @@ -1528,6 +1574,11 @@ void *vmap(struct page **pages, unsigned int count,
92699 if (count > totalram_pages)
92700 return NULL;
92701
92702 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92703 + if (!(pgprot_val(prot) & _PAGE_NX))
92704 + flags |= VM_KERNEXEC;
92705 +#endif
92706 +
92707 area = get_vm_area_caller((count << PAGE_SHIFT), flags,
92708 __builtin_return_address(0));
92709 if (!area)
92710 @@ -1629,6 +1680,13 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align,
92711 if (!size || (size >> PAGE_SHIFT) > totalram_pages)
92712 goto fail;
92713
92714 +#if defined(CONFIG_X86) && defined(CONFIG_PAX_KERNEXEC)
92715 + if (!(pgprot_val(prot) & _PAGE_NX))
92716 + area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED | VM_KERNEXEC,
92717 + VMALLOC_START, VMALLOC_END, node, gfp_mask, caller);
92718 + else
92719 +#endif
92720 +
92721 area = __get_vm_area_node(size, align, VM_ALLOC | VM_UNINITIALIZED,
92722 start, end, node, gfp_mask, caller);
92723 if (!area)
92724 @@ -1805,10 +1863,9 @@ EXPORT_SYMBOL(vzalloc_node);
92725 * For tight control over page level allocator and protection flags
92726 * use __vmalloc() instead.
92727 */
92728 -
92729 void *vmalloc_exec(unsigned long size)
92730 {
92731 - return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM, PAGE_KERNEL_EXEC,
92732 + return __vmalloc_node(size, 1, GFP_KERNEL | __GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL_EXEC,
92733 NUMA_NO_NODE, __builtin_return_address(0));
92734 }
92735
92736 @@ -2115,6 +2172,8 @@ int remap_vmalloc_range_partial(struct vm_area_struct *vma, unsigned long uaddr,
92737 {
92738 struct vm_struct *area;
92739
92740 + BUG_ON(vma->vm_mirror);
92741 +
92742 size = PAGE_ALIGN(size);
92743
92744 if (!PAGE_ALIGNED(uaddr) || !PAGE_ALIGNED(kaddr))
92745 @@ -2600,7 +2659,11 @@ static int s_show(struct seq_file *m, void *p)
92746 v->addr, v->addr + v->size, v->size);
92747
92748 if (v->caller)
92749 +#ifdef CONFIG_GRKERNSEC_HIDESYM
92750 + seq_printf(m, " %pK", v->caller);
92751 +#else
92752 seq_printf(m, " %pS", v->caller);
92753 +#endif
92754
92755 if (v->nr_pages)
92756 seq_printf(m, " pages=%d", v->nr_pages);
92757 diff --git a/mm/vmstat.c b/mm/vmstat.c
92758 index 5a442a7..dbbda4a 100644
92759 --- a/mm/vmstat.c
92760 +++ b/mm/vmstat.c
92761 @@ -20,6 +20,7 @@
92762 #include <linux/writeback.h>
92763 #include <linux/compaction.h>
92764 #include <linux/mm_inline.h>
92765 +#include <linux/grsecurity.h>
92766
92767 #include "internal.h"
92768
92769 @@ -79,7 +80,7 @@ void vm_events_fold_cpu(int cpu)
92770 *
92771 * vm_stat contains the global counters
92772 */
92773 -atomic_long_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92774 +atomic_long_unchecked_t vm_stat[NR_VM_ZONE_STAT_ITEMS] __cacheline_aligned_in_smp;
92775 EXPORT_SYMBOL(vm_stat);
92776
92777 #ifdef CONFIG_SMP
92778 @@ -423,7 +424,7 @@ static inline void fold_diff(int *diff)
92779
92780 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
92781 if (diff[i])
92782 - atomic_long_add(diff[i], &vm_stat[i]);
92783 + atomic_long_add_unchecked(diff[i], &vm_stat[i]);
92784 }
92785
92786 /*
92787 @@ -455,7 +456,7 @@ static void refresh_cpu_vm_stats(void)
92788 v = this_cpu_xchg(p->vm_stat_diff[i], 0);
92789 if (v) {
92790
92791 - atomic_long_add(v, &zone->vm_stat[i]);
92792 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92793 global_diff[i] += v;
92794 #ifdef CONFIG_NUMA
92795 /* 3 seconds idle till flush */
92796 @@ -517,7 +518,7 @@ void cpu_vm_stats_fold(int cpu)
92797
92798 v = p->vm_stat_diff[i];
92799 p->vm_stat_diff[i] = 0;
92800 - atomic_long_add(v, &zone->vm_stat[i]);
92801 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92802 global_diff[i] += v;
92803 }
92804 }
92805 @@ -537,8 +538,8 @@ void drain_zonestat(struct zone *zone, struct per_cpu_pageset *pset)
92806 if (pset->vm_stat_diff[i]) {
92807 int v = pset->vm_stat_diff[i];
92808 pset->vm_stat_diff[i] = 0;
92809 - atomic_long_add(v, &zone->vm_stat[i]);
92810 - atomic_long_add(v, &vm_stat[i]);
92811 + atomic_long_add_unchecked(v, &zone->vm_stat[i]);
92812 + atomic_long_add_unchecked(v, &vm_stat[i]);
92813 }
92814 }
92815 #endif
92816 @@ -1148,10 +1149,22 @@ static void *vmstat_start(struct seq_file *m, loff_t *pos)
92817 stat_items_size += sizeof(struct vm_event_state);
92818 #endif
92819
92820 - v = kmalloc(stat_items_size, GFP_KERNEL);
92821 + v = kzalloc(stat_items_size, GFP_KERNEL);
92822 m->private = v;
92823 if (!v)
92824 return ERR_PTR(-ENOMEM);
92825 +
92826 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
92827 +#if defined(CONFIG_GRKERNSEC_PROC_USER) || defined(CONFIG_GRKERNSEC_PROC_USERGROUP)
92828 + if (!uid_eq(current_uid(), GLOBAL_ROOT_UID)
92829 +#ifdef CONFIG_GRKERNSEC_PROC_USERGROUP
92830 + && !in_group_p(grsec_proc_gid)
92831 +#endif
92832 + )
92833 + return (unsigned long *)m->private + *pos;
92834 +#endif
92835 +#endif
92836 +
92837 for (i = 0; i < NR_VM_ZONE_STAT_ITEMS; i++)
92838 v[i] = global_page_state(i);
92839 v += NR_VM_ZONE_STAT_ITEMS;
92840 @@ -1281,10 +1294,16 @@ static int __init setup_vmstat(void)
92841 start_cpu_timer(cpu);
92842 #endif
92843 #ifdef CONFIG_PROC_FS
92844 - proc_create("buddyinfo", S_IRUGO, NULL, &fragmentation_file_operations);
92845 - proc_create("pagetypeinfo", S_IRUGO, NULL, &pagetypeinfo_file_ops);
92846 - proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
92847 - proc_create("zoneinfo", S_IRUGO, NULL, &proc_zoneinfo_file_operations);
92848 + {
92849 + mode_t gr_mode = S_IRUGO;
92850 +#ifdef CONFIG_GRKERNSEC_PROC_ADD
92851 + gr_mode = S_IRUSR;
92852 +#endif
92853 + proc_create("buddyinfo", gr_mode, NULL, &fragmentation_file_operations);
92854 + proc_create("pagetypeinfo", gr_mode, NULL, &pagetypeinfo_file_ops);
92855 + proc_create("vmstat", S_IRUGO, NULL, &proc_vmstat_file_operations);
92856 + proc_create("zoneinfo", gr_mode, NULL, &proc_zoneinfo_file_operations);
92857 + }
92858 #endif
92859 return 0;
92860 }
92861 diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
92862 index 61fc573..b5e47d0 100644
92863 --- a/net/8021q/vlan.c
92864 +++ b/net/8021q/vlan.c
92865 @@ -472,7 +472,7 @@ out:
92866 return NOTIFY_DONE;
92867 }
92868
92869 -static struct notifier_block vlan_notifier_block __read_mostly = {
92870 +static struct notifier_block vlan_notifier_block = {
92871 .notifier_call = vlan_device_event,
92872 };
92873
92874 @@ -547,8 +547,7 @@ static int vlan_ioctl_handler(struct net *net, void __user *arg)
92875 err = -EPERM;
92876 if (!ns_capable(net->user_ns, CAP_NET_ADMIN))
92877 break;
92878 - if ((args.u.name_type >= 0) &&
92879 - (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
92880 + if (args.u.name_type < VLAN_NAME_TYPE_HIGHEST) {
92881 struct vlan_net *vn;
92882
92883 vn = net_generic(net, vlan_net_id);
92884 diff --git a/net/9p/mod.c b/net/9p/mod.c
92885 index 6ab36ae..6f1841b 100644
92886 --- a/net/9p/mod.c
92887 +++ b/net/9p/mod.c
92888 @@ -84,7 +84,7 @@ static LIST_HEAD(v9fs_trans_list);
92889 void v9fs_register_trans(struct p9_trans_module *m)
92890 {
92891 spin_lock(&v9fs_trans_lock);
92892 - list_add_tail(&m->list, &v9fs_trans_list);
92893 + pax_list_add_tail((struct list_head *)&m->list, &v9fs_trans_list);
92894 spin_unlock(&v9fs_trans_lock);
92895 }
92896 EXPORT_SYMBOL(v9fs_register_trans);
92897 @@ -97,7 +97,7 @@ EXPORT_SYMBOL(v9fs_register_trans);
92898 void v9fs_unregister_trans(struct p9_trans_module *m)
92899 {
92900 spin_lock(&v9fs_trans_lock);
92901 - list_del_init(&m->list);
92902 + pax_list_del_init((struct list_head *)&m->list);
92903 spin_unlock(&v9fs_trans_lock);
92904 }
92905 EXPORT_SYMBOL(v9fs_unregister_trans);
92906 diff --git a/net/9p/trans_fd.c b/net/9p/trans_fd.c
92907 index 3ffda1b..fceac96 100644
92908 --- a/net/9p/trans_fd.c
92909 +++ b/net/9p/trans_fd.c
92910 @@ -432,7 +432,7 @@ static int p9_fd_write(struct p9_client *client, void *v, int len)
92911 oldfs = get_fs();
92912 set_fs(get_ds());
92913 /* The cast to a user pointer is valid due to the set_fs() */
92914 - ret = vfs_write(ts->wr, (__force void __user *)v, len, &ts->wr->f_pos);
92915 + ret = vfs_write(ts->wr, (void __force_user *)v, len, &ts->wr->f_pos);
92916 set_fs(oldfs);
92917
92918 if (ret <= 0 && ret != -ERESTARTSYS && ret != -EAGAIN)
92919 diff --git a/net/atm/atm_misc.c b/net/atm/atm_misc.c
92920 index 876fbe8..8bbea9f 100644
92921 --- a/net/atm/atm_misc.c
92922 +++ b/net/atm/atm_misc.c
92923 @@ -17,7 +17,7 @@ int atm_charge(struct atm_vcc *vcc, int truesize)
92924 if (atomic_read(&sk_atm(vcc)->sk_rmem_alloc) <= sk_atm(vcc)->sk_rcvbuf)
92925 return 1;
92926 atm_return(vcc, truesize);
92927 - atomic_inc(&vcc->stats->rx_drop);
92928 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92929 return 0;
92930 }
92931 EXPORT_SYMBOL(atm_charge);
92932 @@ -39,7 +39,7 @@ struct sk_buff *atm_alloc_charge(struct atm_vcc *vcc, int pdu_size,
92933 }
92934 }
92935 atm_return(vcc, guess);
92936 - atomic_inc(&vcc->stats->rx_drop);
92937 + atomic_inc_unchecked(&vcc->stats->rx_drop);
92938 return NULL;
92939 }
92940 EXPORT_SYMBOL(atm_alloc_charge);
92941 @@ -86,7 +86,7 @@ EXPORT_SYMBOL(atm_pcr_goal);
92942
92943 void sonet_copy_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92944 {
92945 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92946 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92947 __SONET_ITEMS
92948 #undef __HANDLE_ITEM
92949 }
92950 @@ -94,7 +94,7 @@ EXPORT_SYMBOL(sonet_copy_stats);
92951
92952 void sonet_subtract_stats(struct k_sonet_stats *from, struct sonet_stats *to)
92953 {
92954 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
92955 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i,&from->i)
92956 __SONET_ITEMS
92957 #undef __HANDLE_ITEM
92958 }
92959 diff --git a/net/atm/lec.h b/net/atm/lec.h
92960 index 4149db1..f2ab682 100644
92961 --- a/net/atm/lec.h
92962 +++ b/net/atm/lec.h
92963 @@ -48,7 +48,7 @@ struct lane2_ops {
92964 const u8 *tlvs, u32 sizeoftlvs);
92965 void (*associate_indicator) (struct net_device *dev, const u8 *mac_addr,
92966 const u8 *tlvs, u32 sizeoftlvs);
92967 -};
92968 +} __no_const;
92969
92970 /*
92971 * ATM LAN Emulation supports both LLC & Dix Ethernet EtherType
92972 diff --git a/net/atm/proc.c b/net/atm/proc.c
92973 index bbb6461..cf04016 100644
92974 --- a/net/atm/proc.c
92975 +++ b/net/atm/proc.c
92976 @@ -45,9 +45,9 @@ static void add_stats(struct seq_file *seq, const char *aal,
92977 const struct k_atm_aal_stats *stats)
92978 {
92979 seq_printf(seq, "%s ( %d %d %d %d %d )", aal,
92980 - atomic_read(&stats->tx), atomic_read(&stats->tx_err),
92981 - atomic_read(&stats->rx), atomic_read(&stats->rx_err),
92982 - atomic_read(&stats->rx_drop));
92983 + atomic_read_unchecked(&stats->tx),atomic_read_unchecked(&stats->tx_err),
92984 + atomic_read_unchecked(&stats->rx),atomic_read_unchecked(&stats->rx_err),
92985 + atomic_read_unchecked(&stats->rx_drop));
92986 }
92987
92988 static void atm_dev_info(struct seq_file *seq, const struct atm_dev *dev)
92989 diff --git a/net/atm/resources.c b/net/atm/resources.c
92990 index 0447d5d..3cf4728 100644
92991 --- a/net/atm/resources.c
92992 +++ b/net/atm/resources.c
92993 @@ -160,7 +160,7 @@ EXPORT_SYMBOL(atm_dev_deregister);
92994 static void copy_aal_stats(struct k_atm_aal_stats *from,
92995 struct atm_aal_stats *to)
92996 {
92997 -#define __HANDLE_ITEM(i) to->i = atomic_read(&from->i)
92998 +#define __HANDLE_ITEM(i) to->i = atomic_read_unchecked(&from->i)
92999 __AAL_STAT_ITEMS
93000 #undef __HANDLE_ITEM
93001 }
93002 @@ -168,7 +168,7 @@ static void copy_aal_stats(struct k_atm_aal_stats *from,
93003 static void subtract_aal_stats(struct k_atm_aal_stats *from,
93004 struct atm_aal_stats *to)
93005 {
93006 -#define __HANDLE_ITEM(i) atomic_sub(to->i, &from->i)
93007 +#define __HANDLE_ITEM(i) atomic_sub_unchecked(to->i, &from->i)
93008 __AAL_STAT_ITEMS
93009 #undef __HANDLE_ITEM
93010 }
93011 diff --git a/net/ax25/sysctl_net_ax25.c b/net/ax25/sysctl_net_ax25.c
93012 index 919a5ce..cc6b444 100644
93013 --- a/net/ax25/sysctl_net_ax25.c
93014 +++ b/net/ax25/sysctl_net_ax25.c
93015 @@ -152,7 +152,7 @@ int ax25_register_dev_sysctl(ax25_dev *ax25_dev)
93016 {
93017 char path[sizeof("net/ax25/") + IFNAMSIZ];
93018 int k;
93019 - struct ctl_table *table;
93020 + ctl_table_no_const *table;
93021
93022 table = kmemdup(ax25_param_table, sizeof(ax25_param_table), GFP_KERNEL);
93023 if (!table)
93024 diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c
93025 index 0a8a80c..f7e89aa 100644
93026 --- a/net/batman-adv/bat_iv_ogm.c
93027 +++ b/net/batman-adv/bat_iv_ogm.c
93028 @@ -121,7 +121,7 @@ static int batadv_iv_ogm_iface_enable(struct batadv_hard_iface *hard_iface)
93029
93030 /* randomize initial seqno to avoid collision */
93031 get_random_bytes(&random_seqno, sizeof(random_seqno));
93032 - atomic_set(&hard_iface->bat_iv.ogm_seqno, random_seqno);
93033 + atomic_set_unchecked(&hard_iface->bat_iv.ogm_seqno, random_seqno);
93034
93035 hard_iface->bat_iv.ogm_buff_len = BATADV_OGM_HLEN;
93036 ogm_buff = kmalloc(hard_iface->bat_iv.ogm_buff_len, GFP_ATOMIC);
93037 @@ -703,9 +703,9 @@ static void batadv_iv_ogm_schedule(struct batadv_hard_iface *hard_iface)
93038 batadv_ogm_packet = (struct batadv_ogm_packet *)(*ogm_buff);
93039
93040 /* change sequence number to network order */
93041 - seqno = (uint32_t)atomic_read(&hard_iface->bat_iv.ogm_seqno);
93042 + seqno = (uint32_t)atomic_read_unchecked(&hard_iface->bat_iv.ogm_seqno);
93043 batadv_ogm_packet->seqno = htonl(seqno);
93044 - atomic_inc(&hard_iface->bat_iv.ogm_seqno);
93045 + atomic_inc_unchecked(&hard_iface->bat_iv.ogm_seqno);
93046
93047 batadv_ogm_packet->ttvn = atomic_read(&bat_priv->tt.vn);
93048 batadv_ogm_packet->tt_crc = htons(bat_priv->tt.local_crc);
93049 @@ -1111,7 +1111,7 @@ static void batadv_iv_ogm_process(const struct ethhdr *ethhdr,
93050 return;
93051
93052 /* could be changed by schedule_own_packet() */
93053 - if_incoming_seqno = atomic_read(&if_incoming->bat_iv.ogm_seqno);
93054 + if_incoming_seqno = atomic_read_unchecked(&if_incoming->bat_iv.ogm_seqno);
93055
93056 if (batadv_ogm_packet->flags & BATADV_DIRECTLINK)
93057 has_directlink_flag = 1;
93058 diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c
93059 index c478e6b..469fd2f 100644
93060 --- a/net/batman-adv/hard-interface.c
93061 +++ b/net/batman-adv/hard-interface.c
93062 @@ -453,7 +453,7 @@ int batadv_hardif_enable_interface(struct batadv_hard_iface *hard_iface,
93063 hard_iface->batman_adv_ptype.dev = hard_iface->net_dev;
93064 dev_add_pack(&hard_iface->batman_adv_ptype);
93065
93066 - atomic_set(&hard_iface->frag_seqno, 1);
93067 + atomic_set_unchecked(&hard_iface->frag_seqno, 1);
93068 batadv_info(hard_iface->soft_iface, "Adding interface: %s\n",
93069 hard_iface->net_dev->name);
93070
93071 diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c
93072 index 813db4e..847edac 100644
93073 --- a/net/batman-adv/soft-interface.c
93074 +++ b/net/batman-adv/soft-interface.c
93075 @@ -263,7 +263,7 @@ static int batadv_interface_tx(struct sk_buff *skb,
93076 primary_if->net_dev->dev_addr, ETH_ALEN);
93077
93078 /* set broadcast sequence number */
93079 - seqno = atomic_inc_return(&bat_priv->bcast_seqno);
93080 + seqno = atomic_inc_return_unchecked(&bat_priv->bcast_seqno);
93081 bcast_packet->seqno = htonl(seqno);
93082
93083 batadv_add_bcast_packet_to_list(bat_priv, skb, brd_delay);
93084 @@ -483,7 +483,7 @@ static int batadv_softif_init_late(struct net_device *dev)
93085 atomic_set(&bat_priv->batman_queue_left, BATADV_BATMAN_QUEUE_LEN);
93086
93087 atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
93088 - atomic_set(&bat_priv->bcast_seqno, 1);
93089 + atomic_set_unchecked(&bat_priv->bcast_seqno, 1);
93090 atomic_set(&bat_priv->tt.vn, 0);
93091 atomic_set(&bat_priv->tt.local_changes, 0);
93092 atomic_set(&bat_priv->tt.ogm_append_cnt, 0);
93093 diff --git a/net/batman-adv/types.h b/net/batman-adv/types.h
93094 index b2c94e1..3d47e07 100644
93095 --- a/net/batman-adv/types.h
93096 +++ b/net/batman-adv/types.h
93097 @@ -51,7 +51,7 @@
93098 struct batadv_hard_iface_bat_iv {
93099 unsigned char *ogm_buff;
93100 int ogm_buff_len;
93101 - atomic_t ogm_seqno;
93102 + atomic_unchecked_t ogm_seqno;
93103 };
93104
93105 /**
93106 @@ -76,7 +76,7 @@ struct batadv_hard_iface {
93107 int16_t if_num;
93108 char if_status;
93109 struct net_device *net_dev;
93110 - atomic_t frag_seqno;
93111 + atomic_unchecked_t frag_seqno;
93112 uint8_t num_bcasts;
93113 struct kobject *hardif_obj;
93114 atomic_t refcount;
93115 @@ -560,7 +560,7 @@ struct batadv_priv {
93116 #ifdef CONFIG_BATMAN_ADV_DEBUG
93117 atomic_t log_level;
93118 #endif
93119 - atomic_t bcast_seqno;
93120 + atomic_unchecked_t bcast_seqno;
93121 atomic_t bcast_queue_left;
93122 atomic_t batman_queue_left;
93123 char num_ifaces;
93124 diff --git a/net/batman-adv/unicast.c b/net/batman-adv/unicast.c
93125 index 48b31d3..62a0bcb 100644
93126 --- a/net/batman-adv/unicast.c
93127 +++ b/net/batman-adv/unicast.c
93128 @@ -272,7 +272,7 @@ int batadv_frag_send_skb(struct sk_buff *skb, struct batadv_priv *bat_priv,
93129 frag1->flags = BATADV_UNI_FRAG_HEAD | large_tail;
93130 frag2->flags = large_tail;
93131
93132 - seqno = atomic_add_return(2, &hard_iface->frag_seqno);
93133 + seqno = atomic_add_return_unchecked(2, &hard_iface->frag_seqno);
93134 frag1->seqno = htons(seqno - 1);
93135 frag2->seqno = htons(seqno);
93136
93137 diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
93138 index fa4bf66..e92948f 100644
93139 --- a/net/bluetooth/hci_sock.c
93140 +++ b/net/bluetooth/hci_sock.c
93141 @@ -932,7 +932,7 @@ static int hci_sock_setsockopt(struct socket *sock, int level, int optname,
93142 uf.event_mask[1] = *((u32 *) f->event_mask + 1);
93143 }
93144
93145 - len = min_t(unsigned int, len, sizeof(uf));
93146 + len = min((size_t)len, sizeof(uf));
93147 if (copy_from_user(&uf, optval, len)) {
93148 err = -EFAULT;
93149 break;
93150 diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
93151 index 63fa111..b166ec6 100644
93152 --- a/net/bluetooth/l2cap_core.c
93153 +++ b/net/bluetooth/l2cap_core.c
93154 @@ -3511,8 +3511,10 @@ static int l2cap_parse_conf_rsp(struct l2cap_chan *chan, void *rsp, int len,
93155 break;
93156
93157 case L2CAP_CONF_RFC:
93158 - if (olen == sizeof(rfc))
93159 - memcpy(&rfc, (void *)val, olen);
93160 + if (olen != sizeof(rfc))
93161 + break;
93162 +
93163 + memcpy(&rfc, (void *)val, olen);
93164
93165 if (test_bit(CONF_STATE2_DEVICE, &chan->conf_state) &&
93166 rfc.mode != chan->mode)
93167 diff --git a/net/bluetooth/l2cap_sock.c b/net/bluetooth/l2cap_sock.c
93168 index 0098af8..fb5a31f 100644
93169 --- a/net/bluetooth/l2cap_sock.c
93170 +++ b/net/bluetooth/l2cap_sock.c
93171 @@ -485,7 +485,8 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
93172 struct sock *sk = sock->sk;
93173 struct l2cap_chan *chan = l2cap_pi(sk)->chan;
93174 struct l2cap_options opts;
93175 - int len, err = 0;
93176 + int err = 0;
93177 + size_t len = optlen;
93178 u32 opt;
93179
93180 BT_DBG("sk %p", sk);
93181 @@ -507,7 +508,7 @@ static int l2cap_sock_setsockopt_old(struct socket *sock, int optname,
93182 opts.max_tx = chan->max_tx;
93183 opts.txwin_size = chan->tx_win;
93184
93185 - len = min_t(unsigned int, sizeof(opts), optlen);
93186 + len = min(sizeof(opts), len);
93187 if (copy_from_user((char *) &opts, optval, len)) {
93188 err = -EFAULT;
93189 break;
93190 @@ -587,7 +588,8 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93191 struct bt_security sec;
93192 struct bt_power pwr;
93193 struct l2cap_conn *conn;
93194 - int len, err = 0;
93195 + int err = 0;
93196 + size_t len = optlen;
93197 u32 opt;
93198
93199 BT_DBG("sk %p", sk);
93200 @@ -610,7 +612,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93201
93202 sec.level = BT_SECURITY_LOW;
93203
93204 - len = min_t(unsigned int, sizeof(sec), optlen);
93205 + len = min(sizeof(sec), len);
93206 if (copy_from_user((char *) &sec, optval, len)) {
93207 err = -EFAULT;
93208 break;
93209 @@ -707,7 +709,7 @@ static int l2cap_sock_setsockopt(struct socket *sock, int level, int optname,
93210
93211 pwr.force_active = BT_POWER_FORCE_ACTIVE_ON;
93212
93213 - len = min_t(unsigned int, sizeof(pwr), optlen);
93214 + len = min(sizeof(pwr), len);
93215 if (copy_from_user((char *) &pwr, optval, len)) {
93216 err = -EFAULT;
93217 break;
93218 diff --git a/net/bluetooth/rfcomm/sock.c b/net/bluetooth/rfcomm/sock.c
93219 index c1c6028..17e8dcc 100644
93220 --- a/net/bluetooth/rfcomm/sock.c
93221 +++ b/net/bluetooth/rfcomm/sock.c
93222 @@ -665,7 +665,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
93223 struct sock *sk = sock->sk;
93224 struct bt_security sec;
93225 int err = 0;
93226 - size_t len;
93227 + size_t len = optlen;
93228 u32 opt;
93229
93230 BT_DBG("sk %p", sk);
93231 @@ -687,7 +687,7 @@ static int rfcomm_sock_setsockopt(struct socket *sock, int level, int optname, c
93232
93233 sec.level = BT_SECURITY_LOW;
93234
93235 - len = min_t(unsigned int, sizeof(sec), optlen);
93236 + len = min(sizeof(sec), len);
93237 if (copy_from_user((char *) &sec, optval, len)) {
93238 err = -EFAULT;
93239 break;
93240 diff --git a/net/bluetooth/rfcomm/tty.c b/net/bluetooth/rfcomm/tty.c
93241 index 84fcf9f..e389b27 100644
93242 --- a/net/bluetooth/rfcomm/tty.c
93243 +++ b/net/bluetooth/rfcomm/tty.c
93244 @@ -684,7 +684,7 @@ static int rfcomm_tty_open(struct tty_struct *tty, struct file *filp)
93245 BT_DBG("tty %p id %d", tty, tty->index);
93246
93247 BT_DBG("dev %p dst %pMR channel %d opened %d", dev, &dev->dst,
93248 - dev->channel, dev->port.count);
93249 + dev->channel, atomic_read(&dev->port.count));
93250
93251 err = tty_port_open(&dev->port, tty, filp);
93252 if (err)
93253 @@ -707,7 +707,7 @@ static void rfcomm_tty_close(struct tty_struct *tty, struct file *filp)
93254 struct rfcomm_dev *dev = (struct rfcomm_dev *) tty->driver_data;
93255
93256 BT_DBG("tty %p dev %p dlc %p opened %d", tty, dev, dev->dlc,
93257 - dev->port.count);
93258 + atomic_read(&dev->port.count));
93259
93260 tty_port_close(&dev->port, tty, filp);
93261 }
93262 diff --git a/net/bridge/netfilter/ebt_ulog.c b/net/bridge/netfilter/ebt_ulog.c
93263 index 5180938..7c470c3 100644
93264 --- a/net/bridge/netfilter/ebt_ulog.c
93265 +++ b/net/bridge/netfilter/ebt_ulog.c
93266 @@ -181,6 +181,7 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93267 ub->qlen++;
93268
93269 pm = nlmsg_data(nlh);
93270 + memset(pm, 0, sizeof(*pm));
93271
93272 /* Fill in the ulog data */
93273 pm->version = EBT_ULOG_VERSION;
93274 @@ -193,8 +194,6 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93275 pm->hook = hooknr;
93276 if (uloginfo->prefix != NULL)
93277 strcpy(pm->prefix, uloginfo->prefix);
93278 - else
93279 - *(pm->prefix) = '\0';
93280
93281 if (in) {
93282 strcpy(pm->physindev, in->name);
93283 @@ -204,16 +203,14 @@ static void ebt_ulog_packet(struct net *net, unsigned int hooknr,
93284 strcpy(pm->indev, br_port_get_rcu(in)->br->dev->name);
93285 else
93286 strcpy(pm->indev, in->name);
93287 - } else
93288 - pm->indev[0] = pm->physindev[0] = '\0';
93289 + }
93290
93291 if (out) {
93292 /* If out exists, then out is a bridge port */
93293 strcpy(pm->physoutdev, out->name);
93294 /* rcu_read_lock()ed by nf_hook_slow */
93295 strcpy(pm->outdev, br_port_get_rcu(out)->br->dev->name);
93296 - } else
93297 - pm->outdev[0] = pm->physoutdev[0] = '\0';
93298 + }
93299
93300 if (skb_copy_bits(skb, -ETH_HLEN, pm->data, copy_len) < 0)
93301 BUG();
93302 diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
93303 index ac78024..161a80c 100644
93304 --- a/net/bridge/netfilter/ebtables.c
93305 +++ b/net/bridge/netfilter/ebtables.c
93306 @@ -1525,7 +1525,7 @@ static int do_ebt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
93307 tmp.valid_hooks = t->table->valid_hooks;
93308 }
93309 mutex_unlock(&ebt_mutex);
93310 - if (copy_to_user(user, &tmp, *len) != 0){
93311 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0){
93312 BUGPRINT("c2u Didn't work\n");
93313 ret = -EFAULT;
93314 break;
93315 @@ -2331,7 +2331,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
93316 goto out;
93317 tmp.valid_hooks = t->valid_hooks;
93318
93319 - if (copy_to_user(user, &tmp, *len) != 0) {
93320 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
93321 ret = -EFAULT;
93322 break;
93323 }
93324 @@ -2342,7 +2342,7 @@ static int compat_do_ebt_get_ctl(struct sock *sk, int cmd,
93325 tmp.entries_size = t->table->entries_size;
93326 tmp.valid_hooks = t->table->valid_hooks;
93327
93328 - if (copy_to_user(user, &tmp, *len) != 0) {
93329 + if (*len > sizeof(tmp) || copy_to_user(user, &tmp, *len) != 0) {
93330 ret = -EFAULT;
93331 break;
93332 }
93333 diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c
93334 index 0f45522..dab651f 100644
93335 --- a/net/caif/cfctrl.c
93336 +++ b/net/caif/cfctrl.c
93337 @@ -10,6 +10,7 @@
93338 #include <linux/spinlock.h>
93339 #include <linux/slab.h>
93340 #include <linux/pkt_sched.h>
93341 +#include <linux/sched.h>
93342 #include <net/caif/caif_layer.h>
93343 #include <net/caif/cfpkt.h>
93344 #include <net/caif/cfctrl.h>
93345 @@ -43,8 +44,8 @@ struct cflayer *cfctrl_create(void)
93346 memset(&dev_info, 0, sizeof(dev_info));
93347 dev_info.id = 0xff;
93348 cfsrvl_init(&this->serv, 0, &dev_info, false);
93349 - atomic_set(&this->req_seq_no, 1);
93350 - atomic_set(&this->rsp_seq_no, 1);
93351 + atomic_set_unchecked(&this->req_seq_no, 1);
93352 + atomic_set_unchecked(&this->rsp_seq_no, 1);
93353 this->serv.layer.receive = cfctrl_recv;
93354 sprintf(this->serv.layer.name, "ctrl");
93355 this->serv.layer.ctrlcmd = cfctrl_ctrlcmd;
93356 @@ -130,8 +131,8 @@ static void cfctrl_insert_req(struct cfctrl *ctrl,
93357 struct cfctrl_request_info *req)
93358 {
93359 spin_lock_bh(&ctrl->info_list_lock);
93360 - atomic_inc(&ctrl->req_seq_no);
93361 - req->sequence_no = atomic_read(&ctrl->req_seq_no);
93362 + atomic_inc_unchecked(&ctrl->req_seq_no);
93363 + req->sequence_no = atomic_read_unchecked(&ctrl->req_seq_no);
93364 list_add_tail(&req->list, &ctrl->list);
93365 spin_unlock_bh(&ctrl->info_list_lock);
93366 }
93367 @@ -149,7 +150,7 @@ static struct cfctrl_request_info *cfctrl_remove_req(struct cfctrl *ctrl,
93368 if (p != first)
93369 pr_warn("Requests are not received in order\n");
93370
93371 - atomic_set(&ctrl->rsp_seq_no,
93372 + atomic_set_unchecked(&ctrl->rsp_seq_no,
93373 p->sequence_no);
93374 list_del(&p->list);
93375 goto out;
93376 diff --git a/net/can/af_can.c b/net/can/af_can.c
93377 index 3ab8dd2..b9aef13 100644
93378 --- a/net/can/af_can.c
93379 +++ b/net/can/af_can.c
93380 @@ -862,7 +862,7 @@ static const struct net_proto_family can_family_ops = {
93381 };
93382
93383 /* notifier block for netdevice event */
93384 -static struct notifier_block can_netdev_notifier __read_mostly = {
93385 +static struct notifier_block can_netdev_notifier = {
93386 .notifier_call = can_notifier,
93387 };
93388
93389 diff --git a/net/can/gw.c b/net/can/gw.c
93390 index 3f9b0f3..fc6d4fa 100644
93391 --- a/net/can/gw.c
93392 +++ b/net/can/gw.c
93393 @@ -80,7 +80,6 @@ MODULE_PARM_DESC(max_hops,
93394 "default: " __stringify(CGW_DEFAULT_HOPS) ")");
93395
93396 static HLIST_HEAD(cgw_list);
93397 -static struct notifier_block notifier;
93398
93399 static struct kmem_cache *cgw_cache __read_mostly;
93400
93401 @@ -954,6 +953,10 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh)
93402 return err;
93403 }
93404
93405 +static struct notifier_block notifier = {
93406 + .notifier_call = cgw_notifier
93407 +};
93408 +
93409 static __init int cgw_module_init(void)
93410 {
93411 /* sanitize given module parameter */
93412 @@ -969,7 +972,6 @@ static __init int cgw_module_init(void)
93413 return -ENOMEM;
93414
93415 /* set notifier */
93416 - notifier.notifier_call = cgw_notifier;
93417 register_netdevice_notifier(&notifier);
93418
93419 if (__rtnl_register(PF_CAN, RTM_GETROUTE, NULL, cgw_dump_jobs, NULL)) {
93420 diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c
93421 index 4a5df7b..9ad1f1d 100644
93422 --- a/net/ceph/messenger.c
93423 +++ b/net/ceph/messenger.c
93424 @@ -186,7 +186,7 @@ static void con_fault(struct ceph_connection *con);
93425 #define MAX_ADDR_STR_LEN 64 /* 54 is enough */
93426
93427 static char addr_str[ADDR_STR_COUNT][MAX_ADDR_STR_LEN];
93428 -static atomic_t addr_str_seq = ATOMIC_INIT(0);
93429 +static atomic_unchecked_t addr_str_seq = ATOMIC_INIT(0);
93430
93431 static struct page *zero_page; /* used in certain error cases */
93432
93433 @@ -197,7 +197,7 @@ const char *ceph_pr_addr(const struct sockaddr_storage *ss)
93434 struct sockaddr_in *in4 = (struct sockaddr_in *) ss;
93435 struct sockaddr_in6 *in6 = (struct sockaddr_in6 *) ss;
93436
93437 - i = atomic_inc_return(&addr_str_seq) & ADDR_STR_COUNT_MASK;
93438 + i = atomic_inc_return_unchecked(&addr_str_seq) & ADDR_STR_COUNT_MASK;
93439 s = addr_str[i];
93440
93441 switch (ss->ss_family) {
93442 diff --git a/net/compat.c b/net/compat.c
93443 index dd32e34..6066f87 100644
93444 --- a/net/compat.c
93445 +++ b/net/compat.c
93446 @@ -73,9 +73,9 @@ int get_compat_msghdr(struct msghdr *kmsg, struct compat_msghdr __user *umsg)
93447 return -EFAULT;
93448 if (kmsg->msg_namelen > sizeof(struct sockaddr_storage))
93449 kmsg->msg_namelen = sizeof(struct sockaddr_storage);
93450 - kmsg->msg_name = compat_ptr(tmp1);
93451 - kmsg->msg_iov = compat_ptr(tmp2);
93452 - kmsg->msg_control = compat_ptr(tmp3);
93453 + kmsg->msg_name = (void __force_kernel *)compat_ptr(tmp1);
93454 + kmsg->msg_iov = (void __force_kernel *)compat_ptr(tmp2);
93455 + kmsg->msg_control = (void __force_kernel *)compat_ptr(tmp3);
93456 return 0;
93457 }
93458
93459 @@ -87,7 +87,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93460
93461 if (kern_msg->msg_namelen) {
93462 if (mode == VERIFY_READ) {
93463 - int err = move_addr_to_kernel(kern_msg->msg_name,
93464 + int err = move_addr_to_kernel((void __force_user *)kern_msg->msg_name,
93465 kern_msg->msg_namelen,
93466 kern_address);
93467 if (err < 0)
93468 @@ -99,7 +99,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93469 kern_msg->msg_name = NULL;
93470
93471 tot_len = iov_from_user_compat_to_kern(kern_iov,
93472 - (struct compat_iovec __user *)kern_msg->msg_iov,
93473 + (struct compat_iovec __force_user *)kern_msg->msg_iov,
93474 kern_msg->msg_iovlen);
93475 if (tot_len >= 0)
93476 kern_msg->msg_iov = kern_iov;
93477 @@ -119,20 +119,20 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
93478
93479 #define CMSG_COMPAT_FIRSTHDR(msg) \
93480 (((msg)->msg_controllen) >= sizeof(struct compat_cmsghdr) ? \
93481 - (struct compat_cmsghdr __user *)((msg)->msg_control) : \
93482 + (struct compat_cmsghdr __force_user *)((msg)->msg_control) : \
93483 (struct compat_cmsghdr __user *)NULL)
93484
93485 #define CMSG_COMPAT_OK(ucmlen, ucmsg, mhdr) \
93486 ((ucmlen) >= sizeof(struct compat_cmsghdr) && \
93487 (ucmlen) <= (unsigned long) \
93488 ((mhdr)->msg_controllen - \
93489 - ((char *)(ucmsg) - (char *)(mhdr)->msg_control)))
93490 + ((char __force_kernel *)(ucmsg) - (char *)(mhdr)->msg_control)))
93491
93492 static inline struct compat_cmsghdr __user *cmsg_compat_nxthdr(struct msghdr *msg,
93493 struct compat_cmsghdr __user *cmsg, int cmsg_len)
93494 {
93495 char __user *ptr = (char __user *)cmsg + CMSG_COMPAT_ALIGN(cmsg_len);
93496 - if ((unsigned long)(ptr + 1 - (char __user *)msg->msg_control) >
93497 + if ((unsigned long)(ptr + 1 - (char __force_user *)msg->msg_control) >
93498 msg->msg_controllen)
93499 return NULL;
93500 return (struct compat_cmsghdr __user *)ptr;
93501 @@ -222,7 +222,7 @@ Efault:
93502
93503 int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *data)
93504 {
93505 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
93506 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
93507 struct compat_cmsghdr cmhdr;
93508 struct compat_timeval ctv;
93509 struct compat_timespec cts[3];
93510 @@ -278,7 +278,7 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
93511
93512 void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
93513 {
93514 - struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
93515 + struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __force_user *) kmsg->msg_control;
93516 int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
93517 int fdnum = scm->fp->count;
93518 struct file **fp = scm->fp->fp;
93519 @@ -366,7 +366,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
93520 return -EFAULT;
93521 old_fs = get_fs();
93522 set_fs(KERNEL_DS);
93523 - err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
93524 + err = sock_setsockopt(sock, level, optname, (char __force_user *)&ktime, sizeof(ktime));
93525 set_fs(old_fs);
93526
93527 return err;
93528 @@ -427,7 +427,7 @@ static int do_get_sock_timeout(struct socket *sock, int level, int optname,
93529 len = sizeof(ktime);
93530 old_fs = get_fs();
93531 set_fs(KERNEL_DS);
93532 - err = sock_getsockopt(sock, level, optname, (char *) &ktime, &len);
93533 + err = sock_getsockopt(sock, level, optname, (char __force_user *) &ktime, (int __force_user *)&len);
93534 set_fs(old_fs);
93535
93536 if (!err) {
93537 @@ -570,7 +570,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93538 case MCAST_JOIN_GROUP:
93539 case MCAST_LEAVE_GROUP:
93540 {
93541 - struct compat_group_req __user *gr32 = (void *)optval;
93542 + struct compat_group_req __user *gr32 = (void __user *)optval;
93543 struct group_req __user *kgr =
93544 compat_alloc_user_space(sizeof(struct group_req));
93545 u32 interface;
93546 @@ -591,7 +591,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93547 case MCAST_BLOCK_SOURCE:
93548 case MCAST_UNBLOCK_SOURCE:
93549 {
93550 - struct compat_group_source_req __user *gsr32 = (void *)optval;
93551 + struct compat_group_source_req __user *gsr32 = (void __user *)optval;
93552 struct group_source_req __user *kgsr = compat_alloc_user_space(
93553 sizeof(struct group_source_req));
93554 u32 interface;
93555 @@ -612,7 +612,7 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
93556 }
93557 case MCAST_MSFILTER:
93558 {
93559 - struct compat_group_filter __user *gf32 = (void *)optval;
93560 + struct compat_group_filter __user *gf32 = (void __user *)optval;
93561 struct group_filter __user *kgf;
93562 u32 interface, fmode, numsrc;
93563
93564 @@ -650,7 +650,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
93565 char __user *optval, int __user *optlen,
93566 int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
93567 {
93568 - struct compat_group_filter __user *gf32 = (void *)optval;
93569 + struct compat_group_filter __user *gf32 = (void __user *)optval;
93570 struct group_filter __user *kgf;
93571 int __user *koptlen;
93572 u32 interface, fmode, numsrc;
93573 @@ -808,7 +808,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
93574
93575 if (call < SYS_SOCKET || call > SYS_SENDMMSG)
93576 return -EINVAL;
93577 - if (copy_from_user(a, args, nas[call]))
93578 + if (nas[call] > sizeof a || copy_from_user(a, args, nas[call]))
93579 return -EFAULT;
93580 a0 = a[0];
93581 a1 = a[1];
93582 diff --git a/net/core/datagram.c b/net/core/datagram.c
93583 index af814e7..3d761de 100644
93584 --- a/net/core/datagram.c
93585 +++ b/net/core/datagram.c
93586 @@ -301,7 +301,7 @@ int skb_kill_datagram(struct sock *sk, struct sk_buff *skb, unsigned int flags)
93587 }
93588
93589 kfree_skb(skb);
93590 - atomic_inc(&sk->sk_drops);
93591 + atomic_inc_unchecked(&sk->sk_drops);
93592 sk_mem_reclaim_partial(sk);
93593
93594 return err;
93595 diff --git a/net/core/dev.c b/net/core/dev.c
93596 index 3d13874..6e78dc7 100644
93597 --- a/net/core/dev.c
93598 +++ b/net/core/dev.c
93599 @@ -1680,14 +1680,14 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb)
93600 {
93601 if (skb_shinfo(skb)->tx_flags & SKBTX_DEV_ZEROCOPY) {
93602 if (skb_copy_ubufs(skb, GFP_ATOMIC)) {
93603 - atomic_long_inc(&dev->rx_dropped);
93604 + atomic_long_inc_unchecked(&dev->rx_dropped);
93605 kfree_skb(skb);
93606 return NET_RX_DROP;
93607 }
93608 }
93609
93610 if (unlikely(!is_skb_forwardable(dev, skb))) {
93611 - atomic_long_inc(&dev->rx_dropped);
93612 + atomic_long_inc_unchecked(&dev->rx_dropped);
93613 kfree_skb(skb);
93614 return NET_RX_DROP;
93615 }
93616 @@ -2428,7 +2428,7 @@ static int illegal_highdma(struct net_device *dev, struct sk_buff *skb)
93617
93618 struct dev_gso_cb {
93619 void (*destructor)(struct sk_buff *skb);
93620 -};
93621 +} __no_const;
93622
93623 #define DEV_GSO_CB(skb) ((struct dev_gso_cb *)(skb)->cb)
93624
93625 @@ -3203,7 +3203,7 @@ enqueue:
93626
93627 local_irq_restore(flags);
93628
93629 - atomic_long_inc(&skb->dev->rx_dropped);
93630 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93631 kfree_skb(skb);
93632 return NET_RX_DROP;
93633 }
93634 @@ -3275,7 +3275,7 @@ int netif_rx_ni(struct sk_buff *skb)
93635 }
93636 EXPORT_SYMBOL(netif_rx_ni);
93637
93638 -static void net_tx_action(struct softirq_action *h)
93639 +static __latent_entropy void net_tx_action(void)
93640 {
93641 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93642
93643 @@ -3609,7 +3609,7 @@ ncls:
93644 ret = pt_prev->func(skb, skb->dev, pt_prev, orig_dev);
93645 } else {
93646 drop:
93647 - atomic_long_inc(&skb->dev->rx_dropped);
93648 + atomic_long_inc_unchecked(&skb->dev->rx_dropped);
93649 kfree_skb(skb);
93650 /* Jamal, now you will not able to escape explaining
93651 * me how you were going to use this. :-)
93652 @@ -4269,7 +4269,7 @@ void netif_napi_del(struct napi_struct *napi)
93653 }
93654 EXPORT_SYMBOL(netif_napi_del);
93655
93656 -static void net_rx_action(struct softirq_action *h)
93657 +static __latent_entropy void net_rx_action(void)
93658 {
93659 struct softnet_data *sd = &__get_cpu_var(softnet_data);
93660 unsigned long time_limit = jiffies + 2;
93661 @@ -5973,7 +5973,7 @@ struct rtnl_link_stats64 *dev_get_stats(struct net_device *dev,
93662 } else {
93663 netdev_stats_to_stats64(storage, &dev->stats);
93664 }
93665 - storage->rx_dropped += atomic_long_read(&dev->rx_dropped);
93666 + storage->rx_dropped += atomic_long_read_unchecked(&dev->rx_dropped);
93667 return storage;
93668 }
93669 EXPORT_SYMBOL(dev_get_stats);
93670 diff --git a/net/core/dev_ioctl.c b/net/core/dev_ioctl.c
93671 index 5b7d0e1..cb960fc 100644
93672 --- a/net/core/dev_ioctl.c
93673 +++ b/net/core/dev_ioctl.c
93674 @@ -365,9 +365,13 @@ void dev_load(struct net *net, const char *name)
93675 if (no_module && capable(CAP_NET_ADMIN))
93676 no_module = request_module("netdev-%s", name);
93677 if (no_module && capable(CAP_SYS_MODULE)) {
93678 +#ifdef CONFIG_GRKERNSEC_MODHARDEN
93679 + ___request_module(true, "grsec_modharden_netdev", "%s", name);
93680 +#else
93681 if (!request_module("%s", name))
93682 pr_warn("Loading kernel module for a network device with CAP_SYS_MODULE (deprecated). Use CAP_NET_ADMIN and alias netdev-%s instead.\n",
93683 name);
93684 +#endif
93685 }
93686 }
93687 EXPORT_SYMBOL(dev_load);
93688 diff --git a/net/core/flow.c b/net/core/flow.c
93689 index dfa602c..3103d88 100644
93690 --- a/net/core/flow.c
93691 +++ b/net/core/flow.c
93692 @@ -61,7 +61,7 @@ struct flow_cache {
93693 struct timer_list rnd_timer;
93694 };
93695
93696 -atomic_t flow_cache_genid = ATOMIC_INIT(0);
93697 +atomic_unchecked_t flow_cache_genid = ATOMIC_INIT(0);
93698 EXPORT_SYMBOL(flow_cache_genid);
93699 static struct flow_cache flow_cache_global;
93700 static struct kmem_cache *flow_cachep __read_mostly;
93701 @@ -86,7 +86,7 @@ static void flow_cache_new_hashrnd(unsigned long arg)
93702
93703 static int flow_entry_valid(struct flow_cache_entry *fle)
93704 {
93705 - if (atomic_read(&flow_cache_genid) != fle->genid)
93706 + if (atomic_read_unchecked(&flow_cache_genid) != fle->genid)
93707 return 0;
93708 if (fle->object && !fle->object->ops->check(fle->object))
93709 return 0;
93710 @@ -258,7 +258,7 @@ flow_cache_lookup(struct net *net, const struct flowi *key, u16 family, u8 dir,
93711 hlist_add_head(&fle->u.hlist, &fcp->hash_table[hash]);
93712 fcp->hash_count++;
93713 }
93714 - } else if (likely(fle->genid == atomic_read(&flow_cache_genid))) {
93715 + } else if (likely(fle->genid == atomic_read_unchecked(&flow_cache_genid))) {
93716 flo = fle->object;
93717 if (!flo)
93718 goto ret_object;
93719 @@ -279,7 +279,7 @@ nocache:
93720 }
93721 flo = resolver(net, key, family, dir, flo, ctx);
93722 if (fle) {
93723 - fle->genid = atomic_read(&flow_cache_genid);
93724 + fle->genid = atomic_read_unchecked(&flow_cache_genid);
93725 if (!IS_ERR(flo))
93726 fle->object = flo;
93727 else
93728 diff --git a/net/core/iovec.c b/net/core/iovec.c
93729 index 7d84ea1..55385ae 100644
93730 --- a/net/core/iovec.c
93731 +++ b/net/core/iovec.c
93732 @@ -42,7 +42,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93733 if (m->msg_namelen) {
93734 if (mode == VERIFY_READ) {
93735 void __user *namep;
93736 - namep = (void __user __force *) m->msg_name;
93737 + namep = (void __force_user *) m->msg_name;
93738 err = move_addr_to_kernel(namep, m->msg_namelen,
93739 address);
93740 if (err < 0)
93741 @@ -55,7 +55,7 @@ int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr_storage *a
93742 }
93743
93744 size = m->msg_iovlen * sizeof(struct iovec);
93745 - if (copy_from_user(iov, (void __user __force *) m->msg_iov, size))
93746 + if (copy_from_user(iov, (void __force_user *) m->msg_iov, size))
93747 return -EFAULT;
93748
93749 m->msg_iov = iov;
93750 diff --git a/net/core/neighbour.c b/net/core/neighbour.c
93751 index 6072610..7374c18 100644
93752 --- a/net/core/neighbour.c
93753 +++ b/net/core/neighbour.c
93754 @@ -2774,7 +2774,7 @@ static int proc_unres_qlen(struct ctl_table *ctl, int write,
93755 void __user *buffer, size_t *lenp, loff_t *ppos)
93756 {
93757 int size, ret;
93758 - struct ctl_table tmp = *ctl;
93759 + ctl_table_no_const tmp = *ctl;
93760
93761 tmp.extra1 = &zero;
93762 tmp.extra2 = &unres_qlen_max;
93763 diff --git a/net/core/net-procfs.c b/net/core/net-procfs.c
93764 index 2bf8329..7960607 100644
93765 --- a/net/core/net-procfs.c
93766 +++ b/net/core/net-procfs.c
93767 @@ -283,8 +283,13 @@ static int ptype_seq_show(struct seq_file *seq, void *v)
93768 else
93769 seq_printf(seq, "%04x", ntohs(pt->type));
93770
93771 +#ifdef CONFIG_GRKERNSEC_HIDESYM
93772 + seq_printf(seq, " %-8s %pf\n",
93773 + pt->dev ? pt->dev->name : "", NULL);
93774 +#else
93775 seq_printf(seq, " %-8s %pf\n",
93776 pt->dev ? pt->dev->name : "", pt->func);
93777 +#endif
93778 }
93779
93780 return 0;
93781 diff --git a/net/core/net-sysfs.c b/net/core/net-sysfs.c
93782 index d954b56..b0a0f7a 100644
93783 --- a/net/core/net-sysfs.c
93784 +++ b/net/core/net-sysfs.c
93785 @@ -1356,7 +1356,7 @@ void netdev_class_remove_file(struct class_attribute *class_attr)
93786 }
93787 EXPORT_SYMBOL(netdev_class_remove_file);
93788
93789 -int netdev_kobject_init(void)
93790 +int __init netdev_kobject_init(void)
93791 {
93792 kobj_ns_type_register(&net_ns_type_operations);
93793 return class_register(&net_class);
93794 diff --git a/net/core/net_namespace.c b/net/core/net_namespace.c
93795 index 81d3a9a..a0bd7a8 100644
93796 --- a/net/core/net_namespace.c
93797 +++ b/net/core/net_namespace.c
93798 @@ -443,7 +443,7 @@ static int __register_pernet_operations(struct list_head *list,
93799 int error;
93800 LIST_HEAD(net_exit_list);
93801
93802 - list_add_tail(&ops->list, list);
93803 + pax_list_add_tail((struct list_head *)&ops->list, list);
93804 if (ops->init || (ops->id && ops->size)) {
93805 for_each_net(net) {
93806 error = ops_init(ops, net);
93807 @@ -456,7 +456,7 @@ static int __register_pernet_operations(struct list_head *list,
93808
93809 out_undo:
93810 /* If I have an error cleanup all namespaces I initialized */
93811 - list_del(&ops->list);
93812 + pax_list_del((struct list_head *)&ops->list);
93813 ops_exit_list(ops, &net_exit_list);
93814 ops_free_list(ops, &net_exit_list);
93815 return error;
93816 @@ -467,7 +467,7 @@ static void __unregister_pernet_operations(struct pernet_operations *ops)
93817 struct net *net;
93818 LIST_HEAD(net_exit_list);
93819
93820 - list_del(&ops->list);
93821 + pax_list_del((struct list_head *)&ops->list);
93822 for_each_net(net)
93823 list_add_tail(&net->exit_list, &net_exit_list);
93824 ops_exit_list(ops, &net_exit_list);
93825 @@ -601,7 +601,7 @@ int register_pernet_device(struct pernet_operations *ops)
93826 mutex_lock(&net_mutex);
93827 error = register_pernet_operations(&pernet_list, ops);
93828 if (!error && (first_device == &pernet_list))
93829 - first_device = &ops->list;
93830 + first_device = (struct list_head *)&ops->list;
93831 mutex_unlock(&net_mutex);
93832 return error;
93833 }
93834 diff --git a/net/core/netpoll.c b/net/core/netpoll.c
93835 index fc75c9e..8c8e9be 100644
93836 --- a/net/core/netpoll.c
93837 +++ b/net/core/netpoll.c
93838 @@ -428,7 +428,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93839 struct udphdr *udph;
93840 struct iphdr *iph;
93841 struct ethhdr *eth;
93842 - static atomic_t ip_ident;
93843 + static atomic_unchecked_t ip_ident;
93844 struct ipv6hdr *ip6h;
93845
93846 udp_len = len + sizeof(*udph);
93847 @@ -499,7 +499,7 @@ void netpoll_send_udp(struct netpoll *np, const char *msg, int len)
93848 put_unaligned(0x45, (unsigned char *)iph);
93849 iph->tos = 0;
93850 put_unaligned(htons(ip_len), &(iph->tot_len));
93851 - iph->id = htons(atomic_inc_return(&ip_ident));
93852 + iph->id = htons(atomic_inc_return_unchecked(&ip_ident));
93853 iph->frag_off = 0;
93854 iph->ttl = 64;
93855 iph->protocol = IPPROTO_UDP;
93856 diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
93857 index 2a0e21d..6ad7642 100644
93858 --- a/net/core/rtnetlink.c
93859 +++ b/net/core/rtnetlink.c
93860 @@ -58,7 +58,7 @@ struct rtnl_link {
93861 rtnl_doit_func doit;
93862 rtnl_dumpit_func dumpit;
93863 rtnl_calcit_func calcit;
93864 -};
93865 +} __no_const;
93866
93867 static DEFINE_MUTEX(rtnl_mutex);
93868
93869 @@ -299,10 +299,13 @@ int __rtnl_link_register(struct rtnl_link_ops *ops)
93870 if (rtnl_link_ops_get(ops->kind))
93871 return -EEXIST;
93872
93873 - if (!ops->dellink)
93874 - ops->dellink = unregister_netdevice_queue;
93875 + if (!ops->dellink) {
93876 + pax_open_kernel();
93877 + *(void **)&ops->dellink = unregister_netdevice_queue;
93878 + pax_close_kernel();
93879 + }
93880
93881 - list_add_tail(&ops->list, &link_ops);
93882 + pax_list_add_tail((struct list_head *)&ops->list, &link_ops);
93883 return 0;
93884 }
93885 EXPORT_SYMBOL_GPL(__rtnl_link_register);
93886 @@ -349,7 +352,7 @@ void __rtnl_link_unregister(struct rtnl_link_ops *ops)
93887 for_each_net(net) {
93888 __rtnl_kill_links(net, ops);
93889 }
93890 - list_del(&ops->list);
93891 + pax_list_del((struct list_head *)&ops->list);
93892 }
93893 EXPORT_SYMBOL_GPL(__rtnl_link_unregister);
93894
93895 diff --git a/net/core/scm.c b/net/core/scm.c
93896 index b442e7e..6f5b5a2 100644
93897 --- a/net/core/scm.c
93898 +++ b/net/core/scm.c
93899 @@ -210,7 +210,7 @@ EXPORT_SYMBOL(__scm_send);
93900 int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93901 {
93902 struct cmsghdr __user *cm
93903 - = (__force struct cmsghdr __user *)msg->msg_control;
93904 + = (struct cmsghdr __force_user *)msg->msg_control;
93905 struct cmsghdr cmhdr;
93906 int cmlen = CMSG_LEN(len);
93907 int err;
93908 @@ -233,7 +233,7 @@ int put_cmsg(struct msghdr * msg, int level, int type, int len, void *data)
93909 err = -EFAULT;
93910 if (copy_to_user(cm, &cmhdr, sizeof cmhdr))
93911 goto out;
93912 - if (copy_to_user(CMSG_DATA(cm), data, cmlen - sizeof(struct cmsghdr)))
93913 + if (copy_to_user((void __force_user *)CMSG_DATA((void __force_kernel *)cm), data, cmlen - sizeof(struct cmsghdr)))
93914 goto out;
93915 cmlen = CMSG_SPACE(len);
93916 if (msg->msg_controllen < cmlen)
93917 @@ -249,7 +249,7 @@ EXPORT_SYMBOL(put_cmsg);
93918 void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93919 {
93920 struct cmsghdr __user *cm
93921 - = (__force struct cmsghdr __user*)msg->msg_control;
93922 + = (struct cmsghdr __force_user *)msg->msg_control;
93923
93924 int fdmax = 0;
93925 int fdnum = scm->fp->count;
93926 @@ -269,7 +269,7 @@ void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
93927 if (fdnum < fdmax)
93928 fdmax = fdnum;
93929
93930 - for (i=0, cmfptr=(__force int __user *)CMSG_DATA(cm); i<fdmax;
93931 + for (i=0, cmfptr=(int __force_user *)CMSG_DATA((void __force_kernel *)cm); i<fdmax;
93932 i++, cmfptr++)
93933 {
93934 struct socket *sock;
93935 diff --git a/net/core/skbuff.c b/net/core/skbuff.c
93936 index c28c7fe..a399a6d 100644
93937 --- a/net/core/skbuff.c
93938 +++ b/net/core/skbuff.c
93939 @@ -3104,13 +3104,15 @@ void __init skb_init(void)
93940 skbuff_head_cache = kmem_cache_create("skbuff_head_cache",
93941 sizeof(struct sk_buff),
93942 0,
93943 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93944 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93945 + SLAB_NO_SANITIZE,
93946 NULL);
93947 skbuff_fclone_cache = kmem_cache_create("skbuff_fclone_cache",
93948 (2*sizeof(struct sk_buff)) +
93949 sizeof(atomic_t),
93950 0,
93951 - SLAB_HWCACHE_ALIGN|SLAB_PANIC,
93952 + SLAB_HWCACHE_ALIGN|SLAB_PANIC|
93953 + SLAB_NO_SANITIZE,
93954 NULL);
93955 }
93956
93957 @@ -3541,6 +3543,7 @@ void skb_scrub_packet(struct sk_buff *skb, bool xnet)
93958 skb->tstamp.tv64 = 0;
93959 skb->pkt_type = PACKET_HOST;
93960 skb->skb_iif = 0;
93961 + skb->local_df = 0;
93962 skb_dst_drop(skb);
93963 skb->mark = 0;
93964 secpath_reset(skb);
93965 diff --git a/net/core/sock.c b/net/core/sock.c
93966 index 0b39e7a..5e9f91e 100644
93967 --- a/net/core/sock.c
93968 +++ b/net/core/sock.c
93969 @@ -393,7 +393,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93970 struct sk_buff_head *list = &sk->sk_receive_queue;
93971
93972 if (atomic_read(&sk->sk_rmem_alloc) >= sk->sk_rcvbuf) {
93973 - atomic_inc(&sk->sk_drops);
93974 + atomic_inc_unchecked(&sk->sk_drops);
93975 trace_sock_rcvqueue_full(sk, skb);
93976 return -ENOMEM;
93977 }
93978 @@ -403,7 +403,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93979 return err;
93980
93981 if (!sk_rmem_schedule(sk, skb, skb->truesize)) {
93982 - atomic_inc(&sk->sk_drops);
93983 + atomic_inc_unchecked(&sk->sk_drops);
93984 return -ENOBUFS;
93985 }
93986
93987 @@ -423,7 +423,7 @@ int sock_queue_rcv_skb(struct sock *sk, struct sk_buff *skb)
93988 skb_dst_force(skb);
93989
93990 spin_lock_irqsave(&list->lock, flags);
93991 - skb->dropcount = atomic_read(&sk->sk_drops);
93992 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
93993 __skb_queue_tail(list, skb);
93994 spin_unlock_irqrestore(&list->lock, flags);
93995
93996 @@ -443,7 +443,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
93997 skb->dev = NULL;
93998
93999 if (sk_rcvqueues_full(sk, skb, sk->sk_rcvbuf)) {
94000 - atomic_inc(&sk->sk_drops);
94001 + atomic_inc_unchecked(&sk->sk_drops);
94002 goto discard_and_relse;
94003 }
94004 if (nested)
94005 @@ -461,7 +461,7 @@ int sk_receive_skb(struct sock *sk, struct sk_buff *skb, const int nested)
94006 mutex_release(&sk->sk_lock.dep_map, 1, _RET_IP_);
94007 } else if (sk_add_backlog(sk, skb, sk->sk_rcvbuf)) {
94008 bh_unlock_sock(sk);
94009 - atomic_inc(&sk->sk_drops);
94010 + atomic_inc_unchecked(&sk->sk_drops);
94011 goto discard_and_relse;
94012 }
94013
94014 @@ -949,12 +949,12 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
94015 struct timeval tm;
94016 } v;
94017
94018 - int lv = sizeof(int);
94019 - int len;
94020 + unsigned int lv = sizeof(int);
94021 + unsigned int len;
94022
94023 if (get_user(len, optlen))
94024 return -EFAULT;
94025 - if (len < 0)
94026 + if (len > INT_MAX)
94027 return -EINVAL;
94028
94029 memset(&v, 0, sizeof(v));
94030 @@ -1106,11 +1106,11 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
94031
94032 case SO_PEERNAME:
94033 {
94034 - char address[128];
94035 + char address[_K_SS_MAXSIZE];
94036
94037 if (sock->ops->getname(sock, (struct sockaddr *)address, &lv, 2))
94038 return -ENOTCONN;
94039 - if (lv < len)
94040 + if (lv < len || sizeof address < len)
94041 return -EINVAL;
94042 if (copy_to_user(optval, address, len))
94043 return -EFAULT;
94044 @@ -1183,7 +1183,7 @@ int sock_getsockopt(struct socket *sock, int level, int optname,
94045
94046 if (len > lv)
94047 len = lv;
94048 - if (copy_to_user(optval, &v, len))
94049 + if (len > sizeof(v) || copy_to_user(optval, &v, len))
94050 return -EFAULT;
94051 lenout:
94052 if (put_user(len, optlen))
94053 @@ -2326,7 +2326,7 @@ void sock_init_data(struct socket *sock, struct sock *sk)
94054 */
94055 smp_wmb();
94056 atomic_set(&sk->sk_refcnt, 1);
94057 - atomic_set(&sk->sk_drops, 0);
94058 + atomic_set_unchecked(&sk->sk_drops, 0);
94059 }
94060 EXPORT_SYMBOL(sock_init_data);
94061
94062 @@ -2451,6 +2451,7 @@ void sock_enable_timestamp(struct sock *sk, int flag)
94063 int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
94064 int level, int type)
94065 {
94066 + struct sock_extended_err ee;
94067 struct sock_exterr_skb *serr;
94068 struct sk_buff *skb, *skb2;
94069 int copied, err;
94070 @@ -2472,7 +2473,8 @@ int sock_recv_errqueue(struct sock *sk, struct msghdr *msg, int len,
94071 sock_recv_timestamp(msg, sk, skb);
94072
94073 serr = SKB_EXT_ERR(skb);
94074 - put_cmsg(msg, level, type, sizeof(serr->ee), &serr->ee);
94075 + ee = serr->ee;
94076 + put_cmsg(msg, level, type, sizeof ee, &ee);
94077
94078 msg->msg_flags |= MSG_ERRQUEUE;
94079 err = copied;
94080 diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
94081 index a0e9cf6..ef7f9ed 100644
94082 --- a/net/core/sock_diag.c
94083 +++ b/net/core/sock_diag.c
94084 @@ -9,26 +9,33 @@
94085 #include <linux/inet_diag.h>
94086 #include <linux/sock_diag.h>
94087
94088 -static const struct sock_diag_handler *sock_diag_handlers[AF_MAX];
94089 +static const struct sock_diag_handler *sock_diag_handlers[AF_MAX] __read_only;
94090 static int (*inet_rcv_compat)(struct sk_buff *skb, struct nlmsghdr *nlh);
94091 static DEFINE_MUTEX(sock_diag_table_mutex);
94092
94093 int sock_diag_check_cookie(void *sk, __u32 *cookie)
94094 {
94095 +#ifndef CONFIG_GRKERNSEC_HIDESYM
94096 if ((cookie[0] != INET_DIAG_NOCOOKIE ||
94097 cookie[1] != INET_DIAG_NOCOOKIE) &&
94098 ((u32)(unsigned long)sk != cookie[0] ||
94099 (u32)((((unsigned long)sk) >> 31) >> 1) != cookie[1]))
94100 return -ESTALE;
94101 else
94102 +#endif
94103 return 0;
94104 }
94105 EXPORT_SYMBOL_GPL(sock_diag_check_cookie);
94106
94107 void sock_diag_save_cookie(void *sk, __u32 *cookie)
94108 {
94109 +#ifdef CONFIG_GRKERNSEC_HIDESYM
94110 + cookie[0] = 0;
94111 + cookie[1] = 0;
94112 +#else
94113 cookie[0] = (u32)(unsigned long)sk;
94114 cookie[1] = (u32)(((unsigned long)sk >> 31) >> 1);
94115 +#endif
94116 }
94117 EXPORT_SYMBOL_GPL(sock_diag_save_cookie);
94118
94119 @@ -113,8 +120,11 @@ int sock_diag_register(const struct sock_diag_handler *hndl)
94120 mutex_lock(&sock_diag_table_mutex);
94121 if (sock_diag_handlers[hndl->family])
94122 err = -EBUSY;
94123 - else
94124 + else {
94125 + pax_open_kernel();
94126 sock_diag_handlers[hndl->family] = hndl;
94127 + pax_close_kernel();
94128 + }
94129 mutex_unlock(&sock_diag_table_mutex);
94130
94131 return err;
94132 @@ -130,7 +140,9 @@ void sock_diag_unregister(const struct sock_diag_handler *hnld)
94133
94134 mutex_lock(&sock_diag_table_mutex);
94135 BUG_ON(sock_diag_handlers[family] != hnld);
94136 + pax_open_kernel();
94137 sock_diag_handlers[family] = NULL;
94138 + pax_close_kernel();
94139 mutex_unlock(&sock_diag_table_mutex);
94140 }
94141 EXPORT_SYMBOL_GPL(sock_diag_unregister);
94142 diff --git a/net/core/sysctl_net_core.c b/net/core/sysctl_net_core.c
94143 index cca4441..5e616de 100644
94144 --- a/net/core/sysctl_net_core.c
94145 +++ b/net/core/sysctl_net_core.c
94146 @@ -32,7 +32,7 @@ static int rps_sock_flow_sysctl(struct ctl_table *table, int write,
94147 {
94148 unsigned int orig_size, size;
94149 int ret, i;
94150 - struct ctl_table tmp = {
94151 + ctl_table_no_const tmp = {
94152 .data = &size,
94153 .maxlen = sizeof(size),
94154 .mode = table->mode
94155 @@ -199,7 +199,7 @@ static int set_default_qdisc(struct ctl_table *table, int write,
94156 void __user *buffer, size_t *lenp, loff_t *ppos)
94157 {
94158 char id[IFNAMSIZ];
94159 - struct ctl_table tbl = {
94160 + ctl_table_no_const tbl = {
94161 .data = id,
94162 .maxlen = IFNAMSIZ,
94163 };
94164 @@ -378,13 +378,12 @@ static struct ctl_table netns_core_table[] = {
94165
94166 static __net_init int sysctl_core_net_init(struct net *net)
94167 {
94168 - struct ctl_table *tbl;
94169 + ctl_table_no_const *tbl = NULL;
94170
94171 net->core.sysctl_somaxconn = SOMAXCONN;
94172
94173 - tbl = netns_core_table;
94174 if (!net_eq(net, &init_net)) {
94175 - tbl = kmemdup(tbl, sizeof(netns_core_table), GFP_KERNEL);
94176 + tbl = kmemdup(netns_core_table, sizeof(netns_core_table), GFP_KERNEL);
94177 if (tbl == NULL)
94178 goto err_dup;
94179
94180 @@ -394,17 +393,16 @@ static __net_init int sysctl_core_net_init(struct net *net)
94181 if (net->user_ns != &init_user_ns) {
94182 tbl[0].procname = NULL;
94183 }
94184 - }
94185 -
94186 - net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
94187 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", tbl);
94188 + } else
94189 + net->core.sysctl_hdr = register_net_sysctl(net, "net/core", netns_core_table);
94190 if (net->core.sysctl_hdr == NULL)
94191 goto err_reg;
94192
94193 return 0;
94194
94195 err_reg:
94196 - if (tbl != netns_core_table)
94197 - kfree(tbl);
94198 + kfree(tbl);
94199 err_dup:
94200 return -ENOMEM;
94201 }
94202 @@ -419,7 +417,7 @@ static __net_exit void sysctl_core_net_exit(struct net *net)
94203 kfree(tbl);
94204 }
94205
94206 -static __net_initdata struct pernet_operations sysctl_core_ops = {
94207 +static __net_initconst struct pernet_operations sysctl_core_ops = {
94208 .init = sysctl_core_net_init,
94209 .exit = sysctl_core_net_exit,
94210 };
94211 diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
94212 index dd4d506..fb2fb87 100644
94213 --- a/net/decnet/af_decnet.c
94214 +++ b/net/decnet/af_decnet.c
94215 @@ -465,6 +465,7 @@ static struct proto dn_proto = {
94216 .sysctl_rmem = sysctl_decnet_rmem,
94217 .max_header = DN_MAX_NSP_DATA_HEADER + 64,
94218 .obj_size = sizeof(struct dn_sock),
94219 + .slab_flags = SLAB_USERCOPY,
94220 };
94221
94222 static struct sock *dn_alloc_sock(struct net *net, struct socket *sock, gfp_t gfp)
94223 diff --git a/net/decnet/sysctl_net_decnet.c b/net/decnet/sysctl_net_decnet.c
94224 index 5325b54..a0d4d69 100644
94225 --- a/net/decnet/sysctl_net_decnet.c
94226 +++ b/net/decnet/sysctl_net_decnet.c
94227 @@ -174,7 +174,7 @@ static int dn_node_address_handler(struct ctl_table *table, int write,
94228
94229 if (len > *lenp) len = *lenp;
94230
94231 - if (copy_to_user(buffer, addr, len))
94232 + if (len > sizeof addr || copy_to_user(buffer, addr, len))
94233 return -EFAULT;
94234
94235 *lenp = len;
94236 @@ -237,7 +237,7 @@ static int dn_def_dev_handler(struct ctl_table *table, int write,
94237
94238 if (len > *lenp) len = *lenp;
94239
94240 - if (copy_to_user(buffer, devname, len))
94241 + if (len > sizeof devname || copy_to_user(buffer, devname, len))
94242 return -EFAULT;
94243
94244 *lenp = len;
94245 diff --git a/net/ieee802154/6lowpan.c b/net/ieee802154/6lowpan.c
94246 index 008f337..b03b8c9 100644
94247 --- a/net/ieee802154/6lowpan.c
94248 +++ b/net/ieee802154/6lowpan.c
94249 @@ -548,7 +548,7 @@ static int lowpan_header_create(struct sk_buff *skb,
94250 hc06_ptr += 3;
94251 } else {
94252 /* compress nothing */
94253 - memcpy(hc06_ptr, &hdr, 4);
94254 + memcpy(hc06_ptr, hdr, 4);
94255 /* replace the top byte with new ECN | DSCP format */
94256 *hc06_ptr = tmp;
94257 hc06_ptr += 4;
94258 diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
94259 index cfeb85c..385989a 100644
94260 --- a/net/ipv4/af_inet.c
94261 +++ b/net/ipv4/af_inet.c
94262 @@ -1675,13 +1675,9 @@ static int __init inet_init(void)
94263
94264 BUILD_BUG_ON(sizeof(struct inet_skb_parm) > FIELD_SIZEOF(struct sk_buff, cb));
94265
94266 - sysctl_local_reserved_ports = kzalloc(65536 / 8, GFP_KERNEL);
94267 - if (!sysctl_local_reserved_ports)
94268 - goto out;
94269 -
94270 rc = proto_register(&tcp_prot, 1);
94271 if (rc)
94272 - goto out_free_reserved_ports;
94273 + goto out;
94274
94275 rc = proto_register(&udp_prot, 1);
94276 if (rc)
94277 @@ -1790,8 +1786,6 @@ out_unregister_udp_proto:
94278 proto_unregister(&udp_prot);
94279 out_unregister_tcp_proto:
94280 proto_unregister(&tcp_prot);
94281 -out_free_reserved_ports:
94282 - kfree(sysctl_local_reserved_ports);
94283 goto out;
94284 }
94285
94286 diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
94287 index a1b5bcb..62ec5c6 100644
94288 --- a/net/ipv4/devinet.c
94289 +++ b/net/ipv4/devinet.c
94290 @@ -1533,7 +1533,7 @@ static int inet_dump_ifaddr(struct sk_buff *skb, struct netlink_callback *cb)
94291 idx = 0;
94292 head = &net->dev_index_head[h];
94293 rcu_read_lock();
94294 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
94295 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
94296 net->dev_base_seq;
94297 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94298 if (idx < s_idx)
94299 @@ -1844,7 +1844,7 @@ static int inet_netconf_dump_devconf(struct sk_buff *skb,
94300 idx = 0;
94301 head = &net->dev_index_head[h];
94302 rcu_read_lock();
94303 - cb->seq = atomic_read(&net->ipv4.dev_addr_genid) ^
94304 + cb->seq = atomic_read_unchecked(&net->ipv4.dev_addr_genid) ^
94305 net->dev_base_seq;
94306 hlist_for_each_entry_rcu(dev, head, index_hlist) {
94307 if (idx < s_idx)
94308 @@ -2069,7 +2069,7 @@ static int ipv4_doint_and_flush(struct ctl_table *ctl, int write,
94309 #define DEVINET_SYSCTL_FLUSHING_ENTRY(attr, name) \
94310 DEVINET_SYSCTL_COMPLEX_ENTRY(attr, name, ipv4_doint_and_flush)
94311
94312 -static struct devinet_sysctl_table {
94313 +static const struct devinet_sysctl_table {
94314 struct ctl_table_header *sysctl_header;
94315 struct ctl_table devinet_vars[__IPV4_DEVCONF_MAX];
94316 } devinet_sysctl = {
94317 @@ -2191,7 +2191,7 @@ static __net_init int devinet_init_net(struct net *net)
94318 int err;
94319 struct ipv4_devconf *all, *dflt;
94320 #ifdef CONFIG_SYSCTL
94321 - struct ctl_table *tbl = ctl_forward_entry;
94322 + ctl_table_no_const *tbl = NULL;
94323 struct ctl_table_header *forw_hdr;
94324 #endif
94325
94326 @@ -2209,7 +2209,7 @@ static __net_init int devinet_init_net(struct net *net)
94327 goto err_alloc_dflt;
94328
94329 #ifdef CONFIG_SYSCTL
94330 - tbl = kmemdup(tbl, sizeof(ctl_forward_entry), GFP_KERNEL);
94331 + tbl = kmemdup(ctl_forward_entry, sizeof(ctl_forward_entry), GFP_KERNEL);
94332 if (tbl == NULL)
94333 goto err_alloc_ctl;
94334
94335 @@ -2229,7 +2229,10 @@ static __net_init int devinet_init_net(struct net *net)
94336 goto err_reg_dflt;
94337
94338 err = -ENOMEM;
94339 - forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
94340 + if (!net_eq(net, &init_net))
94341 + forw_hdr = register_net_sysctl(net, "net/ipv4", tbl);
94342 + else
94343 + forw_hdr = register_net_sysctl(net, "net/ipv4", ctl_forward_entry);
94344 if (forw_hdr == NULL)
94345 goto err_reg_ctl;
94346 net->ipv4.forw_hdr = forw_hdr;
94347 @@ -2245,8 +2248,7 @@ err_reg_ctl:
94348 err_reg_dflt:
94349 __devinet_sysctl_unregister(all);
94350 err_reg_all:
94351 - if (tbl != ctl_forward_entry)
94352 - kfree(tbl);
94353 + kfree(tbl);
94354 err_alloc_ctl:
94355 #endif
94356 if (dflt != &ipv4_devconf_dflt)
94357 diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c
94358 index b3f627a..b0f3e99 100644
94359 --- a/net/ipv4/fib_frontend.c
94360 +++ b/net/ipv4/fib_frontend.c
94361 @@ -1017,12 +1017,12 @@ static int fib_inetaddr_event(struct notifier_block *this, unsigned long event,
94362 #ifdef CONFIG_IP_ROUTE_MULTIPATH
94363 fib_sync_up(dev);
94364 #endif
94365 - atomic_inc(&net->ipv4.dev_addr_genid);
94366 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94367 rt_cache_flush(dev_net(dev));
94368 break;
94369 case NETDEV_DOWN:
94370 fib_del_ifaddr(ifa, NULL);
94371 - atomic_inc(&net->ipv4.dev_addr_genid);
94372 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94373 if (ifa->ifa_dev->ifa_list == NULL) {
94374 /* Last address was deleted from this interface.
94375 * Disable IP.
94376 @@ -1058,7 +1058,7 @@ static int fib_netdev_event(struct notifier_block *this, unsigned long event, vo
94377 #ifdef CONFIG_IP_ROUTE_MULTIPATH
94378 fib_sync_up(dev);
94379 #endif
94380 - atomic_inc(&net->ipv4.dev_addr_genid);
94381 + atomic_inc_unchecked(&net->ipv4.dev_addr_genid);
94382 rt_cache_flush(net);
94383 break;
94384 case NETDEV_DOWN:
94385 diff --git a/net/ipv4/fib_semantics.c b/net/ipv4/fib_semantics.c
94386 index d5dbca5..6251d5f 100644
94387 --- a/net/ipv4/fib_semantics.c
94388 +++ b/net/ipv4/fib_semantics.c
94389 @@ -766,7 +766,7 @@ __be32 fib_info_update_nh_saddr(struct net *net, struct fib_nh *nh)
94390 nh->nh_saddr = inet_select_addr(nh->nh_dev,
94391 nh->nh_gw,
94392 nh->nh_parent->fib_scope);
94393 - nh->nh_saddr_genid = atomic_read(&net->ipv4.dev_addr_genid);
94394 + nh->nh_saddr_genid = atomic_read_unchecked(&net->ipv4.dev_addr_genid);
94395
94396 return nh->nh_saddr;
94397 }
94398 diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
94399 index 6acb541..9ea617d 100644
94400 --- a/net/ipv4/inet_connection_sock.c
94401 +++ b/net/ipv4/inet_connection_sock.c
94402 @@ -37,7 +37,7 @@ struct local_ports sysctl_local_ports __read_mostly = {
94403 .range = { 32768, 61000 },
94404 };
94405
94406 -unsigned long *sysctl_local_reserved_ports;
94407 +unsigned long sysctl_local_reserved_ports[65536 / 8 / sizeof(unsigned long)];
94408 EXPORT_SYMBOL(sysctl_local_reserved_ports);
94409
94410 void inet_get_local_port_range(int *low, int *high)
94411 diff --git a/net/ipv4/inet_diag.c b/net/ipv4/inet_diag.c
94412 index 5f64875..31cf54d 100644
94413 --- a/net/ipv4/inet_diag.c
94414 +++ b/net/ipv4/inet_diag.c
94415 @@ -106,6 +106,10 @@ int inet_sk_diag_fill(struct sock *sk, struct inet_connection_sock *icsk,
94416
94417 r->id.idiag_sport = inet->inet_sport;
94418 r->id.idiag_dport = inet->inet_dport;
94419 +
94420 + memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
94421 + memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
94422 +
94423 r->id.idiag_src[0] = inet->inet_rcv_saddr;
94424 r->id.idiag_dst[0] = inet->inet_daddr;
94425
94426 @@ -240,12 +244,19 @@ static int inet_twsk_diag_fill(struct inet_timewait_sock *tw,
94427
94428 r->idiag_family = tw->tw_family;
94429 r->idiag_retrans = 0;
94430 +
94431 r->id.idiag_if = tw->tw_bound_dev_if;
94432 sock_diag_save_cookie(tw, r->id.idiag_cookie);
94433 +
94434 r->id.idiag_sport = tw->tw_sport;
94435 r->id.idiag_dport = tw->tw_dport;
94436 +
94437 + memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
94438 + memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
94439 +
94440 r->id.idiag_src[0] = tw->tw_rcv_saddr;
94441 r->id.idiag_dst[0] = tw->tw_daddr;
94442 +
94443 r->idiag_state = tw->tw_substate;
94444 r->idiag_timer = 3;
94445 r->idiag_expires = DIV_ROUND_UP(tmo * 1000, HZ);
94446 @@ -732,8 +743,13 @@ static int inet_diag_fill_req(struct sk_buff *skb, struct sock *sk,
94447
94448 r->id.idiag_sport = inet->inet_sport;
94449 r->id.idiag_dport = ireq->rmt_port;
94450 +
94451 + memset(&r->id.idiag_src, 0, sizeof(r->id.idiag_src));
94452 + memset(&r->id.idiag_dst, 0, sizeof(r->id.idiag_dst));
94453 +
94454 r->id.idiag_src[0] = ireq->loc_addr;
94455 r->id.idiag_dst[0] = ireq->rmt_addr;
94456 +
94457 r->idiag_expires = jiffies_to_msecs(tmo);
94458 r->idiag_rqueue = 0;
94459 r->idiag_wqueue = 0;
94460 diff --git a/net/ipv4/inet_hashtables.c b/net/ipv4/inet_hashtables.c
94461 index 96da9c7..b956690 100644
94462 --- a/net/ipv4/inet_hashtables.c
94463 +++ b/net/ipv4/inet_hashtables.c
94464 @@ -18,12 +18,15 @@
94465 #include <linux/sched.h>
94466 #include <linux/slab.h>
94467 #include <linux/wait.h>
94468 +#include <linux/security.h>
94469
94470 #include <net/inet_connection_sock.h>
94471 #include <net/inet_hashtables.h>
94472 #include <net/secure_seq.h>
94473 #include <net/ip.h>
94474
94475 +extern void gr_update_task_in_ip_table(struct task_struct *task, const struct inet_sock *inet);
94476 +
94477 /*
94478 * Allocate and initialize a new local port bind bucket.
94479 * The bindhash mutex for snum's hash chain must be held here.
94480 @@ -554,6 +557,8 @@ ok:
94481 twrefcnt += inet_twsk_bind_unhash(tw, hinfo);
94482 spin_unlock(&head->lock);
94483
94484 + gr_update_task_in_ip_table(current, inet_sk(sk));
94485 +
94486 if (tw) {
94487 inet_twsk_deschedule(tw, death_row);
94488 while (twrefcnt) {
94489 diff --git a/net/ipv4/inetpeer.c b/net/ipv4/inetpeer.c
94490 index 33d5537..da337a4 100644
94491 --- a/net/ipv4/inetpeer.c
94492 +++ b/net/ipv4/inetpeer.c
94493 @@ -503,8 +503,8 @@ relookup:
94494 if (p) {
94495 p->daddr = *daddr;
94496 atomic_set(&p->refcnt, 1);
94497 - atomic_set(&p->rid, 0);
94498 - atomic_set(&p->ip_id_count,
94499 + atomic_set_unchecked(&p->rid, 0);
94500 + atomic_set_unchecked(&p->ip_id_count,
94501 (daddr->family == AF_INET) ?
94502 secure_ip_id(daddr->addr.a4) :
94503 secure_ipv6_id(daddr->addr.a6));
94504 diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
94505 index b66910a..cfe416e 100644
94506 --- a/net/ipv4/ip_fragment.c
94507 +++ b/net/ipv4/ip_fragment.c
94508 @@ -282,7 +282,7 @@ static inline int ip_frag_too_far(struct ipq *qp)
94509 return 0;
94510
94511 start = qp->rid;
94512 - end = atomic_inc_return(&peer->rid);
94513 + end = atomic_inc_return_unchecked(&peer->rid);
94514 qp->rid = end;
94515
94516 rc = qp->q.fragments && (end - start) > max;
94517 @@ -759,12 +759,11 @@ static struct ctl_table ip4_frags_ctl_table[] = {
94518
94519 static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94520 {
94521 - struct ctl_table *table;
94522 + ctl_table_no_const *table = NULL;
94523 struct ctl_table_header *hdr;
94524
94525 - table = ip4_frags_ns_ctl_table;
94526 if (!net_eq(net, &init_net)) {
94527 - table = kmemdup(table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
94528 + table = kmemdup(ip4_frags_ns_ctl_table, sizeof(ip4_frags_ns_ctl_table), GFP_KERNEL);
94529 if (table == NULL)
94530 goto err_alloc;
94531
94532 @@ -775,9 +774,10 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94533 /* Don't export sysctls to unprivileged users */
94534 if (net->user_ns != &init_user_ns)
94535 table[0].procname = NULL;
94536 - }
94537 + hdr = register_net_sysctl(net, "net/ipv4", table);
94538 + } else
94539 + hdr = register_net_sysctl(net, "net/ipv4", ip4_frags_ns_ctl_table);
94540
94541 - hdr = register_net_sysctl(net, "net/ipv4", table);
94542 if (hdr == NULL)
94543 goto err_reg;
94544
94545 @@ -785,8 +785,7 @@ static int __net_init ip4_frags_ns_ctl_register(struct net *net)
94546 return 0;
94547
94548 err_reg:
94549 - if (!net_eq(net, &init_net))
94550 - kfree(table);
94551 + kfree(table);
94552 err_alloc:
94553 return -ENOMEM;
94554 }
94555 diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
94556 index d7aea4c..a8ee872 100644
94557 --- a/net/ipv4/ip_gre.c
94558 +++ b/net/ipv4/ip_gre.c
94559 @@ -115,7 +115,7 @@ static bool log_ecn_error = true;
94560 module_param(log_ecn_error, bool, 0644);
94561 MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94562
94563 -static struct rtnl_link_ops ipgre_link_ops __read_mostly;
94564 +static struct rtnl_link_ops ipgre_link_ops;
94565 static int ipgre_tunnel_init(struct net_device *dev);
94566
94567 static int ipgre_net_id __read_mostly;
94568 @@ -731,7 +731,7 @@ static const struct nla_policy ipgre_policy[IFLA_GRE_MAX + 1] = {
94569 [IFLA_GRE_PMTUDISC] = { .type = NLA_U8 },
94570 };
94571
94572 -static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
94573 +static struct rtnl_link_ops ipgre_link_ops = {
94574 .kind = "gre",
94575 .maxtype = IFLA_GRE_MAX,
94576 .policy = ipgre_policy,
94577 @@ -745,7 +745,7 @@ static struct rtnl_link_ops ipgre_link_ops __read_mostly = {
94578 .fill_info = ipgre_fill_info,
94579 };
94580
94581 -static struct rtnl_link_ops ipgre_tap_ops __read_mostly = {
94582 +static struct rtnl_link_ops ipgre_tap_ops = {
94583 .kind = "gretap",
94584 .maxtype = IFLA_GRE_MAX,
94585 .policy = ipgre_policy,
94586 diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
94587 index 23e6ab0..be67a57 100644
94588 --- a/net/ipv4/ip_sockglue.c
94589 +++ b/net/ipv4/ip_sockglue.c
94590 @@ -1153,7 +1153,8 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94591 len = min_t(unsigned int, len, opt->optlen);
94592 if (put_user(len, optlen))
94593 return -EFAULT;
94594 - if (copy_to_user(optval, opt->__data, len))
94595 + if ((len > (sizeof(optbuf) - sizeof(struct ip_options))) ||
94596 + copy_to_user(optval, opt->__data, len))
94597 return -EFAULT;
94598 return 0;
94599 }
94600 @@ -1284,7 +1285,7 @@ static int do_ip_getsockopt(struct sock *sk, int level, int optname,
94601 if (sk->sk_type != SOCK_STREAM)
94602 return -ENOPROTOOPT;
94603
94604 - msg.msg_control = optval;
94605 + msg.msg_control = (void __force_kernel *)optval;
94606 msg.msg_controllen = len;
94607 msg.msg_flags = flags;
94608
94609 diff --git a/net/ipv4/ip_vti.c b/net/ipv4/ip_vti.c
94610 index 26847e1..75d2d2f 100644
94611 --- a/net/ipv4/ip_vti.c
94612 +++ b/net/ipv4/ip_vti.c
94613 @@ -44,7 +44,7 @@
94614 #include <net/net_namespace.h>
94615 #include <net/netns/generic.h>
94616
94617 -static struct rtnl_link_ops vti_link_ops __read_mostly;
94618 +static struct rtnl_link_ops vti_link_ops;
94619
94620 static int vti_net_id __read_mostly;
94621 static int vti_tunnel_init(struct net_device *dev);
94622 @@ -425,7 +425,7 @@ static const struct nla_policy vti_policy[IFLA_VTI_MAX + 1] = {
94623 [IFLA_VTI_REMOTE] = { .len = FIELD_SIZEOF(struct iphdr, daddr) },
94624 };
94625
94626 -static struct rtnl_link_ops vti_link_ops __read_mostly = {
94627 +static struct rtnl_link_ops vti_link_ops = {
94628 .kind = "vti",
94629 .maxtype = IFLA_VTI_MAX,
94630 .policy = vti_policy,
94631 diff --git a/net/ipv4/ipconfig.c b/net/ipv4/ipconfig.c
94632 index efa1138..20dbba0 100644
94633 --- a/net/ipv4/ipconfig.c
94634 +++ b/net/ipv4/ipconfig.c
94635 @@ -334,7 +334,7 @@ static int __init ic_devinet_ioctl(unsigned int cmd, struct ifreq *arg)
94636
94637 mm_segment_t oldfs = get_fs();
94638 set_fs(get_ds());
94639 - res = devinet_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94640 + res = devinet_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94641 set_fs(oldfs);
94642 return res;
94643 }
94644 @@ -345,7 +345,7 @@ static int __init ic_dev_ioctl(unsigned int cmd, struct ifreq *arg)
94645
94646 mm_segment_t oldfs = get_fs();
94647 set_fs(get_ds());
94648 - res = dev_ioctl(&init_net, cmd, (struct ifreq __user *) arg);
94649 + res = dev_ioctl(&init_net, cmd, (struct ifreq __force_user *) arg);
94650 set_fs(oldfs);
94651 return res;
94652 }
94653 @@ -356,7 +356,7 @@ static int __init ic_route_ioctl(unsigned int cmd, struct rtentry *arg)
94654
94655 mm_segment_t oldfs = get_fs();
94656 set_fs(get_ds());
94657 - res = ip_rt_ioctl(&init_net, cmd, (void __user *) arg);
94658 + res = ip_rt_ioctl(&init_net, cmd, (void __force_user *) arg);
94659 set_fs(oldfs);
94660 return res;
94661 }
94662 diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
94663 index 7f80fb4..b0328f6 100644
94664 --- a/net/ipv4/ipip.c
94665 +++ b/net/ipv4/ipip.c
94666 @@ -124,7 +124,7 @@ MODULE_PARM_DESC(log_ecn_error, "Log packets received with corrupted ECN");
94667 static int ipip_net_id __read_mostly;
94668
94669 static int ipip_tunnel_init(struct net_device *dev);
94670 -static struct rtnl_link_ops ipip_link_ops __read_mostly;
94671 +static struct rtnl_link_ops ipip_link_ops;
94672
94673 static int ipip_err(struct sk_buff *skb, u32 info)
94674 {
94675 @@ -408,7 +408,7 @@ static const struct nla_policy ipip_policy[IFLA_IPTUN_MAX + 1] = {
94676 [IFLA_IPTUN_PMTUDISC] = { .type = NLA_U8 },
94677 };
94678
94679 -static struct rtnl_link_ops ipip_link_ops __read_mostly = {
94680 +static struct rtnl_link_ops ipip_link_ops = {
94681 .kind = "ipip",
94682 .maxtype = IFLA_IPTUN_MAX,
94683 .policy = ipip_policy,
94684 diff --git a/net/ipv4/netfilter/arp_tables.c b/net/ipv4/netfilter/arp_tables.c
94685 index 85a4f21..1beb1f5 100644
94686 --- a/net/ipv4/netfilter/arp_tables.c
94687 +++ b/net/ipv4/netfilter/arp_tables.c
94688 @@ -880,14 +880,14 @@ static int compat_table_info(const struct xt_table_info *info,
94689 #endif
94690
94691 static int get_info(struct net *net, void __user *user,
94692 - const int *len, int compat)
94693 + int len, int compat)
94694 {
94695 char name[XT_TABLE_MAXNAMELEN];
94696 struct xt_table *t;
94697 int ret;
94698
94699 - if (*len != sizeof(struct arpt_getinfo)) {
94700 - duprintf("length %u != %Zu\n", *len,
94701 + if (len != sizeof(struct arpt_getinfo)) {
94702 + duprintf("length %u != %Zu\n", len,
94703 sizeof(struct arpt_getinfo));
94704 return -EINVAL;
94705 }
94706 @@ -924,7 +924,7 @@ static int get_info(struct net *net, void __user *user,
94707 info.size = private->size;
94708 strcpy(info.name, name);
94709
94710 - if (copy_to_user(user, &info, *len) != 0)
94711 + if (copy_to_user(user, &info, len) != 0)
94712 ret = -EFAULT;
94713 else
94714 ret = 0;
94715 @@ -1683,7 +1683,7 @@ static int compat_do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user,
94716
94717 switch (cmd) {
94718 case ARPT_SO_GET_INFO:
94719 - ret = get_info(sock_net(sk), user, len, 1);
94720 + ret = get_info(sock_net(sk), user, *len, 1);
94721 break;
94722 case ARPT_SO_GET_ENTRIES:
94723 ret = compat_get_entries(sock_net(sk), user, len);
94724 @@ -1728,7 +1728,7 @@ static int do_arpt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len
94725
94726 switch (cmd) {
94727 case ARPT_SO_GET_INFO:
94728 - ret = get_info(sock_net(sk), user, len, 0);
94729 + ret = get_info(sock_net(sk), user, *len, 0);
94730 break;
94731
94732 case ARPT_SO_GET_ENTRIES:
94733 diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
94734 index d23118d..6ad7277 100644
94735 --- a/net/ipv4/netfilter/ip_tables.c
94736 +++ b/net/ipv4/netfilter/ip_tables.c
94737 @@ -1068,14 +1068,14 @@ static int compat_table_info(const struct xt_table_info *info,
94738 #endif
94739
94740 static int get_info(struct net *net, void __user *user,
94741 - const int *len, int compat)
94742 + int len, int compat)
94743 {
94744 char name[XT_TABLE_MAXNAMELEN];
94745 struct xt_table *t;
94746 int ret;
94747
94748 - if (*len != sizeof(struct ipt_getinfo)) {
94749 - duprintf("length %u != %zu\n", *len,
94750 + if (len != sizeof(struct ipt_getinfo)) {
94751 + duprintf("length %u != %zu\n", len,
94752 sizeof(struct ipt_getinfo));
94753 return -EINVAL;
94754 }
94755 @@ -1112,7 +1112,7 @@ static int get_info(struct net *net, void __user *user,
94756 info.size = private->size;
94757 strcpy(info.name, name);
94758
94759 - if (copy_to_user(user, &info, *len) != 0)
94760 + if (copy_to_user(user, &info, len) != 0)
94761 ret = -EFAULT;
94762 else
94763 ret = 0;
94764 @@ -1966,7 +1966,7 @@ compat_do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94765
94766 switch (cmd) {
94767 case IPT_SO_GET_INFO:
94768 - ret = get_info(sock_net(sk), user, len, 1);
94769 + ret = get_info(sock_net(sk), user, *len, 1);
94770 break;
94771 case IPT_SO_GET_ENTRIES:
94772 ret = compat_get_entries(sock_net(sk), user, len);
94773 @@ -2013,7 +2013,7 @@ do_ipt_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
94774
94775 switch (cmd) {
94776 case IPT_SO_GET_INFO:
94777 - ret = get_info(sock_net(sk), user, len, 0);
94778 + ret = get_info(sock_net(sk), user, *len, 0);
94779 break;
94780
94781 case IPT_SO_GET_ENTRIES:
94782 diff --git a/net/ipv4/netfilter/ipt_ULOG.c b/net/ipv4/netfilter/ipt_ULOG.c
94783 index cbc2215..9cb993c 100644
94784 --- a/net/ipv4/netfilter/ipt_ULOG.c
94785 +++ b/net/ipv4/netfilter/ipt_ULOG.c
94786 @@ -220,6 +220,7 @@ static void ipt_ulog_packet(struct net *net,
94787 ub->qlen++;
94788
94789 pm = nlmsg_data(nlh);
94790 + memset(pm, 0, sizeof(*pm));
94791
94792 /* We might not have a timestamp, get one */
94793 if (skb->tstamp.tv64 == 0)
94794 @@ -238,8 +239,6 @@ static void ipt_ulog_packet(struct net *net,
94795 }
94796 else if (loginfo->prefix[0] != '\0')
94797 strncpy(pm->prefix, loginfo->prefix, sizeof(pm->prefix));
94798 - else
94799 - *(pm->prefix) = '\0';
94800
94801 if (in && in->hard_header_len > 0 &&
94802 skb->mac_header != skb->network_header &&
94803 @@ -251,13 +250,9 @@ static void ipt_ulog_packet(struct net *net,
94804
94805 if (in)
94806 strncpy(pm->indev_name, in->name, sizeof(pm->indev_name));
94807 - else
94808 - pm->indev_name[0] = '\0';
94809
94810 if (out)
94811 strncpy(pm->outdev_name, out->name, sizeof(pm->outdev_name));
94812 - else
94813 - pm->outdev_name[0] = '\0';
94814
94815 /* copy_len <= skb->len, so can't fail. */
94816 if (skb_copy_bits(skb, 0, pm->payload, copy_len) < 0)
94817 diff --git a/net/ipv4/ping.c b/net/ipv4/ping.c
94818 index c482f7c..2784262 100644
94819 --- a/net/ipv4/ping.c
94820 +++ b/net/ipv4/ping.c
94821 @@ -55,7 +55,7 @@
94822
94823
94824 struct ping_table ping_table;
94825 -struct pingv6_ops pingv6_ops;
94826 +struct pingv6_ops *pingv6_ops;
94827 EXPORT_SYMBOL_GPL(pingv6_ops);
94828
94829 static u16 ping_port_rover;
94830 @@ -335,7 +335,7 @@ static int ping_check_bind_addr(struct sock *sk, struct inet_sock *isk,
94831 return -ENODEV;
94832 }
94833 }
94834 - has_addr = pingv6_ops.ipv6_chk_addr(net, &addr->sin6_addr, dev,
94835 + has_addr = pingv6_ops->ipv6_chk_addr(net, &addr->sin6_addr, dev,
94836 scoped);
94837 rcu_read_unlock();
94838
94839 @@ -541,7 +541,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
94840 }
94841 #if IS_ENABLED(CONFIG_IPV6)
94842 } else if (skb->protocol == htons(ETH_P_IPV6)) {
94843 - harderr = pingv6_ops.icmpv6_err_convert(type, code, &err);
94844 + harderr = pingv6_ops->icmpv6_err_convert(type, code, &err);
94845 #endif
94846 }
94847
94848 @@ -559,7 +559,7 @@ void ping_err(struct sk_buff *skb, int offset, u32 info)
94849 info, (u8 *)icmph);
94850 #if IS_ENABLED(CONFIG_IPV6)
94851 } else if (family == AF_INET6) {
94852 - pingv6_ops.ipv6_icmp_error(sk, skb, err, 0,
94853 + pingv6_ops->ipv6_icmp_error(sk, skb, err, 0,
94854 info, (u8 *)icmph);
94855 #endif
94856 }
94857 @@ -841,7 +841,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94858 return ip_recv_error(sk, msg, len, addr_len);
94859 #if IS_ENABLED(CONFIG_IPV6)
94860 } else if (family == AF_INET6) {
94861 - return pingv6_ops.ipv6_recv_error(sk, msg, len,
94862 + return pingv6_ops->ipv6_recv_error(sk, msg, len,
94863 addr_len);
94864 #endif
94865 }
94866 @@ -900,7 +900,7 @@ int ping_recvmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
94867 }
94868
94869 if (inet6_sk(sk)->rxopt.all)
94870 - pingv6_ops.ip6_datagram_recv_ctl(sk, msg, skb);
94871 + pingv6_ops->ip6_datagram_recv_ctl(sk, msg, skb);
94872 #endif
94873 } else {
94874 BUG();
94875 @@ -1090,7 +1090,7 @@ static void ping_v4_format_sock(struct sock *sp, struct seq_file *f,
94876 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
94877 0, sock_i_ino(sp),
94878 atomic_read(&sp->sk_refcnt), sp,
94879 - atomic_read(&sp->sk_drops), len);
94880 + atomic_read_unchecked(&sp->sk_drops), len);
94881 }
94882
94883 static int ping_v4_seq_show(struct seq_file *seq, void *v)
94884 diff --git a/net/ipv4/raw.c b/net/ipv4/raw.c
94885 index 7d3db78..9fd511d 100644
94886 --- a/net/ipv4/raw.c
94887 +++ b/net/ipv4/raw.c
94888 @@ -311,7 +311,7 @@ static int raw_rcv_skb(struct sock *sk, struct sk_buff *skb)
94889 int raw_rcv(struct sock *sk, struct sk_buff *skb)
94890 {
94891 if (!xfrm4_policy_check(sk, XFRM_POLICY_IN, skb)) {
94892 - atomic_inc(&sk->sk_drops);
94893 + atomic_inc_unchecked(&sk->sk_drops);
94894 kfree_skb(skb);
94895 return NET_RX_DROP;
94896 }
94897 @@ -746,16 +746,20 @@ static int raw_init(struct sock *sk)
94898
94899 static int raw_seticmpfilter(struct sock *sk, char __user *optval, int optlen)
94900 {
94901 + struct icmp_filter filter;
94902 +
94903 if (optlen > sizeof(struct icmp_filter))
94904 optlen = sizeof(struct icmp_filter);
94905 - if (copy_from_user(&raw_sk(sk)->filter, optval, optlen))
94906 + if (copy_from_user(&filter, optval, optlen))
94907 return -EFAULT;
94908 + raw_sk(sk)->filter = filter;
94909 return 0;
94910 }
94911
94912 static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *optlen)
94913 {
94914 int len, ret = -EFAULT;
94915 + struct icmp_filter filter;
94916
94917 if (get_user(len, optlen))
94918 goto out;
94919 @@ -765,8 +769,8 @@ static int raw_geticmpfilter(struct sock *sk, char __user *optval, int __user *o
94920 if (len > sizeof(struct icmp_filter))
94921 len = sizeof(struct icmp_filter);
94922 ret = -EFAULT;
94923 - if (put_user(len, optlen) ||
94924 - copy_to_user(optval, &raw_sk(sk)->filter, len))
94925 + filter = raw_sk(sk)->filter;
94926 + if (put_user(len, optlen) || len > sizeof filter || copy_to_user(optval, &filter, len))
94927 goto out;
94928 ret = 0;
94929 out: return ret;
94930 @@ -995,7 +999,7 @@ static void raw_sock_seq_show(struct seq_file *seq, struct sock *sp, int i)
94931 0, 0L, 0,
94932 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sp)),
94933 0, sock_i_ino(sp),
94934 - atomic_read(&sp->sk_refcnt), sp, atomic_read(&sp->sk_drops));
94935 + atomic_read(&sp->sk_refcnt), sp, atomic_read_unchecked(&sp->sk_drops));
94936 }
94937
94938 static int raw_seq_show(struct seq_file *seq, void *v)
94939 diff --git a/net/ipv4/route.c b/net/ipv4/route.c
94940 index 62290b5..f0d944f 100644
94941 --- a/net/ipv4/route.c
94942 +++ b/net/ipv4/route.c
94943 @@ -2617,34 +2617,34 @@ static struct ctl_table ipv4_route_flush_table[] = {
94944 .maxlen = sizeof(int),
94945 .mode = 0200,
94946 .proc_handler = ipv4_sysctl_rtcache_flush,
94947 + .extra1 = &init_net,
94948 },
94949 { },
94950 };
94951
94952 static __net_init int sysctl_route_net_init(struct net *net)
94953 {
94954 - struct ctl_table *tbl;
94955 + ctl_table_no_const *tbl = NULL;
94956
94957 - tbl = ipv4_route_flush_table;
94958 if (!net_eq(net, &init_net)) {
94959 - tbl = kmemdup(tbl, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94960 + tbl = kmemdup(ipv4_route_flush_table, sizeof(ipv4_route_flush_table), GFP_KERNEL);
94961 if (tbl == NULL)
94962 goto err_dup;
94963
94964 /* Don't export sysctls to unprivileged users */
94965 if (net->user_ns != &init_user_ns)
94966 tbl[0].procname = NULL;
94967 - }
94968 - tbl[0].extra1 = net;
94969 + tbl[0].extra1 = net;
94970 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94971 + } else
94972 + net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", ipv4_route_flush_table);
94973
94974 - net->ipv4.route_hdr = register_net_sysctl(net, "net/ipv4/route", tbl);
94975 if (net->ipv4.route_hdr == NULL)
94976 goto err_reg;
94977 return 0;
94978
94979 err_reg:
94980 - if (tbl != ipv4_route_flush_table)
94981 - kfree(tbl);
94982 + kfree(tbl);
94983 err_dup:
94984 return -ENOMEM;
94985 }
94986 @@ -2667,8 +2667,8 @@ static __net_initdata struct pernet_operations sysctl_route_ops = {
94987
94988 static __net_init int rt_genid_init(struct net *net)
94989 {
94990 - atomic_set(&net->ipv4.rt_genid, 0);
94991 - atomic_set(&net->fnhe_genid, 0);
94992 + atomic_set_unchecked(&net->ipv4.rt_genid, 0);
94993 + atomic_set_unchecked(&net->fnhe_genid, 0);
94994 get_random_bytes(&net->ipv4.dev_addr_genid,
94995 sizeof(net->ipv4.dev_addr_genid));
94996 return 0;
94997 diff --git a/net/ipv4/sysctl_net_ipv4.c b/net/ipv4/sysctl_net_ipv4.c
94998 index 540279f..9855b16 100644
94999 --- a/net/ipv4/sysctl_net_ipv4.c
95000 +++ b/net/ipv4/sysctl_net_ipv4.c
95001 @@ -58,7 +58,7 @@ static int ipv4_local_port_range(struct ctl_table *table, int write,
95002 {
95003 int ret;
95004 int range[2];
95005 - struct ctl_table tmp = {
95006 + ctl_table_no_const tmp = {
95007 .data = &range,
95008 .maxlen = sizeof(range),
95009 .mode = table->mode,
95010 @@ -111,7 +111,7 @@ static int ipv4_ping_group_range(struct ctl_table *table, int write,
95011 int ret;
95012 gid_t urange[2];
95013 kgid_t low, high;
95014 - struct ctl_table tmp = {
95015 + ctl_table_no_const tmp = {
95016 .data = &urange,
95017 .maxlen = sizeof(urange),
95018 .mode = table->mode,
95019 @@ -142,7 +142,7 @@ static int proc_tcp_congestion_control(struct ctl_table *ctl, int write,
95020 void __user *buffer, size_t *lenp, loff_t *ppos)
95021 {
95022 char val[TCP_CA_NAME_MAX];
95023 - struct ctl_table tbl = {
95024 + ctl_table_no_const tbl = {
95025 .data = val,
95026 .maxlen = TCP_CA_NAME_MAX,
95027 };
95028 @@ -161,7 +161,7 @@ static int proc_tcp_available_congestion_control(struct ctl_table *ctl,
95029 void __user *buffer, size_t *lenp,
95030 loff_t *ppos)
95031 {
95032 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX, };
95033 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX, };
95034 int ret;
95035
95036 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
95037 @@ -178,7 +178,7 @@ static int proc_allowed_congestion_control(struct ctl_table *ctl,
95038 void __user *buffer, size_t *lenp,
95039 loff_t *ppos)
95040 {
95041 - struct ctl_table tbl = { .maxlen = TCP_CA_BUF_MAX };
95042 + ctl_table_no_const tbl = { .maxlen = TCP_CA_BUF_MAX };
95043 int ret;
95044
95045 tbl.data = kmalloc(tbl.maxlen, GFP_USER);
95046 @@ -204,15 +204,17 @@ static int ipv4_tcp_mem(struct ctl_table *ctl, int write,
95047 struct mem_cgroup *memcg;
95048 #endif
95049
95050 - struct ctl_table tmp = {
95051 + ctl_table_no_const tmp = {
95052 .data = &vec,
95053 .maxlen = sizeof(vec),
95054 .mode = ctl->mode,
95055 };
95056
95057 if (!write) {
95058 - ctl->data = &net->ipv4.sysctl_tcp_mem;
95059 - return proc_doulongvec_minmax(ctl, write, buffer, lenp, ppos);
95060 + ctl_table_no_const tcp_mem = *ctl;
95061 +
95062 + tcp_mem.data = &net->ipv4.sysctl_tcp_mem;
95063 + return proc_doulongvec_minmax(&tcp_mem, write, buffer, lenp, ppos);
95064 }
95065
95066 ret = proc_doulongvec_minmax(&tmp, write, buffer, lenp, ppos);
95067 @@ -240,7 +242,7 @@ static int proc_tcp_fastopen_key(struct ctl_table *ctl, int write,
95068 void __user *buffer, size_t *lenp,
95069 loff_t *ppos)
95070 {
95071 - struct ctl_table tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
95072 + ctl_table_no_const tbl = { .maxlen = (TCP_FASTOPEN_KEY_LENGTH * 2 + 10) };
95073 struct tcp_fastopen_context *ctxt;
95074 int ret;
95075 u32 user_key[4]; /* 16 bytes, matching TCP_FASTOPEN_KEY_LENGTH */
95076 @@ -483,7 +485,7 @@ static struct ctl_table ipv4_table[] = {
95077 },
95078 {
95079 .procname = "ip_local_reserved_ports",
95080 - .data = NULL, /* initialized in sysctl_ipv4_init */
95081 + .data = sysctl_local_reserved_ports,
95082 .maxlen = 65536,
95083 .mode = 0644,
95084 .proc_handler = proc_do_large_bitmap,
95085 @@ -864,11 +866,10 @@ static struct ctl_table ipv4_net_table[] = {
95086
95087 static __net_init int ipv4_sysctl_init_net(struct net *net)
95088 {
95089 - struct ctl_table *table;
95090 + ctl_table_no_const *table = NULL;
95091
95092 - table = ipv4_net_table;
95093 if (!net_eq(net, &init_net)) {
95094 - table = kmemdup(table, sizeof(ipv4_net_table), GFP_KERNEL);
95095 + table = kmemdup(ipv4_net_table, sizeof(ipv4_net_table), GFP_KERNEL);
95096 if (table == NULL)
95097 goto err_alloc;
95098
95099 @@ -903,15 +904,17 @@ static __net_init int ipv4_sysctl_init_net(struct net *net)
95100
95101 tcp_init_mem(net);
95102
95103 - net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
95104 + if (!net_eq(net, &init_net))
95105 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", table);
95106 + else
95107 + net->ipv4.ipv4_hdr = register_net_sysctl(net, "net/ipv4", ipv4_net_table);
95108 if (net->ipv4.ipv4_hdr == NULL)
95109 goto err_reg;
95110
95111 return 0;
95112
95113 err_reg:
95114 - if (!net_eq(net, &init_net))
95115 - kfree(table);
95116 + kfree(table);
95117 err_alloc:
95118 return -ENOMEM;
95119 }
95120 @@ -933,16 +936,6 @@ static __net_initdata struct pernet_operations ipv4_sysctl_ops = {
95121 static __init int sysctl_ipv4_init(void)
95122 {
95123 struct ctl_table_header *hdr;
95124 - struct ctl_table *i;
95125 -
95126 - for (i = ipv4_table; i->procname; i++) {
95127 - if (strcmp(i->procname, "ip_local_reserved_ports") == 0) {
95128 - i->data = sysctl_local_reserved_ports;
95129 - break;
95130 - }
95131 - }
95132 - if (!i->procname)
95133 - return -EINVAL;
95134
95135 hdr = register_net_sysctl(&init_net, "net/ipv4", ipv4_table);
95136 if (hdr == NULL)
95137 diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c
95138 index 068c8fb..a755c52 100644
95139 --- a/net/ipv4/tcp_input.c
95140 +++ b/net/ipv4/tcp_input.c
95141 @@ -4435,7 +4435,7 @@ static struct sk_buff *tcp_collapse_one(struct sock *sk, struct sk_buff *skb,
95142 * simplifies code)
95143 */
95144 static void
95145 -tcp_collapse(struct sock *sk, struct sk_buff_head *list,
95146 +__intentional_overflow(5,6) tcp_collapse(struct sock *sk, struct sk_buff_head *list,
95147 struct sk_buff *head, struct sk_buff *tail,
95148 u32 start, u32 end)
95149 {
95150 @@ -5520,6 +5520,7 @@ discard:
95151 tcp_paws_reject(&tp->rx_opt, 0))
95152 goto discard_and_undo;
95153
95154 +#ifndef CONFIG_GRKERNSEC_NO_SIMULT_CONNECT
95155 if (th->syn) {
95156 /* We see SYN without ACK. It is attempt of
95157 * simultaneous connect with crossed SYNs.
95158 @@ -5570,6 +5571,7 @@ discard:
95159 goto discard;
95160 #endif
95161 }
95162 +#endif
95163 /* "fifth, if neither of the SYN or RST bits is set then
95164 * drop the segment and return."
95165 */
95166 @@ -5616,7 +5618,7 @@ int tcp_rcv_state_process(struct sock *sk, struct sk_buff *skb,
95167 goto discard;
95168
95169 if (th->syn) {
95170 - if (th->fin)
95171 + if (th->fin || th->urg || th->psh)
95172 goto discard;
95173 if (icsk->icsk_af_ops->conn_request(sk, skb) < 0)
95174 return 1;
95175 diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
95176 index 5031f68..91569e2 100644
95177 --- a/net/ipv4/tcp_ipv4.c
95178 +++ b/net/ipv4/tcp_ipv4.c
95179 @@ -91,6 +91,10 @@ int sysctl_tcp_low_latency __read_mostly;
95180 EXPORT_SYMBOL(sysctl_tcp_low_latency);
95181
95182
95183 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95184 +extern int grsec_enable_blackhole;
95185 +#endif
95186 +
95187 #ifdef CONFIG_TCP_MD5SIG
95188 static int tcp_v4_md5_hash_hdr(char *md5_hash, const struct tcp_md5sig_key *key,
95189 __be32 daddr, __be32 saddr, const struct tcphdr *th);
95190 @@ -1829,6 +1833,9 @@ int tcp_v4_do_rcv(struct sock *sk, struct sk_buff *skb)
95191 return 0;
95192
95193 reset:
95194 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95195 + if (!grsec_enable_blackhole)
95196 +#endif
95197 tcp_v4_send_reset(rsk, skb);
95198 discard:
95199 kfree_skb(skb);
95200 @@ -1974,12 +1981,19 @@ int tcp_v4_rcv(struct sk_buff *skb)
95201 TCP_SKB_CB(skb)->sacked = 0;
95202
95203 sk = __inet_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
95204 - if (!sk)
95205 + if (!sk) {
95206 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95207 + ret = 1;
95208 +#endif
95209 goto no_tcp_socket;
95210 -
95211 + }
95212 process:
95213 - if (sk->sk_state == TCP_TIME_WAIT)
95214 + if (sk->sk_state == TCP_TIME_WAIT) {
95215 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95216 + ret = 2;
95217 +#endif
95218 goto do_time_wait;
95219 + }
95220
95221 if (unlikely(iph->ttl < inet_sk(sk)->min_ttl)) {
95222 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
95223 @@ -2033,6 +2047,10 @@ csum_error:
95224 bad_packet:
95225 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
95226 } else {
95227 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95228 + if (!grsec_enable_blackhole || (ret == 1 &&
95229 + (skb->dev->flags & IFF_LOOPBACK)))
95230 +#endif
95231 tcp_v4_send_reset(NULL, skb);
95232 }
95233
95234 diff --git a/net/ipv4/tcp_minisocks.c b/net/ipv4/tcp_minisocks.c
95235 index 58a3e69..7f0626e 100644
95236 --- a/net/ipv4/tcp_minisocks.c
95237 +++ b/net/ipv4/tcp_minisocks.c
95238 @@ -27,6 +27,10 @@
95239 #include <net/inet_common.h>
95240 #include <net/xfrm.h>
95241
95242 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95243 +extern int grsec_enable_blackhole;
95244 +#endif
95245 +
95246 int sysctl_tcp_syncookies __read_mostly = 1;
95247 EXPORT_SYMBOL(sysctl_tcp_syncookies);
95248
95249 @@ -711,7 +715,10 @@ embryonic_reset:
95250 * avoid becoming vulnerable to outside attack aiming at
95251 * resetting legit local connections.
95252 */
95253 - req->rsk_ops->send_reset(sk, skb);
95254 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95255 + if (!grsec_enable_blackhole)
95256 +#endif
95257 + req->rsk_ops->send_reset(sk, skb);
95258 } else if (fastopen) { /* received a valid RST pkt */
95259 reqsk_fastopen_remove(sk, req, true);
95260 tcp_reset(sk);
95261 diff --git a/net/ipv4/tcp_probe.c b/net/ipv4/tcp_probe.c
95262 index 611beab..c4b6e1d 100644
95263 --- a/net/ipv4/tcp_probe.c
95264 +++ b/net/ipv4/tcp_probe.c
95265 @@ -245,7 +245,7 @@ static ssize_t tcpprobe_read(struct file *file, char __user *buf,
95266 if (cnt + width >= len)
95267 break;
95268
95269 - if (copy_to_user(buf + cnt, tbuf, width))
95270 + if (width > sizeof tbuf || copy_to_user(buf + cnt, tbuf, width))
95271 return -EFAULT;
95272 cnt += width;
95273 }
95274 diff --git a/net/ipv4/tcp_timer.c b/net/ipv4/tcp_timer.c
95275 index 4b85e6f..22f9ac9 100644
95276 --- a/net/ipv4/tcp_timer.c
95277 +++ b/net/ipv4/tcp_timer.c
95278 @@ -22,6 +22,10 @@
95279 #include <linux/gfp.h>
95280 #include <net/tcp.h>
95281
95282 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95283 +extern int grsec_lastack_retries;
95284 +#endif
95285 +
95286 int sysctl_tcp_syn_retries __read_mostly = TCP_SYN_RETRIES;
95287 int sysctl_tcp_synack_retries __read_mostly = TCP_SYNACK_RETRIES;
95288 int sysctl_tcp_keepalive_time __read_mostly = TCP_KEEPALIVE_TIME;
95289 @@ -185,6 +189,13 @@ static int tcp_write_timeout(struct sock *sk)
95290 }
95291 }
95292
95293 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95294 + if ((sk->sk_state == TCP_LAST_ACK) &&
95295 + (grsec_lastack_retries > 0) &&
95296 + (grsec_lastack_retries < retry_until))
95297 + retry_until = grsec_lastack_retries;
95298 +#endif
95299 +
95300 if (retransmits_timed_out(sk, retry_until,
95301 syn_set ? 0 : icsk->icsk_user_timeout, syn_set)) {
95302 /* Has it gone just too far? */
95303 diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
95304 index 5e2c2f1..6473c22 100644
95305 --- a/net/ipv4/udp.c
95306 +++ b/net/ipv4/udp.c
95307 @@ -87,6 +87,7 @@
95308 #include <linux/types.h>
95309 #include <linux/fcntl.h>
95310 #include <linux/module.h>
95311 +#include <linux/security.h>
95312 #include <linux/socket.h>
95313 #include <linux/sockios.h>
95314 #include <linux/igmp.h>
95315 @@ -112,6 +113,10 @@
95316 #include <net/busy_poll.h>
95317 #include "udp_impl.h"
95318
95319 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95320 +extern int grsec_enable_blackhole;
95321 +#endif
95322 +
95323 struct udp_table udp_table __read_mostly;
95324 EXPORT_SYMBOL(udp_table);
95325
95326 @@ -595,6 +600,9 @@ found:
95327 return s;
95328 }
95329
95330 +extern int gr_search_udp_recvmsg(struct sock *sk, const struct sk_buff *skb);
95331 +extern int gr_search_udp_sendmsg(struct sock *sk, struct sockaddr_in *addr);
95332 +
95333 /*
95334 * This routine is called by the ICMP module when it gets some
95335 * sort of error condition. If err < 0 then the socket should
95336 @@ -892,9 +900,18 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
95337 dport = usin->sin_port;
95338 if (dport == 0)
95339 return -EINVAL;
95340 +
95341 + err = gr_search_udp_sendmsg(sk, usin);
95342 + if (err)
95343 + return err;
95344 } else {
95345 if (sk->sk_state != TCP_ESTABLISHED)
95346 return -EDESTADDRREQ;
95347 +
95348 + err = gr_search_udp_sendmsg(sk, NULL);
95349 + if (err)
95350 + return err;
95351 +
95352 daddr = inet->inet_daddr;
95353 dport = inet->inet_dport;
95354 /* Open fast path for connected socket.
95355 @@ -1141,7 +1158,7 @@ static unsigned int first_packet_length(struct sock *sk)
95356 IS_UDPLITE(sk));
95357 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95358 IS_UDPLITE(sk));
95359 - atomic_inc(&sk->sk_drops);
95360 + atomic_inc_unchecked(&sk->sk_drops);
95361 __skb_unlink(skb, rcvq);
95362 __skb_queue_tail(&list_kill, skb);
95363 }
95364 @@ -1221,6 +1238,10 @@ try_again:
95365 if (!skb)
95366 goto out;
95367
95368 + err = gr_search_udp_recvmsg(sk, skb);
95369 + if (err)
95370 + goto out_free;
95371 +
95372 ulen = skb->len - sizeof(struct udphdr);
95373 copied = len;
95374 if (copied > ulen)
95375 @@ -1254,7 +1275,7 @@ try_again:
95376 if (unlikely(err)) {
95377 trace_kfree_skb(skb, udp_recvmsg);
95378 if (!peeked) {
95379 - atomic_inc(&sk->sk_drops);
95380 + atomic_inc_unchecked(&sk->sk_drops);
95381 UDP_INC_STATS_USER(sock_net(sk),
95382 UDP_MIB_INERRORS, is_udplite);
95383 }
95384 @@ -1542,7 +1563,7 @@ csum_error:
95385 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
95386 drop:
95387 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
95388 - atomic_inc(&sk->sk_drops);
95389 + atomic_inc_unchecked(&sk->sk_drops);
95390 kfree_skb(skb);
95391 return -1;
95392 }
95393 @@ -1561,7 +1582,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
95394 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
95395
95396 if (!skb1) {
95397 - atomic_inc(&sk->sk_drops);
95398 + atomic_inc_unchecked(&sk->sk_drops);
95399 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
95400 IS_UDPLITE(sk));
95401 UDP_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
95402 @@ -1733,6 +1754,9 @@ int __udp4_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
95403 goto csum_error;
95404
95405 UDP_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
95406 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95407 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
95408 +#endif
95409 icmp_send(skb, ICMP_DEST_UNREACH, ICMP_PORT_UNREACH, 0);
95410
95411 /*
95412 @@ -2165,7 +2189,7 @@ static void udp4_format_sock(struct sock *sp, struct seq_file *f,
95413 from_kuid_munged(seq_user_ns(f), sock_i_uid(sp)),
95414 0, sock_i_ino(sp),
95415 atomic_read(&sp->sk_refcnt), sp,
95416 - atomic_read(&sp->sk_drops), len);
95417 + atomic_read_unchecked(&sp->sk_drops), len);
95418 }
95419
95420 int udp4_seq_show(struct seq_file *seq, void *v)
95421 diff --git a/net/ipv4/xfrm4_policy.c b/net/ipv4/xfrm4_policy.c
95422 index adf9983..8e45d0a 100644
95423 --- a/net/ipv4/xfrm4_policy.c
95424 +++ b/net/ipv4/xfrm4_policy.c
95425 @@ -186,11 +186,11 @@ _decode_session4(struct sk_buff *skb, struct flowi *fl, int reverse)
95426 fl4->flowi4_tos = iph->tos;
95427 }
95428
95429 -static inline int xfrm4_garbage_collect(struct dst_ops *ops)
95430 +static int xfrm4_garbage_collect(struct dst_ops *ops)
95431 {
95432 struct net *net = container_of(ops, struct net, xfrm.xfrm4_dst_ops);
95433
95434 - xfrm4_policy_afinfo.garbage_collect(net);
95435 + xfrm_garbage_collect_deferred(net);
95436 return (dst_entries_get_slow(ops) > ops->gc_thresh * 2);
95437 }
95438
95439 @@ -269,19 +269,18 @@ static struct ctl_table xfrm4_policy_table[] = {
95440
95441 static int __net_init xfrm4_net_init(struct net *net)
95442 {
95443 - struct ctl_table *table;
95444 + ctl_table_no_const *table = NULL;
95445 struct ctl_table_header *hdr;
95446
95447 - table = xfrm4_policy_table;
95448 if (!net_eq(net, &init_net)) {
95449 - table = kmemdup(table, sizeof(xfrm4_policy_table), GFP_KERNEL);
95450 + table = kmemdup(xfrm4_policy_table, sizeof(xfrm4_policy_table), GFP_KERNEL);
95451 if (!table)
95452 goto err_alloc;
95453
95454 table[0].data = &net->xfrm.xfrm4_dst_ops.gc_thresh;
95455 - }
95456 -
95457 - hdr = register_net_sysctl(net, "net/ipv4", table);
95458 + hdr = register_net_sysctl(net, "net/ipv4", table);
95459 + } else
95460 + hdr = register_net_sysctl(net, "net/ipv4", xfrm4_policy_table);
95461 if (!hdr)
95462 goto err_reg;
95463
95464 @@ -289,8 +288,7 @@ static int __net_init xfrm4_net_init(struct net *net)
95465 return 0;
95466
95467 err_reg:
95468 - if (!net_eq(net, &init_net))
95469 - kfree(table);
95470 + kfree(table);
95471 err_alloc:
95472 return -ENOMEM;
95473 }
95474 diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
95475 index cd3fb30..b7dfef7 100644
95476 --- a/net/ipv6/addrconf.c
95477 +++ b/net/ipv6/addrconf.c
95478 @@ -586,7 +586,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb,
95479 idx = 0;
95480 head = &net->dev_index_head[h];
95481 rcu_read_lock();
95482 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^
95483 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^
95484 net->dev_base_seq;
95485 hlist_for_each_entry_rcu(dev, head, index_hlist) {
95486 if (idx < s_idx)
95487 @@ -2364,7 +2364,7 @@ int addrconf_set_dstaddr(struct net *net, void __user *arg)
95488 p.iph.ihl = 5;
95489 p.iph.protocol = IPPROTO_IPV6;
95490 p.iph.ttl = 64;
95491 - ifr.ifr_ifru.ifru_data = (__force void __user *)&p;
95492 + ifr.ifr_ifru.ifru_data = (void __force_user *)&p;
95493
95494 if (ops->ndo_do_ioctl) {
95495 mm_segment_t oldfs = get_fs();
95496 @@ -3977,7 +3977,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb,
95497 s_ip_idx = ip_idx = cb->args[2];
95498
95499 rcu_read_lock();
95500 - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
95501 + cb->seq = atomic_read_unchecked(&net->ipv6.dev_addr_genid) ^ net->dev_base_seq;
95502 for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) {
95503 idx = 0;
95504 head = &net->dev_index_head[h];
95505 @@ -4603,7 +4603,7 @@ static void __ipv6_ifa_notify(int event, struct inet6_ifaddr *ifp)
95506 dst_free(&ifp->rt->dst);
95507 break;
95508 }
95509 - atomic_inc(&net->ipv6.dev_addr_genid);
95510 + atomic_inc_unchecked(&net->ipv6.dev_addr_genid);
95511 rt_genid_bump_ipv6(net);
95512 }
95513
95514 @@ -4624,7 +4624,7 @@ int addrconf_sysctl_forward(struct ctl_table *ctl, int write,
95515 int *valp = ctl->data;
95516 int val = *valp;
95517 loff_t pos = *ppos;
95518 - struct ctl_table lctl;
95519 + ctl_table_no_const lctl;
95520 int ret;
95521
95522 /*
95523 @@ -4709,7 +4709,7 @@ int addrconf_sysctl_disable(struct ctl_table *ctl, int write,
95524 int *valp = ctl->data;
95525 int val = *valp;
95526 loff_t pos = *ppos;
95527 - struct ctl_table lctl;
95528 + ctl_table_no_const lctl;
95529 int ret;
95530
95531 /*
95532 diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c
95533 index 8132b44..b8eca70 100644
95534 --- a/net/ipv6/af_inet6.c
95535 +++ b/net/ipv6/af_inet6.c
95536 @@ -767,7 +767,7 @@ static int __net_init inet6_net_init(struct net *net)
95537
95538 net->ipv6.sysctl.bindv6only = 0;
95539 net->ipv6.sysctl.icmpv6_time = 1*HZ;
95540 - atomic_set(&net->ipv6.rt_genid, 0);
95541 + atomic_set_unchecked(&net->ipv6.rt_genid, 0);
95542
95543 err = ipv6_init_mibs(net);
95544 if (err)
95545 diff --git a/net/ipv6/datagram.c b/net/ipv6/datagram.c
95546 index c66c6df..f375d3c 100644
95547 --- a/net/ipv6/datagram.c
95548 +++ b/net/ipv6/datagram.c
95549 @@ -908,5 +908,5 @@ void ip6_dgram_sock_seq_show(struct seq_file *seq, struct sock *sp,
95550 0,
95551 sock_i_ino(sp),
95552 atomic_read(&sp->sk_refcnt), sp,
95553 - atomic_read(&sp->sk_drops));
95554 + atomic_read_unchecked(&sp->sk_drops));
95555 }
95556 diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c
95557 index eef8d94..cfa1852 100644
95558 --- a/net/ipv6/icmp.c
95559 +++ b/net/ipv6/icmp.c
95560 @@ -997,7 +997,7 @@ struct ctl_table ipv6_icmp_table_template[] = {
95561
95562 struct ctl_table * __net_init ipv6_icmp_sysctl_init(struct net *net)
95563 {
95564 - struct ctl_table *table;
95565 + ctl_table_no_const *table;
95566
95567 table = kmemdup(ipv6_icmp_table_template,
95568 sizeof(ipv6_icmp_table_template),
95569 diff --git a/net/ipv6/ip6_gre.c b/net/ipv6/ip6_gre.c
95570 index bf4a9a0..e5f6ac5 100644
95571 --- a/net/ipv6/ip6_gre.c
95572 +++ b/net/ipv6/ip6_gre.c
95573 @@ -74,7 +74,7 @@ struct ip6gre_net {
95574 struct net_device *fb_tunnel_dev;
95575 };
95576
95577 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly;
95578 +static struct rtnl_link_ops ip6gre_link_ops;
95579 static int ip6gre_tunnel_init(struct net_device *dev);
95580 static void ip6gre_tunnel_setup(struct net_device *dev);
95581 static void ip6gre_tunnel_link(struct ip6gre_net *ign, struct ip6_tnl *t);
95582 @@ -1286,7 +1286,7 @@ static void ip6gre_fb_tunnel_init(struct net_device *dev)
95583 }
95584
95585
95586 -static struct inet6_protocol ip6gre_protocol __read_mostly = {
95587 +static struct inet6_protocol ip6gre_protocol = {
95588 .handler = ip6gre_rcv,
95589 .err_handler = ip6gre_err,
95590 .flags = INET6_PROTO_NOPOLICY|INET6_PROTO_FINAL,
95591 @@ -1622,7 +1622,7 @@ static const struct nla_policy ip6gre_policy[IFLA_GRE_MAX + 1] = {
95592 [IFLA_GRE_FLAGS] = { .type = NLA_U32 },
95593 };
95594
95595 -static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
95596 +static struct rtnl_link_ops ip6gre_link_ops = {
95597 .kind = "ip6gre",
95598 .maxtype = IFLA_GRE_MAX,
95599 .policy = ip6gre_policy,
95600 @@ -1635,7 +1635,7 @@ static struct rtnl_link_ops ip6gre_link_ops __read_mostly = {
95601 .fill_info = ip6gre_fill_info,
95602 };
95603
95604 -static struct rtnl_link_ops ip6gre_tap_ops __read_mostly = {
95605 +static struct rtnl_link_ops ip6gre_tap_ops = {
95606 .kind = "ip6gretap",
95607 .maxtype = IFLA_GRE_MAX,
95608 .policy = ip6gre_policy,
95609 diff --git a/net/ipv6/ip6_tunnel.c b/net/ipv6/ip6_tunnel.c
95610 index c1e11b5..568e633 100644
95611 --- a/net/ipv6/ip6_tunnel.c
95612 +++ b/net/ipv6/ip6_tunnel.c
95613 @@ -89,7 +89,7 @@ static u32 HASH(const struct in6_addr *addr1, const struct in6_addr *addr2)
95614
95615 static int ip6_tnl_dev_init(struct net_device *dev);
95616 static void ip6_tnl_dev_setup(struct net_device *dev);
95617 -static struct rtnl_link_ops ip6_link_ops __read_mostly;
95618 +static struct rtnl_link_ops ip6_link_ops;
95619
95620 static int ip6_tnl_net_id __read_mostly;
95621 struct ip6_tnl_net {
95622 @@ -1699,7 +1699,7 @@ static const struct nla_policy ip6_tnl_policy[IFLA_IPTUN_MAX + 1] = {
95623 [IFLA_IPTUN_PROTO] = { .type = NLA_U8 },
95624 };
95625
95626 -static struct rtnl_link_ops ip6_link_ops __read_mostly = {
95627 +static struct rtnl_link_ops ip6_link_ops = {
95628 .kind = "ip6tnl",
95629 .maxtype = IFLA_IPTUN_MAX,
95630 .policy = ip6_tnl_policy,
95631 diff --git a/net/ipv6/ipv6_sockglue.c b/net/ipv6/ipv6_sockglue.c
95632 index d1e2e8e..51c19ae 100644
95633 --- a/net/ipv6/ipv6_sockglue.c
95634 +++ b/net/ipv6/ipv6_sockglue.c
95635 @@ -991,7 +991,7 @@ static int do_ipv6_getsockopt(struct sock *sk, int level, int optname,
95636 if (sk->sk_type != SOCK_STREAM)
95637 return -ENOPROTOOPT;
95638
95639 - msg.msg_control = optval;
95640 + msg.msg_control = (void __force_kernel *)optval;
95641 msg.msg_controllen = len;
95642 msg.msg_flags = flags;
95643
95644 diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
95645 index 44400c2..8e11f52 100644
95646 --- a/net/ipv6/netfilter/ip6_tables.c
95647 +++ b/net/ipv6/netfilter/ip6_tables.c
95648 @@ -1078,14 +1078,14 @@ static int compat_table_info(const struct xt_table_info *info,
95649 #endif
95650
95651 static int get_info(struct net *net, void __user *user,
95652 - const int *len, int compat)
95653 + int len, int compat)
95654 {
95655 char name[XT_TABLE_MAXNAMELEN];
95656 struct xt_table *t;
95657 int ret;
95658
95659 - if (*len != sizeof(struct ip6t_getinfo)) {
95660 - duprintf("length %u != %zu\n", *len,
95661 + if (len != sizeof(struct ip6t_getinfo)) {
95662 + duprintf("length %u != %zu\n", len,
95663 sizeof(struct ip6t_getinfo));
95664 return -EINVAL;
95665 }
95666 @@ -1122,7 +1122,7 @@ static int get_info(struct net *net, void __user *user,
95667 info.size = private->size;
95668 strcpy(info.name, name);
95669
95670 - if (copy_to_user(user, &info, *len) != 0)
95671 + if (copy_to_user(user, &info, len) != 0)
95672 ret = -EFAULT;
95673 else
95674 ret = 0;
95675 @@ -1976,7 +1976,7 @@ compat_do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95676
95677 switch (cmd) {
95678 case IP6T_SO_GET_INFO:
95679 - ret = get_info(sock_net(sk), user, len, 1);
95680 + ret = get_info(sock_net(sk), user, *len, 1);
95681 break;
95682 case IP6T_SO_GET_ENTRIES:
95683 ret = compat_get_entries(sock_net(sk), user, len);
95684 @@ -2023,7 +2023,7 @@ do_ip6t_get_ctl(struct sock *sk, int cmd, void __user *user, int *len)
95685
95686 switch (cmd) {
95687 case IP6T_SO_GET_INFO:
95688 - ret = get_info(sock_net(sk), user, len, 0);
95689 + ret = get_info(sock_net(sk), user, *len, 0);
95690 break;
95691
95692 case IP6T_SO_GET_ENTRIES:
95693 diff --git a/net/ipv6/netfilter/nf_conntrack_reasm.c b/net/ipv6/netfilter/nf_conntrack_reasm.c
95694 index 253566a..9fa50c7 100644
95695 --- a/net/ipv6/netfilter/nf_conntrack_reasm.c
95696 +++ b/net/ipv6/netfilter/nf_conntrack_reasm.c
95697 @@ -90,12 +90,11 @@ static struct ctl_table nf_ct_frag6_sysctl_table[] = {
95698
95699 static int nf_ct_frag6_sysctl_register(struct net *net)
95700 {
95701 - struct ctl_table *table;
95702 + ctl_table_no_const *table = NULL;
95703 struct ctl_table_header *hdr;
95704
95705 - table = nf_ct_frag6_sysctl_table;
95706 if (!net_eq(net, &init_net)) {
95707 - table = kmemdup(table, sizeof(nf_ct_frag6_sysctl_table),
95708 + table = kmemdup(nf_ct_frag6_sysctl_table, sizeof(nf_ct_frag6_sysctl_table),
95709 GFP_KERNEL);
95710 if (table == NULL)
95711 goto err_alloc;
95712 @@ -103,9 +102,9 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95713 table[0].data = &net->nf_frag.frags.timeout;
95714 table[1].data = &net->nf_frag.frags.low_thresh;
95715 table[2].data = &net->nf_frag.frags.high_thresh;
95716 - }
95717 -
95718 - hdr = register_net_sysctl(net, "net/netfilter", table);
95719 + hdr = register_net_sysctl(net, "net/netfilter", table);
95720 + } else
95721 + hdr = register_net_sysctl(net, "net/netfilter", nf_ct_frag6_sysctl_table);
95722 if (hdr == NULL)
95723 goto err_reg;
95724
95725 @@ -113,8 +112,7 @@ static int nf_ct_frag6_sysctl_register(struct net *net)
95726 return 0;
95727
95728 err_reg:
95729 - if (!net_eq(net, &init_net))
95730 - kfree(table);
95731 + kfree(table);
95732 err_alloc:
95733 return -ENOMEM;
95734 }
95735 diff --git a/net/ipv6/output_core.c b/net/ipv6/output_core.c
95736 index 827f795..7e28e82 100644
95737 --- a/net/ipv6/output_core.c
95738 +++ b/net/ipv6/output_core.c
95739 @@ -9,8 +9,8 @@
95740
95741 void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95742 {
95743 - static atomic_t ipv6_fragmentation_id;
95744 - int old, new;
95745 + static atomic_unchecked_t ipv6_fragmentation_id;
95746 + int id;
95747
95748 #if IS_ENABLED(CONFIG_IPV6)
95749 if (rt && !(rt->dst.flags & DST_NOPEER)) {
95750 @@ -26,13 +26,10 @@ void ipv6_select_ident(struct frag_hdr *fhdr, struct rt6_info *rt)
95751 }
95752 }
95753 #endif
95754 - do {
95755 - old = atomic_read(&ipv6_fragmentation_id);
95756 - new = old + 1;
95757 - if (!new)
95758 - new = 1;
95759 - } while (atomic_cmpxchg(&ipv6_fragmentation_id, old, new) != old);
95760 - fhdr->identification = htonl(new);
95761 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95762 + if (!id)
95763 + id = atomic_inc_return_unchecked(&ipv6_fragmentation_id);
95764 + fhdr->identification = htonl(id);
95765 }
95766 EXPORT_SYMBOL(ipv6_select_ident);
95767
95768 diff --git a/net/ipv6/ping.c b/net/ipv6/ping.c
95769 index 7856e96..75ebc7f 100644
95770 --- a/net/ipv6/ping.c
95771 +++ b/net/ipv6/ping.c
95772 @@ -246,6 +246,22 @@ static struct pernet_operations ping_v6_net_ops = {
95773 };
95774 #endif
95775
95776 +static struct pingv6_ops real_pingv6_ops = {
95777 + .ipv6_recv_error = ipv6_recv_error,
95778 + .ip6_datagram_recv_ctl = ip6_datagram_recv_ctl,
95779 + .icmpv6_err_convert = icmpv6_err_convert,
95780 + .ipv6_icmp_error = ipv6_icmp_error,
95781 + .ipv6_chk_addr = ipv6_chk_addr,
95782 +};
95783 +
95784 +static struct pingv6_ops dummy_pingv6_ops = {
95785 + .ipv6_recv_error = dummy_ipv6_recv_error,
95786 + .ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl,
95787 + .icmpv6_err_convert = dummy_icmpv6_err_convert,
95788 + .ipv6_icmp_error = dummy_ipv6_icmp_error,
95789 + .ipv6_chk_addr = dummy_ipv6_chk_addr,
95790 +};
95791 +
95792 int __init pingv6_init(void)
95793 {
95794 #ifdef CONFIG_PROC_FS
95795 @@ -253,11 +269,7 @@ int __init pingv6_init(void)
95796 if (ret)
95797 return ret;
95798 #endif
95799 - pingv6_ops.ipv6_recv_error = ipv6_recv_error;
95800 - pingv6_ops.ip6_datagram_recv_ctl = ip6_datagram_recv_ctl;
95801 - pingv6_ops.icmpv6_err_convert = icmpv6_err_convert;
95802 - pingv6_ops.ipv6_icmp_error = ipv6_icmp_error;
95803 - pingv6_ops.ipv6_chk_addr = ipv6_chk_addr;
95804 + pingv6_ops = &real_pingv6_ops;
95805 return inet6_register_protosw(&pingv6_protosw);
95806 }
95807
95808 @@ -266,11 +278,7 @@ int __init pingv6_init(void)
95809 */
95810 void pingv6_exit(void)
95811 {
95812 - pingv6_ops.ipv6_recv_error = dummy_ipv6_recv_error;
95813 - pingv6_ops.ip6_datagram_recv_ctl = dummy_ip6_datagram_recv_ctl;
95814 - pingv6_ops.icmpv6_err_convert = dummy_icmpv6_err_convert;
95815 - pingv6_ops.ipv6_icmp_error = dummy_ipv6_icmp_error;
95816 - pingv6_ops.ipv6_chk_addr = dummy_ipv6_chk_addr;
95817 + pingv6_ops = &dummy_pingv6_ops;
95818 #ifdef CONFIG_PROC_FS
95819 unregister_pernet_subsys(&ping_v6_net_ops);
95820 #endif
95821 diff --git a/net/ipv6/raw.c b/net/ipv6/raw.c
95822 index 430067c..4adf088 100644
95823 --- a/net/ipv6/raw.c
95824 +++ b/net/ipv6/raw.c
95825 @@ -385,7 +385,7 @@ static inline int rawv6_rcv_skb(struct sock *sk, struct sk_buff *skb)
95826 {
95827 if ((raw6_sk(sk)->checksum || rcu_access_pointer(sk->sk_filter)) &&
95828 skb_checksum_complete(skb)) {
95829 - atomic_inc(&sk->sk_drops);
95830 + atomic_inc_unchecked(&sk->sk_drops);
95831 kfree_skb(skb);
95832 return NET_RX_DROP;
95833 }
95834 @@ -413,7 +413,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95835 struct raw6_sock *rp = raw6_sk(sk);
95836
95837 if (!xfrm6_policy_check(sk, XFRM_POLICY_IN, skb)) {
95838 - atomic_inc(&sk->sk_drops);
95839 + atomic_inc_unchecked(&sk->sk_drops);
95840 kfree_skb(skb);
95841 return NET_RX_DROP;
95842 }
95843 @@ -437,7 +437,7 @@ int rawv6_rcv(struct sock *sk, struct sk_buff *skb)
95844
95845 if (inet->hdrincl) {
95846 if (skb_checksum_complete(skb)) {
95847 - atomic_inc(&sk->sk_drops);
95848 + atomic_inc_unchecked(&sk->sk_drops);
95849 kfree_skb(skb);
95850 return NET_RX_DROP;
95851 }
95852 @@ -607,7 +607,7 @@ out:
95853 return err;
95854 }
95855
95856 -static int rawv6_send_hdrinc(struct sock *sk, void *from, int length,
95857 +static int rawv6_send_hdrinc(struct sock *sk, void *from, unsigned int length,
95858 struct flowi6 *fl6, struct dst_entry **dstp,
95859 unsigned int flags)
95860 {
95861 @@ -920,12 +920,15 @@ do_confirm:
95862 static int rawv6_seticmpfilter(struct sock *sk, int level, int optname,
95863 char __user *optval, int optlen)
95864 {
95865 + struct icmp6_filter filter;
95866 +
95867 switch (optname) {
95868 case ICMPV6_FILTER:
95869 if (optlen > sizeof(struct icmp6_filter))
95870 optlen = sizeof(struct icmp6_filter);
95871 - if (copy_from_user(&raw6_sk(sk)->filter, optval, optlen))
95872 + if (copy_from_user(&filter, optval, optlen))
95873 return -EFAULT;
95874 + raw6_sk(sk)->filter = filter;
95875 return 0;
95876 default:
95877 return -ENOPROTOOPT;
95878 @@ -938,6 +941,7 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95879 char __user *optval, int __user *optlen)
95880 {
95881 int len;
95882 + struct icmp6_filter filter;
95883
95884 switch (optname) {
95885 case ICMPV6_FILTER:
95886 @@ -949,7 +953,8 @@ static int rawv6_geticmpfilter(struct sock *sk, int level, int optname,
95887 len = sizeof(struct icmp6_filter);
95888 if (put_user(len, optlen))
95889 return -EFAULT;
95890 - if (copy_to_user(optval, &raw6_sk(sk)->filter, len))
95891 + filter = raw6_sk(sk)->filter;
95892 + if (len > sizeof filter || copy_to_user(optval, &filter, len))
95893 return -EFAULT;
95894 return 0;
95895 default:
95896 diff --git a/net/ipv6/reassembly.c b/net/ipv6/reassembly.c
95897 index 1aeb473..bea761c 100644
95898 --- a/net/ipv6/reassembly.c
95899 +++ b/net/ipv6/reassembly.c
95900 @@ -626,12 +626,11 @@ static struct ctl_table ip6_frags_ctl_table[] = {
95901
95902 static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95903 {
95904 - struct ctl_table *table;
95905 + ctl_table_no_const *table = NULL;
95906 struct ctl_table_header *hdr;
95907
95908 - table = ip6_frags_ns_ctl_table;
95909 if (!net_eq(net, &init_net)) {
95910 - table = kmemdup(table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95911 + table = kmemdup(ip6_frags_ns_ctl_table, sizeof(ip6_frags_ns_ctl_table), GFP_KERNEL);
95912 if (table == NULL)
95913 goto err_alloc;
95914
95915 @@ -642,9 +641,10 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95916 /* Don't export sysctls to unprivileged users */
95917 if (net->user_ns != &init_user_ns)
95918 table[0].procname = NULL;
95919 - }
95920 + hdr = register_net_sysctl(net, "net/ipv6", table);
95921 + } else
95922 + hdr = register_net_sysctl(net, "net/ipv6", ip6_frags_ns_ctl_table);
95923
95924 - hdr = register_net_sysctl(net, "net/ipv6", table);
95925 if (hdr == NULL)
95926 goto err_reg;
95927
95928 @@ -652,8 +652,7 @@ static int __net_init ip6_frags_ns_sysctl_register(struct net *net)
95929 return 0;
95930
95931 err_reg:
95932 - if (!net_eq(net, &init_net))
95933 - kfree(table);
95934 + kfree(table);
95935 err_alloc:
95936 return -ENOMEM;
95937 }
95938 diff --git a/net/ipv6/route.c b/net/ipv6/route.c
95939 index 77308af..36ed509 100644
95940 --- a/net/ipv6/route.c
95941 +++ b/net/ipv6/route.c
95942 @@ -3009,7 +3009,7 @@ struct ctl_table ipv6_route_table_template[] = {
95943
95944 struct ctl_table * __net_init ipv6_route_sysctl_init(struct net *net)
95945 {
95946 - struct ctl_table *table;
95947 + ctl_table_no_const *table;
95948
95949 table = kmemdup(ipv6_route_table_template,
95950 sizeof(ipv6_route_table_template),
95951 diff --git a/net/ipv6/sit.c b/net/ipv6/sit.c
95952 index b433884..3875266 100644
95953 --- a/net/ipv6/sit.c
95954 +++ b/net/ipv6/sit.c
95955 @@ -74,7 +74,7 @@ static void ipip6_tunnel_setup(struct net_device *dev);
95956 static void ipip6_dev_free(struct net_device *dev);
95957 static bool check_6rd(struct ip_tunnel *tunnel, const struct in6_addr *v6dst,
95958 __be32 *v4dst);
95959 -static struct rtnl_link_ops sit_link_ops __read_mostly;
95960 +static struct rtnl_link_ops sit_link_ops;
95961
95962 static int sit_net_id __read_mostly;
95963 struct sit_net {
95964 @@ -1603,7 +1603,7 @@ static void ipip6_dellink(struct net_device *dev, struct list_head *head)
95965 unregister_netdevice_queue(dev, head);
95966 }
95967
95968 -static struct rtnl_link_ops sit_link_ops __read_mostly = {
95969 +static struct rtnl_link_ops sit_link_ops = {
95970 .kind = "sit",
95971 .maxtype = IFLA_IPTUN_MAX,
95972 .policy = ipip6_policy,
95973 diff --git a/net/ipv6/sysctl_net_ipv6.c b/net/ipv6/sysctl_net_ipv6.c
95974 index 107b2f1..72741a9 100644
95975 --- a/net/ipv6/sysctl_net_ipv6.c
95976 +++ b/net/ipv6/sysctl_net_ipv6.c
95977 @@ -40,7 +40,7 @@ static struct ctl_table ipv6_rotable[] = {
95978
95979 static int __net_init ipv6_sysctl_net_init(struct net *net)
95980 {
95981 - struct ctl_table *ipv6_table;
95982 + ctl_table_no_const *ipv6_table;
95983 struct ctl_table *ipv6_route_table;
95984 struct ctl_table *ipv6_icmp_table;
95985 int err;
95986 diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c
95987 index 5c71501..7e8d5d3 100644
95988 --- a/net/ipv6/tcp_ipv6.c
95989 +++ b/net/ipv6/tcp_ipv6.c
95990 @@ -104,6 +104,10 @@ static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
95991 inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
95992 }
95993
95994 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
95995 +extern int grsec_enable_blackhole;
95996 +#endif
95997 +
95998 static void tcp_v6_hash(struct sock *sk)
95999 {
96000 if (sk->sk_state != TCP_CLOSE) {
96001 @@ -1397,6 +1401,9 @@ static int tcp_v6_do_rcv(struct sock *sk, struct sk_buff *skb)
96002 return 0;
96003
96004 reset:
96005 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96006 + if (!grsec_enable_blackhole)
96007 +#endif
96008 tcp_v6_send_reset(sk, skb);
96009 discard:
96010 if (opt_skb)
96011 @@ -1479,12 +1486,20 @@ static int tcp_v6_rcv(struct sk_buff *skb)
96012 TCP_SKB_CB(skb)->sacked = 0;
96013
96014 sk = __inet6_lookup_skb(&tcp_hashinfo, skb, th->source, th->dest);
96015 - if (!sk)
96016 + if (!sk) {
96017 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96018 + ret = 1;
96019 +#endif
96020 goto no_tcp_socket;
96021 + }
96022
96023 process:
96024 - if (sk->sk_state == TCP_TIME_WAIT)
96025 + if (sk->sk_state == TCP_TIME_WAIT) {
96026 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96027 + ret = 2;
96028 +#endif
96029 goto do_time_wait;
96030 + }
96031
96032 if (hdr->hop_limit < inet6_sk(sk)->min_hopcount) {
96033 NET_INC_STATS_BH(net, LINUX_MIB_TCPMINTTLDROP);
96034 @@ -1536,6 +1551,10 @@ csum_error:
96035 bad_packet:
96036 TCP_INC_STATS_BH(net, TCP_MIB_INERRS);
96037 } else {
96038 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96039 + if (!grsec_enable_blackhole || (ret == 1 &&
96040 + (skb->dev->flags & IFF_LOOPBACK)))
96041 +#endif
96042 tcp_v6_send_reset(NULL, skb);
96043 }
96044
96045 diff --git a/net/ipv6/udp.c b/net/ipv6/udp.c
96046 index 3d2758d..626c422 100644
96047 --- a/net/ipv6/udp.c
96048 +++ b/net/ipv6/udp.c
96049 @@ -53,6 +53,10 @@
96050 #include <trace/events/skb.h>
96051 #include "udp_impl.h"
96052
96053 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96054 +extern int grsec_enable_blackhole;
96055 +#endif
96056 +
96057 int ipv6_rcv_saddr_equal(const struct sock *sk, const struct sock *sk2)
96058 {
96059 const struct in6_addr *sk_rcv_saddr6 = &inet6_sk(sk)->rcv_saddr;
96060 @@ -417,7 +421,7 @@ try_again:
96061 if (unlikely(err)) {
96062 trace_kfree_skb(skb, udpv6_recvmsg);
96063 if (!peeked) {
96064 - atomic_inc(&sk->sk_drops);
96065 + atomic_inc_unchecked(&sk->sk_drops);
96066 if (is_udp4)
96067 UDP_INC_STATS_USER(sock_net(sk),
96068 UDP_MIB_INERRORS,
96069 @@ -665,7 +669,7 @@ csum_error:
96070 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_CSUMERRORS, is_udplite);
96071 drop:
96072 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS, is_udplite);
96073 - atomic_inc(&sk->sk_drops);
96074 + atomic_inc_unchecked(&sk->sk_drops);
96075 kfree_skb(skb);
96076 return -1;
96077 }
96078 @@ -723,7 +727,7 @@ static void flush_stack(struct sock **stack, unsigned int count,
96079 if (likely(skb1 == NULL))
96080 skb1 = (i == final) ? skb : skb_clone(skb, GFP_ATOMIC);
96081 if (!skb1) {
96082 - atomic_inc(&sk->sk_drops);
96083 + atomic_inc_unchecked(&sk->sk_drops);
96084 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_RCVBUFERRORS,
96085 IS_UDPLITE(sk));
96086 UDP6_INC_STATS_BH(sock_net(sk), UDP_MIB_INERRORS,
96087 @@ -863,6 +867,9 @@ int __udp6_lib_rcv(struct sk_buff *skb, struct udp_table *udptable,
96088 goto csum_error;
96089
96090 UDP6_INC_STATS_BH(net, UDP_MIB_NOPORTS, proto == IPPROTO_UDPLITE);
96091 +#ifdef CONFIG_GRKERNSEC_BLACKHOLE
96092 + if (!grsec_enable_blackhole || (skb->dev->flags & IFF_LOOPBACK))
96093 +#endif
96094 icmpv6_send(skb, ICMPV6_DEST_UNREACH, ICMPV6_PORT_UNREACH, 0);
96095
96096 kfree_skb(skb);
96097 diff --git a/net/ipv6/xfrm6_policy.c b/net/ipv6/xfrm6_policy.c
96098 index 550b195..6acea83 100644
96099 --- a/net/ipv6/xfrm6_policy.c
96100 +++ b/net/ipv6/xfrm6_policy.c
96101 @@ -212,11 +212,11 @@ _decode_session6(struct sk_buff *skb, struct flowi *fl, int reverse)
96102 }
96103 }
96104
96105 -static inline int xfrm6_garbage_collect(struct dst_ops *ops)
96106 +static int xfrm6_garbage_collect(struct dst_ops *ops)
96107 {
96108 struct net *net = container_of(ops, struct net, xfrm.xfrm6_dst_ops);
96109
96110 - xfrm6_policy_afinfo.garbage_collect(net);
96111 + xfrm_garbage_collect_deferred(net);
96112 return dst_entries_get_fast(ops) > ops->gc_thresh * 2;
96113 }
96114
96115 @@ -329,19 +329,19 @@ static struct ctl_table xfrm6_policy_table[] = {
96116
96117 static int __net_init xfrm6_net_init(struct net *net)
96118 {
96119 - struct ctl_table *table;
96120 + ctl_table_no_const *table = NULL;
96121 struct ctl_table_header *hdr;
96122
96123 - table = xfrm6_policy_table;
96124 if (!net_eq(net, &init_net)) {
96125 - table = kmemdup(table, sizeof(xfrm6_policy_table), GFP_KERNEL);
96126 + table = kmemdup(xfrm6_policy_table, sizeof(xfrm6_policy_table), GFP_KERNEL);
96127 if (!table)
96128 goto err_alloc;
96129
96130 table[0].data = &net->xfrm.xfrm6_dst_ops.gc_thresh;
96131 - }
96132 + hdr = register_net_sysctl(net, "net/ipv6", table);
96133 + } else
96134 + hdr = register_net_sysctl(net, "net/ipv6", xfrm6_policy_table);
96135
96136 - hdr = register_net_sysctl(net, "net/ipv6", table);
96137 if (!hdr)
96138 goto err_reg;
96139
96140 @@ -349,8 +349,7 @@ static int __net_init xfrm6_net_init(struct net *net)
96141 return 0;
96142
96143 err_reg:
96144 - if (!net_eq(net, &init_net))
96145 - kfree(table);
96146 + kfree(table);
96147 err_alloc:
96148 return -ENOMEM;
96149 }
96150 diff --git a/net/irda/ircomm/ircomm_tty.c b/net/irda/ircomm/ircomm_tty.c
96151 index 41ac7938..75e3bb1 100644
96152 --- a/net/irda/ircomm/ircomm_tty.c
96153 +++ b/net/irda/ircomm/ircomm_tty.c
96154 @@ -319,11 +319,11 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96155 add_wait_queue(&port->open_wait, &wait);
96156
96157 IRDA_DEBUG(2, "%s(%d):block_til_ready before block on %s open_count=%d\n",
96158 - __FILE__, __LINE__, tty->driver->name, port->count);
96159 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96160
96161 spin_lock_irqsave(&port->lock, flags);
96162 if (!tty_hung_up_p(filp))
96163 - port->count--;
96164 + atomic_dec(&port->count);
96165 port->blocked_open++;
96166 spin_unlock_irqrestore(&port->lock, flags);
96167
96168 @@ -358,7 +358,7 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96169 }
96170
96171 IRDA_DEBUG(1, "%s(%d):block_til_ready blocking on %s open_count=%d\n",
96172 - __FILE__, __LINE__, tty->driver->name, port->count);
96173 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96174
96175 schedule();
96176 }
96177 @@ -368,12 +368,12 @@ static int ircomm_tty_block_til_ready(struct ircomm_tty_cb *self,
96178
96179 spin_lock_irqsave(&port->lock, flags);
96180 if (!tty_hung_up_p(filp))
96181 - port->count++;
96182 + atomic_inc(&port->count);
96183 port->blocked_open--;
96184 spin_unlock_irqrestore(&port->lock, flags);
96185
96186 IRDA_DEBUG(1, "%s(%d):block_til_ready after blocking on %s open_count=%d\n",
96187 - __FILE__, __LINE__, tty->driver->name, port->count);
96188 + __FILE__, __LINE__, tty->driver->name, atomic_read(&port->count));
96189
96190 if (!retval)
96191 port->flags |= ASYNC_NORMAL_ACTIVE;
96192 @@ -447,12 +447,12 @@ static int ircomm_tty_open(struct tty_struct *tty, struct file *filp)
96193
96194 /* ++ is not atomic, so this should be protected - Jean II */
96195 spin_lock_irqsave(&self->port.lock, flags);
96196 - self->port.count++;
96197 + atomic_inc(&self->port.count);
96198 spin_unlock_irqrestore(&self->port.lock, flags);
96199 tty_port_tty_set(&self->port, tty);
96200
96201 IRDA_DEBUG(1, "%s(), %s%d, count = %d\n", __func__ , tty->driver->name,
96202 - self->line, self->port.count);
96203 + self->line, atomic_read(&self->port.count));
96204
96205 /* Not really used by us, but lets do it anyway */
96206 self->port.low_latency = (self->port.flags & ASYNC_LOW_LATENCY) ? 1 : 0;
96207 @@ -989,7 +989,7 @@ static void ircomm_tty_hangup(struct tty_struct *tty)
96208 tty_kref_put(port->tty);
96209 }
96210 port->tty = NULL;
96211 - port->count = 0;
96212 + atomic_set(&port->count, 0);
96213 spin_unlock_irqrestore(&port->lock, flags);
96214
96215 wake_up_interruptible(&port->open_wait);
96216 @@ -1346,7 +1346,7 @@ static void ircomm_tty_line_info(struct ircomm_tty_cb *self, struct seq_file *m)
96217 seq_putc(m, '\n');
96218
96219 seq_printf(m, "Role: %s\n", self->client ? "client" : "server");
96220 - seq_printf(m, "Open count: %d\n", self->port.count);
96221 + seq_printf(m, "Open count: %d\n", atomic_read(&self->port.count));
96222 seq_printf(m, "Max data size: %d\n", self->max_data_size);
96223 seq_printf(m, "Max header size: %d\n", self->max_header_size);
96224
96225 diff --git a/net/iucv/af_iucv.c b/net/iucv/af_iucv.c
96226 index c4b7218..3e83259 100644
96227 --- a/net/iucv/af_iucv.c
96228 +++ b/net/iucv/af_iucv.c
96229 @@ -773,10 +773,10 @@ static int iucv_sock_autobind(struct sock *sk)
96230
96231 write_lock_bh(&iucv_sk_list.lock);
96232
96233 - sprintf(name, "%08x", atomic_inc_return(&iucv_sk_list.autobind_name));
96234 + sprintf(name, "%08x", atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
96235 while (__iucv_get_sock_by_name(name)) {
96236 sprintf(name, "%08x",
96237 - atomic_inc_return(&iucv_sk_list.autobind_name));
96238 + atomic_inc_return_unchecked(&iucv_sk_list.autobind_name));
96239 }
96240
96241 write_unlock_bh(&iucv_sk_list.lock);
96242 diff --git a/net/iucv/iucv.c b/net/iucv/iucv.c
96243 index cd5b8ec..f205e6b 100644
96244 --- a/net/iucv/iucv.c
96245 +++ b/net/iucv/iucv.c
96246 @@ -690,7 +690,7 @@ static int iucv_cpu_notify(struct notifier_block *self,
96247 return NOTIFY_OK;
96248 }
96249
96250 -static struct notifier_block __refdata iucv_cpu_notifier = {
96251 +static struct notifier_block iucv_cpu_notifier = {
96252 .notifier_call = iucv_cpu_notify,
96253 };
96254
96255 diff --git a/net/key/af_key.c b/net/key/af_key.c
96256 index 545f047..9757a9d 100644
96257 --- a/net/key/af_key.c
96258 +++ b/net/key/af_key.c
96259 @@ -3041,10 +3041,10 @@ static int pfkey_send_policy_notify(struct xfrm_policy *xp, int dir, const struc
96260 static u32 get_acqseq(void)
96261 {
96262 u32 res;
96263 - static atomic_t acqseq;
96264 + static atomic_unchecked_t acqseq;
96265
96266 do {
96267 - res = atomic_inc_return(&acqseq);
96268 + res = atomic_inc_return_unchecked(&acqseq);
96269 } while (!res);
96270 return res;
96271 }
96272 diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
96273 index 9903ee5..18978be 100644
96274 --- a/net/mac80211/cfg.c
96275 +++ b/net/mac80211/cfg.c
96276 @@ -826,7 +826,7 @@ static int ieee80211_set_monitor_channel(struct wiphy *wiphy,
96277 ret = ieee80211_vif_use_channel(sdata, chandef,
96278 IEEE80211_CHANCTX_EXCLUSIVE);
96279 }
96280 - } else if (local->open_count == local->monitors) {
96281 + } else if (local_read(&local->open_count) == local->monitors) {
96282 local->_oper_chandef = *chandef;
96283 ieee80211_hw_config(local, 0);
96284 }
96285 @@ -3124,7 +3124,7 @@ static void ieee80211_mgmt_frame_register(struct wiphy *wiphy,
96286 else
96287 local->probe_req_reg--;
96288
96289 - if (!local->open_count)
96290 + if (!local_read(&local->open_count))
96291 break;
96292
96293 ieee80211_queue_work(&local->hw, &local->reconfig_filter);
96294 @@ -3587,8 +3587,8 @@ static int ieee80211_cfg_get_channel(struct wiphy *wiphy,
96295 if (chanctx_conf) {
96296 *chandef = chanctx_conf->def;
96297 ret = 0;
96298 - } else if (local->open_count > 0 &&
96299 - local->open_count == local->monitors &&
96300 + } else if (local_read(&local->open_count) > 0 &&
96301 + local_read(&local->open_count) == local->monitors &&
96302 sdata->vif.type == NL80211_IFTYPE_MONITOR) {
96303 if (local->use_chanctx)
96304 *chandef = local->monitor_chandef;
96305 diff --git a/net/mac80211/ieee80211_i.h b/net/mac80211/ieee80211_i.h
96306 index 611abfc..8c2c7e4 100644
96307 --- a/net/mac80211/ieee80211_i.h
96308 +++ b/net/mac80211/ieee80211_i.h
96309 @@ -28,6 +28,7 @@
96310 #include <net/ieee80211_radiotap.h>
96311 #include <net/cfg80211.h>
96312 #include <net/mac80211.h>
96313 +#include <asm/local.h>
96314 #include "key.h"
96315 #include "sta_info.h"
96316 #include "debug.h"
96317 @@ -945,7 +946,7 @@ struct ieee80211_local {
96318 /* also used to protect ampdu_ac_queue and amdpu_ac_stop_refcnt */
96319 spinlock_t queue_stop_reason_lock;
96320
96321 - int open_count;
96322 + local_t open_count;
96323 int monitors, cooked_mntrs;
96324 /* number of interfaces with corresponding FIF_ flags */
96325 int fif_fcsfail, fif_plcpfail, fif_control, fif_other_bss, fif_pspoll,
96326 diff --git a/net/mac80211/iface.c b/net/mac80211/iface.c
96327 index fcecd63..a404454 100644
96328 --- a/net/mac80211/iface.c
96329 +++ b/net/mac80211/iface.c
96330 @@ -519,7 +519,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
96331 break;
96332 }
96333
96334 - if (local->open_count == 0) {
96335 + if (local_read(&local->open_count) == 0) {
96336 res = drv_start(local);
96337 if (res)
96338 goto err_del_bss;
96339 @@ -566,7 +566,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
96340 res = drv_add_interface(local, sdata);
96341 if (res)
96342 goto err_stop;
96343 - } else if (local->monitors == 0 && local->open_count == 0) {
96344 + } else if (local->monitors == 0 && local_read(&local->open_count) == 0) {
96345 res = ieee80211_add_virtual_monitor(local);
96346 if (res)
96347 goto err_stop;
96348 @@ -675,7 +675,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
96349 atomic_inc(&local->iff_promiscs);
96350
96351 if (coming_up)
96352 - local->open_count++;
96353 + local_inc(&local->open_count);
96354
96355 if (hw_reconf_flags)
96356 ieee80211_hw_config(local, hw_reconf_flags);
96357 @@ -713,7 +713,7 @@ int ieee80211_do_open(struct wireless_dev *wdev, bool coming_up)
96358 err_del_interface:
96359 drv_remove_interface(local, sdata);
96360 err_stop:
96361 - if (!local->open_count)
96362 + if (!local_read(&local->open_count))
96363 drv_stop(local);
96364 err_del_bss:
96365 sdata->bss = NULL;
96366 @@ -852,7 +852,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
96367 }
96368
96369 if (going_down)
96370 - local->open_count--;
96371 + local_dec(&local->open_count);
96372
96373 switch (sdata->vif.type) {
96374 case NL80211_IFTYPE_AP_VLAN:
96375 @@ -919,7 +919,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
96376 }
96377 spin_unlock_irqrestore(&local->queue_stop_reason_lock, flags);
96378
96379 - if (local->open_count == 0)
96380 + if (local_read(&local->open_count) == 0)
96381 ieee80211_clear_tx_pending(local);
96382
96383 /*
96384 @@ -959,7 +959,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
96385
96386 ieee80211_recalc_ps(local, -1);
96387
96388 - if (local->open_count == 0) {
96389 + if (local_read(&local->open_count) == 0) {
96390 ieee80211_stop_device(local);
96391
96392 /* no reconfiguring after stop! */
96393 @@ -970,7 +970,7 @@ static void ieee80211_do_stop(struct ieee80211_sub_if_data *sdata,
96394 ieee80211_configure_filter(local);
96395 ieee80211_hw_config(local, hw_reconf_flags);
96396
96397 - if (local->monitors == local->open_count)
96398 + if (local->monitors == local_read(&local->open_count))
96399 ieee80211_add_virtual_monitor(local);
96400 }
96401
96402 diff --git a/net/mac80211/main.c b/net/mac80211/main.c
96403 index e765f77..dfd72e7 100644
96404 --- a/net/mac80211/main.c
96405 +++ b/net/mac80211/main.c
96406 @@ -172,7 +172,7 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
96407 changed &= ~(IEEE80211_CONF_CHANGE_CHANNEL |
96408 IEEE80211_CONF_CHANGE_POWER);
96409
96410 - if (changed && local->open_count) {
96411 + if (changed && local_read(&local->open_count)) {
96412 ret = drv_config(local, changed);
96413 /*
96414 * Goal:
96415 diff --git a/net/mac80211/pm.c b/net/mac80211/pm.c
96416 index 3401262..d5cd68d 100644
96417 --- a/net/mac80211/pm.c
96418 +++ b/net/mac80211/pm.c
96419 @@ -12,7 +12,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96420 struct ieee80211_sub_if_data *sdata;
96421 struct sta_info *sta;
96422
96423 - if (!local->open_count)
96424 + if (!local_read(&local->open_count))
96425 goto suspend;
96426
96427 ieee80211_scan_cancel(local);
96428 @@ -59,7 +59,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96429 cancel_work_sync(&local->dynamic_ps_enable_work);
96430 del_timer_sync(&local->dynamic_ps_timer);
96431
96432 - local->wowlan = wowlan && local->open_count;
96433 + local->wowlan = wowlan && local_read(&local->open_count);
96434 if (local->wowlan) {
96435 int err = drv_suspend(local, wowlan);
96436 if (err < 0) {
96437 @@ -116,7 +116,7 @@ int __ieee80211_suspend(struct ieee80211_hw *hw, struct cfg80211_wowlan *wowlan)
96438 WARN_ON(!list_empty(&local->chanctx_list));
96439
96440 /* stop hardware - this must stop RX */
96441 - if (local->open_count)
96442 + if (local_read(&local->open_count))
96443 ieee80211_stop_device(local);
96444
96445 suspend:
96446 diff --git a/net/mac80211/rate.c b/net/mac80211/rate.c
96447 index e126605..73d2c39 100644
96448 --- a/net/mac80211/rate.c
96449 +++ b/net/mac80211/rate.c
96450 @@ -725,7 +725,7 @@ int ieee80211_init_rate_ctrl_alg(struct ieee80211_local *local,
96451
96452 ASSERT_RTNL();
96453
96454 - if (local->open_count)
96455 + if (local_read(&local->open_count))
96456 return -EBUSY;
96457
96458 if (local->hw.flags & IEEE80211_HW_HAS_RATE_CONTROL) {
96459 diff --git a/net/mac80211/rc80211_pid_debugfs.c b/net/mac80211/rc80211_pid_debugfs.c
96460 index c97a065..ff61928 100644
96461 --- a/net/mac80211/rc80211_pid_debugfs.c
96462 +++ b/net/mac80211/rc80211_pid_debugfs.c
96463 @@ -193,7 +193,7 @@ static ssize_t rate_control_pid_events_read(struct file *file, char __user *buf,
96464
96465 spin_unlock_irqrestore(&events->lock, status);
96466
96467 - if (copy_to_user(buf, pb, p))
96468 + if (p > sizeof(pb) || copy_to_user(buf, pb, p))
96469 return -EFAULT;
96470
96471 return p;
96472 diff --git a/net/mac80211/util.c b/net/mac80211/util.c
96473 index 69e4ef5..e8e4b92 100644
96474 --- a/net/mac80211/util.c
96475 +++ b/net/mac80211/util.c
96476 @@ -1470,7 +1470,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
96477 }
96478 #endif
96479 /* everything else happens only if HW was up & running */
96480 - if (!local->open_count)
96481 + if (!local_read(&local->open_count))
96482 goto wake_up;
96483
96484 /*
96485 @@ -1695,7 +1695,7 @@ int ieee80211_reconfig(struct ieee80211_local *local)
96486 local->in_reconfig = false;
96487 barrier();
96488
96489 - if (local->monitors == local->open_count && local->monitors > 0)
96490 + if (local->monitors == local_read(&local->open_count) && local->monitors > 0)
96491 ieee80211_add_virtual_monitor(local);
96492
96493 /*
96494 diff --git a/net/netfilter/Kconfig b/net/netfilter/Kconfig
96495 index 6e839b6..002a233 100644
96496 --- a/net/netfilter/Kconfig
96497 +++ b/net/netfilter/Kconfig
96498 @@ -950,6 +950,16 @@ config NETFILTER_XT_MATCH_ESP
96499
96500 To compile it as a module, choose M here. If unsure, say N.
96501
96502 +config NETFILTER_XT_MATCH_GRADM
96503 + tristate '"gradm" match support'
96504 + depends on NETFILTER_XTABLES && NETFILTER_ADVANCED
96505 + depends on GRKERNSEC && !GRKERNSEC_NO_RBAC
96506 + ---help---
96507 + The gradm match allows to match on grsecurity RBAC being enabled.
96508 + It is useful when iptables rules are applied early on bootup to
96509 + prevent connections to the machine (except from a trusted host)
96510 + while the RBAC system is disabled.
96511 +
96512 config NETFILTER_XT_MATCH_HASHLIMIT
96513 tristate '"hashlimit" match support'
96514 depends on (IP6_NF_IPTABLES || IP6_NF_IPTABLES=n)
96515 diff --git a/net/netfilter/Makefile b/net/netfilter/Makefile
96516 index c3a0a12..90b587f 100644
96517 --- a/net/netfilter/Makefile
96518 +++ b/net/netfilter/Makefile
96519 @@ -112,6 +112,7 @@ obj-$(CONFIG_NETFILTER_XT_MATCH_DEVGROUP) += xt_devgroup.o
96520 obj-$(CONFIG_NETFILTER_XT_MATCH_DSCP) += xt_dscp.o
96521 obj-$(CONFIG_NETFILTER_XT_MATCH_ECN) += xt_ecn.o
96522 obj-$(CONFIG_NETFILTER_XT_MATCH_ESP) += xt_esp.o
96523 +obj-$(CONFIG_NETFILTER_XT_MATCH_GRADM) += xt_gradm.o
96524 obj-$(CONFIG_NETFILTER_XT_MATCH_HASHLIMIT) += xt_hashlimit.o
96525 obj-$(CONFIG_NETFILTER_XT_MATCH_HELPER) += xt_helper.o
96526 obj-$(CONFIG_NETFILTER_XT_MATCH_HL) += xt_hl.o
96527 diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c
96528 index f2e30fb..f131862 100644
96529 --- a/net/netfilter/ipset/ip_set_core.c
96530 +++ b/net/netfilter/ipset/ip_set_core.c
96531 @@ -1819,7 +1819,7 @@ done:
96532 return ret;
96533 }
96534
96535 -static struct nf_sockopt_ops so_set __read_mostly = {
96536 +static struct nf_sockopt_ops so_set = {
96537 .pf = PF_INET,
96538 .get_optmin = SO_IP_SET,
96539 .get_optmax = SO_IP_SET + 1,
96540 diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
96541 index 4c8e5c0..5a79b4d 100644
96542 --- a/net/netfilter/ipvs/ip_vs_conn.c
96543 +++ b/net/netfilter/ipvs/ip_vs_conn.c
96544 @@ -556,7 +556,7 @@ ip_vs_bind_dest(struct ip_vs_conn *cp, struct ip_vs_dest *dest)
96545 /* Increase the refcnt counter of the dest */
96546 ip_vs_dest_hold(dest);
96547
96548 - conn_flags = atomic_read(&dest->conn_flags);
96549 + conn_flags = atomic_read_unchecked(&dest->conn_flags);
96550 if (cp->protocol != IPPROTO_UDP)
96551 conn_flags &= ~IP_VS_CONN_F_ONE_PACKET;
96552 flags = cp->flags;
96553 @@ -900,7 +900,7 @@ ip_vs_conn_new(const struct ip_vs_conn_param *p,
96554
96555 cp->control = NULL;
96556 atomic_set(&cp->n_control, 0);
96557 - atomic_set(&cp->in_pkts, 0);
96558 + atomic_set_unchecked(&cp->in_pkts, 0);
96559
96560 cp->packet_xmit = NULL;
96561 cp->app = NULL;
96562 @@ -1188,7 +1188,7 @@ static inline int todrop_entry(struct ip_vs_conn *cp)
96563
96564 /* Don't drop the entry if its number of incoming packets is not
96565 located in [0, 8] */
96566 - i = atomic_read(&cp->in_pkts);
96567 + i = atomic_read_unchecked(&cp->in_pkts);
96568 if (i > 8 || i < 0) return 0;
96569
96570 if (!todrop_rate[i]) return 0;
96571 diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
96572 index 3581736..c0453e9 100644
96573 --- a/net/netfilter/ipvs/ip_vs_core.c
96574 +++ b/net/netfilter/ipvs/ip_vs_core.c
96575 @@ -567,7 +567,7 @@ int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
96576 ret = cp->packet_xmit(skb, cp, pd->pp, iph);
96577 /* do not touch skb anymore */
96578
96579 - atomic_inc(&cp->in_pkts);
96580 + atomic_inc_unchecked(&cp->in_pkts);
96581 ip_vs_conn_put(cp);
96582 return ret;
96583 }
96584 @@ -1706,7 +1706,7 @@ ip_vs_in(unsigned int hooknum, struct sk_buff *skb, int af)
96585 if (cp->flags & IP_VS_CONN_F_ONE_PACKET)
96586 pkts = sysctl_sync_threshold(ipvs);
96587 else
96588 - pkts = atomic_add_return(1, &cp->in_pkts);
96589 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96590
96591 if (ipvs->sync_state & IP_VS_STATE_MASTER)
96592 ip_vs_sync_conn(net, cp, pkts);
96593 diff --git a/net/netfilter/ipvs/ip_vs_ctl.c b/net/netfilter/ipvs/ip_vs_ctl.c
96594 index a3df9bd..895ae09 100644
96595 --- a/net/netfilter/ipvs/ip_vs_ctl.c
96596 +++ b/net/netfilter/ipvs/ip_vs_ctl.c
96597 @@ -794,7 +794,7 @@ __ip_vs_update_dest(struct ip_vs_service *svc, struct ip_vs_dest *dest,
96598 */
96599 ip_vs_rs_hash(ipvs, dest);
96600 }
96601 - atomic_set(&dest->conn_flags, conn_flags);
96602 + atomic_set_unchecked(&dest->conn_flags, conn_flags);
96603
96604 /* bind the service */
96605 old_svc = rcu_dereference_protected(dest->svc, 1);
96606 @@ -1641,7 +1641,7 @@ proc_do_sync_ports(struct ctl_table *table, int write,
96607 * align with netns init in ip_vs_control_net_init()
96608 */
96609
96610 -static struct ctl_table vs_vars[] = {
96611 +static ctl_table_no_const vs_vars[] __read_only = {
96612 {
96613 .procname = "amemthresh",
96614 .maxlen = sizeof(int),
96615 @@ -2062,7 +2062,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
96616 " %-7s %-6d %-10d %-10d\n",
96617 &dest->addr.in6,
96618 ntohs(dest->port),
96619 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
96620 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
96621 atomic_read(&dest->weight),
96622 atomic_read(&dest->activeconns),
96623 atomic_read(&dest->inactconns));
96624 @@ -2073,7 +2073,7 @@ static int ip_vs_info_seq_show(struct seq_file *seq, void *v)
96625 "%-7s %-6d %-10d %-10d\n",
96626 ntohl(dest->addr.ip),
96627 ntohs(dest->port),
96628 - ip_vs_fwd_name(atomic_read(&dest->conn_flags)),
96629 + ip_vs_fwd_name(atomic_read_unchecked(&dest->conn_flags)),
96630 atomic_read(&dest->weight),
96631 atomic_read(&dest->activeconns),
96632 atomic_read(&dest->inactconns));
96633 @@ -2551,7 +2551,7 @@ __ip_vs_get_dest_entries(struct net *net, const struct ip_vs_get_dests *get,
96634
96635 entry.addr = dest->addr.ip;
96636 entry.port = dest->port;
96637 - entry.conn_flags = atomic_read(&dest->conn_flags);
96638 + entry.conn_flags = atomic_read_unchecked(&dest->conn_flags);
96639 entry.weight = atomic_read(&dest->weight);
96640 entry.u_threshold = dest->u_threshold;
96641 entry.l_threshold = dest->l_threshold;
96642 @@ -3094,7 +3094,7 @@ static int ip_vs_genl_fill_dest(struct sk_buff *skb, struct ip_vs_dest *dest)
96643 if (nla_put(skb, IPVS_DEST_ATTR_ADDR, sizeof(dest->addr), &dest->addr) ||
96644 nla_put_be16(skb, IPVS_DEST_ATTR_PORT, dest->port) ||
96645 nla_put_u32(skb, IPVS_DEST_ATTR_FWD_METHOD,
96646 - (atomic_read(&dest->conn_flags) &
96647 + (atomic_read_unchecked(&dest->conn_flags) &
96648 IP_VS_CONN_F_FWD_MASK)) ||
96649 nla_put_u32(skb, IPVS_DEST_ATTR_WEIGHT,
96650 atomic_read(&dest->weight)) ||
96651 @@ -3684,7 +3684,7 @@ static int __net_init ip_vs_control_net_init_sysctl(struct net *net)
96652 {
96653 int idx;
96654 struct netns_ipvs *ipvs = net_ipvs(net);
96655 - struct ctl_table *tbl;
96656 + ctl_table_no_const *tbl;
96657
96658 atomic_set(&ipvs->dropentry, 0);
96659 spin_lock_init(&ipvs->dropentry_lock);
96660 diff --git a/net/netfilter/ipvs/ip_vs_lblc.c b/net/netfilter/ipvs/ip_vs_lblc.c
96661 index eff13c9..c1aab3e 100644
96662 --- a/net/netfilter/ipvs/ip_vs_lblc.c
96663 +++ b/net/netfilter/ipvs/ip_vs_lblc.c
96664 @@ -118,7 +118,7 @@ struct ip_vs_lblc_table {
96665 * IPVS LBLC sysctl table
96666 */
96667 #ifdef CONFIG_SYSCTL
96668 -static struct ctl_table vs_vars_table[] = {
96669 +static ctl_table_no_const vs_vars_table[] __read_only = {
96670 {
96671 .procname = "lblc_expiration",
96672 .data = NULL,
96673 diff --git a/net/netfilter/ipvs/ip_vs_lblcr.c b/net/netfilter/ipvs/ip_vs_lblcr.c
96674 index 0b85500..8513fa5 100644
96675 --- a/net/netfilter/ipvs/ip_vs_lblcr.c
96676 +++ b/net/netfilter/ipvs/ip_vs_lblcr.c
96677 @@ -289,7 +289,7 @@ struct ip_vs_lblcr_table {
96678 * IPVS LBLCR sysctl table
96679 */
96680
96681 -static struct ctl_table vs_vars_table[] = {
96682 +static ctl_table_no_const vs_vars_table[] __read_only = {
96683 {
96684 .procname = "lblcr_expiration",
96685 .data = NULL,
96686 diff --git a/net/netfilter/ipvs/ip_vs_sync.c b/net/netfilter/ipvs/ip_vs_sync.c
96687 index f448471..995f131 100644
96688 --- a/net/netfilter/ipvs/ip_vs_sync.c
96689 +++ b/net/netfilter/ipvs/ip_vs_sync.c
96690 @@ -609,7 +609,7 @@ static void ip_vs_sync_conn_v0(struct net *net, struct ip_vs_conn *cp,
96691 cp = cp->control;
96692 if (cp) {
96693 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96694 - pkts = atomic_add_return(1, &cp->in_pkts);
96695 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96696 else
96697 pkts = sysctl_sync_threshold(ipvs);
96698 ip_vs_sync_conn(net, cp->control, pkts);
96699 @@ -771,7 +771,7 @@ control:
96700 if (!cp)
96701 return;
96702 if (cp->flags & IP_VS_CONN_F_TEMPLATE)
96703 - pkts = atomic_add_return(1, &cp->in_pkts);
96704 + pkts = atomic_add_return_unchecked(1, &cp->in_pkts);
96705 else
96706 pkts = sysctl_sync_threshold(ipvs);
96707 goto sloop;
96708 @@ -895,7 +895,7 @@ static void ip_vs_proc_conn(struct net *net, struct ip_vs_conn_param *param,
96709
96710 if (opt)
96711 memcpy(&cp->in_seq, opt, sizeof(*opt));
96712 - atomic_set(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96713 + atomic_set_unchecked(&cp->in_pkts, sysctl_sync_threshold(ipvs));
96714 cp->state = state;
96715 cp->old_state = cp->state;
96716 /*
96717 diff --git a/net/netfilter/ipvs/ip_vs_xmit.c b/net/netfilter/ipvs/ip_vs_xmit.c
96718 index c47444e..b0961c6 100644
96719 --- a/net/netfilter/ipvs/ip_vs_xmit.c
96720 +++ b/net/netfilter/ipvs/ip_vs_xmit.c
96721 @@ -1102,7 +1102,7 @@ ip_vs_icmp_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
96722 else
96723 rc = NF_ACCEPT;
96724 /* do not touch skb anymore */
96725 - atomic_inc(&cp->in_pkts);
96726 + atomic_inc_unchecked(&cp->in_pkts);
96727 goto out;
96728 }
96729
96730 @@ -1194,7 +1194,7 @@ ip_vs_icmp_xmit_v6(struct sk_buff *skb, struct ip_vs_conn *cp,
96731 else
96732 rc = NF_ACCEPT;
96733 /* do not touch skb anymore */
96734 - atomic_inc(&cp->in_pkts);
96735 + atomic_inc_unchecked(&cp->in_pkts);
96736 goto out;
96737 }
96738
96739 diff --git a/net/netfilter/nf_conntrack_acct.c b/net/netfilter/nf_conntrack_acct.c
96740 index 2d3030a..7ba1c0a 100644
96741 --- a/net/netfilter/nf_conntrack_acct.c
96742 +++ b/net/netfilter/nf_conntrack_acct.c
96743 @@ -60,7 +60,7 @@ static struct nf_ct_ext_type acct_extend __read_mostly = {
96744 #ifdef CONFIG_SYSCTL
96745 static int nf_conntrack_acct_init_sysctl(struct net *net)
96746 {
96747 - struct ctl_table *table;
96748 + ctl_table_no_const *table;
96749
96750 table = kmemdup(acct_sysctl_table, sizeof(acct_sysctl_table),
96751 GFP_KERNEL);
96752 diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
96753 index 5d892fe..d2fc9d8 100644
96754 --- a/net/netfilter/nf_conntrack_core.c
96755 +++ b/net/netfilter/nf_conntrack_core.c
96756 @@ -1600,6 +1600,10 @@ void nf_conntrack_init_end(void)
96757 #define DYING_NULLS_VAL ((1<<30)+1)
96758 #define TEMPLATE_NULLS_VAL ((1<<30)+2)
96759
96760 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96761 +static atomic_unchecked_t conntrack_cache_id = ATOMIC_INIT(0);
96762 +#endif
96763 +
96764 int nf_conntrack_init_net(struct net *net)
96765 {
96766 int ret;
96767 @@ -1614,7 +1618,11 @@ int nf_conntrack_init_net(struct net *net)
96768 goto err_stat;
96769 }
96770
96771 +#ifdef CONFIG_GRKERNSEC_HIDESYM
96772 + net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%08lx", atomic_inc_return_unchecked(&conntrack_cache_id));
96773 +#else
96774 net->ct.slabname = kasprintf(GFP_KERNEL, "nf_conntrack_%p", net);
96775 +#endif
96776 if (!net->ct.slabname) {
96777 ret = -ENOMEM;
96778 goto err_slabname;
96779 diff --git a/net/netfilter/nf_conntrack_ecache.c b/net/netfilter/nf_conntrack_ecache.c
96780 index 1df1761..ce8b88a 100644
96781 --- a/net/netfilter/nf_conntrack_ecache.c
96782 +++ b/net/netfilter/nf_conntrack_ecache.c
96783 @@ -188,7 +188,7 @@ static struct nf_ct_ext_type event_extend __read_mostly = {
96784 #ifdef CONFIG_SYSCTL
96785 static int nf_conntrack_event_init_sysctl(struct net *net)
96786 {
96787 - struct ctl_table *table;
96788 + ctl_table_no_const *table;
96789
96790 table = kmemdup(event_sysctl_table, sizeof(event_sysctl_table),
96791 GFP_KERNEL);
96792 diff --git a/net/netfilter/nf_conntrack_helper.c b/net/netfilter/nf_conntrack_helper.c
96793 index 974a2a4..52cc6ff 100644
96794 --- a/net/netfilter/nf_conntrack_helper.c
96795 +++ b/net/netfilter/nf_conntrack_helper.c
96796 @@ -57,7 +57,7 @@ static struct ctl_table helper_sysctl_table[] = {
96797
96798 static int nf_conntrack_helper_init_sysctl(struct net *net)
96799 {
96800 - struct ctl_table *table;
96801 + ctl_table_no_const *table;
96802
96803 table = kmemdup(helper_sysctl_table, sizeof(helper_sysctl_table),
96804 GFP_KERNEL);
96805 diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c
96806 index ce30041..3861b5d 100644
96807 --- a/net/netfilter/nf_conntrack_proto.c
96808 +++ b/net/netfilter/nf_conntrack_proto.c
96809 @@ -52,7 +52,7 @@ nf_ct_register_sysctl(struct net *net,
96810
96811 static void
96812 nf_ct_unregister_sysctl(struct ctl_table_header **header,
96813 - struct ctl_table **table,
96814 + ctl_table_no_const **table,
96815 unsigned int users)
96816 {
96817 if (users > 0)
96818 diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
96819 index a99b6c3..cb372f9 100644
96820 --- a/net/netfilter/nf_conntrack_proto_dccp.c
96821 +++ b/net/netfilter/nf_conntrack_proto_dccp.c
96822 @@ -428,7 +428,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96823 const char *msg;
96824 u_int8_t state;
96825
96826 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96827 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96828 BUG_ON(dh == NULL);
96829
96830 state = dccp_state_table[CT_DCCP_ROLE_CLIENT][dh->dccph_type][CT_DCCP_NONE];
96831 @@ -457,7 +457,7 @@ static bool dccp_new(struct nf_conn *ct, const struct sk_buff *skb,
96832 out_invalid:
96833 if (LOG_INVALID(net, IPPROTO_DCCP))
96834 nf_log_packet(net, nf_ct_l3num(ct), 0, skb, NULL, NULL,
96835 - NULL, msg);
96836 + NULL, "%s", msg);
96837 return false;
96838 }
96839
96840 @@ -486,7 +486,7 @@ static int dccp_packet(struct nf_conn *ct, const struct sk_buff *skb,
96841 u_int8_t type, old_state, new_state;
96842 enum ct_dccp_roles role;
96843
96844 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96845 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96846 BUG_ON(dh == NULL);
96847 type = dh->dccph_type;
96848
96849 @@ -577,7 +577,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96850 unsigned int cscov;
96851 const char *msg;
96852
96853 - dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &dh);
96854 + dh = skb_header_pointer(skb, dataoff, sizeof(_dh), &_dh);
96855 if (dh == NULL) {
96856 msg = "nf_ct_dccp: short packet ";
96857 goto out_invalid;
96858 @@ -614,7 +614,7 @@ static int dccp_error(struct net *net, struct nf_conn *tmpl,
96859
96860 out_invalid:
96861 if (LOG_INVALID(net, IPPROTO_DCCP))
96862 - nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, msg);
96863 + nf_log_packet(net, pf, 0, skb, NULL, NULL, NULL, "%s", msg);
96864 return -NF_ACCEPT;
96865 }
96866
96867 diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
96868 index f641751..d3c5b51 100644
96869 --- a/net/netfilter/nf_conntrack_standalone.c
96870 +++ b/net/netfilter/nf_conntrack_standalone.c
96871 @@ -471,7 +471,7 @@ static struct ctl_table nf_ct_netfilter_table[] = {
96872
96873 static int nf_conntrack_standalone_init_sysctl(struct net *net)
96874 {
96875 - struct ctl_table *table;
96876 + ctl_table_no_const *table;
96877
96878 table = kmemdup(nf_ct_sysctl_table, sizeof(nf_ct_sysctl_table),
96879 GFP_KERNEL);
96880 diff --git a/net/netfilter/nf_conntrack_timestamp.c b/net/netfilter/nf_conntrack_timestamp.c
96881 index 902fb0a..87f7fdb 100644
96882 --- a/net/netfilter/nf_conntrack_timestamp.c
96883 +++ b/net/netfilter/nf_conntrack_timestamp.c
96884 @@ -42,7 +42,7 @@ static struct nf_ct_ext_type tstamp_extend __read_mostly = {
96885 #ifdef CONFIG_SYSCTL
96886 static int nf_conntrack_tstamp_init_sysctl(struct net *net)
96887 {
96888 - struct ctl_table *table;
96889 + ctl_table_no_const *table;
96890
96891 table = kmemdup(tstamp_sysctl_table, sizeof(tstamp_sysctl_table),
96892 GFP_KERNEL);
96893 diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
96894 index 85296d4..8becdec 100644
96895 --- a/net/netfilter/nf_log.c
96896 +++ b/net/netfilter/nf_log.c
96897 @@ -243,7 +243,7 @@ static const struct file_operations nflog_file_ops = {
96898
96899 #ifdef CONFIG_SYSCTL
96900 static char nf_log_sysctl_fnames[NFPROTO_NUMPROTO-NFPROTO_UNSPEC][3];
96901 -static struct ctl_table nf_log_sysctl_table[NFPROTO_NUMPROTO+1];
96902 +static ctl_table_no_const nf_log_sysctl_table[NFPROTO_NUMPROTO+1] __read_only;
96903
96904 static int nf_log_proc_dostring(struct ctl_table *table, int write,
96905 void __user *buffer, size_t *lenp, loff_t *ppos)
96906 @@ -274,14 +274,16 @@ static int nf_log_proc_dostring(struct ctl_table *table, int write,
96907 rcu_assign_pointer(net->nf.nf_loggers[tindex], logger);
96908 mutex_unlock(&nf_log_mutex);
96909 } else {
96910 + ctl_table_no_const nf_log_table = *table;
96911 +
96912 mutex_lock(&nf_log_mutex);
96913 logger = rcu_dereference_protected(net->nf.nf_loggers[tindex],
96914 lockdep_is_held(&nf_log_mutex));
96915 if (!logger)
96916 - table->data = "NONE";
96917 + nf_log_table.data = "NONE";
96918 else
96919 - table->data = logger->name;
96920 - r = proc_dostring(table, write, buffer, lenp, ppos);
96921 + nf_log_table.data = logger->name;
96922 + r = proc_dostring(&nf_log_table, write, buffer, lenp, ppos);
96923 mutex_unlock(&nf_log_mutex);
96924 }
96925
96926 diff --git a/net/netfilter/nf_sockopt.c b/net/netfilter/nf_sockopt.c
96927 index f042ae5..30ea486 100644
96928 --- a/net/netfilter/nf_sockopt.c
96929 +++ b/net/netfilter/nf_sockopt.c
96930 @@ -45,7 +45,7 @@ int nf_register_sockopt(struct nf_sockopt_ops *reg)
96931 }
96932 }
96933
96934 - list_add(&reg->list, &nf_sockopts);
96935 + pax_list_add((struct list_head *)&reg->list, &nf_sockopts);
96936 out:
96937 mutex_unlock(&nf_sockopt_mutex);
96938 return ret;
96939 @@ -55,7 +55,7 @@ EXPORT_SYMBOL(nf_register_sockopt);
96940 void nf_unregister_sockopt(struct nf_sockopt_ops *reg)
96941 {
96942 mutex_lock(&nf_sockopt_mutex);
96943 - list_del(&reg->list);
96944 + pax_list_del((struct list_head *)&reg->list);
96945 mutex_unlock(&nf_sockopt_mutex);
96946 }
96947 EXPORT_SYMBOL(nf_unregister_sockopt);
96948 diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
96949 index d92cc31..e46f350 100644
96950 --- a/net/netfilter/nfnetlink_log.c
96951 +++ b/net/netfilter/nfnetlink_log.c
96952 @@ -82,7 +82,7 @@ static int nfnl_log_net_id __read_mostly;
96953 struct nfnl_log_net {
96954 spinlock_t instances_lock;
96955 struct hlist_head instance_table[INSTANCE_BUCKETS];
96956 - atomic_t global_seq;
96957 + atomic_unchecked_t global_seq;
96958 };
96959
96960 static struct nfnl_log_net *nfnl_log_pernet(struct net *net)
96961 @@ -563,7 +563,7 @@ __build_packet_message(struct nfnl_log_net *log,
96962 /* global sequence number */
96963 if ((inst->flags & NFULNL_CFG_F_SEQ_GLOBAL) &&
96964 nla_put_be32(inst->skb, NFULA_SEQ_GLOBAL,
96965 - htonl(atomic_inc_return(&log->global_seq))))
96966 + htonl(atomic_inc_return_unchecked(&log->global_seq))))
96967 goto nla_put_failure;
96968
96969 if (data_len) {
96970 diff --git a/net/netfilter/xt_gradm.c b/net/netfilter/xt_gradm.c
96971 new file mode 100644
96972 index 0000000..c566332
96973 --- /dev/null
96974 +++ b/net/netfilter/xt_gradm.c
96975 @@ -0,0 +1,51 @@
96976 +/*
96977 + * gradm match for netfilter
96978 + * Copyright © Zbigniew Krzystolik, 2010
96979 + *
96980 + * This program is free software; you can redistribute it and/or modify
96981 + * it under the terms of the GNU General Public License; either version
96982 + * 2 or 3 as published by the Free Software Foundation.
96983 + */
96984 +#include <linux/module.h>
96985 +#include <linux/moduleparam.h>
96986 +#include <linux/skbuff.h>
96987 +#include <linux/netfilter/x_tables.h>
96988 +#include <linux/grsecurity.h>
96989 +#include <linux/netfilter/xt_gradm.h>
96990 +
96991 +static bool
96992 +gradm_mt(const struct sk_buff *skb, struct xt_action_param *par)
96993 +{
96994 + const struct xt_gradm_mtinfo *info = par->matchinfo;
96995 + bool retval = false;
96996 + if (gr_acl_is_enabled())
96997 + retval = true;
96998 + return retval ^ info->invflags;
96999 +}
97000 +
97001 +static struct xt_match gradm_mt_reg __read_mostly = {
97002 + .name = "gradm",
97003 + .revision = 0,
97004 + .family = NFPROTO_UNSPEC,
97005 + .match = gradm_mt,
97006 + .matchsize = XT_ALIGN(sizeof(struct xt_gradm_mtinfo)),
97007 + .me = THIS_MODULE,
97008 +};
97009 +
97010 +static int __init gradm_mt_init(void)
97011 +{
97012 + return xt_register_match(&gradm_mt_reg);
97013 +}
97014 +
97015 +static void __exit gradm_mt_exit(void)
97016 +{
97017 + xt_unregister_match(&gradm_mt_reg);
97018 +}
97019 +
97020 +module_init(gradm_mt_init);
97021 +module_exit(gradm_mt_exit);
97022 +MODULE_AUTHOR("Zbigniew Krzystolik <zbyniu@destrukcja.pl>");
97023 +MODULE_DESCRIPTION("Xtables: Grsecurity RBAC match");
97024 +MODULE_LICENSE("GPL");
97025 +MODULE_ALIAS("ipt_gradm");
97026 +MODULE_ALIAS("ip6t_gradm");
97027 diff --git a/net/netfilter/xt_statistic.c b/net/netfilter/xt_statistic.c
97028 index 4fe4fb4..87a89e5 100644
97029 --- a/net/netfilter/xt_statistic.c
97030 +++ b/net/netfilter/xt_statistic.c
97031 @@ -19,7 +19,7 @@
97032 #include <linux/module.h>
97033
97034 struct xt_statistic_priv {
97035 - atomic_t count;
97036 + atomic_unchecked_t count;
97037 } ____cacheline_aligned_in_smp;
97038
97039 MODULE_LICENSE("GPL");
97040 @@ -42,9 +42,9 @@ statistic_mt(const struct sk_buff *skb, struct xt_action_param *par)
97041 break;
97042 case XT_STATISTIC_MODE_NTH:
97043 do {
97044 - oval = atomic_read(&info->master->count);
97045 + oval = atomic_read_unchecked(&info->master->count);
97046 nval = (oval == info->u.nth.every) ? 0 : oval + 1;
97047 - } while (atomic_cmpxchg(&info->master->count, oval, nval) != oval);
97048 + } while (atomic_cmpxchg_unchecked(&info->master->count, oval, nval) != oval);
97049 if (nval == 0)
97050 ret = !ret;
97051 break;
97052 @@ -64,7 +64,7 @@ static int statistic_mt_check(const struct xt_mtchk_param *par)
97053 info->master = kzalloc(sizeof(*info->master), GFP_KERNEL);
97054 if (info->master == NULL)
97055 return -ENOMEM;
97056 - atomic_set(&info->master->count, info->u.nth.count);
97057 + atomic_set_unchecked(&info->master->count, info->u.nth.count);
97058
97059 return 0;
97060 }
97061 diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
97062 index 6135635..5bdc54a 100644
97063 --- a/net/netlink/af_netlink.c
97064 +++ b/net/netlink/af_netlink.c
97065 @@ -249,7 +249,7 @@ static void netlink_overrun(struct sock *sk)
97066 sk->sk_error_report(sk);
97067 }
97068 }
97069 - atomic_inc(&sk->sk_drops);
97070 + atomic_inc_unchecked(&sk->sk_drops);
97071 }
97072
97073 static void netlink_rcv_wake(struct sock *sk)
97074 @@ -2940,7 +2940,7 @@ static int netlink_seq_show(struct seq_file *seq, void *v)
97075 sk_wmem_alloc_get(s),
97076 nlk->cb_running,
97077 atomic_read(&s->sk_refcnt),
97078 - atomic_read(&s->sk_drops),
97079 + atomic_read_unchecked(&s->sk_drops),
97080 sock_i_ino(s)
97081 );
97082
97083 diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c
97084 index 0c741ce..f8c8ca7 100644
97085 --- a/net/netlink/genetlink.c
97086 +++ b/net/netlink/genetlink.c
97087 @@ -310,18 +310,20 @@ int genl_register_ops(struct genl_family *family, struct genl_ops *ops)
97088 goto errout;
97089 }
97090
97091 + pax_open_kernel();
97092 if (ops->dumpit)
97093 - ops->flags |= GENL_CMD_CAP_DUMP;
97094 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DUMP;
97095 if (ops->doit)
97096 - ops->flags |= GENL_CMD_CAP_DO;
97097 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_DO;
97098 if (ops->policy)
97099 - ops->flags |= GENL_CMD_CAP_HASPOL;
97100 + *(unsigned int *)&ops->flags |= GENL_CMD_CAP_HASPOL;
97101 + pax_close_kernel();
97102
97103 genl_lock_all();
97104 - list_add_tail(&ops->ops_list, &family->ops_list);
97105 + pax_list_add_tail((struct list_head *)&ops->ops_list, &family->ops_list);
97106 genl_unlock_all();
97107
97108 - genl_ctrl_event(CTRL_CMD_NEWOPS, ops);
97109 + genl_ctrl_event(CTRL_CMD_NEWOPS, (void *)ops);
97110 err = 0;
97111 errout:
97112 return err;
97113 @@ -351,9 +353,9 @@ int genl_unregister_ops(struct genl_family *family, struct genl_ops *ops)
97114 genl_lock_all();
97115 list_for_each_entry(rc, &family->ops_list, ops_list) {
97116 if (rc == ops) {
97117 - list_del(&ops->ops_list);
97118 + pax_list_del((struct list_head *)&ops->ops_list);
97119 genl_unlock_all();
97120 - genl_ctrl_event(CTRL_CMD_DELOPS, ops);
97121 + genl_ctrl_event(CTRL_CMD_DELOPS, (void *)ops);
97122 return 0;
97123 }
97124 }
97125 diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c
97126 index 53c19a3..b0ac04a 100644
97127 --- a/net/netrom/af_netrom.c
97128 +++ b/net/netrom/af_netrom.c
97129 @@ -850,7 +850,6 @@ static int nr_getname(struct socket *sock, struct sockaddr *uaddr,
97130 *uaddr_len = sizeof(struct full_sockaddr_ax25);
97131 } else {
97132 sax->fsa_ax25.sax25_family = AF_NETROM;
97133 - sax->fsa_ax25.sax25_ndigis = 0;
97134 sax->fsa_ax25.sax25_call = nr->source_addr;
97135 *uaddr_len = sizeof(struct sockaddr_ax25);
97136 }
97137 diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
97138 index ba2548b..1a4e98e 100644
97139 --- a/net/packet/af_packet.c
97140 +++ b/net/packet/af_packet.c
97141 @@ -1699,7 +1699,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
97142
97143 spin_lock(&sk->sk_receive_queue.lock);
97144 po->stats.stats1.tp_packets++;
97145 - skb->dropcount = atomic_read(&sk->sk_drops);
97146 + skb->dropcount = atomic_read_unchecked(&sk->sk_drops);
97147 __skb_queue_tail(&sk->sk_receive_queue, skb);
97148 spin_unlock(&sk->sk_receive_queue.lock);
97149 sk->sk_data_ready(sk, skb->len);
97150 @@ -1708,7 +1708,7 @@ static int packet_rcv(struct sk_buff *skb, struct net_device *dev,
97151 drop_n_acct:
97152 spin_lock(&sk->sk_receive_queue.lock);
97153 po->stats.stats1.tp_drops++;
97154 - atomic_inc(&sk->sk_drops);
97155 + atomic_inc_unchecked(&sk->sk_drops);
97156 spin_unlock(&sk->sk_receive_queue.lock);
97157
97158 drop_n_restore:
97159 @@ -3261,7 +3261,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
97160 case PACKET_HDRLEN:
97161 if (len > sizeof(int))
97162 len = sizeof(int);
97163 - if (copy_from_user(&val, optval, len))
97164 + if (len > sizeof(val) || copy_from_user(&val, optval, len))
97165 return -EFAULT;
97166 switch (val) {
97167 case TPACKET_V1:
97168 @@ -3304,7 +3304,7 @@ static int packet_getsockopt(struct socket *sock, int level, int optname,
97169 len = lv;
97170 if (put_user(len, optlen))
97171 return -EFAULT;
97172 - if (copy_to_user(optval, data, len))
97173 + if (len > sizeof(st) || copy_to_user(optval, data, len))
97174 return -EFAULT;
97175 return 0;
97176 }
97177 diff --git a/net/phonet/pep.c b/net/phonet/pep.c
97178 index e774117..900b8b7 100644
97179 --- a/net/phonet/pep.c
97180 +++ b/net/phonet/pep.c
97181 @@ -388,7 +388,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
97182
97183 case PNS_PEP_CTRL_REQ:
97184 if (skb_queue_len(&pn->ctrlreq_queue) >= PNPIPE_CTRLREQ_MAX) {
97185 - atomic_inc(&sk->sk_drops);
97186 + atomic_inc_unchecked(&sk->sk_drops);
97187 break;
97188 }
97189 __skb_pull(skb, 4);
97190 @@ -409,7 +409,7 @@ static int pipe_do_rcv(struct sock *sk, struct sk_buff *skb)
97191 }
97192
97193 if (pn->rx_credits == 0) {
97194 - atomic_inc(&sk->sk_drops);
97195 + atomic_inc_unchecked(&sk->sk_drops);
97196 err = -ENOBUFS;
97197 break;
97198 }
97199 @@ -580,7 +580,7 @@ static int pipe_handler_do_rcv(struct sock *sk, struct sk_buff *skb)
97200 }
97201
97202 if (pn->rx_credits == 0) {
97203 - atomic_inc(&sk->sk_drops);
97204 + atomic_inc_unchecked(&sk->sk_drops);
97205 err = NET_RX_DROP;
97206 break;
97207 }
97208 diff --git a/net/phonet/socket.c b/net/phonet/socket.c
97209 index 77e38f7..f4ef5c3 100644
97210 --- a/net/phonet/socket.c
97211 +++ b/net/phonet/socket.c
97212 @@ -612,7 +612,7 @@ static int pn_sock_seq_show(struct seq_file *seq, void *v)
97213 from_kuid_munged(seq_user_ns(seq), sock_i_uid(sk)),
97214 sock_i_ino(sk),
97215 atomic_read(&sk->sk_refcnt), sk,
97216 - atomic_read(&sk->sk_drops), &len);
97217 + atomic_read_unchecked(&sk->sk_drops), &len);
97218 }
97219 seq_printf(seq, "%*s\n", 127 - len, "");
97220 return 0;
97221 diff --git a/net/phonet/sysctl.c b/net/phonet/sysctl.c
97222 index c02a8c4..3c5b600 100644
97223 --- a/net/phonet/sysctl.c
97224 +++ b/net/phonet/sysctl.c
97225 @@ -67,7 +67,7 @@ static int proc_local_port_range(struct ctl_table *table, int write,
97226 {
97227 int ret;
97228 int range[2] = {local_port_range[0], local_port_range[1]};
97229 - struct ctl_table tmp = {
97230 + ctl_table_no_const tmp = {
97231 .data = &range,
97232 .maxlen = sizeof(range),
97233 .mode = table->mode,
97234 diff --git a/net/rds/cong.c b/net/rds/cong.c
97235 index e5b65ac..f3b6fb7 100644
97236 --- a/net/rds/cong.c
97237 +++ b/net/rds/cong.c
97238 @@ -78,7 +78,7 @@
97239 * finds that the saved generation number is smaller than the global generation
97240 * number, it wakes up the process.
97241 */
97242 -static atomic_t rds_cong_generation = ATOMIC_INIT(0);
97243 +static atomic_unchecked_t rds_cong_generation = ATOMIC_INIT(0);
97244
97245 /*
97246 * Congestion monitoring
97247 @@ -233,7 +233,7 @@ void rds_cong_map_updated(struct rds_cong_map *map, uint64_t portmask)
97248 rdsdebug("waking map %p for %pI4\n",
97249 map, &map->m_addr);
97250 rds_stats_inc(s_cong_update_received);
97251 - atomic_inc(&rds_cong_generation);
97252 + atomic_inc_unchecked(&rds_cong_generation);
97253 if (waitqueue_active(&map->m_waitq))
97254 wake_up(&map->m_waitq);
97255 if (waitqueue_active(&rds_poll_waitq))
97256 @@ -259,7 +259,7 @@ EXPORT_SYMBOL_GPL(rds_cong_map_updated);
97257
97258 int rds_cong_updated_since(unsigned long *recent)
97259 {
97260 - unsigned long gen = atomic_read(&rds_cong_generation);
97261 + unsigned long gen = atomic_read_unchecked(&rds_cong_generation);
97262
97263 if (likely(*recent == gen))
97264 return 0;
97265 diff --git a/net/rds/ib.h b/net/rds/ib.h
97266 index 7280ab8..e04f4ea 100644
97267 --- a/net/rds/ib.h
97268 +++ b/net/rds/ib.h
97269 @@ -128,7 +128,7 @@ struct rds_ib_connection {
97270 /* sending acks */
97271 unsigned long i_ack_flags;
97272 #ifdef KERNEL_HAS_ATOMIC64
97273 - atomic64_t i_ack_next; /* next ACK to send */
97274 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
97275 #else
97276 spinlock_t i_ack_lock; /* protect i_ack_next */
97277 u64 i_ack_next; /* next ACK to send */
97278 diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c
97279 index 31b74f5..dc1fbfa 100644
97280 --- a/net/rds/ib_cm.c
97281 +++ b/net/rds/ib_cm.c
97282 @@ -717,7 +717,7 @@ void rds_ib_conn_shutdown(struct rds_connection *conn)
97283 /* Clear the ACK state */
97284 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
97285 #ifdef KERNEL_HAS_ATOMIC64
97286 - atomic64_set(&ic->i_ack_next, 0);
97287 + atomic64_set_unchecked(&ic->i_ack_next, 0);
97288 #else
97289 ic->i_ack_next = 0;
97290 #endif
97291 diff --git a/net/rds/ib_recv.c b/net/rds/ib_recv.c
97292 index 8eb9501..0c386ff 100644
97293 --- a/net/rds/ib_recv.c
97294 +++ b/net/rds/ib_recv.c
97295 @@ -597,7 +597,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
97296 static void rds_ib_set_ack(struct rds_ib_connection *ic, u64 seq,
97297 int ack_required)
97298 {
97299 - atomic64_set(&ic->i_ack_next, seq);
97300 + atomic64_set_unchecked(&ic->i_ack_next, seq);
97301 if (ack_required) {
97302 smp_mb__before_clear_bit();
97303 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97304 @@ -609,7 +609,7 @@ static u64 rds_ib_get_ack(struct rds_ib_connection *ic)
97305 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97306 smp_mb__after_clear_bit();
97307
97308 - return atomic64_read(&ic->i_ack_next);
97309 + return atomic64_read_unchecked(&ic->i_ack_next);
97310 }
97311 #endif
97312
97313 diff --git a/net/rds/iw.h b/net/rds/iw.h
97314 index 04ce3b1..48119a6 100644
97315 --- a/net/rds/iw.h
97316 +++ b/net/rds/iw.h
97317 @@ -134,7 +134,7 @@ struct rds_iw_connection {
97318 /* sending acks */
97319 unsigned long i_ack_flags;
97320 #ifdef KERNEL_HAS_ATOMIC64
97321 - atomic64_t i_ack_next; /* next ACK to send */
97322 + atomic64_unchecked_t i_ack_next; /* next ACK to send */
97323 #else
97324 spinlock_t i_ack_lock; /* protect i_ack_next */
97325 u64 i_ack_next; /* next ACK to send */
97326 diff --git a/net/rds/iw_cm.c b/net/rds/iw_cm.c
97327 index a91e1db..cf3053f 100644
97328 --- a/net/rds/iw_cm.c
97329 +++ b/net/rds/iw_cm.c
97330 @@ -663,7 +663,7 @@ void rds_iw_conn_shutdown(struct rds_connection *conn)
97331 /* Clear the ACK state */
97332 clear_bit(IB_ACK_IN_FLIGHT, &ic->i_ack_flags);
97333 #ifdef KERNEL_HAS_ATOMIC64
97334 - atomic64_set(&ic->i_ack_next, 0);
97335 + atomic64_set_unchecked(&ic->i_ack_next, 0);
97336 #else
97337 ic->i_ack_next = 0;
97338 #endif
97339 diff --git a/net/rds/iw_recv.c b/net/rds/iw_recv.c
97340 index 4503335..db566b4 100644
97341 --- a/net/rds/iw_recv.c
97342 +++ b/net/rds/iw_recv.c
97343 @@ -427,7 +427,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
97344 static void rds_iw_set_ack(struct rds_iw_connection *ic, u64 seq,
97345 int ack_required)
97346 {
97347 - atomic64_set(&ic->i_ack_next, seq);
97348 + atomic64_set_unchecked(&ic->i_ack_next, seq);
97349 if (ack_required) {
97350 smp_mb__before_clear_bit();
97351 set_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97352 @@ -439,7 +439,7 @@ static u64 rds_iw_get_ack(struct rds_iw_connection *ic)
97353 clear_bit(IB_ACK_REQUESTED, &ic->i_ack_flags);
97354 smp_mb__after_clear_bit();
97355
97356 - return atomic64_read(&ic->i_ack_next);
97357 + return atomic64_read_unchecked(&ic->i_ack_next);
97358 }
97359 #endif
97360
97361 diff --git a/net/rds/rds.h b/net/rds/rds.h
97362 index ec1d731..90a3a8d 100644
97363 --- a/net/rds/rds.h
97364 +++ b/net/rds/rds.h
97365 @@ -449,7 +449,7 @@ struct rds_transport {
97366 void (*sync_mr)(void *trans_private, int direction);
97367 void (*free_mr)(void *trans_private, int invalidate);
97368 void (*flush_mrs)(void);
97369 -};
97370 +} __do_const;
97371
97372 struct rds_sock {
97373 struct sock rs_sk;
97374 diff --git a/net/rds/tcp.c b/net/rds/tcp.c
97375 index edac9ef..16bcb98 100644
97376 --- a/net/rds/tcp.c
97377 +++ b/net/rds/tcp.c
97378 @@ -59,7 +59,7 @@ void rds_tcp_nonagle(struct socket *sock)
97379 int val = 1;
97380
97381 set_fs(KERNEL_DS);
97382 - sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __user *)&val,
97383 + sock->ops->setsockopt(sock, SOL_TCP, TCP_NODELAY, (char __force_user *)&val,
97384 sizeof(val));
97385 set_fs(oldfs);
97386 }
97387 diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
97388 index 81cf5a4..b5826ff 100644
97389 --- a/net/rds/tcp_send.c
97390 +++ b/net/rds/tcp_send.c
97391 @@ -43,7 +43,7 @@ static void rds_tcp_cork(struct socket *sock, int val)
97392
97393 oldfs = get_fs();
97394 set_fs(KERNEL_DS);
97395 - sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __user *)&val,
97396 + sock->ops->setsockopt(sock, SOL_TCP, TCP_CORK, (char __force_user *)&val,
97397 sizeof(val));
97398 set_fs(oldfs);
97399 }
97400 diff --git a/net/rxrpc/af_rxrpc.c b/net/rxrpc/af_rxrpc.c
97401 index e61aa60..f07cc89 100644
97402 --- a/net/rxrpc/af_rxrpc.c
97403 +++ b/net/rxrpc/af_rxrpc.c
97404 @@ -40,7 +40,7 @@ static const struct proto_ops rxrpc_rpc_ops;
97405 __be32 rxrpc_epoch;
97406
97407 /* current debugging ID */
97408 -atomic_t rxrpc_debug_id;
97409 +atomic_unchecked_t rxrpc_debug_id;
97410
97411 /* count of skbs currently in use */
97412 atomic_t rxrpc_n_skbs;
97413 diff --git a/net/rxrpc/ar-ack.c b/net/rxrpc/ar-ack.c
97414 index e4d9cbc..b229649 100644
97415 --- a/net/rxrpc/ar-ack.c
97416 +++ b/net/rxrpc/ar-ack.c
97417 @@ -175,7 +175,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
97418
97419 _enter("{%d,%d,%d,%d},",
97420 call->acks_hard, call->acks_unacked,
97421 - atomic_read(&call->sequence),
97422 + atomic_read_unchecked(&call->sequence),
97423 CIRC_CNT(call->acks_head, call->acks_tail, call->acks_winsz));
97424
97425 stop = 0;
97426 @@ -199,7 +199,7 @@ static void rxrpc_resend(struct rxrpc_call *call)
97427
97428 /* each Tx packet has a new serial number */
97429 sp->hdr.serial =
97430 - htonl(atomic_inc_return(&call->conn->serial));
97431 + htonl(atomic_inc_return_unchecked(&call->conn->serial));
97432
97433 hdr = (struct rxrpc_header *) txb->head;
97434 hdr->serial = sp->hdr.serial;
97435 @@ -403,7 +403,7 @@ static void rxrpc_rotate_tx_window(struct rxrpc_call *call, u32 hard)
97436 */
97437 static void rxrpc_clear_tx_window(struct rxrpc_call *call)
97438 {
97439 - rxrpc_rotate_tx_window(call, atomic_read(&call->sequence));
97440 + rxrpc_rotate_tx_window(call, atomic_read_unchecked(&call->sequence));
97441 }
97442
97443 /*
97444 @@ -629,7 +629,7 @@ process_further:
97445
97446 latest = ntohl(sp->hdr.serial);
97447 hard = ntohl(ack.firstPacket);
97448 - tx = atomic_read(&call->sequence);
97449 + tx = atomic_read_unchecked(&call->sequence);
97450
97451 _proto("Rx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
97452 latest,
97453 @@ -1161,7 +1161,7 @@ void rxrpc_process_call(struct work_struct *work)
97454 goto maybe_reschedule;
97455
97456 send_ACK_with_skew:
97457 - ack.maxSkew = htons(atomic_read(&call->conn->hi_serial) -
97458 + ack.maxSkew = htons(atomic_read_unchecked(&call->conn->hi_serial) -
97459 ntohl(ack.serial));
97460 send_ACK:
97461 mtu = call->conn->trans->peer->if_mtu;
97462 @@ -1173,7 +1173,7 @@ send_ACK:
97463 ackinfo.rxMTU = htonl(5692);
97464 ackinfo.jumbo_max = htonl(4);
97465
97466 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
97467 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
97468 _proto("Tx ACK %%%u { m=%hu f=#%u p=#%u s=%%%u r=%s n=%u }",
97469 ntohl(hdr.serial),
97470 ntohs(ack.maxSkew),
97471 @@ -1191,7 +1191,7 @@ send_ACK:
97472 send_message:
97473 _debug("send message");
97474
97475 - hdr.serial = htonl(atomic_inc_return(&call->conn->serial));
97476 + hdr.serial = htonl(atomic_inc_return_unchecked(&call->conn->serial));
97477 _proto("Tx %s %%%u", rxrpc_pkts[hdr.type], ntohl(hdr.serial));
97478 send_message_2:
97479
97480 diff --git a/net/rxrpc/ar-call.c b/net/rxrpc/ar-call.c
97481 index a3bbb36..3341fb9 100644
97482 --- a/net/rxrpc/ar-call.c
97483 +++ b/net/rxrpc/ar-call.c
97484 @@ -83,7 +83,7 @@ static struct rxrpc_call *rxrpc_alloc_call(gfp_t gfp)
97485 spin_lock_init(&call->lock);
97486 rwlock_init(&call->state_lock);
97487 atomic_set(&call->usage, 1);
97488 - call->debug_id = atomic_inc_return(&rxrpc_debug_id);
97489 + call->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97490 call->state = RXRPC_CALL_CLIENT_SEND_REQUEST;
97491
97492 memset(&call->sock_node, 0xed, sizeof(call->sock_node));
97493 diff --git a/net/rxrpc/ar-connection.c b/net/rxrpc/ar-connection.c
97494 index 4106ca9..a338d7a 100644
97495 --- a/net/rxrpc/ar-connection.c
97496 +++ b/net/rxrpc/ar-connection.c
97497 @@ -206,7 +206,7 @@ static struct rxrpc_connection *rxrpc_alloc_connection(gfp_t gfp)
97498 rwlock_init(&conn->lock);
97499 spin_lock_init(&conn->state_lock);
97500 atomic_set(&conn->usage, 1);
97501 - conn->debug_id = atomic_inc_return(&rxrpc_debug_id);
97502 + conn->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97503 conn->avail_calls = RXRPC_MAXCALLS;
97504 conn->size_align = 4;
97505 conn->header_size = sizeof(struct rxrpc_header);
97506 diff --git a/net/rxrpc/ar-connevent.c b/net/rxrpc/ar-connevent.c
97507 index e7ed43a..6afa140 100644
97508 --- a/net/rxrpc/ar-connevent.c
97509 +++ b/net/rxrpc/ar-connevent.c
97510 @@ -109,7 +109,7 @@ static int rxrpc_abort_connection(struct rxrpc_connection *conn,
97511
97512 len = iov[0].iov_len + iov[1].iov_len;
97513
97514 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97515 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97516 _proto("Tx CONN ABORT %%%u { %d }", ntohl(hdr.serial), abort_code);
97517
97518 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97519 diff --git a/net/rxrpc/ar-input.c b/net/rxrpc/ar-input.c
97520 index 529572f..c758ca7 100644
97521 --- a/net/rxrpc/ar-input.c
97522 +++ b/net/rxrpc/ar-input.c
97523 @@ -340,9 +340,9 @@ void rxrpc_fast_process_packet(struct rxrpc_call *call, struct sk_buff *skb)
97524 /* track the latest serial number on this connection for ACK packet
97525 * information */
97526 serial = ntohl(sp->hdr.serial);
97527 - hi_serial = atomic_read(&call->conn->hi_serial);
97528 + hi_serial = atomic_read_unchecked(&call->conn->hi_serial);
97529 while (serial > hi_serial)
97530 - hi_serial = atomic_cmpxchg(&call->conn->hi_serial, hi_serial,
97531 + hi_serial = atomic_cmpxchg_unchecked(&call->conn->hi_serial, hi_serial,
97532 serial);
97533
97534 /* request ACK generation for any ACK or DATA packet that requests
97535 diff --git a/net/rxrpc/ar-internal.h b/net/rxrpc/ar-internal.h
97536 index a693aca..81e7293 100644
97537 --- a/net/rxrpc/ar-internal.h
97538 +++ b/net/rxrpc/ar-internal.h
97539 @@ -272,8 +272,8 @@ struct rxrpc_connection {
97540 int error; /* error code for local abort */
97541 int debug_id; /* debug ID for printks */
97542 unsigned int call_counter; /* call ID counter */
97543 - atomic_t serial; /* packet serial number counter */
97544 - atomic_t hi_serial; /* highest serial number received */
97545 + atomic_unchecked_t serial; /* packet serial number counter */
97546 + atomic_unchecked_t hi_serial; /* highest serial number received */
97547 u8 avail_calls; /* number of calls available */
97548 u8 size_align; /* data size alignment (for security) */
97549 u8 header_size; /* rxrpc + security header size */
97550 @@ -346,7 +346,7 @@ struct rxrpc_call {
97551 spinlock_t lock;
97552 rwlock_t state_lock; /* lock for state transition */
97553 atomic_t usage;
97554 - atomic_t sequence; /* Tx data packet sequence counter */
97555 + atomic_unchecked_t sequence; /* Tx data packet sequence counter */
97556 u32 abort_code; /* local/remote abort code */
97557 enum { /* current state of call */
97558 RXRPC_CALL_CLIENT_SEND_REQUEST, /* - client sending request phase */
97559 @@ -420,7 +420,7 @@ static inline void rxrpc_abort_call(struct rxrpc_call *call, u32 abort_code)
97560 */
97561 extern atomic_t rxrpc_n_skbs;
97562 extern __be32 rxrpc_epoch;
97563 -extern atomic_t rxrpc_debug_id;
97564 +extern atomic_unchecked_t rxrpc_debug_id;
97565 extern struct workqueue_struct *rxrpc_workqueue;
97566
97567 /*
97568 diff --git a/net/rxrpc/ar-local.c b/net/rxrpc/ar-local.c
97569 index 87f7135..74d3703 100644
97570 --- a/net/rxrpc/ar-local.c
97571 +++ b/net/rxrpc/ar-local.c
97572 @@ -45,7 +45,7 @@ struct rxrpc_local *rxrpc_alloc_local(struct sockaddr_rxrpc *srx)
97573 spin_lock_init(&local->lock);
97574 rwlock_init(&local->services_lock);
97575 atomic_set(&local->usage, 1);
97576 - local->debug_id = atomic_inc_return(&rxrpc_debug_id);
97577 + local->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97578 memcpy(&local->srx, srx, sizeof(*srx));
97579 }
97580
97581 diff --git a/net/rxrpc/ar-output.c b/net/rxrpc/ar-output.c
97582 index e1ac183..b43e10e 100644
97583 --- a/net/rxrpc/ar-output.c
97584 +++ b/net/rxrpc/ar-output.c
97585 @@ -682,9 +682,9 @@ static int rxrpc_send_data(struct kiocb *iocb,
97586 sp->hdr.cid = call->cid;
97587 sp->hdr.callNumber = call->call_id;
97588 sp->hdr.seq =
97589 - htonl(atomic_inc_return(&call->sequence));
97590 + htonl(atomic_inc_return_unchecked(&call->sequence));
97591 sp->hdr.serial =
97592 - htonl(atomic_inc_return(&conn->serial));
97593 + htonl(atomic_inc_return_unchecked(&conn->serial));
97594 sp->hdr.type = RXRPC_PACKET_TYPE_DATA;
97595 sp->hdr.userStatus = 0;
97596 sp->hdr.securityIndex = conn->security_ix;
97597 diff --git a/net/rxrpc/ar-peer.c b/net/rxrpc/ar-peer.c
97598 index bebaa43..2644591 100644
97599 --- a/net/rxrpc/ar-peer.c
97600 +++ b/net/rxrpc/ar-peer.c
97601 @@ -72,7 +72,7 @@ static struct rxrpc_peer *rxrpc_alloc_peer(struct sockaddr_rxrpc *srx,
97602 INIT_LIST_HEAD(&peer->error_targets);
97603 spin_lock_init(&peer->lock);
97604 atomic_set(&peer->usage, 1);
97605 - peer->debug_id = atomic_inc_return(&rxrpc_debug_id);
97606 + peer->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97607 memcpy(&peer->srx, srx, sizeof(*srx));
97608
97609 rxrpc_assess_MTU_size(peer);
97610 diff --git a/net/rxrpc/ar-proc.c b/net/rxrpc/ar-proc.c
97611 index 38047f7..9f48511 100644
97612 --- a/net/rxrpc/ar-proc.c
97613 +++ b/net/rxrpc/ar-proc.c
97614 @@ -164,8 +164,8 @@ static int rxrpc_connection_seq_show(struct seq_file *seq, void *v)
97615 atomic_read(&conn->usage),
97616 rxrpc_conn_states[conn->state],
97617 key_serial(conn->key),
97618 - atomic_read(&conn->serial),
97619 - atomic_read(&conn->hi_serial));
97620 + atomic_read_unchecked(&conn->serial),
97621 + atomic_read_unchecked(&conn->hi_serial));
97622
97623 return 0;
97624 }
97625 diff --git a/net/rxrpc/ar-transport.c b/net/rxrpc/ar-transport.c
97626 index 92df566..87ec1bf 100644
97627 --- a/net/rxrpc/ar-transport.c
97628 +++ b/net/rxrpc/ar-transport.c
97629 @@ -47,7 +47,7 @@ static struct rxrpc_transport *rxrpc_alloc_transport(struct rxrpc_local *local,
97630 spin_lock_init(&trans->client_lock);
97631 rwlock_init(&trans->conn_lock);
97632 atomic_set(&trans->usage, 1);
97633 - trans->debug_id = atomic_inc_return(&rxrpc_debug_id);
97634 + trans->debug_id = atomic_inc_return_unchecked(&rxrpc_debug_id);
97635
97636 if (peer->srx.transport.family == AF_INET) {
97637 switch (peer->srx.transport_type) {
97638 diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
97639 index f226709..0e735a8 100644
97640 --- a/net/rxrpc/rxkad.c
97641 +++ b/net/rxrpc/rxkad.c
97642 @@ -610,7 +610,7 @@ static int rxkad_issue_challenge(struct rxrpc_connection *conn)
97643
97644 len = iov[0].iov_len + iov[1].iov_len;
97645
97646 - hdr.serial = htonl(atomic_inc_return(&conn->serial));
97647 + hdr.serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97648 _proto("Tx CHALLENGE %%%u", ntohl(hdr.serial));
97649
97650 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 2, len);
97651 @@ -660,7 +660,7 @@ static int rxkad_send_response(struct rxrpc_connection *conn,
97652
97653 len = iov[0].iov_len + iov[1].iov_len + iov[2].iov_len;
97654
97655 - hdr->serial = htonl(atomic_inc_return(&conn->serial));
97656 + hdr->serial = htonl(atomic_inc_return_unchecked(&conn->serial));
97657 _proto("Tx RESPONSE %%%u", ntohl(hdr->serial));
97658
97659 ret = kernel_sendmsg(conn->trans->local->socket, &msg, iov, 3, len);
97660 diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c
97661 index e7b2d4f..bb1efd0 100644
97662 --- a/net/sctp/ipv6.c
97663 +++ b/net/sctp/ipv6.c
97664 @@ -962,7 +962,7 @@ static const struct inet6_protocol sctpv6_protocol = {
97665 .flags = INET6_PROTO_NOPOLICY | INET6_PROTO_FINAL,
97666 };
97667
97668 -static struct sctp_af sctp_af_inet6 = {
97669 +static struct sctp_af sctp_af_inet6 __read_only = {
97670 .sa_family = AF_INET6,
97671 .sctp_xmit = sctp_v6_xmit,
97672 .setsockopt = ipv6_setsockopt,
97673 @@ -994,7 +994,7 @@ static struct sctp_af sctp_af_inet6 = {
97674 #endif
97675 };
97676
97677 -static struct sctp_pf sctp_pf_inet6 = {
97678 +static struct sctp_pf sctp_pf_inet6 __read_only = {
97679 .event_msgname = sctp_inet6_event_msgname,
97680 .skb_msgname = sctp_inet6_skb_msgname,
97681 .af_supported = sctp_inet6_af_supported,
97682 @@ -1019,7 +1019,7 @@ void sctp_v6_pf_init(void)
97683
97684 void sctp_v6_pf_exit(void)
97685 {
97686 - list_del(&sctp_af_inet6.list);
97687 + pax_list_del(&sctp_af_inet6.list);
97688 }
97689
97690 /* Initialize IPv6 support and register with socket layer. */
97691 diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c
97692 index 5e17092..19be1d4 100644
97693 --- a/net/sctp/protocol.c
97694 +++ b/net/sctp/protocol.c
97695 @@ -832,8 +832,10 @@ int sctp_register_af(struct sctp_af *af)
97696 return 0;
97697 }
97698
97699 + pax_open_kernel();
97700 INIT_LIST_HEAD(&af->list);
97701 - list_add_tail(&af->list, &sctp_address_families);
97702 + pax_close_kernel();
97703 + pax_list_add_tail(&af->list, &sctp_address_families);
97704 return 1;
97705 }
97706
97707 @@ -963,7 +965,7 @@ static inline int sctp_v4_xmit(struct sk_buff *skb,
97708
97709 static struct sctp_af sctp_af_inet;
97710
97711 -static struct sctp_pf sctp_pf_inet = {
97712 +static struct sctp_pf sctp_pf_inet __read_only = {
97713 .event_msgname = sctp_inet_event_msgname,
97714 .skb_msgname = sctp_inet_skb_msgname,
97715 .af_supported = sctp_inet_af_supported,
97716 @@ -1034,7 +1036,7 @@ static const struct net_protocol sctp_protocol = {
97717 };
97718
97719 /* IPv4 address related functions. */
97720 -static struct sctp_af sctp_af_inet = {
97721 +static struct sctp_af sctp_af_inet __read_only = {
97722 .sa_family = AF_INET,
97723 .sctp_xmit = sctp_v4_xmit,
97724 .setsockopt = ip_setsockopt,
97725 @@ -1119,7 +1121,7 @@ static void sctp_v4_pf_init(void)
97726
97727 static void sctp_v4_pf_exit(void)
97728 {
97729 - list_del(&sctp_af_inet.list);
97730 + pax_list_del(&sctp_af_inet.list);
97731 }
97732
97733 static int sctp_v4_protosw_init(void)
97734 diff --git a/net/sctp/sm_sideeffect.c b/net/sctp/sm_sideeffect.c
97735 index 1a6eef3..17e898f 100644
97736 --- a/net/sctp/sm_sideeffect.c
97737 +++ b/net/sctp/sm_sideeffect.c
97738 @@ -440,7 +440,7 @@ static void sctp_generate_sack_event(unsigned long data)
97739 sctp_generate_timeout_event(asoc, SCTP_EVENT_TIMEOUT_SACK);
97740 }
97741
97742 -sctp_timer_event_t *sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97743 +sctp_timer_event_t * const sctp_timer_events[SCTP_NUM_TIMEOUT_TYPES] = {
97744 NULL,
97745 sctp_generate_t1_cookie_event,
97746 sctp_generate_t1_init_event,
97747 diff --git a/net/sctp/socket.c b/net/sctp/socket.c
97748 index 911b71b..90ade0a 100644
97749 --- a/net/sctp/socket.c
97750 +++ b/net/sctp/socket.c
97751 @@ -2153,11 +2153,13 @@ static int sctp_setsockopt_events(struct sock *sk, char __user *optval,
97752 {
97753 struct sctp_association *asoc;
97754 struct sctp_ulpevent *event;
97755 + struct sctp_event_subscribe subscribe;
97756
97757 if (optlen > sizeof(struct sctp_event_subscribe))
97758 return -EINVAL;
97759 - if (copy_from_user(&sctp_sk(sk)->subscribe, optval, optlen))
97760 + if (copy_from_user(&subscribe, optval, optlen))
97761 return -EFAULT;
97762 + sctp_sk(sk)->subscribe = subscribe;
97763
97764 /*
97765 * At the time when a user app subscribes to SCTP_SENDER_DRY_EVENT,
97766 @@ -4213,13 +4215,16 @@ static int sctp_getsockopt_disable_fragments(struct sock *sk, int len,
97767 static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97768 int __user *optlen)
97769 {
97770 + struct sctp_event_subscribe subscribe;
97771 +
97772 if (len <= 0)
97773 return -EINVAL;
97774 if (len > sizeof(struct sctp_event_subscribe))
97775 len = sizeof(struct sctp_event_subscribe);
97776 if (put_user(len, optlen))
97777 return -EFAULT;
97778 - if (copy_to_user(optval, &sctp_sk(sk)->subscribe, len))
97779 + subscribe = sctp_sk(sk)->subscribe;
97780 + if (copy_to_user(optval, &subscribe, len))
97781 return -EFAULT;
97782 return 0;
97783 }
97784 @@ -4237,6 +4242,8 @@ static int sctp_getsockopt_events(struct sock *sk, int len, char __user *optval,
97785 */
97786 static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optval, int __user *optlen)
97787 {
97788 + __u32 autoclose;
97789 +
97790 /* Applicable to UDP-style socket only */
97791 if (sctp_style(sk, TCP))
97792 return -EOPNOTSUPP;
97793 @@ -4245,7 +4252,8 @@ static int sctp_getsockopt_autoclose(struct sock *sk, int len, char __user *optv
97794 len = sizeof(int);
97795 if (put_user(len, optlen))
97796 return -EFAULT;
97797 - if (copy_to_user(optval, &sctp_sk(sk)->autoclose, sizeof(int)))
97798 + autoclose = sctp_sk(sk)->autoclose;
97799 + if (copy_to_user(optval, &autoclose, sizeof(int)))
97800 return -EFAULT;
97801 return 0;
97802 }
97803 @@ -4617,12 +4625,15 @@ static int sctp_getsockopt_delayed_ack(struct sock *sk, int len,
97804 */
97805 static int sctp_getsockopt_initmsg(struct sock *sk, int len, char __user *optval, int __user *optlen)
97806 {
97807 + struct sctp_initmsg initmsg;
97808 +
97809 if (len < sizeof(struct sctp_initmsg))
97810 return -EINVAL;
97811 len = sizeof(struct sctp_initmsg);
97812 if (put_user(len, optlen))
97813 return -EFAULT;
97814 - if (copy_to_user(optval, &sctp_sk(sk)->initmsg, len))
97815 + initmsg = sctp_sk(sk)->initmsg;
97816 + if (copy_to_user(optval, &initmsg, len))
97817 return -EFAULT;
97818 return 0;
97819 }
97820 @@ -4663,6 +4674,8 @@ static int sctp_getsockopt_peer_addrs(struct sock *sk, int len,
97821 addrlen = sctp_get_af_specific(temp.sa.sa_family)->sockaddr_len;
97822 if (space_left < addrlen)
97823 return -ENOMEM;
97824 + if (addrlen > sizeof(temp) || addrlen < 0)
97825 + return -EFAULT;
97826 if (copy_to_user(to, &temp, addrlen))
97827 return -EFAULT;
97828 to += addrlen;
97829 diff --git a/net/sctp/sysctl.c b/net/sctp/sysctl.c
97830 index 6b36561..4f21064 100644
97831 --- a/net/sctp/sysctl.c
97832 +++ b/net/sctp/sysctl.c
97833 @@ -301,7 +301,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
97834 {
97835 struct net *net = current->nsproxy->net_ns;
97836 char tmp[8];
97837 - struct ctl_table tbl;
97838 + ctl_table_no_const tbl;
97839 int ret;
97840 int changed = 0;
97841 char *none = "none";
97842 @@ -344,7 +344,7 @@ static int proc_sctp_do_hmac_alg(struct ctl_table *ctl,
97843
97844 int sctp_sysctl_net_register(struct net *net)
97845 {
97846 - struct ctl_table *table;
97847 + ctl_table_no_const *table;
97848 int i;
97849
97850 table = kmemdup(sctp_net_table, sizeof(sctp_net_table), GFP_KERNEL);
97851 diff --git a/net/socket.c b/net/socket.c
97852 index e83c416..9169305 100644
97853 --- a/net/socket.c
97854 +++ b/net/socket.c
97855 @@ -88,6 +88,7 @@
97856 #include <linux/magic.h>
97857 #include <linux/slab.h>
97858 #include <linux/xattr.h>
97859 +#include <linux/in.h>
97860
97861 #include <asm/uaccess.h>
97862 #include <asm/unistd.h>
97863 @@ -111,6 +112,8 @@ unsigned int sysctl_net_busy_read __read_mostly;
97864 unsigned int sysctl_net_busy_poll __read_mostly;
97865 #endif
97866
97867 +#include <linux/grsock.h>
97868 +
97869 static int sock_no_open(struct inode *irrelevant, struct file *dontcare);
97870 static ssize_t sock_aio_read(struct kiocb *iocb, const struct iovec *iov,
97871 unsigned long nr_segs, loff_t pos);
97872 @@ -162,7 +165,7 @@ static const struct file_operations socket_file_ops = {
97873 */
97874
97875 static DEFINE_SPINLOCK(net_family_lock);
97876 -static const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
97877 +const struct net_proto_family __rcu *net_families[NPROTO] __read_mostly;
97878
97879 /*
97880 * Statistics counters of the socket lists
97881 @@ -328,7 +331,7 @@ static struct dentry *sockfs_mount(struct file_system_type *fs_type,
97882 &sockfs_dentry_operations, SOCKFS_MAGIC);
97883 }
97884
97885 -static struct vfsmount *sock_mnt __read_mostly;
97886 +struct vfsmount *sock_mnt __read_mostly;
97887
97888 static struct file_system_type sock_fs_type = {
97889 .name = "sockfs",
97890 @@ -1255,6 +1258,8 @@ int __sock_create(struct net *net, int family, int type, int protocol,
97891 return -EAFNOSUPPORT;
97892 if (type < 0 || type >= SOCK_MAX)
97893 return -EINVAL;
97894 + if (protocol < 0)
97895 + return -EINVAL;
97896
97897 /* Compatibility.
97898
97899 @@ -1275,6 +1280,20 @@ int __sock_create(struct net *net, int family, int type, int protocol,
97900 if (err)
97901 return err;
97902
97903 + if(!kern && !gr_search_socket(family, type, protocol)) {
97904 + if (rcu_access_pointer(net_families[family]) == NULL)
97905 + return -EAFNOSUPPORT;
97906 + else
97907 + return -EACCES;
97908 + }
97909 +
97910 + if (!kern && gr_handle_sock_all(family, type, protocol)) {
97911 + if (rcu_access_pointer(net_families[family]) == NULL)
97912 + return -EAFNOSUPPORT;
97913 + else
97914 + return -EACCES;
97915 + }
97916 +
97917 /*
97918 * Allocate the socket and allow the family to set things up. if
97919 * the protocol is 0, the family is instructed to select an appropriate
97920 @@ -1513,6 +1532,14 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97921 if (sock) {
97922 err = move_addr_to_kernel(umyaddr, addrlen, &address);
97923 if (err >= 0) {
97924 + if (gr_handle_sock_server((struct sockaddr *)&address)) {
97925 + err = -EACCES;
97926 + goto error;
97927 + }
97928 + err = gr_search_bind(sock, (struct sockaddr_in *)&address);
97929 + if (err)
97930 + goto error;
97931 +
97932 err = security_socket_bind(sock,
97933 (struct sockaddr *)&address,
97934 addrlen);
97935 @@ -1521,6 +1548,7 @@ SYSCALL_DEFINE3(bind, int, fd, struct sockaddr __user *, umyaddr, int, addrlen)
97936 (struct sockaddr *)
97937 &address, addrlen);
97938 }
97939 +error:
97940 fput_light(sock->file, fput_needed);
97941 }
97942 return err;
97943 @@ -1544,10 +1572,20 @@ SYSCALL_DEFINE2(listen, int, fd, int, backlog)
97944 if ((unsigned int)backlog > somaxconn)
97945 backlog = somaxconn;
97946
97947 + if (gr_handle_sock_server_other(sock->sk)) {
97948 + err = -EPERM;
97949 + goto error;
97950 + }
97951 +
97952 + err = gr_search_listen(sock);
97953 + if (err)
97954 + goto error;
97955 +
97956 err = security_socket_listen(sock, backlog);
97957 if (!err)
97958 err = sock->ops->listen(sock, backlog);
97959
97960 +error:
97961 fput_light(sock->file, fput_needed);
97962 }
97963 return err;
97964 @@ -1591,6 +1629,18 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97965 newsock->type = sock->type;
97966 newsock->ops = sock->ops;
97967
97968 + if (gr_handle_sock_server_other(sock->sk)) {
97969 + err = -EPERM;
97970 + sock_release(newsock);
97971 + goto out_put;
97972 + }
97973 +
97974 + err = gr_search_accept(sock);
97975 + if (err) {
97976 + sock_release(newsock);
97977 + goto out_put;
97978 + }
97979 +
97980 /*
97981 * We don't need try_module_get here, as the listening socket (sock)
97982 * has the protocol module (sock->ops->owner) held.
97983 @@ -1636,6 +1686,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
97984 fd_install(newfd, newfile);
97985 err = newfd;
97986
97987 + gr_attach_curr_ip(newsock->sk);
97988 +
97989 out_put:
97990 fput_light(sock->file, fput_needed);
97991 out:
97992 @@ -1668,6 +1720,7 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
97993 int, addrlen)
97994 {
97995 struct socket *sock;
97996 + struct sockaddr *sck;
97997 struct sockaddr_storage address;
97998 int err, fput_needed;
97999
98000 @@ -1678,6 +1731,17 @@ SYSCALL_DEFINE3(connect, int, fd, struct sockaddr __user *, uservaddr,
98001 if (err < 0)
98002 goto out_put;
98003
98004 + sck = (struct sockaddr *)&address;
98005 +
98006 + if (gr_handle_sock_client(sck)) {
98007 + err = -EACCES;
98008 + goto out_put;
98009 + }
98010 +
98011 + err = gr_search_connect(sock, (struct sockaddr_in *)sck);
98012 + if (err)
98013 + goto out_put;
98014 +
98015 err =
98016 security_socket_connect(sock, (struct sockaddr *)&address, addrlen);
98017 if (err)
98018 @@ -1759,6 +1823,8 @@ SYSCALL_DEFINE3(getpeername, int, fd, struct sockaddr __user *, usockaddr,
98019 * the protocol.
98020 */
98021
98022 +asmlinkage long sys_sendto(int, void *, size_t, unsigned, struct sockaddr *, int);
98023 +
98024 SYSCALL_DEFINE6(sendto, int, fd, void __user *, buff, size_t, len,
98025 unsigned int, flags, struct sockaddr __user *, addr,
98026 int, addr_len)
98027 @@ -1825,7 +1891,7 @@ SYSCALL_DEFINE6(recvfrom, int, fd, void __user *, ubuf, size_t, size,
98028 struct socket *sock;
98029 struct iovec iov;
98030 struct msghdr msg;
98031 - struct sockaddr_storage address;
98032 + struct sockaddr_storage address = { };
98033 int err, err2;
98034 int fput_needed;
98035
98036 @@ -2047,7 +2113,7 @@ static int ___sys_sendmsg(struct socket *sock, struct msghdr __user *msg,
98037 * checking falls down on this.
98038 */
98039 if (copy_from_user(ctl_buf,
98040 - (void __user __force *)msg_sys->msg_control,
98041 + (void __force_user *)msg_sys->msg_control,
98042 ctl_len))
98043 goto out_freectl;
98044 msg_sys->msg_control = ctl_buf;
98045 @@ -2198,7 +2264,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
98046 int err, total_len, len;
98047
98048 /* kernel mode address */
98049 - struct sockaddr_storage addr;
98050 + struct sockaddr_storage addr = { };
98051
98052 /* user mode address pointers */
98053 struct sockaddr __user *uaddr;
98054 @@ -2227,7 +2293,7 @@ static int ___sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
98055 /* Save the user-mode address (verify_iovec will change the
98056 * kernel msghdr to use the kernel address space)
98057 */
98058 - uaddr = (__force void __user *)msg_sys->msg_name;
98059 + uaddr = (void __force_user *)msg_sys->msg_name;
98060 uaddr_len = COMPAT_NAMELEN(msg);
98061 if (MSG_CMSG_COMPAT & flags)
98062 err = verify_compat_iovec(msg_sys, iov, &addr, VERIFY_WRITE);
98063 @@ -2985,7 +3051,7 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
98064 old_fs = get_fs();
98065 set_fs(KERNEL_DS);
98066 err = dev_ioctl(net, cmd,
98067 - (struct ifreq __user __force *) &kifr);
98068 + (struct ifreq __force_user *) &kifr);
98069 set_fs(old_fs);
98070
98071 return err;
98072 @@ -3094,7 +3160,7 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
98073
98074 old_fs = get_fs();
98075 set_fs(KERNEL_DS);
98076 - err = dev_ioctl(net, cmd, (void __user __force *)&ifr);
98077 + err = dev_ioctl(net, cmd, (void __force_user *)&ifr);
98078 set_fs(old_fs);
98079
98080 if (cmd == SIOCGIFMAP && !err) {
98081 @@ -3199,7 +3265,7 @@ static int routing_ioctl(struct net *net, struct socket *sock,
98082 ret |= get_user(rtdev, &(ur4->rt_dev));
98083 if (rtdev) {
98084 ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
98085 - r4.rt_dev = (char __user __force *)devname;
98086 + r4.rt_dev = (char __force_user *)devname;
98087 devname[15] = 0;
98088 } else
98089 r4.rt_dev = NULL;
98090 @@ -3425,8 +3491,8 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
98091 int __user *uoptlen;
98092 int err;
98093
98094 - uoptval = (char __user __force *) optval;
98095 - uoptlen = (int __user __force *) optlen;
98096 + uoptval = (char __force_user *) optval;
98097 + uoptlen = (int __force_user *) optlen;
98098
98099 set_fs(KERNEL_DS);
98100 if (level == SOL_SOCKET)
98101 @@ -3446,7 +3512,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
98102 char __user *uoptval;
98103 int err;
98104
98105 - uoptval = (char __user __force *) optval;
98106 + uoptval = (char __force_user *) optval;
98107
98108 set_fs(KERNEL_DS);
98109 if (level == SOL_SOCKET)
98110 diff --git a/net/sunrpc/auth_gss/svcauth_gss.c b/net/sunrpc/auth_gss/svcauth_gss.c
98111 index 09fb638..2e6a5c5 100644
98112 --- a/net/sunrpc/auth_gss/svcauth_gss.c
98113 +++ b/net/sunrpc/auth_gss/svcauth_gss.c
98114 @@ -1140,7 +1140,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
98115 uint64_t *handle)
98116 {
98117 struct rsc rsci, *rscp = NULL;
98118 - static atomic64_t ctxhctr;
98119 + static atomic64_unchecked_t ctxhctr = ATOMIC64_INIT(0);
98120 long long ctxh;
98121 struct gss_api_mech *gm = NULL;
98122 time_t expiry;
98123 @@ -1151,7 +1151,7 @@ static int gss_proxy_save_rsc(struct cache_detail *cd,
98124 status = -ENOMEM;
98125 /* the handle needs to be just a unique id,
98126 * use a static counter */
98127 - ctxh = atomic64_inc_return(&ctxhctr);
98128 + ctxh = atomic64_inc_return_unchecked(&ctxhctr);
98129
98130 /* make a copy for the caller */
98131 *handle = ctxh;
98132 diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c
98133 index 941d19f..c85ff07 100644
98134 --- a/net/sunrpc/clnt.c
98135 +++ b/net/sunrpc/clnt.c
98136 @@ -1319,7 +1319,9 @@ call_start(struct rpc_task *task)
98137 (RPC_IS_ASYNC(task) ? "async" : "sync"));
98138
98139 /* Increment call count */
98140 - task->tk_msg.rpc_proc->p_count++;
98141 + pax_open_kernel();
98142 + (*(unsigned int *)&task->tk_msg.rpc_proc->p_count)++;
98143 + pax_close_kernel();
98144 clnt->cl_stats->rpccnt++;
98145 task->tk_action = call_reserve;
98146 }
98147 diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c
98148 index ff3cc4b..7612a9e 100644
98149 --- a/net/sunrpc/sched.c
98150 +++ b/net/sunrpc/sched.c
98151 @@ -261,9 +261,9 @@ static int rpc_wait_bit_killable(void *word)
98152 #if defined(RPC_DEBUG) || defined(RPC_TRACEPOINTS)
98153 static void rpc_task_set_debuginfo(struct rpc_task *task)
98154 {
98155 - static atomic_t rpc_pid;
98156 + static atomic_unchecked_t rpc_pid;
98157
98158 - task->tk_pid = atomic_inc_return(&rpc_pid);
98159 + task->tk_pid = atomic_inc_return_unchecked(&rpc_pid);
98160 }
98161 #else
98162 static inline void rpc_task_set_debuginfo(struct rpc_task *task)
98163 diff --git a/net/sunrpc/svc.c b/net/sunrpc/svc.c
98164 index b974571..678ed90 100644
98165 --- a/net/sunrpc/svc.c
98166 +++ b/net/sunrpc/svc.c
98167 @@ -1160,7 +1160,9 @@ svc_process_common(struct svc_rqst *rqstp, struct kvec *argv, struct kvec *resv)
98168 svc_putnl(resv, RPC_SUCCESS);
98169
98170 /* Bump per-procedure stats counter */
98171 - procp->pc_count++;
98172 + pax_open_kernel();
98173 + (*(unsigned int *)&procp->pc_count)++;
98174 + pax_close_kernel();
98175
98176 /* Initialize storage for argp and resp */
98177 memset(rqstp->rq_argp, 0, procp->pc_argsize);
98178 diff --git a/net/sunrpc/svcauth_unix.c b/net/sunrpc/svcauth_unix.c
98179 index 621ca7b..59421dd 100644
98180 --- a/net/sunrpc/svcauth_unix.c
98181 +++ b/net/sunrpc/svcauth_unix.c
98182 @@ -414,7 +414,7 @@ struct unix_gid {
98183 struct group_info *gi;
98184 };
98185
98186 -static int unix_gid_hash(kuid_t uid)
98187 +static int __intentional_overflow(-1) unix_gid_hash(kuid_t uid)
98188 {
98189 return hash_long(from_kuid(&init_user_ns, uid), GID_HASHBITS);
98190 }
98191 @@ -470,7 +470,7 @@ static void unix_gid_request(struct cache_detail *cd,
98192 (*bpp)[-1] = '\n';
98193 }
98194
98195 -static struct unix_gid *unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
98196 +static struct unix_gid * __intentional_overflow(-1) unix_gid_lookup(struct cache_detail *cd, kuid_t uid);
98197
98198 static int unix_gid_parse(struct cache_detail *cd,
98199 char *mesg, int mlen)
98200 diff --git a/net/sunrpc/xprtrdma/svc_rdma.c b/net/sunrpc/xprtrdma/svc_rdma.c
98201 index c1b6270..05089c1 100644
98202 --- a/net/sunrpc/xprtrdma/svc_rdma.c
98203 +++ b/net/sunrpc/xprtrdma/svc_rdma.c
98204 @@ -62,15 +62,15 @@ unsigned int svcrdma_max_req_size = RPCRDMA_MAX_REQ_SIZE;
98205 static unsigned int min_max_inline = 4096;
98206 static unsigned int max_max_inline = 65536;
98207
98208 -atomic_t rdma_stat_recv;
98209 -atomic_t rdma_stat_read;
98210 -atomic_t rdma_stat_write;
98211 -atomic_t rdma_stat_sq_starve;
98212 -atomic_t rdma_stat_rq_starve;
98213 -atomic_t rdma_stat_rq_poll;
98214 -atomic_t rdma_stat_rq_prod;
98215 -atomic_t rdma_stat_sq_poll;
98216 -atomic_t rdma_stat_sq_prod;
98217 +atomic_unchecked_t rdma_stat_recv;
98218 +atomic_unchecked_t rdma_stat_read;
98219 +atomic_unchecked_t rdma_stat_write;
98220 +atomic_unchecked_t rdma_stat_sq_starve;
98221 +atomic_unchecked_t rdma_stat_rq_starve;
98222 +atomic_unchecked_t rdma_stat_rq_poll;
98223 +atomic_unchecked_t rdma_stat_rq_prod;
98224 +atomic_unchecked_t rdma_stat_sq_poll;
98225 +atomic_unchecked_t rdma_stat_sq_prod;
98226
98227 /* Temporary NFS request map and context caches */
98228 struct kmem_cache *svc_rdma_map_cachep;
98229 @@ -110,7 +110,7 @@ static int read_reset_stat(struct ctl_table *table, int write,
98230 len -= *ppos;
98231 if (len > *lenp)
98232 len = *lenp;
98233 - if (len && copy_to_user(buffer, str_buf, len))
98234 + if (len > sizeof str_buf || (len && copy_to_user(buffer, str_buf, len)))
98235 return -EFAULT;
98236 *lenp = len;
98237 *ppos += len;
98238 @@ -151,63 +151,63 @@ static struct ctl_table svcrdma_parm_table[] = {
98239 {
98240 .procname = "rdma_stat_read",
98241 .data = &rdma_stat_read,
98242 - .maxlen = sizeof(atomic_t),
98243 + .maxlen = sizeof(atomic_unchecked_t),
98244 .mode = 0644,
98245 .proc_handler = read_reset_stat,
98246 },
98247 {
98248 .procname = "rdma_stat_recv",
98249 .data = &rdma_stat_recv,
98250 - .maxlen = sizeof(atomic_t),
98251 + .maxlen = sizeof(atomic_unchecked_t),
98252 .mode = 0644,
98253 .proc_handler = read_reset_stat,
98254 },
98255 {
98256 .procname = "rdma_stat_write",
98257 .data = &rdma_stat_write,
98258 - .maxlen = sizeof(atomic_t),
98259 + .maxlen = sizeof(atomic_unchecked_t),
98260 .mode = 0644,
98261 .proc_handler = read_reset_stat,
98262 },
98263 {
98264 .procname = "rdma_stat_sq_starve",
98265 .data = &rdma_stat_sq_starve,
98266 - .maxlen = sizeof(atomic_t),
98267 + .maxlen = sizeof(atomic_unchecked_t),
98268 .mode = 0644,
98269 .proc_handler = read_reset_stat,
98270 },
98271 {
98272 .procname = "rdma_stat_rq_starve",
98273 .data = &rdma_stat_rq_starve,
98274 - .maxlen = sizeof(atomic_t),
98275 + .maxlen = sizeof(atomic_unchecked_t),
98276 .mode = 0644,
98277 .proc_handler = read_reset_stat,
98278 },
98279 {
98280 .procname = "rdma_stat_rq_poll",
98281 .data = &rdma_stat_rq_poll,
98282 - .maxlen = sizeof(atomic_t),
98283 + .maxlen = sizeof(atomic_unchecked_t),
98284 .mode = 0644,
98285 .proc_handler = read_reset_stat,
98286 },
98287 {
98288 .procname = "rdma_stat_rq_prod",
98289 .data = &rdma_stat_rq_prod,
98290 - .maxlen = sizeof(atomic_t),
98291 + .maxlen = sizeof(atomic_unchecked_t),
98292 .mode = 0644,
98293 .proc_handler = read_reset_stat,
98294 },
98295 {
98296 .procname = "rdma_stat_sq_poll",
98297 .data = &rdma_stat_sq_poll,
98298 - .maxlen = sizeof(atomic_t),
98299 + .maxlen = sizeof(atomic_unchecked_t),
98300 .mode = 0644,
98301 .proc_handler = read_reset_stat,
98302 },
98303 {
98304 .procname = "rdma_stat_sq_prod",
98305 .data = &rdma_stat_sq_prod,
98306 - .maxlen = sizeof(atomic_t),
98307 + .maxlen = sizeof(atomic_unchecked_t),
98308 .mode = 0644,
98309 .proc_handler = read_reset_stat,
98310 },
98311 diff --git a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
98312 index 0ce7552..d074459 100644
98313 --- a/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
98314 +++ b/net/sunrpc/xprtrdma/svc_rdma_recvfrom.c
98315 @@ -501,7 +501,7 @@ next_sge:
98316 svc_rdma_put_context(ctxt, 0);
98317 goto out;
98318 }
98319 - atomic_inc(&rdma_stat_read);
98320 + atomic_inc_unchecked(&rdma_stat_read);
98321
98322 if (read_wr.num_sge < chl_map->ch[ch_no].count) {
98323 chl_map->ch[ch_no].count -= read_wr.num_sge;
98324 @@ -611,7 +611,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
98325 dto_q);
98326 list_del_init(&ctxt->dto_q);
98327 } else {
98328 - atomic_inc(&rdma_stat_rq_starve);
98329 + atomic_inc_unchecked(&rdma_stat_rq_starve);
98330 clear_bit(XPT_DATA, &xprt->xpt_flags);
98331 ctxt = NULL;
98332 }
98333 @@ -631,7 +631,7 @@ int svc_rdma_recvfrom(struct svc_rqst *rqstp)
98334 dprintk("svcrdma: processing ctxt=%p on xprt=%p, rqstp=%p, status=%d\n",
98335 ctxt, rdma_xprt, rqstp, ctxt->wc_status);
98336 BUG_ON(ctxt->wc_status != IB_WC_SUCCESS);
98337 - atomic_inc(&rdma_stat_recv);
98338 + atomic_inc_unchecked(&rdma_stat_recv);
98339
98340 /* Build up the XDR from the receive buffers. */
98341 rdma_build_arg_xdr(rqstp, ctxt, ctxt->byte_len);
98342 diff --git a/net/sunrpc/xprtrdma/svc_rdma_sendto.c b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98343 index c1d124d..acfc59e 100644
98344 --- a/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98345 +++ b/net/sunrpc/xprtrdma/svc_rdma_sendto.c
98346 @@ -362,7 +362,7 @@ static int send_write(struct svcxprt_rdma *xprt, struct svc_rqst *rqstp,
98347 write_wr.wr.rdma.remote_addr = to;
98348
98349 /* Post It */
98350 - atomic_inc(&rdma_stat_write);
98351 + atomic_inc_unchecked(&rdma_stat_write);
98352 if (svc_rdma_send(xprt, &write_wr))
98353 goto err;
98354 return 0;
98355 diff --git a/net/sunrpc/xprtrdma/svc_rdma_transport.c b/net/sunrpc/xprtrdma/svc_rdma_transport.c
98356 index 62e4f9b..dd3f2d7 100644
98357 --- a/net/sunrpc/xprtrdma/svc_rdma_transport.c
98358 +++ b/net/sunrpc/xprtrdma/svc_rdma_transport.c
98359 @@ -292,7 +292,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
98360 return;
98361
98362 ib_req_notify_cq(xprt->sc_rq_cq, IB_CQ_NEXT_COMP);
98363 - atomic_inc(&rdma_stat_rq_poll);
98364 + atomic_inc_unchecked(&rdma_stat_rq_poll);
98365
98366 while ((ret = ib_poll_cq(xprt->sc_rq_cq, 1, &wc)) > 0) {
98367 ctxt = (struct svc_rdma_op_ctxt *)(unsigned long)wc.wr_id;
98368 @@ -314,7 +314,7 @@ static void rq_cq_reap(struct svcxprt_rdma *xprt)
98369 }
98370
98371 if (ctxt)
98372 - atomic_inc(&rdma_stat_rq_prod);
98373 + atomic_inc_unchecked(&rdma_stat_rq_prod);
98374
98375 set_bit(XPT_DATA, &xprt->sc_xprt.xpt_flags);
98376 /*
98377 @@ -386,7 +386,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
98378 return;
98379
98380 ib_req_notify_cq(xprt->sc_sq_cq, IB_CQ_NEXT_COMP);
98381 - atomic_inc(&rdma_stat_sq_poll);
98382 + atomic_inc_unchecked(&rdma_stat_sq_poll);
98383 while ((ret = ib_poll_cq(cq, 1, &wc)) > 0) {
98384 if (wc.status != IB_WC_SUCCESS)
98385 /* Close the transport */
98386 @@ -404,7 +404,7 @@ static void sq_cq_reap(struct svcxprt_rdma *xprt)
98387 }
98388
98389 if (ctxt)
98390 - atomic_inc(&rdma_stat_sq_prod);
98391 + atomic_inc_unchecked(&rdma_stat_sq_prod);
98392 }
98393
98394 static void sq_comp_handler(struct ib_cq *cq, void *cq_context)
98395 @@ -1262,7 +1262,7 @@ int svc_rdma_send(struct svcxprt_rdma *xprt, struct ib_send_wr *wr)
98396 spin_lock_bh(&xprt->sc_lock);
98397 if (xprt->sc_sq_depth < atomic_read(&xprt->sc_sq_count) + wr_count) {
98398 spin_unlock_bh(&xprt->sc_lock);
98399 - atomic_inc(&rdma_stat_sq_starve);
98400 + atomic_inc_unchecked(&rdma_stat_sq_starve);
98401
98402 /* See if we can opportunistically reap SQ WR to make room */
98403 sq_cq_reap(xprt);
98404 diff --git a/net/sysctl_net.c b/net/sysctl_net.c
98405 index e7000be..e3b0ba7 100644
98406 --- a/net/sysctl_net.c
98407 +++ b/net/sysctl_net.c
98408 @@ -46,7 +46,7 @@ static int net_ctl_permissions(struct ctl_table_header *head,
98409 kgid_t root_gid = make_kgid(net->user_ns, 0);
98410
98411 /* Allow network administrator to have same access as root. */
98412 - if (ns_capable(net->user_ns, CAP_NET_ADMIN) ||
98413 + if (ns_capable_nolog(net->user_ns, CAP_NET_ADMIN) ||
98414 uid_eq(root_uid, current_euid())) {
98415 int mode = (table->mode >> 6) & 7;
98416 return (mode << 6) | (mode << 3) | mode;
98417 diff --git a/net/tipc/link.c b/net/tipc/link.c
98418 index 0cc3d90..cc42021 100644
98419 --- a/net/tipc/link.c
98420 +++ b/net/tipc/link.c
98421 @@ -1165,7 +1165,7 @@ static int link_send_sections_long(struct tipc_port *sender,
98422 struct tipc_msg fragm_hdr;
98423 struct sk_buff *buf, *buf_chain, *prev;
98424 u32 fragm_crs, fragm_rest, hsz, sect_rest;
98425 - const unchar *sect_crs;
98426 + const unchar __user *sect_crs;
98427 int curr_sect;
98428 u32 fragm_no;
98429 int res = 0;
98430 @@ -1207,7 +1207,7 @@ again:
98431
98432 if (!sect_rest) {
98433 sect_rest = msg_sect[++curr_sect].iov_len;
98434 - sect_crs = (const unchar *)msg_sect[curr_sect].iov_base;
98435 + sect_crs = (const unchar __user *)msg_sect[curr_sect].iov_base;
98436 }
98437
98438 if (sect_rest < fragm_rest)
98439 diff --git a/net/tipc/msg.c b/net/tipc/msg.c
98440 index ced60e2..54eab6c 100644
98441 --- a/net/tipc/msg.c
98442 +++ b/net/tipc/msg.c
98443 @@ -93,7 +93,7 @@ int tipc_msg_build(struct tipc_msg *hdr, struct iovec const *msg_sect,
98444 skb_copy_to_linear_data(*buf, hdr, hsz);
98445 for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) {
98446 skb_copy_to_linear_data_offset(*buf, pos,
98447 - msg_sect[cnt].iov_base,
98448 + (const void __force_kernel *)msg_sect[cnt].iov_base,
98449 msg_sect[cnt].iov_len);
98450 pos += msg_sect[cnt].iov_len;
98451 }
98452 diff --git a/net/tipc/subscr.c b/net/tipc/subscr.c
98453 index d38bb45..4fd6ac6 100644
98454 --- a/net/tipc/subscr.c
98455 +++ b/net/tipc/subscr.c
98456 @@ -98,7 +98,7 @@ static void subscr_send_event(struct tipc_subscription *sub, u32 found_lower,
98457 struct kvec msg_sect;
98458 int ret;
98459
98460 - msg_sect.iov_base = (void *)&sub->evt;
98461 + msg_sect.iov_base = (void __force_user *)&sub->evt;
98462 msg_sect.iov_len = sizeof(struct tipc_event);
98463
98464 sub->evt.event = htohl(event, sub->swap);
98465 diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
98466 index 01625cc..d486b64 100644
98467 --- a/net/unix/af_unix.c
98468 +++ b/net/unix/af_unix.c
98469 @@ -784,6 +784,12 @@ static struct sock *unix_find_other(struct net *net,
98470 err = -ECONNREFUSED;
98471 if (!S_ISSOCK(inode->i_mode))
98472 goto put_fail;
98473 +
98474 + if (!gr_acl_handle_unix(path.dentry, path.mnt)) {
98475 + err = -EACCES;
98476 + goto put_fail;
98477 + }
98478 +
98479 u = unix_find_socket_byinode(inode);
98480 if (!u)
98481 goto put_fail;
98482 @@ -804,6 +810,13 @@ static struct sock *unix_find_other(struct net *net,
98483 if (u) {
98484 struct dentry *dentry;
98485 dentry = unix_sk(u)->path.dentry;
98486 +
98487 + if (!gr_handle_chroot_unix(pid_vnr(u->sk_peer_pid))) {
98488 + err = -EPERM;
98489 + sock_put(u);
98490 + goto fail;
98491 + }
98492 +
98493 if (dentry)
98494 touch_atime(&unix_sk(u)->path);
98495 } else
98496 @@ -837,12 +850,18 @@ static int unix_mknod(const char *sun_path, umode_t mode, struct path *res)
98497 */
98498 err = security_path_mknod(&path, dentry, mode, 0);
98499 if (!err) {
98500 + if (!gr_acl_handle_mknod(dentry, path.dentry, path.mnt, mode)) {
98501 + err = -EACCES;
98502 + goto out;
98503 + }
98504 err = vfs_mknod(path.dentry->d_inode, dentry, mode, 0);
98505 if (!err) {
98506 res->mnt = mntget(path.mnt);
98507 res->dentry = dget(dentry);
98508 + gr_handle_create(dentry, path.mnt);
98509 }
98510 }
98511 +out:
98512 done_path_create(&path, dentry);
98513 return err;
98514 }
98515 @@ -2328,9 +2347,13 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98516 seq_puts(seq, "Num RefCount Protocol Flags Type St "
98517 "Inode Path\n");
98518 else {
98519 - struct sock *s = v;
98520 + struct sock *s = v, *peer;
98521 struct unix_sock *u = unix_sk(s);
98522 unix_state_lock(s);
98523 + peer = unix_peer(s);
98524 + unix_state_unlock(s);
98525 +
98526 + unix_state_double_lock(s, peer);
98527
98528 seq_printf(seq, "%pK: %08X %08X %08X %04X %02X %5lu",
98529 s,
98530 @@ -2357,8 +2380,10 @@ static int unix_seq_show(struct seq_file *seq, void *v)
98531 }
98532 for ( ; i < len; i++)
98533 seq_putc(seq, u->addr->name->sun_path[i]);
98534 - }
98535 - unix_state_unlock(s);
98536 + } else if (peer)
98537 + seq_printf(seq, " P%lu", sock_i_ino(peer));
98538 +
98539 + unix_state_double_unlock(s, peer);
98540 seq_putc(seq, '\n');
98541 }
98542
98543 diff --git a/net/unix/sysctl_net_unix.c b/net/unix/sysctl_net_unix.c
98544 index b3d5150..ff3a837 100644
98545 --- a/net/unix/sysctl_net_unix.c
98546 +++ b/net/unix/sysctl_net_unix.c
98547 @@ -28,7 +28,7 @@ static struct ctl_table unix_table[] = {
98548
98549 int __net_init unix_sysctl_register(struct net *net)
98550 {
98551 - struct ctl_table *table;
98552 + ctl_table_no_const *table;
98553
98554 table = kmemdup(unix_table, sizeof(unix_table), GFP_KERNEL);
98555 if (table == NULL)
98556 diff --git a/net/wireless/wext-core.c b/net/wireless/wext-core.c
98557 index c8717c1..08539f5 100644
98558 --- a/net/wireless/wext-core.c
98559 +++ b/net/wireless/wext-core.c
98560 @@ -748,8 +748,7 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98561 */
98562
98563 /* Support for very large requests */
98564 - if ((descr->flags & IW_DESCR_FLAG_NOMAX) &&
98565 - (user_length > descr->max_tokens)) {
98566 + if (user_length > descr->max_tokens) {
98567 /* Allow userspace to GET more than max so
98568 * we can support any size GET requests.
98569 * There is still a limit : -ENOMEM.
98570 @@ -788,22 +787,6 @@ static int ioctl_standard_iw_point(struct iw_point *iwp, unsigned int cmd,
98571 }
98572 }
98573
98574 - if (IW_IS_GET(cmd) && !(descr->flags & IW_DESCR_FLAG_NOMAX)) {
98575 - /*
98576 - * If this is a GET, but not NOMAX, it means that the extra
98577 - * data is not bounded by userspace, but by max_tokens. Thus
98578 - * set the length to max_tokens. This matches the extra data
98579 - * allocation.
98580 - * The driver should fill it with the number of tokens it
98581 - * provided, and it may check iwp->length rather than having
98582 - * knowledge of max_tokens. If the driver doesn't change the
98583 - * iwp->length, this ioctl just copies back max_token tokens
98584 - * filled with zeroes. Hopefully the driver isn't claiming
98585 - * them to be valid data.
98586 - */
98587 - iwp->length = descr->max_tokens;
98588 - }
98589 -
98590 err = handler(dev, info, (union iwreq_data *) iwp, extra);
98591
98592 iwp->length += essid_compat;
98593 diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
98594 index 76e1873..4a12664 100644
98595 --- a/net/xfrm/xfrm_policy.c
98596 +++ b/net/xfrm/xfrm_policy.c
98597 @@ -332,7 +332,7 @@ static void xfrm_policy_kill(struct xfrm_policy *policy)
98598 {
98599 policy->walk.dead = 1;
98600
98601 - atomic_inc(&policy->genid);
98602 + atomic_inc_unchecked(&policy->genid);
98603
98604 if (del_timer(&policy->polq.hold_timer))
98605 xfrm_pol_put(policy);
98606 @@ -660,7 +660,7 @@ int xfrm_policy_insert(int dir, struct xfrm_policy *policy, int excl)
98607 hlist_add_head(&policy->bydst, chain);
98608 xfrm_pol_hold(policy);
98609 net->xfrm.policy_count[dir]++;
98610 - atomic_inc(&flow_cache_genid);
98611 + atomic_inc_unchecked(&flow_cache_genid);
98612
98613 /* After previous checking, family can either be AF_INET or AF_INET6 */
98614 if (policy->family == AF_INET)
98615 @@ -1636,7 +1636,7 @@ free_dst:
98616 goto out;
98617 }
98618
98619 -static int inline
98620 +static inline int
98621 xfrm_dst_alloc_copy(void **target, const void *src, int size)
98622 {
98623 if (!*target) {
98624 @@ -1648,7 +1648,7 @@ xfrm_dst_alloc_copy(void **target, const void *src, int size)
98625 return 0;
98626 }
98627
98628 -static int inline
98629 +static inline int
98630 xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98631 {
98632 #ifdef CONFIG_XFRM_SUB_POLICY
98633 @@ -1660,7 +1660,7 @@ xfrm_dst_update_parent(struct dst_entry *dst, const struct xfrm_selector *sel)
98634 #endif
98635 }
98636
98637 -static int inline
98638 +static inline int
98639 xfrm_dst_update_origin(struct dst_entry *dst, const struct flowi *fl)
98640 {
98641 #ifdef CONFIG_XFRM_SUB_POLICY
98642 @@ -1754,7 +1754,7 @@ xfrm_resolve_and_create_bundle(struct xfrm_policy **pols, int num_pols,
98643
98644 xdst->num_pols = num_pols;
98645 memcpy(xdst->pols, pols, sizeof(struct xfrm_policy*) * num_pols);
98646 - xdst->policy_genid = atomic_read(&pols[0]->genid);
98647 + xdst->policy_genid = atomic_read_unchecked(&pols[0]->genid);
98648
98649 return xdst;
98650 }
98651 @@ -2575,11 +2575,12 @@ void xfrm_garbage_collect(struct net *net)
98652 }
98653 EXPORT_SYMBOL(xfrm_garbage_collect);
98654
98655 -static void xfrm_garbage_collect_deferred(struct net *net)
98656 +void xfrm_garbage_collect_deferred(struct net *net)
98657 {
98658 flow_cache_flush_deferred();
98659 __xfrm_garbage_collect(net);
98660 }
98661 +EXPORT_SYMBOL(xfrm_garbage_collect_deferred);
98662
98663 static void xfrm_init_pmtu(struct dst_entry *dst)
98664 {
98665 @@ -2629,7 +2630,7 @@ static int xfrm_bundle_ok(struct xfrm_dst *first)
98666 if (xdst->xfrm_genid != dst->xfrm->genid)
98667 return 0;
98668 if (xdst->num_pols > 0 &&
98669 - xdst->policy_genid != atomic_read(&xdst->pols[0]->genid))
98670 + xdst->policy_genid != atomic_read_unchecked(&xdst->pols[0]->genid))
98671 return 0;
98672
98673 mtu = dst_mtu(dst->child);
98674 @@ -2717,8 +2718,6 @@ int xfrm_policy_register_afinfo(struct xfrm_policy_afinfo *afinfo)
98675 dst_ops->link_failure = xfrm_link_failure;
98676 if (likely(dst_ops->neigh_lookup == NULL))
98677 dst_ops->neigh_lookup = xfrm_neigh_lookup;
98678 - if (likely(afinfo->garbage_collect == NULL))
98679 - afinfo->garbage_collect = xfrm_garbage_collect_deferred;
98680 rcu_assign_pointer(xfrm_policy_afinfo[afinfo->family], afinfo);
98681 }
98682 spin_unlock(&xfrm_policy_afinfo_lock);
98683 @@ -2772,7 +2771,6 @@ int xfrm_policy_unregister_afinfo(struct xfrm_policy_afinfo *afinfo)
98684 dst_ops->check = NULL;
98685 dst_ops->negative_advice = NULL;
98686 dst_ops->link_failure = NULL;
98687 - afinfo->garbage_collect = NULL;
98688 }
98689 return err;
98690 }
98691 @@ -3155,7 +3153,7 @@ static int xfrm_policy_migrate(struct xfrm_policy *pol,
98692 sizeof(pol->xfrm_vec[i].saddr));
98693 pol->xfrm_vec[i].encap_family = mp->new_family;
98694 /* flush bundles */
98695 - atomic_inc(&pol->genid);
98696 + atomic_inc_unchecked(&pol->genid);
98697 }
98698 }
98699
98700 diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
98701 index b9c3f9e..4767526 100644
98702 --- a/net/xfrm/xfrm_state.c
98703 +++ b/net/xfrm/xfrm_state.c
98704 @@ -174,12 +174,14 @@ int xfrm_register_type(const struct xfrm_type *type, unsigned short family)
98705
98706 if (unlikely(afinfo == NULL))
98707 return -EAFNOSUPPORT;
98708 - typemap = afinfo->type_map;
98709 + typemap = (const struct xfrm_type **)afinfo->type_map;
98710 spin_lock_bh(&xfrm_type_lock);
98711
98712 - if (likely(typemap[type->proto] == NULL))
98713 + if (likely(typemap[type->proto] == NULL)) {
98714 + pax_open_kernel();
98715 typemap[type->proto] = type;
98716 - else
98717 + pax_close_kernel();
98718 + } else
98719 err = -EEXIST;
98720 spin_unlock_bh(&xfrm_type_lock);
98721 xfrm_state_put_afinfo(afinfo);
98722 @@ -195,13 +197,16 @@ int xfrm_unregister_type(const struct xfrm_type *type, unsigned short family)
98723
98724 if (unlikely(afinfo == NULL))
98725 return -EAFNOSUPPORT;
98726 - typemap = afinfo->type_map;
98727 + typemap = (const struct xfrm_type **)afinfo->type_map;
98728 spin_lock_bh(&xfrm_type_lock);
98729
98730 if (unlikely(typemap[type->proto] != type))
98731 err = -ENOENT;
98732 - else
98733 + else {
98734 + pax_open_kernel();
98735 typemap[type->proto] = NULL;
98736 + pax_close_kernel();
98737 + }
98738 spin_unlock_bh(&xfrm_type_lock);
98739 xfrm_state_put_afinfo(afinfo);
98740 return err;
98741 @@ -211,7 +216,6 @@ EXPORT_SYMBOL(xfrm_unregister_type);
98742 static const struct xfrm_type *xfrm_get_type(u8 proto, unsigned short family)
98743 {
98744 struct xfrm_state_afinfo *afinfo;
98745 - const struct xfrm_type **typemap;
98746 const struct xfrm_type *type;
98747 int modload_attempted = 0;
98748
98749 @@ -219,9 +223,8 @@ retry:
98750 afinfo = xfrm_state_get_afinfo(family);
98751 if (unlikely(afinfo == NULL))
98752 return NULL;
98753 - typemap = afinfo->type_map;
98754
98755 - type = typemap[proto];
98756 + type = afinfo->type_map[proto];
98757 if (unlikely(type && !try_module_get(type->owner)))
98758 type = NULL;
98759 if (!type && !modload_attempted) {
98760 @@ -255,7 +258,7 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98761 return -EAFNOSUPPORT;
98762
98763 err = -EEXIST;
98764 - modemap = afinfo->mode_map;
98765 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98766 spin_lock_bh(&xfrm_mode_lock);
98767 if (modemap[mode->encap])
98768 goto out;
98769 @@ -264,8 +267,10 @@ int xfrm_register_mode(struct xfrm_mode *mode, int family)
98770 if (!try_module_get(afinfo->owner))
98771 goto out;
98772
98773 - mode->afinfo = afinfo;
98774 + pax_open_kernel();
98775 + *(const void **)&mode->afinfo = afinfo;
98776 modemap[mode->encap] = mode;
98777 + pax_close_kernel();
98778 err = 0;
98779
98780 out:
98781 @@ -289,10 +294,12 @@ int xfrm_unregister_mode(struct xfrm_mode *mode, int family)
98782 return -EAFNOSUPPORT;
98783
98784 err = -ENOENT;
98785 - modemap = afinfo->mode_map;
98786 + modemap = (struct xfrm_mode **)afinfo->mode_map;
98787 spin_lock_bh(&xfrm_mode_lock);
98788 if (likely(modemap[mode->encap] == mode)) {
98789 + pax_open_kernel();
98790 modemap[mode->encap] = NULL;
98791 + pax_close_kernel();
98792 module_put(mode->afinfo->owner);
98793 err = 0;
98794 }
98795 @@ -1486,10 +1493,10 @@ EXPORT_SYMBOL(xfrm_find_acq_byseq);
98796 u32 xfrm_get_acqseq(void)
98797 {
98798 u32 res;
98799 - static atomic_t acqseq;
98800 + static atomic_unchecked_t acqseq;
98801
98802 do {
98803 - res = atomic_inc_return(&acqseq);
98804 + res = atomic_inc_return_unchecked(&acqseq);
98805 } while (!res);
98806
98807 return res;
98808 diff --git a/net/xfrm/xfrm_sysctl.c b/net/xfrm/xfrm_sysctl.c
98809 index 05a6e3d..6716ec9 100644
98810 --- a/net/xfrm/xfrm_sysctl.c
98811 +++ b/net/xfrm/xfrm_sysctl.c
98812 @@ -42,7 +42,7 @@ static struct ctl_table xfrm_table[] = {
98813
98814 int __net_init xfrm_sysctl_init(struct net *net)
98815 {
98816 - struct ctl_table *table;
98817 + ctl_table_no_const *table;
98818
98819 __xfrm_sysctl_init(net);
98820
98821 diff --git a/scripts/Makefile.build b/scripts/Makefile.build
98822 index d5d859c..781cbcb 100644
98823 --- a/scripts/Makefile.build
98824 +++ b/scripts/Makefile.build
98825 @@ -111,7 +111,7 @@ endif
98826 endif
98827
98828 # Do not include host rules unless needed
98829 -ifneq ($(hostprogs-y)$(hostprogs-m),)
98830 +ifneq ($(hostprogs-y)$(hostprogs-m)$(hostlibs-y)$(hostlibs-m)$(hostcxxlibs-y)$(hostcxxlibs-m),)
98831 include scripts/Makefile.host
98832 endif
98833
98834 diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
98835 index 686cb0d..9d653bf 100644
98836 --- a/scripts/Makefile.clean
98837 +++ b/scripts/Makefile.clean
98838 @@ -43,7 +43,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
98839 __clean-files := $(extra-y) $(always) \
98840 $(targets) $(clean-files) \
98841 $(host-progs) \
98842 - $(hostprogs-y) $(hostprogs-m) $(hostprogs-)
98843 + $(hostprogs-y) $(hostprogs-m) $(hostprogs-) \
98844 + $(hostlibs-y) $(hostlibs-m) $(hostlibs-)
98845
98846 __clean-files := $(filter-out $(no-clean-files), $(__clean-files))
98847
98848 diff --git a/scripts/Makefile.host b/scripts/Makefile.host
98849 index 1ac414f..38575f7 100644
98850 --- a/scripts/Makefile.host
98851 +++ b/scripts/Makefile.host
98852 @@ -31,6 +31,8 @@
98853 # Note: Shared libraries consisting of C++ files are not supported
98854
98855 __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
98856 +__hostlibs := $(sort $(hostlibs-y) $(hostlibs-m))
98857 +__hostcxxlibs := $(sort $(hostcxxlibs-y) $(hostcxxlibs-m))
98858
98859 # C code
98860 # Executables compiled from a single .c file
98861 @@ -54,11 +56,15 @@ host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
98862 # Shared libaries (only .c supported)
98863 # Shared libraries (.so) - all .so files referenced in "xxx-objs"
98864 host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
98865 +host-cshlib += $(sort $(filter %.so, $(__hostlibs)))
98866 +host-cxxshlib := $(sort $(filter %.so, $(__hostcxxlibs)))
98867 # Remove .so files from "xxx-objs"
98868 host-cobjs := $(filter-out %.so,$(host-cobjs))
98869 +host-cxxobjs := $(filter-out %.so,$(host-cxxobjs))
98870
98871 -#Object (.o) files used by the shared libaries
98872 +# Object (.o) files used by the shared libaries
98873 host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
98874 +host-cxxshobjs := $(sort $(foreach m,$(host-cxxshlib),$($(m:.so=-objs))))
98875
98876 # output directory for programs/.o files
98877 # hostprogs-y := tools/build may have been specified. Retrieve directory
98878 @@ -82,7 +88,9 @@ host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
98879 host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
98880 host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
98881 host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
98882 +host-cxxshlib := $(addprefix $(obj)/,$(host-cxxshlib))
98883 host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
98884 +host-cxxshobjs := $(addprefix $(obj)/,$(host-cxxshobjs))
98885 host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
98886
98887 obj-dirs += $(host-objdirs)
98888 @@ -156,6 +164,13 @@ quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
98889 $(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
98890 $(call if_changed_dep,host-cshobjs)
98891
98892 +# Compile .c file, create position independent .o file
98893 +# host-cxxshobjs -> .o
98894 +quiet_cmd_host-cxxshobjs = HOSTCXX -fPIC $@
98895 + cmd_host-cxxshobjs = $(HOSTCXX) $(hostcxx_flags) -fPIC -c -o $@ $<
98896 +$(host-cxxshobjs): $(obj)/%.o: $(src)/%.c FORCE
98897 + $(call if_changed_dep,host-cxxshobjs)
98898 +
98899 # Link a shared library, based on position independent .o files
98900 # *.o -> .so shared library (host-cshlib)
98901 quiet_cmd_host-cshlib = HOSTLLD -shared $@
98902 @@ -165,6 +180,15 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@
98903 $(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
98904 $(call if_changed,host-cshlib)
98905
98906 +# Link a shared library, based on position independent .o files
98907 +# *.o -> .so shared library (host-cxxshlib)
98908 +quiet_cmd_host-cxxshlib = HOSTLLD -shared $@
98909 + cmd_host-cxxshlib = $(HOSTCXX) $(HOSTLDFLAGS) -shared -o $@ \
98910 + $(addprefix $(obj)/,$($(@F:.so=-objs))) \
98911 + $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
98912 +$(host-cxxshlib): $(obj)/%: $(host-cxxshobjs) FORCE
98913 + $(call if_changed,host-cxxshlib)
98914 +
98915 targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
98916 - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
98917 + $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) $(host-cxxshlib) $(host-cxxshobjs)
98918
98919 diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
98920 index 078fe1d..fbdb363 100644
98921 --- a/scripts/basic/fixdep.c
98922 +++ b/scripts/basic/fixdep.c
98923 @@ -161,7 +161,7 @@ static unsigned int strhash(const char *str, unsigned int sz)
98924 /*
98925 * Lookup a value in the configuration string.
98926 */
98927 -static int is_defined_config(const char *name, int len, unsigned int hash)
98928 +static int is_defined_config(const char *name, unsigned int len, unsigned int hash)
98929 {
98930 struct item *aux;
98931
98932 @@ -211,10 +211,10 @@ static void clear_config(void)
98933 /*
98934 * Record the use of a CONFIG_* word.
98935 */
98936 -static void use_config(const char *m, int slen)
98937 +static void use_config(const char *m, unsigned int slen)
98938 {
98939 unsigned int hash = strhash(m, slen);
98940 - int c, i;
98941 + unsigned int c, i;
98942
98943 if (is_defined_config(m, slen, hash))
98944 return;
98945 @@ -235,9 +235,9 @@ static void use_config(const char *m, int slen)
98946
98947 static void parse_config_file(const char *map, size_t len)
98948 {
98949 - const int *end = (const int *) (map + len);
98950 + const unsigned int *end = (const unsigned int *) (map + len);
98951 /* start at +1, so that p can never be < map */
98952 - const int *m = (const int *) map + 1;
98953 + const unsigned int *m = (const unsigned int *) map + 1;
98954 const char *p, *q;
98955
98956 for (; m < end; m++) {
98957 @@ -435,7 +435,7 @@ static void print_deps(void)
98958 static void traps(void)
98959 {
98960 static char test[] __attribute__((aligned(sizeof(int)))) = "CONF";
98961 - int *p = (int *)test;
98962 + unsigned int *p = (unsigned int *)test;
98963
98964 if (*p != INT_CONF) {
98965 fprintf(stderr, "fixdep: sizeof(int) != 4 or wrong endianness? %#x\n",
98966 diff --git a/scripts/gcc-plugin.sh b/scripts/gcc-plugin.sh
98967 new file mode 100644
98968 index 0000000..5e0222d
98969 --- /dev/null
98970 +++ b/scripts/gcc-plugin.sh
98971 @@ -0,0 +1,17 @@
98972 +#!/bin/bash
98973 +plugincc=`$1 -E -shared - -o /dev/null -I\`$3 -print-file-name=plugin\`/include 2>&1 <<EOF
98974 +#include "gcc-plugin.h"
98975 +#include "tree.h"
98976 +#include "tm.h"
98977 +#include "rtl.h"
98978 +#ifdef ENABLE_BUILD_WITH_CXX
98979 +#warning $2
98980 +#else
98981 +#warning $1
98982 +#endif
98983 +EOF`
98984 +if [ $? -eq 0 ]
98985 +then
98986 + [[ "$plugincc" =~ "$1" ]] && echo "$1"
98987 + [[ "$plugincc" =~ "$2" ]] && echo "$2"
98988 +fi
98989 diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
98990 index 5de5660..d3deb89 100644
98991 --- a/scripts/headers_install.sh
98992 +++ b/scripts/headers_install.sh
98993 @@ -32,6 +32,7 @@ do
98994 FILE="$(basename "$i")"
98995 sed -r \
98996 -e 's/([ \t(])(__user|__force|__iomem)[ \t]/\1/g' \
98997 + -e 's/__intentional_overflow\([- \t,0-9]*\)//g' \
98998 -e 's/__attribute_const__([ \t]|$)/\1/g' \
98999 -e 's@^#include <linux/compiler.h>@@' \
99000 -e 's/(^|[^a-zA-Z0-9])__packed([^a-zA-Z0-9_]|$)/\1__attribute__((packed))\2/g' \
99001 diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
99002 index 2dcb377..a82c500 100644
99003 --- a/scripts/link-vmlinux.sh
99004 +++ b/scripts/link-vmlinux.sh
99005 @@ -162,7 +162,7 @@ else
99006 fi;
99007
99008 # final build of init/
99009 -${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init
99010 +${MAKE} -f "${srctree}/scripts/Makefile.build" obj=init GCC_PLUGINS_CFLAGS="${GCC_PLUGINS_CFLAGS}" GCC_PLUGINS_AFLAGS="${GCC_PLUGINS_AFLAGS}"
99011
99012 kallsymso=""
99013 kallsyms_vmlinux=""
99014 diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
99015 index 2370863..212fbca 100644
99016 --- a/scripts/mod/file2alias.c
99017 +++ b/scripts/mod/file2alias.c
99018 @@ -142,7 +142,7 @@ static void device_id_check(const char *modname, const char *device_id,
99019 unsigned long size, unsigned long id_size,
99020 void *symval)
99021 {
99022 - int i;
99023 + unsigned int i;
99024
99025 if (size % id_size || size < id_size) {
99026 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
99027 @@ -170,7 +170,7 @@ static void device_id_check(const char *modname, const char *device_id,
99028 /* USB is special because the bcdDevice can be matched against a numeric range */
99029 /* Looks like "usb:vNpNdNdcNdscNdpNicNiscNipNinN" */
99030 static void do_usb_entry(void *symval,
99031 - unsigned int bcdDevice_initial, int bcdDevice_initial_digits,
99032 + unsigned int bcdDevice_initial, unsigned int bcdDevice_initial_digits,
99033 unsigned char range_lo, unsigned char range_hi,
99034 unsigned char max, struct module *mod)
99035 {
99036 @@ -280,7 +280,7 @@ static void do_usb_entry_multi(void *symval, struct module *mod)
99037 {
99038 unsigned int devlo, devhi;
99039 unsigned char chi, clo, max;
99040 - int ndigits;
99041 + unsigned int ndigits;
99042
99043 DEF_FIELD(symval, usb_device_id, match_flags);
99044 DEF_FIELD(symval, usb_device_id, idVendor);
99045 @@ -533,7 +533,7 @@ static void do_pnp_device_entry(void *symval, unsigned long size,
99046 for (i = 0; i < count; i++) {
99047 DEF_FIELD_ADDR(symval + i*id_size, pnp_device_id, id);
99048 char acpi_id[sizeof(*id)];
99049 - int j;
99050 + unsigned int j;
99051
99052 buf_printf(&mod->dev_table_buf,
99053 "MODULE_ALIAS(\"pnp:d%s*\");\n", *id);
99054 @@ -562,7 +562,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
99055
99056 for (j = 0; j < PNP_MAX_DEVICES; j++) {
99057 const char *id = (char *)(*devs)[j].id;
99058 - int i2, j2;
99059 + unsigned int i2, j2;
99060 int dup = 0;
99061
99062 if (!id[0])
99063 @@ -588,7 +588,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size,
99064 /* add an individual alias for every device entry */
99065 if (!dup) {
99066 char acpi_id[PNP_ID_LEN];
99067 - int k;
99068 + unsigned int k;
99069
99070 buf_printf(&mod->dev_table_buf,
99071 "MODULE_ALIAS(\"pnp:d%s*\");\n", id);
99072 @@ -940,7 +940,7 @@ static void dmi_ascii_filter(char *d, const char *s)
99073 static int do_dmi_entry(const char *filename, void *symval,
99074 char *alias)
99075 {
99076 - int i, j;
99077 + unsigned int i, j;
99078 DEF_FIELD_ADDR(symval, dmi_system_id, matches);
99079 sprintf(alias, "dmi*");
99080
99081 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
99082 index 8247979..815ec76 100644
99083 --- a/scripts/mod/modpost.c
99084 +++ b/scripts/mod/modpost.c
99085 @@ -931,6 +931,7 @@ enum mismatch {
99086 ANY_INIT_TO_ANY_EXIT,
99087 ANY_EXIT_TO_ANY_INIT,
99088 EXPORT_TO_INIT_EXIT,
99089 + DATA_TO_TEXT
99090 };
99091
99092 struct sectioncheck {
99093 @@ -1017,6 +1018,12 @@ const struct sectioncheck sectioncheck[] = {
99094 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
99095 .mismatch = EXPORT_TO_INIT_EXIT,
99096 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
99097 +},
99098 +/* Do not reference code from writable data */
99099 +{
99100 + .fromsec = { DATA_SECTIONS, NULL },
99101 + .tosec = { TEXT_SECTIONS, NULL },
99102 + .mismatch = DATA_TO_TEXT
99103 }
99104 };
99105
99106 @@ -1137,10 +1144,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
99107 continue;
99108 if (ELF_ST_TYPE(sym->st_info) == STT_SECTION)
99109 continue;
99110 - if (sym->st_value == addr)
99111 - return sym;
99112 /* Find a symbol nearby - addr are maybe negative */
99113 d = sym->st_value - addr;
99114 + if (d == 0)
99115 + return sym;
99116 if (d < 0)
99117 d = addr - sym->st_value;
99118 if (d < distance) {
99119 @@ -1418,6 +1425,14 @@ static void report_sec_mismatch(const char *modname,
99120 tosym, prl_to, prl_to, tosym);
99121 free(prl_to);
99122 break;
99123 + case DATA_TO_TEXT:
99124 +#if 0
99125 + fprintf(stderr,
99126 + "The %s %s:%s references\n"
99127 + "the %s %s:%s%s\n",
99128 + from, fromsec, fromsym, to, tosec, tosym, to_p);
99129 +#endif
99130 + break;
99131 }
99132 fprintf(stderr, "\n");
99133 }
99134 @@ -1652,7 +1667,7 @@ static void section_rel(const char *modname, struct elf_info *elf,
99135 static void check_sec_ref(struct module *mod, const char *modname,
99136 struct elf_info *elf)
99137 {
99138 - int i;
99139 + unsigned int i;
99140 Elf_Shdr *sechdrs = elf->sechdrs;
99141
99142 /* Walk through all sections */
99143 @@ -1771,7 +1786,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
99144 va_end(ap);
99145 }
99146
99147 -void buf_write(struct buffer *buf, const char *s, int len)
99148 +void buf_write(struct buffer *buf, const char *s, unsigned int len)
99149 {
99150 if (buf->size - buf->pos < len) {
99151 buf->size += len + SZ;
99152 @@ -1990,7 +2005,7 @@ static void write_if_changed(struct buffer *b, const char *fname)
99153 if (fstat(fileno(file), &st) < 0)
99154 goto close_write;
99155
99156 - if (st.st_size != b->pos)
99157 + if (st.st_size != (off_t)b->pos)
99158 goto close_write;
99159
99160 tmp = NOFAIL(malloc(b->pos));
99161 diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
99162 index 51207e4..f7d603d 100644
99163 --- a/scripts/mod/modpost.h
99164 +++ b/scripts/mod/modpost.h
99165 @@ -92,15 +92,15 @@ void *do_nofail(void *ptr, const char *expr);
99166
99167 struct buffer {
99168 char *p;
99169 - int pos;
99170 - int size;
99171 + unsigned int pos;
99172 + unsigned int size;
99173 };
99174
99175 void __attribute__((format(printf, 2, 3)))
99176 buf_printf(struct buffer *buf, const char *fmt, ...);
99177
99178 void
99179 -buf_write(struct buffer *buf, const char *s, int len);
99180 +buf_write(struct buffer *buf, const char *s, unsigned int len);
99181
99182 struct module {
99183 struct module *next;
99184 diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
99185 index 9dfcd6d..099068e 100644
99186 --- a/scripts/mod/sumversion.c
99187 +++ b/scripts/mod/sumversion.c
99188 @@ -470,7 +470,7 @@ static void write_version(const char *filename, const char *sum,
99189 goto out;
99190 }
99191
99192 - if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
99193 + if (write(fd, sum, strlen(sum)+1) != (ssize_t)strlen(sum)+1) {
99194 warn("writing sum in %s failed: %s\n",
99195 filename, strerror(errno));
99196 goto out;
99197 diff --git a/scripts/module-common.lds b/scripts/module-common.lds
99198 index 0865b3e..7235dd4 100644
99199 --- a/scripts/module-common.lds
99200 +++ b/scripts/module-common.lds
99201 @@ -6,6 +6,10 @@
99202 SECTIONS {
99203 /DISCARD/ : { *(.discard) }
99204
99205 + .rodata : {
99206 + *(.rodata) *(.rodata.*)
99207 + *(.data..read_only)
99208 + }
99209 __ksymtab : { *(SORT(___ksymtab+*)) }
99210 __ksymtab_gpl : { *(SORT(___ksymtab_gpl+*)) }
99211 __ksymtab_unused : { *(SORT(___ksymtab_unused+*)) }
99212 diff --git a/scripts/package/builddeb b/scripts/package/builddeb
99213 index 90e521f..e9eaf8f 100644
99214 --- a/scripts/package/builddeb
99215 +++ b/scripts/package/builddeb
99216 @@ -281,6 +281,7 @@ fi
99217 (cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl > "$objtree/debian/hdrsrcfiles")
99218 (cd $srctree; find arch/$SRCARCH/include include scripts -type f >> "$objtree/debian/hdrsrcfiles")
99219 (cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f >> "$objtree/debian/hdrobjfiles")
99220 +(cd $objtree; find tools/gcc -name \*.so >> "$objtree/debian/hdrobjfiles")
99221 destdir=$kernel_headers_dir/usr/src/linux-headers-$version
99222 mkdir -p "$destdir"
99223 (cd $srctree; tar -c -f - -T "$objtree/debian/hdrsrcfiles") | (cd $destdir; tar -xf -)
99224 diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c
99225 index 68bb4ef..2f419e1 100644
99226 --- a/scripts/pnmtologo.c
99227 +++ b/scripts/pnmtologo.c
99228 @@ -244,14 +244,14 @@ static void write_header(void)
99229 fprintf(out, " * Linux logo %s\n", logoname);
99230 fputs(" */\n\n", out);
99231 fputs("#include <linux/linux_logo.h>\n\n", out);
99232 - fprintf(out, "static unsigned char %s_data[] __initdata = {\n",
99233 + fprintf(out, "static unsigned char %s_data[] = {\n",
99234 logoname);
99235 }
99236
99237 static void write_footer(void)
99238 {
99239 fputs("\n};\n\n", out);
99240 - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname);
99241 + fprintf(out, "const struct linux_logo %s = {\n", logoname);
99242 fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]);
99243 fprintf(out, "\t.width\t\t= %d,\n", logo_width);
99244 fprintf(out, "\t.height\t\t= %d,\n", logo_height);
99245 @@ -381,7 +381,7 @@ static void write_logo_clut224(void)
99246 fputs("\n};\n\n", out);
99247
99248 /* write logo clut */
99249 - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n",
99250 + fprintf(out, "static unsigned char %s_clut[] = {\n",
99251 logoname);
99252 write_hex_cnt = 0;
99253 for (i = 0; i < logo_clutsize; i++) {
99254 diff --git a/scripts/sortextable.h b/scripts/sortextable.h
99255 index f5eb43d..1814de8 100644
99256 --- a/scripts/sortextable.h
99257 +++ b/scripts/sortextable.h
99258 @@ -106,9 +106,9 @@ do_func(Elf_Ehdr *ehdr, char const *const fname, table_sort_t custom_sort)
99259 const char *secstrtab;
99260 const char *strtab;
99261 char *extab_image;
99262 - int extab_index = 0;
99263 - int i;
99264 - int idx;
99265 + unsigned int extab_index = 0;
99266 + unsigned int i;
99267 + unsigned int idx;
99268
99269 shdr = (Elf_Shdr *)((char *)ehdr + _r(&ehdr->e_shoff));
99270 shstrtab_sec = shdr + r2(&ehdr->e_shstrndx);
99271 diff --git a/security/Kconfig b/security/Kconfig
99272 index e9c6ac7..9551ea7 100644
99273 --- a/security/Kconfig
99274 +++ b/security/Kconfig
99275 @@ -4,6 +4,958 @@
99276
99277 menu "Security options"
99278
99279 +menu "Grsecurity"
99280 +
99281 + config ARCH_TRACK_EXEC_LIMIT
99282 + bool
99283 +
99284 + config PAX_KERNEXEC_PLUGIN
99285 + bool
99286 +
99287 + config PAX_PER_CPU_PGD
99288 + bool
99289 +
99290 + config TASK_SIZE_MAX_SHIFT
99291 + int
99292 + depends on X86_64
99293 + default 47 if !PAX_PER_CPU_PGD
99294 + default 42 if PAX_PER_CPU_PGD
99295 +
99296 + config PAX_ENABLE_PAE
99297 + bool
99298 + default y if (X86_32 && (MPENTIUM4 || MK8 || MPSC || MCORE2 || MATOM))
99299 +
99300 + config PAX_USERCOPY_SLABS
99301 + bool
99302 +
99303 +config GRKERNSEC
99304 + bool "Grsecurity"
99305 + select CRYPTO
99306 + select CRYPTO_SHA256
99307 + select PROC_FS
99308 + select STOP_MACHINE
99309 + select TTY
99310 + select DEBUG_LIST
99311 + help
99312 + If you say Y here, you will be able to configure many features
99313 + that will enhance the security of your system. It is highly
99314 + recommended that you say Y here and read through the help
99315 + for each option so that you fully understand the features and
99316 + can evaluate their usefulness for your machine.
99317 +
99318 +choice
99319 + prompt "Configuration Method"
99320 + depends on GRKERNSEC
99321 + default GRKERNSEC_CONFIG_CUSTOM
99322 + help
99323 +
99324 +config GRKERNSEC_CONFIG_AUTO
99325 + bool "Automatic"
99326 + help
99327 + If you choose this configuration method, you'll be able to answer a small
99328 + number of simple questions about how you plan to use this kernel.
99329 + The settings of grsecurity and PaX will be automatically configured for
99330 + the highest commonly-used settings within the provided constraints.
99331 +
99332 + If you require additional configuration, custom changes can still be made
99333 + from the "custom configuration" menu.
99334 +
99335 +config GRKERNSEC_CONFIG_CUSTOM
99336 + bool "Custom"
99337 + help
99338 + If you choose this configuration method, you'll be able to configure all
99339 + grsecurity and PaX settings manually. Via this method, no options are
99340 + automatically enabled.
99341 +
99342 +endchoice
99343 +
99344 +choice
99345 + prompt "Usage Type"
99346 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99347 + default GRKERNSEC_CONFIG_SERVER
99348 + help
99349 +
99350 +config GRKERNSEC_CONFIG_SERVER
99351 + bool "Server"
99352 + help
99353 + Choose this option if you plan to use this kernel on a server.
99354 +
99355 +config GRKERNSEC_CONFIG_DESKTOP
99356 + bool "Desktop"
99357 + help
99358 + Choose this option if you plan to use this kernel on a desktop.
99359 +
99360 +endchoice
99361 +
99362 +choice
99363 + prompt "Virtualization Type"
99364 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO)
99365 + default GRKERNSEC_CONFIG_VIRT_NONE
99366 + help
99367 +
99368 +config GRKERNSEC_CONFIG_VIRT_NONE
99369 + bool "None"
99370 + help
99371 + Choose this option if this kernel will be run on bare metal.
99372 +
99373 +config GRKERNSEC_CONFIG_VIRT_GUEST
99374 + bool "Guest"
99375 + help
99376 + Choose this option if this kernel will be run as a VM guest.
99377 +
99378 +config GRKERNSEC_CONFIG_VIRT_HOST
99379 + bool "Host"
99380 + help
99381 + Choose this option if this kernel will be run as a VM host.
99382 +
99383 +endchoice
99384 +
99385 +choice
99386 + prompt "Virtualization Hardware"
99387 + depends on (GRKERNSEC && X86 && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
99388 + help
99389 +
99390 +config GRKERNSEC_CONFIG_VIRT_EPT
99391 + bool "EPT/RVI Processor Support"
99392 + depends on X86
99393 + help
99394 + Choose this option if your CPU supports the EPT or RVI features of 2nd-gen
99395 + hardware virtualization. This allows for additional kernel hardening protections
99396 + to operate without additional performance impact.
99397 +
99398 + To see if your Intel processor supports EPT, see:
99399 + http://ark.intel.com/Products/VirtualizationTechnology
99400 + (Most Core i3/5/7 support EPT)
99401 +
99402 + To see if your AMD processor supports RVI, see:
99403 + http://support.amd.com/us/kbarticles/Pages/GPU120AMDRVICPUsHyperVWin8.aspx
99404 +
99405 +config GRKERNSEC_CONFIG_VIRT_SOFT
99406 + bool "First-gen/No Hardware Virtualization"
99407 + help
99408 + Choose this option if you use an Atom/Pentium/Core 2 processor that either doesn't
99409 + support hardware virtualization or doesn't support the EPT/RVI extensions.
99410 +
99411 +endchoice
99412 +
99413 +choice
99414 + prompt "Virtualization Software"
99415 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO && (GRKERNSEC_CONFIG_VIRT_GUEST || GRKERNSEC_CONFIG_VIRT_HOST))
99416 + help
99417 +
99418 +config GRKERNSEC_CONFIG_VIRT_XEN
99419 + bool "Xen"
99420 + help
99421 + Choose this option if this kernel is running as a Xen guest or host.
99422 +
99423 +config GRKERNSEC_CONFIG_VIRT_VMWARE
99424 + bool "VMWare"
99425 + help
99426 + Choose this option if this kernel is running as a VMWare guest or host.
99427 +
99428 +config GRKERNSEC_CONFIG_VIRT_KVM
99429 + bool "KVM"
99430 + help
99431 + Choose this option if this kernel is running as a KVM guest or host.
99432 +
99433 +config GRKERNSEC_CONFIG_VIRT_VIRTUALBOX
99434 + bool "VirtualBox"
99435 + help
99436 + Choose this option if this kernel is running as a VirtualBox guest or host.
99437 +
99438 +endchoice
99439 +
99440 +choice
99441 + prompt "Required Priorities"
99442 + depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99443 + default GRKERNSEC_CONFIG_PRIORITY_PERF
99444 + help
99445 +
99446 +config GRKERNSEC_CONFIG_PRIORITY_PERF
99447 + bool "Performance"
99448 + help
99449 + Choose this option if performance is of highest priority for this deployment
99450 + of grsecurity. Features like UDEREF on a 64bit kernel, kernel stack clearing,
99451 + clearing of structures intended for userland, and freed memory sanitizing will
99452 + be disabled.
99453 +
99454 +config GRKERNSEC_CONFIG_PRIORITY_SECURITY
99455 + bool "Security"
99456 + help
99457 + Choose this option if security is of highest priority for this deployment of
99458 + grsecurity. UDEREF, kernel stack clearing, clearing of structures intended
99459 + for userland, and freed memory sanitizing will be enabled for this kernel.
99460 + In a worst-case scenario, these features can introduce a 20% performance hit
99461 + (UDEREF on x64 contributing half of this hit).
99462 +
99463 +endchoice
99464 +
99465 +menu "Default Special Groups"
99466 +depends on (GRKERNSEC && GRKERNSEC_CONFIG_AUTO)
99467 +
99468 +config GRKERNSEC_PROC_GID
99469 + int "GID exempted from /proc restrictions"
99470 + default 1001
99471 + help
99472 + Setting this GID determines which group will be exempted from
99473 + grsecurity's /proc restrictions, allowing users of the specified
99474 + group to view network statistics and the existence of other users'
99475 + processes on the system. This GID may also be chosen at boot time
99476 + via "grsec_proc_gid=" on the kernel commandline.
99477 +
99478 +config GRKERNSEC_TPE_UNTRUSTED_GID
99479 + int "GID for TPE-untrusted users"
99480 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && !GRKERNSEC_TPE_INVERT
99481 + default 1005
99482 + help
99483 + Setting this GID determines which group untrusted users should
99484 + be added to. These users will be placed under grsecurity's Trusted Path
99485 + Execution mechanism, preventing them from executing their own binaries.
99486 + The users will only be able to execute binaries in directories owned and
99487 + writable only by the root user. If the sysctl option is enabled, a sysctl
99488 + option with name "tpe_gid" is created.
99489 +
99490 +config GRKERNSEC_TPE_TRUSTED_GID
99491 + int "GID for TPE-trusted users"
99492 + depends on GRKERNSEC_CONFIG_SERVER && GRKERNSEC_TPE && GRKERNSEC_TPE_INVERT
99493 + default 1005
99494 + help
99495 + Setting this GID determines what group TPE restrictions will be
99496 + *disabled* for. If the sysctl option is enabled, a sysctl option
99497 + with name "tpe_gid" is created.
99498 +
99499 +config GRKERNSEC_SYMLINKOWN_GID
99500 + int "GID for users with kernel-enforced SymlinksIfOwnerMatch"
99501 + depends on GRKERNSEC_CONFIG_SERVER
99502 + default 1006
99503 + help
99504 + Setting this GID determines what group kernel-enforced
99505 + SymlinksIfOwnerMatch will be enabled for. If the sysctl option
99506 + is enabled, a sysctl option with name "symlinkown_gid" is created.
99507 +
99508 +
99509 +endmenu
99510 +
99511 +menu "Customize Configuration"
99512 +depends on GRKERNSEC
99513 +
99514 +menu "PaX"
99515 +
99516 +config PAX
99517 + bool "Enable various PaX features"
99518 + default y if GRKERNSEC_CONFIG_AUTO
99519 + depends on GRKERNSEC && (ALPHA || ARM || AVR32 || IA64 || MIPS || PARISC || PPC || SPARC || X86)
99520 + help
99521 + This allows you to enable various PaX features. PaX adds
99522 + intrusion prevention mechanisms to the kernel that reduce
99523 + the risks posed by exploitable memory corruption bugs.
99524 +
99525 +menu "PaX Control"
99526 + depends on PAX
99527 +
99528 +config PAX_SOFTMODE
99529 + bool 'Support soft mode'
99530 + help
99531 + Enabling this option will allow you to run PaX in soft mode, that
99532 + is, PaX features will not be enforced by default, only on executables
99533 + marked explicitly. You must also enable PT_PAX_FLAGS or XATTR_PAX_FLAGS
99534 + support as they are the only way to mark executables for soft mode use.
99535 +
99536 + Soft mode can be activated by using the "pax_softmode=1" kernel command
99537 + line option on boot. Furthermore you can control various PaX features
99538 + at runtime via the entries in /proc/sys/kernel/pax.
99539 +
99540 +config PAX_EI_PAX
99541 + bool 'Use legacy ELF header marking'
99542 + default y if GRKERNSEC_CONFIG_AUTO
99543 + help
99544 + Enabling this option will allow you to control PaX features on
99545 + a per executable basis via the 'chpax' utility available at
99546 + http://pax.grsecurity.net/. The control flags will be read from
99547 + an otherwise reserved part of the ELF header. This marking has
99548 + numerous drawbacks (no support for soft-mode, toolchain does not
99549 + know about the non-standard use of the ELF header) therefore it
99550 + has been deprecated in favour of PT_PAX_FLAGS and XATTR_PAX_FLAGS
99551 + support.
99552 +
99553 + Note that if you enable PT_PAX_FLAGS or XATTR_PAX_FLAGS marking
99554 + support as well, they will override the legacy EI_PAX marks.
99555 +
99556 + If you enable none of the marking options then all applications
99557 + will run with PaX enabled on them by default.
99558 +
99559 +config PAX_PT_PAX_FLAGS
99560 + bool 'Use ELF program header marking'
99561 + default y if GRKERNSEC_CONFIG_AUTO
99562 + help
99563 + Enabling this option will allow you to control PaX features on
99564 + a per executable basis via the 'paxctl' utility available at
99565 + http://pax.grsecurity.net/. The control flags will be read from
99566 + a PaX specific ELF program header (PT_PAX_FLAGS). This marking
99567 + has the benefits of supporting both soft mode and being fully
99568 + integrated into the toolchain (the binutils patch is available
99569 + from http://pax.grsecurity.net).
99570 +
99571 + Note that if you enable the legacy EI_PAX marking support as well,
99572 + the EI_PAX marks will be overridden by the PT_PAX_FLAGS marks.
99573 +
99574 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99575 + must make sure that the marks are the same if a binary has both marks.
99576 +
99577 + If you enable none of the marking options then all applications
99578 + will run with PaX enabled on them by default.
99579 +
99580 +config PAX_XATTR_PAX_FLAGS
99581 + bool 'Use filesystem extended attributes marking'
99582 + default y if GRKERNSEC_CONFIG_AUTO
99583 + select CIFS_XATTR if CIFS
99584 + select EXT2_FS_XATTR if EXT2_FS
99585 + select EXT3_FS_XATTR if EXT3_FS
99586 + select JFFS2_FS_XATTR if JFFS2_FS
99587 + select REISERFS_FS_XATTR if REISERFS_FS
99588 + select SQUASHFS_XATTR if SQUASHFS
99589 + select TMPFS_XATTR if TMPFS
99590 + select UBIFS_FS_XATTR if UBIFS_FS
99591 + help
99592 + Enabling this option will allow you to control PaX features on
99593 + a per executable basis via the 'setfattr' utility. The control
99594 + flags will be read from the user.pax.flags extended attribute of
99595 + the file. This marking has the benefit of supporting binary-only
99596 + applications that self-check themselves (e.g., skype) and would
99597 + not tolerate chpax/paxctl changes. The main drawback is that
99598 + extended attributes are not supported by some filesystems (e.g.,
99599 + isofs, udf, vfat) so copying files through such filesystems will
99600 + lose the extended attributes and these PaX markings.
99601 +
99602 + Note that if you enable the legacy EI_PAX marking support as well,
99603 + the EI_PAX marks will be overridden by the XATTR_PAX_FLAGS marks.
99604 +
99605 + If you enable both PT_PAX_FLAGS and XATTR_PAX_FLAGS support then you
99606 + must make sure that the marks are the same if a binary has both marks.
99607 +
99608 + If you enable none of the marking options then all applications
99609 + will run with PaX enabled on them by default.
99610 +
99611 +choice
99612 + prompt 'MAC system integration'
99613 + default PAX_HAVE_ACL_FLAGS
99614 + help
99615 + Mandatory Access Control systems have the option of controlling
99616 + PaX flags on a per executable basis, choose the method supported
99617 + by your particular system.
99618 +
99619 + - "none": if your MAC system does not interact with PaX,
99620 + - "direct": if your MAC system defines pax_set_initial_flags() itself,
99621 + - "hook": if your MAC system uses the pax_set_initial_flags_func callback.
99622 +
99623 + NOTE: this option is for developers/integrators only.
99624 +
99625 + config PAX_NO_ACL_FLAGS
99626 + bool 'none'
99627 +
99628 + config PAX_HAVE_ACL_FLAGS
99629 + bool 'direct'
99630 +
99631 + config PAX_HOOK_ACL_FLAGS
99632 + bool 'hook'
99633 +endchoice
99634 +
99635 +endmenu
99636 +
99637 +menu "Non-executable pages"
99638 + depends on PAX
99639 +
99640 +config PAX_NOEXEC
99641 + bool "Enforce non-executable pages"
99642 + default y if GRKERNSEC_CONFIG_AUTO
99643 + depends on ALPHA || (ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || IA64 || MIPS || PARISC || PPC || S390 || SPARC || X86
99644 + help
99645 + By design some architectures do not allow for protecting memory
99646 + pages against execution or even if they do, Linux does not make
99647 + use of this feature. In practice this means that if a page is
99648 + readable (such as the stack or heap) it is also executable.
99649 +
99650 + There is a well known exploit technique that makes use of this
99651 + fact and a common programming mistake where an attacker can
99652 + introduce code of his choice somewhere in the attacked program's
99653 + memory (typically the stack or the heap) and then execute it.
99654 +
99655 + If the attacked program was running with different (typically
99656 + higher) privileges than that of the attacker, then he can elevate
99657 + his own privilege level (e.g. get a root shell, write to files for
99658 + which he does not have write access to, etc).
99659 +
99660 + Enabling this option will let you choose from various features
99661 + that prevent the injection and execution of 'foreign' code in
99662 + a program.
99663 +
99664 + This will also break programs that rely on the old behaviour and
99665 + expect that dynamically allocated memory via the malloc() family
99666 + of functions is executable (which it is not). Notable examples
99667 + are the XFree86 4.x server, the java runtime and wine.
99668 +
99669 +config PAX_PAGEEXEC
99670 + bool "Paging based non-executable pages"
99671 + default y if GRKERNSEC_CONFIG_AUTO
99672 + 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)
99673 + select ARCH_TRACK_EXEC_LIMIT if X86_32
99674 + help
99675 + This implementation is based on the paging feature of the CPU.
99676 + On i386 without hardware non-executable bit support there is a
99677 + variable but usually low performance impact, however on Intel's
99678 + P4 core based CPUs it is very high so you should not enable this
99679 + for kernels meant to be used on such CPUs.
99680 +
99681 + On alpha, avr32, ia64, parisc, sparc, sparc64, x86_64 and i386
99682 + with hardware non-executable bit support there is no performance
99683 + impact, on ppc the impact is negligible.
99684 +
99685 + Note that several architectures require various emulations due to
99686 + badly designed userland ABIs, this will cause a performance impact
99687 + but will disappear as soon as userland is fixed. For example, ppc
99688 + userland MUST have been built with secure-plt by a recent toolchain.
99689 +
99690 +config PAX_SEGMEXEC
99691 + bool "Segmentation based non-executable pages"
99692 + default y if GRKERNSEC_CONFIG_AUTO
99693 + depends on PAX_NOEXEC && X86_32
99694 + help
99695 + This implementation is based on the segmentation feature of the
99696 + CPU and has a very small performance impact, however applications
99697 + will be limited to a 1.5 GB address space instead of the normal
99698 + 3 GB.
99699 +
99700 +config PAX_EMUTRAMP
99701 + bool "Emulate trampolines" if (PAX_PAGEEXEC || PAX_SEGMEXEC) && (PARISC || X86)
99702 + default y if PARISC
99703 + help
99704 + There are some programs and libraries that for one reason or
99705 + another attempt to execute special small code snippets from
99706 + non-executable memory pages. Most notable examples are the
99707 + signal handler return code generated by the kernel itself and
99708 + the GCC trampolines.
99709 +
99710 + If you enabled CONFIG_PAX_PAGEEXEC or CONFIG_PAX_SEGMEXEC then
99711 + such programs will no longer work under your kernel.
99712 +
99713 + As a remedy you can say Y here and use the 'chpax' or 'paxctl'
99714 + utilities to enable trampoline emulation for the affected programs
99715 + yet still have the protection provided by the non-executable pages.
99716 +
99717 + On parisc you MUST enable this option and EMUSIGRT as well, otherwise
99718 + your system will not even boot.
99719 +
99720 + Alternatively you can say N here and use the 'chpax' or 'paxctl'
99721 + utilities to disable CONFIG_PAX_PAGEEXEC and CONFIG_PAX_SEGMEXEC
99722 + for the affected files.
99723 +
99724 + NOTE: enabling this feature *may* open up a loophole in the
99725 + protection provided by non-executable pages that an attacker
99726 + could abuse. Therefore the best solution is to not have any
99727 + files on your system that would require this option. This can
99728 + be achieved by not using libc5 (which relies on the kernel
99729 + signal handler return code) and not using or rewriting programs
99730 + that make use of the nested function implementation of GCC.
99731 + Skilled users can just fix GCC itself so that it implements
99732 + nested function calls in a way that does not interfere with PaX.
99733 +
99734 +config PAX_EMUSIGRT
99735 + bool "Automatically emulate sigreturn trampolines"
99736 + depends on PAX_EMUTRAMP && PARISC
99737 + default y
99738 + help
99739 + Enabling this option will have the kernel automatically detect
99740 + and emulate signal return trampolines executing on the stack
99741 + that would otherwise lead to task termination.
99742 +
99743 + This solution is intended as a temporary one for users with
99744 + legacy versions of libc (libc5, glibc 2.0, uClibc before 0.9.17,
99745 + Modula-3 runtime, etc) or executables linked to such, basically
99746 + everything that does not specify its own SA_RESTORER function in
99747 + normal executable memory like glibc 2.1+ does.
99748 +
99749 + On parisc you MUST enable this option, otherwise your system will
99750 + not even boot.
99751 +
99752 + NOTE: this feature cannot be disabled on a per executable basis
99753 + and since it *does* open up a loophole in the protection provided
99754 + by non-executable pages, the best solution is to not have any
99755 + files on your system that would require this option.
99756 +
99757 +config PAX_MPROTECT
99758 + bool "Restrict mprotect()"
99759 + default y if GRKERNSEC_CONFIG_AUTO
99760 + depends on (PAX_PAGEEXEC || PAX_SEGMEXEC)
99761 + help
99762 + Enabling this option will prevent programs from
99763 + - changing the executable status of memory pages that were
99764 + not originally created as executable,
99765 + - making read-only executable pages writable again,
99766 + - creating executable pages from anonymous memory,
99767 + - making read-only-after-relocations (RELRO) data pages writable again.
99768 +
99769 + You should say Y here to complete the protection provided by
99770 + the enforcement of non-executable pages.
99771 +
99772 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99773 + this feature on a per file basis.
99774 +
99775 +config PAX_MPROTECT_COMPAT
99776 + bool "Use legacy/compat protection demoting (read help)"
99777 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99778 + depends on PAX_MPROTECT
99779 + help
99780 + The current implementation of PAX_MPROTECT denies RWX allocations/mprotects
99781 + by sending the proper error code to the application. For some broken
99782 + userland, this can cause problems with Python or other applications. The
99783 + current implementation however allows for applications like clamav to
99784 + detect if JIT compilation/execution is allowed and to fall back gracefully
99785 + to an interpreter-based mode if it does not. While we encourage everyone
99786 + to use the current implementation as-is and push upstream to fix broken
99787 + userland (note that the RWX logging option can assist with this), in some
99788 + environments this may not be possible. Having to disable MPROTECT
99789 + completely on certain binaries reduces the security benefit of PaX,
99790 + so this option is provided for those environments to revert to the old
99791 + behavior.
99792 +
99793 +config PAX_ELFRELOCS
99794 + bool "Allow ELF text relocations (read help)"
99795 + depends on PAX_MPROTECT
99796 + default n
99797 + help
99798 + Non-executable pages and mprotect() restrictions are effective
99799 + in preventing the introduction of new executable code into an
99800 + attacked task's address space. There remain only two venues
99801 + for this kind of attack: if the attacker can execute already
99802 + existing code in the attacked task then he can either have it
99803 + create and mmap() a file containing his code or have it mmap()
99804 + an already existing ELF library that does not have position
99805 + independent code in it and use mprotect() on it to make it
99806 + writable and copy his code there. While protecting against
99807 + the former approach is beyond PaX, the latter can be prevented
99808 + by having only PIC ELF libraries on one's system (which do not
99809 + need to relocate their code). If you are sure this is your case,
99810 + as is the case with all modern Linux distributions, then leave
99811 + this option disabled. You should say 'n' here.
99812 +
99813 +config PAX_ETEXECRELOCS
99814 + bool "Allow ELF ET_EXEC text relocations"
99815 + depends on PAX_MPROTECT && (ALPHA || IA64 || PARISC)
99816 + select PAX_ELFRELOCS
99817 + default y
99818 + help
99819 + On some architectures there are incorrectly created applications
99820 + that require text relocations and would not work without enabling
99821 + this option. If you are an alpha, ia64 or parisc user, you should
99822 + enable this option and disable it once you have made sure that
99823 + none of your applications need it.
99824 +
99825 +config PAX_EMUPLT
99826 + bool "Automatically emulate ELF PLT"
99827 + depends on PAX_MPROTECT && (ALPHA || PARISC || SPARC)
99828 + default y
99829 + help
99830 + Enabling this option will have the kernel automatically detect
99831 + and emulate the Procedure Linkage Table entries in ELF files.
99832 + On some architectures such entries are in writable memory, and
99833 + become non-executable leading to task termination. Therefore
99834 + it is mandatory that you enable this option on alpha, parisc,
99835 + sparc and sparc64, otherwise your system would not even boot.
99836 +
99837 + NOTE: this feature *does* open up a loophole in the protection
99838 + provided by the non-executable pages, therefore the proper
99839 + solution is to modify the toolchain to produce a PLT that does
99840 + not need to be writable.
99841 +
99842 +config PAX_DLRESOLVE
99843 + bool 'Emulate old glibc resolver stub'
99844 + depends on PAX_EMUPLT && SPARC
99845 + default n
99846 + help
99847 + This option is needed if userland has an old glibc (before 2.4)
99848 + that puts a 'save' instruction into the runtime generated resolver
99849 + stub that needs special emulation.
99850 +
99851 +config PAX_KERNEXEC
99852 + bool "Enforce non-executable kernel pages"
99853 + 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))
99854 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !(ARM_LPAE && MODULES))) && !XEN
99855 + select PAX_PER_CPU_PGD if X86_64 || (X86_32 && X86_PAE)
99856 + select PAX_KERNEXEC_PLUGIN if X86_64
99857 + help
99858 + This is the kernel land equivalent of PAGEEXEC and MPROTECT,
99859 + that is, enabling this option will make it harder to inject
99860 + and execute 'foreign' code in kernel memory itself.
99861 +
99862 +choice
99863 + prompt "Return Address Instrumentation Method"
99864 + default PAX_KERNEXEC_PLUGIN_METHOD_BTS
99865 + depends on PAX_KERNEXEC_PLUGIN
99866 + help
99867 + Select the method used to instrument function pointer dereferences.
99868 + Note that binary modules cannot be instrumented by this approach.
99869 +
99870 + Note that the implementation requires a gcc with plugin support,
99871 + i.e., gcc 4.5 or newer. You may need to install the supporting
99872 + headers explicitly in addition to the normal gcc package.
99873 +
99874 + config PAX_KERNEXEC_PLUGIN_METHOD_BTS
99875 + bool "bts"
99876 + help
99877 + This method is compatible with binary only modules but has
99878 + a higher runtime overhead.
99879 +
99880 + config PAX_KERNEXEC_PLUGIN_METHOD_OR
99881 + bool "or"
99882 + depends on !PARAVIRT
99883 + help
99884 + This method is incompatible with binary only modules but has
99885 + a lower runtime overhead.
99886 +endchoice
99887 +
99888 +config PAX_KERNEXEC_PLUGIN_METHOD
99889 + string
99890 + default "bts" if PAX_KERNEXEC_PLUGIN_METHOD_BTS
99891 + default "or" if PAX_KERNEXEC_PLUGIN_METHOD_OR
99892 + default ""
99893 +
99894 +config PAX_KERNEXEC_MODULE_TEXT
99895 + int "Minimum amount of memory reserved for module code"
99896 + default "4" if (!GRKERNSEC_CONFIG_AUTO || GRKERNSEC_CONFIG_SERVER)
99897 + default "12" if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_DESKTOP)
99898 + depends on PAX_KERNEXEC && X86_32
99899 + help
99900 + Due to implementation details the kernel must reserve a fixed
99901 + amount of memory for runtime allocated code (such as modules)
99902 + at compile time that cannot be changed at runtime. Here you
99903 + can specify the minimum amount in MB that will be reserved.
99904 + Due to the same implementation details this size will always
99905 + be rounded up to the next 2/4 MB boundary (depends on PAE) so
99906 + the actually available memory for runtime allocated code will
99907 + usually be more than this minimum.
99908 +
99909 + The default 4 MB should be enough for most users but if you have
99910 + an excessive number of modules (e.g., most distribution configs
99911 + compile many drivers as modules) or use huge modules such as
99912 + nvidia's kernel driver, you will need to adjust this amount.
99913 + A good rule of thumb is to look at your currently loaded kernel
99914 + modules and add up their sizes.
99915 +
99916 +endmenu
99917 +
99918 +menu "Address Space Layout Randomization"
99919 + depends on PAX
99920 +
99921 +config PAX_ASLR
99922 + bool "Address Space Layout Randomization"
99923 + default y if GRKERNSEC_CONFIG_AUTO
99924 + help
99925 + Many if not most exploit techniques rely on the knowledge of
99926 + certain addresses in the attacked program. The following options
99927 + will allow the kernel to apply a certain amount of randomization
99928 + to specific parts of the program thereby forcing an attacker to
99929 + guess them in most cases. Any failed guess will most likely crash
99930 + the attacked program which allows the kernel to detect such attempts
99931 + and react on them. PaX itself provides no reaction mechanisms,
99932 + instead it is strongly encouraged that you make use of Nergal's
99933 + segvguard (ftp://ftp.pl.openwall.com/misc/segvguard/) or grsecurity's
99934 + (http://www.grsecurity.net/) built-in crash detection features or
99935 + develop one yourself.
99936 +
99937 + By saying Y here you can choose to randomize the following areas:
99938 + - top of the task's kernel stack
99939 + - top of the task's userland stack
99940 + - base address for mmap() requests that do not specify one
99941 + (this includes all libraries)
99942 + - base address of the main executable
99943 +
99944 + It is strongly recommended to say Y here as address space layout
99945 + randomization has negligible impact on performance yet it provides
99946 + a very effective protection.
99947 +
99948 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control
99949 + this feature on a per file basis.
99950 +
99951 +config PAX_RANDKSTACK
99952 + bool "Randomize kernel stack base"
99953 + default y if GRKERNSEC_CONFIG_AUTO && !(GRKERNSEC_CONFIG_VIRT_HOST && GRKERNSEC_CONFIG_VIRT_VIRTUALBOX)
99954 + depends on X86_TSC && X86
99955 + help
99956 + By saying Y here the kernel will randomize every task's kernel
99957 + stack on every system call. This will not only force an attacker
99958 + to guess it but also prevent him from making use of possible
99959 + leaked information about it.
99960 +
99961 + Since the kernel stack is a rather scarce resource, randomization
99962 + may cause unexpected stack overflows, therefore you should very
99963 + carefully test your system. Note that once enabled in the kernel
99964 + configuration, this feature cannot be disabled on a per file basis.
99965 +
99966 +config PAX_RANDUSTACK
99967 + bool "Randomize user stack base"
99968 + default y if GRKERNSEC_CONFIG_AUTO
99969 + depends on PAX_ASLR
99970 + help
99971 + By saying Y here the kernel will randomize every task's userland
99972 + stack. The randomization is done in two steps where the second
99973 + one may apply a big amount of shift to the top of the stack and
99974 + cause problems for programs that want to use lots of memory (more
99975 + than 2.5 GB if SEGMEXEC is not active, or 1.25 GB when it is).
99976 + For this reason the second step can be controlled by 'chpax' or
99977 + 'paxctl' on a per file basis.
99978 +
99979 +config PAX_RANDMMAP
99980 + bool "Randomize mmap() base"
99981 + default y if GRKERNSEC_CONFIG_AUTO
99982 + depends on PAX_ASLR
99983 + help
99984 + By saying Y here the kernel will use a randomized base address for
99985 + mmap() requests that do not specify one themselves. As a result
99986 + all dynamically loaded libraries will appear at random addresses
99987 + and therefore be harder to exploit by a technique where an attacker
99988 + attempts to execute library code for his purposes (e.g. spawn a
99989 + shell from an exploited program that is running at an elevated
99990 + privilege level).
99991 +
99992 + Furthermore, if a program is relinked as a dynamic ELF file, its
99993 + base address will be randomized as well, completing the full
99994 + randomization of the address space layout. Attacking such programs
99995 + becomes a guess game. You can find an example of doing this at
99996 + http://pax.grsecurity.net/et_dyn.tar.gz and practical samples at
99997 + http://www.grsecurity.net/grsec-gcc-specs.tar.gz .
99998 +
99999 + NOTE: you can use the 'chpax' or 'paxctl' utilities to control this
100000 + feature on a per file basis.
100001 +
100002 +endmenu
100003 +
100004 +menu "Miscellaneous hardening features"
100005 +
100006 +config PAX_MEMORY_SANITIZE
100007 + bool "Sanitize all freed memory"
100008 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
100009 + help
100010 + By saying Y here the kernel will erase memory pages and slab objects
100011 + as soon as they are freed. This in turn reduces the lifetime of data
100012 + stored in them, making it less likely that sensitive information such
100013 + as passwords, cryptographic secrets, etc stay in memory for too long.
100014 +
100015 + This is especially useful for programs whose runtime is short, long
100016 + lived processes and the kernel itself benefit from this as long as
100017 + they ensure timely freeing of memory that may hold sensitive
100018 + information.
100019 +
100020 + A nice side effect of the sanitization of slab objects is the
100021 + reduction of possible info leaks caused by padding bytes within the
100022 + leaky structures. Use-after-free bugs for structures containing
100023 + pointers can also be detected as dereferencing the sanitized pointer
100024 + will generate an access violation.
100025 +
100026 + The tradeoff is performance impact, on a single CPU system kernel
100027 + compilation sees a 3% slowdown, other systems and workloads may vary
100028 + and you are advised to test this feature on your expected workload
100029 + before deploying it.
100030 +
100031 + To reduce the performance penalty by sanitizing pages only, albeit
100032 + limiting the effectiveness of this feature at the same time, slab
100033 + sanitization can be disabled with the kernel commandline parameter
100034 + "pax_sanitize_slab=0".
100035 +
100036 + Note that this feature does not protect data stored in live pages,
100037 + e.g., process memory swapped to disk may stay there for a long time.
100038 +
100039 +config PAX_MEMORY_STACKLEAK
100040 + bool "Sanitize kernel stack"
100041 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
100042 + depends on X86
100043 + help
100044 + By saying Y here the kernel will erase the kernel stack before it
100045 + returns from a system call. This in turn reduces the information
100046 + that a kernel stack leak bug can reveal.
100047 +
100048 + Note that such a bug can still leak information that was put on
100049 + the stack by the current system call (the one eventually triggering
100050 + the bug) but traces of earlier system calls on the kernel stack
100051 + cannot leak anymore.
100052 +
100053 + The tradeoff is performance impact: on a single CPU system kernel
100054 + compilation sees a 1% slowdown, other systems and workloads may vary
100055 + and you are advised to test this feature on your expected workload
100056 + before deploying it.
100057 +
100058 + Note that the full feature requires a gcc with plugin support,
100059 + i.e., gcc 4.5 or newer. You may need to install the supporting
100060 + headers explicitly in addition to the normal gcc package. Using
100061 + older gcc versions means that functions with large enough stack
100062 + frames may leave uninitialized memory behind that may be exposed
100063 + to a later syscall leaking the stack.
100064 +
100065 +config PAX_MEMORY_STRUCTLEAK
100066 + bool "Forcibly initialize local variables copied to userland"
100067 + default y if (GRKERNSEC_CONFIG_AUTO && GRKERNSEC_CONFIG_PRIORITY_SECURITY)
100068 + help
100069 + By saying Y here the kernel will zero initialize some local
100070 + variables that are going to be copied to userland. This in
100071 + turn prevents unintended information leakage from the kernel
100072 + stack should later code forget to explicitly set all parts of
100073 + the copied variable.
100074 +
100075 + The tradeoff is less performance impact than PAX_MEMORY_STACKLEAK
100076 + at a much smaller coverage.
100077 +
100078 + Note that the implementation requires a gcc with plugin support,
100079 + i.e., gcc 4.5 or newer. You may need to install the supporting
100080 + headers explicitly in addition to the normal gcc package.
100081 +
100082 +config PAX_MEMORY_UDEREF
100083 + bool "Prevent invalid userland pointer dereference"
100084 + default y if GRKERNSEC_CONFIG_AUTO && !(X86_64 && GRKERNSEC_CONFIG_PRIORITY_PERF) && (GRKERNSEC_CONFIG_VIRT_NONE || GRKERNSEC_CONFIG_VIRT_EPT)
100085 + depends on (X86 || (ARM && (CPU_V6 || CPU_V6K || CPU_V7) && !ARM_LPAE)) && !UML_X86 && !XEN
100086 + select PAX_PER_CPU_PGD if X86_64
100087 + help
100088 + By saying Y here the kernel will be prevented from dereferencing
100089 + userland pointers in contexts where the kernel expects only kernel
100090 + pointers. This is both a useful runtime debugging feature and a
100091 + security measure that prevents exploiting a class of kernel bugs.
100092 +
100093 + The tradeoff is that some virtualization solutions may experience
100094 + a huge slowdown and therefore you should not enable this feature
100095 + for kernels meant to run in such environments. Whether a given VM
100096 + solution is affected or not is best determined by simply trying it
100097 + out, the performance impact will be obvious right on boot as this
100098 + mechanism engages from very early on. A good rule of thumb is that
100099 + VMs running on CPUs without hardware virtualization support (i.e.,
100100 + the majority of IA-32 CPUs) will likely experience the slowdown.
100101 +
100102 + On X86_64 the kernel will make use of PCID support when available
100103 + (Intel's Westmere, Sandy Bridge, etc) for better security (default)
100104 + or performance impact. Pass pax_weakuderef on the kernel command
100105 + line to choose the latter.
100106 +
100107 +config PAX_REFCOUNT
100108 + bool "Prevent various kernel object reference counter overflows"
100109 + default y if GRKERNSEC_CONFIG_AUTO
100110 + depends on GRKERNSEC && ((ARM && (CPU_V6 || CPU_V6K || CPU_V7)) || MIPS || SPARC64 || X86)
100111 + help
100112 + By saying Y here the kernel will detect and prevent overflowing
100113 + various (but not all) kinds of object reference counters. Such
100114 + overflows can normally occur due to bugs only and are often, if
100115 + not always, exploitable.
100116 +
100117 + The tradeoff is that data structures protected by an overflowed
100118 + refcount will never be freed and therefore will leak memory. Note
100119 + that this leak also happens even without this protection but in
100120 + that case the overflow can eventually trigger the freeing of the
100121 + data structure while it is still being used elsewhere, resulting
100122 + in the exploitable situation that this feature prevents.
100123 +
100124 + Since this has a negligible performance impact, you should enable
100125 + this feature.
100126 +
100127 +config PAX_CONSTIFY_PLUGIN
100128 + bool "Automatically constify eligible structures"
100129 + default y
100130 + depends on !UML && PAX_KERNEXEC
100131 + help
100132 + By saying Y here the compiler will automatically constify a class
100133 + of types that contain only function pointers. This reduces the
100134 + kernel's attack surface and also produces a better memory layout.
100135 +
100136 + Note that the implementation requires a gcc with plugin support,
100137 + i.e., gcc 4.5 or newer. You may need to install the supporting
100138 + headers explicitly in addition to the normal gcc package.
100139 +
100140 + Note that if some code really has to modify constified variables
100141 + then the source code will have to be patched to allow it. Examples
100142 + can be found in PaX itself (the no_const attribute) and for some
100143 + out-of-tree modules at http://www.grsecurity.net/~paxguy1/ .
100144 +
100145 +config PAX_USERCOPY
100146 + bool "Harden heap object copies between kernel and userland"
100147 + default y if GRKERNSEC_CONFIG_AUTO
100148 + depends on ARM || IA64 || PPC || SPARC || X86
100149 + depends on GRKERNSEC && (SLAB || SLUB || SLOB)
100150 + select PAX_USERCOPY_SLABS
100151 + help
100152 + By saying Y here the kernel will enforce the size of heap objects
100153 + when they are copied in either direction between the kernel and
100154 + userland, even if only a part of the heap object is copied.
100155 +
100156 + Specifically, this checking prevents information leaking from the
100157 + kernel heap during kernel to userland copies (if the kernel heap
100158 + object is otherwise fully initialized) and prevents kernel heap
100159 + overflows during userland to kernel copies.
100160 +
100161 + Note that the current implementation provides the strictest bounds
100162 + checks for the SLUB allocator.
100163 +
100164 + Enabling this option also enables per-slab cache protection against
100165 + data in a given cache being copied into/out of via userland
100166 + accessors. Though the whitelist of regions will be reduced over
100167 + time, it notably protects important data structures like task structs.
100168 +
100169 + If frame pointers are enabled on x86, this option will also restrict
100170 + copies into and out of the kernel stack to local variables within a
100171 + single frame.
100172 +
100173 + Since this has a negligible performance impact, you should enable
100174 + this feature.
100175 +
100176 +config PAX_USERCOPY_DEBUG
100177 + bool
100178 + depends on X86 && PAX_USERCOPY
100179 + default n
100180 +
100181 +config PAX_SIZE_OVERFLOW
100182 + bool "Prevent various integer overflows in function size parameters"
100183 + default y if GRKERNSEC_CONFIG_AUTO
100184 + depends on X86
100185 + help
100186 + By saying Y here the kernel recomputes expressions of function
100187 + arguments marked by a size_overflow attribute with double integer
100188 + precision (DImode/TImode for 32/64 bit integer types).
100189 +
100190 + The recomputed argument is checked against TYPE_MAX and an event
100191 + is logged on overflow and the triggering process is killed.
100192 +
100193 + Homepage: http://www.grsecurity.net/~ephox/overflow_plugin/
100194 +
100195 + Note that the implementation requires a gcc with plugin support,
100196 + i.e., gcc 4.5 or newer. You may need to install the supporting
100197 + headers explicitly in addition to the normal gcc package.
100198 +
100199 +config PAX_LATENT_ENTROPY
100200 + bool "Generate some entropy during boot and runtime"
100201 + default y if GRKERNSEC_CONFIG_AUTO
100202 + help
100203 + By saying Y here the kernel will instrument some kernel code to
100204 + extract some entropy from both original and artificially created
100205 + program state. This will help especially embedded systems where
100206 + there is little 'natural' source of entropy normally. The cost
100207 + is some slowdown of the boot process and fork and irq processing.
100208 +
100209 + When pax_extra_latent_entropy is passed on the kernel command line,
100210 + entropy will be extracted from up to the first 4GB of RAM while the
100211 + runtime memory allocator is being initialized. This costs even more
100212 + slowdown of the boot process.
100213 +
100214 + Note that the implementation requires a gcc with plugin support,
100215 + i.e., gcc 4.5 or newer. You may need to install the supporting
100216 + headers explicitly in addition to the normal gcc package.
100217 +
100218 + Note that entropy extracted this way is not cryptographically
100219 + secure!
100220 +
100221 +endmenu
100222 +
100223 +endmenu
100224 +
100225 +source grsecurity/Kconfig
100226 +
100227 +endmenu
100228 +
100229 +endmenu
100230 +
100231 source security/keys/Kconfig
100232
100233 config SECURITY_DMESG_RESTRICT
100234 @@ -103,7 +1055,7 @@ config INTEL_TXT
100235 config LSM_MMAP_MIN_ADDR
100236 int "Low address space for LSM to protect from user allocation"
100237 depends on SECURITY && SECURITY_SELINUX
100238 - default 32768 if ARM
100239 + default 32768 if ALPHA || ARM || PARISC || SPARC32
100240 default 65536
100241 help
100242 This is the portion of low virtual memory which should be protected
100243 diff --git a/security/apparmor/lsm.c b/security/apparmor/lsm.c
100244 index fb99e18..b3e0bbb 100644
100245 --- a/security/apparmor/lsm.c
100246 +++ b/security/apparmor/lsm.c
100247 @@ -615,7 +615,7 @@ static int apparmor_task_setrlimit(struct task_struct *task,
100248 return error;
100249 }
100250
100251 -static struct security_operations apparmor_ops = {
100252 +static struct security_operations apparmor_ops __read_only = {
100253 .name = "apparmor",
100254
100255 .ptrace_access_check = apparmor_ptrace_access_check,
100256 diff --git a/security/commoncap.c b/security/commoncap.c
100257 index b9d613e..f68305c 100644
100258 --- a/security/commoncap.c
100259 +++ b/security/commoncap.c
100260 @@ -424,6 +424,32 @@ int get_vfs_caps_from_disk(const struct dentry *dentry, struct cpu_vfs_cap_data
100261 return 0;
100262 }
100263
100264 +/* returns:
100265 + 1 for suid privilege
100266 + 2 for sgid privilege
100267 + 3 for fscap privilege
100268 +*/
100269 +int is_privileged_binary(const struct dentry *dentry)
100270 +{
100271 + struct cpu_vfs_cap_data capdata;
100272 + struct inode *inode = dentry->d_inode;
100273 +
100274 + if (!inode || S_ISDIR(inode->i_mode))
100275 + return 0;
100276 +
100277 + if (inode->i_mode & S_ISUID)
100278 + return 1;
100279 + if ((inode->i_mode & (S_ISGID | S_IXGRP)) == (S_ISGID | S_IXGRP))
100280 + return 2;
100281 +
100282 + if (!get_vfs_caps_from_disk(dentry, &capdata)) {
100283 + if (!cap_isclear(capdata.inheritable) || !cap_isclear(capdata.permitted))
100284 + return 3;
100285 + }
100286 +
100287 + return 0;
100288 +}
100289 +
100290 /*
100291 * Attempt to get the on-exec apply capability sets for an executable file from
100292 * its xattrs and, if present, apply them to the proposed credentials being
100293 @@ -592,6 +618,9 @@ int cap_bprm_secureexec(struct linux_binprm *bprm)
100294 const struct cred *cred = current_cred();
100295 kuid_t root_uid = make_kuid(cred->user_ns, 0);
100296
100297 + if (gr_acl_enable_at_secure())
100298 + return 1;
100299 +
100300 if (!uid_eq(cred->uid, root_uid)) {
100301 if (bprm->cap_effective)
100302 return 1;
100303 diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h
100304 index b3dd616..4bb17f3 100644
100305 --- a/security/integrity/ima/ima.h
100306 +++ b/security/integrity/ima/ima.h
100307 @@ -83,8 +83,8 @@ int ima_init_crypto(void);
100308 extern spinlock_t ima_queue_lock;
100309
100310 struct ima_h_table {
100311 - atomic_long_t len; /* number of stored measurements in the list */
100312 - atomic_long_t violations;
100313 + atomic_long_unchecked_t len; /* number of stored measurements in the list */
100314 + atomic_long_unchecked_t violations;
100315 struct hlist_head queue[IMA_MEASURE_HTABLE_SIZE];
100316 };
100317 extern struct ima_h_table ima_htable;
100318 diff --git a/security/integrity/ima/ima_api.c b/security/integrity/ima/ima_api.c
100319 index 1c03e8f1..398a941 100644
100320 --- a/security/integrity/ima/ima_api.c
100321 +++ b/security/integrity/ima/ima_api.c
100322 @@ -79,7 +79,7 @@ void ima_add_violation(struct inode *inode, const unsigned char *filename,
100323 int result;
100324
100325 /* can overflow, only indicator */
100326 - atomic_long_inc(&ima_htable.violations);
100327 + atomic_long_inc_unchecked(&ima_htable.violations);
100328
100329 entry = kmalloc(sizeof(*entry), GFP_KERNEL);
100330 if (!entry) {
100331 diff --git a/security/integrity/ima/ima_fs.c b/security/integrity/ima/ima_fs.c
100332 index 38477c9..87a60c7 100644
100333 --- a/security/integrity/ima/ima_fs.c
100334 +++ b/security/integrity/ima/ima_fs.c
100335 @@ -28,12 +28,12 @@
100336 static int valid_policy = 1;
100337 #define TMPBUFLEN 12
100338 static ssize_t ima_show_htable_value(char __user *buf, size_t count,
100339 - loff_t *ppos, atomic_long_t *val)
100340 + loff_t *ppos, atomic_long_unchecked_t *val)
100341 {
100342 char tmpbuf[TMPBUFLEN];
100343 ssize_t len;
100344
100345 - len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read(val));
100346 + len = scnprintf(tmpbuf, TMPBUFLEN, "%li\n", atomic_long_read_unchecked(val));
100347 return simple_read_from_buffer(buf, count, ppos, tmpbuf, len);
100348 }
100349
100350 diff --git a/security/integrity/ima/ima_queue.c b/security/integrity/ima/ima_queue.c
100351 index ff63fe0..809cd96 100644
100352 --- a/security/integrity/ima/ima_queue.c
100353 +++ b/security/integrity/ima/ima_queue.c
100354 @@ -80,7 +80,7 @@ static int ima_add_digest_entry(struct ima_template_entry *entry)
100355 INIT_LIST_HEAD(&qe->later);
100356 list_add_tail_rcu(&qe->later, &ima_measurements);
100357
100358 - atomic_long_inc(&ima_htable.len);
100359 + atomic_long_inc_unchecked(&ima_htable.len);
100360 key = ima_hash_key(entry->digest);
100361 hlist_add_head_rcu(&qe->hnext, &ima_htable.queue[key]);
100362 return 0;
100363 diff --git a/security/keys/compat.c b/security/keys/compat.c
100364 index d65fa7f..cbfe366 100644
100365 --- a/security/keys/compat.c
100366 +++ b/security/keys/compat.c
100367 @@ -44,7 +44,7 @@ static long compat_keyctl_instantiate_key_iov(
100368 if (ret == 0)
100369 goto no_payload_free;
100370
100371 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100372 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100373 err:
100374 if (iov != iovstack)
100375 kfree(iov);
100376 diff --git a/security/keys/internal.h b/security/keys/internal.h
100377 index d4f1468..cc52f92 100644
100378 --- a/security/keys/internal.h
100379 +++ b/security/keys/internal.h
100380 @@ -242,7 +242,7 @@ extern long keyctl_instantiate_key_iov(key_serial_t,
100381 extern long keyctl_invalidate_key(key_serial_t);
100382
100383 extern long keyctl_instantiate_key_common(key_serial_t,
100384 - const struct iovec *,
100385 + const struct iovec __user *,
100386 unsigned, size_t, key_serial_t);
100387
100388 /*
100389 diff --git a/security/keys/key.c b/security/keys/key.c
100390 index 8fb7c7b..ba3610d 100644
100391 --- a/security/keys/key.c
100392 +++ b/security/keys/key.c
100393 @@ -284,7 +284,7 @@ struct key *key_alloc(struct key_type *type, const char *desc,
100394
100395 atomic_set(&key->usage, 1);
100396 init_rwsem(&key->sem);
100397 - lockdep_set_class(&key->sem, &type->lock_class);
100398 + lockdep_set_class(&key->sem, (struct lock_class_key *)&type->lock_class);
100399 key->type = type;
100400 key->user = user;
100401 key->quotalen = quotalen;
100402 @@ -1032,7 +1032,9 @@ int register_key_type(struct key_type *ktype)
100403 struct key_type *p;
100404 int ret;
100405
100406 - memset(&ktype->lock_class, 0, sizeof(ktype->lock_class));
100407 + pax_open_kernel();
100408 + memset((void *)&ktype->lock_class, 0, sizeof(ktype->lock_class));
100409 + pax_close_kernel();
100410
100411 ret = -EEXIST;
100412 down_write(&key_types_sem);
100413 @@ -1044,7 +1046,7 @@ int register_key_type(struct key_type *ktype)
100414 }
100415
100416 /* store the type */
100417 - list_add(&ktype->link, &key_types_list);
100418 + pax_list_add((struct list_head *)&ktype->link, &key_types_list);
100419
100420 pr_notice("Key type %s registered\n", ktype->name);
100421 ret = 0;
100422 @@ -1066,7 +1068,7 @@ EXPORT_SYMBOL(register_key_type);
100423 void unregister_key_type(struct key_type *ktype)
100424 {
100425 down_write(&key_types_sem);
100426 - list_del_init(&ktype->link);
100427 + pax_list_del_init((struct list_head *)&ktype->link);
100428 downgrade_write(&key_types_sem);
100429 key_gc_keytype(ktype);
100430 pr_notice("Key type %s unregistered\n", ktype->name);
100431 @@ -1084,10 +1086,10 @@ void __init key_init(void)
100432 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, NULL);
100433
100434 /* add the special key types */
100435 - list_add_tail(&key_type_keyring.link, &key_types_list);
100436 - list_add_tail(&key_type_dead.link, &key_types_list);
100437 - list_add_tail(&key_type_user.link, &key_types_list);
100438 - list_add_tail(&key_type_logon.link, &key_types_list);
100439 + pax_list_add_tail((struct list_head *)&key_type_keyring.link, &key_types_list);
100440 + pax_list_add_tail((struct list_head *)&key_type_dead.link, &key_types_list);
100441 + pax_list_add_tail((struct list_head *)&key_type_user.link, &key_types_list);
100442 + pax_list_add_tail((struct list_head *)&key_type_logon.link, &key_types_list);
100443
100444 /* record the root user tracking */
100445 rb_link_node(&root_key_user.node,
100446 diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
100447 index 33cfd27..842fc5a 100644
100448 --- a/security/keys/keyctl.c
100449 +++ b/security/keys/keyctl.c
100450 @@ -987,7 +987,7 @@ static int keyctl_change_reqkey_auth(struct key *key)
100451 /*
100452 * Copy the iovec data from userspace
100453 */
100454 -static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100455 +static long copy_from_user_iovec(void *buffer, const struct iovec __user *iov,
100456 unsigned ioc)
100457 {
100458 for (; ioc > 0; ioc--) {
100459 @@ -1009,7 +1009,7 @@ static long copy_from_user_iovec(void *buffer, const struct iovec *iov,
100460 * If successful, 0 will be returned.
100461 */
100462 long keyctl_instantiate_key_common(key_serial_t id,
100463 - const struct iovec *payload_iov,
100464 + const struct iovec __user *payload_iov,
100465 unsigned ioc,
100466 size_t plen,
100467 key_serial_t ringid)
100468 @@ -1104,7 +1104,7 @@ long keyctl_instantiate_key(key_serial_t id,
100469 [0].iov_len = plen
100470 };
100471
100472 - return keyctl_instantiate_key_common(id, iov, 1, plen, ringid);
100473 + return keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, 1, plen, ringid);
100474 }
100475
100476 return keyctl_instantiate_key_common(id, NULL, 0, 0, ringid);
100477 @@ -1137,7 +1137,7 @@ long keyctl_instantiate_key_iov(key_serial_t id,
100478 if (ret == 0)
100479 goto no_payload_free;
100480
100481 - ret = keyctl_instantiate_key_common(id, iov, ioc, ret, ringid);
100482 + ret = keyctl_instantiate_key_common(id, (const struct iovec __force_user *)iov, ioc, ret, ringid);
100483 err:
100484 if (iov != iovstack)
100485 kfree(iov);
100486 diff --git a/security/keys/keyring.c b/security/keys/keyring.c
100487 index 6ece7f2..ecdb55c 100644
100488 --- a/security/keys/keyring.c
100489 +++ b/security/keys/keyring.c
100490 @@ -227,16 +227,16 @@ static long keyring_read(const struct key *keyring,
100491 ret = -EFAULT;
100492
100493 for (loop = 0; loop < klist->nkeys; loop++) {
100494 + key_serial_t serial;
100495 key = rcu_deref_link_locked(klist, loop,
100496 keyring);
100497 + serial = key->serial;
100498
100499 tmp = sizeof(key_serial_t);
100500 if (tmp > buflen)
100501 tmp = buflen;
100502
100503 - if (copy_to_user(buffer,
100504 - &key->serial,
100505 - tmp) != 0)
100506 + if (copy_to_user(buffer, &serial, tmp))
100507 goto error;
100508
100509 buflen -= tmp;
100510 diff --git a/security/min_addr.c b/security/min_addr.c
100511 index f728728..6457a0c 100644
100512 --- a/security/min_addr.c
100513 +++ b/security/min_addr.c
100514 @@ -14,6 +14,7 @@ unsigned long dac_mmap_min_addr = CONFIG_DEFAULT_MMAP_MIN_ADDR;
100515 */
100516 static void update_mmap_min_addr(void)
100517 {
100518 +#ifndef SPARC
100519 #ifdef CONFIG_LSM_MMAP_MIN_ADDR
100520 if (dac_mmap_min_addr > CONFIG_LSM_MMAP_MIN_ADDR)
100521 mmap_min_addr = dac_mmap_min_addr;
100522 @@ -22,6 +23,7 @@ static void update_mmap_min_addr(void)
100523 #else
100524 mmap_min_addr = dac_mmap_min_addr;
100525 #endif
100526 +#endif
100527 }
100528
100529 /*
100530 diff --git a/security/security.c b/security/security.c
100531 index 4dc31f4..eabcf41 100644
100532 --- a/security/security.c
100533 +++ b/security/security.c
100534 @@ -33,8 +33,8 @@
100535 static __initdata char chosen_lsm[SECURITY_NAME_MAX + 1] =
100536 CONFIG_DEFAULT_SECURITY;
100537
100538 -static struct security_operations *security_ops;
100539 -static struct security_operations default_security_ops = {
100540 +struct security_operations *security_ops __read_only;
100541 +struct security_operations default_security_ops __read_only = {
100542 .name = "default",
100543 };
100544
100545 @@ -73,11 +73,6 @@ int __init security_init(void)
100546 return 0;
100547 }
100548
100549 -void reset_security_ops(void)
100550 -{
100551 - security_ops = &default_security_ops;
100552 -}
100553 -
100554 /* Save user chosen LSM */
100555 static int __init choose_lsm(char *str)
100556 {
100557 diff --git a/security/selinux/avc.c b/security/selinux/avc.c
100558 index fc3e662..7844c60 100644
100559 --- a/security/selinux/avc.c
100560 +++ b/security/selinux/avc.c
100561 @@ -59,7 +59,7 @@ struct avc_node {
100562 struct avc_cache {
100563 struct hlist_head slots[AVC_CACHE_SLOTS]; /* head for avc_node->list */
100564 spinlock_t slots_lock[AVC_CACHE_SLOTS]; /* lock for writes */
100565 - atomic_t lru_hint; /* LRU hint for reclaim scan */
100566 + atomic_unchecked_t lru_hint; /* LRU hint for reclaim scan */
100567 atomic_t active_nodes;
100568 u32 latest_notif; /* latest revocation notification */
100569 };
100570 @@ -167,7 +167,7 @@ void __init avc_init(void)
100571 spin_lock_init(&avc_cache.slots_lock[i]);
100572 }
100573 atomic_set(&avc_cache.active_nodes, 0);
100574 - atomic_set(&avc_cache.lru_hint, 0);
100575 + atomic_set_unchecked(&avc_cache.lru_hint, 0);
100576
100577 avc_node_cachep = kmem_cache_create("avc_node", sizeof(struct avc_node),
100578 0, SLAB_PANIC, NULL);
100579 @@ -242,7 +242,7 @@ static inline int avc_reclaim_node(void)
100580 spinlock_t *lock;
100581
100582 for (try = 0, ecx = 0; try < AVC_CACHE_SLOTS; try++) {
100583 - hvalue = atomic_inc_return(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100584 + hvalue = atomic_inc_return_unchecked(&avc_cache.lru_hint) & (AVC_CACHE_SLOTS - 1);
100585 head = &avc_cache.slots[hvalue];
100586 lock = &avc_cache.slots_lock[hvalue];
100587
100588 diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
100589 index 392a044..5e931be 100644
100590 --- a/security/selinux/hooks.c
100591 +++ b/security/selinux/hooks.c
100592 @@ -5693,7 +5693,7 @@ static int selinux_key_getsecurity(struct key *key, char **_buffer)
100593
100594 #endif
100595
100596 -static struct security_operations selinux_ops = {
100597 +static struct security_operations selinux_ops __read_only = {
100598 .name = "selinux",
100599
100600 .ptrace_access_check = selinux_ptrace_access_check,
100601 @@ -6045,6 +6045,9 @@ static void selinux_nf_ip_exit(void)
100602 #ifdef CONFIG_SECURITY_SELINUX_DISABLE
100603 static int selinux_disabled;
100604
100605 +extern struct security_operations *security_ops;
100606 +extern struct security_operations default_security_ops;
100607 +
100608 int selinux_disable(void)
100609 {
100610 if (ss_initialized) {
100611 @@ -6062,7 +6065,9 @@ int selinux_disable(void)
100612 selinux_disabled = 1;
100613 selinux_enabled = 0;
100614
100615 - reset_security_ops();
100616 + pax_open_kernel();
100617 + security_ops = &default_security_ops;
100618 + pax_close_kernel();
100619
100620 /* Try to destroy the avc node cache */
100621 avc_disable();
100622 diff --git a/security/selinux/include/xfrm.h b/security/selinux/include/xfrm.h
100623 index c1af4e1..bcb003c 100644
100624 --- a/security/selinux/include/xfrm.h
100625 +++ b/security/selinux/include/xfrm.h
100626 @@ -53,7 +53,7 @@ static inline void selinux_xfrm_notify_policyload(void)
100627 {
100628 struct net *net;
100629
100630 - atomic_inc(&flow_cache_genid);
100631 + atomic_inc_unchecked(&flow_cache_genid);
100632 rtnl_lock();
100633 for_each_net(net)
100634 rt_genid_bump_all(net);
100635 diff --git a/security/smack/smack_lsm.c b/security/smack/smack_lsm.c
100636 index 8825375..97a623b 100644
100637 --- a/security/smack/smack_lsm.c
100638 +++ b/security/smack/smack_lsm.c
100639 @@ -3726,7 +3726,7 @@ static int smack_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen)
100640 return 0;
100641 }
100642
100643 -struct security_operations smack_ops = {
100644 +struct security_operations smack_ops __read_only = {
100645 .name = "smack",
100646
100647 .ptrace_access_check = smack_ptrace_access_check,
100648 diff --git a/security/tomoyo/mount.c b/security/tomoyo/mount.c
100649 index 390c646..f2f8db3 100644
100650 --- a/security/tomoyo/mount.c
100651 +++ b/security/tomoyo/mount.c
100652 @@ -118,6 +118,10 @@ static int tomoyo_mount_acl(struct tomoyo_request_info *r,
100653 type == tomoyo_mounts[TOMOYO_MOUNT_MOVE]) {
100654 need_dev = -1; /* dev_name is a directory */
100655 } else {
100656 + if (!capable(CAP_SYS_ADMIN)) {
100657 + error = -EPERM;
100658 + goto out;
100659 + }
100660 fstype = get_fs_type(type);
100661 if (!fstype) {
100662 error = -ENODEV;
100663 diff --git a/security/tomoyo/tomoyo.c b/security/tomoyo/tomoyo.c
100664 index f0b756e..b129202 100644
100665 --- a/security/tomoyo/tomoyo.c
100666 +++ b/security/tomoyo/tomoyo.c
100667 @@ -503,7 +503,7 @@ static int tomoyo_socket_sendmsg(struct socket *sock, struct msghdr *msg,
100668 * tomoyo_security_ops is a "struct security_operations" which is used for
100669 * registering TOMOYO.
100670 */
100671 -static struct security_operations tomoyo_security_ops = {
100672 +static struct security_operations tomoyo_security_ops __read_only = {
100673 .name = "tomoyo",
100674 .cred_alloc_blank = tomoyo_cred_alloc_blank,
100675 .cred_prepare = tomoyo_cred_prepare,
100676 diff --git a/security/yama/Kconfig b/security/yama/Kconfig
100677 index 20ef514..4182bed 100644
100678 --- a/security/yama/Kconfig
100679 +++ b/security/yama/Kconfig
100680 @@ -1,6 +1,6 @@
100681 config SECURITY_YAMA
100682 bool "Yama support"
100683 - depends on SECURITY
100684 + depends on SECURITY && !GRKERNSEC
100685 select SECURITYFS
100686 select SECURITY_PATH
100687 default n
100688 diff --git a/security/yama/yama_lsm.c b/security/yama/yama_lsm.c
100689 index 13c88fbc..f8c115e 100644
100690 --- a/security/yama/yama_lsm.c
100691 +++ b/security/yama/yama_lsm.c
100692 @@ -365,7 +365,7 @@ int yama_ptrace_traceme(struct task_struct *parent)
100693 }
100694
100695 #ifndef CONFIG_SECURITY_YAMA_STACKED
100696 -static struct security_operations yama_ops = {
100697 +static struct security_operations yama_ops __read_only = {
100698 .name = "yama",
100699
100700 .ptrace_access_check = yama_ptrace_access_check,
100701 @@ -376,28 +376,24 @@ static struct security_operations yama_ops = {
100702 #endif
100703
100704 #ifdef CONFIG_SYSCTL
100705 +static int zero __read_only;
100706 +static int max_scope __read_only = YAMA_SCOPE_NO_ATTACH;
100707 +
100708 static int yama_dointvec_minmax(struct ctl_table *table, int write,
100709 void __user *buffer, size_t *lenp, loff_t *ppos)
100710 {
100711 - int rc;
100712 + ctl_table_no_const yama_table;
100713
100714 if (write && !capable(CAP_SYS_PTRACE))
100715 return -EPERM;
100716
100717 - rc = proc_dointvec_minmax(table, write, buffer, lenp, ppos);
100718 - if (rc)
100719 - return rc;
100720 -
100721 + yama_table = *table;
100722 /* Lock the max value if it ever gets set. */
100723 - if (write && *(int *)table->data == *(int *)table->extra2)
100724 - table->extra1 = table->extra2;
100725 -
100726 - return rc;
100727 + if (ptrace_scope == max_scope)
100728 + yama_table.extra1 = &max_scope;
100729 + return proc_dointvec_minmax(&yama_table, write, buffer, lenp, ppos);
100730 }
100731
100732 -static int zero;
100733 -static int max_scope = YAMA_SCOPE_NO_ATTACH;
100734 -
100735 struct ctl_path yama_sysctl_path[] = {
100736 { .procname = "kernel", },
100737 { .procname = "yama", },
100738 diff --git a/sound/aoa/codecs/onyx.c b/sound/aoa/codecs/onyx.c
100739 index 4cedc69..e59d8a3 100644
100740 --- a/sound/aoa/codecs/onyx.c
100741 +++ b/sound/aoa/codecs/onyx.c
100742 @@ -54,7 +54,7 @@ struct onyx {
100743 spdif_locked:1,
100744 analog_locked:1,
100745 original_mute:2;
100746 - int open_count;
100747 + local_t open_count;
100748 struct codec_info *codec_info;
100749
100750 /* mutex serializes concurrent access to the device
100751 @@ -753,7 +753,7 @@ static int onyx_open(struct codec_info_item *cii,
100752 struct onyx *onyx = cii->codec_data;
100753
100754 mutex_lock(&onyx->mutex);
100755 - onyx->open_count++;
100756 + local_inc(&onyx->open_count);
100757 mutex_unlock(&onyx->mutex);
100758
100759 return 0;
100760 @@ -765,8 +765,7 @@ static int onyx_close(struct codec_info_item *cii,
100761 struct onyx *onyx = cii->codec_data;
100762
100763 mutex_lock(&onyx->mutex);
100764 - onyx->open_count--;
100765 - if (!onyx->open_count)
100766 + if (local_dec_and_test(&onyx->open_count))
100767 onyx->spdif_locked = onyx->analog_locked = 0;
100768 mutex_unlock(&onyx->mutex);
100769
100770 diff --git a/sound/aoa/codecs/onyx.h b/sound/aoa/codecs/onyx.h
100771 index ffd2025..df062c9 100644
100772 --- a/sound/aoa/codecs/onyx.h
100773 +++ b/sound/aoa/codecs/onyx.h
100774 @@ -11,6 +11,7 @@
100775 #include <linux/i2c.h>
100776 #include <asm/pmac_low_i2c.h>
100777 #include <asm/prom.h>
100778 +#include <asm/local.h>
100779
100780 /* PCM3052 register definitions */
100781
100782 diff --git a/sound/core/oss/pcm_oss.c b/sound/core/oss/pcm_oss.c
100783 index 4c1cc51..16040040 100644
100784 --- a/sound/core/oss/pcm_oss.c
100785 +++ b/sound/core/oss/pcm_oss.c
100786 @@ -1189,10 +1189,10 @@ snd_pcm_sframes_t snd_pcm_oss_write3(struct snd_pcm_substream *substream, const
100787 if (in_kernel) {
100788 mm_segment_t fs;
100789 fs = snd_enter_user();
100790 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100791 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100792 snd_leave_user(fs);
100793 } else {
100794 - ret = snd_pcm_lib_write(substream, (void __force __user *)ptr, frames);
100795 + ret = snd_pcm_lib_write(substream, (void __force_user *)ptr, frames);
100796 }
100797 if (ret != -EPIPE && ret != -ESTRPIPE)
100798 break;
100799 @@ -1234,10 +1234,10 @@ snd_pcm_sframes_t snd_pcm_oss_read3(struct snd_pcm_substream *substream, char *p
100800 if (in_kernel) {
100801 mm_segment_t fs;
100802 fs = snd_enter_user();
100803 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100804 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100805 snd_leave_user(fs);
100806 } else {
100807 - ret = snd_pcm_lib_read(substream, (void __force __user *)ptr, frames);
100808 + ret = snd_pcm_lib_read(substream, (void __force_user *)ptr, frames);
100809 }
100810 if (ret == -EPIPE) {
100811 if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) {
100812 @@ -1337,7 +1337,7 @@ static ssize_t snd_pcm_oss_write2(struct snd_pcm_substream *substream, const cha
100813 struct snd_pcm_plugin_channel *channels;
100814 size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
100815 if (!in_kernel) {
100816 - if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
100817 + if (copy_from_user(runtime->oss.buffer, (const char __force_user *)buf, bytes))
100818 return -EFAULT;
100819 buf = runtime->oss.buffer;
100820 }
100821 @@ -1407,7 +1407,7 @@ static ssize_t snd_pcm_oss_write1(struct snd_pcm_substream *substream, const cha
100822 }
100823 } else {
100824 tmp = snd_pcm_oss_write2(substream,
100825 - (const char __force *)buf,
100826 + (const char __force_kernel *)buf,
100827 runtime->oss.period_bytes, 0);
100828 if (tmp <= 0)
100829 goto err;
100830 @@ -1433,7 +1433,7 @@ static ssize_t snd_pcm_oss_read2(struct snd_pcm_substream *substream, char *buf,
100831 struct snd_pcm_runtime *runtime = substream->runtime;
100832 snd_pcm_sframes_t frames, frames1;
100833 #ifdef CONFIG_SND_PCM_OSS_PLUGINS
100834 - char __user *final_dst = (char __force __user *)buf;
100835 + char __user *final_dst = (char __force_user *)buf;
100836 if (runtime->oss.plugin_first) {
100837 struct snd_pcm_plugin_channel *channels;
100838 size_t oss_frame_bytes = (runtime->oss.plugin_last->dst_width * runtime->oss.plugin_last->dst_format.channels) / 8;
100839 @@ -1495,7 +1495,7 @@ static ssize_t snd_pcm_oss_read1(struct snd_pcm_substream *substream, char __use
100840 xfer += tmp;
100841 runtime->oss.buffer_used -= tmp;
100842 } else {
100843 - tmp = snd_pcm_oss_read2(substream, (char __force *)buf,
100844 + tmp = snd_pcm_oss_read2(substream, (char __force_kernel *)buf,
100845 runtime->oss.period_bytes, 0);
100846 if (tmp <= 0)
100847 goto err;
100848 @@ -1663,7 +1663,7 @@ static int snd_pcm_oss_sync(struct snd_pcm_oss_file *pcm_oss_file)
100849 size1);
100850 size1 /= runtime->channels; /* frames */
100851 fs = snd_enter_user();
100852 - snd_pcm_lib_write(substream, (void __force __user *)runtime->oss.buffer, size1);
100853 + snd_pcm_lib_write(substream, (void __force_user *)runtime->oss.buffer, size1);
100854 snd_leave_user(fs);
100855 }
100856 } else if (runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) {
100857 diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c
100858 index af49721..e85058e 100644
100859 --- a/sound/core/pcm_compat.c
100860 +++ b/sound/core/pcm_compat.c
100861 @@ -31,7 +31,7 @@ static int snd_pcm_ioctl_delay_compat(struct snd_pcm_substream *substream,
100862 int err;
100863
100864 fs = snd_enter_user();
100865 - err = snd_pcm_delay(substream, &delay);
100866 + err = snd_pcm_delay(substream, (snd_pcm_sframes_t __force_user *)&delay);
100867 snd_leave_user(fs);
100868 if (err < 0)
100869 return err;
100870 diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
100871 index a68d4c6..72af3cf 100644
100872 --- a/sound/core/pcm_native.c
100873 +++ b/sound/core/pcm_native.c
100874 @@ -2809,11 +2809,11 @@ int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream,
100875 switch (substream->stream) {
100876 case SNDRV_PCM_STREAM_PLAYBACK:
100877 result = snd_pcm_playback_ioctl1(NULL, substream, cmd,
100878 - (void __user *)arg);
100879 + (void __force_user *)arg);
100880 break;
100881 case SNDRV_PCM_STREAM_CAPTURE:
100882 result = snd_pcm_capture_ioctl1(NULL, substream, cmd,
100883 - (void __user *)arg);
100884 + (void __force_user *)arg);
100885 break;
100886 default:
100887 result = -EINVAL;
100888 diff --git a/sound/core/seq/seq_device.c b/sound/core/seq/seq_device.c
100889 index 040c60e..989a19a 100644
100890 --- a/sound/core/seq/seq_device.c
100891 +++ b/sound/core/seq/seq_device.c
100892 @@ -64,7 +64,7 @@ struct ops_list {
100893 int argsize; /* argument size */
100894
100895 /* operators */
100896 - struct snd_seq_dev_ops ops;
100897 + struct snd_seq_dev_ops *ops;
100898
100899 /* registered devices */
100900 struct list_head dev_list; /* list of devices */
100901 @@ -333,7 +333,7 @@ int snd_seq_device_register_driver(char *id, struct snd_seq_dev_ops *entry,
100902
100903 mutex_lock(&ops->reg_mutex);
100904 /* copy driver operators */
100905 - ops->ops = *entry;
100906 + ops->ops = entry;
100907 ops->driver |= DRIVER_LOADED;
100908 ops->argsize = argsize;
100909
100910 @@ -463,7 +463,7 @@ static int init_device(struct snd_seq_device *dev, struct ops_list *ops)
100911 dev->name, ops->id, ops->argsize, dev->argsize);
100912 return -EINVAL;
100913 }
100914 - if (ops->ops.init_device(dev) >= 0) {
100915 + if (ops->ops->init_device(dev) >= 0) {
100916 dev->status = SNDRV_SEQ_DEVICE_REGISTERED;
100917 ops->num_init_devices++;
100918 } else {
100919 @@ -490,7 +490,7 @@ static int free_device(struct snd_seq_device *dev, struct ops_list *ops)
100920 dev->name, ops->id, ops->argsize, dev->argsize);
100921 return -EINVAL;
100922 }
100923 - if ((result = ops->ops.free_device(dev)) >= 0 || result == -ENXIO) {
100924 + if ((result = ops->ops->free_device(dev)) >= 0 || result == -ENXIO) {
100925 dev->status = SNDRV_SEQ_DEVICE_FREE;
100926 dev->driver_data = NULL;
100927 ops->num_init_devices--;
100928 diff --git a/sound/core/sound.c b/sound/core/sound.c
100929 index f002bd9..c462985 100644
100930 --- a/sound/core/sound.c
100931 +++ b/sound/core/sound.c
100932 @@ -86,7 +86,7 @@ static void snd_request_other(int minor)
100933 case SNDRV_MINOR_TIMER: str = "snd-timer"; break;
100934 default: return;
100935 }
100936 - request_module(str);
100937 + request_module("%s", str);
100938 }
100939
100940 #endif /* modular kernel */
100941 diff --git a/sound/drivers/mts64.c b/sound/drivers/mts64.c
100942 index 4e0dd22..7a1f32c 100644
100943 --- a/sound/drivers/mts64.c
100944 +++ b/sound/drivers/mts64.c
100945 @@ -29,6 +29,7 @@
100946 #include <sound/initval.h>
100947 #include <sound/rawmidi.h>
100948 #include <sound/control.h>
100949 +#include <asm/local.h>
100950
100951 #define CARD_NAME "Miditerminal 4140"
100952 #define DRIVER_NAME "MTS64"
100953 @@ -67,7 +68,7 @@ struct mts64 {
100954 struct pardevice *pardev;
100955 int pardev_claimed;
100956
100957 - int open_count;
100958 + local_t open_count;
100959 int current_midi_output_port;
100960 int current_midi_input_port;
100961 u8 mode[MTS64_NUM_INPUT_PORTS];
100962 @@ -697,7 +698,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100963 {
100964 struct mts64 *mts = substream->rmidi->private_data;
100965
100966 - if (mts->open_count == 0) {
100967 + if (local_read(&mts->open_count) == 0) {
100968 /* We don't need a spinlock here, because this is just called
100969 if the device has not been opened before.
100970 So there aren't any IRQs from the device */
100971 @@ -705,7 +706,7 @@ static int snd_mts64_rawmidi_open(struct snd_rawmidi_substream *substream)
100972
100973 msleep(50);
100974 }
100975 - ++(mts->open_count);
100976 + local_inc(&mts->open_count);
100977
100978 return 0;
100979 }
100980 @@ -715,8 +716,7 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100981 struct mts64 *mts = substream->rmidi->private_data;
100982 unsigned long flags;
100983
100984 - --(mts->open_count);
100985 - if (mts->open_count == 0) {
100986 + if (local_dec_return(&mts->open_count) == 0) {
100987 /* We need the spinlock_irqsave here because we can still
100988 have IRQs at this point */
100989 spin_lock_irqsave(&mts->lock, flags);
100990 @@ -725,8 +725,8 @@ static int snd_mts64_rawmidi_close(struct snd_rawmidi_substream *substream)
100991
100992 msleep(500);
100993
100994 - } else if (mts->open_count < 0)
100995 - mts->open_count = 0;
100996 + } else if (local_read(&mts->open_count) < 0)
100997 + local_set(&mts->open_count, 0);
100998
100999 return 0;
101000 }
101001 diff --git a/sound/drivers/opl4/opl4_lib.c b/sound/drivers/opl4/opl4_lib.c
101002 index b953fb4..1999c01 100644
101003 --- a/sound/drivers/opl4/opl4_lib.c
101004 +++ b/sound/drivers/opl4/opl4_lib.c
101005 @@ -29,7 +29,7 @@ MODULE_AUTHOR("Clemens Ladisch <clemens@ladisch.de>");
101006 MODULE_DESCRIPTION("OPL4 driver");
101007 MODULE_LICENSE("GPL");
101008
101009 -static void inline snd_opl4_wait(struct snd_opl4 *opl4)
101010 +static inline void snd_opl4_wait(struct snd_opl4 *opl4)
101011 {
101012 int timeout = 10;
101013 while ((inb(opl4->fm_port) & OPL4_STATUS_BUSY) && --timeout > 0)
101014 diff --git a/sound/drivers/portman2x4.c b/sound/drivers/portman2x4.c
101015 index 991018d..8984740 100644
101016 --- a/sound/drivers/portman2x4.c
101017 +++ b/sound/drivers/portman2x4.c
101018 @@ -48,6 +48,7 @@
101019 #include <sound/initval.h>
101020 #include <sound/rawmidi.h>
101021 #include <sound/control.h>
101022 +#include <asm/local.h>
101023
101024 #define CARD_NAME "Portman 2x4"
101025 #define DRIVER_NAME "portman"
101026 @@ -85,7 +86,7 @@ struct portman {
101027 struct pardevice *pardev;
101028 int pardev_claimed;
101029
101030 - int open_count;
101031 + local_t open_count;
101032 int mode[PORTMAN_NUM_INPUT_PORTS];
101033 struct snd_rawmidi_substream *midi_input[PORTMAN_NUM_INPUT_PORTS];
101034 };
101035 diff --git a/sound/firewire/amdtp.c b/sound/firewire/amdtp.c
101036 index ea995af..f1bfa37 100644
101037 --- a/sound/firewire/amdtp.c
101038 +++ b/sound/firewire/amdtp.c
101039 @@ -389,7 +389,7 @@ static void queue_out_packet(struct amdtp_out_stream *s, unsigned int cycle)
101040 ptr = s->pcm_buffer_pointer + data_blocks;
101041 if (ptr >= pcm->runtime->buffer_size)
101042 ptr -= pcm->runtime->buffer_size;
101043 - ACCESS_ONCE(s->pcm_buffer_pointer) = ptr;
101044 + ACCESS_ONCE_RW(s->pcm_buffer_pointer) = ptr;
101045
101046 s->pcm_period_pointer += data_blocks;
101047 if (s->pcm_period_pointer >= pcm->runtime->period_size) {
101048 @@ -557,7 +557,7 @@ EXPORT_SYMBOL(amdtp_out_stream_pcm_pointer);
101049 */
101050 void amdtp_out_stream_update(struct amdtp_out_stream *s)
101051 {
101052 - ACCESS_ONCE(s->source_node_id_field) =
101053 + ACCESS_ONCE_RW(s->source_node_id_field) =
101054 (fw_parent_device(s->unit)->card->node_id & 0x3f) << 24;
101055 }
101056 EXPORT_SYMBOL(amdtp_out_stream_update);
101057 diff --git a/sound/firewire/amdtp.h b/sound/firewire/amdtp.h
101058 index f6103d6..4843fbf 100644
101059 --- a/sound/firewire/amdtp.h
101060 +++ b/sound/firewire/amdtp.h
101061 @@ -138,7 +138,7 @@ static inline bool amdtp_out_streaming_error(struct amdtp_out_stream *s)
101062 static inline void amdtp_out_stream_pcm_trigger(struct amdtp_out_stream *s,
101063 struct snd_pcm_substream *pcm)
101064 {
101065 - ACCESS_ONCE(s->pcm) = pcm;
101066 + ACCESS_ONCE_RW(s->pcm) = pcm;
101067 }
101068
101069 static inline bool cip_sfc_is_base_44100(enum cip_sfc sfc)
101070 diff --git a/sound/firewire/isight.c b/sound/firewire/isight.c
101071 index 58a5afe..af5bd64 100644
101072 --- a/sound/firewire/isight.c
101073 +++ b/sound/firewire/isight.c
101074 @@ -96,7 +96,7 @@ static void isight_update_pointers(struct isight *isight, unsigned int count)
101075 ptr += count;
101076 if (ptr >= runtime->buffer_size)
101077 ptr -= runtime->buffer_size;
101078 - ACCESS_ONCE(isight->buffer_pointer) = ptr;
101079 + ACCESS_ONCE_RW(isight->buffer_pointer) = ptr;
101080
101081 isight->period_counter += count;
101082 if (isight->period_counter >= runtime->period_size) {
101083 @@ -307,7 +307,7 @@ static int isight_hw_params(struct snd_pcm_substream *substream,
101084 if (err < 0)
101085 return err;
101086
101087 - ACCESS_ONCE(isight->pcm_active) = true;
101088 + ACCESS_ONCE_RW(isight->pcm_active) = true;
101089
101090 return 0;
101091 }
101092 @@ -340,7 +340,7 @@ static int isight_hw_free(struct snd_pcm_substream *substream)
101093 {
101094 struct isight *isight = substream->private_data;
101095
101096 - ACCESS_ONCE(isight->pcm_active) = false;
101097 + ACCESS_ONCE_RW(isight->pcm_active) = false;
101098
101099 mutex_lock(&isight->mutex);
101100 isight_stop_streaming(isight);
101101 @@ -433,10 +433,10 @@ static int isight_trigger(struct snd_pcm_substream *substream, int cmd)
101102
101103 switch (cmd) {
101104 case SNDRV_PCM_TRIGGER_START:
101105 - ACCESS_ONCE(isight->pcm_running) = true;
101106 + ACCESS_ONCE_RW(isight->pcm_running) = true;
101107 break;
101108 case SNDRV_PCM_TRIGGER_STOP:
101109 - ACCESS_ONCE(isight->pcm_running) = false;
101110 + ACCESS_ONCE_RW(isight->pcm_running) = false;
101111 break;
101112 default:
101113 return -EINVAL;
101114 diff --git a/sound/firewire/scs1x.c b/sound/firewire/scs1x.c
101115 index 505fc81..62e569e 100644
101116 --- a/sound/firewire/scs1x.c
101117 +++ b/sound/firewire/scs1x.c
101118 @@ -74,7 +74,7 @@ static void scs_output_trigger(struct snd_rawmidi_substream *stream, int up)
101119 {
101120 struct scs *scs = stream->rmidi->private_data;
101121
101122 - ACCESS_ONCE(scs->output) = up ? stream : NULL;
101123 + ACCESS_ONCE_RW(scs->output) = up ? stream : NULL;
101124 if (up) {
101125 scs->output_idle = false;
101126 tasklet_schedule(&scs->tasklet);
101127 @@ -257,7 +257,7 @@ static void scs_input_trigger(struct snd_rawmidi_substream *stream, int up)
101128 {
101129 struct scs *scs = stream->rmidi->private_data;
101130
101131 - ACCESS_ONCE(scs->input) = up ? stream : NULL;
101132 + ACCESS_ONCE_RW(scs->input) = up ? stream : NULL;
101133 }
101134
101135 static void scs_input_escaped_byte(struct snd_rawmidi_substream *stream,
101136 @@ -469,8 +469,8 @@ static void scs_remove(struct fw_unit *unit)
101137
101138 snd_card_disconnect(scs->card);
101139
101140 - ACCESS_ONCE(scs->output) = NULL;
101141 - ACCESS_ONCE(scs->input) = NULL;
101142 + ACCESS_ONCE_RW(scs->output) = NULL;
101143 + ACCESS_ONCE_RW(scs->input) = NULL;
101144
101145 wait_event(scs->idle_wait, scs->output_idle);
101146
101147 diff --git a/sound/oss/sb_audio.c b/sound/oss/sb_audio.c
101148 index 048439a..3be9f6f 100644
101149 --- a/sound/oss/sb_audio.c
101150 +++ b/sound/oss/sb_audio.c
101151 @@ -904,7 +904,7 @@ sb16_copy_from_user(int dev,
101152 buf16 = (signed short *)(localbuf + localoffs);
101153 while (c)
101154 {
101155 - locallen = (c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
101156 + locallen = ((unsigned)c >= LBUFCOPYSIZE ? LBUFCOPYSIZE : c);
101157 if (copy_from_user(lbuf8,
101158 userbuf+useroffs + p,
101159 locallen))
101160 diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
101161 index 7d8803a..559f8d0 100644
101162 --- a/sound/oss/swarm_cs4297a.c
101163 +++ b/sound/oss/swarm_cs4297a.c
101164 @@ -2621,7 +2621,6 @@ static int __init cs4297a_init(void)
101165 {
101166 struct cs4297a_state *s;
101167 u32 pwr, id;
101168 - mm_segment_t fs;
101169 int rval;
101170 #ifndef CONFIG_BCM_CS4297A_CSWARM
101171 u64 cfg;
101172 @@ -2711,22 +2710,23 @@ static int __init cs4297a_init(void)
101173 if (!rval) {
101174 char *sb1250_duart_present;
101175
101176 +#if 0
101177 + mm_segment_t fs;
101178 fs = get_fs();
101179 set_fs(KERNEL_DS);
101180 -#if 0
101181 val = SOUND_MASK_LINE;
101182 mixer_ioctl(s, SOUND_MIXER_WRITE_RECSRC, (unsigned long) &val);
101183 for (i = 0; i < ARRAY_SIZE(initvol); i++) {
101184 val = initvol[i].vol;
101185 mixer_ioctl(s, initvol[i].mixch, (unsigned long) &val);
101186 }
101187 + set_fs(fs);
101188 // cs4297a_write_ac97(s, 0x18, 0x0808);
101189 #else
101190 // cs4297a_write_ac97(s, 0x5e, 0x180);
101191 cs4297a_write_ac97(s, 0x02, 0x0808);
101192 cs4297a_write_ac97(s, 0x18, 0x0808);
101193 #endif
101194 - set_fs(fs);
101195
101196 list_add(&s->list, &cs4297a_devs);
101197
101198 diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
101199 index e938a68..2a728ad 100644
101200 --- a/sound/pci/hda/hda_codec.c
101201 +++ b/sound/pci/hda/hda_codec.c
101202 @@ -976,14 +976,10 @@ find_codec_preset(struct hda_codec *codec)
101203 mutex_unlock(&preset_mutex);
101204
101205 if (mod_requested < HDA_MODREQ_MAX_COUNT) {
101206 - char name[32];
101207 if (!mod_requested)
101208 - snprintf(name, sizeof(name), "snd-hda-codec-id:%08x",
101209 - codec->vendor_id);
101210 + request_module("snd-hda-codec-id:%08x", codec->vendor_id);
101211 else
101212 - snprintf(name, sizeof(name), "snd-hda-codec-id:%04x*",
101213 - (codec->vendor_id >> 16) & 0xffff);
101214 - request_module(name);
101215 + request_module("snd-hda-codec-id:%04x*", (codec->vendor_id >> 16) & 0xffff);
101216 mod_requested++;
101217 goto again;
101218 }
101219 diff --git a/sound/pci/ymfpci/ymfpci.h b/sound/pci/ymfpci/ymfpci.h
101220 index 4631a23..001ae57 100644
101221 --- a/sound/pci/ymfpci/ymfpci.h
101222 +++ b/sound/pci/ymfpci/ymfpci.h
101223 @@ -358,7 +358,7 @@ struct snd_ymfpci {
101224 spinlock_t reg_lock;
101225 spinlock_t voice_lock;
101226 wait_queue_head_t interrupt_sleep;
101227 - atomic_t interrupt_sleep_count;
101228 + atomic_unchecked_t interrupt_sleep_count;
101229 struct snd_info_entry *proc_entry;
101230 const struct firmware *dsp_microcode;
101231 const struct firmware *controller_microcode;
101232 diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c
101233 index d591c15..8cb8f94 100644
101234 --- a/sound/pci/ymfpci/ymfpci_main.c
101235 +++ b/sound/pci/ymfpci/ymfpci_main.c
101236 @@ -202,8 +202,8 @@ static void snd_ymfpci_hw_stop(struct snd_ymfpci *chip)
101237 if ((snd_ymfpci_readl(chip, YDSXGR_STATUS) & 2) == 0)
101238 break;
101239 }
101240 - if (atomic_read(&chip->interrupt_sleep_count)) {
101241 - atomic_set(&chip->interrupt_sleep_count, 0);
101242 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
101243 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101244 wake_up(&chip->interrupt_sleep);
101245 }
101246 __end:
101247 @@ -787,7 +787,7 @@ static void snd_ymfpci_irq_wait(struct snd_ymfpci *chip)
101248 continue;
101249 init_waitqueue_entry(&wait, current);
101250 add_wait_queue(&chip->interrupt_sleep, &wait);
101251 - atomic_inc(&chip->interrupt_sleep_count);
101252 + atomic_inc_unchecked(&chip->interrupt_sleep_count);
101253 schedule_timeout_uninterruptible(msecs_to_jiffies(50));
101254 remove_wait_queue(&chip->interrupt_sleep, &wait);
101255 }
101256 @@ -825,8 +825,8 @@ static irqreturn_t snd_ymfpci_interrupt(int irq, void *dev_id)
101257 snd_ymfpci_writel(chip, YDSXGR_MODE, mode);
101258 spin_unlock(&chip->reg_lock);
101259
101260 - if (atomic_read(&chip->interrupt_sleep_count)) {
101261 - atomic_set(&chip->interrupt_sleep_count, 0);
101262 + if (atomic_read_unchecked(&chip->interrupt_sleep_count)) {
101263 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101264 wake_up(&chip->interrupt_sleep);
101265 }
101266 }
101267 @@ -2421,7 +2421,7 @@ int snd_ymfpci_create(struct snd_card *card,
101268 spin_lock_init(&chip->reg_lock);
101269 spin_lock_init(&chip->voice_lock);
101270 init_waitqueue_head(&chip->interrupt_sleep);
101271 - atomic_set(&chip->interrupt_sleep_count, 0);
101272 + atomic_set_unchecked(&chip->interrupt_sleep_count, 0);
101273 chip->card = card;
101274 chip->pci = pci;
101275 chip->irq = -1;
101276 diff --git a/sound/soc/fsl/fsl_ssi.c b/sound/soc/fsl/fsl_ssi.c
101277 index 6b81d0c..031c056 100644
101278 --- a/sound/soc/fsl/fsl_ssi.c
101279 +++ b/sound/soc/fsl/fsl_ssi.c
101280 @@ -864,7 +864,7 @@ static int fsl_ssi_probe(struct platform_device *pdev)
101281 {
101282 struct fsl_ssi_private *ssi_private;
101283 int ret = 0;
101284 - struct device_attribute *dev_attr = NULL;
101285 + device_attribute_no_const *dev_attr = NULL;
101286 struct device_node *np = pdev->dev.of_node;
101287 const char *p, *sprop;
101288 const uint32_t *iprop;
101289 diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
101290 index 1a38be0..66809d1 100644
101291 --- a/sound/soc/soc-core.c
101292 +++ b/sound/soc/soc-core.c
101293 @@ -2248,8 +2248,10 @@ int snd_soc_set_ac97_ops_of_reset(struct snd_ac97_bus_ops *ops,
101294 if (ret)
101295 return ret;
101296
101297 - ops->warm_reset = snd_soc_ac97_warm_reset;
101298 - ops->reset = snd_soc_ac97_reset;
101299 + pax_open_kernel();
101300 + *(void **)&ops->warm_reset = snd_soc_ac97_warm_reset;
101301 + *(void **)&ops->reset = snd_soc_ac97_reset;
101302 + pax_close_kernel();
101303
101304 snd_ac97_rst_cfg = cfg;
101305 return 0;
101306 diff --git a/tools/gcc/.gitignore b/tools/gcc/.gitignore
101307 new file mode 100644
101308 index 0000000..50f2f2f
101309 --- /dev/null
101310 +++ b/tools/gcc/.gitignore
101311 @@ -0,0 +1 @@
101312 +size_overflow_hash.h
101313 diff --git a/tools/gcc/Makefile b/tools/gcc/Makefile
101314 new file mode 100644
101315 index 0000000..144dbee
101316 --- /dev/null
101317 +++ b/tools/gcc/Makefile
101318 @@ -0,0 +1,45 @@
101319 +#CC := gcc
101320 +#PLUGIN_SOURCE_FILES := pax_plugin.c
101321 +#PLUGIN_OBJECT_FILES := $(patsubst %.c,%.o,$(PLUGIN_SOURCE_FILES))
101322 +GCCPLUGINS_DIR := $(shell $(CC) -print-file-name=plugin)
101323 +#CFLAGS += -I$(GCCPLUGINS_DIR)/include -fPIC -O2 -Wall -W -std=gnu99
101324 +
101325 +ifeq ($(PLUGINCC),$(HOSTCC))
101326 +HOSTLIBS := hostlibs
101327 +HOST_EXTRACFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu99 -ggdb
101328 +else
101329 +HOSTLIBS := hostcxxlibs
101330 +HOST_EXTRACXXFLAGS += -I$(GCCPLUGINS_DIR)/include -std=gnu++98 -ggdb -Wno-unused-parameter
101331 +endif
101332 +
101333 +$(HOSTLIBS)-$(CONFIG_PAX_CONSTIFY_PLUGIN) := constify_plugin.so
101334 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STACKLEAK) += stackleak_plugin.so
101335 +$(HOSTLIBS)-$(CONFIG_KALLOCSTAT_PLUGIN) += kallocstat_plugin.so
101336 +$(HOSTLIBS)-$(CONFIG_PAX_KERNEXEC_PLUGIN) += kernexec_plugin.so
101337 +$(HOSTLIBS)-$(CONFIG_CHECKER_PLUGIN) += checker_plugin.so
101338 +$(HOSTLIBS)-y += colorize_plugin.so
101339 +$(HOSTLIBS)-$(CONFIG_PAX_SIZE_OVERFLOW) += size_overflow_plugin.so
101340 +$(HOSTLIBS)-$(CONFIG_PAX_LATENT_ENTROPY) += latent_entropy_plugin.so
101341 +$(HOSTLIBS)-$(CONFIG_PAX_MEMORY_STRUCTLEAK) += structleak_plugin.so
101342 +
101343 +always := $($(HOSTLIBS)-y)
101344 +
101345 +constify_plugin-objs := constify_plugin.o
101346 +stackleak_plugin-objs := stackleak_plugin.o
101347 +kallocstat_plugin-objs := kallocstat_plugin.o
101348 +kernexec_plugin-objs := kernexec_plugin.o
101349 +checker_plugin-objs := checker_plugin.o
101350 +colorize_plugin-objs := colorize_plugin.o
101351 +size_overflow_plugin-objs := size_overflow_plugin.o
101352 +latent_entropy_plugin-objs := latent_entropy_plugin.o
101353 +structleak_plugin-objs := structleak_plugin.o
101354 +
101355 +$(obj)/size_overflow_plugin.o: $(objtree)/$(obj)/size_overflow_hash.h
101356 +
101357 +quiet_cmd_build_size_overflow_hash = GENHASH $@
101358 + cmd_build_size_overflow_hash = \
101359 + $(CONFIG_SHELL) $(srctree)/$(src)/generate_size_overflow_hash.sh -d $< -o $@
101360 +$(objtree)/$(obj)/size_overflow_hash.h: $(src)/size_overflow_hash.data FORCE
101361 + $(call if_changed,build_size_overflow_hash)
101362 +
101363 +targets += size_overflow_hash.h
101364 diff --git a/tools/gcc/checker_plugin.c b/tools/gcc/checker_plugin.c
101365 new file mode 100644
101366 index 0000000..22f03c0
101367 --- /dev/null
101368 +++ b/tools/gcc/checker_plugin.c
101369 @@ -0,0 +1,172 @@
101370 +/*
101371 + * Copyright 2011 by the PaX Team <pageexec@freemail.hu>
101372 + * Licensed under the GPL v2
101373 + *
101374 + * Note: the choice of the license means that the compilation process is
101375 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101376 + * but for the kernel it doesn't matter since it doesn't link against
101377 + * any of the gcc libraries
101378 + *
101379 + * gcc plugin to implement various sparse (source code checker) features
101380 + *
101381 + * TODO:
101382 + * - define separate __iomem, __percpu and __rcu address spaces (lots of code to patch)
101383 + *
101384 + * BUGS:
101385 + * - none known
101386 + */
101387 +#include "gcc-plugin.h"
101388 +#include "config.h"
101389 +#include "system.h"
101390 +#include "coretypes.h"
101391 +#include "tree.h"
101392 +#include "tree-pass.h"
101393 +#include "flags.h"
101394 +#include "intl.h"
101395 +#include "toplev.h"
101396 +#include "plugin.h"
101397 +//#include "expr.h" where are you...
101398 +#include "diagnostic.h"
101399 +#include "plugin-version.h"
101400 +#include "tm.h"
101401 +#include "function.h"
101402 +#include "basic-block.h"
101403 +#include "gimple.h"
101404 +#include "rtl.h"
101405 +#include "emit-rtl.h"
101406 +#include "tree-flow.h"
101407 +#include "target.h"
101408 +
101409 +extern void c_register_addr_space (const char *str, addr_space_t as);
101410 +extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
101411 +extern enum machine_mode default_addr_space_address_mode (addr_space_t);
101412 +extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
101413 +extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
101414 +extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
101415 +
101416 +extern void print_gimple_stmt(FILE *, gimple, int, int);
101417 +extern rtx emit_move_insn(rtx x, rtx y);
101418 +
101419 +int plugin_is_GPL_compatible;
101420 +
101421 +static struct plugin_info checker_plugin_info = {
101422 + .version = "201111150100",
101423 + .help = NULL,
101424 +};
101425 +
101426 +#define ADDR_SPACE_KERNEL 0
101427 +#define ADDR_SPACE_FORCE_KERNEL 1
101428 +#define ADDR_SPACE_USER 2
101429 +#define ADDR_SPACE_FORCE_USER 3
101430 +#define ADDR_SPACE_IOMEM 0
101431 +#define ADDR_SPACE_FORCE_IOMEM 0
101432 +#define ADDR_SPACE_PERCPU 0
101433 +#define ADDR_SPACE_FORCE_PERCPU 0
101434 +#define ADDR_SPACE_RCU 0
101435 +#define ADDR_SPACE_FORCE_RCU 0
101436 +
101437 +static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
101438 +{
101439 + return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
101440 +}
101441 +
101442 +static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
101443 +{
101444 + return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
101445 +}
101446 +
101447 +static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
101448 +{
101449 + return default_addr_space_valid_pointer_mode(mode, as);
101450 +}
101451 +
101452 +static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
101453 +{
101454 + return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
101455 +}
101456 +
101457 +static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
101458 +{
101459 + return default_addr_space_legitimize_address(x, oldx, mode, as);
101460 +}
101461 +
101462 +static bool checker_addr_space_subset_p(addr_space_t subset, addr_space_t superset)
101463 +{
101464 + if (subset == ADDR_SPACE_FORCE_KERNEL && superset == ADDR_SPACE_KERNEL)
101465 + return true;
101466 +
101467 + if (subset == ADDR_SPACE_FORCE_USER && superset == ADDR_SPACE_USER)
101468 + return true;
101469 +
101470 + if (subset == ADDR_SPACE_FORCE_IOMEM && superset == ADDR_SPACE_IOMEM)
101471 + return true;
101472 +
101473 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_USER)
101474 + return true;
101475 +
101476 + if (subset == ADDR_SPACE_KERNEL && superset == ADDR_SPACE_FORCE_IOMEM)
101477 + return true;
101478 +
101479 + if (subset == ADDR_SPACE_USER && superset == ADDR_SPACE_FORCE_KERNEL)
101480 + return true;
101481 +
101482 + if (subset == ADDR_SPACE_IOMEM && superset == ADDR_SPACE_FORCE_KERNEL)
101483 + return true;
101484 +
101485 + return subset == superset;
101486 +}
101487 +
101488 +static rtx checker_addr_space_convert(rtx op, tree from_type, tree to_type)
101489 +{
101490 +// addr_space_t from_as = TYPE_ADDR_SPACE(TREE_TYPE(from_type));
101491 +// addr_space_t to_as = TYPE_ADDR_SPACE(TREE_TYPE(to_type));
101492 +
101493 + return op;
101494 +}
101495 +
101496 +static void register_checker_address_spaces(void *event_data, void *data)
101497 +{
101498 + c_register_addr_space("__kernel", ADDR_SPACE_KERNEL);
101499 + c_register_addr_space("__force_kernel", ADDR_SPACE_FORCE_KERNEL);
101500 + c_register_addr_space("__user", ADDR_SPACE_USER);
101501 + c_register_addr_space("__force_user", ADDR_SPACE_FORCE_USER);
101502 +// c_register_addr_space("__iomem", ADDR_SPACE_IOMEM);
101503 +// c_register_addr_space("__force_iomem", ADDR_SPACE_FORCE_IOMEM);
101504 +// c_register_addr_space("__percpu", ADDR_SPACE_PERCPU);
101505 +// c_register_addr_space("__force_percpu", ADDR_SPACE_FORCE_PERCPU);
101506 +// c_register_addr_space("__rcu", ADDR_SPACE_RCU);
101507 +// c_register_addr_space("__force_rcu", ADDR_SPACE_FORCE_RCU);
101508 +
101509 + targetm.addr_space.pointer_mode = checker_addr_space_pointer_mode;
101510 + targetm.addr_space.address_mode = checker_addr_space_address_mode;
101511 + targetm.addr_space.valid_pointer_mode = checker_addr_space_valid_pointer_mode;
101512 + targetm.addr_space.legitimate_address_p = checker_addr_space_legitimate_address_p;
101513 +// targetm.addr_space.legitimize_address = checker_addr_space_legitimize_address;
101514 + targetm.addr_space.subset_p = checker_addr_space_subset_p;
101515 + targetm.addr_space.convert = checker_addr_space_convert;
101516 +}
101517 +
101518 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101519 +{
101520 + const char * const plugin_name = plugin_info->base_name;
101521 + const int argc = plugin_info->argc;
101522 + const struct plugin_argument * const argv = plugin_info->argv;
101523 + int i;
101524 +
101525 + if (!plugin_default_version_check(version, &gcc_version)) {
101526 + error(G_("incompatible gcc/plugin versions"));
101527 + return 1;
101528 + }
101529 +
101530 + register_callback(plugin_name, PLUGIN_INFO, NULL, &checker_plugin_info);
101531 +
101532 + for (i = 0; i < argc; ++i)
101533 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
101534 +
101535 + if (TARGET_64BIT == 0)
101536 + return 0;
101537 +
101538 + register_callback(plugin_name, PLUGIN_PRAGMAS, register_checker_address_spaces, NULL);
101539 +
101540 + return 0;
101541 +}
101542 diff --git a/tools/gcc/colorize_plugin.c b/tools/gcc/colorize_plugin.c
101543 new file mode 100644
101544 index 0000000..414fe5e
101545 --- /dev/null
101546 +++ b/tools/gcc/colorize_plugin.c
101547 @@ -0,0 +1,151 @@
101548 +/*
101549 + * Copyright 2012-2013 by PaX Team <pageexec@freemail.hu>
101550 + * Licensed under the GPL v2
101551 + *
101552 + * Note: the choice of the license means that the compilation process is
101553 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
101554 + * but for the kernel it doesn't matter since it doesn't link against
101555 + * any of the gcc libraries
101556 + *
101557 + * gcc plugin to colorize diagnostic output
101558 + *
101559 + */
101560 +
101561 +#include "gcc-plugin.h"
101562 +#include "config.h"
101563 +#include "system.h"
101564 +#include "coretypes.h"
101565 +#include "tree.h"
101566 +#include "tree-pass.h"
101567 +#include "flags.h"
101568 +#include "intl.h"
101569 +#include "toplev.h"
101570 +#include "plugin.h"
101571 +#include "diagnostic.h"
101572 +#include "plugin-version.h"
101573 +#include "tm.h"
101574 +
101575 +int plugin_is_GPL_compatible;
101576 +
101577 +static struct plugin_info colorize_plugin_info = {
101578 + .version = "201302112000",
101579 + .help = NULL,
101580 +};
101581 +
101582 +#define GREEN "\033[32m\033[2m"
101583 +#define LIGHTGREEN "\033[32m\033[1m"
101584 +#define YELLOW "\033[33m\033[2m"
101585 +#define LIGHTYELLOW "\033[33m\033[1m"
101586 +#define RED "\033[31m\033[2m"
101587 +#define LIGHTRED "\033[31m\033[1m"
101588 +#define BLUE "\033[34m\033[2m"
101589 +#define LIGHTBLUE "\033[34m\033[1m"
101590 +#define BRIGHT "\033[m\033[1m"
101591 +#define NORMAL "\033[m"
101592 +
101593 +static diagnostic_starter_fn old_starter;
101594 +static diagnostic_finalizer_fn old_finalizer;
101595 +
101596 +static void start_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101597 +{
101598 + const char *color;
101599 + char *newprefix;
101600 +
101601 + switch (diagnostic->kind) {
101602 + case DK_NOTE:
101603 + color = LIGHTBLUE;
101604 + break;
101605 +
101606 + case DK_PEDWARN:
101607 + case DK_WARNING:
101608 + color = LIGHTYELLOW;
101609 + break;
101610 +
101611 + case DK_ERROR:
101612 + case DK_FATAL:
101613 + case DK_ICE:
101614 + case DK_PERMERROR:
101615 + case DK_SORRY:
101616 + color = LIGHTRED;
101617 + break;
101618 +
101619 + default:
101620 + color = NORMAL;
101621 + }
101622 +
101623 + old_starter(context, diagnostic);
101624 + if (-1 == asprintf(&newprefix, "%s%s" NORMAL, color, context->printer->prefix))
101625 + return;
101626 + pp_destroy_prefix(context->printer);
101627 + pp_set_prefix(context->printer, newprefix);
101628 +}
101629 +
101630 +static void finalize_colorize(diagnostic_context *context, diagnostic_info *diagnostic)
101631 +{
101632 + old_finalizer(context, diagnostic);
101633 +}
101634 +
101635 +static void colorize_arm(void)
101636 +{
101637 + old_starter = diagnostic_starter(global_dc);
101638 + old_finalizer = diagnostic_finalizer(global_dc);
101639 +
101640 + diagnostic_starter(global_dc) = start_colorize;
101641 + diagnostic_finalizer(global_dc) = finalize_colorize;
101642 +}
101643 +
101644 +static unsigned int execute_colorize_rearm(void)
101645 +{
101646 + if (diagnostic_starter(global_dc) == start_colorize)
101647 + return 0;
101648 +
101649 + colorize_arm();
101650 + return 0;
101651 +}
101652 +
101653 +struct simple_ipa_opt_pass pass_ipa_colorize_rearm = {
101654 + .pass = {
101655 + .type = SIMPLE_IPA_PASS,
101656 + .name = "colorize_rearm",
101657 +#if BUILDING_GCC_VERSION >= 4008
101658 + .optinfo_flags = OPTGROUP_NONE,
101659 +#endif
101660 + .gate = NULL,
101661 + .execute = execute_colorize_rearm,
101662 + .sub = NULL,
101663 + .next = NULL,
101664 + .static_pass_number = 0,
101665 + .tv_id = TV_NONE,
101666 + .properties_required = 0,
101667 + .properties_provided = 0,
101668 + .properties_destroyed = 0,
101669 + .todo_flags_start = 0,
101670 + .todo_flags_finish = 0
101671 + }
101672 +};
101673 +
101674 +static void colorize_start_unit(void *gcc_data, void *user_data)
101675 +{
101676 + colorize_arm();
101677 +}
101678 +
101679 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
101680 +{
101681 + const char * const plugin_name = plugin_info->base_name;
101682 + struct register_pass_info colorize_rearm_pass_info = {
101683 + .pass = &pass_ipa_colorize_rearm.pass,
101684 + .reference_pass_name = "*free_lang_data",
101685 + .ref_pass_instance_number = 1,
101686 + .pos_op = PASS_POS_INSERT_AFTER
101687 + };
101688 +
101689 + if (!plugin_default_version_check(version, &gcc_version)) {
101690 + error(G_("incompatible gcc/plugin versions"));
101691 + return 1;
101692 + }
101693 +
101694 + register_callback(plugin_name, PLUGIN_INFO, NULL, &colorize_plugin_info);
101695 + register_callback(plugin_name, PLUGIN_START_UNIT, &colorize_start_unit, NULL);
101696 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &colorize_rearm_pass_info);
101697 + return 0;
101698 +}
101699 diff --git a/tools/gcc/constify_plugin.c b/tools/gcc/constify_plugin.c
101700 new file mode 100644
101701 index 0000000..ba59e50
101702 --- /dev/null
101703 +++ b/tools/gcc/constify_plugin.c
101704 @@ -0,0 +1,558 @@
101705 +/*
101706 + * Copyright 2011 by Emese Revfy <re.emese@gmail.com>
101707 + * Copyright 2011-2013 by PaX Team <pageexec@freemail.hu>
101708 + * Licensed under the GPL v2, or (at your option) v3
101709 + *
101710 + * This gcc plugin constifies all structures which contain only function pointers or are explicitly marked for constification.
101711 + *
101712 + * Homepage:
101713 + * http://www.grsecurity.net/~ephox/const_plugin/
101714 + *
101715 + * Usage:
101716 + * $ gcc -I`gcc -print-file-name=plugin`/include -fPIC -shared -O2 -o constify_plugin.so constify_plugin.c
101717 + * $ gcc -fplugin=constify_plugin.so test.c -O2
101718 + */
101719 +
101720 +#include "gcc-plugin.h"
101721 +#include "config.h"
101722 +#include "system.h"
101723 +#include "coretypes.h"
101724 +#include "tree.h"
101725 +#include "tree-pass.h"
101726 +#include "flags.h"
101727 +#include "intl.h"
101728 +#include "toplev.h"
101729 +#include "plugin.h"
101730 +#include "diagnostic.h"
101731 +#include "plugin-version.h"
101732 +#include "tm.h"
101733 +#include "function.h"
101734 +#include "basic-block.h"
101735 +#include "gimple.h"
101736 +#include "rtl.h"
101737 +#include "emit-rtl.h"
101738 +#include "tree-flow.h"
101739 +#include "target.h"
101740 +#include "langhooks.h"
101741 +
101742 +// should come from c-tree.h if only it were installed for gcc 4.5...
101743 +#define C_TYPE_FIELDS_READONLY(TYPE) TREE_LANG_FLAG_1(TYPE)
101744 +
101745 +// unused type flag in all versions 4.5-4.8
101746 +#define TYPE_CONSTIFY_VISITED(TYPE) TYPE_LANG_FLAG_4(TYPE)
101747 +
101748 +int plugin_is_GPL_compatible;
101749 +
101750 +static struct plugin_info const_plugin_info = {
101751 + .version = "201312032345",
101752 + .help = "no-constify\tturn off constification\n",
101753 +};
101754 +
101755 +typedef struct {
101756 + bool has_fptr_field;
101757 + bool has_writable_field;
101758 + bool has_do_const_field;
101759 + bool has_no_const_field;
101760 +} constify_info;
101761 +
101762 +static const_tree get_field_type(const_tree field)
101763 +{
101764 + return strip_array_types(TREE_TYPE(field));
101765 +}
101766 +
101767 +static bool is_fptr(const_tree field)
101768 +{
101769 + const_tree ptr = get_field_type(field);
101770 +
101771 + if (TREE_CODE(ptr) != POINTER_TYPE)
101772 + return false;
101773 +
101774 + return TREE_CODE(TREE_TYPE(ptr)) == FUNCTION_TYPE;
101775 +}
101776 +
101777 +/*
101778 + * determine whether the given structure type meets the requirements for automatic constification,
101779 + * including the constification attributes on nested structure types
101780 + */
101781 +static void constifiable(const_tree node, constify_info *cinfo)
101782 +{
101783 + const_tree field;
101784 +
101785 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101786 +
101787 + // e.g., pointer to structure fields while still constructing the structure type
101788 + if (TYPE_FIELDS(node) == NULL_TREE)
101789 + return;
101790 +
101791 + for (field = TYPE_FIELDS(node); field; field = TREE_CHAIN(field)) {
101792 + const_tree type = get_field_type(field);
101793 + enum tree_code code = TREE_CODE(type);
101794 +
101795 + if (node == type)
101796 + continue;
101797 +
101798 + if (is_fptr(field))
101799 + cinfo->has_fptr_field = true;
101800 + else if (!TREE_READONLY(field))
101801 + cinfo->has_writable_field = true;
101802 +
101803 + if (code == RECORD_TYPE || code == UNION_TYPE) {
101804 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101805 + cinfo->has_do_const_field = true;
101806 + else if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type)))
101807 + cinfo->has_no_const_field = true;
101808 + else
101809 + constifiable(type, cinfo);
101810 + }
101811 + }
101812 +}
101813 +
101814 +static bool constified(const_tree node)
101815 +{
101816 + constify_info cinfo = {
101817 + .has_fptr_field = false,
101818 + .has_writable_field = false,
101819 + .has_do_const_field = false,
101820 + .has_no_const_field = false
101821 + };
101822 +
101823 + gcc_assert(TREE_CODE(node) == RECORD_TYPE || TREE_CODE(node) == UNION_TYPE);
101824 +
101825 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(node))) {
101826 + gcc_assert(!TYPE_READONLY(node));
101827 + return false;
101828 + }
101829 +
101830 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(node))) {
101831 + gcc_assert(TYPE_READONLY(node));
101832 + return true;
101833 + }
101834 +
101835 + constifiable(node, &cinfo);
101836 + if ((!cinfo.has_fptr_field || cinfo.has_writable_field) && !cinfo.has_do_const_field)
101837 + return false;
101838 +
101839 + return TYPE_READONLY(node);
101840 +}
101841 +
101842 +static void deconstify_tree(tree node);
101843 +
101844 +static void deconstify_type(tree type)
101845 +{
101846 + tree field;
101847 +
101848 + gcc_assert(TREE_CODE(type) == RECORD_TYPE || TREE_CODE(type) == UNION_TYPE);
101849 +
101850 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
101851 + const_tree fieldtype = get_field_type(field);
101852 +
101853 + // special case handling of simple ptr-to-same-array-type members
101854 + if (TREE_CODE(TREE_TYPE(field)) == POINTER_TYPE) {
101855 + const_tree ptrtype = TREE_TYPE(TREE_TYPE(field));
101856 +
101857 + if (TREE_CODE(ptrtype) != RECORD_TYPE && TREE_CODE(ptrtype) != UNION_TYPE)
101858 + continue;
101859 + if (TREE_TYPE(TREE_TYPE(field)) == type)
101860 + continue;
101861 + if (TYPE_MAIN_VARIANT(ptrtype) == TYPE_MAIN_VARIANT(type)) {
101862 + TREE_TYPE(field) = copy_node(TREE_TYPE(field));
101863 + TREE_TYPE(TREE_TYPE(field)) = type;
101864 + }
101865 + continue;
101866 + }
101867 + if (TREE_CODE(fieldtype) != RECORD_TYPE && TREE_CODE(fieldtype) != UNION_TYPE)
101868 + continue;
101869 + if (!constified(fieldtype))
101870 + continue;
101871 +
101872 + deconstify_tree(field);
101873 + TREE_READONLY(field) = 0;
101874 + }
101875 + TYPE_READONLY(type) = 0;
101876 + C_TYPE_FIELDS_READONLY(type) = 0;
101877 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101878 + TYPE_ATTRIBUTES(type) = remove_attribute("do_const", TYPE_ATTRIBUTES(type));
101879 +}
101880 +
101881 +static void deconstify_tree(tree node)
101882 +{
101883 + tree old_type, new_type, field;
101884 +
101885 + old_type = TREE_TYPE(node);
101886 + while (TREE_CODE(old_type) == ARRAY_TYPE && TREE_CODE(TREE_TYPE(old_type)) != ARRAY_TYPE) {
101887 + node = TREE_TYPE(node) = copy_node(old_type);
101888 + old_type = TREE_TYPE(old_type);
101889 + }
101890 +
101891 + gcc_assert(TREE_CODE(old_type) == RECORD_TYPE || TREE_CODE(old_type) == UNION_TYPE);
101892 + gcc_assert(TYPE_READONLY(old_type) && (TYPE_QUALS(old_type) & TYPE_QUAL_CONST));
101893 +
101894 + new_type = build_qualified_type(old_type, TYPE_QUALS(old_type) & ~TYPE_QUAL_CONST);
101895 + TYPE_FIELDS(new_type) = copy_list(TYPE_FIELDS(new_type));
101896 + for (field = TYPE_FIELDS(new_type); field; field = TREE_CHAIN(field))
101897 + DECL_FIELD_CONTEXT(field) = new_type;
101898 +
101899 + deconstify_type(new_type);
101900 +
101901 + TREE_TYPE(node) = new_type;
101902 +}
101903 +
101904 +static tree handle_no_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101905 +{
101906 + tree type;
101907 + constify_info cinfo = {
101908 + .has_fptr_field = false,
101909 + .has_writable_field = false,
101910 + .has_do_const_field = false,
101911 + .has_no_const_field = false
101912 + };
101913 +
101914 + *no_add_attrs = true;
101915 + if (TREE_CODE(*node) == FUNCTION_DECL) {
101916 + error("%qE attribute does not apply to functions (%qF)", name, *node);
101917 + return NULL_TREE;
101918 + }
101919 +
101920 + if (TREE_CODE(*node) == PARM_DECL) {
101921 + error("%qE attribute does not apply to function parameters (%qD)", name, *node);
101922 + return NULL_TREE;
101923 + }
101924 +
101925 + if (TREE_CODE(*node) == VAR_DECL) {
101926 + error("%qE attribute does not apply to variables (%qD)", name, *node);
101927 + return NULL_TREE;
101928 + }
101929 +
101930 + if (TYPE_P(*node)) {
101931 + *no_add_attrs = false;
101932 + type = *node;
101933 + } else {
101934 + gcc_assert(TREE_CODE(*node) == TYPE_DECL);
101935 + type = TREE_TYPE(*node);
101936 + }
101937 +
101938 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE) {
101939 + error("%qE attribute used on %qT applies to struct and union types only", name, type);
101940 + return NULL_TREE;
101941 + }
101942 +
101943 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(type))) {
101944 + error("%qE attribute is already applied to the type %qT", name, type);
101945 + return NULL_TREE;
101946 + }
101947 +
101948 + if (TYPE_P(*node)) {
101949 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type)))
101950 + error("%qE attribute used on type %qT is incompatible with 'do_const'", name, type);
101951 + return NULL_TREE;
101952 + }
101953 +
101954 + constifiable(type, &cinfo);
101955 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
101956 + deconstify_tree(*node);
101957 + TYPE_CONSTIFY_VISITED(TREE_TYPE(*node)) = 1;
101958 + return NULL_TREE;
101959 + }
101960 +
101961 + error("%qE attribute used on type %qT that is not constified", name, type);
101962 + return NULL_TREE;
101963 +}
101964 +
101965 +static void constify_type(tree type)
101966 +{
101967 + TYPE_READONLY(type) = 1;
101968 + C_TYPE_FIELDS_READONLY(type) = 1;
101969 + TYPE_CONSTIFY_VISITED(type) = 1;
101970 +// TYPE_ATTRIBUTES(type) = tree_cons(get_identifier("do_const"), NULL_TREE, TYPE_ATTRIBUTES(type));
101971 +}
101972 +
101973 +static tree handle_do_const_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
101974 +{
101975 + *no_add_attrs = true;
101976 + if (!TYPE_P(*node)) {
101977 + error("%qE attribute applies to types only (%qD)", name, *node);
101978 + return NULL_TREE;
101979 + }
101980 +
101981 + if (TREE_CODE(*node) != RECORD_TYPE && TREE_CODE(*node) != UNION_TYPE) {
101982 + error("%qE attribute used on %qT applies to struct and union types only", name, *node);
101983 + return NULL_TREE;
101984 + }
101985 +
101986 + if (lookup_attribute(IDENTIFIER_POINTER(name), TYPE_ATTRIBUTES(*node))) {
101987 + error("%qE attribute used on %qT is already applied to the type", name, *node);
101988 + return NULL_TREE;
101989 + }
101990 +
101991 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(*node))) {
101992 + error("%qE attribute used on %qT is incompatible with 'no_const'", name, *node);
101993 + return NULL_TREE;
101994 + }
101995 +
101996 + *no_add_attrs = false;
101997 + return NULL_TREE;
101998 +}
101999 +
102000 +static struct attribute_spec no_const_attr = {
102001 + .name = "no_const",
102002 + .min_length = 0,
102003 + .max_length = 0,
102004 + .decl_required = false,
102005 + .type_required = false,
102006 + .function_type_required = false,
102007 + .handler = handle_no_const_attribute,
102008 +#if BUILDING_GCC_VERSION >= 4007
102009 + .affects_type_identity = true
102010 +#endif
102011 +};
102012 +
102013 +static struct attribute_spec do_const_attr = {
102014 + .name = "do_const",
102015 + .min_length = 0,
102016 + .max_length = 0,
102017 + .decl_required = false,
102018 + .type_required = false,
102019 + .function_type_required = false,
102020 + .handler = handle_do_const_attribute,
102021 +#if BUILDING_GCC_VERSION >= 4007
102022 + .affects_type_identity = true
102023 +#endif
102024 +};
102025 +
102026 +static void register_attributes(void *event_data, void *data)
102027 +{
102028 + register_attribute(&no_const_attr);
102029 + register_attribute(&do_const_attr);
102030 +}
102031 +
102032 +static void finish_type(void *event_data, void *data)
102033 +{
102034 + tree type = (tree)event_data;
102035 + constify_info cinfo = {
102036 + .has_fptr_field = false,
102037 + .has_writable_field = false,
102038 + .has_do_const_field = false,
102039 + .has_no_const_field = false
102040 + };
102041 +
102042 + if (type == NULL_TREE || type == error_mark_node)
102043 + return;
102044 +
102045 + if (TYPE_FIELDS(type) == NULL_TREE || TYPE_CONSTIFY_VISITED(type))
102046 + return;
102047 +
102048 + constifiable(type, &cinfo);
102049 +
102050 + if (lookup_attribute("no_const", TYPE_ATTRIBUTES(type))) {
102051 + if ((cinfo.has_fptr_field && !cinfo.has_writable_field) || cinfo.has_do_const_field) {
102052 + deconstify_type(type);
102053 + TYPE_CONSTIFY_VISITED(type) = 1;
102054 + } else
102055 + error("'no_const' attribute used on type %qT that is not constified", type);
102056 + return;
102057 + }
102058 +
102059 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
102060 + if (!cinfo.has_writable_field) {
102061 + error("'do_const' attribute used on type %qT that is%sconstified", type, cinfo.has_fptr_field ? " " : " not ");
102062 + return;
102063 + }
102064 + constify_type(type);
102065 + return;
102066 + }
102067 +
102068 + if (cinfo.has_fptr_field && !cinfo.has_writable_field) {
102069 + if (lookup_attribute("do_const", TYPE_ATTRIBUTES(type))) {
102070 + error("'do_const' attribute used on type %qT that is constified", type);
102071 + return;
102072 + }
102073 + constify_type(type);
102074 + return;
102075 + }
102076 +
102077 + deconstify_type(type);
102078 + TYPE_CONSTIFY_VISITED(type) = 1;
102079 +}
102080 +
102081 +static void check_global_variables(void)
102082 +{
102083 + struct varpool_node *node;
102084 +
102085 +#if BUILDING_GCC_VERSION <= 4007
102086 + for (node = varpool_nodes; node; node = node->next) {
102087 + tree var = node->decl;
102088 +#else
102089 + FOR_EACH_VARIABLE(node) {
102090 + tree var = node->symbol.decl;
102091 +#endif
102092 + tree type = TREE_TYPE(var);
102093 +
102094 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102095 + continue;
102096 +
102097 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
102098 + continue;
102099 +
102100 + if (!TYPE_CONSTIFY_VISITED(type))
102101 + continue;
102102 +
102103 + if (DECL_EXTERNAL(var))
102104 + continue;
102105 +
102106 + if (DECL_INITIAL(var))
102107 + continue;
102108 +
102109 + // this works around a gcc bug/feature where uninitialized globals
102110 + // are moved into the .bss section regardless of any constification
102111 + DECL_INITIAL(var) = build_constructor(type, NULL);
102112 +// inform(DECL_SOURCE_LOCATION(var), "constified variable %qE moved into .rodata", var);
102113 + }
102114 +}
102115 +
102116 +static unsigned int check_local_variables(void)
102117 +{
102118 + unsigned int ret = 0;
102119 + tree var;
102120 +
102121 +#if BUILDING_GCC_VERSION == 4005
102122 + tree vars;
102123 +#else
102124 + unsigned int i;
102125 +#endif
102126 +
102127 +#if BUILDING_GCC_VERSION == 4005
102128 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
102129 + var = TREE_VALUE(vars);
102130 +#else
102131 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
102132 +#endif
102133 + tree type = TREE_TYPE(var);
102134 +
102135 + gcc_assert(DECL_P(var));
102136 + if (is_global_var(var))
102137 + continue;
102138 +
102139 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
102140 + continue;
102141 +
102142 + if (!TYPE_READONLY(type) || !C_TYPE_FIELDS_READONLY(type))
102143 + continue;
102144 +
102145 + if (!TYPE_CONSTIFY_VISITED(type))
102146 + continue;
102147 +
102148 + error_at(DECL_SOURCE_LOCATION(var), "constified variable %qE cannot be local", var);
102149 + ret = 1;
102150 + }
102151 + return ret;
102152 +}
102153 +
102154 +static unsigned int check_variables(void)
102155 +{
102156 + check_global_variables();
102157 + return check_local_variables();
102158 +}
102159 +
102160 +static struct gimple_opt_pass pass_local_variable = {
102161 + {
102162 + .type = GIMPLE_PASS,
102163 + .name = "check_variables",
102164 +#if BUILDING_GCC_VERSION >= 4008
102165 + .optinfo_flags = OPTGROUP_NONE,
102166 +#endif
102167 + .gate = NULL,
102168 + .execute = check_variables,
102169 + .sub = NULL,
102170 + .next = NULL,
102171 + .static_pass_number = 0,
102172 + .tv_id = TV_NONE,
102173 + .properties_required = 0,
102174 + .properties_provided = 0,
102175 + .properties_destroyed = 0,
102176 + .todo_flags_start = 0,
102177 + .todo_flags_finish = 0
102178 + }
102179 +};
102180 +
102181 +static struct {
102182 + const char *name;
102183 + const char *asm_op;
102184 +} sections[] = {
102185 + {".init.rodata", "\t.section\t.init.rodata,\"a\""},
102186 + {".ref.rodata", "\t.section\t.ref.rodata,\"a\""},
102187 + {".devinit.rodata", "\t.section\t.devinit.rodata,\"a\""},
102188 + {".devexit.rodata", "\t.section\t.devexit.rodata,\"a\""},
102189 + {".cpuinit.rodata", "\t.section\t.cpuinit.rodata,\"a\""},
102190 + {".cpuexit.rodata", "\t.section\t.cpuexit.rodata,\"a\""},
102191 + {".meminit.rodata", "\t.section\t.meminit.rodata,\"a\""},
102192 + {".memexit.rodata", "\t.section\t.memexit.rodata,\"a\""},
102193 + {".data..read_only", "\t.section\t.data..read_only,\"a\""},
102194 +};
102195 +
102196 +static unsigned int (*old_section_type_flags)(tree decl, const char *name, int reloc);
102197 +
102198 +static unsigned int constify_section_type_flags(tree decl, const char *name, int reloc)
102199 +{
102200 + size_t i;
102201 +
102202 + for (i = 0; i < ARRAY_SIZE(sections); i++)
102203 + if (!strcmp(sections[i].name, name))
102204 + return 0;
102205 + return old_section_type_flags(decl, name, reloc);
102206 +}
102207 +
102208 +static void constify_start_unit(void *gcc_data, void *user_data)
102209 +{
102210 +// size_t i;
102211 +
102212 +// for (i = 0; i < ARRAY_SIZE(sections); i++)
102213 +// sections[i].section = get_unnamed_section(0, output_section_asm_op, sections[i].asm_op);
102214 +// sections[i].section = get_section(sections[i].name, 0, NULL);
102215 +
102216 + old_section_type_flags = targetm.section_type_flags;
102217 + targetm.section_type_flags = constify_section_type_flags;
102218 +}
102219 +
102220 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102221 +{
102222 + const char * const plugin_name = plugin_info->base_name;
102223 + const int argc = plugin_info->argc;
102224 + const struct plugin_argument * const argv = plugin_info->argv;
102225 + int i;
102226 + bool constify = true;
102227 +
102228 + struct register_pass_info local_variable_pass_info = {
102229 + .pass = &pass_local_variable.pass,
102230 + .reference_pass_name = "ssa",
102231 + .ref_pass_instance_number = 1,
102232 + .pos_op = PASS_POS_INSERT_BEFORE
102233 + };
102234 +
102235 + if (!plugin_default_version_check(version, &gcc_version)) {
102236 + error(G_("incompatible gcc/plugin versions"));
102237 + return 1;
102238 + }
102239 +
102240 + for (i = 0; i < argc; ++i) {
102241 + if (!(strcmp(argv[i].key, "no-constify"))) {
102242 + constify = false;
102243 + continue;
102244 + }
102245 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102246 + }
102247 +
102248 + if (strcmp(lang_hooks.name, "GNU C")) {
102249 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
102250 + constify = false;
102251 + }
102252 +
102253 + register_callback(plugin_name, PLUGIN_INFO, NULL, &const_plugin_info);
102254 + if (constify) {
102255 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
102256 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &local_variable_pass_info);
102257 + register_callback(plugin_name, PLUGIN_START_UNIT, constify_start_unit, NULL);
102258 + }
102259 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
102260 +
102261 + return 0;
102262 +}
102263 diff --git a/tools/gcc/generate_size_overflow_hash.sh b/tools/gcc/generate_size_overflow_hash.sh
102264 new file mode 100644
102265 index 0000000..e518932
102266 --- /dev/null
102267 +++ b/tools/gcc/generate_size_overflow_hash.sh
102268 @@ -0,0 +1,94 @@
102269 +#!/bin/bash
102270 +
102271 +# This script generates the hash table (size_overflow_hash.h) for the size_overflow gcc plugin (size_overflow_plugin.c).
102272 +
102273 +header1="size_overflow_hash.h"
102274 +database="size_overflow_hash.data"
102275 +n=65536
102276 +
102277 +usage() {
102278 +cat <<EOF
102279 +usage: $0 options
102280 +OPTIONS:
102281 + -h|--help help
102282 + -o header file
102283 + -d database file
102284 + -n hash array size
102285 +EOF
102286 + return 0
102287 +}
102288 +
102289 +while true
102290 +do
102291 + case "$1" in
102292 + -h|--help) usage && exit 0;;
102293 + -n) n=$2; shift 2;;
102294 + -o) header1="$2"; shift 2;;
102295 + -d) database="$2"; shift 2;;
102296 + --) shift 1; break ;;
102297 + *) break ;;
102298 + esac
102299 +done
102300 +
102301 +create_defines() {
102302 + for i in `seq 0 31`
102303 + do
102304 + echo -e "#define PARAM"$i" (1U << "$i")" >> "$header1"
102305 + done
102306 + echo >> "$header1"
102307 +}
102308 +
102309 +create_structs() {
102310 + rm -f "$header1"
102311 +
102312 + create_defines
102313 +
102314 + cat "$database" | while read data
102315 + do
102316 + data_array=($data)
102317 + struct_hash_name="${data_array[0]}"
102318 + funcn="${data_array[1]}"
102319 + params="${data_array[2]}"
102320 + next="${data_array[4]}"
102321 +
102322 + echo "const struct size_overflow_hash $struct_hash_name = {" >> "$header1"
102323 +
102324 + echo -e "\t.next\t= $next,\n\t.name\t= \"$funcn\"," >> "$header1"
102325 + echo -en "\t.param\t= " >> "$header1"
102326 + line=
102327 + for param_num in ${params//-/ };
102328 + do
102329 + line="${line}PARAM"$param_num"|"
102330 + done
102331 +
102332 + echo -e "${line%?},\n};\n" >> "$header1"
102333 + done
102334 +}
102335 +
102336 +create_headers() {
102337 + echo "const struct size_overflow_hash * const size_overflow_hash[$n] = {" >> "$header1"
102338 +}
102339 +
102340 +create_array_elements() {
102341 + index=0
102342 + grep -v "nohasharray" $database | sort -n -k 4 | while read data
102343 + do
102344 + data_array=($data)
102345 + i="${data_array[3]}"
102346 + hash="${data_array[0]}"
102347 + while [[ $index -lt $i ]]
102348 + do
102349 + echo -e "\t["$index"]\t= NULL," >> "$header1"
102350 + index=$(($index + 1))
102351 + done
102352 + index=$(($index + 1))
102353 + echo -e "\t["$i"]\t= &"$hash"," >> "$header1"
102354 + done
102355 + echo '};' >> $header1
102356 +}
102357 +
102358 +create_structs
102359 +create_headers
102360 +create_array_elements
102361 +
102362 +exit 0
102363 diff --git a/tools/gcc/kallocstat_plugin.c b/tools/gcc/kallocstat_plugin.c
102364 new file mode 100644
102365 index 0000000..568b360
102366 --- /dev/null
102367 +++ b/tools/gcc/kallocstat_plugin.c
102368 @@ -0,0 +1,170 @@
102369 +/*
102370 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102371 + * Licensed under the GPL v2
102372 + *
102373 + * Note: the choice of the license means that the compilation process is
102374 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102375 + * but for the kernel it doesn't matter since it doesn't link against
102376 + * any of the gcc libraries
102377 + *
102378 + * gcc plugin to find the distribution of k*alloc sizes
102379 + *
102380 + * TODO:
102381 + *
102382 + * BUGS:
102383 + * - none known
102384 + */
102385 +#include "gcc-plugin.h"
102386 +#include "config.h"
102387 +#include "system.h"
102388 +#include "coretypes.h"
102389 +#include "tree.h"
102390 +#include "tree-pass.h"
102391 +#include "flags.h"
102392 +#include "intl.h"
102393 +#include "toplev.h"
102394 +#include "plugin.h"
102395 +//#include "expr.h" where are you...
102396 +#include "diagnostic.h"
102397 +#include "plugin-version.h"
102398 +#include "tm.h"
102399 +#include "function.h"
102400 +#include "basic-block.h"
102401 +#include "gimple.h"
102402 +#include "rtl.h"
102403 +#include "emit-rtl.h"
102404 +
102405 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102406 +
102407 +int plugin_is_GPL_compatible;
102408 +
102409 +static const char * const kalloc_functions[] = {
102410 + "__kmalloc",
102411 + "kmalloc",
102412 + "kmalloc_large",
102413 + "kmalloc_node",
102414 + "kmalloc_order",
102415 + "kmalloc_order_trace",
102416 + "kmalloc_slab",
102417 + "kzalloc",
102418 + "kzalloc_node",
102419 +};
102420 +
102421 +static struct plugin_info kallocstat_plugin_info = {
102422 + .version = "201302112000",
102423 +};
102424 +
102425 +static unsigned int execute_kallocstat(void);
102426 +
102427 +static struct gimple_opt_pass kallocstat_pass = {
102428 + .pass = {
102429 + .type = GIMPLE_PASS,
102430 + .name = "kallocstat",
102431 +#if BUILDING_GCC_VERSION >= 4008
102432 + .optinfo_flags = OPTGROUP_NONE,
102433 +#endif
102434 + .gate = NULL,
102435 + .execute = execute_kallocstat,
102436 + .sub = NULL,
102437 + .next = NULL,
102438 + .static_pass_number = 0,
102439 + .tv_id = TV_NONE,
102440 + .properties_required = 0,
102441 + .properties_provided = 0,
102442 + .properties_destroyed = 0,
102443 + .todo_flags_start = 0,
102444 + .todo_flags_finish = 0
102445 + }
102446 +};
102447 +
102448 +static bool is_kalloc(const char *fnname)
102449 +{
102450 + size_t i;
102451 +
102452 + for (i = 0; i < ARRAY_SIZE(kalloc_functions); i++)
102453 + if (!strcmp(fnname, kalloc_functions[i]))
102454 + return true;
102455 + return false;
102456 +}
102457 +
102458 +static unsigned int execute_kallocstat(void)
102459 +{
102460 + basic_block bb;
102461 +
102462 + // 1. loop through BBs and GIMPLE statements
102463 + FOR_EACH_BB(bb) {
102464 + gimple_stmt_iterator gsi;
102465 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102466 + // gimple match:
102467 + tree fndecl, size;
102468 + gimple call_stmt;
102469 + const char *fnname;
102470 +
102471 + // is it a call
102472 + call_stmt = gsi_stmt(gsi);
102473 + if (!is_gimple_call(call_stmt))
102474 + continue;
102475 + fndecl = gimple_call_fndecl(call_stmt);
102476 + if (fndecl == NULL_TREE)
102477 + continue;
102478 + if (TREE_CODE(fndecl) != FUNCTION_DECL)
102479 + continue;
102480 +
102481 + // is it a call to k*alloc
102482 + fnname = IDENTIFIER_POINTER(DECL_NAME(fndecl));
102483 + if (!is_kalloc(fnname))
102484 + continue;
102485 +
102486 + // is the size arg the result of a simple const assignment
102487 + size = gimple_call_arg(call_stmt, 0);
102488 + while (true) {
102489 + gimple def_stmt;
102490 + expanded_location xloc;
102491 + size_t size_val;
102492 +
102493 + if (TREE_CODE(size) != SSA_NAME)
102494 + break;
102495 + def_stmt = SSA_NAME_DEF_STMT(size);
102496 + if (!def_stmt || !is_gimple_assign(def_stmt))
102497 + break;
102498 + if (gimple_num_ops(def_stmt) != 2)
102499 + break;
102500 + size = gimple_assign_rhs1(def_stmt);
102501 + if (!TREE_CONSTANT(size))
102502 + continue;
102503 + xloc = expand_location(gimple_location(def_stmt));
102504 + if (!xloc.file)
102505 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
102506 + size_val = TREE_INT_CST_LOW(size);
102507 + fprintf(stderr, "kallocsize: %8zu %8zx %s %s:%u\n", size_val, size_val, fnname, xloc.file, xloc.line);
102508 + break;
102509 + }
102510 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102511 +//debug_tree(gimple_call_fn(call_stmt));
102512 +//print_node(stderr, "pax", fndecl, 4);
102513 + }
102514 + }
102515 +
102516 + return 0;
102517 +}
102518 +
102519 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102520 +{
102521 + const char * const plugin_name = plugin_info->base_name;
102522 + struct register_pass_info kallocstat_pass_info = {
102523 + .pass = &kallocstat_pass.pass,
102524 + .reference_pass_name = "ssa",
102525 + .ref_pass_instance_number = 1,
102526 + .pos_op = PASS_POS_INSERT_AFTER
102527 + };
102528 +
102529 + if (!plugin_default_version_check(version, &gcc_version)) {
102530 + error(G_("incompatible gcc/plugin versions"));
102531 + return 1;
102532 + }
102533 +
102534 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kallocstat_plugin_info);
102535 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kallocstat_pass_info);
102536 +
102537 + return 0;
102538 +}
102539 diff --git a/tools/gcc/kernexec_plugin.c b/tools/gcc/kernexec_plugin.c
102540 new file mode 100644
102541 index 0000000..a25306b
102542 --- /dev/null
102543 +++ b/tools/gcc/kernexec_plugin.c
102544 @@ -0,0 +1,474 @@
102545 +/*
102546 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
102547 + * Licensed under the GPL v2
102548 + *
102549 + * Note: the choice of the license means that the compilation process is
102550 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
102551 + * but for the kernel it doesn't matter since it doesn't link against
102552 + * any of the gcc libraries
102553 + *
102554 + * gcc plugin to make KERNEXEC/amd64 almost as good as it is on i386
102555 + *
102556 + * TODO:
102557 + *
102558 + * BUGS:
102559 + * - none known
102560 + */
102561 +#include "gcc-plugin.h"
102562 +#include "config.h"
102563 +#include "system.h"
102564 +#include "coretypes.h"
102565 +#include "tree.h"
102566 +#include "tree-pass.h"
102567 +#include "flags.h"
102568 +#include "intl.h"
102569 +#include "toplev.h"
102570 +#include "plugin.h"
102571 +//#include "expr.h" where are you...
102572 +#include "diagnostic.h"
102573 +#include "plugin-version.h"
102574 +#include "tm.h"
102575 +#include "function.h"
102576 +#include "basic-block.h"
102577 +#include "gimple.h"
102578 +#include "rtl.h"
102579 +#include "emit-rtl.h"
102580 +#include "tree-flow.h"
102581 +
102582 +extern void print_gimple_stmt(FILE *, gimple, int, int);
102583 +extern rtx emit_move_insn(rtx x, rtx y);
102584 +
102585 +#if BUILDING_GCC_VERSION <= 4006
102586 +#define ANY_RETURN_P(rtx) (GET_CODE(rtx) == RETURN)
102587 +#endif
102588 +
102589 +#if BUILDING_GCC_VERSION >= 4008
102590 +#define TODO_dump_func 0
102591 +#endif
102592 +
102593 +int plugin_is_GPL_compatible;
102594 +
102595 +static struct plugin_info kernexec_plugin_info = {
102596 + .version = "201308230150",
102597 + .help = "method=[bts|or]\tinstrumentation method\n"
102598 +};
102599 +
102600 +static unsigned int execute_kernexec_reload(void);
102601 +static unsigned int execute_kernexec_fptr(void);
102602 +static unsigned int execute_kernexec_retaddr(void);
102603 +static bool kernexec_cmodel_check(void);
102604 +
102605 +static void (*kernexec_instrument_fptr)(gimple_stmt_iterator *);
102606 +static void (*kernexec_instrument_retaddr)(rtx);
102607 +
102608 +static struct gimple_opt_pass kernexec_reload_pass = {
102609 + .pass = {
102610 + .type = GIMPLE_PASS,
102611 + .name = "kernexec_reload",
102612 +#if BUILDING_GCC_VERSION >= 4008
102613 + .optinfo_flags = OPTGROUP_NONE,
102614 +#endif
102615 + .gate = kernexec_cmodel_check,
102616 + .execute = execute_kernexec_reload,
102617 + .sub = NULL,
102618 + .next = NULL,
102619 + .static_pass_number = 0,
102620 + .tv_id = TV_NONE,
102621 + .properties_required = 0,
102622 + .properties_provided = 0,
102623 + .properties_destroyed = 0,
102624 + .todo_flags_start = 0,
102625 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102626 + }
102627 +};
102628 +
102629 +static struct gimple_opt_pass kernexec_fptr_pass = {
102630 + .pass = {
102631 + .type = GIMPLE_PASS,
102632 + .name = "kernexec_fptr",
102633 +#if BUILDING_GCC_VERSION >= 4008
102634 + .optinfo_flags = OPTGROUP_NONE,
102635 +#endif
102636 + .gate = kernexec_cmodel_check,
102637 + .execute = execute_kernexec_fptr,
102638 + .sub = NULL,
102639 + .next = NULL,
102640 + .static_pass_number = 0,
102641 + .tv_id = TV_NONE,
102642 + .properties_required = 0,
102643 + .properties_provided = 0,
102644 + .properties_destroyed = 0,
102645 + .todo_flags_start = 0,
102646 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_remove_unused_locals | TODO_update_ssa_no_phi
102647 + }
102648 +};
102649 +
102650 +static struct rtl_opt_pass kernexec_retaddr_pass = {
102651 + .pass = {
102652 + .type = RTL_PASS,
102653 + .name = "kernexec_retaddr",
102654 +#if BUILDING_GCC_VERSION >= 4008
102655 + .optinfo_flags = OPTGROUP_NONE,
102656 +#endif
102657 + .gate = kernexec_cmodel_check,
102658 + .execute = execute_kernexec_retaddr,
102659 + .sub = NULL,
102660 + .next = NULL,
102661 + .static_pass_number = 0,
102662 + .tv_id = TV_NONE,
102663 + .properties_required = 0,
102664 + .properties_provided = 0,
102665 + .properties_destroyed = 0,
102666 + .todo_flags_start = 0,
102667 + .todo_flags_finish = TODO_dump_func | TODO_ggc_collect
102668 + }
102669 +};
102670 +
102671 +static bool kernexec_cmodel_check(void)
102672 +{
102673 + tree section;
102674 +
102675 + if (ix86_cmodel != CM_KERNEL)
102676 + return false;
102677 +
102678 + section = lookup_attribute("section", DECL_ATTRIBUTES(current_function_decl));
102679 + if (!section || !TREE_VALUE(section))
102680 + return true;
102681 +
102682 + section = TREE_VALUE(TREE_VALUE(section));
102683 + if (strncmp(TREE_STRING_POINTER(section), ".vsyscall_", 10))
102684 + return true;
102685 +
102686 + return false;
102687 +}
102688 +
102689 +/*
102690 + * add special KERNEXEC instrumentation: reload %r12 after it has been clobbered
102691 + */
102692 +static void kernexec_reload_fptr_mask(gimple_stmt_iterator *gsi)
102693 +{
102694 + gimple asm_movabs_stmt;
102695 +
102696 + // build asm volatile("movabs $0x8000000000000000, %%r12\n\t" : : : );
102697 + asm_movabs_stmt = gimple_build_asm_vec("movabs $0x8000000000000000, %%r12\n\t", NULL, NULL, NULL, NULL);
102698 + gimple_asm_set_volatile(asm_movabs_stmt, true);
102699 + gsi_insert_after(gsi, asm_movabs_stmt, GSI_CONTINUE_LINKING);
102700 + update_stmt(asm_movabs_stmt);
102701 +}
102702 +
102703 +/*
102704 + * find all asm() stmts that clobber r12 and add a reload of r12
102705 + */
102706 +static unsigned int execute_kernexec_reload(void)
102707 +{
102708 + basic_block bb;
102709 +
102710 + // 1. loop through BBs and GIMPLE statements
102711 + FOR_EACH_BB(bb) {
102712 + gimple_stmt_iterator gsi;
102713 +
102714 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102715 + // gimple match: __asm__ ("" : : : "r12");
102716 + gimple asm_stmt;
102717 + size_t nclobbers;
102718 +
102719 + // is it an asm ...
102720 + asm_stmt = gsi_stmt(gsi);
102721 + if (gimple_code(asm_stmt) != GIMPLE_ASM)
102722 + continue;
102723 +
102724 + // ... clobbering r12
102725 + nclobbers = gimple_asm_nclobbers(asm_stmt);
102726 + while (nclobbers--) {
102727 + tree op = gimple_asm_clobber_op(asm_stmt, nclobbers);
102728 + if (strcmp(TREE_STRING_POINTER(TREE_VALUE(op)), "r12"))
102729 + continue;
102730 + kernexec_reload_fptr_mask(&gsi);
102731 +//print_gimple_stmt(stderr, asm_stmt, 0, TDF_LINENO);
102732 + break;
102733 + }
102734 + }
102735 + }
102736 +
102737 + return 0;
102738 +}
102739 +
102740 +/*
102741 + * add special KERNEXEC instrumentation: force MSB of fptr to 1, which will produce
102742 + * a non-canonical address from a userland ptr and will just trigger a GPF on dereference
102743 + */
102744 +static void kernexec_instrument_fptr_bts(gimple_stmt_iterator *gsi)
102745 +{
102746 + gimple assign_intptr, assign_new_fptr, call_stmt;
102747 + tree intptr, orptr, old_fptr, new_fptr, kernexec_mask;
102748 +
102749 + call_stmt = gsi_stmt(*gsi);
102750 + old_fptr = gimple_call_fn(call_stmt);
102751 +
102752 + // create temporary unsigned long variable used for bitops and cast fptr to it
102753 + intptr = create_tmp_var(long_unsigned_type_node, "kernexec_bts");
102754 +#if BUILDING_GCC_VERSION <= 4007
102755 + add_referenced_var(intptr);
102756 +#endif
102757 + intptr = make_ssa_name(intptr, NULL);
102758 + assign_intptr = gimple_build_assign(intptr, fold_convert(long_unsigned_type_node, old_fptr));
102759 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102760 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102761 + update_stmt(assign_intptr);
102762 +
102763 + // apply logical or to temporary unsigned long and bitmask
102764 + kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0x8000000000000000LL);
102765 +// kernexec_mask = build_int_cstu(long_long_unsigned_type_node, 0xffffffff80000000LL);
102766 + orptr = fold_build2(BIT_IOR_EXPR, long_long_unsigned_type_node, intptr, kernexec_mask);
102767 + intptr = make_ssa_name(SSA_NAME_VAR(intptr), NULL);
102768 + assign_intptr = gimple_build_assign(intptr, orptr);
102769 + SSA_NAME_DEF_STMT(intptr) = assign_intptr;
102770 + gsi_insert_before(gsi, assign_intptr, GSI_SAME_STMT);
102771 + update_stmt(assign_intptr);
102772 +
102773 + // cast temporary unsigned long back to a temporary fptr variable
102774 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_fptr");
102775 +#if BUILDING_GCC_VERSION <= 4007
102776 + add_referenced_var(new_fptr);
102777 +#endif
102778 + new_fptr = make_ssa_name(new_fptr, NULL);
102779 + assign_new_fptr = gimple_build_assign(new_fptr, fold_convert(TREE_TYPE(old_fptr), intptr));
102780 + SSA_NAME_DEF_STMT(new_fptr) = assign_new_fptr;
102781 + gsi_insert_before(gsi, assign_new_fptr, GSI_SAME_STMT);
102782 + update_stmt(assign_new_fptr);
102783 +
102784 + // replace call stmt fn with the new fptr
102785 + gimple_call_set_fn(call_stmt, new_fptr);
102786 + update_stmt(call_stmt);
102787 +}
102788 +
102789 +static void kernexec_instrument_fptr_or(gimple_stmt_iterator *gsi)
102790 +{
102791 + gimple asm_or_stmt, call_stmt;
102792 + tree old_fptr, new_fptr, input, output;
102793 +#if BUILDING_GCC_VERSION <= 4007
102794 + VEC(tree, gc) *inputs = NULL;
102795 + VEC(tree, gc) *outputs = NULL;
102796 +#else
102797 + vec<tree, va_gc> *inputs = NULL;
102798 + vec<tree, va_gc> *outputs = NULL;
102799 +#endif
102800 +
102801 + call_stmt = gsi_stmt(*gsi);
102802 + old_fptr = gimple_call_fn(call_stmt);
102803 +
102804 + // create temporary fptr variable
102805 + new_fptr = create_tmp_var(TREE_TYPE(old_fptr), "kernexec_or");
102806 +#if BUILDING_GCC_VERSION <= 4007
102807 + add_referenced_var(new_fptr);
102808 +#endif
102809 + new_fptr = make_ssa_name(new_fptr, NULL);
102810 +
102811 + // build asm volatile("orq %%r12, %0\n\t" : "=r"(new_fptr) : "0"(old_fptr));
102812 + input = build_tree_list(NULL_TREE, build_string(1, "0"));
102813 + input = chainon(NULL_TREE, build_tree_list(input, old_fptr));
102814 + output = build_tree_list(NULL_TREE, build_string(2, "=r"));
102815 + output = chainon(NULL_TREE, build_tree_list(output, new_fptr));
102816 +#if BUILDING_GCC_VERSION <= 4007
102817 + VEC_safe_push(tree, gc, inputs, input);
102818 + VEC_safe_push(tree, gc, outputs, output);
102819 +#else
102820 + vec_safe_push(inputs, input);
102821 + vec_safe_push(outputs, output);
102822 +#endif
102823 + asm_or_stmt = gimple_build_asm_vec("orq %%r12, %0\n\t", inputs, outputs, NULL, NULL);
102824 + SSA_NAME_DEF_STMT(new_fptr) = asm_or_stmt;
102825 + gimple_asm_set_volatile(asm_or_stmt, true);
102826 + gsi_insert_before(gsi, asm_or_stmt, GSI_SAME_STMT);
102827 + update_stmt(asm_or_stmt);
102828 +
102829 + // replace call stmt fn with the new fptr
102830 + gimple_call_set_fn(call_stmt, new_fptr);
102831 + update_stmt(call_stmt);
102832 +}
102833 +
102834 +/*
102835 + * find all C level function pointer dereferences and forcibly set the highest bit of the pointer
102836 + */
102837 +static unsigned int execute_kernexec_fptr(void)
102838 +{
102839 + basic_block bb;
102840 +
102841 + // 1. loop through BBs and GIMPLE statements
102842 + FOR_EACH_BB(bb) {
102843 + gimple_stmt_iterator gsi;
102844 +
102845 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
102846 + // gimple match: h_1 = get_fptr (); D.2709_3 = h_1 (x_2(D));
102847 + tree fn;
102848 + gimple call_stmt;
102849 +
102850 + // is it a call ...
102851 + call_stmt = gsi_stmt(gsi);
102852 + if (!is_gimple_call(call_stmt))
102853 + continue;
102854 + fn = gimple_call_fn(call_stmt);
102855 + if (TREE_CODE(fn) == ADDR_EXPR)
102856 + continue;
102857 + if (TREE_CODE(fn) != SSA_NAME)
102858 + gcc_unreachable();
102859 +
102860 + // ... through a function pointer
102861 + if (SSA_NAME_VAR(fn) != NULL_TREE) {
102862 + fn = SSA_NAME_VAR(fn);
102863 + if (TREE_CODE(fn) != VAR_DECL && TREE_CODE(fn) != PARM_DECL) {
102864 + debug_tree(fn);
102865 + gcc_unreachable();
102866 + }
102867 + }
102868 + fn = TREE_TYPE(fn);
102869 + if (TREE_CODE(fn) != POINTER_TYPE)
102870 + continue;
102871 + fn = TREE_TYPE(fn);
102872 + if (TREE_CODE(fn) != FUNCTION_TYPE)
102873 + continue;
102874 +
102875 + kernexec_instrument_fptr(&gsi);
102876 +
102877 +//debug_tree(gimple_call_fn(call_stmt));
102878 +//print_gimple_stmt(stderr, call_stmt, 0, TDF_LINENO);
102879 + }
102880 + }
102881 +
102882 + return 0;
102883 +}
102884 +
102885 +// add special KERNEXEC instrumentation: btsq $63,(%rsp) just before retn
102886 +static void kernexec_instrument_retaddr_bts(rtx insn)
102887 +{
102888 + rtx btsq;
102889 + rtvec argvec, constraintvec, labelvec;
102890 + int line;
102891 +
102892 + // create asm volatile("btsq $63,(%%rsp)":::)
102893 + argvec = rtvec_alloc(0);
102894 + constraintvec = rtvec_alloc(0);
102895 + labelvec = rtvec_alloc(0);
102896 + line = expand_location(RTL_LOCATION(insn)).line;
102897 + btsq = gen_rtx_ASM_OPERANDS(VOIDmode, "btsq $63,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102898 + MEM_VOLATILE_P(btsq) = 1;
102899 +// RTX_FRAME_RELATED_P(btsq) = 1; // not for ASM_OPERANDS
102900 + emit_insn_before(btsq, insn);
102901 +}
102902 +
102903 +// add special KERNEXEC instrumentation: orq %r12,(%rsp) just before retn
102904 +static void kernexec_instrument_retaddr_or(rtx insn)
102905 +{
102906 + rtx orq;
102907 + rtvec argvec, constraintvec, labelvec;
102908 + int line;
102909 +
102910 + // create asm volatile("orq %%r12,(%%rsp)":::)
102911 + argvec = rtvec_alloc(0);
102912 + constraintvec = rtvec_alloc(0);
102913 + labelvec = rtvec_alloc(0);
102914 + line = expand_location(RTL_LOCATION(insn)).line;
102915 + orq = gen_rtx_ASM_OPERANDS(VOIDmode, "orq %%r12,(%%rsp)", empty_string, 0, argvec, constraintvec, labelvec, line);
102916 + MEM_VOLATILE_P(orq) = 1;
102917 +// RTX_FRAME_RELATED_P(orq) = 1; // not for ASM_OPERANDS
102918 + emit_insn_before(orq, insn);
102919 +}
102920 +
102921 +/*
102922 + * find all asm level function returns and forcibly set the highest bit of the return address
102923 + */
102924 +static unsigned int execute_kernexec_retaddr(void)
102925 +{
102926 + rtx insn;
102927 +
102928 +// if (stack_realign_drap)
102929 +// inform(DECL_SOURCE_LOCATION(current_function_decl), "drap detected in %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
102930 +
102931 + // 1. find function returns
102932 + for (insn = get_insns(); insn; insn = NEXT_INSN(insn)) {
102933 + // rtl match: (jump_insn 41 40 42 2 (return) fptr.c:42 634 {return_internal} (nil))
102934 + // (jump_insn 12 9 11 2 (parallel [ (return) (unspec [ (0) ] UNSPEC_REP) ]) fptr.c:46 635 {return_internal_long} (nil))
102935 + // (jump_insn 97 96 98 6 (simple_return) fptr.c:50 -1 (nil) -> simple_return)
102936 + rtx body;
102937 +
102938 + // is it a retn
102939 + if (!JUMP_P(insn))
102940 + continue;
102941 + body = PATTERN(insn);
102942 + if (GET_CODE(body) == PARALLEL)
102943 + body = XVECEXP(body, 0, 0);
102944 + if (!ANY_RETURN_P(body))
102945 + continue;
102946 + kernexec_instrument_retaddr(insn);
102947 + }
102948 +
102949 +// print_simple_rtl(stderr, get_insns());
102950 +// print_rtl(stderr, get_insns());
102951 +
102952 + return 0;
102953 +}
102954 +
102955 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
102956 +{
102957 + const char * const plugin_name = plugin_info->base_name;
102958 + const int argc = plugin_info->argc;
102959 + const struct plugin_argument * const argv = plugin_info->argv;
102960 + int i;
102961 + struct register_pass_info kernexec_reload_pass_info = {
102962 + .pass = &kernexec_reload_pass.pass,
102963 + .reference_pass_name = "ssa",
102964 + .ref_pass_instance_number = 1,
102965 + .pos_op = PASS_POS_INSERT_AFTER
102966 + };
102967 + struct register_pass_info kernexec_fptr_pass_info = {
102968 + .pass = &kernexec_fptr_pass.pass,
102969 + .reference_pass_name = "ssa",
102970 + .ref_pass_instance_number = 1,
102971 + .pos_op = PASS_POS_INSERT_AFTER
102972 + };
102973 + struct register_pass_info kernexec_retaddr_pass_info = {
102974 + .pass = &kernexec_retaddr_pass.pass,
102975 + .reference_pass_name = "pro_and_epilogue",
102976 + .ref_pass_instance_number = 1,
102977 + .pos_op = PASS_POS_INSERT_AFTER
102978 + };
102979 +
102980 + if (!plugin_default_version_check(version, &gcc_version)) {
102981 + error(G_("incompatible gcc/plugin versions"));
102982 + return 1;
102983 + }
102984 +
102985 + register_callback(plugin_name, PLUGIN_INFO, NULL, &kernexec_plugin_info);
102986 +
102987 + if (TARGET_64BIT == 0)
102988 + return 0;
102989 +
102990 + for (i = 0; i < argc; ++i) {
102991 + if (!strcmp(argv[i].key, "method")) {
102992 + if (!argv[i].value) {
102993 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
102994 + continue;
102995 + }
102996 + if (!strcmp(argv[i].value, "bts")) {
102997 + kernexec_instrument_fptr = kernexec_instrument_fptr_bts;
102998 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_bts;
102999 + } else if (!strcmp(argv[i].value, "or")) {
103000 + kernexec_instrument_fptr = kernexec_instrument_fptr_or;
103001 + kernexec_instrument_retaddr = kernexec_instrument_retaddr_or;
103002 + fix_register("r12", 1, 1);
103003 + } else
103004 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
103005 + continue;
103006 + }
103007 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
103008 + }
103009 + if (!kernexec_instrument_fptr || !kernexec_instrument_retaddr)
103010 + error(G_("no instrumentation method was selected via '-fplugin-arg-%s-method'"), plugin_name);
103011 +
103012 + if (kernexec_instrument_fptr == kernexec_instrument_fptr_or)
103013 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_reload_pass_info);
103014 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_fptr_pass_info);
103015 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &kernexec_retaddr_pass_info);
103016 +
103017 + return 0;
103018 +}
103019 diff --git a/tools/gcc/latent_entropy_plugin.c b/tools/gcc/latent_entropy_plugin.c
103020 new file mode 100644
103021 index 0000000..679b9ef
103022 --- /dev/null
103023 +++ b/tools/gcc/latent_entropy_plugin.c
103024 @@ -0,0 +1,335 @@
103025 +/*
103026 + * Copyright 2012-2013 by the PaX Team <pageexec@freemail.hu>
103027 + * Licensed under the GPL v2
103028 + *
103029 + * Note: the choice of the license means that the compilation process is
103030 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
103031 + * but for the kernel it doesn't matter since it doesn't link against
103032 + * any of the gcc libraries
103033 + *
103034 + * gcc plugin to help generate a little bit of entropy from program state,
103035 + * used during boot in the kernel
103036 + *
103037 + * TODO:
103038 + * - add ipa pass to identify not explicitly marked candidate functions
103039 + * - mix in more program state (function arguments/return values, loop variables, etc)
103040 + * - more instrumentation control via attribute parameters
103041 + *
103042 + * BUGS:
103043 + * - LTO needs -flto-partition=none for now
103044 + */
103045 +#include "gcc-plugin.h"
103046 +#include "config.h"
103047 +#include "system.h"
103048 +#include "coretypes.h"
103049 +#include "tree.h"
103050 +#include "tree-pass.h"
103051 +#include "flags.h"
103052 +#include "intl.h"
103053 +#include "toplev.h"
103054 +#include "plugin.h"
103055 +//#include "expr.h" where are you...
103056 +#include "diagnostic.h"
103057 +#include "plugin-version.h"
103058 +#include "tm.h"
103059 +#include "function.h"
103060 +#include "basic-block.h"
103061 +#include "gimple.h"
103062 +#include "rtl.h"
103063 +#include "emit-rtl.h"
103064 +#include "tree-flow.h"
103065 +#include "langhooks.h"
103066 +
103067 +#if BUILDING_GCC_VERSION >= 4008
103068 +#define TODO_dump_func 0
103069 +#endif
103070 +
103071 +int plugin_is_GPL_compatible;
103072 +
103073 +static tree latent_entropy_decl;
103074 +
103075 +static struct plugin_info latent_entropy_plugin_info = {
103076 + .version = "201308230230",
103077 + .help = NULL
103078 +};
103079 +
103080 +static unsigned int execute_latent_entropy(void);
103081 +static bool gate_latent_entropy(void);
103082 +
103083 +static struct gimple_opt_pass latent_entropy_pass = {
103084 + .pass = {
103085 + .type = GIMPLE_PASS,
103086 + .name = "latent_entropy",
103087 +#if BUILDING_GCC_VERSION >= 4008
103088 + .optinfo_flags = OPTGROUP_NONE,
103089 +#endif
103090 + .gate = gate_latent_entropy,
103091 + .execute = execute_latent_entropy,
103092 + .sub = NULL,
103093 + .next = NULL,
103094 + .static_pass_number = 0,
103095 + .tv_id = TV_NONE,
103096 + .properties_required = PROP_gimple_leh | PROP_cfg,
103097 + .properties_provided = 0,
103098 + .properties_destroyed = 0,
103099 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
103100 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
103101 + }
103102 +};
103103 +
103104 +static unsigned HOST_WIDE_INT seed;
103105 +static unsigned HOST_WIDE_INT get_random_const(void)
103106 +{
103107 + seed = (seed >> 1U) ^ (-(seed & 1ULL) & 0xD800000000000000ULL);
103108 + return seed;
103109 +}
103110 +
103111 +static tree handle_latent_entropy_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
103112 +{
103113 + switch (TREE_CODE(*node)) {
103114 + default:
103115 + *no_add_attrs = true;
103116 + error("%qE attribute only applies to functions and variables", name);
103117 + break;
103118 +
103119 + case VAR_DECL:
103120 + if (DECL_INITIAL(*node)) {
103121 + *no_add_attrs = true;
103122 + error("variable %qD with %qE attribute must not be initialized", *node, name);
103123 + break;
103124 + }
103125 + DECL_INITIAL(*node) = build_int_cstu(long_long_unsigned_type_node, get_random_const());
103126 + break;
103127 +
103128 + case FUNCTION_DECL:
103129 + break;
103130 + }
103131 +
103132 + return NULL_TREE;
103133 +}
103134 +
103135 +static struct attribute_spec latent_entropy_attr = {
103136 + .name = "latent_entropy",
103137 + .min_length = 0,
103138 + .max_length = 0,
103139 + .decl_required = true,
103140 + .type_required = false,
103141 + .function_type_required = false,
103142 + .handler = handle_latent_entropy_attribute,
103143 +#if BUILDING_GCC_VERSION >= 4007
103144 + .affects_type_identity = false
103145 +#endif
103146 +};
103147 +
103148 +static void register_attributes(void *event_data, void *data)
103149 +{
103150 + register_attribute(&latent_entropy_attr);
103151 +}
103152 +
103153 +static bool gate_latent_entropy(void)
103154 +{
103155 + tree latent_entropy_attr;
103156 +
103157 + latent_entropy_attr = lookup_attribute("latent_entropy", DECL_ATTRIBUTES(current_function_decl));
103158 + return latent_entropy_attr != NULL_TREE;
103159 +}
103160 +
103161 +static enum tree_code get_op(tree *rhs)
103162 +{
103163 + static enum tree_code op;
103164 + unsigned HOST_WIDE_INT random_const;
103165 +
103166 + random_const = get_random_const();
103167 +
103168 + switch (op) {
103169 + case BIT_XOR_EXPR:
103170 + op = PLUS_EXPR;
103171 + break;
103172 +
103173 + case PLUS_EXPR:
103174 + if (rhs) {
103175 + op = LROTATE_EXPR;
103176 + random_const &= HOST_BITS_PER_WIDE_INT - 1;
103177 + break;
103178 + }
103179 +
103180 + case LROTATE_EXPR:
103181 + default:
103182 + op = BIT_XOR_EXPR;
103183 + break;
103184 + }
103185 + if (rhs)
103186 + *rhs = build_int_cstu(unsigned_intDI_type_node, random_const);
103187 + return op;
103188 +}
103189 +
103190 +static void perturb_local_entropy(basic_block bb, tree local_entropy)
103191 +{
103192 + gimple_stmt_iterator gsi;
103193 + gimple assign;
103194 + tree addxorrol, rhs;
103195 + enum tree_code op;
103196 +
103197 + op = get_op(&rhs);
103198 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, op, unsigned_intDI_type_node, local_entropy, rhs);
103199 + assign = gimple_build_assign(local_entropy, addxorrol);
103200 + gsi = gsi_after_labels(bb);
103201 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
103202 + update_stmt(assign);
103203 +//debug_bb(bb);
103204 +}
103205 +
103206 +static void perturb_latent_entropy(basic_block bb, tree rhs)
103207 +{
103208 + gimple_stmt_iterator gsi;
103209 + gimple assign;
103210 + tree addxorrol, temp;
103211 +
103212 + // 1. create temporary copy of latent_entropy
103213 + temp = create_tmp_var(unsigned_intDI_type_node, "temp_latent_entropy");
103214 +#if BUILDING_GCC_VERSION <= 4007
103215 + add_referenced_var(temp);
103216 +#endif
103217 +
103218 + // 2. read...
103219 + temp = make_ssa_name(temp, NULL);
103220 + assign = gimple_build_assign(temp, latent_entropy_decl);
103221 + SSA_NAME_DEF_STMT(temp) = assign;
103222 +#if BUILDING_GCC_VERSION <= 4007
103223 + add_referenced_var(latent_entropy_decl);
103224 +#endif
103225 + gsi = gsi_after_labels(bb);
103226 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103227 + update_stmt(assign);
103228 +
103229 + // 3. ...modify...
103230 + addxorrol = fold_build2_loc(UNKNOWN_LOCATION, get_op(NULL), unsigned_intDI_type_node, temp, rhs);
103231 + temp = make_ssa_name(SSA_NAME_VAR(temp), NULL);
103232 + assign = gimple_build_assign(temp, addxorrol);
103233 + SSA_NAME_DEF_STMT(temp) = assign;
103234 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103235 + update_stmt(assign);
103236 +
103237 + // 4. ...write latent_entropy
103238 + assign = gimple_build_assign(latent_entropy_decl, temp);
103239 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103240 + update_stmt(assign);
103241 +}
103242 +
103243 +static unsigned int execute_latent_entropy(void)
103244 +{
103245 + basic_block bb;
103246 + gimple assign;
103247 + gimple_stmt_iterator gsi;
103248 + tree local_entropy;
103249 +
103250 + if (!latent_entropy_decl) {
103251 + struct varpool_node *node;
103252 +
103253 +#if BUILDING_GCC_VERSION <= 4007
103254 + for (node = varpool_nodes; node; node = node->next) {
103255 + tree var = node->decl;
103256 +#else
103257 + FOR_EACH_VARIABLE(node) {
103258 + tree var = node->symbol.decl;
103259 +#endif
103260 + if (strcmp(IDENTIFIER_POINTER(DECL_NAME(var)), "latent_entropy"))
103261 + continue;
103262 + latent_entropy_decl = var;
103263 +// debug_tree(var);
103264 + break;
103265 + }
103266 + if (!latent_entropy_decl) {
103267 +// debug_tree(current_function_decl);
103268 + return 0;
103269 + }
103270 + }
103271 +
103272 +//fprintf(stderr, "latent_entropy: %s\n", IDENTIFIER_POINTER(DECL_NAME(current_function_decl)));
103273 +
103274 + // 1. create local entropy variable
103275 + local_entropy = create_tmp_var(unsigned_intDI_type_node, "local_entropy");
103276 +#if BUILDING_GCC_VERSION <= 4007
103277 + add_referenced_var(local_entropy);
103278 + mark_sym_for_renaming(local_entropy);
103279 +#endif
103280 +
103281 + // 2. initialize local entropy variable
103282 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
103283 + if (dom_info_available_p(CDI_DOMINATORS))
103284 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
103285 + gsi = gsi_start_bb(bb);
103286 +
103287 + assign = gimple_build_assign(local_entropy, build_int_cstu(unsigned_intDI_type_node, get_random_const()));
103288 +// gimple_set_location(assign, loc);
103289 + gsi_insert_after(&gsi, assign, GSI_NEW_STMT);
103290 + update_stmt(assign);
103291 +//debug_bb(bb);
103292 + bb = bb->next_bb;
103293 +
103294 + // 3. instrument each BB with an operation on the local entropy variable
103295 + while (bb != EXIT_BLOCK_PTR) {
103296 + perturb_local_entropy(bb, local_entropy);
103297 +//debug_bb(bb);
103298 + bb = bb->next_bb;
103299 + };
103300 +
103301 + // 4. mix local entropy into the global entropy variable
103302 + perturb_latent_entropy(EXIT_BLOCK_PTR->prev_bb, local_entropy);
103303 +//debug_bb(EXIT_BLOCK_PTR->prev_bb);
103304 + return 0;
103305 +}
103306 +
103307 +static void start_unit_callback(void *gcc_data, void *user_data)
103308 +{
103309 + tree latent_entropy_type;
103310 +
103311 +#if BUILDING_GCC_VERSION >= 4007
103312 + seed = get_random_seed(false);
103313 +#else
103314 + sscanf(get_random_seed(false), "%" HOST_WIDE_INT_PRINT "x", &seed);
103315 + seed *= seed;
103316 +#endif
103317 +
103318 + if (in_lto_p)
103319 + return;
103320 +
103321 + // extern volatile u64 latent_entropy
103322 + gcc_assert(TYPE_PRECISION(long_long_unsigned_type_node) == 64);
103323 + latent_entropy_type = build_qualified_type(long_long_unsigned_type_node, TYPE_QUALS(long_long_unsigned_type_node) | TYPE_QUAL_VOLATILE);
103324 + latent_entropy_decl = build_decl(UNKNOWN_LOCATION, VAR_DECL, get_identifier("latent_entropy"), latent_entropy_type);
103325 +
103326 + TREE_STATIC(latent_entropy_decl) = 1;
103327 + TREE_PUBLIC(latent_entropy_decl) = 1;
103328 + TREE_USED(latent_entropy_decl) = 1;
103329 + TREE_THIS_VOLATILE(latent_entropy_decl) = 1;
103330 + DECL_EXTERNAL(latent_entropy_decl) = 1;
103331 + DECL_ARTIFICIAL(latent_entropy_decl) = 1;
103332 + lang_hooks.decls.pushdecl(latent_entropy_decl);
103333 +// DECL_ASSEMBLER_NAME(latent_entropy_decl);
103334 +// varpool_finalize_decl(latent_entropy_decl);
103335 +// varpool_mark_needed_node(latent_entropy_decl);
103336 +}
103337 +
103338 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
103339 +{
103340 + const char * const plugin_name = plugin_info->base_name;
103341 + struct register_pass_info latent_entropy_pass_info = {
103342 + .pass = &latent_entropy_pass.pass,
103343 + .reference_pass_name = "optimized",
103344 + .ref_pass_instance_number = 1,
103345 + .pos_op = PASS_POS_INSERT_BEFORE
103346 + };
103347 +
103348 + if (!plugin_default_version_check(version, &gcc_version)) {
103349 + error(G_("incompatible gcc/plugin versions"));
103350 + return 1;
103351 + }
103352 +
103353 + register_callback(plugin_name, PLUGIN_INFO, NULL, &latent_entropy_plugin_info);
103354 + register_callback ("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
103355 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &latent_entropy_pass_info);
103356 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
103357 +
103358 + return 0;
103359 +}
103360 diff --git a/tools/gcc/size_overflow_hash.data b/tools/gcc/size_overflow_hash.data
103361 new file mode 100644
103362 index 0000000..3d6cc0f
103363 --- /dev/null
103364 +++ b/tools/gcc/size_overflow_hash.data
103365 @@ -0,0 +1,7743 @@
103366 +intel_fake_agp_alloc_by_type_1 intel_fake_agp_alloc_by_type 1 1 NULL
103367 +ocfs2_get_refcount_tree_3 ocfs2_get_refcount_tree 0 3 NULL
103368 +batadv_orig_node_del_if_4 batadv_orig_node_del_if 2 4 NULL
103369 +storvsc_connect_to_vsp_22 storvsc_connect_to_vsp 2 22 NULL
103370 +compat_sock_setsockopt_23 compat_sock_setsockopt 5 23 NULL
103371 +carl9170_alloc_27 carl9170_alloc 1 27 NULL
103372 +sel_read_policyvers_55 sel_read_policyvers 3 55 NULL nohasharray
103373 +padzero_55 padzero 1 55 &sel_read_policyvers_55
103374 +cfg80211_disconnected_57 cfg80211_disconnected 4 57 NULL
103375 +__skb_to_sgvec_72 __skb_to_sgvec 0 72 NULL
103376 +crypto_authenc_setkey_80 crypto_authenc_setkey 3 80 NULL
103377 +snd_korg1212_copy_to_92 snd_korg1212_copy_to 6 92 NULL
103378 +load_msg_95 load_msg 2 95 NULL
103379 +device_flush_iotlb_115 device_flush_iotlb 2-3 115 NULL
103380 +write_all_supers_117 write_all_supers 0 117 NULL nohasharray
103381 +ipath_verbs_send_117 ipath_verbs_send 5-3 117 &write_all_supers_117
103382 +init_q_132 init_q 4 132 NULL
103383 +ocfs2_local_alloc_slide_window_134 ocfs2_local_alloc_slide_window 0 134 NULL
103384 +memstick_alloc_host_142 memstick_alloc_host 1 142 NULL
103385 +hva_to_gfn_memslot_149 hva_to_gfn_memslot 0-1 149 NULL
103386 +ping_v6_sendmsg_152 ping_v6_sendmsg 4 152 NULL
103387 +ext4_ext_get_actual_len_153 ext4_ext_get_actual_len 0 153 NULL nohasharray
103388 +tracing_trace_options_write_153 tracing_trace_options_write 3 153 &ext4_ext_get_actual_len_153
103389 +nvme_create_queue_170 nvme_create_queue 3 170 NULL
103390 +xfs_buf_item_get_format_189 xfs_buf_item_get_format 2 189 NULL
103391 +iscsi_session_setup_196 iscsi_session_setup 4-5 196 NULL
103392 +device_add_bin_attributes_205 device_add_bin_attributes 0 205 NULL
103393 +br_port_info_size_268 br_port_info_size 0 268 NULL
103394 +generic_file_direct_write_291 generic_file_direct_write 0 291 NULL
103395 +read_file_war_stats_292 read_file_war_stats 3 292 NULL
103396 +SYSC_connect_304 SYSC_connect 3 304 NULL
103397 +syslog_print_307 syslog_print 2 307 NULL
103398 +dn_setsockopt_314 dn_setsockopt 5 314 NULL
103399 +next_node_allowed_318 next_node_allowed 1-0 318 NULL
103400 +mlx5_core_access_reg_361 mlx5_core_access_reg 5-3 361 NULL
103401 +xfs_get_blocks_364 xfs_get_blocks 2 364 NULL
103402 +get_more_blocks_367 get_more_blocks 0 367 NULL
103403 +sysfs_create_dir_398 sysfs_create_dir 0 398 NULL
103404 +hw_device_state_409 hw_device_state 0 409 NULL
103405 +aio_read_events_ring_410 aio_read_events_ring 3 410 NULL
103406 +lbs_rdmac_read_418 lbs_rdmac_read 3 418 NULL
103407 +snd_ca0106_ptr_read_467 snd_ca0106_ptr_read 0 467 NULL
103408 +sparse_index_init_482 sparse_index_init 2 482 NULL
103409 +cfs_trace_set_debug_mb_usrstr_486 cfs_trace_set_debug_mb_usrstr 2 486 NULL
103410 +nvme_trans_modesel_data_488 nvme_trans_modesel_data 4 488 NULL
103411 +iwl_dbgfs_protection_mode_write_502 iwl_dbgfs_protection_mode_write 3 502 NULL
103412 +rx_rx_defrag_end_read_505 rx_rx_defrag_end_read 3 505 NULL
103413 +_snd_pcm_hw_param_first_516 _snd_pcm_hw_param_first 0 516 NULL
103414 +ocfs2_validate_meta_ecc_bhs_527 ocfs2_validate_meta_ecc_bhs 0 527 NULL
103415 +zlib_deflate_workspacesize_537 zlib_deflate_workspacesize 0-1-2 537 NULL
103416 +iwl_dbgfs_wowlan_sram_read_540 iwl_dbgfs_wowlan_sram_read 3 540 NULL
103417 +sco_sock_setsockopt_552 sco_sock_setsockopt 5 552 NULL
103418 +lpfc_nlp_state_name_556 lpfc_nlp_state_name 2 556 NULL
103419 +snd_aw2_saa7146_get_hw_ptr_playback_558 snd_aw2_saa7146_get_hw_ptr_playback 0 558 NULL
103420 +dev_hard_header_565 dev_hard_header 0 565 NULL nohasharray
103421 +start_isoc_chain_565 start_isoc_chain 2 565 &dev_hard_header_565
103422 +ocfs2_refcounted_xattr_delete_need_584 ocfs2_refcounted_xattr_delete_need 0 584 NULL
103423 +smk_write_load_self2_591 smk_write_load_self2 3 591 NULL
103424 +cl_page_own0_599 cl_page_own0 0 599 NULL
103425 +btrfs_stack_file_extent_offset_607 btrfs_stack_file_extent_offset 0 607 NULL
103426 +ni_gpct_device_construct_610 ni_gpct_device_construct 5 610 NULL
103427 +fuse_request_alloc_nofs_617 fuse_request_alloc_nofs 1 617 NULL
103428 +ptlrpc_lprocfs_nrs_seq_write_621 ptlrpc_lprocfs_nrs_seq_write 3 621 NULL
103429 +viafb_dfpl_proc_write_627 viafb_dfpl_proc_write 3 627 NULL
103430 +ocfs2_num_free_extents_632 ocfs2_num_free_extents 0 632 NULL
103431 +clone_split_bio_633 clone_split_bio 6 633 NULL
103432 +ceph_osdc_new_request_635 ceph_osdc_new_request 6 635 NULL
103433 +remap_to_cache_640 remap_to_cache 3 640 NULL
103434 +cfs_hash_bkt_size_643 cfs_hash_bkt_size 0 643 NULL nohasharray
103435 +drbd_bm_find_next_643 drbd_bm_find_next 2 643 &cfs_hash_bkt_size_643
103436 +unlink_queued_645 unlink_queued 4 645 NULL
103437 +dtim_interval_read_654 dtim_interval_read 3 654 NULL
103438 +div_u64_rem_672 div_u64_rem 0 672 NULL
103439 +mem_rx_free_mem_blks_read_675 mem_rx_free_mem_blks_read 3 675 NULL
103440 +persistent_ram_vmap_709 persistent_ram_vmap 1-2 709 NULL
103441 +ipath_resize_cq_712 ipath_resize_cq 2 712 NULL
103442 +disk_max_parts_719 disk_max_parts 0 719 NULL
103443 +sctp_setsockopt_peer_addr_params_734 sctp_setsockopt_peer_addr_params 3 734 NULL
103444 +dvb_video_write_754 dvb_video_write 3 754 NULL
103445 +cfs_trace_allocate_string_buffer_781 cfs_trace_allocate_string_buffer 2 781 NULL
103446 +jbd2_journal_dirty_metadata_784 jbd2_journal_dirty_metadata 0 784 NULL
103447 +ath6kl_disconnect_timeout_write_794 ath6kl_disconnect_timeout_write 3 794 NULL
103448 +__vmalloc_node_range_811 __vmalloc_node_range 7 811 NULL nohasharray
103449 +snd_pcm_drain_811 snd_pcm_drain 0 811 &__vmalloc_node_range_811
103450 +if_writecmd_815 if_writecmd 2 815 NULL
103451 +aac_change_queue_depth_825 aac_change_queue_depth 2 825 NULL
103452 +SyS_write_846 SyS_write 3 846 NULL
103453 +um_idi_read_850 um_idi_read 3 850 NULL
103454 +error_state_read_859 error_state_read 6 859 NULL
103455 +o2net_send_message_vec_879 o2net_send_message_vec 4 879 NULL nohasharray
103456 +iwl_dbgfs_fh_reg_read_879 iwl_dbgfs_fh_reg_read 3 879 &o2net_send_message_vec_879
103457 +intel_alloc_iova_883 intel_alloc_iova 3 883 NULL
103458 +snd_pcm_action_single_905 snd_pcm_action_single 0 905 NULL
103459 +readw_931 readw 0 931 NULL
103460 +carl9170_cmd_buf_950 carl9170_cmd_buf 3 950 NULL
103461 +__nodes_weight_956 __nodes_weight 2-0 956 NULL
103462 +bnx2x_fill_fw_str_968 bnx2x_fill_fw_str 3 968 NULL
103463 +memcmp_990 memcmp 0 990 NULL
103464 +pte_prefetch_gfn_to_pfn_997 pte_prefetch_gfn_to_pfn 2 997 NULL
103465 +free_ind_block_999 free_ind_block 0 999 NULL
103466 +dm_cache_set_dirty_1016 dm_cache_set_dirty 2 1016 NULL
103467 +readreg_1017 readreg 0-1 1017 NULL
103468 +_do_truncate_1019 _do_truncate 2 1019 NULL
103469 +smk_write_cipso2_1021 smk_write_cipso2 3 1021 NULL
103470 +gigaset_initdriver_1060 gigaset_initdriver 2 1060 NULL
103471 +mce_request_packet_1073 mce_request_packet 3 1073 NULL
103472 +agp_create_memory_1075 agp_create_memory 1 1075 NULL
103473 +ext4_orphan_add_1080 ext4_orphan_add 0 1080 NULL
103474 +_scsih_adjust_queue_depth_1083 _scsih_adjust_queue_depth 2 1083 NULL
103475 +llcp_sock_sendmsg_1092 llcp_sock_sendmsg 4 1092 NULL
103476 +inode_ref_info_1094 inode_ref_info 0 1094 NULL nohasharray
103477 +llc_mac_hdr_init_1094 llc_mac_hdr_init 0 1094 &inode_ref_info_1094
103478 +nfs4_init_nonuniform_client_string_1097 nfs4_init_nonuniform_client_string 3 1097 NULL
103479 +utf8s_to_utf16s_1115 utf8s_to_utf16s 0 1115 NULL
103480 +__btrfs_cow_block_1125 __btrfs_cow_block 7-0 1125 NULL nohasharray
103481 +__ext4_journal_stop_1125 __ext4_journal_stop 0 1125 &__btrfs_cow_block_1125
103482 +cfg80211_report_obss_beacon_1133 cfg80211_report_obss_beacon 3 1133 NULL
103483 +vmalloc_32_1135 vmalloc_32 1 1135 NULL
103484 +i2400m_rx_ctl_1157 i2400m_rx_ctl 4 1157 NULL
103485 +find_free_extent_1173 find_free_extent 4-0 1173 NULL
103486 +ipc_alloc_1192 ipc_alloc 1 1192 NULL
103487 +ib_create_send_mad_1196 ib_create_send_mad 5 1196 NULL
103488 +pstore_ftrace_knob_write_1198 pstore_ftrace_knob_write 3 1198 NULL
103489 +i2400m_rx_ctl_ack_1199 i2400m_rx_ctl_ack 3 1199 NULL
103490 +dgrp_dpa_read_1204 dgrp_dpa_read 3 1204 NULL
103491 +i2cdev_read_1206 i2cdev_read 3 1206 NULL
103492 +lov_ost_pool_init_1215 lov_ost_pool_init 2 1215 NULL
103493 +acpi_battery_write_alarm_1240 acpi_battery_write_alarm 3 1240 NULL
103494 +nested_get_page_1252 nested_get_page 2 1252 NULL
103495 +ocfs2_extend_file_1266 ocfs2_extend_file 3 1266 NULL
103496 +qla4xxx_change_queue_depth_1268 qla4xxx_change_queue_depth 2 1268 NULL
103497 +ioctl_private_iw_point_1273 ioctl_private_iw_point 7 1273 NULL
103498 +batadv_tt_prepare_packet_buff_1280 batadv_tt_prepare_packet_buff 4 1280 NULL
103499 +SyS_flistxattr_1287 SyS_flistxattr 3 1287 NULL
103500 +tx_frag_in_process_called_read_1290 tx_frag_in_process_called_read 3 1290 NULL
103501 +ocfs2_append_rec_to_path_1321 ocfs2_append_rec_to_path 0 1321 NULL
103502 +ffs_1322 ffs 0 1322 NULL
103503 +qlcnic_pci_sriov_configure_1327 qlcnic_pci_sriov_configure 2 1327 NULL nohasharray
103504 +push_node_left_1327 push_node_left 0 1327 &qlcnic_pci_sriov_configure_1327
103505 +btrfs_submit_compressed_write_1347 btrfs_submit_compressed_write 5 1347 NULL
103506 +gen_pool_best_fit_1348 gen_pool_best_fit 2-3-4 1348 NULL
103507 +btrfs_alloc_logged_file_extent_1354 btrfs_alloc_logged_file_extent 0 1354 NULL
103508 +snd_pcm_lib_write1_1358 snd_pcm_lib_write1 0-3 1358 NULL
103509 +ipx_sendmsg_1362 ipx_sendmsg 4 1362 NULL
103510 +iov_num_pages_1364 iov_num_pages 0 1364 NULL
103511 +fw_stats_raw_read_1369 fw_stats_raw_read 3 1369 NULL
103512 +ocfs2_prepare_inode_for_write_1372 ocfs2_prepare_inode_for_write 3 1372 NULL
103513 +sctp_setsockopt_initmsg_1383 sctp_setsockopt_initmsg 3 1383 NULL
103514 +do_msgsnd_1387 do_msgsnd 4 1387 NULL
103515 +SYSC_io_getevents_1392 SYSC_io_getevents 3 1392 NULL
103516 +zone_page_state_1393 zone_page_state 0 1393 NULL
103517 +file_read_actor_1401 file_read_actor 4 1401 NULL
103518 +vb2_vmalloc_alloc_1402 vb2_vmalloc_alloc 2 1402 NULL
103519 +cfs_trace_copyout_string_1416 cfs_trace_copyout_string 2 1416 NULL
103520 +pq_init_1423 pq_init 1 1423 NULL
103521 +init_rs_internal_1436 init_rs_internal 1 1436 NULL
103522 +vb2_dc_get_user_pages_1442 vb2_dc_get_user_pages 1-3 1442 NULL
103523 +stack_max_size_read_1445 stack_max_size_read 3 1445 NULL
103524 +tx_queue_len_read_1463 tx_queue_len_read 3 1463 NULL
103525 +xprt_alloc_1475 xprt_alloc 2 1475 NULL
103526 +SYSC_syslog_1477 SYSC_syslog 3 1477 NULL
103527 +sta_num_ps_buf_frames_read_1488 sta_num_ps_buf_frames_read 3 1488 NULL
103528 +posix_acl_permission_1495 posix_acl_permission 0 1495 NULL
103529 +fpregs_set_1497 fpregs_set 4 1497 NULL
103530 +ocfs2_alloc_dinode_update_counts_1507 ocfs2_alloc_dinode_update_counts 0 1507 NULL
103531 +tomoyo_round2_1518 tomoyo_round2 0 1518 NULL
103532 +alloc_perm_bits_1532 alloc_perm_bits 2 1532 NULL
103533 +ath6kl_init_get_fwcaps_1557 ath6kl_init_get_fwcaps 3 1557 NULL
103534 +extent_from_logical_1585 extent_from_logical 0 1585 NULL
103535 +ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime_1589 ieee80211_if_read_dot11MeshHWMPnetDiameterTraversalTime 3 1589 NULL
103536 +ipath_ht_handle_hwerrors_1592 ipath_ht_handle_hwerrors 3 1592 NULL
103537 +packet_buffer_init_1607 packet_buffer_init 2 1607 NULL
103538 +btmrvl_hscmd_read_1614 btmrvl_hscmd_read 3 1614 NULL
103539 +v9fs_fid_xattr_get_1618 v9fs_fid_xattr_get 0 1618 NULL
103540 +run_delayed_extent_op_1637 run_delayed_extent_op 0 1637 NULL
103541 +ikconfig_read_current_1658 ikconfig_read_current 3 1658 NULL
103542 +qgroup_rescan_init_1664 qgroup_rescan_init 0 1664 NULL
103543 +mei_cl_recv_1665 mei_cl_recv 3 1665 NULL
103544 +rmap_add_1677 rmap_add 3 1677 NULL
103545 +configfs_read_file_1683 configfs_read_file 3 1683 NULL
103546 +pdu_write_u_1710 pdu_write_u 3 1710 NULL
103547 +coda_psdev_write_1711 coda_psdev_write 3 1711 NULL nohasharray
103548 +gfn_to_hva_prot_1711 gfn_to_hva_prot 2 1711 &coda_psdev_write_1711
103549 +btrfs_dir_data_len_1714 btrfs_dir_data_len 0 1714 NULL
103550 +dma_memcpy_pg_to_iovec_1725 dma_memcpy_pg_to_iovec 6 1725 NULL
103551 +internal_create_group_1733 internal_create_group 0 1733 NULL
103552 +dev_irnet_read_1741 dev_irnet_read 3 1741 NULL
103553 +tx_frag_called_read_1748 tx_frag_called_read 3 1748 NULL
103554 +ebt_size_mwt_1768 ebt_size_mwt 0 1768 NULL
103555 +cosa_write_1774 cosa_write 3 1774 NULL
103556 +fcoe_ctlr_device_add_1793 fcoe_ctlr_device_add 3 1793 NULL
103557 +__nodelist_scnprintf_1815 __nodelist_scnprintf 4-2-0 1815 NULL
103558 +sb_issue_zeroout_1884 sb_issue_zeroout 3-0 1884 NULL
103559 +rx_defrag_called_read_1897 rx_defrag_called_read 3 1897 NULL
103560 +nfs_parse_server_name_1899 nfs_parse_server_name 2 1899 NULL
103561 +SyS_add_key_1900 SyS_add_key 4 1900 NULL
103562 +uhid_char_read_1920 uhid_char_read 3 1920 NULL
103563 +tx_tx_retry_data_read_1926 tx_tx_retry_data_read 3 1926 NULL
103564 +bdev_erase_1933 bdev_erase 3 1933 NULL
103565 +ext3_fiemap_1936 ext3_fiemap 4 1936 NULL
103566 +cyttsp_probe_1940 cyttsp_probe 4 1940 NULL
103567 +ieee80211_if_fmt_dot11MeshConfirmTimeout_1945 ieee80211_if_fmt_dot11MeshConfirmTimeout 3 1945 NULL
103568 +read_swap_header_1957 read_swap_header 0 1957 NULL
103569 +ivtv_v4l2_read_1964 ivtv_v4l2_read 3 1964 NULL
103570 +sel_read_avc_hash_stats_1984 sel_read_avc_hash_stats 3 1984 NULL
103571 +gpio_power_write_1991 gpio_power_write 3 1991 NULL
103572 +__alloc_bootmem_node_1992 __alloc_bootmem_node 2 1992 NULL
103573 +atomic_read_unchecked_1995 atomic_read_unchecked 0 1995 NULL
103574 +sb_min_blocksize_2004 sb_min_blocksize 0-2 2004 NULL
103575 +batadv_tt_commit_changes_2008 batadv_tt_commit_changes 4 2008 NULL
103576 +sep_prepare_input_dma_table_2009 sep_prepare_input_dma_table 2-3 2009 NULL
103577 +rx_rx_defrag_read_2010 rx_rx_defrag_read 3 2010 NULL
103578 +ksm_madvise_2012 ksm_madvise 0 2012 NULL
103579 +ocfs2_global_qinit_alloc_2018 ocfs2_global_qinit_alloc 0 2018 NULL
103580 +write_flush_pipefs_2021 write_flush_pipefs 3 2021 NULL
103581 +BcmCopySection_2035 BcmCopySection 5-0 2035 NULL
103582 +ath6kl_fwlog_mask_read_2050 ath6kl_fwlog_mask_read 3 2050 NULL
103583 +ocfs2_expand_inline_dir_2063 ocfs2_expand_inline_dir 3 2063 NULL
103584 +__generic_copy_from_user_intel_2073 __generic_copy_from_user_intel 0-3 2073 NULL
103585 +diva_set_driver_dbg_mask_2077 diva_set_driver_dbg_mask 0 2077 NULL nohasharray
103586 +alloc_retstack_tasklist_2077 alloc_retstack_tasklist 0 2077 &diva_set_driver_dbg_mask_2077
103587 +iwl_dbgfs_current_sleep_command_read_2081 iwl_dbgfs_current_sleep_command_read 3 2081 NULL
103588 +get_unaligned_le32_2092 get_unaligned_le32 0 2092 NULL
103589 +idetape_chrdev_read_2097 idetape_chrdev_read 3 2097 NULL
103590 +audit_expand_2098 audit_expand 0 2098 NULL
103591 +num_pages_spanned_2105 num_pages_spanned 0 2105 NULL
103592 +shrd128_2106 shrd128 0-1-3-2 2106 NULL
103593 +iwl_dbgfs_log_event_read_2107 iwl_dbgfs_log_event_read 3 2107 NULL
103594 +ecryptfs_encrypt_and_encode_filename_2109 ecryptfs_encrypt_and_encode_filename 6 2109 NULL
103595 +enable_read_2117 enable_read 3 2117 NULL
103596 +pcf50633_write_block_2124 pcf50633_write_block 2-3 2124 NULL
103597 +snd_interval_refine_last_2127 snd_interval_refine_last 0 2127 NULL
103598 +check_load_and_stores_2143 check_load_and_stores 2 2143 NULL
103599 +lp_gpio_irq_map_2149 lp_gpio_irq_map 2 2149 NULL
103600 +iov_iter_count_2152 iov_iter_count 0 2152 NULL
103601 +__copy_to_user_ll_2157 __copy_to_user_ll 0-3 2157 NULL
103602 +ocfs2_et_sanity_check_2164 ocfs2_et_sanity_check 0 2164 NULL
103603 +_ore_get_io_state_2166 _ore_get_io_state 5-3-4 2166 NULL
103604 +bio_integrity_alloc_2194 bio_integrity_alloc 3 2194 NULL
103605 +picolcd_debug_reset_write_2195 picolcd_debug_reset_write 3 2195 NULL
103606 +mei_dbgfs_read_meclients_2219 mei_dbgfs_read_meclients 3 2219 NULL nohasharray
103607 +u32_array_read_2219 u32_array_read 3 2219 &mei_dbgfs_read_meclients_2219
103608 +vhci_write_2224 vhci_write 3 2224 NULL
103609 +__ocfs2_journal_access_2241 __ocfs2_journal_access 0 2241 NULL
103610 +ieee80211_if_read_dot11MeshHWMPRannInterval_2249 ieee80211_if_read_dot11MeshHWMPRannInterval 3 2249 NULL
103611 +netlbl_secattr_catmap_walk_2255 netlbl_secattr_catmap_walk 0-2 2255 NULL
103612 +sel_write_avc_cache_threshold_2256 sel_write_avc_cache_threshold 3 2256 NULL
103613 +do_update_counters_2259 do_update_counters 4 2259 NULL
103614 +ath6kl_wmi_bssinfo_event_rx_2275 ath6kl_wmi_bssinfo_event_rx 3 2275 NULL
103615 +debug_debug5_read_2291 debug_debug5_read 3 2291 NULL
103616 +ocfs2_shift_tree_depth_2292 ocfs2_shift_tree_depth 0 2292 NULL
103617 +kvm_clear_guest_page_2308 kvm_clear_guest_page 2-4 2308 NULL
103618 +intel_sdvo_set_value_2311 intel_sdvo_set_value 4 2311 NULL
103619 +picolcd_fb_write_2318 picolcd_fb_write 3 2318 NULL nohasharray
103620 +hfsplus_find_init_2318 hfsplus_find_init 0 2318 &picolcd_fb_write_2318
103621 +gart_map_page_2325 gart_map_page 4-3 2325 NULL
103622 +__erst_read_to_erange_2341 __erst_read_to_erange 0 2341 NULL
103623 +zr364xx_read_2354 zr364xx_read 3 2354 NULL
103624 +viafb_iga2_odev_proc_write_2363 viafb_iga2_odev_proc_write 3 2363 NULL
103625 +SyS_mremap_2367 SyS_mremap 2-3-1-5 2367 NULL
103626 +xfs_buf_map_from_irec_2368 xfs_buf_map_from_irec 5 2368 NULL nohasharray
103627 +rose_recvmsg_2368 rose_recvmsg 4 2368 &xfs_buf_map_from_irec_2368
103628 +il_dbgfs_sensitivity_read_2370 il_dbgfs_sensitivity_read 3 2370 NULL
103629 +rxpipe_rx_prep_beacon_drop_read_2403 rxpipe_rx_prep_beacon_drop_read 3 2403 NULL
103630 +SYSC_mlock_2415 SYSC_mlock 1-2 2415 NULL
103631 +isdn_v110_open_2418 isdn_v110_open 3 2418 NULL
103632 +raid1_size_2419 raid1_size 0-2 2419 NULL
103633 +timespec_to_jiffies_timeout_2428 timespec_to_jiffies_timeout 0 2428 NULL
103634 +tty_buffer_find_2443 tty_buffer_find 2 2443 NULL
103635 +b43legacy_debugfs_read_2473 b43legacy_debugfs_read 3 2473 NULL
103636 +wiphy_new_2482 wiphy_new 2 2482 NULL
103637 +bio_alloc_bioset_2484 bio_alloc_bioset 2 2484 NULL
103638 +hfsplus_user_setxattr_2485 hfsplus_user_setxattr 4 2485 NULL
103639 +lookup_cache_entry_2494 lookup_cache_entry 2 2494 NULL
103640 +squashfs_read_fragment_index_table_2506 squashfs_read_fragment_index_table 4 2506 NULL
103641 +v9fs_cached_file_read_2514 v9fs_cached_file_read 3 2514 NULL
103642 +ext4_get_inode_loc_2516 ext4_get_inode_loc 0 2516 NULL
103643 +gspca_dev_probe_2570 gspca_dev_probe 4 2570 NULL
103644 +pcm_sanity_check_2574 pcm_sanity_check 0 2574 NULL
103645 +mdc_max_rpcs_in_flight_seq_write_2594 mdc_max_rpcs_in_flight_seq_write 3 2594 NULL
103646 +slot_bytes_2609 slot_bytes 0 2609 NULL
103647 +smk_write_logging_2618 smk_write_logging 3 2618 NULL
103648 +switch_status_2629 switch_status 5 2629 NULL
103649 +tlv_put_string_2631 tlv_put_string 0 2631 NULL
103650 +kvm_gfn_to_hva_cache_init_2636 kvm_gfn_to_hva_cache_init 3 2636 NULL
103651 +tcp_xmit_size_goal_2661 tcp_xmit_size_goal 2 2661 NULL
103652 +osc_build_ppga_2670 osc_build_ppga 2 2670 NULL
103653 +ffs_ep0_read_2672 ffs_ep0_read 3 2672 NULL
103654 +ocfs2_rotate_subtree_right_2674 ocfs2_rotate_subtree_right 0 2674 NULL
103655 +oti6858_write_2692 oti6858_write 4 2692 NULL
103656 +nfc_llcp_send_ui_frame_2702 nfc_llcp_send_ui_frame 5 2702 NULL
103657 +memcpy_fromiovecend_2707 memcpy_fromiovecend 4-3 2707 NULL
103658 +SyS_pwrite64_2708 SyS_pwrite64 3 2708 NULL nohasharray
103659 +lprocfs_stats_counter_size_2708 lprocfs_stats_counter_size 0 2708 &SyS_pwrite64_2708
103660 +__xip_file_write_2733 __xip_file_write 3-4 2733 NULL
103661 +can_nocow_extent_2744 can_nocow_extent 3 2744 NULL
103662 +xfs_readdir_2767 xfs_readdir 3 2767 NULL
103663 +mon_bin_ioctl_2771 mon_bin_ioctl 3 2771 NULL nohasharray
103664 +bictcp_update_2771 bictcp_update 2 2771 &mon_bin_ioctl_2771
103665 +__next_cpu_2782 __next_cpu 1-0 2782 NULL
103666 +set_msr_hyperv_pw_2785 set_msr_hyperv_pw 3 2785 NULL
103667 +device_add_attrs_2789 device_add_attrs 0 2789 NULL
103668 +iwl_dbgfs_clear_ucode_statistics_write_2804 iwl_dbgfs_clear_ucode_statistics_write 3 2804 NULL
103669 +vmemmap_pte_populate_2822 vmemmap_pte_populate 3 2822 NULL
103670 +sel_read_enforce_2828 sel_read_enforce 3 2828 NULL
103671 +vb2_dc_get_userptr_2829 vb2_dc_get_userptr 2-3 2829 NULL nohasharray
103672 +snd_pcm_reset_2829 snd_pcm_reset 0 2829 &vb2_dc_get_userptr_2829
103673 +sock_create_2838 sock_create 0 2838 NULL
103674 +wait_for_avail_2847 wait_for_avail 0 2847 NULL
103675 +ufs_free_fragments_2857 ufs_free_fragments 2 2857 NULL
103676 +sfq_alloc_2861 sfq_alloc 1 2861 NULL
103677 +irnet_ctrl_read_2863 irnet_ctrl_read 4 2863 NULL
103678 +move_addr_to_user_2868 move_addr_to_user 2 2868 NULL
103679 +mq_map_2871 mq_map 2 2871 NULL
103680 +__swab64p_2875 __swab64p 0 2875 NULL
103681 +nla_padlen_2883 nla_padlen 1 2883 NULL
103682 +cmm_write_2896 cmm_write 3 2896 NULL
103683 +alloc_page_cgroup_2919 alloc_page_cgroup 1-2 2919 NULL
103684 +osc_import_seq_write_2923 osc_import_seq_write 3 2923 NULL
103685 +xfs_trans_get_buf_map_2927 xfs_trans_get_buf_map 4 2927 NULL
103686 +nes_read_indexed_2946 nes_read_indexed 0 2946 NULL
103687 +tm6000_i2c_recv_regs16_2949 tm6000_i2c_recv_regs16 5 2949 NULL
103688 +i40e_dbg_prep_dump_buf_2951 i40e_dbg_prep_dump_buf 2 2951 NULL
103689 +set_fast_connectable_2952 set_fast_connectable 4 2952 NULL
103690 +free_area_init_core_2962 free_area_init_core 2-3 2962 NULL
103691 +do_strnlen_user_2976 do_strnlen_user 0-2 2976 NULL
103692 +ocfs2_find_branch_target_2989 ocfs2_find_branch_target 0 2989 NULL
103693 +p9_nr_pages_2992 p9_nr_pages 0-2 2992 NULL
103694 +lov_stripetype_seq_write_3013 lov_stripetype_seq_write 3 3013 NULL
103695 +btrfs_add_block_group_cache_3016 btrfs_add_block_group_cache 0 3016 NULL
103696 +do_dmabuf_dirty_sou_3017 do_dmabuf_dirty_sou 7 3017 NULL
103697 +depth_write_3021 depth_write 3 3021 NULL
103698 +snd_azf3328_codec_inl_3022 snd_azf3328_codec_inl 0 3022 NULL
103699 +kvm_unmap_hva_3028 kvm_unmap_hva 2 3028 NULL
103700 +xfrm_dst_alloc_copy_3034 xfrm_dst_alloc_copy 3 3034 NULL
103701 +lpfc_idiag_mbxacc_write_3038 lpfc_idiag_mbxacc_write 3 3038 NULL nohasharray
103702 +iwl_dbgfs_sleep_level_override_read_3038 iwl_dbgfs_sleep_level_override_read 3 3038 &lpfc_idiag_mbxacc_write_3038
103703 +nr_free_buffer_pages_3044 nr_free_buffer_pages 0 3044 NULL
103704 +il3945_ucode_rx_stats_read_3048 il3945_ucode_rx_stats_read 3 3048 NULL
103705 +qp_alloc_ppn_set_3068 qp_alloc_ppn_set 2-4 3068 NULL
103706 +__blk_end_bidi_request_3070 __blk_end_bidi_request 4-3 3070 NULL
103707 +dac960_user_command_proc_write_3071 dac960_user_command_proc_write 3 3071 NULL
103708 +read_file_antenna_diversity_3077 read_file_antenna_diversity 3 3077 NULL
103709 +free_coherent_3082 free_coherent 4-2 3082 NULL
103710 +ocfs2_get_right_path_3097 ocfs2_get_right_path 0 3097 NULL
103711 +clone_bio_3100 clone_bio 6 3100 NULL nohasharray
103712 +ttusb2_msg_3100 ttusb2_msg 4 3100 &clone_bio_3100
103713 +rb_alloc_3102 rb_alloc 1-3 3102 NULL
103714 +simple_write_to_buffer_3122 simple_write_to_buffer 2-5 3122 NULL
103715 +print_time_3132 print_time 0 3132 NULL
103716 +fill_write_buffer_3142 fill_write_buffer 3 3142 NULL
103717 +find_free_extent_3153 find_free_extent 5 3153 NULL
103718 +CIFSSMBSetPosixACL_3154 CIFSSMBSetPosixACL 5 3154 NULL
103719 +compat_sys_migrate_pages_3157 compat_sys_migrate_pages 2 3157 NULL
103720 +i915_gem_obj_ggtt_offset_3162 i915_gem_obj_ggtt_offset 0 3162 NULL
103721 +uv_num_possible_blades_3177 uv_num_possible_blades 0 3177 NULL
103722 +uvc_video_stats_dump_3181 uvc_video_stats_dump 3 3181 NULL
103723 +compat_do_ip6t_set_ctl_3184 compat_do_ip6t_set_ctl 4 3184 NULL
103724 +wait_table_bits_3187 wait_table_bits 1 3187 NULL
103725 +mempool_create_node_3191 mempool_create_node 1-6 3191 NULL
103726 +alloc_context_3194 alloc_context 1 3194 NULL
103727 +shmem_pread_slow_3198 shmem_pread_slow 3-2 3198 NULL
103728 +codec_reg_write_file_3204 codec_reg_write_file 3 3204 NULL
103729 +SyS_sendto_3219 SyS_sendto 6 3219 NULL
103730 +btrfs_prealloc_file_range_3227 btrfs_prealloc_file_range 3 3227 NULL
103731 +btrfs_next_leaf_3232 btrfs_next_leaf 0 3232 NULL
103732 +kimage_crash_alloc_3233 kimage_crash_alloc 3 3233 NULL
103733 +write_adapter_mem_3234 write_adapter_mem 3 3234 NULL
103734 +do_read_log_to_user_3236 do_read_log_to_user 4 3236 NULL
103735 +ext3_xattr_find_entry_3237 ext3_xattr_find_entry 0 3237 NULL
103736 +key_key_read_3241 key_key_read 3 3241 NULL
103737 +mmap_piobufs_3244 mmap_piobufs 4 3244 NULL
103738 +did_overwrite_first_ref_3259 did_overwrite_first_ref 0 3259 NULL
103739 +__ilog2_u64_3284 __ilog2_u64 0 3284 NULL
103740 +__iovec_copy_from_user_inatomic_3314 __iovec_copy_from_user_inatomic 0-4-3 3314 NULL
103741 +dbDiscardAG_3322 dbDiscardAG 3 3322 NULL
103742 +compat_sys_setsockopt_3326 compat_sys_setsockopt 5 3326 NULL
103743 +read_from_oldmem_3337 read_from_oldmem 2 3337 NULL
103744 +sysfs_create_group_3339 sysfs_create_group 0 3339 NULL
103745 +tty_port_register_device_attr_3341 tty_port_register_device_attr 3 3341 NULL
103746 +il_dbgfs_interrupt_read_3351 il_dbgfs_interrupt_read 3 3351 NULL
103747 +gsm_control_rls_3353 gsm_control_rls 3 3353 NULL
103748 +scnprintf_3360 scnprintf 0-2 3360 NULL
103749 +ReadByteAmd7930_3365 ReadByteAmd7930 0 3365 NULL
103750 +sr_read_3366 sr_read 3 3366 NULL
103751 +count_inode_refs_3375 count_inode_refs 0 3375 NULL
103752 +x86_emulate_instruction_3389 x86_emulate_instruction 2 3389 NULL
103753 +mtdchar_writeoob_3393 mtdchar_writeoob 4 3393 NULL
103754 +send_stream_3397 send_stream 4 3397 NULL
103755 +isdn_readbchan_3401 isdn_readbchan 0-5 3401 NULL
103756 +mei_io_cb_alloc_resp_buf_3414 mei_io_cb_alloc_resp_buf 2 3414 NULL
103757 +zone_to_nid_3415 zone_to_nid 0 3415 NULL
103758 +pci_add_cap_save_buffer_3426 pci_add_cap_save_buffer 3 3426 NULL
103759 +crystalhd_create_dio_pool_3427 crystalhd_create_dio_pool 2 3427 NULL
103760 +SyS_msgsnd_3436 SyS_msgsnd 3 3436 NULL
103761 +send_unlink_3438 send_unlink 0 3438 NULL
103762 +pipe_iov_copy_to_user_3447 pipe_iov_copy_to_user 3 3447 NULL
103763 +map_single_3449 map_single 0 3449 NULL
103764 +softsynth_write_3455 softsynth_write 3 3455 NULL
103765 +jffs2_acl_setxattr_3464 jffs2_acl_setxattr 4 3464 NULL nohasharray
103766 +snd_pcm_lib_readv_transfer_3464 snd_pcm_lib_readv_transfer 5-4-2 3464 &jffs2_acl_setxattr_3464
103767 +security_context_to_sid_default_3492 security_context_to_sid_default 2 3492 NULL
103768 +xfrm_migrate_msgsize_3496 xfrm_migrate_msgsize 1 3496 NULL
103769 +run_one_delayed_ref_3503 run_one_delayed_ref 0 3503 NULL nohasharray
103770 +kvm_handle_bad_page_3503 kvm_handle_bad_page 2 3503 &run_one_delayed_ref_3503
103771 +mem_tx_free_mem_blks_read_3521 mem_tx_free_mem_blks_read 3 3521 NULL
103772 +SyS_semtimedop_3532 SyS_semtimedop 3 3532 NULL
103773 +SyS_readv_3539 SyS_readv 3 3539 NULL
103774 +btrfs_dir_name_len_3549 btrfs_dir_name_len 0 3549 NULL
103775 +iommu_map_3554 iommu_map 3-2 3554 NULL
103776 +btrfs_delayed_update_inode_3557 btrfs_delayed_update_inode 0 3557 NULL
103777 +i915_gem_execbuffer_reserve_3558 i915_gem_execbuffer_reserve 0 3558 NULL
103778 +alloc_smp_resp_3566 alloc_smp_resp 1 3566 NULL
103779 +evtchn_read_3569 evtchn_read 3 3569 NULL
103780 +ll_track_ppid_seq_write_3582 ll_track_ppid_seq_write 3 3582 NULL
103781 +vc_resize_3585 vc_resize 3-2 3585 NULL
103782 +kvm_mmu_notifier_change_pte_3596 kvm_mmu_notifier_change_pte 3 3596 NULL
103783 +sctp_getsockopt_events_3607 sctp_getsockopt_events 2 3607 NULL
103784 +edac_mc_alloc_3611 edac_mc_alloc 4 3611 NULL
103785 +tx_tx_starts_read_3617 tx_tx_starts_read 3 3617 NULL
103786 +aligned_kmalloc_3628 aligned_kmalloc 1 3628 NULL
103787 +x86_swiotlb_alloc_coherent_3649 x86_swiotlb_alloc_coherent 2 3649 NULL
103788 +ath6kl_disconnect_timeout_read_3650 ath6kl_disconnect_timeout_read 3 3650 NULL
103789 +i915_compat_ioctl_3656 i915_compat_ioctl 2 3656 NULL
103790 +replace_pin_at_irq_node_3687 replace_pin_at_irq_node 2 3687 NULL
103791 +ntfs_attr_make_non_resident_3694 ntfs_attr_make_non_resident 0-2 3694 NULL
103792 +snd_m3_assp_read_3703 snd_m3_assp_read 0 3703 NULL nohasharray
103793 +create_irq_3703 create_irq 0 3703 &snd_m3_assp_read_3703
103794 +videobuf_pages_to_sg_3708 videobuf_pages_to_sg 2 3708 NULL
103795 +ci_ll_write_3740 ci_ll_write 4 3740 NULL nohasharray
103796 +ath6kl_mgmt_tx_3740 ath6kl_mgmt_tx 7 3740 &ci_ll_write_3740
103797 +uar_index2pfn_3741 uar_index2pfn 0-2 3741 NULL
103798 +sctp_setsockopt_auth_key_3793 sctp_setsockopt_auth_key 3 3793 NULL
103799 +btrfs_alloc_chunk_3808 btrfs_alloc_chunk 0 3808 NULL
103800 +ncp_file_write_3813 ncp_file_write 3 3813 NULL
103801 +llc_ui_recvmsg_3826 llc_ui_recvmsg 4 3826 NULL
103802 +btrfs_uuid_iter_rem_3831 btrfs_uuid_iter_rem 0 3831 NULL
103803 +hfsplus_direct_IO_3835 hfsplus_direct_IO 4 3835 NULL
103804 +stringify_nodemap_3842 stringify_nodemap 2 3842 NULL
103805 +ubi_eba_read_leb_3847 ubi_eba_read_leb 0 3847 NULL
103806 +create_one_cdev_3852 create_one_cdev 2 3852 NULL
103807 +smk_read_onlycap_3855 smk_read_onlycap 3 3855 NULL
103808 +get_fd_set_3866 get_fd_set 1 3866 NULL
103809 +apei_res_sub_3873 apei_res_sub 0 3873 NULL
103810 +garp_attr_create_3883 garp_attr_create 3 3883 NULL
103811 +efivarfs_file_read_3893 efivarfs_file_read 3 3893 NULL
103812 +nvram_write_3894 nvram_write 3 3894 NULL
103813 +pipeline_pre_proc_swi_read_3898 pipeline_pre_proc_swi_read 3 3898 NULL
103814 +comedi_buf_read_n_available_3899 comedi_buf_read_n_available 0 3899 NULL
103815 +vcs_write_3910 vcs_write 3 3910 NULL
103816 +SyS_move_pages_3920 SyS_move_pages 2 3920 NULL
103817 +hdlc_irq_one_3944 hdlc_irq_one 2 3944 NULL
103818 +brcmf_debugfs_fws_stats_read_3947 brcmf_debugfs_fws_stats_read 3 3947 NULL
103819 +mite_bytes_written_to_memory_lb_3987 mite_bytes_written_to_memory_lb 0 3987 NULL
103820 +do_add_counters_3992 do_add_counters 3 3992 NULL
103821 +obd_alloc_memmd_4002 obd_alloc_memmd 0 4002 NULL
103822 +userspace_status_4004 userspace_status 4 4004 NULL
103823 +mei_write_4005 mei_write 3 4005 NULL nohasharray
103824 +xfs_check_block_4005 xfs_check_block 4 4005 &mei_write_4005
103825 +snd_hdsp_capture_copy_4011 snd_hdsp_capture_copy 5 4011 NULL
103826 +mm_populate_4016 mm_populate 1-2 4016 NULL nohasharray
103827 +i915_gem_object_unbind_4016 i915_gem_object_unbind 0 4016 &mm_populate_4016
103828 +blk_end_request_4024 blk_end_request 3 4024 NULL
103829 +ext4_xattr_find_entry_4025 ext4_xattr_find_entry 0 4025 NULL
103830 +mtip_hw_read_registers_4037 mtip_hw_read_registers 3 4037 NULL
103831 +i915_gpu_idle_4062 i915_gpu_idle 0 4062 NULL
103832 +vmemmap_pmd_populate_4071 vmemmap_pmd_populate 3 4071 NULL
103833 +read_file_queues_4078 read_file_queues 3 4078 NULL
103834 +fbcon_do_set_font_4079 fbcon_do_set_font 2-3 4079 NULL
103835 +btrfs_inc_ref_4084 btrfs_inc_ref 0 4084 NULL
103836 +da9052_free_irq_4090 da9052_free_irq 2 4090 NULL
103837 +tm6000_read_4151 tm6000_read 3 4151 NULL
103838 +mpt_raid_phys_disk_get_num_paths_4155 mpt_raid_phys_disk_get_num_paths 0 4155 NULL
103839 +msg_bits_4158 msg_bits 0-3-4 4158 NULL
103840 +get_alua_req_4166 get_alua_req 3 4166 NULL
103841 +blk_dropped_read_4168 blk_dropped_read 3 4168 NULL
103842 +read_file_bool_4180 read_file_bool 3 4180 NULL
103843 +ocfs2_find_cpos_for_right_leaf_4194 ocfs2_find_cpos_for_right_leaf 0 4194 NULL
103844 +f1x_determine_channel_4202 f1x_determine_channel 2 4202 NULL
103845 +_osd_req_list_objects_4204 _osd_req_list_objects 6 4204 NULL
103846 +__snd_gf1_read_addr_4210 __snd_gf1_read_addr 0 4210 NULL
103847 +ath6kl_force_roam_write_4282 ath6kl_force_roam_write 3 4282 NULL
103848 +goldfish_audio_write_4284 goldfish_audio_write 3 4284 NULL
103849 +msb_do_write_request_4286 msb_do_write_request 2 4286 NULL
103850 +paging32_page_fault_4288 paging32_page_fault 2 4288 NULL
103851 +xt_compat_add_offset_4289 xt_compat_add_offset 0 4289 NULL
103852 +__usbnet_read_cmd_4299 __usbnet_read_cmd 7 4299 NULL
103853 +dvb_ringbuffer_pkt_read_user_4303 dvb_ringbuffer_pkt_read_user 3-2-5 4303 NULL
103854 +__pool_find_4308 __pool_find 3 4308 NULL
103855 +count_strings_4315 count_strings 0 4315 NULL
103856 +nouveau_fifo_create__4327 nouveau_fifo_create_ 5-6 4327 NULL
103857 +snd_rawmidi_kernel_read_4328 snd_rawmidi_kernel_read 3 4328 NULL
103858 +kvm_apic_get_reg_4354 kvm_apic_get_reg 0 4354 NULL
103859 +__copy_from_user_inatomic_4365 __copy_from_user_inatomic 0-3 4365 NULL nohasharray
103860 +lookup_string_4365 lookup_string 0 4365 &__copy_from_user_inatomic_4365
103861 +btrfs_set_disk_extent_flags_4374 btrfs_set_disk_extent_flags 0 4374 NULL
103862 +irda_sendmsg_4388 irda_sendmsg 4 4388 NULL
103863 +access_process_vm_4412 access_process_vm 0-4-2 4412 NULL nohasharray
103864 +cxacru_cm_get_array_4412 cxacru_cm_get_array 4 4412 &access_process_vm_4412
103865 +libfc_vport_create_4415 libfc_vport_create 2 4415 NULL
103866 +rtw_android_get_rssi_4421 rtw_android_get_rssi 0 4421 NULL
103867 +do_pages_stat_4437 do_pages_stat 2 4437 NULL
103868 +memparse_4444 memparse 0 4444 NULL
103869 +tcp_dma_try_early_copy_4457 tcp_dma_try_early_copy 3 4457 NULL
103870 +at76_set_card_command_4471 at76_set_card_command 4 4471 NULL
103871 +snd_seq_expand_var_event_4481 snd_seq_expand_var_event 5-0 4481 NULL
103872 +ocfs2_grow_tree_4492 ocfs2_grow_tree 0 4492 NULL
103873 +vmbus_establish_gpadl_4495 vmbus_establish_gpadl 3 4495 NULL
103874 +set_link_security_4502 set_link_security 4 4502 NULL
103875 +dm_cache_remove_mapping_4513 dm_cache_remove_mapping 2 4513 NULL
103876 +__gfn_to_pfn_memslot_4530 __gfn_to_pfn_memslot 2-0 4530 NULL
103877 +ll_max_readahead_per_file_mb_seq_write_4531 ll_max_readahead_per_file_mb_seq_write 3 4531 NULL
103878 +da9052_group_write_4534 da9052_group_write 2-3 4534 NULL
103879 +tty_register_device_4544 tty_register_device 2 4544 NULL
103880 +videobuf_vmalloc_to_sg_4548 videobuf_vmalloc_to_sg 2 4548 NULL
103881 +btrfs_file_extent_inline_item_len_4575 btrfs_file_extent_inline_item_len 0 4575 NULL
103882 +xfs_buf_get_maps_4581 xfs_buf_get_maps 2 4581 NULL
103883 +iommu_map_page_4588 iommu_map_page 5 4588 NULL
103884 +bch_alloc_4593 bch_alloc 1 4593 NULL
103885 +ocfs2_refcount_lock_4595 ocfs2_refcount_lock 0 4595 NULL
103886 +__wb_force_remove_mapping_4622 __wb_force_remove_mapping 2 4622 NULL
103887 +ll_rw_extents_stats_seq_write_4633 ll_rw_extents_stats_seq_write 3 4633 NULL
103888 +iwl_dbgfs_tx_queue_read_4635 iwl_dbgfs_tx_queue_read 3 4635 NULL
103889 +ext3_orphan_add_4665 ext3_orphan_add 0 4665 NULL
103890 +skb_add_data_nocache_4682 skb_add_data_nocache 4 4682 NULL
103891 +cx18_read_pos_4683 cx18_read_pos 3 4683 NULL
103892 +short_retry_limit_read_4687 short_retry_limit_read 3 4687 NULL
103893 +kone_receive_4690 kone_receive 4 4690 NULL
103894 +link_to_fixup_dir_4699 link_to_fixup_dir 0 4699 NULL
103895 +cxgbi_alloc_big_mem_4707 cxgbi_alloc_big_mem 1 4707 NULL
103896 +konepure_sysfs_read_4709 konepure_sysfs_read 6 4709 NULL
103897 +ati_create_gatt_pages_4722 ati_create_gatt_pages 1 4722 NULL nohasharray
103898 +show_header_4722 show_header 3 4722 &ati_create_gatt_pages_4722
103899 +gfs2_bit_search_4728 gfs2_bit_search 0-2 4728 NULL
103900 +ll_rw_offset_stats_seq_write_4736 ll_rw_offset_stats_seq_write 3 4736 NULL nohasharray
103901 +bitmap_startwrite_4736 bitmap_startwrite 2 4736 &ll_rw_offset_stats_seq_write_4736
103902 +__find_free_cblock_4741 __find_free_cblock 2 4741 NULL
103903 +lu_buf_alloc_4753 lu_buf_alloc 2 4753 NULL
103904 +find_next_best_node_4774 find_next_best_node 1-0 4774 NULL nohasharray
103905 +pwr_rcvd_bcns_cnt_read_4774 pwr_rcvd_bcns_cnt_read 3 4774 &find_next_best_node_4774
103906 +btrfs_del_items_4791 btrfs_del_items 0 4791 NULL nohasharray
103907 +create_subvol_4791 create_subvol 4 4791 &btrfs_del_items_4791
103908 +ncp__vol2io_4804 ncp__vol2io 5 4804 NULL
103909 +repair_io_failure_4815 repair_io_failure 4-3 4815 NULL
103910 +comedi_buf_write_free_4847 comedi_buf_write_free 2 4847 NULL
103911 +gigaset_if_receive_4861 gigaset_if_receive 3 4861 NULL
103912 +key_tx_spec_read_4862 key_tx_spec_read 3 4862 NULL
103913 +get_new_location_4866 get_new_location 0 4866 NULL
103914 +ocfs2_defrag_extent_4873 ocfs2_defrag_extent 3-2 4873 NULL
103915 +hid_register_field_4874 hid_register_field 2-3 4874 NULL
103916 +vga_arb_read_4886 vga_arb_read 3 4886 NULL
103917 +ntfs_rl_insert_4931 ntfs_rl_insert 4-2 4931 NULL
103918 +ieee80211_if_fmt_ave_beacon_4941 ieee80211_if_fmt_ave_beacon 3 4941 NULL
103919 +ocfs2_should_refresh_lock_res_4958 ocfs2_should_refresh_lock_res 0 4958 NULL
103920 +compat_rawv6_setsockopt_4967 compat_rawv6_setsockopt 5 4967 NULL
103921 +skb_network_header_len_4971 skb_network_header_len 0 4971 NULL
103922 +ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval_4976 ieee80211_if_fmt_dot11MeshHWMPconfirmationInterval 3 4976 NULL
103923 +do_sync_read_4977 do_sync_read 0 4977 NULL
103924 +vmw_surface_define_size_4993 vmw_surface_define_size 0 4993 NULL
103925 +compat_SyS_ipc_5000 compat_SyS_ipc 3 5000 NULL
103926 +do_mincore_5018 do_mincore 0-2-1 5018 NULL
103927 +btrfs_punch_hole_5041 btrfs_punch_hole 2 5041 NULL
103928 +cfg80211_rx_mgmt_5056 cfg80211_rx_mgmt 5 5056 NULL
103929 +ocfs2_check_range_for_holes_5066 ocfs2_check_range_for_holes 3-2 5066 NULL
103930 +snd_mixart_BA1_read_5082 snd_mixart_BA1_read 5 5082 NULL
103931 +snd_emu10k1_ptr20_read_5087 snd_emu10k1_ptr20_read 0 5087 NULL
103932 +get_random_bytes_5091 get_random_bytes 2 5091 NULL nohasharray
103933 +kfifo_copy_from_user_5091 kfifo_copy_from_user 4-3-0 5091 &get_random_bytes_5091 nohasharray
103934 +blk_rq_sectors_5091 blk_rq_sectors 0 5091 &kfifo_copy_from_user_5091
103935 +sound_write_5102 sound_write 3 5102 NULL
103936 +clear_dirty_5105 clear_dirty 3 5105 NULL
103937 +i40e_dbg_netdev_ops_write_5117 i40e_dbg_netdev_ops_write 3 5117 NULL
103938 +qib_7220_handle_hwerrors_5142 qib_7220_handle_hwerrors 3 5142 NULL
103939 +ufs_add_fragments_5144 ufs_add_fragments 2 5144 NULL
103940 +ocfs2_inode_lock_full_nested_5148 ocfs2_inode_lock_full_nested 0 5148 NULL
103941 +__uwb_addr_print_5161 __uwb_addr_print 2 5161 NULL
103942 +iwl_dbgfs_status_read_5171 iwl_dbgfs_status_read 3 5171 NULL
103943 +acpi_pcc_get_sqty_5176 acpi_pcc_get_sqty 0 5176 NULL
103944 +ppp_cp_parse_cr_5214 ppp_cp_parse_cr 4 5214 NULL nohasharray
103945 +r600_mip_minify_5214 r600_mip_minify 2-1-0 5214 &ppp_cp_parse_cr_5214
103946 +dwc2_hcd_urb_alloc_5217 dwc2_hcd_urb_alloc 2 5217 NULL
103947 +ath6kl_debug_roam_tbl_event_5224 ath6kl_debug_roam_tbl_event 3 5224 NULL
103948 +nouveau_fb_create__5244 nouveau_fb_create_ 5 5244 NULL
103949 +gfn_to_hva_memslot_5265 gfn_to_hva_memslot 2 5265 NULL
103950 +btrfs_alloc_reserved_file_extent_5274 btrfs_alloc_reserved_file_extent 0 5274 NULL
103951 +iommu_domain_identity_map_5284 iommu_domain_identity_map 2-3 5284 NULL
103952 +alloc_cache_blocks_with_hash_5285 alloc_cache_blocks_with_hash 2 5285 NULL
103953 +usb_descriptor_fillbuf_5302 usb_descriptor_fillbuf 0 5302 NULL
103954 +__gfn_to_hva_memslot_5304 __gfn_to_hva_memslot 0-2 5304 NULL
103955 +r592_write_fifo_pio_5315 r592_write_fifo_pio 3 5315 NULL
103956 +sbc_get_write_same_sectors_5317 sbc_get_write_same_sectors 0 5317 NULL
103957 +pwr_elp_enter_read_5324 pwr_elp_enter_read 3 5324 NULL
103958 +allocate_cnodes_5329 allocate_cnodes 1 5329 NULL
103959 +vm_insert_pfn_5341 vm_insert_pfn 3-0 5341 NULL
103960 +cq_free_res_5355 cq_free_res 5 5355 NULL
103961 +ps_pspoll_utilization_read_5361 ps_pspoll_utilization_read 3 5361 NULL
103962 +cciss_allocate_sg_chain_blocks_5368 cciss_allocate_sg_chain_blocks 2-3 5368 NULL
103963 +kvm_pin_pages_5369 kvm_pin_pages 2-0 5369 NULL
103964 +bitmap_fold_5396 bitmap_fold 4 5396 NULL
103965 +security_inode_init_security_5408 security_inode_init_security 0 5408 NULL
103966 +__resolve_indirect_refs_5409 __resolve_indirect_refs 0 5409 NULL
103967 +nilfs_palloc_entries_per_group_5418 nilfs_palloc_entries_per_group 0 5418 NULL
103968 +check_item_in_log_5440 check_item_in_log 0 5440 NULL
103969 +__split_bvec_across_targets_5454 __split_bvec_across_targets 3 5454 NULL
103970 +xfs_efd_init_5463 xfs_efd_init 3 5463 NULL
103971 +xfs_efi_init_5476 xfs_efi_init 2 5476 NULL
103972 +ubi_leb_write_5478 ubi_leb_write 4-5 5478 NULL
103973 +cifs_security_flags_proc_write_5484 cifs_security_flags_proc_write 3 5484 NULL
103974 +tty_write_5494 tty_write 3 5494 NULL
103975 +tomoyo_update_domain_5498 tomoyo_update_domain 2 5498 NULL nohasharray
103976 +ieee80211_if_fmt_last_beacon_5498 ieee80211_if_fmt_last_beacon 3 5498 &tomoyo_update_domain_5498
103977 +__max_nr_grant_frames_5505 __max_nr_grant_frames 0 5505 NULL
103978 +ieee80211_if_fmt_auto_open_plinks_5534 ieee80211_if_fmt_auto_open_plinks 3 5534 NULL
103979 +iommu_prepare_identity_map_5540 iommu_prepare_identity_map 2-3 5540 NULL
103980 +get_entry_msg_len_5552 get_entry_msg_len 0 5552 NULL
103981 +le_readq_5557 le_readq 0 5557 NULL
103982 +inw_5558 inw 0 5558 NULL
103983 +bioset_create_5580 bioset_create 1 5580 NULL
103984 +domain_sg_mapping_5586 domain_sg_mapping 4 5586 NULL
103985 +oz_ep_alloc_5587 oz_ep_alloc 1 5587 NULL
103986 +ldm_frag_add_5611 ldm_frag_add 2 5611 NULL
103987 +compat_copy_entries_5617 compat_copy_entries 0 5617 NULL
103988 +SYSC_init_module_5626 SYSC_init_module 2 5626 NULL
103989 +iterate_extent_inodes_5631 iterate_extent_inodes 0 5631 NULL
103990 +SYSC_fsetxattr_5639 SYSC_fsetxattr 4 5639 NULL
103991 +ext4_xattr_get_5661 ext4_xattr_get 0 5661 NULL
103992 +posix_clock_register_5662 posix_clock_register 2 5662 NULL
103993 +kgdb_arch_pc_5673 kgdb_arch_pc 0 5673 NULL
103994 +wb_clear_dirty_5684 wb_clear_dirty 2 5684 NULL
103995 +get_arg_5694 get_arg 3 5694 NULL
103996 +subbuf_read_actor_5708 subbuf_read_actor 3 5708 NULL
103997 +ntfs_attr_record_resize_5720 ntfs_attr_record_resize 0 5720 NULL
103998 +vmw_kms_readback_5727 vmw_kms_readback 6 5727 NULL
103999 +rts51x_transfer_data_partial_5735 rts51x_transfer_data_partial 6 5735 NULL
104000 +ubi_calc_fm_size_5749 ubi_calc_fm_size 0 5749 NULL
104001 +sctp_setsockopt_autoclose_5775 sctp_setsockopt_autoclose 3 5775 NULL
104002 +__vxge_hw_blockpool_malloc_5786 __vxge_hw_blockpool_malloc 2 5786 NULL
104003 +nvme_trans_bdev_char_page_5797 nvme_trans_bdev_char_page 3 5797 NULL
104004 +skb_copy_datagram_iovec_5806 skb_copy_datagram_iovec 2-4 5806 NULL
104005 +nv50_disp_pioc_create__5812 nv50_disp_pioc_create_ 5 5812 NULL
104006 +ceph_x_encrypt_buflen_5829 ceph_x_encrypt_buflen 0-1 5829 NULL
104007 +ceph_msg_new_5846 ceph_msg_new 2 5846 NULL
104008 +setup_req_5848 setup_req 3 5848 NULL
104009 +ria_page_count_5849 ria_page_count 0 5849 NULL
104010 +rx_filter_max_arp_queue_dep_read_5851 rx_filter_max_arp_queue_dep_read 3 5851 NULL
104011 +config_buf_5862 config_buf 0 5862 NULL
104012 +ext4_ext_correct_indexes_5865 ext4_ext_correct_indexes 0 5865 NULL
104013 +paging64_walk_addr_5887 paging64_walk_addr 3 5887 NULL
104014 +scan_bitmap_5888 scan_bitmap 3 5888 NULL
104015 +lprocfs_fid_width_seq_write_5889 lprocfs_fid_width_seq_write 3 5889 NULL
104016 +port_show_regs_5904 port_show_regs 3 5904 NULL
104017 +rbd_segment_length_5907 rbd_segment_length 0-3-2 5907 NULL
104018 +uhci_debug_read_5911 uhci_debug_read 3 5911 NULL
104019 +lbs_highsnr_read_5931 lbs_highsnr_read 3 5931 NULL
104020 +ps_poll_ps_poll_timeouts_read_5934 ps_poll_ps_poll_timeouts_read 3 5934 NULL
104021 +edac_device_alloc_ctl_info_5941 edac_device_alloc_ctl_info 1 5941 NULL
104022 +find_parent_nodes_5948 find_parent_nodes 0 5948 NULL
104023 +ll_statahead_one_5962 ll_statahead_one 3 5962 NULL
104024 +__apu_get_register_5967 __apu_get_register 0 5967 NULL
104025 +ieee80211_if_fmt_rc_rateidx_mask_5ghz_5971 ieee80211_if_fmt_rc_rateidx_mask_5ghz 3 5971 NULL
104026 +native_pte_val_5978 native_pte_val 0 5978 NULL
104027 +jbd2_journal_stop_5979 jbd2_journal_stop 0 5979 NULL
104028 +ntfs_rl_append_6037 ntfs_rl_append 4-2 6037 NULL
104029 +da9052_request_irq_6058 da9052_request_irq 2 6058 NULL nohasharray
104030 +device_add_attributes_6058 device_add_attributes 0 6058 &da9052_request_irq_6058
104031 +alloc_msg_6072 alloc_msg 1 6072 NULL
104032 +sctp_setsockopt_connectx_6073 sctp_setsockopt_connectx 3 6073 NULL
104033 +rts51x_ms_rw_multi_sector_6076 rts51x_ms_rw_multi_sector 3-4 6076 NULL
104034 +md_trim_bio_6078 md_trim_bio 2 6078 NULL
104035 +finish_inode_if_needed_6098 finish_inode_if_needed 0 6098 NULL
104036 +ipmi_addr_length_6110 ipmi_addr_length 0 6110 NULL
104037 +dfs_global_file_write_6112 dfs_global_file_write 3 6112 NULL
104038 +nouveau_parent_create__6131 nouveau_parent_create_ 7 6131 NULL
104039 +__btrfs_commit_inode_delayed_items_6150 __btrfs_commit_inode_delayed_items 0 6150 NULL
104040 +ieee80211_if_fmt_beacon_timeout_6153 ieee80211_if_fmt_beacon_timeout 3 6153 NULL
104041 +ivtv_copy_buf_to_user_6159 ivtv_copy_buf_to_user 4 6159 NULL
104042 +vdma_mem_alloc_6171 vdma_mem_alloc 1 6171 NULL
104043 +wl1251_cmd_template_set_6172 wl1251_cmd_template_set 4 6172 NULL
104044 +paging64_walk_addr_generic_6180 paging64_walk_addr_generic 4 6180 NULL
104045 +SyS_setgroups_6182 SyS_setgroups 1 6182 NULL
104046 +__add_pin_to_irq_node_6188 __add_pin_to_irq_node 2 6188 NULL
104047 +qp_host_get_user_memory_6189 qp_host_get_user_memory 1-2 6189 NULL
104048 +cl_sync_io_wait_6196 cl_sync_io_wait 0 6196 NULL
104049 +i915_gem_execbuffer_move_to_gpu_6197 i915_gem_execbuffer_move_to_gpu 0 6197 NULL
104050 +mxt_show_instance_6207 mxt_show_instance 2-0 6207 NULL
104051 +v4l2_ctrl_new_std_menu_6221 v4l2_ctrl_new_std_menu 4 6221 NULL
104052 +mqueue_read_file_6228 mqueue_read_file 3 6228 NULL
104053 +f_hidg_read_6238 f_hidg_read 3 6238 NULL
104054 +changed_ref_6242 changed_ref 0 6242 NULL
104055 +fbcon_prepare_logo_6246 fbcon_prepare_logo 5 6246 NULL
104056 +ext4_ext_split_6249 ext4_ext_split 0 6249 NULL
104057 +pcpu_next_pop_6277 pcpu_next_pop 4 6277 NULL
104058 +tx_tx_start_null_frame_read_6281 tx_tx_start_null_frame_read 3 6281 NULL
104059 +snd_hda_override_conn_list_6282 snd_hda_override_conn_list 3-0 6282 NULL nohasharray
104060 +xenbus_file_write_6282 xenbus_file_write 3 6282 &snd_hda_override_conn_list_6282
104061 +posix_acl_fix_xattr_to_user_6283 posix_acl_fix_xattr_to_user 2 6283 NULL
104062 +paging64_gva_to_gpa_nested_6287 paging64_gva_to_gpa_nested 2 6287 NULL
104063 +qlcnic_sriov_alloc_bc_msg_6309 qlcnic_sriov_alloc_bc_msg 2 6309 NULL
104064 +exclude_super_stripes_6326 exclude_super_stripes 0 6326 NULL
104065 +SyS_mincore_6329 SyS_mincore 2-1 6329 NULL nohasharray
104066 +hfa384x_inw_6329 hfa384x_inw 0 6329 &SyS_mincore_6329
104067 +fuse_get_req_for_background_6337 fuse_get_req_for_background 2 6337 NULL
104068 +ucs2_strnlen_6342 ucs2_strnlen 0 6342 NULL
104069 +utc2ntfs_6347 utc2ntfs 0 6347 NULL
104070 +regcache_sync_block_raw_6350 regcache_sync_block_raw 5-4 6350 NULL
104071 +mei_dbgfs_read_devstate_6352 mei_dbgfs_read_devstate 3 6352 NULL
104072 +_proc_do_string_6376 _proc_do_string 2 6376 NULL
104073 +osd_req_read_sg_kern_6378 osd_req_read_sg_kern 5 6378 NULL
104074 +msb_write_block_6379 msb_write_block 3 6379 NULL
104075 +BcmFlash2xBulkRead_6395 BcmFlash2xBulkRead 0 6395 NULL
104076 +posix_acl_fix_xattr_userns_6420 posix_acl_fix_xattr_userns 4 6420 NULL
104077 +add_transaction_credits_6422 add_transaction_credits 2-3 6422 NULL
104078 +ipr_change_queue_depth_6431 ipr_change_queue_depth 2 6431 NULL
104079 +__alloc_bootmem_node_nopanic_6432 __alloc_bootmem_node_nopanic 2 6432 NULL
104080 +add_to_list_6433 add_to_list 0 6433 NULL
104081 +paging32_gva_to_gpa_nested_6442 paging32_gva_to_gpa_nested 2 6442 NULL
104082 +i915_gem_object_wait_rendering_6446 i915_gem_object_wait_rendering 0 6446 NULL
104083 +mlx4_ib_reg_user_mr_6471 mlx4_ib_reg_user_mr 2-3 6471 NULL
104084 +ieee80211_if_fmt_dot11MeshMaxRetries_6476 ieee80211_if_fmt_dot11MeshMaxRetries 3 6476 NULL
104085 +qp_memcpy_from_queue_6479 qp_memcpy_from_queue 5-4 6479 NULL
104086 +cipso_v4_map_lvl_hton_6490 cipso_v4_map_lvl_hton 0 6490 NULL
104087 +ntfs_cluster_free_6497 ntfs_cluster_free 0 6497 NULL
104088 +dbg_intr_buf_6501 dbg_intr_buf 2 6501 NULL
104089 +mei_read_6507 mei_read 3 6507 NULL
104090 +__start_delalloc_inodes_6528 __start_delalloc_inodes 0 6528 NULL
104091 +rndis_set_oid_6547 rndis_set_oid 4 6547 NULL
104092 +wdm_read_6549 wdm_read 3 6549 NULL
104093 +dm_stats_create_6551 dm_stats_create 4-2-3 6551 NULL
104094 +fb_alloc_cmap_6554 fb_alloc_cmap 2 6554 NULL
104095 +SyS_semtimedop_6563 SyS_semtimedop 3 6563 NULL
104096 +SyS_fcntl64_6582 SyS_fcntl64 3 6582 NULL
104097 +snd_pcm_hw_refine_old_user_6586 snd_pcm_hw_refine_old_user 0 6586 NULL
104098 +btrfs_start_all_delalloc_inodes_6596 btrfs_start_all_delalloc_inodes 0 6596 NULL
104099 +snmp_mib_init_6604 snmp_mib_init 2-3 6604 NULL
104100 +ecryptfs_filldir_6622 ecryptfs_filldir 3 6622 NULL
104101 +xfs_do_div_6649 xfs_do_div 0-2 6649 NULL
104102 +journal_dirty_metadata_6658 journal_dirty_metadata 0 6658 NULL
104103 +process_rcvd_data_6679 process_rcvd_data 3 6679 NULL
104104 +btrfs_lookup_csums_range_6696 btrfs_lookup_csums_range 2-3-0 6696 NULL
104105 +ps_pspoll_max_apturn_read_6699 ps_pspoll_max_apturn_read 3 6699 NULL
104106 +bnad_debugfs_write_regrd_6706 bnad_debugfs_write_regrd 3 6706 NULL
104107 +mpeg_read_6708 mpeg_read 3 6708 NULL
104108 +ibmpex_query_sensor_count_6709 ibmpex_query_sensor_count 0 6709 NULL
104109 +set_orig_insn_6712 set_orig_insn 3 6712 NULL
104110 +video_proc_write_6724 video_proc_write 3 6724 NULL
104111 +posix_acl_xattr_count_6725 posix_acl_xattr_count 0-1 6725 NULL
104112 +ocfs2_insert_extent_6737 ocfs2_insert_extent 0 6737 NULL
104113 +btrfs_inode_delayed_dir_index_count_6759 btrfs_inode_delayed_dir_index_count 0 6759 NULL
104114 +kobject_add_varg_6781 kobject_add_varg 0 6781 NULL
104115 +iwl_dbgfs_channels_read_6784 iwl_dbgfs_channels_read 3 6784 NULL
104116 +ieee80211_if_read_6785 ieee80211_if_read 3 6785 NULL
104117 +zone_spanned_pages_in_node_6787 zone_spanned_pages_in_node 0-3-4 6787 NULL
104118 +hdlcdrv_register_6792 hdlcdrv_register 2 6792 NULL
104119 +tx_tx_done_data_read_6799 tx_tx_done_data_read 3 6799 NULL
104120 +ocfs2_calc_refcount_meta_credits_6802 ocfs2_calc_refcount_meta_credits 0 6802 NULL
104121 +lbs_rdrf_write_6826 lbs_rdrf_write 3 6826 NULL
104122 +make_8259A_irq_6828 make_8259A_irq 1 6828 NULL
104123 +calc_pages_for_6838 calc_pages_for 0-1-2 6838 NULL
104124 +mon_bin_read_6841 mon_bin_read 3 6841 NULL
104125 +snd_cs4281_BA0_read_6847 snd_cs4281_BA0_read 5 6847 NULL
104126 +ecryptfs_write_lower_6870 ecryptfs_write_lower 4 6870 NULL
104127 +dio_complete_6879 dio_complete 0-2-3 6879 NULL
104128 +ieee80211_if_fmt_path_refresh_time_6888 ieee80211_if_fmt_path_refresh_time 3 6888 NULL nohasharray
104129 +raw_seticmpfilter_6888 raw_seticmpfilter 3 6888 &ieee80211_if_fmt_path_refresh_time_6888
104130 +dlmfs_file_write_6892 dlmfs_file_write 3 6892 NULL
104131 +ext4_inode_bitmap_6902 ext4_inode_bitmap 0 6902 NULL
104132 +spi_show_regs_6911 spi_show_regs 3 6911 NULL nohasharray
104133 +proc_sessionid_read_6911 proc_sessionid_read 3 6911 &spi_show_regs_6911 nohasharray
104134 +acm_alloc_minor_6911 acm_alloc_minor 0 6911 &proc_sessionid_read_6911
104135 +__kfifo_dma_in_finish_r_6913 __kfifo_dma_in_finish_r 2-3 6913 NULL
104136 +do_msgrcv_6921 do_msgrcv 3 6921 NULL
104137 +__vxge_hw_mempool_create_6923 __vxge_hw_mempool_create 3-2-6 6923 NULL
104138 +cache_do_downcall_6926 cache_do_downcall 3 6926 NULL
104139 +ipath_verbs_send_dma_6929 ipath_verbs_send_dma 6 6929 NULL
104140 +qsfp_cks_6945 qsfp_cks 2-0 6945 NULL
104141 +tg3_nvram_write_block_unbuffered_6955 tg3_nvram_write_block_unbuffered 3 6955 NULL
104142 +pch_uart_hal_read_6961 pch_uart_hal_read 0 6961 NULL
104143 +videobuf_dma_init_kernel_6963 videobuf_dma_init_kernel 3 6963 NULL
104144 +i40e_dbg_dump_write_6973 i40e_dbg_dump_write 3 6973 NULL nohasharray
104145 +rsa_extract_mpi_6973 rsa_extract_mpi 5 6973 &i40e_dbg_dump_write_6973
104146 +crypto_authenc_esn_setkey_6985 crypto_authenc_esn_setkey 3 6985 NULL
104147 +request_key_async_6990 request_key_async 4 6990 NULL
104148 +tpl_write_6998 tpl_write 3 6998 NULL
104149 +r871x_set_wpa_ie_7000 r871x_set_wpa_ie 3 7000 NULL
104150 +log_wait_commit_7005 log_wait_commit 0 7005 NULL
104151 +cipso_v4_gentag_enum_7006 cipso_v4_gentag_enum 0 7006 NULL
104152 +tracing_cpumask_read_7010 tracing_cpumask_read 3 7010 NULL
104153 +ld_usb_write_7022 ld_usb_write 3 7022 NULL
104154 +wimax_msg_7030 wimax_msg 4 7030 NULL
104155 +ipath_get_base_info_7043 ipath_get_base_info 3 7043 NULL
104156 +snd_pcm_oss_bytes_7051 snd_pcm_oss_bytes 2 7051 NULL
104157 +hci_sock_recvmsg_7072 hci_sock_recvmsg 4 7072 NULL
104158 +event_enable_read_7074 event_enable_read 3 7074 NULL
104159 +ip_vs_sync_conn_7075 ip_vs_sync_conn 3 7075 NULL
104160 +beacon_interval_read_7091 beacon_interval_read 3 7091 NULL
104161 +pipeline_enc_rx_stat_fifo_int_read_7107 pipeline_enc_rx_stat_fifo_int_read 3 7107 NULL
104162 +check_header_7108 check_header 0 7108 NULL
104163 +osc_resend_count_seq_write_7120 osc_resend_count_seq_write 3 7120 NULL
104164 +qib_format_hwerrors_7133 qib_format_hwerrors 5 7133 NULL
104165 +kvm_mmu_notifier_test_young_7139 kvm_mmu_notifier_test_young 3 7139 NULL
104166 +ipv6_recv_rxpmtu_7142 ipv6_recv_rxpmtu 3 7142 NULL
104167 +qlcnic_enable_msix_7144 qlcnic_enable_msix 2 7144 NULL
104168 +ocfs2_get_left_path_7159 ocfs2_get_left_path 0 7159 NULL
104169 +core_alua_write_tpg_metadata_7168 core_alua_write_tpg_metadata 3 7168 NULL
104170 +ext3_xattr_ibody_list_7201 ext3_xattr_ibody_list 3-0 7201 NULL
104171 +__alloc_objio_seg_7203 __alloc_objio_seg 1 7203 NULL
104172 +get_param_h_7247 get_param_h 0 7247 NULL
104173 +af_alg_make_sg_7254 af_alg_make_sg 3-0 7254 NULL
104174 +hdlc_loop_7255 hdlc_loop 0 7255 NULL
104175 +vm_mmap_pgoff_7259 vm_mmap_pgoff 0 7259 NULL
104176 +snd_mask_refine_7267 snd_mask_refine 0 7267 NULL
104177 +f_midi_start_ep_7270 f_midi_start_ep 0 7270 NULL
104178 +dma_ops_alloc_addresses_7272 dma_ops_alloc_addresses 3-4-5-0 7272 NULL
104179 +rx_rate_rx_frames_per_rates_read_7282 rx_rate_rx_frames_per_rates_read 3 7282 NULL
104180 +get_string_7302 get_string 0 7302 NULL
104181 +wb_remove_mapping_7307 wb_remove_mapping 2 7307 NULL
104182 +wait_on_sync_kiocb_7327 wait_on_sync_kiocb 0 7327 NULL
104183 +mgmt_control_7349 mgmt_control 3 7349 NULL
104184 +max8998_irq_domain_map_7359 max8998_irq_domain_map 2 7359 NULL
104185 +i915_gem_do_execbuffer_7362 i915_gem_do_execbuffer 0 7362 NULL nohasharray
104186 +ext3_free_blocks_7362 ext3_free_blocks 3-4 7362 &i915_gem_do_execbuffer_7362
104187 +at_est2timeout_7365 at_est2timeout 0-1 7365 NULL
104188 +ieee80211_if_read_dot11MeshHWMPactivePathTimeout_7368 ieee80211_if_read_dot11MeshHWMPactivePathTimeout 3 7368 NULL
104189 +schedule_timeout_7371 schedule_timeout 0 7371 NULL
104190 +ath10k_read_fw_stats_7387 ath10k_read_fw_stats 3 7387 NULL
104191 +hweight_long_7388 hweight_long 1-0 7388 NULL
104192 +sl_change_mtu_7396 sl_change_mtu 2 7396 NULL
104193 +_ore_add_stripe_unit_7399 _ore_add_stripe_unit 6-3 7399 NULL
104194 +readb_7401 readb 0 7401 NULL
104195 +drm_property_create_blob_7414 drm_property_create_blob 2 7414 NULL
104196 +ip_options_get_alloc_7448 ip_options_get_alloc 1 7448 NULL
104197 +SYSC_setgroups_7454 SYSC_setgroups 1 7454 NULL
104198 +rt2x00debug_read_queue_stats_7455 rt2x00debug_read_queue_stats 3 7455 NULL
104199 +l2tp_ip6_sendmsg_7461 l2tp_ip6_sendmsg 4 7461 NULL
104200 +ReadHSCX_7471 ReadHSCX 0 7471 NULL nohasharray
104201 +garp_request_join_7471 garp_request_join 4 7471 &ReadHSCX_7471
104202 +snd_pcm_lib_read1_7491 snd_pcm_lib_read1 0-3 7491 NULL
104203 +iwl_mvm_power_dbgfs_read_7502 iwl_mvm_power_dbgfs_read 0 7502 NULL
104204 +sdhci_alloc_host_7509 sdhci_alloc_host 2 7509 NULL nohasharray
104205 +ahash_instance_headroom_7509 ahash_instance_headroom 0 7509 &sdhci_alloc_host_7509
104206 +array_zalloc_7519 array_zalloc 2-1 7519 NULL
104207 +btrfs_insert_xattr_item_7545 btrfs_insert_xattr_item 0 7545 NULL
104208 +goal_in_my_reservation_7553 goal_in_my_reservation 3 7553 NULL
104209 +smk_read_mapped_7562 smk_read_mapped 3 7562 NULL
104210 +cfs_cpt_num_estimate_7571 cfs_cpt_num_estimate 0 7571 NULL
104211 +ext4_ext_insert_extent_7576 ext4_ext_insert_extent 0 7576 NULL
104212 +btrfs_block_rsv_add_7579 btrfs_block_rsv_add 3-0 7579 NULL
104213 +ext3_try_to_allocate_7590 ext3_try_to_allocate 5-3-0 7590 NULL
104214 +ocfs2_lock_create_7612 ocfs2_lock_create 0 7612 NULL
104215 +create_dir_7614 create_dir 0 7614 NULL nohasharray
104216 +groups_alloc_7614 groups_alloc 1 7614 &create_dir_7614
104217 +_rtw_zmalloc_7636 _rtw_zmalloc 1 7636 NULL
104218 +fault_inject_write_7662 fault_inject_write 3 7662 NULL
104219 +acpi_ex_allocate_name_string_7685 acpi_ex_allocate_name_string 1-2 7685 NULL
104220 +acpi_ns_get_pathname_length_7699 acpi_ns_get_pathname_length 0 7699 NULL
104221 +dev_write_7708 dev_write 3 7708 NULL
104222 +unmap_region_7709 unmap_region 1 7709 NULL
104223 +dbg_check_cats_7713 dbg_check_cats 0 7713 NULL
104224 +pci_raw_set_power_state_7729 pci_raw_set_power_state 0 7729 NULL
104225 +vxge_device_register_7752 vxge_device_register 4 7752 NULL
104226 +ubi_io_read_vid_hdr_7766 ubi_io_read_vid_hdr 0 7766 NULL
104227 +paths_from_inode_7774 paths_from_inode 0 7774 NULL
104228 +alloc_candev_7776 alloc_candev 1-2 7776 NULL
104229 +dfs_global_file_read_7787 dfs_global_file_read 3 7787 NULL
104230 +bnx2_nvram_write_7790 bnx2_nvram_write 2-4 7790 NULL
104231 +diva_os_copy_from_user_7792 diva_os_copy_from_user 4 7792 NULL nohasharray
104232 +lustre_packed_msg_size_7792 lustre_packed_msg_size 0 7792 &diva_os_copy_from_user_7792
104233 +ubifs_leb_read_7828 ubifs_leb_read 0 7828 NULL
104234 +cfs_trace_dump_debug_buffer_usrstr_7861 cfs_trace_dump_debug_buffer_usrstr 2 7861 NULL
104235 +tipc_alloc_entry_7875 tipc_alloc_entry 2 7875 NULL
104236 +btrfs_find_space_for_alloc_7876 btrfs_find_space_for_alloc 2 7876 NULL
104237 +config_desc_7878 config_desc 0 7878 NULL
104238 +dvb_dmxdev_read_sec_7892 dvb_dmxdev_read_sec 4 7892 NULL
104239 +xfs_trans_get_efi_7898 xfs_trans_get_efi 2 7898 NULL
104240 +ext3_group_extend_7911 ext3_group_extend 3 7911 NULL
104241 +libfc_host_alloc_7917 libfc_host_alloc 2 7917 NULL
104242 +f_hidg_write_7932 f_hidg_write 3 7932 NULL
104243 +io_apic_setup_irq_pin_once_7934 io_apic_setup_irq_pin_once 1-2 7934 NULL
104244 +compare_refs_7938 compare_refs 0 7938 NULL
104245 +fsnotify_7943 fsnotify 0 7943 NULL
104246 +hash_netiface6_expire_7944 hash_netiface6_expire 3 7944 NULL
104247 +integrity_digsig_verify_7956 integrity_digsig_verify 3 7956 NULL
104248 +smk_write_load_self_7958 smk_write_load_self 3 7958 NULL
104249 +bch_btree_to_text_7960 bch_btree_to_text 2 7960 NULL
104250 +fixup_inode_link_count_8002 fixup_inode_link_count 0 8002 NULL
104251 +extend_or_restart_transaction_8008 extend_or_restart_transaction 0 8008 NULL
104252 +tt3650_ci_msg_locked_8013 tt3650_ci_msg_locked 4 8013 NULL
104253 +vcs_read_8017 vcs_read 3 8017 NULL
104254 +vhost_add_used_and_signal_n_8038 vhost_add_used_and_signal_n 4 8038 NULL
104255 +ms_read_multiple_pages_8052 ms_read_multiple_pages 5-4 8052 NULL
104256 +dgrp_mon_read_8065 dgrp_mon_read 3 8065 NULL
104257 +leb_read_lock_8070 leb_read_lock 0 8070 NULL
104258 +spi_write_then_read_8073 spi_write_then_read 5-3 8073 NULL
104259 +alloc_targets_8074 alloc_targets 2 8074 NULL nohasharray
104260 +qla4xxx_post_ping_evt_work_8074 qla4xxx_post_ping_evt_work 4 8074 &alloc_targets_8074
104261 +ext4_ext_map_blocks_8078 ext4_ext_map_blocks 0 8078 NULL
104262 +venus_lookup_8121 venus_lookup 4 8121 NULL
104263 +ieee80211_if_fmt_num_buffered_multicast_8127 ieee80211_if_fmt_num_buffered_multicast 3 8127 NULL
104264 +xfs_iomap_prealloc_size_8141 xfs_iomap_prealloc_size 3 8141 NULL
104265 +dma_map_area_8178 dma_map_area 3-2-5-0 8178 NULL
104266 +ore_truncate_8181 ore_truncate 3 8181 NULL
104267 +__sk_mem_schedule_8185 __sk_mem_schedule 2 8185 NULL
104268 +ieee80211_if_fmt_dot11MeshHoldingTimeout_8187 ieee80211_if_fmt_dot11MeshHoldingTimeout 3 8187 NULL
104269 +update_cowonly_root_8200 update_cowonly_root 0 8200 NULL
104270 +recent_mt_proc_write_8206 recent_mt_proc_write 3 8206 NULL
104271 +__ocfs2_lock_refcount_tree_8207 __ocfs2_lock_refcount_tree 0 8207 NULL
104272 +rt2x00debug_write_bbp_8212 rt2x00debug_write_bbp 3 8212 NULL
104273 +ad7879_spi_multi_read_8218 ad7879_spi_multi_read 3 8218 NULL
104274 +play_iframe_8219 play_iframe 3 8219 NULL
104275 +create_log_8225 create_log 2 8225 NULL nohasharray
104276 +kvm_mmu_page_set_gfn_8225 kvm_mmu_page_set_gfn 2 8225 &create_log_8225
104277 +sctp_ssnmap_size_8228 sctp_ssnmap_size 0-1-2 8228 NULL
104278 +ceph_sync_write_8233 ceph_sync_write 4 8233 NULL
104279 +bnx2x_iov_get_max_queue_count_8235 bnx2x_iov_get_max_queue_count 0 8235 NULL
104280 +check_xattr_ref_inode_8244 check_xattr_ref_inode 0 8244 NULL
104281 +t3_init_l2t_8261 t3_init_l2t 1 8261 NULL
104282 +init_cdev_8274 init_cdev 1 8274 NULL
104283 +rproc_recovery_write_8281 rproc_recovery_write 3 8281 NULL
104284 +qib_decode_7220_err_8315 qib_decode_7220_err 3 8315 NULL
104285 +snd_pcm_update_state_8320 snd_pcm_update_state 0 8320 NULL
104286 +construct_key_and_link_8321 construct_key_and_link 4 8321 NULL
104287 +ipwireless_send_packet_8328 ipwireless_send_packet 4 8328 NULL
104288 +cfs_cpt_spread_node_8338 cfs_cpt_spread_node 0 8338 NULL
104289 +tracing_entries_read_8345 tracing_entries_read 3 8345 NULL
104290 +ieee80211_if_fmt_ht_opmode_8347 ieee80211_if_fmt_ht_opmode 3 8347 NULL
104291 +generic_write_sync_8358 generic_write_sync 0 8358 NULL
104292 +ping_getfrag_8360 ping_getfrag 4-3 8360 NULL
104293 +ath6kl_lrssi_roam_write_8362 ath6kl_lrssi_roam_write 3 8362 NULL
104294 +ocfs2_decrease_refcount_rec_8385 ocfs2_decrease_refcount_rec 0 8385 NULL
104295 +xdi_copy_from_user_8395 xdi_copy_from_user 4 8395 NULL
104296 +zd_rf_scnprint_id_8406 zd_rf_scnprint_id 0-3 8406 NULL
104297 +smk_write_change_rule_8411 smk_write_change_rule 3 8411 NULL nohasharray
104298 +uvc_v4l2_ioctl_8411 uvc_v4l2_ioctl 2 8411 &smk_write_change_rule_8411
104299 +pca953x_gpio_to_irq_8424 pca953x_gpio_to_irq 2 8424 NULL
104300 +irq_create_mapping_8437 irq_create_mapping 2-0 8437 NULL
104301 +generic_bin_search_8440 generic_bin_search 0 8440 NULL
104302 +ring_wait_for_space_8457 ring_wait_for_space 0 8457 NULL
104303 +dir_changed_8471 dir_changed 0 8471 NULL
104304 +afs_cell_lookup_8482 afs_cell_lookup 2 8482 NULL
104305 +fore200e_chunk_alloc_8501 fore200e_chunk_alloc 4-3 8501 NULL
104306 +batadv_tt_len_8502 batadv_tt_len 0-1 8502 NULL
104307 +dev_config_8506 dev_config 3 8506 NULL
104308 +ACL_to_cifs_posix_8509 ACL_to_cifs_posix 3 8509 NULL
104309 +opticon_process_data_packet_8524 opticon_process_data_packet 3 8524 NULL
104310 +alloc_pg_vec_8533 alloc_pg_vec 2 8533 NULL
104311 +ocfs2_read_virt_blocks_8538 ocfs2_read_virt_blocks 2-3 8538 NULL
104312 +user_on_off_8552 user_on_off 2 8552 NULL
104313 +profile_remove_8556 profile_remove 3 8556 NULL
104314 +remove_extent_backref_8559 remove_extent_backref 0 8559 NULL
104315 +cache_slow_downcall_8570 cache_slow_downcall 2 8570 NULL
104316 +isr_dma0_done_read_8574 isr_dma0_done_read 3 8574 NULL
104317 +tower_write_8580 tower_write 3 8580 NULL
104318 +ocfs2_reserve_local_alloc_bits_8581 ocfs2_reserve_local_alloc_bits 0 8581 NULL
104319 +cfs_cpt_number_8618 cfs_cpt_number 0 8618 NULL
104320 +shash_setkey_unaligned_8620 shash_setkey_unaligned 3 8620 NULL
104321 +iommu_unmap_8624 iommu_unmap 2-0 8624 NULL
104322 +it821x_firmware_command_8628 it821x_firmware_command 3 8628 NULL
104323 +scsi_dma_map_8632 scsi_dma_map 0 8632 NULL
104324 +fuse_send_write_pages_8636 fuse_send_write_pages 0-5 8636 NULL
104325 +generic_acl_set_8658 generic_acl_set 4 8658 NULL
104326 +mlx5_vzalloc_8663 mlx5_vzalloc 1 8663 NULL
104327 +dio_bio_alloc_8677 dio_bio_alloc 5 8677 NULL
104328 +lbs_bcnmiss_read_8678 lbs_bcnmiss_read 3 8678 NULL
104329 +tc3589x_gpio_irq_unmap_8680 tc3589x_gpio_irq_unmap 2 8680 NULL
104330 +rproc_trace_read_8686 rproc_trace_read 3 8686 NULL
104331 +skb_frag_size_8695 skb_frag_size 0 8695 NULL
104332 +arcfb_write_8702 arcfb_write 3 8702 NULL
104333 +i_size_read_8703 i_size_read 0 8703 NULL nohasharray
104334 +init_header_8703 init_header 0 8703 &i_size_read_8703
104335 +HDLC_irq_8709 HDLC_irq 2 8709 NULL
104336 +ctrl_out_8712 ctrl_out 5-3 8712 NULL
104337 +__create_free_space_inode_8724 __create_free_space_inode 0 8724 NULL
104338 +tracing_max_lat_write_8728 tracing_max_lat_write 3 8728 NULL
104339 +jffs2_acl_count_8729 jffs2_acl_count 0-1 8729 NULL
104340 +f_dupfd_8730 f_dupfd 1 8730 NULL
104341 +__create_irqs_8733 __create_irqs 2-1-0-3 8733 NULL
104342 +pca953x_gpio_irq_map_8737 pca953x_gpio_irq_map 2 8737 NULL
104343 +tx_tx_exch_expiry_read_8749 tx_tx_exch_expiry_read 3 8749 NULL
104344 +compound_order_8750 compound_order 0 8750 NULL
104345 +ocfs2_find_path_8754 ocfs2_find_path 0 8754 NULL
104346 +yurex_write_8761 yurex_write 3 8761 NULL
104347 +joydev_compat_ioctl_8765 joydev_compat_ioctl 2 8765 NULL
104348 +x32_arch_ptrace_8767 x32_arch_ptrace 3 8767 NULL
104349 +kstrtoint_from_user_8778 kstrtoint_from_user 2 8778 NULL
104350 +paging32_prefetch_gpte_8783 paging32_prefetch_gpte 4 8783 NULL
104351 +ext4_try_to_write_inline_data_8785 ext4_try_to_write_inline_data 3-4 8785 NULL
104352 +aligned_nrpages_8791 aligned_nrpages 0-1-2 8791 NULL
104353 +__bitmap_weight_8796 __bitmap_weight 0-2 8796 NULL
104354 +cpuset_common_file_read_8800 cpuset_common_file_read 5 8800 NULL
104355 +intel_ring_begin_8808 intel_ring_begin 0 8808 NULL
104356 +ntfs_commit_pages_after_write_8809 ntfs_commit_pages_after_write 4-3 8809 NULL
104357 +metronomefb_write_8823 metronomefb_write 3 8823 NULL
104358 +SyS_llistxattr_8824 SyS_llistxattr 3 8824 NULL
104359 +get_queue_depth_8833 get_queue_depth 0 8833 NULL
104360 +dvb_ringbuffer_pkt_next_8834 dvb_ringbuffer_pkt_next 0-2 8834 NULL
104361 +usb_ep_queue_8839 usb_ep_queue 0 8839 NULL
104362 +clear_bitset_8840 clear_bitset 2 8840 NULL
104363 +debug_debug1_read_8856 debug_debug1_read 3 8856 NULL
104364 +wa_nep_queue_8858 wa_nep_queue 2 8858 NULL
104365 +sk_memory_allocated_8882 sk_memory_allocated 0 8882 NULL
104366 +compressed_bio_size_8887 compressed_bio_size 0-2 8887 NULL
104367 +ab3100_get_set_reg_8890 ab3100_get_set_reg 3 8890 NULL nohasharray
104368 +tracing_max_lat_read_8890 tracing_max_lat_read 3 8890 &ab3100_get_set_reg_8890
104369 +xfs_contig_bits_8904 xfs_contig_bits 3-0 8904 NULL
104370 +sdio_max_byte_size_8907 sdio_max_byte_size 0 8907 NULL
104371 +sysfs_merge_group_8917 sysfs_merge_group 0 8917 NULL
104372 +write_file_ani_8918 write_file_ani 3 8918 NULL
104373 +layout_commit_8926 layout_commit 3 8926 NULL
104374 +adjust_priv_size_8935 adjust_priv_size 0-1 8935 NULL
104375 +driver_stats_read_8944 driver_stats_read 3 8944 NULL
104376 +lookup_zone_8956 lookup_zone 2 8956 NULL
104377 +read_file_tgt_stats_8959 read_file_tgt_stats 3 8959 NULL
104378 +seq_bitmap_list_8963 seq_bitmap_list 3 8963 NULL
104379 +usb_allocate_stream_buffers_8964 usb_allocate_stream_buffers 3 8964 NULL
104380 +qib_qsfp_dump_8966 qib_qsfp_dump 0-3 8966 NULL
104381 +venus_mkdir_8967 venus_mkdir 4 8967 NULL
104382 +vol_cdev_read_8968 vol_cdev_read 3 8968 NULL nohasharray
104383 +seq_open_net_8968 seq_open_net 4 8968 &vol_cdev_read_8968
104384 +bio_integrity_get_tag_8974 bio_integrity_get_tag 3 8974 NULL
104385 +btrfs_alloc_free_block_8986 btrfs_alloc_free_block 3-8 8986 NULL
104386 +jbd2_journal_blocks_per_page_9004 jbd2_journal_blocks_per_page 0 9004 NULL
104387 +il_dbgfs_clear_ucode_stats_write_9016 il_dbgfs_clear_ucode_stats_write 3 9016 NULL
104388 +sparse_index_alloc_9021 sparse_index_alloc 1 9021 NULL
104389 +snd_emu10k1_ptr_read_9026 snd_emu10k1_ptr_read 0-2 9026 NULL
104390 +fd_ioctl_9028 fd_ioctl 3 9028 NULL
104391 +nla_put_9042 nla_put 3 9042 NULL
104392 +offset_il_node_9059 offset_il_node 0 9059 NULL
104393 +snd_emu10k1_synth_copy_from_user_9061 snd_emu10k1_synth_copy_from_user 5-3 9061 NULL
104394 +snd_gus_dram_peek_9062 snd_gus_dram_peek 4 9062 NULL
104395 +fib_info_hash_alloc_9075 fib_info_hash_alloc 1 9075 NULL
104396 +create_queues_9088 create_queues 3-2 9088 NULL
104397 +ftdi_prepare_write_buffer_9093 ftdi_prepare_write_buffer 3 9093 NULL
104398 +adxl34x_spi_read_block_9108 adxl34x_spi_read_block 3 9108 NULL
104399 +alloc_slabmgmt_9109 alloc_slabmgmt 5 9109 NULL
104400 +caif_stream_sendmsg_9110 caif_stream_sendmsg 4 9110 NULL nohasharray
104401 +gfn_to_rmap_9110 gfn_to_rmap 3-2 9110 &caif_stream_sendmsg_9110
104402 +udf_direct_IO_9111 udf_direct_IO 4 9111 NULL
104403 +pmcraid_change_queue_depth_9116 pmcraid_change_queue_depth 2 9116 NULL
104404 +mq_remove_mapping_9124 mq_remove_mapping 2 9124 NULL
104405 +mlx4_alloc_resize_umem_9132 mlx4_alloc_resize_umem 3 9132 NULL
104406 +ext4_list_backups_9138 ext4_list_backups 0 9138 NULL
104407 +apei_resources_merge_9149 apei_resources_merge 0 9149 NULL
104408 +vb2_dma_sg_alloc_9157 vb2_dma_sg_alloc 2 9157 NULL
104409 +dbg_command_buf_9165 dbg_command_buf 2 9165 NULL
104410 +__btrfs_add_delayed_deletion_item_9177 __btrfs_add_delayed_deletion_item 0 9177 NULL
104411 +isr_irqs_read_9181 isr_irqs_read 3 9181 NULL
104412 +count_leading_zeros_9183 count_leading_zeros 0 9183 NULL
104413 +altera_swap_ir_9194 altera_swap_ir 2 9194 NULL
104414 +snd_m3_get_pointer_9206 snd_m3_get_pointer 0 9206 NULL
104415 +get_pfn_9207 get_pfn 1 9207 NULL
104416 +virtqueue_add_9217 virtqueue_add 4-5 9217 NULL
104417 +tx_tx_prepared_descs_read_9221 tx_tx_prepared_descs_read 3 9221 NULL
104418 +sctp_getsockopt_delayed_ack_9232 sctp_getsockopt_delayed_ack 2 9232 NULL
104419 +ext4_mark_iloc_dirty_9239 ext4_mark_iloc_dirty 0 9239 NULL
104420 +ocfs2_clear_ext_refcount_9256 ocfs2_clear_ext_refcount 4-0 9256 NULL
104421 +hfsplus_bnode_read_u16_9262 hfsplus_bnode_read_u16 0 9262 NULL
104422 +btrfs_search_slot_9264 btrfs_search_slot 0 9264 NULL
104423 +ocfs2_merge_rec_right_9267 ocfs2_merge_rec_right 0 9267 NULL
104424 +sparse_early_usemaps_alloc_node_9269 sparse_early_usemaps_alloc_node 4 9269 NULL
104425 +hdpvr_read_9273 hdpvr_read 3 9273 NULL
104426 +flakey_status_9274 flakey_status 5 9274 NULL
104427 +migrate_misplaced_transhuge_page_9298 migrate_misplaced_transhuge_page 7 9298 NULL
104428 +iwl_dbgfs_stations_read_9309 iwl_dbgfs_stations_read 3 9309 NULL
104429 +ceph_sync_setxattr_9310 ceph_sync_setxattr 4 9310 NULL
104430 +ieee80211_if_fmt_txpower_9334 ieee80211_if_fmt_txpower 3 9334 NULL
104431 +nvme_trans_fmt_get_parm_header_9340 nvme_trans_fmt_get_parm_header 2 9340 NULL
104432 +ocfs2_orphan_for_truncate_9342 ocfs2_orphan_for_truncate 4 9342 NULL
104433 +__ksm_enter_9347 __ksm_enter 0 9347 NULL
104434 +ll_direct_rw_pages_9361 ll_direct_rw_pages 0 9361 NULL
104435 +of_node_to_nid_9367 of_node_to_nid 0 9367 NULL
104436 +sta_beacon_loss_count_read_9370 sta_beacon_loss_count_read 3 9370 NULL
104437 +get_request_type_9393 get_request_type 0 9393 NULL nohasharray
104438 +mlx4_bitmap_init_9393 mlx4_bitmap_init 5-2 9393 &get_request_type_9393
104439 +virtqueue_add_outbuf_9395 virtqueue_add_outbuf 3 9395 NULL
104440 +read_9397 read 3 9397 NULL
104441 +btrfs_drop_extents_9423 btrfs_drop_extents 4-0 9423 NULL
104442 +bm_realloc_pages_9431 bm_realloc_pages 2 9431 NULL
104443 +ffs_ep0_write_9438 ffs_ep0_write 3 9438 NULL
104444 +ieee80211_if_fmt_fwded_unicast_9454 ieee80211_if_fmt_fwded_unicast 3 9454 NULL
104445 +ext3_xattr_set_acl_9467 ext3_xattr_set_acl 4 9467 NULL
104446 +agp_generic_alloc_user_9470 agp_generic_alloc_user 1 9470 NULL nohasharray
104447 +get_registers_9470 get_registers 4 9470 &agp_generic_alloc_user_9470
104448 +btrfs_csum_file_blocks_9491 btrfs_csum_file_blocks 0 9491 NULL
104449 +crypt_status_9492 crypt_status 5 9492 NULL
104450 +lbs_threshold_write_9502 lbs_threshold_write 5 9502 NULL
104451 +btrfs_add_delayed_data_ref_9508 btrfs_add_delayed_data_ref 0 9508 NULL
104452 +lp_write_9511 lp_write 3 9511 NULL
104453 +mext_calc_swap_extents_9517 mext_calc_swap_extents 4 9517 NULL
104454 +scsi_tgt_kspace_exec_9522 scsi_tgt_kspace_exec 8 9522 NULL
104455 +ll_max_read_ahead_whole_mb_seq_write_9528 ll_max_read_ahead_whole_mb_seq_write 3 9528 NULL
104456 +read_file_dma_9530 read_file_dma 3 9530 NULL
104457 +ext3_alloc_branch_9534 ext3_alloc_branch 5 9534 NULL
104458 +iwl_dbgfs_bf_params_read_9542 iwl_dbgfs_bf_params_read 3 9542 NULL
104459 +unmerge_ksm_pages_9546 unmerge_ksm_pages 0 9546 NULL nohasharray
104460 +il_dbgfs_missed_beacon_write_9546 il_dbgfs_missed_beacon_write 3 9546 &unmerge_ksm_pages_9546
104461 +compat_SyS_pwritev64_9548 compat_SyS_pwritev64 3 9548 NULL
104462 +readl_9557 readl 0 9557 NULL
104463 +fw_node_create_9559 fw_node_create 2 9559 NULL
104464 +ipath_get_user_pages_9561 ipath_get_user_pages 1-2 9561 NULL
104465 +kobj_map_9566 kobj_map 3-2 9566 NULL
104466 +f2fs_read_data_pages_9574 f2fs_read_data_pages 4 9574 NULL
104467 +use_block_rsv_9597 use_block_rsv 3 9597 NULL
104468 +snd_emu10k1_fx8010_read_9605 snd_emu10k1_fx8010_read 5-6 9605 NULL
104469 +ocfs2_claim_suballoc_bits_9615 ocfs2_claim_suballoc_bits 0 9615 NULL
104470 +lov_ost_pool_add_9626 lov_ost_pool_add 3 9626 NULL
104471 +saa7164_buffer_alloc_user_9627 saa7164_buffer_alloc_user 2 9627 NULL
104472 +ceph_copy_user_to_page_vector_9635 ceph_copy_user_to_page_vector 3-4 9635 NULL
104473 +acpi_ex_insert_into_field_9638 acpi_ex_insert_into_field 3 9638 NULL
104474 +compat_sys_keyctl_9639 compat_sys_keyctl 4 9639 NULL
104475 +ll_checksum_seq_write_9648 ll_checksum_seq_write 3 9648 NULL
104476 +ocfs2_xattr_get_rec_9652 ocfs2_xattr_get_rec 0 9652 NULL
104477 +queue_received_packet_9657 queue_received_packet 5 9657 NULL
104478 +snd_opl4_mem_proc_write_9670 snd_opl4_mem_proc_write 5 9670 NULL
104479 +dns_query_9676 dns_query 3 9676 NULL
104480 +qib_7322_handle_hwerrors_9678 qib_7322_handle_hwerrors 3 9678 NULL
104481 +__erst_read_from_storage_9690 __erst_read_from_storage 0 9690 NULL
104482 +vx_transfer_end_9701 vx_transfer_end 0 9701 NULL
104483 +fnb_9703 fnb 2-3-0 9703 NULL
104484 +fuse_iter_npages_9705 fuse_iter_npages 0 9705 NULL nohasharray
104485 +ieee80211_if_read_aid_9705 ieee80211_if_read_aid 3 9705 &fuse_iter_npages_9705
104486 +cfg80211_tx_mlme_mgmt_9715 cfg80211_tx_mlme_mgmt 3 9715 NULL
104487 +btrfs_stack_file_extent_num_bytes_9720 btrfs_stack_file_extent_num_bytes 0 9720 NULL
104488 +SYSC_ppoll_9721 SYSC_ppoll 2 9721 NULL
104489 +nla_get_u8_9736 nla_get_u8 0 9736 NULL
104490 +ieee80211_if_fmt_num_mcast_sta_9738 ieee80211_if_fmt_num_mcast_sta 3 9738 NULL
104491 +shmem_replace_page_9740 shmem_replace_page 0 9740 NULL
104492 +ddb_input_read_9743 ddb_input_read 3-0 9743 NULL
104493 +sta_last_ack_signal_read_9751 sta_last_ack_signal_read 3 9751 NULL
104494 +ni_calculate_power_boost_limit_9757 ni_calculate_power_boost_limit 3 9757 NULL
104495 +btrfs_super_root_9763 btrfs_super_root 0 9763 NULL
104496 +__alloc_percpu_9764 __alloc_percpu 2-1 9764 NULL
104497 +btrfs_write_and_wait_transaction_9768 btrfs_write_and_wait_transaction 0 9768 NULL
104498 +__blk_queue_init_tags_9778 __blk_queue_init_tags 2 9778 NULL
104499 +snd_mem_proc_write_9786 snd_mem_proc_write 3 9786 NULL
104500 +kvm_age_hva_9795 kvm_age_hva 2 9795 NULL
104501 +parse_uac2_sample_rate_range_9801 parse_uac2_sample_rate_range 0 9801 NULL
104502 +tpm_data_in_9802 tpm_data_in 0 9802 NULL
104503 +ttm_bo_fbdev_io_9805 ttm_bo_fbdev_io 4 9805 NULL
104504 +udpv6_recvmsg_9813 udpv6_recvmsg 4 9813 NULL nohasharray
104505 +ieee80211_if_read_state_9813 ieee80211_if_read_state 3 9813 &udpv6_recvmsg_9813
104506 +svc_pool_map_get_node_9817 svc_pool_map_get_node 0 9817 NULL
104507 +dvb_dvr_set_buffer_size_9840 dvb_dvr_set_buffer_size 2 9840 NULL
104508 +pmcraid_alloc_sglist_9864 pmcraid_alloc_sglist 1 9864 NULL
104509 +btrfs_free_reserved_extent_9867 btrfs_free_reserved_extent 2 9867 NULL
104510 +f1x_translate_sysaddr_to_cs_9868 f1x_translate_sysaddr_to_cs 2 9868 NULL
104511 +mlx4_bitmap_alloc_range_9876 mlx4_bitmap_alloc_range 2-3 9876 NULL
104512 +wil_read_file_ioblob_9878 wil_read_file_ioblob 3 9878 NULL
104513 +bm_register_write_9893 bm_register_write 3 9893 NULL nohasharray
104514 +snd_midi_event_new_9893 snd_midi_event_new 1 9893 &bm_register_write_9893
104515 +snd_gf1_pcm_playback_copy_9895 snd_gf1_pcm_playback_copy 5-3 9895 NULL
104516 +nonpaging_page_fault_9908 nonpaging_page_fault 2 9908 NULL
104517 +ext4_map_blocks_9916 ext4_map_blocks 0 9916 NULL
104518 +root_nfs_parse_options_9937 root_nfs_parse_options 3 9937 NULL
104519 +tc3589x_reg_read_9940 tc3589x_reg_read 0 9940 NULL
104520 +pstore_ftrace_knob_read_9947 pstore_ftrace_knob_read 3 9947 NULL
104521 +read_file_misc_9948 read_file_misc 3 9948 NULL
104522 +ext2_new_blocks_9954 ext2_new_blocks 2-0 9954 NULL
104523 +csum_partial_copy_fromiovecend_9957 csum_partial_copy_fromiovecend 4-3 9957 NULL
104524 +SyS_gethostname_9964 SyS_gethostname 2 9964 NULL
104525 +get_free_serial_index_9969 get_free_serial_index 0 9969 NULL
104526 +btrfs_add_link_9973 btrfs_add_link 5-0 9973 NULL
104527 +SYSC_move_pages_9986 SYSC_move_pages 2 9986 NULL
104528 +aat2870_dump_reg_10019 aat2870_dump_reg 0 10019 NULL
104529 +batadv_orig_hash_add_if_10033 batadv_orig_hash_add_if 2 10033 NULL
104530 +iterate_inodes_from_logical_10037 iterate_inodes_from_logical 0 10037 NULL
104531 +vm_iomap_memory_10038 vm_iomap_memory 2 10038 NULL
104532 +ieee80211_set_probe_resp_10077 ieee80211_set_probe_resp 3 10077 NULL
104533 +ufs_bitmap_search_10105 ufs_bitmap_search 0-3 10105 NULL
104534 +get_elem_size_10110 get_elem_size 0-2 10110 NULL nohasharray
104535 +dynamic_ps_timeout_read_10110 dynamic_ps_timeout_read 3 10110 &get_elem_size_10110
104536 +gfs2_meta_read_10112 gfs2_meta_read 0 10112 NULL
104537 +SyS_migrate_pages_10134 SyS_migrate_pages 2 10134 NULL nohasharray
104538 +offset_to_bit_10134 offset_to_bit 0-2-1-3 10134 &SyS_migrate_pages_10134
104539 +aes_decrypt_packets_read_10155 aes_decrypt_packets_read 3 10155 NULL
104540 +rx_out_of_mem_read_10157 rx_out_of_mem_read 3 10157 NULL
104541 +hidg_alloc_ep_req_10159 hidg_alloc_ep_req 2 10159 NULL nohasharray
104542 +ol_chunk_entries_10159 ol_chunk_entries 0 10159 &hidg_alloc_ep_req_10159
104543 +stmpe_irq_unmap_10164 stmpe_irq_unmap 2 10164 NULL
104544 +asd_store_update_bios_10165 asd_store_update_bios 4 10165 NULL
104545 +kstrtol_from_user_10168 kstrtol_from_user 2 10168 NULL
104546 +proc_pid_attr_read_10173 proc_pid_attr_read 3 10173 NULL
104547 +jffs2_user_setxattr_10182 jffs2_user_setxattr 4 10182 NULL
104548 +register_ftrace_function_10218 register_ftrace_function 0 10218 NULL
104549 +hdlc_rpr_irq_10240 hdlc_rpr_irq 2 10240 NULL
104550 +mutex_lock_killable_10244 mutex_lock_killable 0 10244 NULL
104551 +insert_orphan_item_10249 insert_orphan_item 0 10249 NULL
104552 +cciss_proc_write_10259 cciss_proc_write 3 10259 NULL
104553 +gpiochip_add_to_list_10262 gpiochip_add_to_list 0 10262 NULL
104554 +__qlcnic_pci_sriov_enable_10281 __qlcnic_pci_sriov_enable 2 10281 NULL
104555 +snd_rme9652_capture_copy_10287 snd_rme9652_capture_copy 5 10287 NULL
104556 +ubi_leb_change_10289 ubi_leb_change 0-4 10289 NULL
104557 +read_emulate_10310 read_emulate 2-4 10310 NULL
104558 +read_file_spectral_count_10320 read_file_spectral_count 3 10320 NULL
104559 +ttm_object_device_init_10321 ttm_object_device_init 2 10321 NULL
104560 +compat_SyS_writev_10327 compat_SyS_writev 3 10327 NULL
104561 +ubi_leb_read_10328 ubi_leb_read 0 10328 NULL
104562 +tun_sendmsg_10337 tun_sendmsg 4 10337 NULL
104563 +get_dump_page_10338 get_dump_page 1 10338 NULL
104564 +ufx_alloc_urb_list_10349 ufx_alloc_urb_list 3 10349 NULL
104565 +whci_add_cap_10350 whci_add_cap 0 10350 NULL
104566 +dbAllocAny_10354 dbAllocAny 0 10354 NULL
104567 +ath6kl_listen_int_read_10355 ath6kl_listen_int_read 3 10355 NULL
104568 +__ntfs_cluster_free_10360 __ntfs_cluster_free 0 10360 NULL
104569 +ms_write_multiple_pages_10362 ms_write_multiple_pages 6-5 10362 NULL
104570 +sta_ht_capa_read_10366 sta_ht_capa_read 3 10366 NULL
104571 +ecryptfs_decode_and_decrypt_filename_10379 ecryptfs_decode_and_decrypt_filename 5 10379 NULL
104572 +do_compat_pselect_10398 do_compat_pselect 1 10398 NULL
104573 +fwtty_rx_10434 fwtty_rx 3 10434 NULL
104574 +event_phy_transmit_error_read_10471 event_phy_transmit_error_read 3 10471 NULL
104575 +ext4_itable_unused_count_10501 ext4_itable_unused_count 0 10501 NULL
104576 +qib_alloc_fast_reg_page_list_10507 qib_alloc_fast_reg_page_list 2 10507 NULL
104577 +sel_write_disable_10511 sel_write_disable 3 10511 NULL
104578 +osd_req_write_sg_kern_10514 osd_req_write_sg_kern 5 10514 NULL
104579 +rds_message_alloc_10517 rds_message_alloc 1 10517 NULL
104580 +qlcnic_pci_sriov_enable_10519 qlcnic_pci_sriov_enable 2 10519 NULL nohasharray
104581 +hash_netiface4_expire_10519 hash_netiface4_expire 3 10519 &qlcnic_pci_sriov_enable_10519
104582 +snd_pcm_hw_params_user_10520 snd_pcm_hw_params_user 0 10520 NULL
104583 +ocfs2_add_refcounted_extent_10526 ocfs2_add_refcounted_extent 6 10526 NULL
104584 +snd_pcm_lib_read_10536 snd_pcm_lib_read 0-3 10536 NULL nohasharray
104585 +kstrtouint_from_user_10536 kstrtouint_from_user 2 10536 &snd_pcm_lib_read_10536
104586 +SYSC_read_10545 SYSC_read 3 10545 NULL
104587 +ext4_write_begin_10576 ext4_write_begin 3-4 10576 NULL
104588 +scrub_remap_extent_10588 scrub_remap_extent 2 10588 NULL
104589 +otp_read_10594 otp_read 5-4-2 10594 NULL
104590 +supply_map_read_file_10608 supply_map_read_file 3 10608 NULL
104591 +ima_show_htable_violations_10619 ima_show_htable_violations 3 10619 NULL
104592 +alloc_coherent_10632 alloc_coherent 2 10632 NULL
104593 +ubi_io_write_vid_hdr_10660 ubi_io_write_vid_hdr 0 10660 NULL nohasharray
104594 +nfs_idmap_lookup_id_10660 nfs_idmap_lookup_id 2 10660 &ubi_io_write_vid_hdr_10660
104595 +efx_max_tx_len_10662 efx_max_tx_len 0-2 10662 NULL
104596 +dtf_read_device_10663 dtf_read_device 3 10663 NULL
104597 +parport_write_10669 parport_write 0 10669 NULL
104598 +alloc_vmap_area_10682 alloc_vmap_area 5 10682 NULL
104599 +edge_write_10692 edge_write 4 10692 NULL
104600 +ubi_wl_get_peb_10699 ubi_wl_get_peb 0 10699 NULL
104601 +inl_10708 inl 0 10708 NULL nohasharray
104602 +selinux_inode_setxattr_10708 selinux_inode_setxattr 4 10708 &inl_10708
104603 +pvr2_ioread_read_10720 pvr2_ioread_read 3 10720 NULL nohasharray
104604 +shash_async_setkey_10720 shash_async_setkey 3 10720 &pvr2_ioread_read_10720
104605 +spi_sync_10731 spi_sync 0 10731 NULL
104606 +sctp_getsockopt_maxseg_10737 sctp_getsockopt_maxseg 2 10737 NULL nohasharray
104607 +apu_get_register_10737 apu_get_register 0 10737 &sctp_getsockopt_maxseg_10737
104608 +alloc_one_pg_vec_page_10747 alloc_one_pg_vec_page 1 10747 NULL
104609 +ttm_ref_object_add_10748 ttm_ref_object_add 0 10748 NULL
104610 +SyS_io_getevents_10756 SyS_io_getevents 3 10756 NULL
104611 +vhost_add_used_n_10760 vhost_add_used_n 3 10760 NULL
104612 +kvm_read_guest_atomic_10765 kvm_read_guest_atomic 2-4 10765 NULL
104613 +wb_set_dirty_10778 wb_set_dirty 2 10778 NULL
104614 +__qp_memcpy_to_queue_10779 __qp_memcpy_to_queue 2-4 10779 NULL
104615 +i915_gem_wait_for_error_10791 i915_gem_wait_for_error 0 10791 NULL
104616 +snd_mask_value_10794 snd_mask_value 0 10794 NULL
104617 +diva_set_trace_filter_10820 diva_set_trace_filter 0-1 10820 NULL
104618 +lbs_sleepparams_read_10840 lbs_sleepparams_read 3 10840 NULL
104619 +ida_get_new_above_10853 ida_get_new_above 2-0 10853 NULL
104620 +fuse_conn_max_background_read_10855 fuse_conn_max_background_read 3 10855 NULL
104621 +ol_chunk_blocks_10864 ol_chunk_blocks 0 10864 NULL
104622 +snd_pcm_oss_write1_10872 snd_pcm_oss_write1 3 10872 NULL
104623 +drm_ht_insert_item_10877 drm_ht_insert_item 0 10877 NULL
104624 +wiidebug_drm_write_10879 wiidebug_drm_write 3 10879 NULL
104625 +get_scq_10897 get_scq 2 10897 NULL
104626 +cgroup_write_string_10900 cgroup_write_string 5 10900 NULL
104627 +tifm_alloc_adapter_10903 tifm_alloc_adapter 1 10903 NULL
104628 +lprocfs_wr_atomic_10912 lprocfs_wr_atomic 3 10912 NULL
104629 +__copy_from_user_10918 __copy_from_user 3-0 10918 NULL
104630 +kobject_add_10919 kobject_add 0 10919 NULL
104631 +da9052_map_irq_10952 da9052_map_irq 2 10952 NULL
104632 +ci_port_test_write_10962 ci_port_test_write 3 10962 NULL
104633 +bm_entry_read_10976 bm_entry_read 3 10976 NULL
104634 +sched_autogroup_write_10984 sched_autogroup_write 3 10984 NULL
104635 +__hci_num_ctrl_10985 __hci_num_ctrl 0 10985 NULL
104636 +lz4_compress_10986 lz4_compress 2 10986 NULL
104637 +do_switch_10994 do_switch 0 10994 NULL
104638 +xfrm_hash_alloc_10997 xfrm_hash_alloc 1 10997 NULL
104639 +btrfs_add_delayed_extent_op_11000 btrfs_add_delayed_extent_op 0 11000 NULL
104640 +rx_filter_accum_arp_pend_requests_read_11003 rx_filter_accum_arp_pend_requests_read 3 11003 NULL
104641 +SetLineNumber_11023 SetLineNumber 0 11023 NULL
104642 +btrfs_find_space_for_alloc_11028 btrfs_find_space_for_alloc 2 11028 NULL
104643 +mb_find_next_bit_11037 mb_find_next_bit 0-2-3 11037 NULL
104644 +tda10048_writeregbulk_11050 tda10048_writeregbulk 4 11050 NULL
104645 +insert_inline_extent_backref_11063 insert_inline_extent_backref 8-0 11063 NULL
104646 +tcp_send_mss_11079 tcp_send_mss 0 11079 NULL
104647 +snd_pcm_delay_11081 snd_pcm_delay 0 11081 NULL
104648 +count_argc_11083 count_argc 0 11083 NULL
104649 +kvm_write_guest_cached_11106 kvm_write_guest_cached 4 11106 NULL
104650 +stmpe_gpio_to_irq_11110 stmpe_gpio_to_irq 2 11110 NULL
104651 +tw_change_queue_depth_11116 tw_change_queue_depth 2 11116 NULL
104652 +page_offset_11120 page_offset 0 11120 NULL
104653 +tracing_buffers_read_11124 tracing_buffers_read 3 11124 NULL nohasharray
104654 +cea_db_payload_len_11124 cea_db_payload_len 0 11124 &tracing_buffers_read_11124
104655 +alloc_alien_cache_11127 alloc_alien_cache 2-1 11127 NULL
104656 +eb_lookup_objects_11163 eb_lookup_objects 0 11163 NULL
104657 +snd_gf1_pcm_playback_silence_11172 snd_gf1_pcm_playback_silence 4-3 11172 NULL
104658 +il_dbgfs_rx_queue_read_11221 il_dbgfs_rx_queue_read 3 11221 NULL
104659 +comedi_alloc_spriv_11234 comedi_alloc_spriv 2 11234 NULL
104660 +mmap_region_11247 mmap_region 0-2 11247 NULL
104661 +ubifs_write_node_11258 ubifs_write_node 5-3 11258 NULL
104662 +dm_cache_discard_bitset_resize_11262 dm_cache_discard_bitset_resize 3 11262 NULL
104663 +hugetlbfs_read_11268 hugetlbfs_read 3 11268 NULL
104664 +ath6kl_power_params_write_11274 ath6kl_power_params_write 3 11274 NULL
104665 +__proc_daemon_file_11305 __proc_daemon_file 5 11305 NULL
104666 +split_vma_11312 split_vma 0 11312 NULL
104667 +btrfs_update_inode_fallback_11313 btrfs_update_inode_fallback 0 11313 NULL
104668 +ext4_xattr_check_names_11314 ext4_xattr_check_names 0 11314 NULL
104669 +sk_filter_size_11316 sk_filter_size 0 11316 NULL nohasharray
104670 +tcp_send_rcvq_11316 tcp_send_rcvq 3 11316 &sk_filter_size_11316
104671 +shmem_radix_tree_replace_11325 shmem_radix_tree_replace 0 11325 NULL
104672 +construct_key_11329 construct_key 3 11329 NULL nohasharray
104673 +__kfifo_out_peek_11329 __kfifo_out_peek 0-3 11329 &construct_key_11329
104674 +next_segment_11330 next_segment 0-2-1 11330 NULL
104675 +persistent_ram_buffer_map_11332 persistent_ram_buffer_map 2-1 11332 NULL
104676 +ext4_get_inline_size_11349 ext4_get_inline_size 0 11349 NULL
104677 +nl80211_send_mgmt_11353 nl80211_send_mgmt 7 11353 NULL nohasharray
104678 +sel_write_create_11353 sel_write_create 3 11353 &nl80211_send_mgmt_11353
104679 +drm_vblank_init_11362 drm_vblank_init 2 11362 NULL
104680 +qib_get_base_info_11369 qib_get_base_info 3 11369 NULL
104681 +isku_sysfs_read_keys_capslock_11392 isku_sysfs_read_keys_capslock 6 11392 NULL
104682 +dev_irnet_write_11398 dev_irnet_write 3 11398 NULL
104683 +__btrfs_add_delayed_insertion_item_11400 __btrfs_add_delayed_insertion_item 0 11400 NULL
104684 +lprocfs_wr_evict_client_11402 lprocfs_wr_evict_client 3 11402 NULL
104685 +___alloc_bootmem_11410 ___alloc_bootmem 1 11410 NULL
104686 +str_to_user_11411 str_to_user 2 11411 NULL
104687 +mem_fw_gen_free_mem_blks_read_11413 mem_fw_gen_free_mem_blks_read 3 11413 NULL
104688 +ath6kl_wmi_test_rx_11414 ath6kl_wmi_test_rx 3 11414 NULL
104689 +relocate_entry_gtt_11416 relocate_entry_gtt 0 11416 NULL
104690 +adis16480_show_firmware_revision_11417 adis16480_show_firmware_revision 3 11417 NULL
104691 +trace_options_read_11419 trace_options_read 3 11419 NULL
104692 +i40e_dbg_command_write_11421 i40e_dbg_command_write 3 11421 NULL
104693 +__irq_set_trigger_11422 __irq_set_trigger 0 11422 NULL nohasharray
104694 +xd_read_multiple_pages_11422 xd_read_multiple_pages 5-4 11422 &__irq_set_trigger_11422
104695 +prepare_image_11424 prepare_image 0 11424 NULL
104696 +ext3_xattr_block_list_11428 ext3_xattr_block_list 3 11428 NULL
104697 +bttv_read_11432 bttv_read 3 11432 NULL
104698 +create_zero_mask_11453 create_zero_mask 0-1 11453 NULL
104699 +do_blockdev_direct_IO_11455 do_blockdev_direct_IO 0-6 11455 NULL
104700 +swp_offset_11475 swp_offset 0 11475 NULL
104701 +st_sensors_write_data_with_mask_11476 st_sensors_write_data_with_mask 3 11476 NULL
104702 +pci_set_power_state_11479 pci_set_power_state 0 11479 NULL nohasharray
104703 +sca3000_read_first_n_hw_rb_11479 sca3000_read_first_n_hw_rb 2 11479 &pci_set_power_state_11479
104704 +xfs_file_buffered_aio_write_11492 xfs_file_buffered_aio_write 4 11492 NULL
104705 +sd_do_mode_sense_11507 sd_do_mode_sense 5 11507 NULL
104706 +kmem_zalloc_11510 kmem_zalloc 1 11510 NULL
104707 +ll_direct_IO_26_seg_11518 ll_direct_IO_26_seg 0 11518 NULL
104708 +twl_direction_in_11527 twl_direction_in 2 11527 NULL
104709 +setup_IO_APIC_irq_extra_11537 setup_IO_APIC_irq_extra 1 11537 NULL
104710 +radix_tree_extend_11555 radix_tree_extend 0 11555 NULL
104711 +skb_cow_data_11565 skb_cow_data 0 11565 NULL
104712 +posix_acl_create_masq_11567 posix_acl_create_masq 0 11567 NULL
104713 +qgroup_account_ref_step2_11575 qgroup_account_ref_step2 0 11575 NULL
104714 +lpfc_idiag_ctlacc_write_11576 lpfc_idiag_ctlacc_write 3 11576 NULL
104715 +oprofilefs_ulong_to_user_11582 oprofilefs_ulong_to_user 3 11582 NULL
104716 +snd_pcm_action_11589 snd_pcm_action 0 11589 NULL
104717 +fw_device_op_ioctl_11595 fw_device_op_ioctl 2 11595 NULL
104718 +btrfs_uuid_tree_add_11598 btrfs_uuid_tree_add 0 11598 NULL
104719 +SYSC_mq_timedsend_11607 SYSC_mq_timedsend 3 11607 NULL
104720 +i915_gem_object_pin_11630 i915_gem_object_pin 0 11630 NULL
104721 +add_new_bitmap_11644 add_new_bitmap 3 11644 NULL
104722 +sisusb_send_bridge_packet_11649 sisusb_send_bridge_packet 2 11649 NULL
104723 +nla_total_size_11658 nla_total_size 0-1 11658 NULL
104724 +slab_ksize_11664 slab_ksize 0 11664 NULL
104725 +__btrfs_run_delayed_items_11671 __btrfs_run_delayed_items 0 11671 NULL
104726 +ide_queue_pc_tail_11673 ide_queue_pc_tail 5 11673 NULL
104727 +compat_SyS_msgsnd_11675 compat_SyS_msgsnd 3 11675 NULL
104728 +btrfs_alloc_delayed_item_11678 btrfs_alloc_delayed_item 1 11678 NULL
104729 +dsp_buffer_alloc_11684 dsp_buffer_alloc 2 11684 NULL
104730 +sctp_setsockopt_hmac_ident_11687 sctp_setsockopt_hmac_ident 3 11687 NULL
104731 +split_11691 split 2 11691 NULL
104732 +snd_ctl_elem_user_tlv_11695 snd_ctl_elem_user_tlv 3 11695 NULL
104733 +blk_rq_cur_bytes_11723 blk_rq_cur_bytes 0 11723 NULL
104734 +dm_bio_prison_create_11749 dm_bio_prison_create 1 11749 NULL
104735 +iwl_dbgfs_qos_read_11753 iwl_dbgfs_qos_read 3 11753 NULL
104736 +intel_map_page_11762 intel_map_page 4-3 11762 NULL
104737 +ocfs2_relink_block_group_11769 ocfs2_relink_block_group 0 11769 NULL
104738 +ps_pspoll_timeouts_read_11776 ps_pspoll_timeouts_read 3 11776 NULL
104739 +ebt_buf_add_11779 ebt_buf_add 0 11779 NULL
104740 +btrfs_key_blockptr_11786 btrfs_key_blockptr 0 11786 NULL
104741 +rtw_alloc_etherdev_11792 rtw_alloc_etherdev 1 11792 NULL
104742 +pcpu_fc_alloc_11818 pcpu_fc_alloc 2 11818 NULL
104743 +umc_device_register_11824 umc_device_register 0 11824 NULL
104744 +zerocopy_sg_from_iovec_11828 zerocopy_sg_from_iovec 3 11828 NULL
104745 +sctp_setsockopt_maxseg_11829 sctp_setsockopt_maxseg 3 11829 NULL
104746 +rts51x_read_status_11830 rts51x_read_status 4 11830 NULL
104747 +unix_stream_connect_11844 unix_stream_connect 3 11844 NULL
104748 +ecryptfs_copy_filename_11868 ecryptfs_copy_filename 4 11868 NULL
104749 +ieee80211_rx_bss_info_11887 ieee80211_rx_bss_info 3 11887 NULL
104750 +mdc_rename_11899 mdc_rename 4-6 11899 NULL
104751 +perf_mmap_alloc_page_11904 perf_mmap_alloc_page 1 11904 NULL
104752 +xstateregs_get_11906 xstateregs_get 4 11906 NULL
104753 +ti_write_11916 ti_write 4 11916 NULL
104754 +fs_devrw_entry_11924 fs_devrw_entry 3 11924 NULL
104755 +bitmap_remap_11929 bitmap_remap 5 11929 NULL
104756 +atomic_sub_return_11939 atomic_sub_return 0-1 11939 NULL
104757 +r1_sync_page_io_11963 r1_sync_page_io 3 11963 NULL
104758 +f1x_swap_interleaved_region_11970 f1x_swap_interleaved_region 0-2 11970 NULL
104759 +usc_InReg_11976 usc_InReg 0 11976 NULL nohasharray
104760 +split_node_11976 split_node 0 11976 &usc_InReg_11976
104761 +BeceemFlashBulkRead_11979 BeceemFlashBulkRead 0 11979 NULL
104762 +read_and_add_raw_conns_11987 read_and_add_raw_conns 0 11987 NULL
104763 +i40e_pci_sriov_configure_12011 i40e_pci_sriov_configure 2 12011 NULL
104764 +intel_init_ring_buffer_12016 intel_init_ring_buffer 0 12016 NULL
104765 +ftdi_elan_total_command_size_12045 ftdi_elan_total_command_size 0 12045 NULL
104766 +did_overwrite_ref_12046 did_overwrite_ref 0 12046 NULL
104767 +ieee80211_if_read_user_power_level_12050 ieee80211_if_read_user_power_level 3 12050 NULL
104768 +il4965_ucode_tx_stats_read_12064 il4965_ucode_tx_stats_read 3 12064 NULL
104769 +ptc_proc_write_12076 ptc_proc_write 3 12076 NULL
104770 +ubifs_recover_log_leb_12079 ubifs_recover_log_leb 3 12079 NULL
104771 +pse36_gfn_delta_12087 pse36_gfn_delta 0-1 12087 NULL
104772 +rtw_malloc2d_12102 rtw_malloc2d 1-2-3 12102 NULL
104773 +twl6030_irq_map_12105 twl6030_irq_map 2 12105 NULL
104774 +i915_gem_evict_something_12118 i915_gem_evict_something 0 12118 NULL
104775 +alloc_bulk_urbs_generic_12127 alloc_bulk_urbs_generic 5 12127 NULL
104776 +set_powered_12129 set_powered 4 12129 NULL
104777 +ramoops_init_prz_12134 ramoops_init_prz 5 12134 NULL
104778 +xfs_handle_to_dentry_12135 xfs_handle_to_dentry 3 12135 NULL
104779 +rawv6_seticmpfilter_12137 rawv6_seticmpfilter 5 12137 NULL
104780 +vmw_fifo_reserve_12141 vmw_fifo_reserve 2 12141 NULL
104781 +rawsock_recvmsg_12144 rawsock_recvmsg 4 12144 NULL
104782 +get_idx_gc_leb_12148 get_idx_gc_leb 0 12148 NULL
104783 +btmrvl_sdio_host_to_card_12152 btmrvl_sdio_host_to_card 3 12152 NULL
104784 +ocfs2_local_alloc_new_window_12153 ocfs2_local_alloc_new_window 0 12153 NULL
104785 +vmbus_open_12154 vmbus_open 2-3 12154 NULL
104786 +dma_memcpy_to_iovec_12173 dma_memcpy_to_iovec 5 12173 NULL
104787 +LNetEQAlloc_12178 LNetEQAlloc 1 12178 NULL
104788 +ddp_make_gl_12179 ddp_make_gl 1 12179 NULL
104789 +compat_do_arpt_set_ctl_12184 compat_do_arpt_set_ctl 4 12184 NULL
104790 +ip_generic_getfrag_12187 ip_generic_getfrag 3-4 12187 NULL
104791 +scaled_div_12201 scaled_div 2-1-0 12201 NULL
104792 +snd_pcm_kernel_ioctl_12219 snd_pcm_kernel_ioctl 0 12219 NULL
104793 +fuse_get_req_12221 fuse_get_req 2 12221 NULL nohasharray
104794 +aat2870_reg_read_file_12221 aat2870_reg_read_file 3 12221 &fuse_get_req_12221
104795 +__alloc_bootmem_low_nopanic_12235 __alloc_bootmem_low_nopanic 1 12235 NULL
104796 +kvirt_to_pa_12247 kvirt_to_pa 0 12247 NULL
104797 +ib_uverbs_unmarshall_recv_12251 ib_uverbs_unmarshall_recv 5 12251 NULL
104798 +shash_compat_setkey_12267 shash_compat_setkey 3 12267 NULL
104799 +add_sctp_bind_addr_12269 add_sctp_bind_addr 3 12269 NULL
104800 +note_last_dentry_12285 note_last_dentry 3 12285 NULL
104801 +roundup_to_multiple_of_64_12288 roundup_to_multiple_of_64 0-1 12288 NULL nohasharray
104802 +il_dbgfs_nvm_read_12288 il_dbgfs_nvm_read 3 12288 &roundup_to_multiple_of_64_12288
104803 +wrap_min_12303 wrap_min 0-1-2 12303 NULL
104804 +bt_sock_recvmsg_12316 bt_sock_recvmsg 4 12316 NULL
104805 +pcbit_writecmd_12332 pcbit_writecmd 2 12332 NULL
104806 +btrfs_lookup_file_extent_12341 btrfs_lookup_file_extent 0 12341 NULL
104807 +mptctl_ioctl_12355 mptctl_ioctl 2 12355 NULL
104808 +paging32_walk_addr_12359 paging32_walk_addr 3 12359 NULL
104809 +__nf_ct_ext_add_length_12364 __nf_ct_ext_add_length 3 12364 NULL
104810 +xfs_iext_inline_to_direct_12384 xfs_iext_inline_to_direct 2 12384 NULL
104811 +btrfs_file_extent_ram_bytes_12391 btrfs_file_extent_ram_bytes 0 12391 NULL nohasharray
104812 +populate_dir_12391 populate_dir 0 12391 &btrfs_file_extent_ram_bytes_12391
104813 +ntfs_get_size_for_mapping_pairs_12413 ntfs_get_size_for_mapping_pairs 0 12413 NULL nohasharray
104814 +ext4_bg_num_gdb_nometa_12413 ext4_bg_num_gdb_nometa 0 12413 &ntfs_get_size_for_mapping_pairs_12413
104815 +hbucket_elem_add_12416 hbucket_elem_add 3 12416 NULL
104816 +ieee80211_if_read_num_mcast_sta_12419 ieee80211_if_read_num_mcast_sta 3 12419 NULL
104817 +cfs_array_alloc_12441 cfs_array_alloc 2 12441 NULL
104818 +skb_do_copy_data_nocache_12465 skb_do_copy_data_nocache 5 12465 NULL
104819 +x25_sendmsg_12487 x25_sendmsg 4 12487 NULL
104820 +fnic_trace_ctrl_read_12497 fnic_trace_ctrl_read 3 12497 NULL
104821 +qib_alloc_fast_reg_mr_12526 qib_alloc_fast_reg_mr 2 12526 NULL
104822 +xfs_get_extsz_hint_12531 xfs_get_extsz_hint 0 12531 NULL
104823 +kvm_setup_async_pf_12555 kvm_setup_async_pf 3 12555 NULL
104824 +ib_umem_get_12557 ib_umem_get 2-3 12557 NULL
104825 +ceph_osdc_wait_request_12572 ceph_osdc_wait_request 0 12572 NULL
104826 +hvc_alloc_12579 hvc_alloc 4 12579 NULL
104827 +snd_pcm_plugin_alloc_12580 snd_pcm_plugin_alloc 2 12580 NULL
104828 +pcpu_extend_area_map_12589 pcpu_extend_area_map 2 12589 NULL
104829 +tlbflush_write_file_12598 tlbflush_write_file 3 12598 NULL
104830 +vhci_put_user_12604 vhci_put_user 4 12604 NULL
104831 +ipath_mmap_mem_12625 ipath_mmap_mem 3 12625 NULL
104832 +sdhci_pltfm_init_12627 sdhci_pltfm_init 3 12627 NULL
104833 +pwr_rcvd_awake_bcns_cnt_read_12632 pwr_rcvd_awake_bcns_cnt_read 3 12632 NULL
104834 +pn_sendmsg_12640 pn_sendmsg 4 12640 NULL
104835 +dwc3_link_state_write_12641 dwc3_link_state_write 3 12641 NULL
104836 +nr_recvmsg_12649 nr_recvmsg 4 12649 NULL
104837 +wb_create_12651 wb_create 1 12651 NULL
104838 +rtw_android_get_link_speed_12655 rtw_android_get_link_speed 0 12655 NULL
104839 +ocfs2_read_block_12659 ocfs2_read_block 0 12659 NULL
104840 +sel_read_class_12669 sel_read_class 3 12669 NULL nohasharray
104841 +sparse_mem_maps_populate_node_12669 sparse_mem_maps_populate_node 4-5 12669 &sel_read_class_12669
104842 +ext4_writepage_trans_blocks_12674 ext4_writepage_trans_blocks 0 12674 NULL
104843 +ext4_bg_num_gdb_meta_12702 ext4_bg_num_gdb_meta 0 12702 NULL
104844 +iwl_dbgfs_calib_disabled_write_12707 iwl_dbgfs_calib_disabled_write 3 12707 NULL
104845 +ieee80211_if_read_num_buffered_multicast_12716 ieee80211_if_read_num_buffered_multicast 3 12716 NULL
104846 +ivtv_write_12721 ivtv_write 3 12721 NULL
104847 +key_rx_spec_read_12736 key_rx_spec_read 3 12736 NULL
104848 +__mei_cl_async_send_12737 __mei_cl_async_send 3 12737 NULL
104849 +run_delayed_data_ref_12749 run_delayed_data_ref 0 12749 NULL
104850 +ieee80211_if_read_dot11MeshMaxRetries_12756 ieee80211_if_read_dot11MeshMaxRetries 3 12756 NULL
104851 +listxattr_12769 listxattr 3 12769 NULL
104852 +sctp_ssnmap_init_12772 sctp_ssnmap_init 2-3 12772 NULL
104853 +btrfs_remove_free_space_12793 btrfs_remove_free_space 2-0 12793 NULL
104854 +scsi_adjust_queue_depth_12802 scsi_adjust_queue_depth 3 12802 NULL
104855 +xfs_inumbers_fmt_12817 xfs_inumbers_fmt 3 12817 NULL
104856 +tlv_put_uuid_12824 tlv_put_uuid 0 12824 NULL
104857 +readq_12825 readq 0 12825 NULL
104858 +SyS_add_key_12834 SyS_add_key 4 12834 NULL
104859 +TSS_authhmac_12839 TSS_authhmac 3 12839 NULL
104860 +spidev_sync_12842 spidev_sync 0 12842 NULL
104861 +spidev_ioctl_12846 spidev_ioctl 2 12846 NULL
104862 +get_leb_cnt_12892 get_leb_cnt 0-2 12892 NULL
104863 +ocfs2_hamming_encode_block_12904 ocfs2_hamming_encode_block 2 12904 NULL
104864 +get_virtual_node_size_12908 get_virtual_node_size 0 12908 NULL
104865 +rds_pages_in_vec_12922 rds_pages_in_vec 0 12922 NULL
104866 +free_tind_blocks_12926 free_tind_blocks 0 12926 NULL
104867 +ci_ll_init_12930 ci_ll_init 3 12930 NULL
104868 +SYSC_sendfile_12936 SYSC_sendfile 4 12936 NULL
104869 +do_inode_permission_12946 do_inode_permission 0 12946 NULL
104870 +bm_status_write_12964 bm_status_write 3 12964 NULL
104871 +raid56_parity_recover_12987 raid56_parity_recover 5 12987 NULL
104872 +TransmitTcb_12989 TransmitTcb 4 12989 NULL
104873 +sk_peek_offset_12991 sk_peek_offset 0 12991 NULL
104874 +subsystem_filter_write_13022 subsystem_filter_write 3 13022 NULL
104875 +btrfs_write_dirty_block_groups_13030 btrfs_write_dirty_block_groups 0 13030 NULL
104876 +generic_segment_checks_13041 generic_segment_checks 0 13041 NULL
104877 +SyS_sendfile64_13043 SyS_sendfile64 4 13043 NULL
104878 +ocfs2_write_begin_13045 ocfs2_write_begin 3-4 13045 NULL
104879 +ptlrpc_lprocfs_threads_min_seq_write_13060 ptlrpc_lprocfs_threads_min_seq_write 3 13060 NULL nohasharray
104880 +__dn_setsockopt_13060 __dn_setsockopt 5 13060 &ptlrpc_lprocfs_threads_min_seq_write_13060
104881 +biovec_create_pool_13079 biovec_create_pool 2 13079 NULL
104882 +_ocfs2_free_suballoc_bits_13085 _ocfs2_free_suballoc_bits 0 13085 NULL
104883 +irq_set_chip_and_handler_13088 irq_set_chip_and_handler 1 13088 NULL
104884 +xattr_getsecurity_13090 xattr_getsecurity 0 13090 NULL
104885 +mb_find_next_zero_bit_13100 mb_find_next_zero_bit 2-3-0 13100 NULL
104886 +ttm_dma_pool_alloc_new_pages_13105 ttm_dma_pool_alloc_new_pages 3 13105 NULL
104887 +SyS_msgrcv_13109 SyS_msgrcv 3 13109 NULL
104888 +snd_rme96_playback_copy_13111 snd_rme96_playback_copy 5 13111 NULL
104889 +xen_allocate_irq_dynamic_13116 xen_allocate_irq_dynamic 0 13116 NULL
104890 +bfad_debugfs_read_13119 bfad_debugfs_read 3 13119 NULL
104891 +blk_update_request_13146 blk_update_request 3 13146 NULL
104892 +caif_stream_recvmsg_13173 caif_stream_recvmsg 4 13173 NULL
104893 +pwr_disable_ps_read_13176 pwr_disable_ps_read 3 13176 NULL
104894 +ucs2_strlen_13178 ucs2_strlen 0 13178 NULL
104895 +dgrp_net_ioctl_13183 dgrp_net_ioctl 2 13183 NULL
104896 +create_trace_uprobe_13184 create_trace_uprobe 1 13184 NULL
104897 +__cmpxchg64_13187 __cmpxchg64 0 13187 NULL
104898 +comedi_read_13199 comedi_read 3 13199 NULL
104899 +mmc_ext_csd_read_13205 mmc_ext_csd_read 3 13205 NULL
104900 +__nodes_fold_13215 __nodes_fold 4 13215 NULL
104901 +get_unaligned_le64_13219 get_unaligned_le64 0 13219 NULL
104902 +svm_msrpm_offset_13220 svm_msrpm_offset 0-1 13220 NULL
104903 +fnic_trace_ctrl_write_13229 fnic_trace_ctrl_write 3 13229 NULL
104904 +asix_read_cmd_13245 asix_read_cmd 5 13245 NULL
104905 +kvm_lapic_enable_pv_eoi_13249 kvm_lapic_enable_pv_eoi 2 13249 NULL
104906 +init_tid_tabs_13252 init_tid_tabs 2-3-4 13252 NULL
104907 +bio_integrity_trim_13259 bio_integrity_trim 3 13259 NULL
104908 +simple_attr_write_13260 simple_attr_write 3 13260 NULL
104909 +c4iw_reg_user_mr_13269 c4iw_reg_user_mr 2-3 13269 NULL
104910 +pmcraid_notify_aen_13274 pmcraid_notify_aen 3 13274 NULL
104911 +il4965_stats_flag_13281 il4965_stats_flag 0-3 13281 NULL
104912 +lpfc_idiag_mbxacc_get_setup_13282 lpfc_idiag_mbxacc_get_setup 0 13282 NULL
104913 +sd_major_13294 sd_major 0-1 13294 NULL
104914 +kempld_read16_13297 kempld_read16 0 13297 NULL
104915 +reexecute_instruction_13321 reexecute_instruction 2 13321 NULL
104916 +__clone_and_map_data_bio_13334 __clone_and_map_data_bio 4-8 13334 NULL
104917 +kvm_read_nested_guest_page_13337 kvm_read_nested_guest_page 5-2 13337 NULL
104918 +get_bits_13353 get_bits 0-2 13353 NULL
104919 +hscx_empty_fifo_13360 hscx_empty_fifo 2 13360 NULL
104920 +snd_ctl_elem_info_13363 snd_ctl_elem_info 0 13363 NULL
104921 +iso_sched_alloc_13377 iso_sched_alloc 1 13377 NULL nohasharray
104922 +wep_key_not_found_read_13377 wep_key_not_found_read 3 13377 &iso_sched_alloc_13377
104923 +ext4_meta_trans_blocks_13380 ext4_meta_trans_blocks 0-3-2 13380 NULL
104924 +lov_mds_md_size_13388 lov_mds_md_size 0-1 13388 NULL nohasharray
104925 +dis_bypass_write_13388 dis_bypass_write 3 13388 &lov_mds_md_size_13388
104926 +BcmSetActiveSection_13389 BcmSetActiveSection 0 13389 NULL
104927 +ocfs2_inode_lock_update_13414 ocfs2_inode_lock_update 0 13414 NULL
104928 +netxen_alloc_sds_rings_13417 netxen_alloc_sds_rings 2 13417 NULL
104929 +compat_SyS_sendfile64_13420 compat_SyS_sendfile64 4 13420 NULL
104930 +keyring_read_13438 keyring_read 3 13438 NULL
104931 +sctp_setsockopt_peer_primary_addr_13440 sctp_setsockopt_peer_primary_addr 3 13440 NULL
104932 +ath6kl_cfg80211_connect_event_13443 ath6kl_cfg80211_connect_event 8-9-7 13443 NULL
104933 +sb_init_dio_done_wq_13482 sb_init_dio_done_wq 0 13482 NULL
104934 +data_read_13494 data_read 3 13494 NULL
104935 +i915_switch_context_13498 i915_switch_context 0 13498 NULL
104936 +ioat_chansts_32_13506 ioat_chansts_32 0 13506 NULL
104937 +ocfs2_align_bytes_to_blocks_13512 ocfs2_align_bytes_to_blocks 2-0 13512 NULL
104938 +core_status_13515 core_status 4 13515 NULL
104939 +smk_write_mapped_13519 smk_write_mapped 3 13519 NULL
104940 +bm_init_13529 bm_init 2 13529 NULL
104941 +kvm_get_cr8_13538 kvm_get_cr8 0 13538 NULL
104942 +SYSC_remap_file_pages_13540 SYSC_remap_file_pages 1-2 13540 NULL nohasharray
104943 +non_atomic_pte_lookup_13540 non_atomic_pte_lookup 2 13540 &SYSC_remap_file_pages_13540
104944 +__btrfs_alloc_chunk_13554 __btrfs_alloc_chunk 0 13554 NULL
104945 +llcp_sock_recvmsg_13556 llcp_sock_recvmsg 4 13556 NULL
104946 +ieee80211_if_read_ap_power_level_13558 ieee80211_if_read_ap_power_level 3 13558 NULL
104947 +ubifs_get_idx_gc_leb_13566 ubifs_get_idx_gc_leb 0 13566 NULL
104948 +read_file_antenna_13574 read_file_antenna 3 13574 NULL
104949 +cache_write_13589 cache_write 3 13589 NULL
104950 +Rd_Indx_13602 Rd_Indx 3-2 13602 NULL
104951 +swap_cgroup_swapon_13614 swap_cgroup_swapon 2 13614 NULL
104952 +wm8994_bulk_write_13615 wm8994_bulk_write 2-3 13615 NULL
104953 +pmcraid_get_minor_13619 pmcraid_get_minor 0 13619 NULL
104954 +packet_snd_13634 packet_snd 3 13634 NULL
104955 +blk_msg_write_13655 blk_msg_write 3 13655 NULL
104956 +cache_downcall_13666 cache_downcall 3 13666 NULL
104957 +ext3_xattr_list_entries_13682 ext3_xattr_list_entries 0-4 13682 NULL
104958 +nv94_aux_13689 nv94_aux 2-5 13689 NULL
104959 +usb_get_string_13693 usb_get_string 0 13693 NULL
104960 +atomic_cmpxchg_13700 atomic_cmpxchg 0 13700 NULL
104961 +fw_iso_buffer_alloc_13704 fw_iso_buffer_alloc 2 13704 NULL
104962 +ocfs2_cache_block_dealloc_13731 ocfs2_cache_block_dealloc 0 13731 NULL
104963 +netdev_queue_numa_node_read_13732 netdev_queue_numa_node_read 0 13732 NULL
104964 +audit_unpack_string_13748 audit_unpack_string 3 13748 NULL
104965 +ufs_dtog_13750 ufs_dtog 0-2 13750 NULL
104966 +ieee802154_alloc_device_13767 ieee802154_alloc_device 1 13767 NULL
104967 +fb_sys_read_13778 fb_sys_read 3 13778 NULL
104968 +ath6kl_mgmt_powersave_ap_13791 ath6kl_mgmt_powersave_ap 6 13791 NULL
104969 +random_read_13815 random_read 3 13815 NULL
104970 +mutex_lock_interruptible_nested_13817 mutex_lock_interruptible_nested 0 13817 NULL
104971 +hsi_register_board_info_13820 hsi_register_board_info 2 13820 NULL
104972 +___mei_cl_send_13821 ___mei_cl_send 3 13821 NULL
104973 +enc_pools_insert_13849 enc_pools_insert 3 13849 NULL
104974 +evdev_ioctl_compat_13851 evdev_ioctl_compat 2 13851 NULL
104975 +compat_ip_setsockopt_13870 compat_ip_setsockopt 5 13870 NULL
104976 +btrfs_insert_empty_item_13885 btrfs_insert_empty_item 0 13885 NULL
104977 +qp_memcpy_to_queue_13886 qp_memcpy_to_queue 5-2 13886 NULL nohasharray
104978 +__fsnotify_parent_13886 __fsnotify_parent 0 13886 &qp_memcpy_to_queue_13886
104979 +window_alignment_13895 window_alignment 0 13895 NULL
104980 +snd_pcm_aio_read_13900 snd_pcm_aio_read 3 13900 NULL
104981 +is_inode_existent_13913 is_inode_existent 0 13913 NULL
104982 +cfg80211_inform_bss_width_13933 cfg80211_inform_bss_width 9 13933 NULL
104983 +ext3_xattr_block_get_13936 ext3_xattr_block_get 0 13936 NULL
104984 +ieee80211_if_read_dot11MeshForwarding_13940 ieee80211_if_read_dot11MeshForwarding 3 13940 NULL nohasharray
104985 +ocfs2_xa_value_truncate_13940 ocfs2_xa_value_truncate 2 13940 &ieee80211_if_read_dot11MeshForwarding_13940
104986 +iwl_dbgfs_protection_mode_read_13943 iwl_dbgfs_protection_mode_read 3 13943 NULL
104987 +ieee80211_if_read_min_discovery_timeout_13946 ieee80211_if_read_min_discovery_timeout 3 13946 NULL
104988 +qib_mmap_mem_13947 qib_mmap_mem 3 13947 NULL
104989 +lpfc_idiag_queacc_read_13950 lpfc_idiag_queacc_read 3 13950 NULL
104990 +osc_grant_shrink_interval_seq_write_13952 osc_grant_shrink_interval_seq_write 3 13952 NULL
104991 +ocfs2_refresh_slot_info_13957 ocfs2_refresh_slot_info 0 13957 NULL
104992 +snd_pcm_plug_slave_size_13967 snd_pcm_plug_slave_size 0-2 13967 NULL
104993 +qcam_read_13977 qcam_read 3 13977 NULL
104994 +dsp_read_13980 dsp_read 2 13980 NULL
104995 +bm_block_bits_13981 bm_block_bits 0 13981 NULL nohasharray
104996 +dvb_demux_read_13981 dvb_demux_read 3 13981 &bm_block_bits_13981
104997 +create_files_14003 create_files 0 14003 NULL
104998 +sddr09_write_data_14014 sddr09_write_data 3 14014 NULL
104999 +btrfs_get_blocks_direct_14016 btrfs_get_blocks_direct 2 14016 NULL
105000 +dmi_format_ids_14018 dmi_format_ids 2 14018 NULL
105001 +iscsi_create_flashnode_conn_14022 iscsi_create_flashnode_conn 4 14022 NULL
105002 +dvb_usercopy_14036 dvb_usercopy 2 14036 NULL
105003 +read_def_modal_eeprom_14041 read_def_modal_eeprom 3 14041 NULL
105004 +ieee80211_if_fmt_aid_14055 ieee80211_if_fmt_aid 3 14055 NULL
105005 +sta_agg_status_read_14058 sta_agg_status_read 3 14058 NULL
105006 +ovs_flow_actions_alloc_14072 ovs_flow_actions_alloc 1 14072 NULL
105007 +lov_stripeoffset_seq_write_14078 lov_stripeoffset_seq_write 3 14078 NULL
105008 +do_proc_readlink_14096 do_proc_readlink 3 14096 NULL
105009 +compat_sys_pselect6_14105 compat_sys_pselect6 1 14105 NULL
105010 +intel_ring_wait_seqno_14107 intel_ring_wait_seqno 0 14107 NULL
105011 +ext4_journal_blocks_per_page_14127 ext4_journal_blocks_per_page 0 14127 NULL
105012 +ntfs_rl_replace_14136 ntfs_rl_replace 4-2 14136 NULL
105013 +qfq_ffs_14139 qfq_ffs 2 14139 NULL
105014 +isku_sysfs_read_light_14140 isku_sysfs_read_light 6 14140 NULL
105015 +em_canid_change_14150 em_canid_change 3 14150 NULL
105016 +gsm_dlci_data_14155 gsm_dlci_data 3 14155 NULL
105017 +print_input_mask_14168 print_input_mask 3-0 14168 NULL
105018 +ocfs2_split_and_insert_14171 ocfs2_split_and_insert 0 14171 NULL
105019 +ocfs2_xattr_value_truncate_14183 ocfs2_xattr_value_truncate 3 14183 NULL
105020 +datafab_read_data_14186 datafab_read_data 4 14186 NULL
105021 +do_splice_14196 do_splice 5 14196 NULL
105022 +hfsplus_brec_find_14200 hfsplus_brec_find 0 14200 NULL
105023 +alloc_async_14208 alloc_async 1 14208 NULL
105024 +ath6kl_regread_write_14220 ath6kl_regread_write 3 14220 NULL
105025 +ieee80211_if_write_uapsd_max_sp_len_14233 ieee80211_if_write_uapsd_max_sp_len 3 14233 NULL
105026 +dma_declare_coherent_memory_14244 dma_declare_coherent_memory 4 14244 NULL
105027 +snd_soc_hw_bulk_write_raw_14245 snd_soc_hw_bulk_write_raw 2-4 14245 NULL
105028 +ext4_journal_restart_14251 ext4_journal_restart 0 14251 NULL
105029 +will_overwrite_ref_14252 will_overwrite_ref 0 14252 NULL
105030 +ath6kl_connect_event_14267 ath6kl_connect_event 7-8-9 14267 NULL
105031 +numa_mem_id_14279 numa_mem_id 0 14279 NULL
105032 +rr_status_14293 rr_status 5 14293 NULL
105033 +read_default_ldt_14302 read_default_ldt 2 14302 NULL
105034 +__readl_14308 __readl 0 14308 NULL
105035 +send_chown_14309 send_chown 0 14309 NULL
105036 +i915_gem_object_finish_gpu_14312 i915_gem_object_finish_gpu 0 14312 NULL
105037 +oo_objects_14319 oo_objects 0 14319 NULL
105038 +ww_mutex_deadlock_injection_14321 ww_mutex_deadlock_injection 0 14321 NULL
105039 +ll_get_user_pages_14328 ll_get_user_pages 2-3-0 14328 NULL
105040 +down_write_failed_14331 down_write_failed 2 14331 NULL
105041 +p9_client_zc_rpc_14345 p9_client_zc_rpc 7 14345 NULL
105042 +alloc_tx_struct_14349 alloc_tx_struct 1 14349 NULL
105043 +snd_pcm_lib_readv_14363 snd_pcm_lib_readv 0-3 14363 NULL
105044 +btrfs_set_inode_index_14379 btrfs_set_inode_index 0 14379 NULL
105045 +acpi_get_override_irq_14381 acpi_get_override_irq 1 14381 NULL
105046 +ath6kl_regdump_read_14393 ath6kl_regdump_read 3 14393 NULL
105047 +smk_write_onlycap_14400 smk_write_onlycap 3 14400 NULL
105048 +first_logical_byte_14403 first_logical_byte 0 14403 NULL
105049 +mtd_concat_create_14416 mtd_concat_create 2 14416 NULL
105050 +get_kcore_size_14425 get_kcore_size 0 14425 NULL
105051 +qib_user_sdma_page_length_14432 qib_user_sdma_page_length 0-2-1 14432 NULL
105052 +check_lpt_crc_14442 check_lpt_crc 0 14442 NULL
105053 +block_size_14443 block_size 0 14443 NULL
105054 +lmv_user_md_size_14456 lmv_user_md_size 0-1 14456 NULL
105055 +snd_emu10k1_proc_spdif_status_14457 snd_emu10k1_proc_spdif_status 4-5 14457 NULL
105056 +lustre_msg_size_v2_14470 lustre_msg_size_v2 0 14470 NULL
105057 +dma_transfer_size_14473 dma_transfer_size 0 14473 NULL
105058 +udplite_getfrag_14479 udplite_getfrag 3-4 14479 NULL
105059 +efx_mdio_check_mmds_14486 efx_mdio_check_mmds 2 14486 NULL nohasharray
105060 +ieee80211_if_read_dot11MeshGateAnnouncementProtocol_14486 ieee80211_if_read_dot11MeshGateAnnouncementProtocol 3 14486 &efx_mdio_check_mmds_14486
105061 +ocfs2_debug_read_14507 ocfs2_debug_read 3 14507 NULL
105062 +dataflash_read_user_otp_14536 dataflash_read_user_otp 3-2 14536 NULL nohasharray
105063 +ep0_write_14536 ep0_write 3 14536 &dataflash_read_user_otp_14536
105064 +register_trace_sched_switch_14545 register_trace_sched_switch 0 14545 NULL
105065 +picolcd_debug_eeprom_read_14549 picolcd_debug_eeprom_read 3 14549 NULL
105066 +drm_vmalloc_dma_14550 drm_vmalloc_dma 1 14550 NULL
105067 +qp_host_alloc_queue_14566 qp_host_alloc_queue 1 14566 NULL
105068 +SyS_setdomainname_14569 SyS_setdomainname 2 14569 NULL
105069 +remap_to_origin_then_cache_14583 remap_to_origin_then_cache 3 14583 NULL
105070 +idmap_pipe_downcall_14591 idmap_pipe_downcall 3 14591 NULL
105071 +ceph_osdc_alloc_request_14597 ceph_osdc_alloc_request 3 14597 NULL
105072 +ocfs2_steal_meta_14602 ocfs2_steal_meta 0 14602 NULL
105073 +ocfs2_trim_group_14641 ocfs2_trim_group 4-3 14641 NULL
105074 +dbJoin_14644 dbJoin 0 14644 NULL
105075 +profile_replace_14652 profile_replace 3 14652 NULL
105076 +add_to_page_cache_locked_14668 add_to_page_cache_locked 0 14668 NULL
105077 +min_bytes_needed_14675 min_bytes_needed 0 14675 NULL
105078 +nvme_trans_log_info_exceptions_14677 nvme_trans_log_info_exceptions 3 14677 NULL
105079 +pipeline_enc_tx_stat_fifo_int_read_14680 pipeline_enc_tx_stat_fifo_int_read 3 14680 NULL
105080 +ieee80211_if_fmt_rc_rateidx_mask_2ghz_14683 ieee80211_if_fmt_rc_rateidx_mask_2ghz 3 14683 NULL
105081 +SyS_fsetxattr_14702 SyS_fsetxattr 4 14702 NULL
105082 +persistent_ram_ecc_string_14704 persistent_ram_ecc_string 0 14704 NULL
105083 +u_audio_playback_14709 u_audio_playback 3 14709 NULL
105084 +rtw_cbuf_alloc_14710 rtw_cbuf_alloc 1 14710 NULL
105085 +cgroup_path_14713 cgroup_path 3 14713 NULL
105086 +get_bio_block_14714 get_bio_block 0 14714 NULL
105087 +vfd_write_14717 vfd_write 3 14717 NULL
105088 +SyS_sendfile_14718 SyS_sendfile 4 14718 NULL
105089 +__blk_end_request_14729 __blk_end_request 3 14729 NULL
105090 +raid1_resize_14740 raid1_resize 2 14740 NULL
105091 +i915_error_state_buf_init_14742 i915_error_state_buf_init 2 14742 NULL
105092 +btrfs_inode_extref_name_len_14752 btrfs_inode_extref_name_len 0 14752 NULL
105093 +rx_rx_cmplt_read_14753 rx_rx_cmplt_read 3 14753 NULL
105094 +regmap_range_read_file_14775 regmap_range_read_file 3 14775 NULL
105095 +sta_dev_read_14782 sta_dev_read 3 14782 NULL
105096 +keys_proc_write_14792 keys_proc_write 3 14792 NULL
105097 +ext4_kvmalloc_14796 ext4_kvmalloc 1 14796 NULL
105098 +__kfifo_in_14797 __kfifo_in 3-0 14797 NULL
105099 +snd_als300_gcr_read_14801 snd_als300_gcr_read 0 14801 NULL nohasharray
105100 +hpet_readl_14801 hpet_readl 0 14801 &snd_als300_gcr_read_14801
105101 +changed_cb_14819 changed_cb 0 14819 NULL
105102 +do_tune_cpucache_14828 do_tune_cpucache 2 14828 NULL
105103 +mrp_attr_create_14853 mrp_attr_create 3 14853 NULL
105104 +lcd_write_14857 lcd_write 3 14857 NULL
105105 +get_user_cpu_mask_14861 get_user_cpu_mask 2 14861 NULL
105106 +gmux_index_read8_14890 gmux_index_read8 0 14890 NULL
105107 +acpi_os_allocate_14892 acpi_os_allocate 1 14892 NULL
105108 +SYSC_readv_14901 SYSC_readv 3 14901 NULL
105109 +regmap_irq_get_virq_14910 regmap_irq_get_virq 2-0 14910 NULL
105110 +__arch_hweight64_14923 __arch_hweight64 0 14923 NULL nohasharray
105111 +qp_memcpy_to_queue_iov_14923 qp_memcpy_to_queue_iov 5-2 14923 &__arch_hweight64_14923
105112 +ocfs2_expand_nonsparse_inode_14936 ocfs2_expand_nonsparse_inode 3-4 14936 NULL
105113 +range_to_mtrr_14940 range_to_mtrr 2 14940 NULL
105114 +queue_cnt_14951 queue_cnt 0 14951 NULL
105115 +unix_dgram_recvmsg_14952 unix_dgram_recvmsg 4 14952 NULL
105116 +i915_vma_unbind_14954 i915_vma_unbind 0 14954 NULL
105117 +videobuf_read_stream_14956 videobuf_read_stream 3 14956 NULL
105118 +mce_flush_rx_buffer_14976 mce_flush_rx_buffer 2 14976 NULL
105119 +setkey_14987 setkey 3 14987 NULL nohasharray
105120 +gpio_twl4030_write_14987 gpio_twl4030_write 1 14987 &setkey_14987
105121 +xfs_dinode_size_14996 xfs_dinode_size 0 14996 NULL
105122 +blk_integrity_tuple_size_15027 blk_integrity_tuple_size 0 15027 NULL
105123 +irq_get_next_irq_15053 irq_get_next_irq 1-0 15053 NULL
105124 +cld_pipe_downcall_15058 cld_pipe_downcall 3 15058 NULL
105125 +ieee80211_if_read_uapsd_max_sp_len_15067 ieee80211_if_read_uapsd_max_sp_len 3 15067 NULL
105126 +nfs4_write_cached_acl_15070 nfs4_write_cached_acl 4 15070 NULL
105127 +ntfs_copy_from_user_15072 ntfs_copy_from_user 3-5-0 15072 NULL
105128 +pppoe_recvmsg_15073 pppoe_recvmsg 4 15073 NULL
105129 +ceph_calc_ceph_pg_15075 ceph_calc_ceph_pg 0 15075 NULL
105130 +perf_trace_sched_stat_runtime_15115 perf_trace_sched_stat_runtime 3 15115 NULL
105131 +hex_dump_to_buffer_15121 hex_dump_to_buffer 6 15121 NULL
105132 +start_port_15124 start_port 0 15124 NULL
105133 +ipwireless_ppp_mru_15153 ipwireless_ppp_mru 0 15153 NULL
105134 +iwl_dbgfs_sta_drain_write_15167 iwl_dbgfs_sta_drain_write 3 15167 NULL
105135 +self_check_not_bad_15175 self_check_not_bad 0 15175 NULL
105136 +SYSC_setdomainname_15180 SYSC_setdomainname 2 15180 NULL
105137 +iscsi_create_endpoint_15193 iscsi_create_endpoint 1 15193 NULL
105138 +reserve_resources_15194 reserve_resources 3 15194 NULL
105139 +mtt_alloc_res_15211 mtt_alloc_res 5 15211 NULL
105140 +bfad_debugfs_write_regrd_15218 bfad_debugfs_write_regrd 3 15218 NULL
105141 +iwl_dbgfs_sram_write_15239 iwl_dbgfs_sram_write 3 15239 NULL
105142 +il_dbgfs_rx_stats_read_15243 il_dbgfs_rx_stats_read 3 15243 NULL
105143 +div64_u64_15263 div64_u64 0-1-2 15263 NULL
105144 +simple_strtol_15273 simple_strtol 0 15273 NULL
105145 +fw_realloc_buffer_15280 fw_realloc_buffer 2 15280 NULL
105146 +arch_enable_uv_irq_15294 arch_enable_uv_irq 2 15294 NULL
105147 +acpi_ev_create_gpe_block_15297 acpi_ev_create_gpe_block 5 15297 NULL
105148 +ocfs2_read_refcount_block_15305 ocfs2_read_refcount_block 0 15305 NULL
105149 +__ocfs2_remove_xattr_range_15330 __ocfs2_remove_xattr_range 4-3-5 15330 NULL
105150 +bfloat_mantissa_15334 bfloat_mantissa 0 15334 NULL
105151 +xlog_ticket_alloc_15335 xlog_ticket_alloc 2 15335 NULL
105152 +kovaplus_sysfs_read_15337 kovaplus_sysfs_read 6 15337 NULL
105153 +ioread16_15342 ioread16 0 15342 NULL
105154 +ept_prefetch_gpte_15348 ept_prefetch_gpte 4 15348 NULL
105155 +acpi_ut_create_string_object_15360 acpi_ut_create_string_object 1 15360 NULL
105156 +count_inode_extrefs_15366 count_inode_extrefs 0 15366 NULL
105157 +ext4_direct_IO_15369 ext4_direct_IO 4 15369 NULL
105158 +graph_depth_read_15371 graph_depth_read 3 15371 NULL
105159 +compat_sys_process_vm_readv_15374 compat_sys_process_vm_readv 3-5 15374 NULL
105160 +fq_codel_zalloc_15378 fq_codel_zalloc 1 15378 NULL
105161 +domain_flush_pages_15379 domain_flush_pages 2-3 15379 NULL
105162 +alloc_fddidev_15382 alloc_fddidev 1 15382 NULL
105163 +btrfs_level_size_15392 btrfs_level_size 0 15392 NULL
105164 +pipeline_csum_to_rx_xfer_swi_read_15403 pipeline_csum_to_rx_xfer_swi_read 3 15403 NULL
105165 +get_modalias_15406 get_modalias 2 15406 NULL
105166 +blockdev_direct_IO_15408 blockdev_direct_IO 0-5 15408 NULL
105167 +dm_cache_resize_15422 dm_cache_resize 2 15422 NULL
105168 +__videobuf_copy_to_user_15423 __videobuf_copy_to_user 4-0 15423 NULL
105169 +tcp_mtu_to_mss_15438 tcp_mtu_to_mss 2-0 15438 NULL
105170 +hpsa_change_queue_depth_15449 hpsa_change_queue_depth 2 15449 NULL
105171 +memweight_15450 memweight 2 15450 NULL
105172 +vmalloc_15464 vmalloc 1 15464 NULL
105173 +__mutex_lock_killable_slowpath_15472 __mutex_lock_killable_slowpath 0 15472 NULL
105174 +insert_old_idx_znode_15500 insert_old_idx_znode 0 15500 NULL
105175 +zd_chip_is_zd1211b_15518 zd_chip_is_zd1211b 0 15518 NULL
105176 +ifx_spi_write_15531 ifx_spi_write 3 15531 NULL
105177 +da9052_bat_irq_15533 da9052_bat_irq 1 15533 NULL
105178 +p9_check_zc_errors_15534 p9_check_zc_errors 4 15534 NULL
105179 +xfrm_state_mtu_15548 xfrm_state_mtu 0-2 15548 NULL
105180 +snd_pcm_channel_info_15572 snd_pcm_channel_info 0 15572 NULL
105181 +persistent_status_15574 persistent_status 4 15574 NULL
105182 +bnx2fc_process_unsol_compl_15576 bnx2fc_process_unsol_compl 2 15576 NULL
105183 +cl_io_submit_sync_15579 cl_io_submit_sync 0 15579 NULL
105184 +vme_user_write_15587 vme_user_write 3 15587 NULL
105185 +ocfs2_truncate_rec_15595 ocfs2_truncate_rec 7-0 15595 NULL
105186 +sx150x_install_irq_chip_15609 sx150x_install_irq_chip 3 15609 NULL
105187 +iommu_device_max_index_15620 iommu_device_max_index 0-3-2-1 15620 NULL nohasharray
105188 +compat_fillonedir_15620 compat_fillonedir 3 15620 &iommu_device_max_index_15620
105189 +proc_loginuid_read_15631 proc_loginuid_read 3 15631 NULL
105190 +tomoyo_scan_bprm_15642 tomoyo_scan_bprm 4-2 15642 NULL nohasharray
105191 +sk_memory_allocated_add_15642 sk_memory_allocated_add 2 15642 &tomoyo_scan_bprm_15642 nohasharray
105192 +pipeline_hs_tx_stat_fifo_int_read_15642 pipeline_hs_tx_stat_fifo_int_read 3 15642 &sk_memory_allocated_add_15642
105193 +joydev_handle_JSIOCSBTNMAP_15643 joydev_handle_JSIOCSBTNMAP 3 15643 NULL
105194 +fs_path_add_15648 fs_path_add 3-0 15648 NULL
105195 +xsd_read_15653 xsd_read 3 15653 NULL
105196 +unix_bind_15668 unix_bind 3 15668 NULL
105197 +SyS_connect_15674 SyS_connect 3 15674 NULL nohasharray
105198 +dm_read_15674 dm_read 3 15674 &SyS_connect_15674
105199 +pstore_mkfile_15675 pstore_mkfile 6 15675 NULL
105200 +i915_gem_object_set_to_cpu_domain_15705 i915_gem_object_set_to_cpu_domain 0 15705 NULL nohasharray
105201 +uncore_alloc_box_15705 uncore_alloc_box 2 15705 &i915_gem_object_set_to_cpu_domain_15705
105202 +ocfs2_split_tree_15716 ocfs2_split_tree 5-0 15716 NULL
105203 +tracing_snapshot_write_15719 tracing_snapshot_write 3 15719 NULL
105204 +HiSax_readstatus_15752 HiSax_readstatus 2 15752 NULL
105205 +ftrace_profile_init_cpu_15761 ftrace_profile_init_cpu 0 15761 NULL
105206 +bitmap_search_next_usable_block_15762 bitmap_search_next_usable_block 3-1-0 15762 NULL
105207 +i915_gem_init_seqno_15793 i915_gem_init_seqno 0 15793 NULL
105208 +smk_read_direct_15803 smk_read_direct 3 15803 NULL
105209 +nameseq_list_15817 nameseq_list 3-0 15817 NULL nohasharray
105210 +gnttab_expand_15817 gnttab_expand 1 15817 &nameseq_list_15817
105211 +afs_proc_rootcell_write_15822 afs_proc_rootcell_write 3 15822 NULL
105212 +brcmf_sdbrcm_died_dump_15841 brcmf_sdbrcm_died_dump 3 15841 NULL
105213 +table_size_15851 table_size 0-1-2 15851 NULL
105214 +ubi_io_write_15870 ubi_io_write 0-5-4 15870 NULL nohasharray
105215 +media_entity_init_15870 media_entity_init 2-4 15870 &ubi_io_write_15870
105216 +__mptctl_ioctl_15875 __mptctl_ioctl 2 15875 NULL
105217 +profile_pc_15887 profile_pc 0 15887 NULL
105218 +nfs_map_group_to_gid_15892 nfs_map_group_to_gid 3 15892 NULL
105219 +native_read_msr_15905 native_read_msr 0 15905 NULL
105220 +parse_audio_stream_data_15937 parse_audio_stream_data 3 15937 NULL
105221 +power_read_15939 power_read 3 15939 NULL
105222 +lpfc_idiag_drbacc_read_15948 lpfc_idiag_drbacc_read 3 15948 NULL
105223 +snd_pcm_lib_read_transfer_15952 snd_pcm_lib_read_transfer 5-2-4 15952 NULL
105224 +tfrc_calc_x_15975 tfrc_calc_x 2-1 15975 NULL
105225 +frame_alloc_15981 frame_alloc 4 15981 NULL
105226 +hdpvr_register_videodev_16010 hdpvr_register_videodev 3 16010 NULL
105227 +viafb_vt1636_proc_write_16018 viafb_vt1636_proc_write 3 16018 NULL
105228 +i915_gem_object_pin_16032 i915_gem_object_pin 0 16032 NULL
105229 +dccp_recvmsg_16056 dccp_recvmsg 4 16056 NULL
105230 +read_file_spectral_period_16057 read_file_spectral_period 3 16057 NULL
105231 +si5351_msynth_params_address_16062 si5351_msynth_params_address 0-1 16062 NULL
105232 +ocfs2_sync_local_to_main_16076 ocfs2_sync_local_to_main 0 16076 NULL
105233 +isr_tx_exch_complete_read_16103 isr_tx_exch_complete_read 3 16103 NULL
105234 +dma_tx_requested_read_16110 dma_tx_requested_read 3 16110 NULL nohasharray
105235 +isr_hw_pm_mode_changes_read_16110 isr_hw_pm_mode_changes_read 3 16110 &dma_tx_requested_read_16110
105236 +irq_set_chip_and_handler_name_16111 irq_set_chip_and_handler_name 1 16111 NULL
105237 +snd_dma_pointer_16126 snd_dma_pointer 0-2 16126 NULL
105238 +compat_sys_select_16131 compat_sys_select 1 16131 NULL
105239 +fsm_init_16134 fsm_init 2 16134 NULL
105240 +ext4_xattr_block_get_16148 ext4_xattr_block_get 0 16148 NULL
105241 +update_block_group_16155 update_block_group 0 16155 NULL
105242 +optimal_reclaimed_pages_16172 optimal_reclaimed_pages 0 16172 NULL
105243 +mapping_level_16188 mapping_level 2-0 16188 NULL
105244 +i40e_allocate_virt_mem_d_16191 i40e_allocate_virt_mem_d 3 16191 NULL
105245 +tcp_syn_options_16197 tcp_syn_options 0 16197 NULL
105246 +ath10k_htt_rx_ring_size_16201 ath10k_htt_rx_ring_size 0 16201 NULL
105247 +cipso_v4_map_cat_rng_hton_16203 cipso_v4_map_cat_rng_hton 0 16203 NULL
105248 +SyS_pselect6_16210 SyS_pselect6 1 16210 NULL
105249 +create_table_16213 create_table 2 16213 NULL
105250 +atomic_read_file_16227 atomic_read_file 3 16227 NULL
105251 +BcmGetSectionValStartOffset_16235 BcmGetSectionValStartOffset 0 16235 NULL
105252 +lov_prep_brw_set_16246 lov_prep_brw_set 3 16246 NULL
105253 +i40e_dbg_dump_read_16247 i40e_dbg_dump_read 3 16247 NULL nohasharray
105254 +btrfs_dev_extent_chunk_offset_16247 btrfs_dev_extent_chunk_offset 0 16247 &i40e_dbg_dump_read_16247
105255 +il_dbgfs_disable_ht40_write_16249 il_dbgfs_disable_ht40_write 3 16249 NULL
105256 +SyS_fgetxattr_16254 SyS_fgetxattr 4 16254 NULL
105257 +reiserfs_acl_count_16265 reiserfs_acl_count 0-1 16265 NULL
105258 +mq_force_mapping_16277 mq_force_mapping 2 16277 NULL
105259 +ocfs2_xattr_bucket_value_truncate_16279 ocfs2_xattr_bucket_value_truncate 4 16279 NULL
105260 +drbd_setsockopt_16280 drbd_setsockopt 5 16280 NULL nohasharray
105261 +nand_bch_init_16280 nand_bch_init 2-3 16280 &drbd_setsockopt_16280
105262 +account_16283 account 0-4-2 16283 NULL nohasharray
105263 +mirror_status_16283 mirror_status 5 16283 &account_16283
105264 +retry_instruction_16285 retry_instruction 2 16285 NULL
105265 +jumpshot_read_data_16287 jumpshot_read_data 4 16287 NULL
105266 +mo_xattr_get_16288 mo_xattr_get 0 16288 NULL
105267 +stk_allocate_buffers_16291 stk_allocate_buffers 2 16291 NULL
105268 +rbd_segment_offset_16293 rbd_segment_offset 0-2 16293 NULL
105269 +tfrc_invert_loss_event_rate_16295 tfrc_invert_loss_event_rate 1 16295 NULL
105270 +rsc_mgr_init_16299 rsc_mgr_init 3 16299 NULL
105271 +wb_map_16301 wb_map 2 16301 NULL
105272 +kvm_handle_hva_range_16312 kvm_handle_hva_range 3-2 16312 NULL
105273 +ext4_blocks_count_16320 ext4_blocks_count 0 16320 NULL
105274 +vmw_cursor_update_image_16332 vmw_cursor_update_image 3-4 16332 NULL
105275 +btrfs_insert_item_16357 btrfs_insert_item 0 16357 NULL
105276 +sysfs_create_groups_16360 sysfs_create_groups 0 16360 NULL
105277 +total_ps_buffered_read_16365 total_ps_buffered_read 3 16365 NULL
105278 +iscsi_tcp_conn_setup_16376 iscsi_tcp_conn_setup 2 16376 NULL
105279 +diva_os_malloc_16406 diva_os_malloc 2 16406 NULL
105280 +ieee80211_if_read_tsf_16420 ieee80211_if_read_tsf 3 16420 NULL
105281 +rxrpc_server_keyring_16431 rxrpc_server_keyring 3 16431 NULL
105282 +__bio_add_page_16435 __bio_add_page 0-4 16435 NULL
105283 +btrfs_truncate_inode_items_16452 btrfs_truncate_inode_items 0-4 16452 NULL
105284 +ocfs2_expand_refcount_tree_16455 ocfs2_expand_refcount_tree 0 16455 NULL
105285 +netlink_change_ngroups_16457 netlink_change_ngroups 2 16457 NULL
105286 +alloc_disk_node_16458 alloc_disk_node 2 16458 NULL
105287 +req_capsule_get_size_16467 req_capsule_get_size 0 16467 NULL
105288 +ocfs2_block_group_set_bits_16488 ocfs2_block_group_set_bits 0 16488 NULL
105289 +add_qgroup_item_16492 add_qgroup_item 0 16492 NULL
105290 +tracing_readme_read_16493 tracing_readme_read 3 16493 NULL
105291 +filemap_write_and_wait_16506 filemap_write_and_wait 0 16506 NULL
105292 +start_this_handle_16519 start_this_handle 0 16519 NULL
105293 +snd_interval_max_16529 snd_interval_max 0 16529 NULL
105294 +raid10_resize_16537 raid10_resize 2 16537 NULL
105295 +lpfc_debugfs_read_16566 lpfc_debugfs_read 3 16566 NULL
105296 +perf_event_set_period_16574 perf_event_set_period 2-3 16574 NULL
105297 +agp_allocate_memory_wrap_16576 agp_allocate_memory_wrap 1 16576 NULL
105298 +lustre_msg_hdr_size_v2_16589 lustre_msg_hdr_size_v2 0 16589 NULL
105299 +btrfs_insert_orphan_item_16602 btrfs_insert_orphan_item 0 16602 NULL
105300 +gmux_index_read32_16604 gmux_index_read32 0 16604 NULL
105301 +btrfs_end_transaction_16610 btrfs_end_transaction 0 16610 NULL
105302 +palmas_irq_get_virq_16613 palmas_irq_get_virq 2 16613 NULL
105303 +btrfs_wait_marked_extents_16615 btrfs_wait_marked_extents 0 16615 NULL
105304 +rtw_set_wpa_ie_16633 rtw_set_wpa_ie 3 16633 NULL
105305 +btrfs_get_token_32_16651 btrfs_get_token_32 0 16651 NULL
105306 +packet_recv_error_16669 packet_recv_error 3 16669 NULL
105307 +__proc_lnet_buffers_16717 __proc_lnet_buffers 5 16717 NULL
105308 +__copy_to_user_swizzled_16748 __copy_to_user_swizzled 3-4 16748 NULL
105309 +arcmsr_adjust_disk_queue_depth_16756 arcmsr_adjust_disk_queue_depth 2 16756 NULL
105310 +blk_rq_map_user_iov_16772 blk_rq_map_user_iov 5 16772 NULL
105311 +i2o_parm_issue_16790 i2o_parm_issue 0 16790 NULL
105312 +get_server_iovec_16804 get_server_iovec 2 16804 NULL
105313 +tipc_send2name_16809 tipc_send2name 6 16809 NULL
105314 +dm_vcalloc_16814 dm_vcalloc 1-2 16814 NULL
105315 +cache_grow_16818 cache_grow 3 16818 NULL
105316 +drm_malloc_ab_16831 drm_malloc_ab 1-2 16831 NULL
105317 +scsi_mode_sense_16835 scsi_mode_sense 5 16835 NULL
105318 +hfsplus_min_io_size_16859 hfsplus_min_io_size 0 16859 NULL
105319 +alloc_idx_lebs_16872 alloc_idx_lebs 2 16872 NULL
105320 +carl9170_debugfs_ampdu_state_read_16873 carl9170_debugfs_ampdu_state_read 3 16873 NULL
105321 +st_write_16874 st_write 3 16874 NULL
105322 +__kfifo_peek_n_16877 __kfifo_peek_n 0 16877 NULL
105323 +transport_init_session_tags_16878 transport_init_session_tags 1-2 16878 NULL
105324 +ext4_ext_zeroout_16895 ext4_ext_zeroout 0 16895 NULL
105325 +psb_unlocked_ioctl_16926 psb_unlocked_ioctl 2 16926 NULL nohasharray
105326 +snd_gf1_mem_proc_dump_16926 snd_gf1_mem_proc_dump 5 16926 &psb_unlocked_ioctl_16926
105327 +_sp2d_alloc_16944 _sp2d_alloc 3-2-1 16944 NULL
105328 +squashfs_read_table_16945 squashfs_read_table 3 16945 NULL
105329 +wrm_16966 wrm 0 16966 NULL
105330 +keyctl_instantiate_key_iov_16969 keyctl_instantiate_key_iov 3 16969 NULL
105331 +ocfs2_read_quota_phys_block_16990 ocfs2_read_quota_phys_block 0 16990 NULL
105332 +ceph_read_dir_17005 ceph_read_dir 3 17005 NULL
105333 +snd_mask_refine_first_17026 snd_mask_refine_first 0 17026 NULL
105334 +copy_counters_to_user_17027 copy_counters_to_user 5 17027 NULL
105335 +btrfs_unlink_inode_17043 btrfs_unlink_inode 0 17043 NULL
105336 +jffs2_trusted_setxattr_17048 jffs2_trusted_setxattr 4 17048 NULL
105337 +__arch_hweight32_17060 __arch_hweight32 0 17060 NULL
105338 +__copy_user_nocache_17065 __copy_user_nocache 0 17065 NULL
105339 +sddr55_read_data_17072 sddr55_read_data 4 17072 NULL
105340 +dvb_dvr_read_17073 dvb_dvr_read 3 17073 NULL
105341 +simple_transaction_read_17076 simple_transaction_read 3 17076 NULL
105342 +__kmalloc_reserve_17080 __kmalloc_reserve 3 17080 NULL
105343 +carl9170_debugfs_mem_usage_read_17084 carl9170_debugfs_mem_usage_read 3 17084 NULL
105344 +entry_length_17093 entry_length 0 17093 NULL
105345 +ocfs2_get_refcount_cpos_end_17113 ocfs2_get_refcount_cpos_end 0 17113 NULL
105346 +write_mem_17114 write_mem 3 17114 NULL
105347 +pvr2_hdw_state_report_17121 pvr2_hdw_state_report 3 17121 NULL
105348 +wrmaltWithLock_17139 wrmaltWithLock 0 17139 NULL
105349 +nouveau_instobj_create__17144 nouveau_instobj_create_ 4 17144 NULL
105350 +jumpshot_write_data_17151 jumpshot_write_data 4 17151 NULL
105351 +sep_read_17161 sep_read 3 17161 NULL
105352 +befs_nls2utf_17163 befs_nls2utf 3 17163 NULL
105353 +tx_tx_start_templates_read_17164 tx_tx_start_templates_read 3 17164 NULL
105354 +UniStrnlen_17169 UniStrnlen 0 17169 NULL
105355 +ocfs2_flock_handle_signal_17189 ocfs2_flock_handle_signal 0 17189 NULL nohasharray
105356 +access_remote_vm_17189 access_remote_vm 0-4-2 17189 &ocfs2_flock_handle_signal_17189 nohasharray
105357 +iwl_dbgfs_txfifo_flush_write_17189 iwl_dbgfs_txfifo_flush_write 3 17189 &access_remote_vm_17189
105358 +driver_state_read_17194 driver_state_read 3 17194 NULL nohasharray
105359 +iscsit_find_cmd_from_itt_or_dump_17194 iscsit_find_cmd_from_itt_or_dump 3 17194 &driver_state_read_17194
105360 +sync_request_17208 sync_request 2 17208 NULL
105361 +dn_recvmsg_17213 dn_recvmsg 4 17213 NULL
105362 +send_write_or_clone_17241 send_write_or_clone 0 17241 NULL
105363 +to_oblock_17254 to_oblock 0-1 17254 NULL
105364 +unpack_value_17259 unpack_value 1 17259 NULL
105365 +lprocfs_read_frac_helper_17261 lprocfs_read_frac_helper 0 17261 NULL
105366 +error_error_frame_cts_nul_flid_read_17262 error_error_frame_cts_nul_flid_read 3 17262 NULL
105367 +alloc_reserved_file_extent_17267 alloc_reserved_file_extent 0 17267 NULL
105368 +alloc_ep_17269 alloc_ep 1 17269 NULL
105369 +hw_test_and_write_17271 hw_test_and_write 3 17271 NULL
105370 +pg_read_17276 pg_read 3 17276 NULL
105371 +raw_recvmsg_17277 raw_recvmsg 4 17277 NULL
105372 +hmac_sha256_17278 hmac_sha256 2 17278 NULL
105373 +neigh_hash_grow_17283 neigh_hash_grow 2 17283 NULL
105374 +minstrel_stats_read_17290 minstrel_stats_read 3 17290 NULL
105375 +install_breakpoint_17292 install_breakpoint 4 17292 NULL
105376 +ieee80211_if_fmt_dot11MeshForwarding_17301 ieee80211_if_fmt_dot11MeshForwarding 3 17301 NULL
105377 +mb_cache_create_17307 mb_cache_create 2 17307 NULL
105378 +gnttab_map_frames_v2_17314 gnttab_map_frames_v2 2 17314 NULL
105379 +SYSC_pread64_17337 SYSC_pread64 3 17337 NULL
105380 +ieee80211_if_read_dot11MeshHWMPperrMinInterval_17346 ieee80211_if_read_dot11MeshHWMPperrMinInterval 3 17346 NULL
105381 +ath6kl_wmi_send_mgmt_cmd_17347 ath6kl_wmi_send_mgmt_cmd 7 17347 NULL
105382 +mdc_import_seq_write_17409 mdc_import_seq_write 3 17409 NULL
105383 +lpfc_debugfs_dif_err_write_17424 lpfc_debugfs_dif_err_write 3 17424 NULL
105384 +compat_sys_ppoll_17430 compat_sys_ppoll 2 17430 NULL
105385 +sta_connected_time_read_17435 sta_connected_time_read 3 17435 NULL
105386 +SYSC_fcntl_17441 SYSC_fcntl 3 17441 NULL
105387 +libcfs_ipif_enumerate_17445 libcfs_ipif_enumerate 0 17445 NULL
105388 +nla_get_u32_17455 nla_get_u32 0 17455 NULL
105389 +__ref_totlen_17461 __ref_totlen 0 17461 NULL
105390 +probe_kernel_write_17481 probe_kernel_write 3 17481 NULL
105391 +TSS_rawhmac_17486 TSS_rawhmac 3 17486 NULL
105392 +lookup_tree_block_ref_17494 lookup_tree_block_ref 0 17494 NULL
105393 +bitmap_pos_to_ord_17503 bitmap_pos_to_ord 3 17503 NULL
105394 +lbs_highrssi_write_17515 lbs_highrssi_write 3 17515 NULL
105395 +qp_free_res_17541 qp_free_res 5 17541 NULL
105396 +xlog_do_log_recovery_17550 xlog_do_log_recovery 3 17550 NULL
105397 +__copy_to_user_17551 __copy_to_user 3-0 17551 NULL
105398 +copy_from_user_17559 copy_from_user 3-0 17559 NULL
105399 +snd_pcm_action_lock_irq_17569 snd_pcm_action_lock_irq 0 17569 NULL
105400 +acpi_ut_create_package_object_17594 acpi_ut_create_package_object 1 17594 NULL
105401 +neigh_hash_alloc_17595 neigh_hash_alloc 1 17595 NULL
105402 +__inode_info_17603 __inode_info 0 17603 NULL
105403 +wm8994_gpio_to_irq_17604 wm8994_gpio_to_irq 2 17604 NULL
105404 +osst_execute_17607 osst_execute 7-6 17607 NULL
105405 +ocfs2_mark_extent_written_17615 ocfs2_mark_extent_written 6 17615 NULL
105406 +ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout_17618 ieee80211_if_read_dot11MeshHWMPactivePathToRootTimeout 3 17618 NULL
105407 +dma_map_page_17628 dma_map_page 0 17628 NULL
105408 +ocfs2_rotate_subtree_left_17634 ocfs2_rotate_subtree_left 0 17634 NULL
105409 +twl4030_set_gpio_direction_17645 twl4030_set_gpio_direction 1 17645 NULL
105410 +SYSC_migrate_pages_17657 SYSC_migrate_pages 2 17657 NULL
105411 +packet_setsockopt_17662 packet_setsockopt 5 17662 NULL nohasharray
105412 +ubi_io_read_data_17662 ubi_io_read_data 0 17662 &packet_setsockopt_17662
105413 +kernel_write_17665 kernel_write 3 17665 NULL
105414 +pwr_enable_ps_read_17686 pwr_enable_ps_read 3 17686 NULL
105415 +filemap_fdatawait_17688 filemap_fdatawait 0 17688 NULL
105416 +gfn_to_pfn_memslot_17693 gfn_to_pfn_memslot 2-0 17693 NULL
105417 +__einj_error_trigger_17707 __einj_error_trigger 0 17707 NULL nohasharray
105418 +venus_rename_17707 venus_rename 4-5 17707 &__einj_error_trigger_17707
105419 +exofs_read_lookup_dev_table_17733 exofs_read_lookup_dev_table 3 17733 NULL
105420 +sctpprobe_read_17741 sctpprobe_read 3 17741 NULL
105421 +mark_unsafe_pages_17759 mark_unsafe_pages 0 17759 NULL
105422 +dgap_do_fep_load_17765 dgap_do_fep_load 3 17765 NULL
105423 +dtf_read_run_17768 dtf_read_run 3 17768 NULL
105424 +brcmf_sdio_chip_verifynvram_17776 brcmf_sdio_chip_verifynvram 4 17776 NULL
105425 +hash_ipport6_expire_17784 hash_ipport6_expire 3 17784 NULL
105426 +perf_clock_17787 perf_clock 0 17787 NULL
105427 +ubifs_leb_change_17789 ubifs_leb_change 0-4 17789 NULL
105428 +get_unaligned_be64_17794 get_unaligned_be64 0 17794 NULL nohasharray
105429 +shrink_slab_node_17794 shrink_slab_node 3-4 17794 &get_unaligned_be64_17794
105430 +bkey_to_cacheline_17811 bkey_to_cacheline 0 17811 NULL
105431 +_snd_pcm_lib_alloc_vmalloc_buffer_17820 _snd_pcm_lib_alloc_vmalloc_buffer 2 17820 NULL
105432 +gnet_stats_copy_app_17821 gnet_stats_copy_app 3 17821 NULL
105433 +cipso_v4_gentag_rbm_17836 cipso_v4_gentag_rbm 0 17836 NULL
105434 +dm_stats_message_17863 dm_stats_message 5 17863 NULL
105435 +sisusb_send_bulk_msg_17864 sisusb_send_bulk_msg 3 17864 NULL
105436 +alloc_sja1000dev_17868 alloc_sja1000dev 1 17868 NULL
105437 +ray_cs_essid_proc_write_17875 ray_cs_essid_proc_write 3 17875 NULL
105438 +orinoco_set_key_17878 orinoco_set_key 7-5 17878 NULL nohasharray
105439 +i40e_align_l2obj_base_17878 i40e_align_l2obj_base 0-1 17878 &orinoco_set_key_17878
105440 +init_per_cpu_17880 init_per_cpu 1 17880 NULL
105441 +ieee80211_if_fmt_dot11MeshMaxPeerLinks_17883 ieee80211_if_fmt_dot11MeshMaxPeerLinks 3 17883 NULL
105442 +ieee80211_if_fmt_dot11MeshHWMPRootMode_17890 ieee80211_if_fmt_dot11MeshHWMPRootMode 3 17890 NULL
105443 +ocfs2_clusters_to_blocks_17896 ocfs2_clusters_to_blocks 0-2 17896 NULL
105444 +recover_head_17904 recover_head 3 17904 NULL
105445 +xfs_buf_associate_memory_17915 xfs_buf_associate_memory 3 17915 NULL
105446 +scsi_bufflen_17933 scsi_bufflen 0 17933 NULL
105447 +__mutex_lock_check_stamp_17947 __mutex_lock_check_stamp 0 17947 NULL
105448 +beacon_interval_write_17952 beacon_interval_write 3 17952 NULL
105449 +ufs_free_blocks_17963 ufs_free_blocks 3-2 17963 NULL nohasharray
105450 +tlv_put_u64_17963 tlv_put_u64 0 17963 &ufs_free_blocks_17963
105451 +calc_nr_buckets_17976 calc_nr_buckets 0 17976 NULL
105452 +ext4_ext_calc_credits_for_single_extent_17983 ext4_ext_calc_credits_for_single_extent 0-2 17983 NULL
105453 +smk_write_cipso_17989 smk_write_cipso 3 17989 NULL
105454 +gnttab_max_grant_frames_17993 gnttab_max_grant_frames 0 17993 NULL
105455 +ext4_num_overhead_clusters_18001 ext4_num_overhead_clusters 2 18001 NULL
105456 +pvr2_v4l2_read_18006 pvr2_v4l2_read 3 18006 NULL
105457 +alloc_rx_desc_ring_18016 alloc_rx_desc_ring 2 18016 NULL
105458 +fill_read_18019 fill_read 0 18019 NULL
105459 +o2hb_highest_node_18034 o2hb_highest_node 2-0 18034 NULL
105460 +__posix_lock_file_18035 __posix_lock_file 0 18035 NULL
105461 +ocfs2_cache_cluster_dealloc_18043 ocfs2_cache_cluster_dealloc 0 18043 NULL
105462 +cryptd_alloc_instance_18048 cryptd_alloc_instance 3-2 18048 NULL
105463 +find_next_inuse_18051 find_next_inuse 2-3-0 18051 NULL
105464 +ddebug_proc_write_18055 ddebug_proc_write 3 18055 NULL
105465 +lua_sysfs_read_18062 lua_sysfs_read 6 18062 NULL
105466 +fpregs_get_18066 fpregs_get 4 18066 NULL
105467 +kvm_read_guest_page_18074 kvm_read_guest_page 5-2 18074 NULL
105468 +SYSC_pselect6_18076 SYSC_pselect6 1 18076 NULL
105469 +SYSC_semtimedop_18091 SYSC_semtimedop 3 18091 NULL
105470 +mpi_alloc_18094 mpi_alloc 1 18094 NULL
105471 +hfs_direct_IO_18104 hfs_direct_IO 4 18104 NULL
105472 +dfs_file_read_18116 dfs_file_read 3 18116 NULL
105473 +svc_getnl_18120 svc_getnl 0 18120 NULL
105474 +paging32_gpte_to_gfn_lvl_18131 paging32_gpte_to_gfn_lvl 0-2-1 18131 NULL
105475 +vmw_surface_dma_size_18132 vmw_surface_dma_size 0 18132 NULL
105476 +selinux_inode_setsecurity_18148 selinux_inode_setsecurity 4 18148 NULL
105477 +is_idx_node_in_use_18165 is_idx_node_in_use 0 18165 NULL
105478 +pccard_store_cis_18176 pccard_store_cis 6 18176 NULL
105479 +snd_pcm_hw_refine_user_18204 snd_pcm_hw_refine_user 0 18204 NULL
105480 +orinoco_add_extscan_result_18207 orinoco_add_extscan_result 3 18207 NULL
105481 +gsm_control_message_18209 gsm_control_message 4 18209 NULL
105482 +ocfs2_divide_leaf_refcount_block_18214 ocfs2_divide_leaf_refcount_block 0 18214 NULL
105483 +do_ipv6_setsockopt_18215 do_ipv6_setsockopt 5 18215 NULL
105484 +gnttab_alloc_grant_references_18240 gnttab_alloc_grant_references 1 18240 NULL
105485 +alloc_trace_uprobe_18247 alloc_trace_uprobe 3 18247 NULL
105486 +rfcomm_sock_setsockopt_18254 rfcomm_sock_setsockopt 5 18254 NULL
105487 +__sysfs_add_one_18258 __sysfs_add_one 0 18258 NULL
105488 +qdisc_class_hash_alloc_18262 qdisc_class_hash_alloc 1 18262 NULL
105489 +gfs2_alloc_sort_buffer_18275 gfs2_alloc_sort_buffer 1 18275 NULL
105490 +alloc_ring_18278 alloc_ring 4-2-8 18278 NULL
105491 +find_dirty_idx_leb_18280 find_dirty_idx_leb 0 18280 NULL
105492 +nouveau_subdev_create__18281 nouveau_subdev_create_ 7 18281 NULL nohasharray
105493 +bio_phys_segments_18281 bio_phys_segments 0 18281 &nouveau_subdev_create__18281
105494 +ext4_readpages_18283 ext4_readpages 4 18283 NULL
105495 +mmc_send_bus_test_18285 mmc_send_bus_test 4 18285 NULL
105496 +um_idi_write_18293 um_idi_write 3 18293 NULL
105497 +nouveau_disp_create__18305 nouveau_disp_create_ 4-7 18305 NULL
105498 +vga_r_18310 vga_r 0 18310 NULL
105499 +class_add_profile_18315 class_add_profile 1-3-5 18315 NULL
105500 +csio_mem_read_18319 csio_mem_read 3 18319 NULL
105501 +alloc_and_copy_string_18321 alloc_and_copy_string 2 18321 NULL
105502 +ecryptfs_send_message_18322 ecryptfs_send_message 2 18322 NULL
105503 +bio_integrity_advance_18324 bio_integrity_advance 2 18324 NULL
105504 +__inorder_to_tree_18329 __inorder_to_tree 0-3-1 18329 NULL
105505 +lcd_proc_write_18351 lcd_proc_write 3 18351 NULL
105506 +pwr_power_save_off_read_18355 pwr_power_save_off_read 3 18355 NULL
105507 +xlbd_reserve_minors_18365 xlbd_reserve_minors 1-2 18365 NULL
105508 +SyS_process_vm_readv_18366 SyS_process_vm_readv 5-3 18366 NULL
105509 +ep_io_18367 ep_io 0 18367 NULL
105510 +qib_user_sdma_num_pages_18371 qib_user_sdma_num_pages 0 18371 NULL
105511 +ci_role_write_18388 ci_role_write 3 18388 NULL nohasharray
105512 +irq_find_mapping_18388 irq_find_mapping 0-2 18388 &ci_role_write_18388
105513 +btrfs_update_inode_18394 btrfs_update_inode 0 18394 NULL
105514 +hdlc_empty_fifo_18397 hdlc_empty_fifo 2 18397 NULL
105515 +__video_register_device_18399 __video_register_device 3 18399 NULL
105516 +hash_ip4_expire_18402 hash_ip4_expire 3 18402 NULL nohasharray
105517 +adis16136_show_serial_18402 adis16136_show_serial 3 18402 &hash_ip4_expire_18402
105518 +btrfs_rmap_block_18403 btrfs_rmap_block 0 18403 NULL
105519 +crystalhd_user_data_18407 crystalhd_user_data 3 18407 NULL
105520 +batadv_orig_node_add_if_18433 batadv_orig_node_add_if 2 18433 NULL nohasharray
105521 +iscsi_create_flashnode_sess_18433 iscsi_create_flashnode_sess 4 18433 &batadv_orig_node_add_if_18433
105522 +snd_hda_get_connections_18437 snd_hda_get_connections 0 18437 NULL
105523 +btrfs_uuid_tree_lookup_18451 btrfs_uuid_tree_lookup 0 18451 NULL
105524 +flash_dev_cache_miss_18454 flash_dev_cache_miss 4 18454 NULL
105525 +fuse_perform_write_18457 fuse_perform_write 4 18457 NULL
105526 +regset_tls_set_18459 regset_tls_set 4 18459 NULL
105527 +pcibios_window_alignment_18460 pcibios_window_alignment 0 18460 NULL
105528 +dma_alloc_from_contiguous_18466 dma_alloc_from_contiguous 3-2 18466 NULL
105529 +pci_vpd_lrdt_size_18479 pci_vpd_lrdt_size 0 18479 NULL nohasharray
105530 +mite_bytes_in_transit_18479 mite_bytes_in_transit 0 18479 &pci_vpd_lrdt_size_18479
105531 +r600_texture_size_18487 r600_texture_size 4-5-6 18487 NULL nohasharray
105532 +udpv6_setsockopt_18487 udpv6_setsockopt 5 18487 &r600_texture_size_18487
105533 +btrfs_fiemap_18501 btrfs_fiemap 3 18501 NULL nohasharray
105534 +remap_pmd_range_18501 remap_pmd_range 3-4-5 18501 &btrfs_fiemap_18501
105535 +i915_gem_object_wait_fence_18508 i915_gem_object_wait_fence 0 18508 NULL
105536 +__copy_user_zeroing_intel_18510 __copy_user_zeroing_intel 0-3 18510 NULL
105537 +snd_vx_inb_18514 snd_vx_inb 0 18514 NULL
105538 +snd_gus_dram_poke_18525 snd_gus_dram_poke 4 18525 NULL
105539 +nouveau_fifo_channel_create__18530 nouveau_fifo_channel_create_ 9 18530 NULL
105540 +seq_copy_in_user_18543 seq_copy_in_user 3 18543 NULL
105541 +acpi_register_gsi_ioapic_18550 acpi_register_gsi_ioapic 2 18550 NULL
105542 +sas_change_queue_depth_18555 sas_change_queue_depth 2 18555 NULL
105543 +vb2_streamon_18562 vb2_streamon 0 18562 NULL
105544 +smk_write_rules_list_18565 smk_write_rules_list 3 18565 NULL
105545 +debug_output_18575 debug_output 3 18575 NULL
105546 +is_extent_unchanged_18576 is_extent_unchanged 0 18576 NULL
105547 +check_lpt_type_18577 check_lpt_type 0 18577 NULL
105548 +numa_node_id_18596 numa_node_id 0 18596 NULL
105549 +filemap_fdatawait_range_18600 filemap_fdatawait_range 0 18600 NULL nohasharray
105550 +slabinfo_write_18600 slabinfo_write 3 18600 &filemap_fdatawait_range_18600
105551 +iowarrior_write_18604 iowarrior_write 3 18604 NULL
105552 +audio_get_endpoint_req_18624 audio_get_endpoint_req 0 18624 NULL
105553 +from_buffer_18625 from_buffer 3 18625 NULL
105554 +snd_pcm_oss_write3_18657 snd_pcm_oss_write3 0-3 18657 NULL
105555 +ieee80211_if_fmt_rssi_threshold_18664 ieee80211_if_fmt_rssi_threshold 3 18664 NULL
105556 +unmap_page_18665 unmap_page 2-3 18665 NULL
105557 +xfs_iext_insert_18667 xfs_iext_insert 3 18667 NULL
105558 +__alloc_skb_head_18683 __alloc_skb_head 2 18683 NULL
105559 +echo_client_prep_commit_18693 echo_client_prep_commit 8 18693 NULL
105560 +replay_log_leb_18704 replay_log_leb 3 18704 NULL
105561 +iwl_dbgfs_rx_handlers_read_18708 iwl_dbgfs_rx_handlers_read 3 18708 NULL
105562 +ceph_alloc_page_vector_18710 ceph_alloc_page_vector 1 18710 NULL
105563 +ocfs2_trim_extent_18711 ocfs2_trim_extent 3-4 18711 NULL
105564 +blk_rq_bytes_18715 blk_rq_bytes 0 18715 NULL
105565 +byt_gpio_to_irq_18721 byt_gpio_to_irq 2 18721 NULL
105566 +ext4_es_insert_extent_18729 ext4_es_insert_extent 0 18729 NULL
105567 +snd_als4k_gcr_read_addr_18741 snd_als4k_gcr_read_addr 0 18741 NULL
105568 +o2hb_debug_create_18744 o2hb_debug_create 4 18744 NULL
105569 +__erst_read_to_erange_from_nvram_18748 __erst_read_to_erange_from_nvram 0 18748 NULL
105570 +wep_packets_read_18751 wep_packets_read 3 18751 NULL
105571 +read_file_dump_nfcal_18766 read_file_dump_nfcal 3 18766 NULL
105572 +ffs_epfile_read_18775 ffs_epfile_read 3 18775 NULL
105573 +SyS_lsetxattr_18776 SyS_lsetxattr 4 18776 NULL
105574 +alloc_fcdev_18780 alloc_fcdev 1 18780 NULL
105575 +prealloc_18800 prealloc 0 18800 NULL
105576 +alloc_pages_node_18809 alloc_pages_node 1 18809 NULL
105577 +madvise_hwpoison_18812 madvise_hwpoison 2 18812 NULL
105578 +setup_ioapic_irq_18813 setup_ioapic_irq 1 18813 NULL
105579 +dm_stats_print_18815 dm_stats_print 7 18815 NULL
105580 +sys_modify_ldt_18824 sys_modify_ldt 3 18824 NULL
105581 +mtf_test_write_18844 mtf_test_write 3 18844 NULL
105582 +iterate_inode_refs_18846 iterate_inode_refs 0 18846 NULL
105583 +drm_ht_create_18853 drm_ht_create 2 18853 NULL
105584 +sctp_setsockopt_events_18862 sctp_setsockopt_events 3 18862 NULL
105585 +ieee80211_if_read_element_ttl_18869 ieee80211_if_read_element_ttl 3 18869 NULL nohasharray
105586 +heads_to_leaves_18869 heads_to_leaves 2-0 18869 &ieee80211_if_read_element_ttl_18869
105587 +xlog_find_verify_log_record_18870 xlog_find_verify_log_record 2 18870 NULL
105588 +width_to_agaw_18883 width_to_agaw 0-1 18883 NULL
105589 +overwrite_item_18896 overwrite_item 0 18896 NULL
105590 +kmem_cache_alloc_node_18899 kmem_cache_alloc_node 3 18899 NULL
105591 +ceph_setxattr_18913 ceph_setxattr 4 18913 NULL
105592 +ext4_block_in_group_18922 ext4_block_in_group 2 18922 NULL
105593 +ieee80211_rx_mgmt_disassoc_18927 ieee80211_rx_mgmt_disassoc 3 18927 NULL
105594 +create_pending_snapshot_18936 create_pending_snapshot 0 18936 NULL
105595 +snapshot_write_next_18937 snapshot_write_next 0 18937 NULL
105596 +regcache_sync_block_18963 regcache_sync_block 4-3 18963 NULL
105597 +__nla_reserve_18974 __nla_reserve 3 18974 NULL
105598 +__blockdev_direct_IO_18977 __blockdev_direct_IO 0-6 18977 NULL
105599 +gfn_to_pfn_atomic_18981 gfn_to_pfn_atomic 2 18981 NULL
105600 +get_inode_path_18988 get_inode_path 0 18988 NULL
105601 +find_dirtiest_idx_leb_19001 find_dirtiest_idx_leb 0 19001 NULL nohasharray
105602 +test_check_exists_19001 test_check_exists 2 19001 &find_dirtiest_idx_leb_19001
105603 +layout_in_gaps_19006 layout_in_gaps 2 19006 NULL
105604 +huge_page_size_19008 huge_page_size 0 19008 NULL
105605 +push_leaf_right_19017 push_leaf_right 0 19017 NULL
105606 +prepare_highmem_image_19028 prepare_highmem_image 0 19028 NULL
105607 +ocfs2_steal_resource_19036 ocfs2_steal_resource 0 19036 NULL
105608 +revalidate_19043 revalidate 2 19043 NULL
105609 +afs_vnode_store_data_19048 afs_vnode_store_data 2-3-4-5 19048 NULL
105610 +osc_pinger_recov_seq_write_19056 osc_pinger_recov_seq_write 3 19056 NULL
105611 +create_gpadl_header_19064 create_gpadl_header 2 19064 NULL
105612 +ieee80211_key_alloc_19065 ieee80211_key_alloc 3 19065 NULL
105613 +ceph_create_snap_context_19082 ceph_create_snap_context 1 19082 NULL
105614 +kvm_lapic_set_vapic_addr_19083 kvm_lapic_set_vapic_addr 2 19083 NULL
105615 +sta_last_seq_ctrl_read_19106 sta_last_seq_ctrl_read 3 19106 NULL
105616 +cifs_readv_from_socket_19109 cifs_readv_from_socket 3 19109 NULL
105617 +ATOMIC_SUB_RETURN_19115 ATOMIC_SUB_RETURN 2 19115 NULL
105618 +ext4_inode_table_19125 ext4_inode_table 0 19125 NULL
105619 +snd_als4k_iobase_readl_19136 snd_als4k_iobase_readl 0 19136 NULL
105620 +btrfs_run_delayed_refs_19137 btrfs_run_delayed_refs 0 19137 NULL
105621 +alloc_irdadev_19140 alloc_irdadev 1 19140 NULL
105622 +sleep_auth_read_19159 sleep_auth_read 3 19159 NULL
105623 +ext3_reserve_inode_write_19163 ext3_reserve_inode_write 0 19163 NULL
105624 +smk_write_access2_19170 smk_write_access2 3 19170 NULL
105625 +iwl_dbgfs_reply_tx_error_read_19205 iwl_dbgfs_reply_tx_error_read 3 19205 NULL
105626 +vmw_unlocked_ioctl_19212 vmw_unlocked_ioctl 2 19212 NULL
105627 +__copy_to_user_inatomic_19214 __copy_to_user_inatomic 3-0 19214 NULL
105628 +dev_counters_read_19216 dev_counters_read 3 19216 NULL
105629 +wbcir_tx_19219 wbcir_tx 3 19219 NULL
105630 +gsi_to_irq_19220 gsi_to_irq 0-1 19220 NULL
105631 +snd_mask_max_19224 snd_mask_max 0 19224 NULL
105632 +snd_pcm_capture_rewind_19229 snd_pcm_capture_rewind 0-2 19229 NULL
105633 +bio_alloc_mddev_19238 bio_alloc_mddev 2 19238 NULL
105634 +ucma_query_19260 ucma_query 4 19260 NULL
105635 +write_one_cache_group_19261 write_one_cache_group 0 19261 NULL
105636 +il_dbgfs_rxon_filter_flags_read_19281 il_dbgfs_rxon_filter_flags_read 3 19281 NULL
105637 +cfg80211_rx_unprot_mlme_mgmt_19288 cfg80211_rx_unprot_mlme_mgmt 3 19288 NULL
105638 +____cache_alloc_node_19297 ____cache_alloc_node 3 19297 NULL
105639 +qc_capture_19298 qc_capture 3 19298 NULL
105640 +ocfs2_prepare_inode_for_refcount_19303 ocfs2_prepare_inode_for_refcount 4-3 19303 NULL
105641 +event_tx_stuck_read_19305 event_tx_stuck_read 3 19305 NULL
105642 +gfn_to_gpa_19320 gfn_to_gpa 0-1 19320 NULL
105643 +debug_read_19322 debug_read 3 19322 NULL
105644 +SYSC_sendfile64_19327 SYSC_sendfile64 4 19327 NULL
105645 +cfg80211_inform_bss_19332 cfg80211_inform_bss 8 19332 NULL nohasharray
105646 +lbs_host_sleep_write_19332 lbs_host_sleep_write 3 19332 &cfg80211_inform_bss_19332
105647 +closure_sub_19359 closure_sub 2 19359 NULL
105648 +firmware_data_write_19360 firmware_data_write 6-5 19360 NULL
105649 +read_zero_19366 read_zero 3 19366 NULL
105650 +interpret_user_input_19393 interpret_user_input 2 19393 NULL
105651 +sync_fill_pt_info_19397 sync_fill_pt_info 0 19397 NULL
105652 +get_unaligned_be16_19400 get_unaligned_be16 0 19400 NULL
105653 +get_n_events_by_type_19401 get_n_events_by_type 0 19401 NULL
105654 +pep_recvmsg_19402 pep_recvmsg 4 19402 NULL
105655 +dvbdmx_write_19423 dvbdmx_write 3 19423 NULL
105656 +__phys_addr_19434 __phys_addr 0 19434 NULL
105657 +SyS_sched_getaffinity_19444 SyS_sched_getaffinity 2 19444 NULL
105658 +xfrm_alg_auth_len_19454 xfrm_alg_auth_len 0 19454 NULL
105659 +gnet_stats_copy_19458 gnet_stats_copy 4 19458 NULL
105660 +sky2_read16_19475 sky2_read16 0 19475 NULL
105661 +__read_status_pciv2_19492 __read_status_pciv2 0 19492 NULL
105662 +kstrtoll_from_user_19500 kstrtoll_from_user 2 19500 NULL
105663 +ext4_add_new_descs_19509 ext4_add_new_descs 3 19509 NULL
105664 +cfc_write_array_to_buffer_19529 cfc_write_array_to_buffer 3 19529 NULL nohasharray
105665 +apei_exec_pre_map_gars_19529 apei_exec_pre_map_gars 0 19529 &cfc_write_array_to_buffer_19529
105666 +nfc_llcp_build_tlv_19536 nfc_llcp_build_tlv 3 19536 NULL
105667 +howmany_64_19548 howmany_64 2 19548 NULL
105668 +btrfs_xattr_security_init_19553 btrfs_xattr_security_init 0 19553 NULL
105669 +gfn_to_index_19558 gfn_to_index 0-1-3-2 19558 NULL
105670 +kernel_read_19559 kernel_read 4-0 19559 NULL
105671 +ocfs2_control_message_19564 ocfs2_control_message 3 19564 NULL
105672 +ieee80211_if_read_tkip_mic_test_19565 ieee80211_if_read_tkip_mic_test 3 19565 NULL
105673 +nfsd_read_19568 nfsd_read 5 19568 NULL
105674 +cgroup_read_s64_19570 cgroup_read_s64 5 19570 NULL
105675 +bm_status_read_19583 bm_status_read 3 19583 NULL
105676 +batadv_tt_update_orig_19586 batadv_tt_update_orig 4 19586 NULL
105677 +load_xattr_datum_19594 load_xattr_datum 0 19594 NULL
105678 +__mei_cl_recv_19636 __mei_cl_recv 3 19636 NULL
105679 +usbvision_rvmalloc_19655 usbvision_rvmalloc 1 19655 NULL
105680 +LoadBitmap_19658 LoadBitmap 2 19658 NULL
105681 +i915_gem_object_bind_to_gtt_19682 i915_gem_object_bind_to_gtt 0 19682 NULL
105682 +bio_detain_19690 bio_detain 2 19690 NULL
105683 +btrfs_del_inode_extref_19692 btrfs_del_inode_extref 0 19692 NULL
105684 +mem_cgroup_swappiness_19718 mem_cgroup_swappiness 0 19718 NULL
105685 +btrfs_write_marked_extents_19720 btrfs_write_marked_extents 0 19720 NULL
105686 +read_reg_19723 read_reg 0 19723 NULL
105687 +wm8350_block_write_19727 wm8350_block_write 2-3 19727 NULL
105688 +memcpy_toiovecend_19736 memcpy_toiovecend 3-4-0 19736 NULL
105689 +snd_es1968_get_dma_ptr_19747 snd_es1968_get_dma_ptr 0 19747 NULL
105690 +p9_client_read_19750 p9_client_read 0-5 19750 NULL
105691 +pnpbios_proc_write_19758 pnpbios_proc_write 3 19758 NULL
105692 +ocfs2_readpages_19759 ocfs2_readpages 4 19759 NULL
105693 +jffs2_acl_from_medium_19762 jffs2_acl_from_medium 2 19762 NULL
105694 +readhscx_19769 readhscx 0 19769 NULL
105695 +ocfs2_read_group_descriptor_19771 ocfs2_read_group_descriptor 0 19771 NULL
105696 +__set_print_fmt_19776 __set_print_fmt 0 19776 NULL
105697 +saa7146_vmalloc_build_pgtable_19780 saa7146_vmalloc_build_pgtable 2 19780 NULL
105698 +irda_setsockopt_19824 irda_setsockopt 5 19824 NULL
105699 +pcpu_next_unpop_19831 pcpu_next_unpop 4 19831 NULL
105700 +vfs_getxattr_19832 vfs_getxattr 0 19832 NULL
105701 +security_context_to_sid_19839 security_context_to_sid 2 19839 NULL
105702 +crypt_alloc_buffer_19846 crypt_alloc_buffer 2 19846 NULL
105703 +cfg80211_mlme_register_mgmt_19852 cfg80211_mlme_register_mgmt 5 19852 NULL
105704 +__nla_put_19857 __nla_put 3 19857 NULL
105705 +mrp_request_join_19882 mrp_request_join 4 19882 NULL
105706 +blk_alloc_queue_node_19887 blk_alloc_queue_node 2 19887 NULL
105707 +aes_decrypt_interrupt_read_19910 aes_decrypt_interrupt_read 3 19910 NULL
105708 +ps_upsd_max_apturn_read_19918 ps_upsd_max_apturn_read 3 19918 NULL
105709 +mangle_name_19923 mangle_name 0 19923 NULL
105710 +cgroup_task_count_19930 cgroup_task_count 0 19930 NULL
105711 +guest_read_tsc_19931 guest_read_tsc 0 19931 NULL
105712 +iwl_dbgfs_rx_queue_read_19943 iwl_dbgfs_rx_queue_read 3 19943 NULL
105713 +cfg80211_rx_assoc_resp_19944 cfg80211_rx_assoc_resp 4 19944 NULL
105714 +alloc_elfnotes_buf_19974 alloc_elfnotes_buf 1 19974 NULL
105715 +get_jack_mode_name_19976 get_jack_mode_name 4 19976 NULL
105716 +attach_hdlc_protocol_19986 attach_hdlc_protocol 3 19986 NULL
105717 +rtw_set_wps_probe_resp_19989 rtw_set_wps_probe_resp 3 19989 NULL
105718 +diva_um_idi_read_20003 diva_um_idi_read 0 20003 NULL
105719 +lov_stripe_md_size_20009 lov_stripe_md_size 0-1 20009 NULL
105720 +SYSC_fgetxattr_20027 SYSC_fgetxattr 4 20027 NULL
105721 +split_scan_timeout_read_20029 split_scan_timeout_read 3 20029 NULL
105722 +mlx5_ib_db_map_user_20037 mlx5_ib_db_map_user 2 20037 NULL
105723 +btrfs_block_rsv_migrate_20050 btrfs_block_rsv_migrate 0 20050 NULL
105724 +__be32_to_cpup_20056 __be32_to_cpup 0 20056 NULL
105725 +alloc_ieee80211_20063 alloc_ieee80211 1 20063 NULL
105726 +iwl_mvm_power_mac_dbgfs_read_20067 iwl_mvm_power_mac_dbgfs_read 4 20067 NULL
105727 +btrfs_pin_extent_for_log_replay_20069 btrfs_pin_extent_for_log_replay 2 20069 NULL
105728 +target_message_20072 target_message 2 20072 NULL
105729 +rawv6_sendmsg_20080 rawv6_sendmsg 4 20080 NULL
105730 +fuse_conn_limit_read_20084 fuse_conn_limit_read 3 20084 NULL
105731 +aat2870_reg_write_file_20086 aat2870_reg_write_file 3 20086 NULL
105732 +team_options_register_20091 team_options_register 3 20091 NULL
105733 +qla2x00_adjust_sdev_qdepth_up_20097 qla2x00_adjust_sdev_qdepth_up 2 20097 NULL
105734 +read_int_20098 read_int 0 20098 NULL
105735 +root_nfs_copy_20111 root_nfs_copy 3 20111 NULL
105736 +hptiop_adjust_disk_queue_depth_20122 hptiop_adjust_disk_queue_depth 2 20122 NULL
105737 +self_check_vid_hdr_20131 self_check_vid_hdr 0 20131 NULL
105738 +tomoyo_commit_ok_20167 tomoyo_commit_ok 2 20167 NULL
105739 +read_flush_pipefs_20171 read_flush_pipefs 3 20171 NULL
105740 +wep_addr_key_count_read_20174 wep_addr_key_count_read 3 20174 NULL
105741 +create_trace_probe_20175 create_trace_probe 1 20175 NULL
105742 +crystalhd_map_dio_20181 crystalhd_map_dio 3 20181 NULL
105743 +udf_bitmap_new_block_20214 udf_bitmap_new_block 4 20214 NULL
105744 +pvr2_ctrl_value_to_sym_20229 pvr2_ctrl_value_to_sym 5 20229 NULL
105745 +rose_sendmsg_20249 rose_sendmsg 4 20249 NULL
105746 +tm6000_i2c_send_regs_20250 tm6000_i2c_send_regs 5 20250 NULL
105747 +pcpu_alloc_20255 pcpu_alloc 1-2 20255 NULL
105748 +resource_size_20256 resource_size 0 20256 NULL
105749 +uv_blade_to_memory_nid_20259 uv_blade_to_memory_nid 0 20259 NULL
105750 +r10_sync_page_io_20307 r10_sync_page_io 3 20307 NULL
105751 +dm_get_reserved_bio_based_ios_20315 dm_get_reserved_bio_based_ios 0 20315 NULL
105752 +tx_tx_burst_programmed_read_20320 tx_tx_burst_programmed_read 3 20320 NULL
105753 +vx_send_msg_nolock_20322 vx_send_msg_nolock 0 20322 NULL
105754 +snd_cs4281_BA1_read_20323 snd_cs4281_BA1_read 5 20323 NULL
105755 +ocfs2_et_insert_check_20341 ocfs2_et_insert_check 0 20341 NULL
105756 +gfs2_glock_nq_m_20347 gfs2_glock_nq_m 1 20347 NULL
105757 +handle_arr_calc_size_20355 handle_arr_calc_size 0-1 20355 NULL
105758 +snd_pcm_stop_20376 snd_pcm_stop 0 20376 NULL
105759 +smk_set_cipso_20379 smk_set_cipso 3 20379 NULL
105760 +block_read_full_page_20380 block_read_full_page 0 20380 NULL
105761 +snd_nm256_readl_20394 snd_nm256_readl 0 20394 NULL nohasharray
105762 +read_7220_creg32_20394 read_7220_creg32 0 20394 &snd_nm256_readl_20394
105763 +__kfifo_from_user_20399 __kfifo_from_user 3 20399 NULL nohasharray
105764 +SyS_get_mempolicy_20399 SyS_get_mempolicy 3-4 20399 &__kfifo_from_user_20399
105765 +btrfs_set_acl_20440 btrfs_set_acl 0 20440 NULL
105766 +nfs3_setxattr_20458 nfs3_setxattr 4 20458 NULL
105767 +compat_ipv6_setsockopt_20468 compat_ipv6_setsockopt 5 20468 NULL
105768 +read_buf_20469 read_buf 2 20469 NULL
105769 +btrfs_get_32_20476 btrfs_get_32 0 20476 NULL
105770 +fast_user_write_20494 fast_user_write 5 20494 NULL
105771 +ocfs2_db_frozen_trigger_20503 ocfs2_db_frozen_trigger 4 20503 NULL
105772 +pcpu_alloc_area_20511 pcpu_alloc_area 0-3 20511 NULL
105773 +link_free_space_20512 link_free_space 0 20512 NULL
105774 +pcpu_depopulate_chunk_20517 pcpu_depopulate_chunk 3-2 20517 NULL
105775 +xfs_iext_realloc_direct_20521 xfs_iext_realloc_direct 2 20521 NULL
105776 +drbd_bm_resize_20522 drbd_bm_resize 2 20522 NULL
105777 +amd_create_gatt_pages_20537 amd_create_gatt_pages 1 20537 NULL
105778 +scsi_report_opcode_20551 scsi_report_opcode 3 20551 NULL
105779 +venus_create_20555 venus_create 4 20555 NULL
105780 +btrfs_super_log_root_20565 btrfs_super_log_root 0 20565 NULL
105781 +crypto_ahash_reqsize_20569 crypto_ahash_reqsize 0 20569 NULL
105782 +batadv_tt_append_diff_20588 batadv_tt_append_diff 4 20588 NULL nohasharray
105783 +ocfs2_cluster_lock_20588 ocfs2_cluster_lock 0 20588 &batadv_tt_append_diff_20588
105784 +kvm_test_age_hva_20593 kvm_test_age_hva 2 20593 NULL
105785 +sync_timeline_create_20601 sync_timeline_create 2 20601 NULL
105786 +lirc_write_20604 lirc_write 3 20604 NULL
105787 +qib_qsfp_write_20614 qib_qsfp_write 0-2-4 20614 NULL
105788 +snd_pcm_oss_prepare_20641 snd_pcm_oss_prepare 0 20641 NULL
105789 +get_extent_skip_holes_20642 get_extent_skip_holes 2 20642 NULL
105790 +kfifo_copy_to_user_20646 kfifo_copy_to_user 4-3 20646 NULL
105791 +cpulist_scnprintf_20648 cpulist_scnprintf 2-0 20648 NULL
105792 +oz_add_farewell_20652 oz_add_farewell 5 20652 NULL
105793 +oz_cdev_read_20659 oz_cdev_read 3 20659 NULL
105794 +btrfs_qgroup_reserve_20676 btrfs_qgroup_reserve 0 20676 NULL nohasharray
105795 +snd_hdsp_playback_copy_20676 snd_hdsp_playback_copy 5 20676 &btrfs_qgroup_reserve_20676
105796 +get_user_page_nowait_20682 get_user_page_nowait 3 20682 NULL nohasharray
105797 +dvb_dmxdev_buffer_read_20682 dvb_dmxdev_buffer_read 0-4 20682 &get_user_page_nowait_20682
105798 +cpumask_size_20683 cpumask_size 0 20683 NULL
105799 +btrfs_node_blockptr_20685 btrfs_node_blockptr 0 20685 NULL
105800 +gru_vtop_20689 gru_vtop 2 20689 NULL
105801 +read_file_tgt_int_stats_20697 read_file_tgt_int_stats 3 20697 NULL
105802 +i915_gem_obj_ggtt_pin_20698 i915_gem_obj_ggtt_pin 0 20698 NULL
105803 +__maestro_read_20700 __maestro_read 0 20700 NULL
105804 +cipso_v4_gentag_rng_20703 cipso_v4_gentag_rng 0 20703 NULL
105805 +pcpu_page_first_chunk_20712 pcpu_page_first_chunk 1 20712 NULL
105806 +ocfs2_read_xattr_bucket_20722 ocfs2_read_xattr_bucket 0 20722 NULL
105807 +security_context_to_sid_force_20724 security_context_to_sid_force 2 20724 NULL
105808 +io_apic_set_pci_routing_20740 io_apic_set_pci_routing 2 20740 NULL
105809 +fb_prepare_logo_20743 fb_prepare_logo 0 20743 NULL
105810 +vol_cdev_direct_write_20751 vol_cdev_direct_write 3 20751 NULL
105811 +ocfs2_align_bytes_to_clusters_20754 ocfs2_align_bytes_to_clusters 2 20754 NULL
105812 +brcmf_p2p_escan_20763 brcmf_p2p_escan 2 20763 NULL
105813 +ubi_io_read_20767 ubi_io_read 0 20767 NULL
105814 +ext4_r_blocks_count_20768 ext4_r_blocks_count 0 20768 NULL
105815 +fb_alloc_cmap_gfp_20792 fb_alloc_cmap_gfp 2 20792 NULL
105816 +iommu_range_alloc_20794 iommu_range_alloc 3 20794 NULL
105817 +iwl_dbgfs_rxon_flags_read_20795 iwl_dbgfs_rxon_flags_read 3 20795 NULL
105818 +ext4_convert_unwritten_extents_endio_20812 ext4_convert_unwritten_extents_endio 0 20812 NULL
105819 +strndup_user_20819 strndup_user 2 20819 NULL
105820 +dtf_read_channel_20831 dtf_read_channel 3 20831 NULL
105821 +wl1271_format_buffer_20834 wl1271_format_buffer 2 20834 NULL
105822 +uvc_alloc_entity_20836 uvc_alloc_entity 3-4 20836 NULL
105823 +btrfs_orphan_add_20840 btrfs_orphan_add 0 20840 NULL
105824 +p9_tag_alloc_20845 p9_tag_alloc 3 20845 NULL
105825 +nvme_trans_supported_vpd_pages_20847 nvme_trans_supported_vpd_pages 4 20847 NULL
105826 +get_name_20855 get_name 4 20855 NULL
105827 +iwl_dbgfs_pm_params_read_20866 iwl_dbgfs_pm_params_read 3 20866 NULL
105828 +snd_pcm_capture_avail_20867 snd_pcm_capture_avail 0 20867 NULL
105829 +srq_free_res_20868 srq_free_res 5 20868 NULL
105830 +ocfs2_bmap_20874 ocfs2_bmap 2 20874 NULL
105831 +cfs_cpt_table_create_20884 cfs_cpt_table_create 1 20884 NULL
105832 +rb_simple_write_20890 rb_simple_write 3 20890 NULL
105833 +sisusb_send_packet_20891 sisusb_send_packet 2 20891 NULL
105834 +key_icverrors_read_20895 key_icverrors_read 3 20895 NULL
105835 +vfio_msi_enable_20906 vfio_msi_enable 2 20906 NULL
105836 +lbs_rdbbp_write_20918 lbs_rdbbp_write 3 20918 NULL
105837 +htable_bits_20933 htable_bits 0 20933 NULL
105838 +check_eofblocks_fl_20942 check_eofblocks_fl 0 20942 NULL
105839 +altera_set_ir_post_20948 altera_set_ir_post 2 20948 NULL
105840 +rx_rx_phy_hdr_read_20950 rx_rx_phy_hdr_read 3 20950 NULL
105841 +rsxx_cram_read_20957 rsxx_cram_read 3 20957 NULL
105842 +nfs_map_name_to_uid_20962 nfs_map_name_to_uid 3 20962 NULL
105843 +snd_rme9652_playback_copy_20970 snd_rme9652_playback_copy 5 20970 NULL
105844 +alg_setsockopt_20985 alg_setsockopt 5 20985 NULL
105845 +qib_verbs_send_20999 qib_verbs_send 5-3 20999 NULL
105846 +ocfs2_free_clusters_21001 ocfs2_free_clusters 4-0 21001 NULL
105847 +btrfs_inode_ref_name_len_21024 btrfs_inode_ref_name_len 0 21024 NULL
105848 +rx_defrag_tkip_called_read_21031 rx_defrag_tkip_called_read 3 21031 NULL
105849 +lbs_threshold_read_21046 lbs_threshold_read 5 21046 NULL
105850 +reiserfs_direct_IO_21051 reiserfs_direct_IO 4 21051 NULL
105851 +proc_fault_inject_write_21058 proc_fault_inject_write 3 21058 NULL
105852 +btrfs_insert_root_21061 btrfs_insert_root 0 21061 NULL
105853 +qdisc_get_default_21072 qdisc_get_default 2 21072 NULL
105854 +event_calibration_read_21083 event_calibration_read 3 21083 NULL
105855 +bl_add_page_to_bio_21094 bl_add_page_to_bio 2 21094 NULL nohasharray
105856 +multipath_status_21094 multipath_status 5 21094 &bl_add_page_to_bio_21094
105857 +ext2_valid_block_bitmap_21101 ext2_valid_block_bitmap 3 21101 NULL
105858 +ath6kl_send_go_probe_resp_21113 ath6kl_send_go_probe_resp 3 21113 NULL
105859 +bitset_size_in_bytes_21124 bitset_size_in_bytes 0-1 21124 NULL
105860 +i2400m_rx_trace_21127 i2400m_rx_trace 3 21127 NULL
105861 +tps6586x_irq_init_21144 tps6586x_irq_init 3 21144 NULL
105862 +chunk_size_21146 chunk_size 0 21146 NULL
105863 +ocfs2_block_check_validate_21149 ocfs2_block_check_validate 2 21149 NULL
105864 +alloc_pg_vec_21159 alloc_pg_vec 3 21159 NULL
105865 +btrfs_add_root_ref_21186 btrfs_add_root_ref 0 21186 NULL
105866 +cx18_v4l2_read_21196 cx18_v4l2_read 3 21196 NULL
105867 +get_current_ntfs_time_21198 get_current_ntfs_time 0 21198 NULL
105868 +ipc_rcu_alloc_21208 ipc_rcu_alloc 1 21208 NULL
105869 +scsi_execute_req_flags_21215 scsi_execute_req_flags 5 21215 NULL
105870 +_ocfs2_free_clusters_21220 _ocfs2_free_clusters 4-0 21220 NULL
105871 +get_numpages_21227 get_numpages 0-1-2 21227 NULL
105872 +SyS_mlock_21238 SyS_mlock 1-2 21238 NULL
105873 +input_ff_create_21240 input_ff_create 2 21240 NULL
105874 +cfg80211_notify_new_peer_candidate_21242 cfg80211_notify_new_peer_candidate 4 21242 NULL
105875 +fru_length_21257 fru_length 0 21257 NULL
105876 +rtw_set_wps_beacon_21262 rtw_set_wps_beacon 3 21262 NULL
105877 +ocfs2_blocks_for_bytes_21268 ocfs2_blocks_for_bytes 0-2 21268 NULL
105878 +vmw_gmr2_bind_21305 vmw_gmr2_bind 3 21305 NULL
105879 +do_msg_fill_21307 do_msg_fill 3 21307 NULL
105880 +add_res_range_21310 add_res_range 4 21310 NULL
105881 +get_zeroed_page_21322 get_zeroed_page 0 21322 NULL
105882 +ftrace_profile_read_21327 ftrace_profile_read 3 21327 NULL
105883 +gfs2_ea_get_copy_21353 gfs2_ea_get_copy 0 21353 NULL
105884 +max77693_irq_domain_map_21357 max77693_irq_domain_map 2 21357 NULL
105885 +alloc_orinocodev_21371 alloc_orinocodev 1 21371 NULL
105886 +split_leaf_21378 split_leaf 0 21378 NULL
105887 +SYSC_rt_sigpending_21379 SYSC_rt_sigpending 2 21379 NULL
105888 +video_ioctl2_21380 video_ioctl2 2 21380 NULL
105889 +diva_get_driver_dbg_mask_21399 diva_get_driver_dbg_mask 0 21399 NULL
105890 +sle64_to_cpu_21400 sle64_to_cpu 0-1 21400 NULL
105891 +snd_m3_inw_21406 snd_m3_inw 0 21406 NULL
105892 +snapshot_read_next_21426 snapshot_read_next 0 21426 NULL
105893 +tcp_bound_to_half_wnd_21429 tcp_bound_to_half_wnd 0-2 21429 NULL
105894 +tracing_saved_cmdlines_read_21434 tracing_saved_cmdlines_read 3 21434 NULL
105895 +aggr_size_tx_agg_vs_rate_read_21438 aggr_size_tx_agg_vs_rate_read 3 21438 NULL
105896 +__ertm_hdr_size_21450 __ertm_hdr_size 0 21450 NULL
105897 +ReadISAR_21453 ReadISAR 0 21453 NULL
105898 +mei_nfc_send_21477 mei_nfc_send 3 21477 NULL
105899 +read_file_xmit_21487 read_file_xmit 3 21487 NULL
105900 +mmc_alloc_sg_21504 mmc_alloc_sg 1 21504 NULL
105901 +dma_skb_copy_datagram_iovec_21516 dma_skb_copy_datagram_iovec 3-5 21516 NULL
105902 +btrfs_file_aio_write_21520 btrfs_file_aio_write 4 21520 NULL
105903 +il_dbgfs_stations_read_21532 il_dbgfs_stations_read 3 21532 NULL
105904 +cipso_v4_map_cat_enum_hton_21540 cipso_v4_map_cat_enum_hton 0 21540 NULL
105905 +rxrpc_send_data_21553 rxrpc_send_data 5 21553 NULL
105906 +rx_rx_beacon_early_term_read_21559 rx_rx_beacon_early_term_read 3 21559 NULL
105907 +xfs_buf_read_uncached_21585 xfs_buf_read_uncached 3 21585 NULL
105908 +snd_es18xx_mixer_read_21586 snd_es18xx_mixer_read 0 21586 NULL
105909 +ocfs2_acl_from_xattr_21604 ocfs2_acl_from_xattr 2 21604 NULL
105910 +filemap_get_page_21606 filemap_get_page 2 21606 NULL
105911 +xlog_do_recovery_pass_21618 xlog_do_recovery_pass 3 21618 NULL
105912 +pci_cardbus_resource_alignment_21625 pci_cardbus_resource_alignment 0 21625 NULL
105913 +add_pin_to_irq_node_21628 add_pin_to_irq_node 2 21628 NULL
105914 +ocfs2_refcount_cow_hunk_21630 ocfs2_refcount_cow_hunk 3-4 21630 NULL
105915 +__jfs_getxattr_21631 __jfs_getxattr 0 21631 NULL
105916 +validate_nnode_21638 validate_nnode 0 21638 NULL
105917 +__irq_alloc_descs_21639 __irq_alloc_descs 2-1-0-3-4 21639 NULL
105918 +ocfs2_lock_refcount_allocators_21646 ocfs2_lock_refcount_allocators 0 21646 NULL
105919 +atalk_sendmsg_21677 atalk_sendmsg 4 21677 NULL
105920 +ocfs2_xattr_get_nolock_21678 ocfs2_xattr_get_nolock 0 21678 NULL
105921 +rtllib_alloc_txb_21687 rtllib_alloc_txb 1 21687 NULL
105922 +evdev_ioctl_handler_21705 evdev_ioctl_handler 2 21705 NULL
105923 +btrfs_find_all_leafs_21712 btrfs_find_all_leafs 0 21712 NULL
105924 +unix_skb_len_21722 unix_skb_len 0 21722 NULL
105925 +lprocfs_wr_import_21728 lprocfs_wr_import 3 21728 NULL
105926 +ocfs2_remove_rightmost_path_21729 ocfs2_remove_rightmost_path 0 21729 NULL
105927 +reiserfs_allocate_list_bitmaps_21732 reiserfs_allocate_list_bitmaps 3 21732 NULL nohasharray
105928 +ext4_split_extent_at_21732 ext4_split_extent_at 0 21732 &reiserfs_allocate_list_bitmaps_21732
105929 +vm_brk_21739 vm_brk 1-2 21739 NULL
105930 +mthca_alloc_init_21754 mthca_alloc_init 2 21754 NULL
105931 +usbat_flash_read_data_21762 usbat_flash_read_data 4 21762 NULL
105932 +gen_pool_add_21776 gen_pool_add 3-4 21776 NULL
105933 +SyS_sendfile_21777 SyS_sendfile 4 21777 NULL
105934 +atomic64_cmpxchg_21782 atomic64_cmpxchg 0 21782 NULL
105935 +xfs_da_grow_inode_int_21785 xfs_da_grow_inode_int 3 21785 NULL
105936 +dvb_generic_ioctl_21810 dvb_generic_ioctl 2 21810 NULL
105937 +__ocfs2_cluster_lock_21812 __ocfs2_cluster_lock 0 21812 NULL
105938 +wm8994_request_irq_21822 wm8994_request_irq 2 21822 NULL
105939 +oom_adj_read_21847 oom_adj_read 3 21847 NULL
105940 +gen_unique_name_21852 gen_unique_name 0 21852 NULL
105941 +lpfc_idiag_extacc_avail_get_21865 lpfc_idiag_extacc_avail_get 0-3 21865 NULL
105942 +brcms_debugfs_hardware_read_21867 brcms_debugfs_hardware_read 3 21867 NULL
105943 +sisusbcon_bmove_21873 sisusbcon_bmove 6-5-7 21873 NULL
105944 +ldlm_lock_create_21888 ldlm_lock_create 7 21888 NULL
105945 +__alloc_reserved_percpu_21895 __alloc_reserved_percpu 2-1 21895 NULL
105946 +rio_destid_first_21900 rio_destid_first 0 21900 NULL
105947 +dbAllocCtl_21911 dbAllocCtl 0 21911 NULL
105948 +qsfp_1_read_21915 qsfp_1_read 3 21915 NULL
105949 +ast_ttm_tt_create_21917 ast_ttm_tt_create 2 21917 NULL
105950 +__ocfs2_claim_clusters_21936 __ocfs2_claim_clusters 0 21936 NULL
105951 +alloc_ldt_21972 alloc_ldt 2 21972 NULL
105952 +SYSC_prctl_21980 SYSC_prctl 4 21980 NULL
105953 +rxpipe_descr_host_int_trig_rx_data_read_22001 rxpipe_descr_host_int_trig_rx_data_read 3 22001 NULL nohasharray
105954 +compat_rw_copy_check_uvector_22001 compat_rw_copy_check_uvector 3-0 22001 &rxpipe_descr_host_int_trig_rx_data_read_22001
105955 +ocfs2_reserve_cluster_bitmap_bits_22016 ocfs2_reserve_cluster_bitmap_bits 0 22016 NULL
105956 +regcache_sync_block_raw_flush_22021 regcache_sync_block_raw_flush 3-4 22021 NULL
105957 +btrfs_get_16_22023 btrfs_get_16 0 22023 NULL
105958 +i915_gem_evict_something_22028 i915_gem_evict_something 0 22028 NULL
105959 +_sp2d_min_pg_22032 _sp2d_min_pg 0 22032 NULL
105960 +zd_usb_read_fw_22049 zd_usb_read_fw 4 22049 NULL
105961 +atalk_recvmsg_22053 atalk_recvmsg 4 22053 NULL
105962 +ieee80211_if_fmt_dropped_frames_ttl_22054 ieee80211_if_fmt_dropped_frames_ttl 3 22054 NULL
105963 +btrfs_reloc_clone_csums_22077 btrfs_reloc_clone_csums 2-3 22077 NULL
105964 +write_opcode_22082 write_opcode 2 22082 NULL
105965 +mem_rw_22085 mem_rw 3 22085 NULL
105966 +snd_pcm_xrun_22088 snd_pcm_xrun 0 22088 NULL
105967 +sched_clock_cpu_22098 sched_clock_cpu 0 22098 NULL
105968 +rt2x00debug_read_crypto_stats_22109 rt2x00debug_read_crypto_stats 3 22109 NULL
105969 +shmem_add_to_page_cache_22121 shmem_add_to_page_cache 0 22121 NULL
105970 +snd_hda_codec_read_22130 snd_hda_codec_read 0 22130 NULL
105971 +SyS_sched_setaffinity_22148 SyS_sched_setaffinity 2 22148 NULL
105972 +do_tcp_sendpages_22155 do_tcp_sendpages 4 22155 NULL
105973 +remap_pud_range_22164 remap_pud_range 3-4-5 22164 NULL
105974 +__kfifo_alloc_22173 __kfifo_alloc 3 22173 NULL nohasharray
105975 +vmci_qp_broker_map_22173 vmci_qp_broker_map 3 22173 &__kfifo_alloc_22173
105976 +fls_22210 fls 0 22210 NULL
105977 +rfcomm_sock_recvmsg_22227 rfcomm_sock_recvmsg 4 22227 NULL nohasharray
105978 +bitmap_clear_bits_22227 bitmap_clear_bits 3 22227 &rfcomm_sock_recvmsg_22227
105979 +mem_write_22232 mem_write 3 22232 NULL
105980 +p9_virtio_zc_request_22240 p9_virtio_zc_request 6-5 22240 NULL
105981 +fsnotify_parent_22243 fsnotify_parent 0 22243 NULL
105982 +compat_process_vm_rw_22254 compat_process_vm_rw 3-5 22254 NULL
105983 +ping_common_sendmsg_22261 ping_common_sendmsg 5 22261 NULL
105984 +add_res_tree_22263 add_res_tree 7 22263 NULL
105985 +__btrfs_direct_write_22273 __btrfs_direct_write 4 22273 NULL
105986 +queue_max_sectors_22280 queue_max_sectors 0 22280 NULL
105987 +i915_gem_execbuffer_relocate_22294 i915_gem_execbuffer_relocate 0 22294 NULL
105988 +pci_vpd_srdt_size_22300 pci_vpd_srdt_size 0 22300 NULL nohasharray
105989 +__tun_chr_ioctl_22300 __tun_chr_ioctl 4 22300 &pci_vpd_srdt_size_22300
105990 +mesh_table_alloc_22305 mesh_table_alloc 1 22305 NULL
105991 +lov_setstripe_22307 lov_setstripe 2 22307 NULL
105992 +udpv6_sendmsg_22316 udpv6_sendmsg 4 22316 NULL
105993 +C_SYSC_msgrcv_22320 C_SYSC_msgrcv 3 22320 NULL
105994 +radix_tree_find_next_bit_22334 radix_tree_find_next_bit 3-2-0 22334 NULL
105995 +atomic_read_22342 atomic_read 0 22342 NULL
105996 +ll_lazystatfs_seq_write_22353 ll_lazystatfs_seq_write 3 22353 NULL
105997 +mlx4_db_alloc_22358 mlx4_db_alloc 3 22358 NULL
105998 +irq_reserve_irq_22360 irq_reserve_irq 1 22360 NULL nohasharray
105999 +memcg_size_22360 memcg_size 0 22360 &irq_reserve_irq_22360
106000 +snd_pcm_alsa_frames_22363 snd_pcm_alsa_frames 2 22363 NULL
106001 +tps6586x_gpio_to_irq_22365 tps6586x_gpio_to_irq 2 22365 NULL
106002 +evdev_ioctl_22371 evdev_ioctl 2 22371 NULL
106003 +alloc_large_system_hash_22391 alloc_large_system_hash 2-8-9 22391 NULL
106004 +ocfs2_assign_bh_22392 ocfs2_assign_bh 0 22392 NULL
106005 +zoran_write_22404 zoran_write 3 22404 NULL
106006 +ATOMIC_ADD_RETURN_22413 ATOMIC_ADD_RETURN 2 22413 NULL
106007 +queue_reply_22416 queue_reply 3 22416 NULL
106008 +__set_enter_print_fmt_22431 __set_enter_print_fmt 0 22431 NULL
106009 +queue_max_segments_22441 queue_max_segments 0 22441 NULL
106010 +_rtw_vmalloc_22444 _rtw_vmalloc 1 22444 NULL
106011 +handle_received_packet_22457 handle_received_packet 3 22457 NULL
106012 +mem_cgroup_read_22461 mem_cgroup_read 5 22461 NULL
106013 +btrfs_write_out_cache_22471 btrfs_write_out_cache 0 22471 NULL nohasharray
106014 +dtf_write_device_22471 dtf_write_device 3 22471 &btrfs_write_out_cache_22471
106015 +source_sink_start_ep_22472 source_sink_start_ep 0 22472 NULL
106016 +alloc_desc_22487 alloc_desc 2 22487 NULL
106017 +ecryptfs_write_22488 ecryptfs_write 4-3 22488 NULL
106018 +qib_user_sdma_alloc_header_22490 qib_user_sdma_alloc_header 2 22490 NULL
106019 +cache_write_procfs_22491 cache_write_procfs 3 22491 NULL
106020 +mp_find_ioapic_pin_22499 mp_find_ioapic_pin 0-2 22499 NULL
106021 +mutex_lock_interruptible_22505 mutex_lock_interruptible 0 22505 NULL
106022 +__btrfs_add_delayed_item_22511 __btrfs_add_delayed_item 0 22511 NULL
106023 +trim_no_bitmap_22524 trim_no_bitmap 4-3 22524 NULL
106024 +ocfs2_read_extent_block_22550 ocfs2_read_extent_block 0 22550 NULL
106025 +agp_alloc_page_array_22554 agp_alloc_page_array 1 22554 NULL
106026 +snd_pcm_hw_params_choose_22560 snd_pcm_hw_params_choose 0 22560 NULL
106027 +dbFindCtl_22587 dbFindCtl 0 22587 NULL
106028 +snapshot_read_22601 snapshot_read 3 22601 NULL
106029 +ocfs2_get_refcount_block_22610 ocfs2_get_refcount_block 0 22610 NULL
106030 +remove_breakpoint_22628 remove_breakpoint 3 22628 NULL
106031 +sctp_setsockopt_connectx_old_22631 sctp_setsockopt_connectx_old 3 22631 NULL
106032 +ide_core_cp_entry_22636 ide_core_cp_entry 3 22636 NULL
106033 +wl1271_rx_filter_get_fields_size_22638 wl1271_rx_filter_get_fields_size 0 22638 NULL
106034 +pwr_wake_on_timer_exp_read_22640 pwr_wake_on_timer_exp_read 3 22640 NULL
106035 +sysfs_attr_ns_22645 sysfs_attr_ns 0 22645 NULL
106036 +iwl_dbgfs_calib_disabled_read_22649 iwl_dbgfs_calib_disabled_read 3 22649 NULL
106037 +compat_SyS_msgrcv_22661 compat_SyS_msgrcv 3 22661 NULL
106038 +ubifs_leb_write_22679 ubifs_leb_write 4-5 22679 NULL nohasharray
106039 +ext4_ext_direct_IO_22679 ext4_ext_direct_IO 4 22679 &ubifs_leb_write_22679
106040 +fill_gap_22681 fill_gap 0 22681 NULL nohasharray
106041 +l2tp_ip_recvmsg_22681 l2tp_ip_recvmsg 4 22681 &fill_gap_22681
106042 +bch_dump_read_22685 bch_dump_read 3 22685 NULL
106043 +reg_umr_22686 reg_umr 5 22686 NULL
106044 +ocfs2_get_block_22687 ocfs2_get_block 2 22687 NULL
106045 +map_22700 map 2 22700 NULL nohasharray
106046 +btrfs_del_inode_ref_in_log_22700 btrfs_del_inode_ref_in_log 0 22700 &map_22700
106047 +alloc_libipw_22708 alloc_libipw 1 22708 NULL
106048 +ecryptfs_write_metadata_to_contents_22721 ecryptfs_write_metadata_to_contents 3 22721 NULL
106049 +cx18_copy_buf_to_user_22735 cx18_copy_buf_to_user 4-0 22735 NULL
106050 +ceph_decode_32_22738 ceph_decode_32 0 22738 NULL nohasharray
106051 +__mei_cl_send_22738 __mei_cl_send 3 22738 &ceph_decode_32_22738
106052 +iio_debugfs_write_reg_22742 iio_debugfs_write_reg 3 22742 NULL
106053 +qlcnic_sriov_init_22762 qlcnic_sriov_init 2 22762 NULL
106054 +print_frame_22769 print_frame 0 22769 NULL
106055 +ftrace_arch_read_dyn_info_22773 ftrace_arch_read_dyn_info 0 22773 NULL
106056 +ocfs2_block_group_alloc_22774 ocfs2_block_group_alloc 0 22774 NULL
106057 +pla_ocp_write_22802 pla_ocp_write 4 22802 NULL
106058 +__generic_copy_to_user_intel_22806 __generic_copy_to_user_intel 0-3 22806 NULL
106059 +clone_bio_integrity_22842 clone_bio_integrity 4 22842 NULL
106060 +read_file_rcstat_22854 read_file_rcstat 3 22854 NULL
106061 +create_attr_set_22861 create_attr_set 1 22861 NULL
106062 +vmw_execbuf_process_22885 vmw_execbuf_process 5 22885 NULL
106063 +usblp_new_writeurb_22894 usblp_new_writeurb 2 22894 NULL
106064 +mdc800_device_read_22896 mdc800_device_read 3 22896 NULL
106065 +policy_emit_config_values_22900 policy_emit_config_values 3 22900 NULL
106066 +__btrfs_add_free_space_22917 __btrfs_add_free_space 0 22917 NULL
106067 +xstateregs_set_22932 xstateregs_set 4 22932 NULL
106068 +pcpu_mem_zalloc_22948 pcpu_mem_zalloc 1 22948 NULL
106069 +alloc_sglist_22960 alloc_sglist 3-2 22960 NULL
106070 +caif_seqpkt_sendmsg_22961 caif_seqpkt_sendmsg 4 22961 NULL
106071 +vme_get_size_22964 vme_get_size 0 22964 NULL
106072 +tx_frag_key_not_found_read_22971 tx_frag_key_not_found_read 3 22971 NULL
106073 +cached_dev_cache_miss_22979 cached_dev_cache_miss 4 22979 NULL
106074 +usb_get_langid_22983 usb_get_langid 0 22983 NULL
106075 +set_msr_hyperv_22985 set_msr_hyperv 3 22985 NULL
106076 +remote_settings_file_write_22987 remote_settings_file_write 3 22987 NULL
106077 +brcmf_sdio_chip_exit_download_23001 brcmf_sdio_chip_exit_download 4 23001 NULL
106078 +viafb_dvp0_proc_write_23023 viafb_dvp0_proc_write 3 23023 NULL
106079 +cifs_local_to_utf16_bytes_23025 cifs_local_to_utf16_bytes 0 23025 NULL
106080 +ocfs2_refcount_cow_xattr_23029 ocfs2_refcount_cow_xattr 0-6-7 23029 NULL
106081 +st_status_23032 st_status 5 23032 NULL
106082 +nv50_disp_chan_create__23056 nv50_disp_chan_create_ 5 23056 NULL
106083 +comedi_buf_write_n_available_23057 comedi_buf_write_n_available 0 23057 NULL
106084 +reiserfs_add_entry_23062 reiserfs_add_entry 4 23062 NULL nohasharray
106085 +unix_seqpacket_recvmsg_23062 unix_seqpacket_recvmsg 4 23062 &reiserfs_add_entry_23062
106086 +mei_cl_send_23068 mei_cl_send 3 23068 NULL
106087 +filp_close_23071 filp_close 0 23071 NULL
106088 +kvm_mmu_gva_to_gpa_write_23075 kvm_mmu_gva_to_gpa_write 0 23075 NULL
106089 +vm_map_ram_23078 vm_map_ram 3 23078 NULL nohasharray
106090 +raw_sendmsg_23078 raw_sendmsg 4 23078 &vm_map_ram_23078
106091 +get_user_hdr_len_23079 get_user_hdr_len 0 23079 NULL
106092 +isr_tx_procs_read_23084 isr_tx_procs_read 3 23084 NULL
106093 +lnw_gpio_irq_map_23087 lnw_gpio_irq_map 2 23087 NULL
106094 +rt2x00debug_write_eeprom_23091 rt2x00debug_write_eeprom 3 23091 NULL
106095 +__add_prelim_ref_23095 __add_prelim_ref 0 23095 NULL
106096 +fls_long_23096 fls_long 0 23096 NULL
106097 +ntfs_ucstonls_23097 ntfs_ucstonls 5-3 23097 NULL
106098 +pipe_iov_copy_from_user_23102 pipe_iov_copy_from_user 3 23102 NULL
106099 +dgram_recvmsg_23104 dgram_recvmsg 4 23104 NULL
106100 +ip_recv_error_23109 ip_recv_error 3 23109 NULL
106101 +mwl8k_cmd_set_beacon_23110 mwl8k_cmd_set_beacon 4 23110 NULL
106102 +nl80211_send_rx_auth_23111 nl80211_send_rx_auth 4 23111 NULL
106103 +__clear_user_23118 __clear_user 0-2 23118 NULL
106104 +drm_mode_create_tv_properties_23122 drm_mode_create_tv_properties 2 23122 NULL
106105 +ata_scsi_change_queue_depth_23126 ata_scsi_change_queue_depth 2 23126 NULL
106106 +ext3_listxattr_23137 ext3_listxattr 3 23137 NULL
106107 +read_file_ani_23161 read_file_ani 3 23161 NULL
106108 +tg_get_cfs_quota_23176 tg_get_cfs_quota 0 23176 NULL
106109 +usblp_write_23178 usblp_write 3 23178 NULL
106110 +msnd_fifo_alloc_23179 msnd_fifo_alloc 2 23179 NULL
106111 +gss_pipe_downcall_23182 gss_pipe_downcall 3 23182 NULL
106112 +fix_unclean_leb_23188 fix_unclean_leb 3 23188 NULL
106113 +mpi_alloc_limb_space_23190 mpi_alloc_limb_space 1 23190 NULL
106114 +convert_ip_to_linear_23198 convert_ip_to_linear 0 23198 NULL
106115 +pm80x_free_irq_23210 pm80x_free_irq 2 23210 NULL
106116 +tty_buffer_request_room_23228 tty_buffer_request_room 2-0 23228 NULL
106117 +__read_status_pci_23229 __read_status_pci 0 23229 NULL nohasharray
106118 +xlog_get_bp_23229 xlog_get_bp 2 23229 &__read_status_pci_23229
106119 +ft1000_read_dpram_mag_32_23232 ft1000_read_dpram_mag_32 0 23232 NULL
106120 +rxrpc_client_sendmsg_23236 rxrpc_client_sendmsg 5 23236 NULL
106121 +__gfn_to_rmap_23240 __gfn_to_rmap 2-1 23240 NULL
106122 +sctp_recvmsg_23265 sctp_recvmsg 4 23265 NULL
106123 +uwb_dev_addr_print_23282 uwb_dev_addr_print 2 23282 NULL
106124 +diva_get_trace_filter_23286 diva_get_trace_filter 0 23286 NULL
106125 +gru_preload_tlb_23305 gru_preload_tlb 7-4 23305 NULL
106126 +i2cdev_write_23310 i2cdev_write 3 23310 NULL
106127 +__aa_kvmalloc_23320 __aa_kvmalloc 1 23320 NULL
106128 +__es_remove_extent_23323 __es_remove_extent 0 23323 NULL
106129 +page_readlink_23346 page_readlink 3 23346 NULL
106130 +kmem_zalloc_large_23351 kmem_zalloc_large 1 23351 NULL
106131 +get_dst_timing_23358 get_dst_timing 0 23358 NULL
106132 +fd_setup_write_same_buf_23369 fd_setup_write_same_buf 3 23369 NULL
106133 +iscsi_change_queue_depth_23416 iscsi_change_queue_depth 2 23416 NULL
106134 +vga_mm_r_23419 vga_mm_r 0 23419 NULL
106135 +vzalloc_node_23424 vzalloc_node 1-2 23424 NULL
106136 +vmemmap_populate_basepages_23435 vmemmap_populate_basepages 3 23435 NULL
106137 +__ctzsi2_23444 __ctzsi2 1 23444 NULL
106138 +ocfs2_zero_tail_23447 ocfs2_zero_tail 3 23447 NULL
106139 +hidraw_send_report_23449 hidraw_send_report 3 23449 NULL
106140 +__ata_change_queue_depth_23484 __ata_change_queue_depth 3-0 23484 NULL
106141 +linear_conf_23485 linear_conf 2 23485 NULL
106142 +copy_module_from_user_23492 copy_module_from_user 2 23492 NULL
106143 +event_filter_read_23494 event_filter_read 3 23494 NULL
106144 +ext4_remove_blocks_23497 ext4_remove_blocks 0 23497 NULL
106145 +lustre_acl_xattr_merge2ext_23502 lustre_acl_xattr_merge2ext 2 23502 NULL
106146 +__gfn_to_hva_many_23508 __gfn_to_hva_many 0-2 23508 NULL
106147 +devm_iio_device_alloc_23511 devm_iio_device_alloc 2 23511 NULL
106148 +__proc_cpt_table_23516 __proc_cpt_table 5 23516 NULL
106149 +ima_show_measurements_count_23536 ima_show_measurements_count 3 23536 NULL
106150 +__es_insert_extent_23543 __es_insert_extent 0 23543 NULL
106151 +xen_allocate_irq_gsi_23546 xen_allocate_irq_gsi 1-0 23546 NULL
106152 +tcp_current_mss_23552 tcp_current_mss 0 23552 NULL
106153 +dbg_leb_change_23555 dbg_leb_change 0-4 23555 NULL
106154 +btrfs_super_bytenr_23561 btrfs_super_bytenr 0 23561 NULL
106155 +venus_symlink_23570 venus_symlink 6-4 23570 NULL
106156 +iwl_dbgfs_interrupt_read_23574 iwl_dbgfs_interrupt_read 3 23574 NULL
106157 +xfpregs_get_23586 xfpregs_get 4 23586 NULL
106158 +snd_interval_min_23590 snd_interval_min 0 23590 NULL
106159 +do_mmap_pgoff_23600 do_mmap_pgoff 0 23600 NULL
106160 +islpci_mgt_transaction_23610 islpci_mgt_transaction 5 23610 NULL
106161 +ocfs2_journal_access_23616 ocfs2_journal_access 0 23616 NULL
106162 +alloc_pte_23642 alloc_pte 3 23642 NULL
106163 +__i2400mu_send_barker_23652 __i2400mu_send_barker 3 23652 NULL
106164 +sInW_23663 sInW 0 23663 NULL
106165 +SyS_connect_23669 SyS_connect 3 23669 NULL
106166 +cx18_read_23699 cx18_read 3 23699 NULL
106167 +btrfs_insert_delayed_item_23705 btrfs_insert_delayed_item 0 23705 NULL
106168 +at_get_23708 at_get 0 23708 NULL
106169 +snd_pcm_hw_refine_23721 snd_pcm_hw_refine 0 23721 NULL
106170 +mp_config_acpi_gsi_23728 mp_config_acpi_gsi 2 23728 NULL
106171 +rx_rx_dropped_frame_read_23748 rx_rx_dropped_frame_read 3 23748 NULL
106172 +__kfifo_max_r_23768 __kfifo_max_r 0-2-1 23768 NULL
106173 +svc_prepare_thread_23772 svc_prepare_thread 3 23772 NULL
106174 +__build_packet_message_23778 __build_packet_message 4-10 23778 NULL
106175 +security_inode_getxattr_23781 security_inode_getxattr 0 23781 NULL
106176 +cfg80211_inform_bss_width_frame_23782 cfg80211_inform_bss_width_frame 5 23782 NULL
106177 +mpt_free_res_23793 mpt_free_res 5 23793 NULL
106178 +map_write_23795 map_write 3 23795 NULL
106179 +diva_alloc_dma_map_23798 diva_alloc_dma_map 2 23798 NULL
106180 +rx_path_reset_read_23801 rx_path_reset_read 3 23801 NULL
106181 +ocfs2_replace_cow_23803 ocfs2_replace_cow 0 23803 NULL
106182 +__earlyonly_bootmem_alloc_23824 __earlyonly_bootmem_alloc 2 23824 NULL
106183 +lustre_msg_buflen_23827 lustre_msg_buflen 0 23827 NULL
106184 +ceph_copy_page_vector_to_user_23829 ceph_copy_page_vector_to_user 0-4-3 23829 NULL
106185 +tfrc_binsearch_23833 tfrc_binsearch 0 23833 NULL
106186 +pgdat_end_pfn_23842 pgdat_end_pfn 0 23842 NULL
106187 +iwl_dbgfs_nvm_read_23845 iwl_dbgfs_nvm_read 3 23845 NULL
106188 +p54_init_common_23850 p54_init_common 1 23850 NULL
106189 +gart_alloc_coherent_23852 gart_alloc_coherent 2 23852 NULL
106190 +bin_to_hex_dup_23853 bin_to_hex_dup 2 23853 NULL
106191 +ocfs2_xattr_get_clusters_23857 ocfs2_xattr_get_clusters 0 23857 NULL
106192 +ieee80211_if_read_dot11MeshMaxPeerLinks_23878 ieee80211_if_read_dot11MeshMaxPeerLinks 3 23878 NULL
106193 +nes_alloc_resource_23891 nes_alloc_resource 3 23891 NULL
106194 +_rtw_zvmalloc_23892 _rtw_zvmalloc 1 23892 NULL
106195 +tipc_snprintf_23893 tipc_snprintf 2-0 23893 NULL
106196 +usbg_prepare_w_request_23895 usbg_prepare_w_request 0 23895 NULL
106197 +add_new_gdb_meta_bg_23911 add_new_gdb_meta_bg 3 23911 NULL nohasharray
106198 +ieee80211_if_read_hw_queues_23911 ieee80211_if_read_hw_queues 3 23911 &add_new_gdb_meta_bg_23911
106199 +device_create_bin_file_23914 device_create_bin_file 0 23914 NULL
106200 +f2fs_getxattr_23917 f2fs_getxattr 0 23917 NULL
106201 +ipath_reg_phys_mr_23918 ipath_reg_phys_mr 3 23918 NULL nohasharray
106202 +mpihelp_mul_karatsuba_case_23918 mpihelp_mul_karatsuba_case 5-3 23918 &ipath_reg_phys_mr_23918
106203 +kvm_read_guest_23928 kvm_read_guest 4-2 23928 NULL nohasharray
106204 +intel_ring_alloc_seqno_23928 intel_ring_alloc_seqno 0 23928 &kvm_read_guest_23928
106205 +__alloc_skb_23940 __alloc_skb 4 23940 NULL
106206 +uvc_endpoint_max_bpi_23944 uvc_endpoint_max_bpi 0 23944 NULL
106207 +cifs_setxattr_23957 cifs_setxattr 4 23957 NULL
106208 +size_roundup_power2_23958 size_roundup_power2 0-1 23958 NULL
106209 +vfs_write_23971 vfs_write 0-3 23971 NULL
106210 +sddr55_write_data_23983 sddr55_write_data 4 23983 NULL
106211 +zd_usb_iowrite16v_async_23984 zd_usb_iowrite16v_async 3 23984 NULL
106212 +cxgb_alloc_mem_24007 cxgb_alloc_mem 1 24007 NULL
106213 +intel_ring_idle_24014 intel_ring_idle 0 24014 NULL
106214 +give_pages_24021 give_pages 3 24021 NULL
106215 +ocfs2_mark_extent_refcounted_24035 ocfs2_mark_extent_refcounted 6 24035 NULL
106216 +adis16400_show_serial_number_24037 adis16400_show_serial_number 3 24037 NULL
106217 +hmac_setkey_24043 hmac_setkey 3 24043 NULL
106218 +afs_cell_alloc_24052 afs_cell_alloc 2 24052 NULL
106219 +blkcipher_copy_iv_24075 blkcipher_copy_iv 3 24075 NULL
106220 +vb2_fop_read_24080 vb2_fop_read 3 24080 NULL
106221 +ocfs2_cannibalize_resv_24090 ocfs2_cannibalize_resv 3 24090 NULL
106222 +pipeline_post_proc_swi_read_24108 pipeline_post_proc_swi_read 3 24108 NULL
106223 +request_key_auth_read_24109 request_key_auth_read 3 24109 NULL
106224 +lov_brw_24122 lov_brw 4 24122 NULL
106225 +mpu401_read_24126 mpu401_read 3-0 24126 NULL
106226 +_picolcd_flash_write_24134 _picolcd_flash_write 4 24134 NULL
106227 +irnet_ctrl_write_24139 irnet_ctrl_write 3 24139 NULL
106228 +SyS_sethostname_24150 SyS_sethostname 2 24150 NULL
106229 +trim_bitmaps_24158 trim_bitmaps 3 24158 NULL
106230 +set_discard_24162 set_discard 2 24162 NULL
106231 +__copy_user_zeroing_intel_nocache_24163 __copy_user_zeroing_intel_nocache 0-3 24163 NULL
106232 +adu_read_24177 adu_read 3 24177 NULL
106233 +safe_prepare_write_buffer_24187 safe_prepare_write_buffer 3 24187 NULL
106234 +shrink_tnc_24190 shrink_tnc 0 24190 NULL
106235 +irq_remapping_setup_msi_irqs_24194 irq_remapping_setup_msi_irqs 2 24194 NULL
106236 +ieee80211_if_read_dot11MeshHWMPpreqMinInterval_24208 ieee80211_if_read_dot11MeshHWMPpreqMinInterval 3 24208 NULL
106237 +efx_vf_size_24213 efx_vf_size 0 24213 NULL
106238 +SyS_sendfile64_24220 SyS_sendfile64 4 24220 NULL
106239 +tcpprobe_sprint_24222 tcpprobe_sprint 0-2 24222 NULL
106240 +pcpu_embed_first_chunk_24224 pcpu_embed_first_chunk 3-2-1 24224 NULL nohasharray
106241 +mei_amthif_read_24224 mei_amthif_read 4 24224 &pcpu_embed_first_chunk_24224
106242 +pci_num_vf_24235 pci_num_vf 0 24235 NULL
106243 +sel_read_bool_24236 sel_read_bool 3 24236 NULL
106244 +dm_cache_save_hint_24257 dm_cache_save_hint 2 24257 NULL
106245 +em28xx_alloc_urbs_24260 em28xx_alloc_urbs 4-6 24260 NULL
106246 +calculate_sizes_24273 calculate_sizes 2 24273 NULL
106247 +thin_status_24278 thin_status 5 24278 NULL
106248 +msg_size_24288 msg_size 0 24288 NULL
106249 +ext2_free_blocks_24292 ext2_free_blocks 3-2 24292 NULL
106250 +i2c_smbus_check_pec_24297 i2c_smbus_check_pec 0 24297 NULL
106251 +map_page_24298 map_page 3-4 24298 NULL
106252 +gserial_connect_24302 gserial_connect 0 24302 NULL
106253 +btmrvl_pscmd_read_24308 btmrvl_pscmd_read 3 24308 NULL
106254 +reserve_metadata_bytes_24313 reserve_metadata_bytes 3-0 24313 NULL
106255 +ath6kl_add_bss_if_needed_24317 ath6kl_add_bss_if_needed 6 24317 NULL
106256 +ocfs2_direct_IO_get_blocks_24333 ocfs2_direct_IO_get_blocks 2 24333 NULL
106257 +si476x_radio_read_acf_blob_24336 si476x_radio_read_acf_blob 3 24336 NULL
106258 +kzalloc_node_24352 kzalloc_node 1-3 24352 NULL
106259 +qla2x00_handle_queue_full_24365 qla2x00_handle_queue_full 2 24365 NULL
106260 +cfi_read_pri_24366 cfi_read_pri 3 24366 NULL
106261 +btrfs_item_size_nr_24367 btrfs_item_size_nr 0 24367 NULL
106262 +igetword_24373 igetword 0 24373 NULL
106263 +max_io_len_24384 max_io_len 0-1 24384 NULL
106264 +mpt_alloc_res_24387 mpt_alloc_res 5 24387 NULL
106265 +osc_cur_grant_bytes_seq_write_24396 osc_cur_grant_bytes_seq_write 3 24396 NULL
106266 +pvr2_v4l2_ioctl_24398 pvr2_v4l2_ioctl 2 24398 NULL nohasharray
106267 +getxattr_24398 getxattr 4 24398 &pvr2_v4l2_ioctl_24398 nohasharray
106268 +__btrfs_write_out_cache_24398 __btrfs_write_out_cache 0 24398 &getxattr_24398
106269 +blk_update_bidi_request_24415 blk_update_bidi_request 3-4 24415 NULL
106270 +nvme_trans_log_supp_pages_24418 nvme_trans_log_supp_pages 3 24418 NULL
106271 +b43_debugfs_read_24425 b43_debugfs_read 3 24425 NULL
106272 +xenbus_file_read_24427 xenbus_file_read 3 24427 NULL
106273 +ieee80211_rx_mgmt_beacon_24430 ieee80211_rx_mgmt_beacon 3 24430 NULL
106274 +copy_and_ioctl_24434 copy_and_ioctl 4 24434 NULL
106275 +ixgbe_alloc_q_vector_24439 ixgbe_alloc_q_vector 6-4 24439 NULL
106276 +smk_user_access_24440 smk_user_access 3 24440 NULL nohasharray
106277 +rtw_set_wps_assoc_resp_24440 rtw_set_wps_assoc_resp 3 24440 &smk_user_access_24440
106278 +__push_leaf_left_24456 __push_leaf_left 0 24456 NULL
106279 +evdev_do_ioctl_24459 evdev_do_ioctl 2 24459 NULL
106280 +lbs_highsnr_write_24460 lbs_highsnr_write 3 24460 NULL
106281 +skb_copy_and_csum_datagram_iovec_24466 skb_copy_and_csum_datagram_iovec 2 24466 NULL nohasharray
106282 +ocfs2_write_cluster_by_desc_24466 ocfs2_write_cluster_by_desc 6-5 24466 &skb_copy_and_csum_datagram_iovec_24466
106283 +snd_pcm_hw_param_first_24487 snd_pcm_hw_param_first 0 24487 NULL
106284 +read_file_spec_scan_ctl_24491 read_file_spec_scan_ctl 3 24491 NULL
106285 +i915_gem_obj_offset_24494 i915_gem_obj_offset 0 24494 NULL
106286 +push_nodes_for_insert_24496 push_nodes_for_insert 0 24496 NULL
106287 +pd_video_read_24510 pd_video_read 3 24510 NULL
106288 +request_key_with_auxdata_24515 request_key_with_auxdata 4 24515 NULL
106289 +xfs_buf_get_map_24522 xfs_buf_get_map 3 24522 NULL
106290 +do_mpage_readpage_24536 do_mpage_readpage 3 24536 NULL
106291 +write_cache_pages_24562 write_cache_pages 0 24562 NULL
106292 +SyS_pselect6_24582 SyS_pselect6 1 24582 NULL
106293 +udf_compute_nr_groups_24594 udf_compute_nr_groups 0 24594 NULL
106294 +sensor_hub_get_physical_device_count_24605 sensor_hub_get_physical_device_count 0 24605 NULL nohasharray
106295 +lov_alloc_memmd_24605 lov_alloc_memmd 2 24605 &sensor_hub_get_physical_device_count_24605
106296 +SyS_poll_24620 SyS_poll 2 24620 NULL
106297 +kvm_pv_enable_async_pf_24637 kvm_pv_enable_async_pf 2 24637 NULL
106298 +context_alloc_24645 context_alloc 3 24645 NULL
106299 +blk_rq_err_bytes_24650 blk_rq_err_bytes 0 24650 NULL
106300 +btrfs_check_data_free_space_24692 btrfs_check_data_free_space 0 24692 NULL
106301 +datafab_write_data_24696 datafab_write_data 4 24696 NULL
106302 +intelfbhw_get_p1p2_24703 intelfbhw_get_p1p2 2 24703 NULL
106303 +simple_attr_read_24738 simple_attr_read 3 24738 NULL
106304 +qla2x00_change_queue_depth_24742 qla2x00_change_queue_depth 2 24742 NULL
106305 +get_dma_residue_24749 get_dma_residue 0 24749 NULL
106306 +ocfs2_cow_file_pos_24751 ocfs2_cow_file_pos 3 24751 NULL
106307 +kgdb_hex2mem_24755 kgdb_hex2mem 3 24755 NULL
106308 +kempld_read8_24756 kempld_read8 0 24756 NULL
106309 +ocfs2_read_blocks_24777 ocfs2_read_blocks 0 24777 NULL
106310 +datablob_hmac_verify_24786 datablob_hmac_verify 4 24786 NULL
106311 +cache_read_24790 cache_read 3 24790 NULL
106312 +__xfs_get_blocks_24791 __xfs_get_blocks 2 24791 NULL
106313 +i915_gem_check_wedge_24793 i915_gem_check_wedge 0 24793 NULL
106314 +user_regset_copyout_24796 user_regset_copyout 7 24796 NULL
106315 +kvm_read_guest_virt_helper_24804 kvm_read_guest_virt_helper 3-1 24804 NULL
106316 +__next_cpu_nr_24805 __next_cpu_nr 1 24805 NULL
106317 +sb_set_blocksize_24807 sb_set_blocksize 0-2 24807 NULL
106318 +ath6kl_fwlog_mask_write_24810 ath6kl_fwlog_mask_write 3 24810 NULL
106319 +comedi_buf_alloc_24822 comedi_buf_alloc 3 24822 NULL
106320 +net2272_read_24825 net2272_read 0 24825 NULL
106321 +snd_als4k_gcr_read_24840 snd_als4k_gcr_read 0 24840 NULL
106322 +btrfs_next_old_item_24843 btrfs_next_old_item 0 24843 NULL
106323 +xfs_free_file_space_24853 xfs_free_file_space 2-3 24853 NULL
106324 +snd_pcm_lib_buffer_bytes_24865 snd_pcm_lib_buffer_bytes 0 24865 NULL
106325 +pnp_alloc_24869 pnp_alloc 1 24869 NULL nohasharray
106326 +l2cap_create_basic_pdu_24869 l2cap_create_basic_pdu 3 24869 &pnp_alloc_24869
106327 +setup_buffering_24872 setup_buffering 3 24872 NULL
106328 +queues_read_24877 queues_read 3 24877 NULL
106329 +__vxge_hw_vp_initialize_24885 __vxge_hw_vp_initialize 2 24885 NULL
106330 +codec_list_read_file_24910 codec_list_read_file 3 24910 NULL
106331 +__btrfs_free_extent_24927 __btrfs_free_extent 7-0 24927 NULL nohasharray
106332 +v4l2_ctrl_new_24927 v4l2_ctrl_new 7 24927 &__btrfs_free_extent_24927
106333 +ocfs2_fiemap_24949 ocfs2_fiemap 4-3 24949 NULL
106334 +packet_sendmsg_24954 packet_sendmsg 4 24954 NULL
106335 +ensure_wear_leveling_24971 ensure_wear_leveling 0 24971 NULL
106336 +twl_i2c_write_u8_24976 twl_i2c_write_u8 3 24976 NULL
106337 +llc_ui_sendmsg_24987 llc_ui_sendmsg 4 24987 NULL
106338 +btrfs_update_delayed_inode_24988 btrfs_update_delayed_inode 0 24988 NULL
106339 +key_conf_hw_key_idx_read_25003 key_conf_hw_key_idx_read 3 25003 NULL
106340 +il_dbgfs_channels_read_25005 il_dbgfs_channels_read 3 25005 NULL
106341 +twl6030_irq_unmap_25014 twl6030_irq_unmap 2 25014 NULL
106342 +ni_660x_num_counters_25031 ni_660x_num_counters 0 25031 NULL
106343 +nfs_dns_resolve_name_25036 nfs_dns_resolve_name 3 25036 NULL
106344 +load_unaligned_zeropad_25050 load_unaligned_zeropad 0 25050 NULL
106345 +btrfs_stack_key_blockptr_25058 btrfs_stack_key_blockptr 0 25058 NULL
106346 +gs_buf_alloc_25067 gs_buf_alloc 2 25067 NULL
106347 +ll_track_pid_seq_write_25068 ll_track_pid_seq_write 3 25068 NULL
106348 +SYSC_listxattr_25072 SYSC_listxattr 3 25072 NULL
106349 +iwl_dbgfs_tx_flush_write_25091 iwl_dbgfs_tx_flush_write 3 25091 NULL
106350 +gfs2_iter_unstuffed_25099 gfs2_iter_unstuffed 0 25099 NULL nohasharray
106351 +blkg_path_25099 blkg_path 3 25099 &gfs2_iter_unstuffed_25099
106352 +snd_rawmidi_kernel_write_25106 snd_rawmidi_kernel_write 3 25106 NULL
106353 +fs32_to_cpu_25143 fs32_to_cpu 0 25143 NULL
106354 +record_new_ref_25154 record_new_ref 0 25154 NULL
106355 +ipath_init_qp_table_25167 ipath_init_qp_table 2 25167 NULL nohasharray
106356 +btrfs_delete_delayed_items_25167 btrfs_delete_delayed_items 0 25167 &ipath_init_qp_table_25167
106357 +kvm_mmu_notifier_change_pte_25169 kvm_mmu_notifier_change_pte 3 25169 NULL
106358 +sctp_getsockopt_local_addrs_25178 sctp_getsockopt_local_addrs 2 25178 NULL
106359 +res_counter_read_u64_25180 res_counter_read_u64 0 25180 NULL
106360 +send_create_inode_if_needed_25211 send_create_inode_if_needed 0 25211 NULL
106361 +security_socket_post_create_25221 security_socket_post_create 0 25221 NULL
106362 +ocfs2_block_check_compute_25223 ocfs2_block_check_compute 2 25223 NULL
106363 +dtf_write_string_25232 dtf_write_string 5 25232 NULL
106364 +mon_stat_read_25238 mon_stat_read 3 25238 NULL
106365 +nilfs_palloc_find_available_slot_25245 nilfs_palloc_find_available_slot 5-3 25245 NULL
106366 +stripe_status_25259 stripe_status 5 25259 NULL
106367 +snd_pcm_start_25273 snd_pcm_start 0 25273 NULL
106368 +crypto_alloc_instance2_25277 crypto_alloc_instance2 3 25277 NULL
106369 +vfs_writev_25278 vfs_writev 3 25278 NULL
106370 +l2tp_session_create_25286 l2tp_session_create 1 25286 NULL
106371 +ath9k_debugfs_read_buf_25316 ath9k_debugfs_read_buf 3 25316 NULL
106372 +rng_buffer_size_25348 rng_buffer_size 0 25348 NULL
106373 +SYSC_kexec_load_25361 SYSC_kexec_load 2 25361 NULL
106374 +rio_destid_next_25368 rio_destid_next 2-0 25368 NULL nohasharray
106375 +unix_mkname_25368 unix_mkname 0-2 25368 &rio_destid_next_25368
106376 +sel_read_mls_25369 sel_read_mls 3 25369 NULL
106377 +tc3589x_gpio_to_irq_25371 tc3589x_gpio_to_irq 2 25371 NULL
106378 +orphanize_inode_25382 orphanize_inode 0 25382 NULL
106379 +SyS_splice_25390 SyS_splice 5 25390 NULL
106380 +btrfs_update_reserved_bytes_25393 btrfs_update_reserved_bytes 0 25393 NULL
106381 +vsp1_entity_init_25407 vsp1_entity_init 3 25407 NULL
106382 +ebt_buf_add_pad_25413 ebt_buf_add_pad 0 25413 NULL
106383 +dai_list_read_file_25421 dai_list_read_file 3 25421 NULL
106384 +generic_file_buffered_write_25464 generic_file_buffered_write 4 25464 NULL
106385 +ipath_decode_err_25468 ipath_decode_err 3 25468 NULL
106386 +crypto_hash_digestsize_25469 crypto_hash_digestsize 0 25469 NULL
106387 +ocfs2_hamming_encode_25501 ocfs2_hamming_encode 3 25501 NULL
106388 +ivtv_buf_copy_from_user_25502 ivtv_buf_copy_from_user 4-0 25502 NULL
106389 +evm_init_hmac_25504 evm_init_hmac 0 25504 NULL
106390 +snd_pcm_plugin_build_25505 snd_pcm_plugin_build 5 25505 NULL
106391 +sb_permission_25523 sb_permission 0 25523 NULL
106392 +down_read_failed_25532 down_read_failed 2 25532 NULL
106393 +ext3_get_inode_loc_25542 ext3_get_inode_loc 0 25542 NULL
106394 +ieee80211_if_read_path_refresh_time_25545 ieee80211_if_read_path_refresh_time 3 25545 NULL
106395 +wimax_addr_scnprint_25548 wimax_addr_scnprint 2 25548 NULL
106396 +mgag200_ttm_tt_create_25550 mgag200_ttm_tt_create 2 25550 NULL
106397 +ht_print_chan_25556 ht_print_chan 0 25556 NULL
106398 +skb_tailroom_25567 skb_tailroom 0 25567 NULL
106399 +ping_recvmsg_25597 ping_recvmsg 4 25597 NULL nohasharray
106400 +find_extend_vma_25597 find_extend_vma 2 25597 &ping_recvmsg_25597
106401 +copy_user_generic_25611 copy_user_generic 0 25611 NULL
106402 +proc_coredump_filter_write_25625 proc_coredump_filter_write 3 25625 NULL
106403 +__get_user_pages_25628 __get_user_pages 0-3-4 25628 NULL nohasharray
106404 +befs_utf2nls_25628 befs_utf2nls 3 25628 &__get_user_pages_25628
106405 +__direct_map_25647 __direct_map 6-5 25647 NULL
106406 +ext2_try_to_allocate_25667 ext2_try_to_allocate 4-2-0 25667 NULL
106407 +aircable_prepare_write_buffer_25669 aircable_prepare_write_buffer 3 25669 NULL
106408 +lpfc_idiag_cmd_get_25672 lpfc_idiag_cmd_get 2 25672 NULL
106409 +sta_inactive_ms_read_25690 sta_inactive_ms_read 3 25690 NULL
106410 +sparse_mem_map_populate_25693 sparse_mem_map_populate 2 25693 NULL
106411 +ebitmap_start_positive_25703 ebitmap_start_positive 0 25703 NULL
106412 +wl1271_tx_enabled_rates_get_25712 wl1271_tx_enabled_rates_get 0 25712 NULL nohasharray
106413 +rx_filter_mc_filter_read_25712 rx_filter_mc_filter_read 3 25712 &wl1271_tx_enabled_rates_get_25712
106414 +ibmasm_new_command_25714 ibmasm_new_command 2 25714 NULL
106415 +ttm_tt_init_25717 ttm_tt_init 3 25717 NULL
106416 +sel_write_context_25726 sel_write_context 3 25726 NULL nohasharray
106417 +__alloc_bootmem_low_node_25726 __alloc_bootmem_low_node 2 25726 &sel_write_context_25726
106418 +ext2_find_near_25734 ext2_find_near 0 25734 NULL
106419 +__set_clear_dirty_25744 __set_clear_dirty 2 25744 NULL
106420 +cxgbi_device_portmap_create_25747 cxgbi_device_portmap_create 3 25747 NULL
106421 +dtf_write_channel_25748 dtf_write_channel 3 25748 NULL
106422 +event_rx_pool_read_25792 event_rx_pool_read 3 25792 NULL
106423 +sg_read_25799 sg_read 3 25799 NULL
106424 +system_enable_read_25815 system_enable_read 3 25815 NULL
106425 +realloc_buffer_25816 realloc_buffer 2 25816 NULL
106426 +ftrace_profile_init_25821 ftrace_profile_init 0 25821 NULL
106427 +mthca_map_user_db_25823 mthca_map_user_db 5 25823 NULL
106428 +pwr_missing_bcns_read_25824 pwr_missing_bcns_read 3 25824 NULL
106429 +parport_read_25855 parport_read 0 25855 NULL
106430 +xfs_dir2_sf_hdr_size_25858 xfs_dir2_sf_hdr_size 0 25858 NULL
106431 +key_attr_size_25865 key_attr_size 0 25865 NULL
106432 +ath6kl_regread_read_25884 ath6kl_regread_read 3 25884 NULL
106433 +run_delalloc_nocow_25896 run_delalloc_nocow 3-4 25896 NULL
106434 +sisusbcon_scroll_area_25899 sisusbcon_scroll_area 4-3 25899 NULL
106435 +lpfc_change_queue_depth_25905 lpfc_change_queue_depth 2 25905 NULL
106436 +nvme_trans_mode_page_create_25908 nvme_trans_mode_page_create 7-4 25908 NULL
106437 +do_jffs2_setxattr_25910 do_jffs2_setxattr 5 25910 NULL
106438 +rcname_read_25919 rcname_read 3 25919 NULL
106439 +snd_es1938_capture_copy_25930 snd_es1938_capture_copy 5 25930 NULL
106440 +key_flags_read_25931 key_flags_read 3 25931 NULL
106441 +copy_play_buf_25932 copy_play_buf 3 25932 NULL
106442 +flush_25957 flush 2 25957 NULL
106443 +video_register_device_25971 video_register_device 3 25971 NULL
106444 +udp_setsockopt_25985 udp_setsockopt 5 25985 NULL
106445 +lustre_msg_buflen_v2_25997 lustre_msg_buflen_v2 0 25997 NULL
106446 +ebt_compat_entry_padsize_26001 ebt_compat_entry_padsize 0 26001 NULL
106447 +blk_init_queue_node_26015 blk_init_queue_node 3 26015 NULL
106448 +SyS_process_vm_readv_26019 SyS_process_vm_readv 3-5 26019 NULL
106449 +irq_create_strict_mappings_26025 irq_create_strict_mappings 2-4 26025 NULL
106450 +xfs_xattr_acl_set_26028 xfs_xattr_acl_set 4 26028 NULL
106451 +mptscsih_change_queue_depth_26036 mptscsih_change_queue_depth 2 26036 NULL
106452 +selinux_inode_post_setxattr_26037 selinux_inode_post_setxattr 4 26037 NULL
106453 +tun_do_read_26047 tun_do_read 5 26047 NULL
106454 +make_bfloat_26056 make_bfloat 2 26056 NULL
106455 +keyctl_update_key_26061 keyctl_update_key 3 26061 NULL
106456 +rx_rx_wa_density_dropped_frame_read_26095 rx_rx_wa_density_dropped_frame_read 3 26095 NULL
106457 +__add_inline_refs_26096 __add_inline_refs 0 26096 NULL
106458 +dup_ref_26100 dup_ref 0 26100 NULL
106459 +intel_wrap_ring_buffer_26117 intel_wrap_ring_buffer 0 26117 NULL
106460 +read_sb_page_26119 read_sb_page 5 26119 NULL
106461 +__fswab64_26155 __fswab64 0 26155 NULL
106462 +copy_oldmem_page_26164 copy_oldmem_page 3 26164 NULL
106463 +ath6kl_roam_table_read_26166 ath6kl_roam_table_read 3 26166 NULL nohasharray
106464 +gfs2_xattr_acl_get_26166 gfs2_xattr_acl_get 0 26166 &ath6kl_roam_table_read_26166
106465 +disk_devt_26180 disk_devt 0 26180 NULL
106466 +cgroup_setxattr_26188 cgroup_setxattr 4 26188 NULL
106467 +ieee80211_if_fmt_dot11MeshTTL_26198 ieee80211_if_fmt_dot11MeshTTL 3 26198 NULL
106468 +xfs_idata_realloc_26199 xfs_idata_realloc 2 26199 NULL
106469 +mce_write_26201 mce_write 3 26201 NULL
106470 +SyS_splice_26206 SyS_splice 5 26206 NULL
106471 +mwifiex_regrdwr_write_26225 mwifiex_regrdwr_write 3 26225 NULL
106472 +_scsih_change_queue_depth_26230 _scsih_change_queue_depth 2 26230 NULL
106473 +rxrpc_recvmsg_26233 rxrpc_recvmsg 4 26233 NULL
106474 +bio_split_26235 bio_split 2 26235 NULL
106475 +btrfs_delayed_inode_reserve_metadata_26236 btrfs_delayed_inode_reserve_metadata 0 26236 NULL
106476 +ecryptfs_read_lower_page_segment_26244 ecryptfs_read_lower_page_segment 4 26244 NULL
106477 +do_setxattr_26264 do_setxattr 0 26264 NULL
106478 +crypto_ctxsize_26278 crypto_ctxsize 0 26278 NULL
106479 +apei_resources_request_26279 apei_resources_request 0 26279 NULL
106480 +wacom_set_device_mode_26280 wacom_set_device_mode 3 26280 NULL
106481 +ext2_find_goal_26306 ext2_find_goal 0 26306 NULL
106482 +snd_pcm_plug_client_channels_buf_26309 snd_pcm_plug_client_channels_buf 0-3 26309 NULL nohasharray
106483 +pax_get_random_long_26309 pax_get_random_long 0 26309 &snd_pcm_plug_client_channels_buf_26309
106484 +pwr_wake_on_host_read_26321 pwr_wake_on_host_read 3 26321 NULL
106485 +check_can_nocow_26336 check_can_nocow 2 26336 NULL
106486 +snd_vx_check_reg_bit_26344 snd_vx_check_reg_bit 0 26344 NULL
106487 +ocfs2_duplicate_clusters_by_page_26357 ocfs2_duplicate_clusters_by_page 5-0-6-3 26357 NULL
106488 +cifs_readdata_alloc_26360 cifs_readdata_alloc 1 26360 NULL
106489 +invalidate_inode_pages2_range_26403 invalidate_inode_pages2_range 0 26403 NULL
106490 +ntty_write_26404 ntty_write 3 26404 NULL
106491 +pagemap_read_26441 pagemap_read 3 26441 NULL
106492 +tower_read_26461 tower_read 3 26461 NULL nohasharray
106493 +enc_pools_add_pages_26461 enc_pools_add_pages 1 26461 &tower_read_26461 nohasharray
106494 +numa_cpu_node_26461 numa_cpu_node 0 26461 &enc_pools_add_pages_26461
106495 +memory_present_26470 memory_present 1 26470 NULL
106496 +ib_alloc_device_26483 ib_alloc_device 1 26483 NULL
106497 +ulong_write_file_26485 ulong_write_file 3 26485 NULL
106498 +dvb_ca_en50221_io_ioctl_26490 dvb_ca_en50221_io_ioctl 2 26490 NULL
106499 +vfio_pin_pages_26494 vfio_pin_pages 1 26494 NULL
106500 +read_vmcore_26501 read_vmcore 3 26501 NULL
106501 +uhid_char_write_26502 uhid_char_write 3 26502 NULL
106502 +vfio_pci_set_msi_trigger_26507 vfio_pci_set_msi_trigger 4-3 26507 NULL
106503 +iwl_dbgfs_rf_reset_read_26512 iwl_dbgfs_rf_reset_read 3 26512 NULL
106504 +SyS_rt_sigpending_26538 SyS_rt_sigpending 2 26538 NULL
106505 +rds_message_inc_copy_to_user_26540 rds_message_inc_copy_to_user 3 26540 NULL
106506 +__vhost_add_used_n_26554 __vhost_add_used_n 3 26554 NULL
106507 +qgroup_account_ref_step3_26558 qgroup_account_ref_step3 0 26558 NULL
106508 +dio_new_bio_26562 dio_new_bio 0 26562 NULL
106509 +kvm_iommu_put_pages_26571 kvm_iommu_put_pages 2 26571 NULL
106510 +rts51x_read_mem_26577 rts51x_read_mem 4 26577 NULL
106511 +regcache_set_reg_present_26598 regcache_set_reg_present 2 26598 NULL
106512 +__unmap_single_26604 __unmap_single 2-3 26604 NULL
106513 +dev_to_node_26617 dev_to_node 0 26617 NULL
106514 +iommu_alloc_26621 iommu_alloc 4 26621 NULL
106515 +pack_value_26625 pack_value 1 26625 NULL
106516 +pwr_fix_tsf_ps_read_26627 pwr_fix_tsf_ps_read 3 26627 NULL
106517 +drm_ht_find_item_26637 drm_ht_find_item 0 26637 NULL
106518 +process_extent_26646 process_extent 0 26646 NULL nohasharray
106519 +btrfs_lookup_inode_26646 btrfs_lookup_inode 0 26646 &process_extent_26646
106520 +irq_alloc_generic_chip_26650 irq_alloc_generic_chip 2 26650 NULL nohasharray
106521 +inb_p_26650 inb_p 0 26650 &irq_alloc_generic_chip_26650
106522 +usb_reset_device_26661 usb_reset_device 0 26661 NULL
106523 +cipso_v4_map_cat_rbm_hton_26680 cipso_v4_map_cat_rbm_hton 0 26680 NULL
106524 +nouveau_namedb_create__26732 nouveau_namedb_create_ 7 26732 NULL
106525 +SyS_fcntl_26737 SyS_fcntl 3 26737 NULL
106526 +pipeline_tcp_rx_stat_fifo_int_read_26745 pipeline_tcp_rx_stat_fifo_int_read 3 26745 NULL
106527 +bos_desc_26752 bos_desc 0 26752 NULL
106528 +snd_hda_get_raw_connections_26762 snd_hda_get_raw_connections 0 26762 NULL
106529 +dma_map_single_attrs_26779 dma_map_single_attrs 0 26779 NULL
106530 +cache_save_setup_26783 cache_save_setup 0 26783 NULL
106531 +qlcnic_alloc_sds_rings_26795 qlcnic_alloc_sds_rings 2 26795 NULL
106532 +cipso_v4_genopt_26812 cipso_v4_genopt 0 26812 NULL
106533 +iwl_trans_read_mem32_26825 iwl_trans_read_mem32 0 26825 NULL
106534 +smk_write_load_26829 smk_write_load 3 26829 NULL
106535 +ept_get_level1_sp_gpa_26831 ept_get_level1_sp_gpa 0 26831 NULL
106536 +__nodes_onto_26838 __nodes_onto 4 26838 NULL
106537 +scnprint_id_26842 scnprint_id 3-0 26842 NULL
106538 +ecryptfs_miscdev_write_26847 ecryptfs_miscdev_write 3 26847 NULL
106539 +tipc_conn_sendmsg_26867 tipc_conn_sendmsg 5 26867 NULL
106540 +ath6kl_create_qos_write_26879 ath6kl_create_qos_write 3 26879 NULL
106541 +svc_print_xprts_26881 svc_print_xprts 0 26881 NULL
106542 +cfg80211_process_auth_26916 cfg80211_process_auth 3 26916 NULL
106543 +x25_asy_change_mtu_26928 x25_asy_change_mtu 2 26928 NULL
106544 +compat_mtw_from_user_26932 compat_mtw_from_user 0 26932 NULL
106545 +scsi_tgt_copy_sense_26933 scsi_tgt_copy_sense 3 26933 NULL
106546 +pwr_ps_enter_read_26935 pwr_ps_enter_read 3 26935 NULL nohasharray
106547 +sctp_setsockopt_adaptation_layer_26935 sctp_setsockopt_adaptation_layer 3 26935 &pwr_ps_enter_read_26935
106548 +remove_from_bitmap_26939 remove_from_bitmap 0 26939 NULL
106549 +create_bm_block_list_26940 create_bm_block_list 0 26940 NULL
106550 +hecubafb_write_26942 hecubafb_write 3 26942 NULL
106551 +extract_entropy_user_26952 extract_entropy_user 3 26952 NULL nohasharray
106552 +do_trimming_26952 do_trimming 3 26952 &extract_entropy_user_26952
106553 +xlog_grant_push_ail_26972 xlog_grant_push_ail 2 26972 NULL
106554 +do_direct_IO_26979 do_direct_IO 0 26979 NULL
106555 +pcf857x_irq_domain_map_26998 pcf857x_irq_domain_map 2 26998 NULL
106556 +i2c_smbus_xfer_27006 i2c_smbus_xfer 0 27006 NULL
106557 +omfs_allocate_range_27034 omfs_allocate_range 3 27034 NULL
106558 +fill_read_buf_27036 fill_read_buf 0 27036 NULL
106559 +ufs_alloc_fragments_27059 ufs_alloc_fragments 3-0-2 27059 NULL
106560 +__videobuf_alloc_vb_27062 __videobuf_alloc_vb 1 27062 NULL
106561 +ext4_convert_unwritten_extents_27064 ext4_convert_unwritten_extents 4-3-0 27064 NULL
106562 +snd_pcm_lib_period_bytes_27071 snd_pcm_lib_period_bytes 0 27071 NULL
106563 +paravirt_read_msr_27077 paravirt_read_msr 0 27077 NULL
106564 +snd_mixer_oss_set_recsrc_27080 snd_mixer_oss_set_recsrc 2 27080 NULL
106565 +alloc_fdmem_27083 alloc_fdmem 1 27083 NULL
106566 +find_first_bit_27088 find_first_bit 0-2 27088 NULL
106567 +btmrvl_hscmd_write_27089 btmrvl_hscmd_write 3 27089 NULL
106568 +nes_reg_user_mr_27106 nes_reg_user_mr 2-3 27106 NULL
106569 +__devcgroup_inode_permission_27108 __devcgroup_inode_permission 0 27108 NULL
106570 +i915_gem_execbuffer_relocate_slow_27116 i915_gem_execbuffer_relocate_slow 0 27116 NULL
106571 +get_kernel_page_27133 get_kernel_page 0 27133 NULL
106572 +__ext4_handle_dirty_metadata_27137 __ext4_handle_dirty_metadata 0 27137 NULL
106573 +drbd_get_capacity_27141 drbd_get_capacity 0 27141 NULL
106574 +pms_capture_27142 pms_capture 4 27142 NULL
106575 +btmrvl_hscfgcmd_write_27143 btmrvl_hscfgcmd_write 3 27143 NULL
106576 +snd_compr_calc_avail_27165 snd_compr_calc_avail 0 27165 NULL
106577 +ieee80211_if_read_rc_rateidx_mask_5ghz_27183 ieee80211_if_read_rc_rateidx_mask_5ghz 3 27183 NULL
106578 +get_unaligned_be32_27184 get_unaligned_be32 0 27184 NULL
106579 +__intel_ring_begin_27197 __intel_ring_begin 0 27197 NULL
106580 +__sg_alloc_table_27198 __sg_alloc_table 0 27198 NULL
106581 +ocfs2_read_blocks_sync_27210 ocfs2_read_blocks_sync 0 27210 NULL
106582 +write_kmem_27225 write_kmem 3 27225 NULL
106583 +dbAllocAG_27228 dbAllocAG 0 27228 NULL
106584 +rxrpc_request_key_27235 rxrpc_request_key 3 27235 NULL
106585 +ocfs2_journal_access_path_27243 ocfs2_journal_access_path 0 27243 NULL
106586 +ll_track_gid_seq_write_27267 ll_track_gid_seq_write 3 27267 NULL
106587 +qfq_unblock_groups_27269 qfq_unblock_groups 2 27269 NULL
106588 +comedi_alloc_devpriv_27272 comedi_alloc_devpriv 2 27272 NULL
106589 +__dma_map_cont_27289 __dma_map_cont 5 27289 NULL
106590 +copy_from_buf_27308 copy_from_buf 2-4 27308 NULL
106591 +virtqueue_add_inbuf_27312 virtqueue_add_inbuf 3 27312 NULL
106592 +write_buf_27316 write_buf 0-3 27316 NULL
106593 +ocfs2_blocks_to_clusters_27327 ocfs2_blocks_to_clusters 0-2 27327 NULL
106594 +snd_pcm_oss_write2_27332 snd_pcm_oss_write2 3-0 27332 NULL
106595 +afs_cell_create_27346 afs_cell_create 2 27346 NULL
106596 +iwl_dbgfs_csr_write_27363 iwl_dbgfs_csr_write 3 27363 NULL
106597 +pcbit_stat_27364 pcbit_stat 2 27364 NULL
106598 +lz4_compress_crypto_27387 lz4_compress_crypto 3 27387 NULL
106599 +seq_read_27411 seq_read 3 27411 NULL
106600 +ib_dma_map_sg_27413 ib_dma_map_sg 0 27413 NULL nohasharray
106601 +zalloc_cpumask_var_node_27413 zalloc_cpumask_var_node 3 27413 &ib_dma_map_sg_27413
106602 +ieee80211_if_read_smps_27416 ieee80211_if_read_smps 3 27416 NULL
106603 +ocfs2_refcount_cal_cow_clusters_27422 ocfs2_refcount_cal_cow_clusters 0-3-4 27422 NULL nohasharray
106604 +evm_inode_init_security_27422 evm_inode_init_security 0 27422 &ocfs2_refcount_cal_cow_clusters_27422
106605 +cypress_write_27423 cypress_write 4 27423 NULL
106606 +vmemmap_populate_27442 vmemmap_populate 3 27442 NULL
106607 +sddr09_read_data_27447 sddr09_read_data 3 27447 NULL
106608 +ktime_to_us_27455 ktime_to_us 0 27455 NULL
106609 +sk_extract_addr_27474 sk_extract_addr 0 27474 NULL
106610 +v4l2_ctrl_new_std_menu_items_27487 v4l2_ctrl_new_std_menu_items 4 27487 NULL
106611 +hcd_buffer_alloc_27495 hcd_buffer_alloc 2 27495 NULL
106612 +qib_create_cq_27497 qib_create_cq 2 27497 NULL
106613 +ip_set_get_h32_27498 ip_set_get_h32 0 27498 NULL
106614 +btrfs_get_64_27499 btrfs_get_64 0 27499 NULL
106615 +ept_walk_addr_generic_27501 ept_walk_addr_generic 4 27501 NULL
106616 +garmin_read_process_27509 garmin_read_process 3 27509 NULL
106617 +oti_alloc_cookies_27510 oti_alloc_cookies 2 27510 NULL
106618 +ib_copy_to_udata_27525 ib_copy_to_udata 3 27525 NULL
106619 +snd_sonicvibes_getdmaa_27552 snd_sonicvibes_getdmaa 0 27552 NULL
106620 +SyS_fgetxattr_27571 SyS_fgetxattr 4 27571 NULL
106621 +sco_sock_recvmsg_27572 sco_sock_recvmsg 4 27572 NULL
106622 +libipw_alloc_txb_27579 libipw_alloc_txb 1 27579 NULL
106623 +read_flush_procfs_27642 read_flush_procfs 3 27642 NULL nohasharray
106624 +nl80211_send_connect_result_27642 nl80211_send_connect_result 5-7 27642 &read_flush_procfs_27642 nohasharray
106625 +ocfs2_direct_IO_27642 ocfs2_direct_IO 4 27642 &nl80211_send_connect_result_27642 nohasharray
106626 +ocfs2_xattr_ibody_get_27642 ocfs2_xattr_ibody_get 0 27642 &ocfs2_direct_IO_27642
106627 +add_new_gdb_27643 add_new_gdb 3 27643 NULL
106628 +btrfs_fallocate_27647 btrfs_fallocate 3-4 27647 NULL
106629 +qnx6_readpages_27657 qnx6_readpages 4 27657 NULL
106630 +cdrom_read_cdda_old_27664 cdrom_read_cdda_old 4 27664 NULL
106631 +record_changed_ref_27665 record_changed_ref 0 27665 NULL
106632 +iommu_pgsize_27677 iommu_pgsize 2-0 27677 NULL
106633 +ocfs2_extend_dir_27695 ocfs2_extend_dir 4 27695 NULL
106634 +fs_path_add_from_extent_buffer_27702 fs_path_add_from_extent_buffer 4-0 27702 NULL
106635 +evm_write_key_27715 evm_write_key 3 27715 NULL
106636 +ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol_27722 ieee80211_if_fmt_dot11MeshGateAnnouncementProtocol 3 27722 NULL
106637 +xfs_dir2_block_sfsize_27727 xfs_dir2_block_sfsize 0 27727 NULL
106638 +macvtap_skb_to_vnet_hdr_27747 macvtap_skb_to_vnet_hdr 0 27747 NULL
106639 +SyS_setsockopt_27759 SyS_setsockopt 5 27759 NULL
106640 +gpiochip_export_27776 gpiochip_export 0 27776 NULL
106641 +__lov_setstripe_27782 __lov_setstripe 2 27782 NULL
106642 +twl4030_set_gpio_dataout_27792 twl4030_set_gpio_dataout 1 27792 NULL
106643 +DivaSTraceGetMemotyRequirement_27797 DivaSTraceGetMemotyRequirement 0-1 27797 NULL
106644 +ttm_object_file_init_27804 ttm_object_file_init 2 27804 NULL nohasharray
106645 +SyS_readv_27804 SyS_readv 3 27804 &ttm_object_file_init_27804
106646 +mpihelp_mul_27805 mpihelp_mul 5-3 27805 NULL
106647 +fwtty_buffer_rx_27821 fwtty_buffer_rx 3 27821 NULL
106648 +hpt374_read_freq_27828 hpt374_read_freq 0 27828 NULL
106649 +init_header_complete_27833 init_header_complete 0 27833 NULL
106650 +read_profile_27859 read_profile 3 27859 NULL
106651 +sky2_pci_read16_27863 sky2_pci_read16 0 27863 NULL
106652 +ieee80211_if_read_dot11MeshHWMProotInterval_27873 ieee80211_if_read_dot11MeshHWMProotInterval 3 27873 NULL
106653 +process_all_extents_27879 process_all_extents 0 27879 NULL
106654 +unix_seqpacket_sendmsg_27893 unix_seqpacket_sendmsg 4 27893 NULL
106655 +gluebi_write_27905 gluebi_write 3-2 27905 NULL
106656 +SyS_ptrace_27924 SyS_ptrace 3 27924 NULL
106657 +bm_find_next_27929 bm_find_next 2 27929 NULL
106658 +check_mapped_name_27943 check_mapped_name 3 27943 NULL
106659 +i915_gem_execbuffer_reserve_object_27956 i915_gem_execbuffer_reserve_object 0 27956 NULL
106660 +tracing_clock_write_27961 tracing_clock_write 3 27961 NULL
106661 +tipc_media_addr_printf_27971 tipc_media_addr_printf 2 27971 NULL
106662 +device_register_27972 device_register 0 27972 NULL nohasharray
106663 +mic_rx_pkts_read_27972 mic_rx_pkts_read 3 27972 &device_register_27972
106664 +pci_enable_device_flags_27977 pci_enable_device_flags 0 27977 NULL
106665 +f2fs_bio_alloc_27983 f2fs_bio_alloc 2 27983 NULL
106666 +edt_ft5x06_debugfs_raw_data_read_28002 edt_ft5x06_debugfs_raw_data_read 3 28002 NULL
106667 +snd_rawmidi_write_28008 snd_rawmidi_write 3 28008 NULL
106668 +remove_extent_data_ref_28023 remove_extent_data_ref 0 28023 NULL
106669 +alloc_one_pg_vec_page_28031 alloc_one_pg_vec_page 1 28031 NULL
106670 +record_deleted_ref_28039 record_deleted_ref 0 28039 NULL
106671 +sctp_setsockopt_maxburst_28041 sctp_setsockopt_maxburst 3 28041 NULL
106672 +rts51x_xd_rw_28046 rts51x_xd_rw 3-4 28046 NULL
106673 +p9_fd_write_28050 p9_fd_write 3 28050 NULL
106674 +cx231xx_init_vbi_isoc_28053 cx231xx_init_vbi_isoc 3-2-4 28053 NULL
106675 +pool_status_28055 pool_status 5 28055 NULL
106676 +init_rs_non_canonical_28059 init_rs_non_canonical 1 28059 NULL
106677 +lpfc_idiag_mbxacc_read_28061 lpfc_idiag_mbxacc_read 3 28061 NULL
106678 +tx_frag_bad_mblk_num_read_28064 tx_frag_bad_mblk_num_read 3 28064 NULL
106679 +ext4_read_block_bitmap_nowait_28078 ext4_read_block_bitmap_nowait 2 28078 NULL
106680 +platform_get_irq_28088 platform_get_irq 0 28088 NULL
106681 +SyS_brk_28096 SyS_brk 1 28096 NULL
106682 +mmc_test_alloc_mem_28102 mmc_test_alloc_mem 2-3 28102 NULL
106683 +rx_defrag_need_defrag_read_28117 rx_defrag_need_defrag_read 3 28117 NULL
106684 +vgacon_adjust_height_28124 vgacon_adjust_height 2 28124 NULL
106685 +tipc_msg_init_28128 tipc_msg_init 4-2 28128 NULL
106686 +video_read_28148 video_read 3 28148 NULL
106687 +snd_midi_channel_alloc_set_28153 snd_midi_channel_alloc_set 1 28153 NULL
106688 +stats_dot11FCSErrorCount_read_28154 stats_dot11FCSErrorCount_read 3 28154 NULL
106689 +__add_reloc_root_28155 __add_reloc_root 0 28155 NULL
106690 +vread_28173 vread 0-3 28173 NULL
106691 +macvtap_get_user_28185 macvtap_get_user 4 28185 NULL
106692 +counter_free_res_28187 counter_free_res 5 28187 NULL
106693 +read_disk_sb_28188 read_disk_sb 2 28188 NULL
106694 +nouveau_mxm_create__28200 nouveau_mxm_create_ 4 28200 NULL
106695 +__exclude_logged_extent_28212 __exclude_logged_extent 2-0 28212 NULL
106696 +__qp_memcpy_from_queue_28220 __qp_memcpy_from_queue 3-4 28220 NULL
106697 +ocfs2_cow_sync_writeback_28221 ocfs2_cow_sync_writeback 0 28221 NULL
106698 +line6_alloc_sysex_buffer_28225 line6_alloc_sysex_buffer 4 28225 NULL
106699 +amd_nb_num_28228 amd_nb_num 0 28228 NULL
106700 +ext4_validate_block_bitmap_28243 ext4_validate_block_bitmap 3 28243 NULL
106701 +fuse_direct_IO_28275 fuse_direct_IO 4 28275 NULL
106702 +usemap_size_28281 usemap_size 0 28281 NULL
106703 +inline_xattr_size_28285 inline_xattr_size 0 28285 NULL
106704 +dma_map_sg_attrs_28289 dma_map_sg_attrs 0 28289 NULL
106705 +SyS_ppoll_28290 SyS_ppoll 2 28290 NULL
106706 +kstrtos16_from_user_28300 kstrtos16_from_user 2 28300 NULL
106707 +acpi_register_gsi_xen_28305 acpi_register_gsi_xen 2 28305 NULL nohasharray
106708 +nouveau_compat_ioctl_28305 nouveau_compat_ioctl 2 28305 &acpi_register_gsi_xen_28305
106709 +create_io_context_28306 create_io_context 2 28306 NULL
106710 +__mlock_vma_pages_range_28315 __mlock_vma_pages_range 2-3-0 28315 NULL
106711 +snd_pcm_oss_read_28317 snd_pcm_oss_read 3 28317 NULL
106712 +bm_entry_write_28338 bm_entry_write 3 28338 NULL
106713 +tcp_copy_to_iovec_28344 tcp_copy_to_iovec 3 28344 NULL
106714 +cpuset_spread_node_28351 cpuset_spread_node 0 28351 NULL nohasharray
106715 +snapshot_write_28351 snapshot_write 3 28351 &cpuset_spread_node_28351
106716 +xfs_iomap_write_unwritten_28365 xfs_iomap_write_unwritten 3-2 28365 NULL
106717 +dlmfs_file_read_28385 dlmfs_file_read 3 28385 NULL
106718 +tx_frag_cache_miss_read_28394 tx_frag_cache_miss_read 3 28394 NULL
106719 +bypass_pwup_write_28416 bypass_pwup_write 3 28416 NULL
106720 +subdev_ioctl_28417 subdev_ioctl 2 28417 NULL
106721 +get_extent_allocation_hint_28423 get_extent_allocation_hint 0 28423 NULL
106722 +ksocknal_alloc_tx_28426 ksocknal_alloc_tx 2 28426 NULL
106723 +mpage_readpages_28436 mpage_readpages 3 28436 NULL
106724 +snd_emu10k1_efx_read_28452 snd_emu10k1_efx_read 2 28452 NULL
106725 +key_mic_failures_read_28457 key_mic_failures_read 3 28457 NULL
106726 +alloc_irq_cpu_rmap_28459 alloc_irq_cpu_rmap 1 28459 NULL
106727 +vmw_du_crtc_cursor_set_28479 vmw_du_crtc_cursor_set 4-5 28479 NULL
106728 +ocfs2_backup_super_blkno_28484 ocfs2_backup_super_blkno 0-2 28484 NULL
106729 +__filemap_fdatawrite_28485 __filemap_fdatawrite 0 28485 NULL
106730 +clear_discard_28494 clear_discard 2 28494 NULL
106731 +ps_poll_upsd_utilization_read_28519 ps_poll_upsd_utilization_read 3 28519 NULL
106732 +__next_node_28521 __next_node 1-0 28521 NULL
106733 +i2400m_tx_stats_read_28527 i2400m_tx_stats_read 3 28527 NULL
106734 +sel_read_policycap_28544 sel_read_policycap 3 28544 NULL
106735 +run_delalloc_range_28545 run_delalloc_range 3-4 28545 NULL nohasharray
106736 +mptctl_getiocinfo_28545 mptctl_getiocinfo 2 28545 &run_delalloc_range_28545 nohasharray
106737 +aio_read_events_28545 aio_read_events 3 28545 &mptctl_getiocinfo_28545
106738 +sysfs_create_bin_file_28551 sysfs_create_bin_file 0 28551 NULL
106739 +b43legacy_debugfs_write_28556 b43legacy_debugfs_write 3 28556 NULL
106740 +i2o_msg_post_wait_mem_28558 i2o_msg_post_wait_mem 0 28558 NULL
106741 +asymmetric_verify_28567 asymmetric_verify 3 28567 NULL
106742 +oxygen_read32_28582 oxygen_read32 0 28582 NULL
106743 +ocfs2_read_dir_block_28587 ocfs2_read_dir_block 2 28587 NULL
106744 +extract_entropy_28604 extract_entropy 5-3 28604 NULL
106745 +kfifo_unused_28612 kfifo_unused 0 28612 NULL
106746 +mp_override_legacy_irq_28618 mp_override_legacy_irq 4 28618 NULL
106747 +snd_nm256_capture_copy_28622 snd_nm256_capture_copy 5-3 28622 NULL
106748 +setup_usemap_28636 setup_usemap 3-4 28636 NULL
106749 +qib_handle_6120_hwerrors_28642 qib_handle_6120_hwerrors 3 28642 NULL
106750 +p9_fcall_alloc_28652 p9_fcall_alloc 1 28652 NULL
106751 +read_nic_io_byte_28654 read_nic_io_byte 0 28654 NULL
106752 +btrfs_previous_item_28667 btrfs_previous_item 0 28667 NULL
106753 +blk_queue_resize_tags_28670 blk_queue_resize_tags 2 28670 NULL
106754 +__perf_sw_event_28684 __perf_sw_event 2 28684 NULL
106755 +SyS_setgroups16_28686 SyS_setgroups16 1 28686 NULL
106756 +kvm_mmu_get_page_28692 kvm_mmu_get_page 2 28692 NULL
106757 +balance_level_28707 balance_level 0 28707 NULL
106758 +drm_plane_init_28731 drm_plane_init 6 28731 NULL
106759 +alloc_irq_cfg_28734 alloc_irq_cfg 2 28734 NULL
106760 +spi_execute_28736 spi_execute 5 28736 NULL
106761 +snd_pcm_aio_write_28738 snd_pcm_aio_write 3 28738 NULL
106762 +read_file_btcoex_28743 read_file_btcoex 3 28743 NULL
106763 +max_hw_blocks_28748 max_hw_blocks 0 28748 NULL
106764 +rpc_pipe_generic_upcall_28766 rpc_pipe_generic_upcall 4 28766 NULL
106765 +atomic_inc_return_unchecked_28778 atomic_inc_return_unchecked 0 28778 NULL
106766 +ath6kl_get_num_reg_28780 ath6kl_get_num_reg 0 28780 NULL
106767 +btrfs_block_rsv_refill_28800 btrfs_block_rsv_refill 3 28800 NULL nohasharray
106768 +sel_write_member_28800 sel_write_member 3 28800 &btrfs_block_rsv_refill_28800
106769 +cgroup_file_read_28804 cgroup_file_read 3 28804 NULL
106770 +memory_bm_create_28814 memory_bm_create 0 28814 NULL
106771 +iwl_dbgfs_rxon_filter_flags_read_28832 iwl_dbgfs_rxon_filter_flags_read 3 28832 NULL
106772 +vp_request_msix_vectors_28849 vp_request_msix_vectors 2 28849 NULL
106773 +ipv6_renew_options_28867 ipv6_renew_options 5 28867 NULL
106774 +max_io_len_target_boundary_28879 max_io_len_target_boundary 0-1 28879 NULL
106775 +packet_sendmsg_spkt_28885 packet_sendmsg_spkt 4 28885 NULL
106776 +to_cblock_28899 to_cblock 0-1 28899 NULL
106777 +da9055_group_write_28904 da9055_group_write 2-3 28904 NULL
106778 +ps_upsd_timeouts_read_28924 ps_upsd_timeouts_read 3 28924 NULL
106779 +iwl_dbgfs_sleep_level_override_write_28925 iwl_dbgfs_sleep_level_override_write 3 28925 NULL
106780 +ocfs2_frozen_trigger_28929 ocfs2_frozen_trigger 4 28929 NULL
106781 +push_rx_28939 push_rx 3 28939 NULL
106782 +btrfs_trim_block_group_28963 btrfs_trim_block_group 4-3 28963 NULL
106783 +alloc_sched_domains_28972 alloc_sched_domains 1 28972 NULL
106784 +remap_pfn_range_28976 remap_pfn_range 3-4-2 28976 NULL
106785 +ext4_mb_add_groupinfo_28988 ext4_mb_add_groupinfo 2 28988 NULL
106786 +hci_sock_setsockopt_28993 hci_sock_setsockopt 5 28993 NULL
106787 +bin_uuid_28999 bin_uuid 3 28999 NULL
106788 +fd_execute_rw_29004 fd_execute_rw 3 29004 NULL nohasharray
106789 +offset_to_bitmap_29004 offset_to_bitmap 2 29004 &fd_execute_rw_29004
106790 +xz_dec_init_29029 xz_dec_init 2 29029 NULL
106791 +i915_gem_object_bind_to_vm_29035 i915_gem_object_bind_to_vm 0 29035 NULL
106792 +ieee80211_if_read_ht_opmode_29044 ieee80211_if_read_ht_opmode 3 29044 NULL
106793 +rxrpc_sendmsg_29049 rxrpc_sendmsg 4 29049 NULL nohasharray
106794 +ProcessGetHostMibs_29049 ProcessGetHostMibs 0 29049 &rxrpc_sendmsg_29049
106795 +btrfs_root_bytenr_29058 btrfs_root_bytenr 0 29058 NULL
106796 +iso_packets_buffer_init_29061 iso_packets_buffer_init 3-4 29061 NULL
106797 +roundup_64_29066 roundup_64 2-0-1 29066 NULL
106798 +lpfc_idiag_extacc_drivr_get_29067 lpfc_idiag_extacc_drivr_get 0-3 29067 NULL
106799 +sctp_getsockopt_assoc_stats_29074 sctp_getsockopt_assoc_stats 2 29074 NULL
106800 +iwl_dbgfs_log_event_write_29088 iwl_dbgfs_log_event_write 3 29088 NULL
106801 +i915_error_object_create_sized_29091 i915_error_object_create_sized 3 29091 NULL
106802 +init_cache_node_node_29092 init_cache_node_node 1 29092 NULL
106803 +isdn_ppp_write_29109 isdn_ppp_write 4 29109 NULL
106804 +snprintf_29125 snprintf 0 29125 NULL
106805 +iov_shorten_29130 iov_shorten 0 29130 NULL
106806 +proc_scsi_write_29142 proc_scsi_write 3 29142 NULL
106807 +alloc_irqs_from_29152 alloc_irqs_from 1-2-0-3 29152 NULL
106808 +kvm_mmu_notifier_clear_flush_young_29154 kvm_mmu_notifier_clear_flush_young 3 29154 NULL
106809 +drm_property_create_enum_29201 drm_property_create_enum 5 29201 NULL
106810 +wusb_prf_256_29203 wusb_prf_256 7 29203 NULL
106811 +__mm_populate_29204 __mm_populate 1-2 29204 NULL
106812 +do_shrinker_shrink_29208 do_shrinker_shrink 0 29208 NULL
106813 +rds_iw_inc_copy_to_user_29214 rds_iw_inc_copy_to_user 3 29214 NULL
106814 +iwl_dbgfs_temperature_read_29224 iwl_dbgfs_temperature_read 3 29224 NULL
106815 +nvme_trans_copy_from_user_29227 nvme_trans_copy_from_user 3 29227 NULL
106816 +irq_domain_add_linear_29236 irq_domain_add_linear 2 29236 NULL
106817 +recover_peb_29238 recover_peb 0-7-6 29238 NULL
106818 +evdev_handle_get_val_29242 evdev_handle_get_val 5-6 29242 NULL
106819 +rw_verify_area_29243 rw_verify_area 0-4 29243 NULL
106820 +security_context_to_sid_core_29248 security_context_to_sid_core 2 29248 NULL
106821 +block_div_29268 block_div 0-1-2 29268 NULL
106822 +prism2_set_genericelement_29277 prism2_set_genericelement 3 29277 NULL
106823 +bitmap_ord_to_pos_29279 bitmap_ord_to_pos 3 29279 NULL
106824 +ext4_fiemap_29296 ext4_fiemap 4 29296 NULL
106825 +sn9c102_read_29305 sn9c102_read 3 29305 NULL
106826 +replace_file_extents_29312 replace_file_extents 0 29312 NULL
106827 +__fuse_get_req_29315 __fuse_get_req 2 29315 NULL
106828 +lprocfs_write_helper_29323 lprocfs_write_helper 2 29323 NULL
106829 +kvm_handle_hva_29326 kvm_handle_hva 2 29326 NULL
106830 +tun_put_user_29337 tun_put_user 5 29337 NULL
106831 +__alloc_ei_netdev_29338 __alloc_ei_netdev 1 29338 NULL
106832 +ide_read_altstatus_29343 ide_read_altstatus 0 29343 NULL
106833 +l2cap_sock_setsockopt_old_29346 l2cap_sock_setsockopt_old 4 29346 NULL
106834 +gpiochip_find_base_29366 gpiochip_find_base 0-1 29366 NULL
106835 +ktime_us_delta_29375 ktime_us_delta 0 29375 NULL
106836 +mwifiex_cfg80211_mgmt_tx_29387 mwifiex_cfg80211_mgmt_tx 7 29387 NULL
106837 +pca953x_irq_setup_29407 pca953x_irq_setup 3 29407 NULL
106838 +btrfs_run_delayed_items_29428 btrfs_run_delayed_items 0 29428 NULL
106839 +mempool_create_29437 mempool_create 1 29437 NULL
106840 +crypto_ahash_alignmask_29445 crypto_ahash_alignmask 0 29445 NULL
106841 +p9_client_prepare_req_29448 p9_client_prepare_req 3 29448 NULL
106842 +ept_page_fault_29450 ept_page_fault 2 29450 NULL
106843 +__kmalloc_node_29455 __kmalloc_node 3 29455 NULL
106844 +validate_scan_freqs_29462 validate_scan_freqs 0 29462 NULL
106845 +SyS_flistxattr_29474 SyS_flistxattr 3 29474 NULL
106846 +do_register_entry_29478 do_register_entry 4 29478 NULL
106847 +simple_strtoul_29480 simple_strtoul 0 29480 NULL
106848 +sched_clock_local_29498 sched_clock_local 0 29498 NULL
106849 +btmrvl_pscmd_write_29504 btmrvl_pscmd_write 3 29504 NULL
106850 +btrfs_file_extent_disk_bytenr_29505 btrfs_file_extent_disk_bytenr 0 29505 NULL
106851 +write_file_regidx_29517 write_file_regidx 3 29517 NULL
106852 +atk_debugfs_ggrp_read_29522 atk_debugfs_ggrp_read 3 29522 NULL
106853 +_regmap_raw_write_29541 _regmap_raw_write 2-4 29541 NULL
106854 +vfs_read_29543 vfs_read 0-3 29543 NULL
106855 +set_brk_29551 set_brk 1-2 29551 NULL nohasharray
106856 +ftrace_write_29551 ftrace_write 3 29551 &set_brk_29551
106857 +idetape_queue_rw_tail_29562 idetape_queue_rw_tail 3 29562 NULL
106858 +leaf_dealloc_29566 leaf_dealloc 3 29566 NULL
106859 +kvm_read_guest_virt_system_29569 kvm_read_guest_virt_system 4-2 29569 NULL
106860 +p9_fd_read_29570 p9_fd_read 3 29570 NULL
106861 +lbs_lowsnr_read_29571 lbs_lowsnr_read 3 29571 NULL
106862 +iwl_dbgfs_missed_beacon_write_29586 iwl_dbgfs_missed_beacon_write 3 29586 NULL
106863 +pvr2_hdw_report_unlocked_29589 pvr2_hdw_report_unlocked 4-0 29589 NULL
106864 +dio_set_defer_completion_29599 dio_set_defer_completion 0 29599 NULL
106865 +slots_per_page_29601 slots_per_page 0 29601 NULL
106866 +osc_cached_mb_seq_write_29610 osc_cached_mb_seq_write 3 29610 NULL
106867 +nla_get_u16_29624 nla_get_u16 0 29624 NULL
106868 +tx_frag_cache_hit_read_29639 tx_frag_cache_hit_read 3 29639 NULL
106869 +sctp_make_abort_user_29654 sctp_make_abort_user 3 29654 NULL
106870 +sisusb_write_mem_bulk_29678 sisusb_write_mem_bulk 4 29678 NULL
106871 +tracepoint_probe_register_29688 tracepoint_probe_register 0 29688 NULL
106872 +__btrfs_setxattr_29689 __btrfs_setxattr 0 29689 NULL
106873 +jbd2_journal_restart_29692 jbd2_journal_restart 0 29692 NULL
106874 +lustre_posix_acl_xattr_2ext_29693 lustre_posix_acl_xattr_2ext 2 29693 NULL
106875 +posix_acl_from_xattr_29708 posix_acl_from_xattr 3 29708 NULL
106876 +probes_write_29711 probes_write 3 29711 NULL
106877 +read_cis_cache_29735 read_cis_cache 4 29735 NULL
106878 +xfs_new_eof_29737 xfs_new_eof 2 29737 NULL
106879 +std_nic_write_29752 std_nic_write 3 29752 NULL
106880 +dbAlloc_29794 dbAlloc 0 29794 NULL
106881 +ext4_trim_all_free_29806 ext4_trim_all_free 4-3-2 29806 NULL
106882 +tcp_sendpage_29829 tcp_sendpage 4 29829 NULL
106883 +scan_bitmap_block_29840 scan_bitmap_block 4 29840 NULL
106884 +__probe_kernel_write_29842 __probe_kernel_write 3 29842 NULL
106885 +kvm_read_hva_atomic_29848 kvm_read_hva_atomic 3 29848 NULL
106886 +count_partial_29850 count_partial 0 29850 NULL
106887 +radeon_ttm_tt_create_29859 radeon_ttm_tt_create 2 29859 NULL
106888 +solo_enc_alloc_29860 solo_enc_alloc 3 29860 NULL
106889 +ipv6_setsockopt_29871 ipv6_setsockopt 5 29871 NULL
106890 +tlv_put_29872 tlv_put 0 29872 NULL
106891 +scsi_end_request_29876 scsi_end_request 3 29876 NULL
106892 +changed_extent_29881 changed_extent 0 29881 NULL
106893 +crypto_aead_alignmask_29885 crypto_aead_alignmask 0 29885 NULL
106894 +lov_ost_pool_extend_29914 lov_ost_pool_extend 2 29914 NULL
106895 +write_file_queue_29922 write_file_queue 3 29922 NULL
106896 +ext4_xattr_set_acl_29930 ext4_xattr_set_acl 4 29930 NULL
106897 +__btrfs_getxattr_29947 __btrfs_getxattr 0 29947 NULL nohasharray
106898 +ipv6_recv_error_29947 ipv6_recv_error 3 29947 &__btrfs_getxattr_29947
106899 +diva_os_get_context_size_29983 diva_os_get_context_size 0 29983 NULL
106900 +arch_setup_dmar_msi_29992 arch_setup_dmar_msi 1 29992 NULL
106901 +vmci_host_setup_notify_30002 vmci_host_setup_notify 2 30002 NULL
106902 +dev_mem_write_30028 dev_mem_write 3 30028 NULL
106903 +alloc_netdev_mqs_30030 alloc_netdev_mqs 1 30030 NULL
106904 +scsi_vpd_inquiry_30040 scsi_vpd_inquiry 4 30040 NULL
106905 +drp_wmove_30043 drp_wmove 4 30043 NULL nohasharray
106906 +wrmalt_30043 wrmalt 0 30043 &drp_wmove_30043
106907 +mem_cgroup_charge_common_30047 mem_cgroup_charge_common 0 30047 NULL
106908 +SyS_write_30059 SyS_write 3 30059 NULL
106909 +cxgbi_ddp_reserve_30091 cxgbi_ddp_reserve 4 30091 NULL
106910 +snd_midi_channel_init_set_30092 snd_midi_channel_init_set 1 30092 NULL
106911 +rx_filter_data_filter_read_30098 rx_filter_data_filter_read 3 30098 NULL
106912 +defragment_dma_buffer_30113 defragment_dma_buffer 0 30113 NULL
106913 +spi_async_locked_30117 spi_async_locked 0 30117 NULL
106914 +calgary_unmap_page_30130 calgary_unmap_page 3-2 30130 NULL
106915 +recv_stream_30138 recv_stream 4 30138 NULL
106916 +u_memcpya_30139 u_memcpya 3-2 30139 NULL
106917 +elfcorehdr_read_30159 elfcorehdr_read 2 30159 NULL
106918 +alloc_switch_ctx_30165 alloc_switch_ctx 2 30165 NULL
106919 +expand_inode_data_30169 expand_inode_data 2-3 30169 NULL
106920 +btrfs_start_transaction_lflush_30178 btrfs_start_transaction_lflush 2 30178 NULL
106921 +mempool_create_page_pool_30189 mempool_create_page_pool 1 30189 NULL
106922 +drm_property_create_bitmask_30195 drm_property_create_bitmask 5 30195 NULL
106923 +snd_pcm_playback_forward_30201 snd_pcm_playback_forward 0-2 30201 NULL
106924 +usblp_ioctl_30203 usblp_ioctl 2 30203 NULL
106925 +read_4k_modal_eeprom_30212 read_4k_modal_eeprom 3 30212 NULL
106926 +bitmap_file_set_bit_30228 bitmap_file_set_bit 2 30228 NULL
106927 +shmem_unuse_inode_30263 shmem_unuse_inode 0 30263 NULL
106928 +rawv6_recvmsg_30265 rawv6_recvmsg 4 30265 NULL
106929 +hfsplus_trusted_setxattr_30270 hfsplus_trusted_setxattr 4 30270 NULL
106930 +isr_pci_pm_read_30271 isr_pci_pm_read 3 30271 NULL
106931 +compat_readv_30273 compat_readv 3 30273 NULL
106932 +lapic_register_intr_30279 lapic_register_intr 1 30279 NULL
106933 +skcipher_sendmsg_30290 skcipher_sendmsg 4 30290 NULL
106934 +pipeline_sec_frag_swi_read_30294 pipeline_sec_frag_swi_read 3 30294 NULL
106935 +tcp_sendmsg_30296 tcp_sendmsg 4 30296 NULL
106936 +osc_contention_seconds_seq_write_30305 osc_contention_seconds_seq_write 3 30305 NULL
106937 +drm_core_get_reg_ofs_30309 drm_core_get_reg_ofs 0 30309 NULL
106938 +ext4_acl_from_disk_30320 ext4_acl_from_disk 2 30320 NULL
106939 +i8254_read_30330 i8254_read 0 30330 NULL
106940 +generic_ptrace_pokedata_30338 generic_ptrace_pokedata 2 30338 NULL
106941 +resource_from_user_30341 resource_from_user 3 30341 NULL
106942 +o2nm_this_node_30342 o2nm_this_node 0 30342 NULL
106943 +__vmalloc_node_flags_30352 __vmalloc_node_flags 1-2 30352 NULL
106944 +kstrtou32_from_user_30361 kstrtou32_from_user 2 30361 NULL
106945 +inet_getid_30365 inet_getid 2 30365 NULL
106946 +C_SYSC_readv_30369 C_SYSC_readv 3 30369 NULL
106947 +blkdev_issue_zeroout_30392 blkdev_issue_zeroout 3-0 30392 NULL
106948 +c4iw_init_resource_30393 c4iw_init_resource 2-3 30393 NULL
106949 +get_kernel_pages_30397 get_kernel_pages 0 30397 NULL
106950 +_drbd_bm_find_next_zero_30415 _drbd_bm_find_next_zero 2 30415 NULL
106951 +ext3_xattr_list_30419 ext3_xattr_list 3 30419 NULL
106952 +vb2_fop_write_30420 vb2_fop_write 3 30420 NULL
106953 +tx_tx_template_prepared_read_30424 tx_tx_template_prepared_read 3 30424 NULL
106954 +mq_create_30425 mq_create 1 30425 NULL nohasharray
106955 +lstcon_session_info_30425 lstcon_session_info 6 30425 &mq_create_30425
106956 +ext4_ext_create_new_leaf_30428 ext4_ext_create_new_leaf 0 30428 NULL
106957 +enable_write_30456 enable_write 3 30456 NULL
106958 +pci_resource_alignment_30457 pci_resource_alignment 0 30457 NULL
106959 +tx_tx_template_programmed_read_30461 tx_tx_template_programmed_read 3 30461 NULL
106960 +urandom_read_30462 urandom_read 3 30462 NULL
106961 +zoran_ioctl_30465 zoran_ioctl 2 30465 NULL
106962 +i2c_ctrl_read_30467 i2c_ctrl_read 0 30467 NULL
106963 +send_rmdir_30470 send_rmdir 0 30470 NULL
106964 +i915_mutex_lock_interruptible_30474 i915_mutex_lock_interruptible 0 30474 NULL nohasharray
106965 +ocrdma_reg_user_mr_30474 ocrdma_reg_user_mr 2-3 30474 &i915_mutex_lock_interruptible_30474
106966 +write_head_30481 write_head 4 30481 NULL
106967 +adu_write_30487 adu_write 3 30487 NULL
106968 +dtim_interval_write_30489 dtim_interval_write 3 30489 NULL
106969 +btrfs_free_extent_30515 btrfs_free_extent 0 30515 NULL
106970 +dwc3_testmode_write_30516 dwc3_testmode_write 3 30516 NULL
106971 +debug_debug2_read_30526 debug_debug2_read 3 30526 NULL nohasharray
106972 +set_config_30526 set_config 0 30526 &debug_debug2_read_30526
106973 +disk_expand_part_tbl_30561 disk_expand_part_tbl 2 30561 NULL
106974 +set_le_30581 set_le 4 30581 NULL
106975 +from_cblock_30582 from_cblock 0-1 30582 NULL
106976 +blk_init_tags_30592 blk_init_tags 1 30592 NULL
106977 +i2c_hid_get_report_length_30598 i2c_hid_get_report_length 0 30598 NULL
106978 +sgl_map_user_pages_30610 sgl_map_user_pages 2-3-4 30610 NULL
106979 +SyS_msgrcv_30611 SyS_msgrcv 3 30611 NULL
106980 +macvtap_sendmsg_30629 macvtap_sendmsg 4 30629 NULL
106981 +ieee80211_if_read_dot11MeshAwakeWindowDuration_30631 ieee80211_if_read_dot11MeshAwakeWindowDuration 3 30631 NULL
106982 +compat_raw_setsockopt_30634 compat_raw_setsockopt 5 30634 NULL
106983 +mlx5_ib_alloc_fast_reg_page_list_30638 mlx5_ib_alloc_fast_reg_page_list 2 30638 NULL
106984 +SyS_listxattr_30647 SyS_listxattr 3 30647 NULL
106985 +agp_remap_30665 agp_remap 2 30665 NULL
106986 +jffs2_flash_read_30667 jffs2_flash_read 0 30667 NULL
106987 +ni_ai_fifo_read_30681 ni_ai_fifo_read 3 30681 NULL
106988 +dccp_setsockopt_ccid_30701 dccp_setsockopt_ccid 4 30701 NULL
106989 +lbs_wrbbp_write_30712 lbs_wrbbp_write 3 30712 NULL
106990 +ocfs2_find_cpos_for_left_leaf_30713 ocfs2_find_cpos_for_left_leaf 0 30713 NULL
106991 +__mutex_lock_common_30717 __mutex_lock_common 0 30717 NULL
106992 +lbs_debugfs_read_30721 lbs_debugfs_read 3 30721 NULL
106993 +snd_nm256_playback_silence_30727 snd_nm256_playback_silence 4-3 30727 NULL
106994 +snapshot_status_30744 snapshot_status 5 30744 NULL
106995 +fuse_conn_limit_write_30777 fuse_conn_limit_write 3 30777 NULL
106996 +SyS_pread64_30778 SyS_pread64 3 30778 NULL
106997 +btrfs_run_ordered_operations_30793 btrfs_run_ordered_operations 0 30793 NULL
106998 +smk_read_doi_30813 smk_read_doi 3 30813 NULL
106999 +SYSC_splice_30820 SYSC_splice 5 30820 NULL
107000 +xlog_grant_head_wait_30829 xlog_grant_head_wait 4 30829 NULL
107001 +get_kobj_path_length_30831 get_kobj_path_length 0 30831 NULL
107002 +sctp_setsockopt_auth_chunk_30843 sctp_setsockopt_auth_chunk 3 30843 NULL
107003 +cfg80211_rx_mgmt_30844 cfg80211_rx_mgmt 5 30844 NULL
107004 +wd_autoreset_write_30862 wd_autoreset_write 3 30862 NULL
107005 +ieee80211_if_fmt_dropped_frames_no_route_30884 ieee80211_if_fmt_dropped_frames_no_route 3 30884 NULL
107006 +pn_recvmsg_30887 pn_recvmsg 4 30887 NULL
107007 +sctp_setsockopt_rtoinfo_30941 sctp_setsockopt_rtoinfo 3 30941 NULL
107008 +find_free_dev_extent_30963 find_free_dev_extent 0 30963 NULL
107009 +tty_insert_flip_string_flags_30969 tty_insert_flip_string_flags 4 30969 NULL
107010 +huge_page_mask_30981 huge_page_mask 0 30981 NULL
107011 +read_file_bt_ant_diversity_30983 read_file_bt_ant_diversity 3 30983 NULL
107012 +lbs_host_sleep_read_31013 lbs_host_sleep_read 3 31013 NULL
107013 +do_setup_msi_irqs_31043 do_setup_msi_irqs 2 31043 NULL
107014 +stride_pg_count_31053 stride_pg_count 0-2-1-4-3-5 31053 NULL
107015 +lbs_failcount_read_31063 lbs_failcount_read 3 31063 NULL
107016 +find_next_bit_le_31064 find_next_bit_le 0-2-3 31064 NULL
107017 +sctp_setsockopt_context_31091 sctp_setsockopt_context 3 31091 NULL
107018 +proc_gid_map_write_31093 proc_gid_map_write 3 31093 NULL
107019 +compat_sys_get_mempolicy_31109 compat_sys_get_mempolicy 3 31109 NULL
107020 +si_calculate_power_efficiency_ratio_31111 si_calculate_power_efficiency_ratio 3-2 31111 NULL
107021 +depth_read_31112 depth_read 3 31112 NULL
107022 +kimage_normal_alloc_31140 kimage_normal_alloc 3 31140 NULL
107023 +size_inside_page_31141 size_inside_page 0-1-2 31141 NULL
107024 +w9966_v4l_read_31148 w9966_v4l_read 3 31148 NULL
107025 +ch_do_scsi_31171 ch_do_scsi 4 31171 NULL
107026 +crypto_rng_seedsize_31196 crypto_rng_seedsize 0 31196 NULL
107027 +r592_read_fifo_pio_31198 r592_read_fifo_pio 3 31198 NULL
107028 +mtdchar_readoob_31200 mtdchar_readoob 4 31200 NULL
107029 +__btrfs_free_reserved_extent_31207 __btrfs_free_reserved_extent 2 31207 NULL
107030 +kvm_mmu_page_fault_31213 kvm_mmu_page_fault 2 31213 NULL
107031 +cpumask_weight_31215 cpumask_weight 0 31215 NULL
107032 +__read_reg_31216 __read_reg 0 31216 NULL
107033 +atm_get_addr_31221 atm_get_addr 3 31221 NULL
107034 +ulist_rbtree_insert_31235 ulist_rbtree_insert 0 31235 NULL
107035 +tcp_recvmsg_31238 tcp_recvmsg 4 31238 NULL
107036 +cyy_readb_31240 cyy_readb 0 31240 NULL
107037 +_create_sg_bios_31244 _create_sg_bios 4 31244 NULL
107038 +ieee80211_if_read_last_beacon_31257 ieee80211_if_read_last_beacon 3 31257 NULL
107039 +sctp_tsnmap_find_gap_ack_31272 sctp_tsnmap_find_gap_ack 3-2 31272 NULL
107040 +uvc_simplify_fraction_31303 uvc_simplify_fraction 3 31303 NULL
107041 +push_leaf_left_31306 push_leaf_left 0 31306 NULL
107042 +sisusbcon_scroll_31315 sisusbcon_scroll 5-2-3 31315 NULL
107043 +command_file_write_31318 command_file_write 3 31318 NULL
107044 +ext4_xattr_block_list_31325 ext4_xattr_block_list 3 31325 NULL
107045 +hwerr_crcbits_31334 hwerr_crcbits 4 31334 NULL
107046 +radix_tree_insert_31336 radix_tree_insert 0 31336 NULL
107047 +em28xx_init_usb_xfer_31337 em28xx_init_usb_xfer 4-6 31337 NULL
107048 +__cpu_to_node_31345 __cpu_to_node 0 31345 NULL
107049 +outlen_write_31358 outlen_write 3 31358 NULL
107050 +ieee80211_rx_mgmt_auth_31366 ieee80211_rx_mgmt_auth 3 31366 NULL
107051 +xprt_rdma_allocate_31372 xprt_rdma_allocate 2 31372 NULL
107052 +vb2_vmalloc_get_userptr_31374 vb2_vmalloc_get_userptr 2-3 31374 NULL
107053 +trace_parser_get_init_31379 trace_parser_get_init 2 31379 NULL
107054 +inb_31388 inb 0 31388 NULL
107055 +key_ifindex_read_31411 key_ifindex_read 3 31411 NULL
107056 +i915_gem_object_put_fence_31413 i915_gem_object_put_fence 0 31413 NULL
107057 +_sp2d_max_pg_31422 _sp2d_max_pg 0 31422 NULL
107058 +TSS_checkhmac1_31429 TSS_checkhmac1 5 31429 NULL
107059 +snd_aw2_saa7146_get_hw_ptr_capture_31431 snd_aw2_saa7146_get_hw_ptr_capture 0 31431 NULL
107060 +acpi_sci_ioapic_setup_31445 acpi_sci_ioapic_setup 4 31445 NULL
107061 +transport_alloc_session_tags_31449 transport_alloc_session_tags 2-3 31449 NULL
107062 +opera1_xilinx_rw_31453 opera1_xilinx_rw 5 31453 NULL
107063 +register_ftrace_graph_31456 register_ftrace_graph 0 31456 NULL
107064 +input_get_new_minor_31464 input_get_new_minor 1 31464 NULL
107065 +do_fcntl_31468 do_fcntl 3 31468 NULL
107066 +xfs_btree_get_numrecs_31477 xfs_btree_get_numrecs 0 31477 NULL
107067 +__ext4_journal_get_write_access_31482 __ext4_journal_get_write_access 0 31482 NULL
107068 +alg_setkey_31485 alg_setkey 3 31485 NULL
107069 +rds_message_map_pages_31487 rds_message_map_pages 2 31487 NULL
107070 +qsfp_2_read_31491 qsfp_2_read 3 31491 NULL
107071 +__alloc_bootmem_31498 __alloc_bootmem 1 31498 NULL
107072 +nouveau_mc_create__31513 nouveau_mc_create_ 5 31513 NULL
107073 +hidraw_write_31536 hidraw_write 3 31536 NULL
107074 +mtd_div_by_eb_31543 mtd_div_by_eb 0-1 31543 NULL
107075 +usbvision_read_31555 usbvision_read 3 31555 NULL
107076 +tx_frag_tkip_called_read_31575 tx_frag_tkip_called_read 3 31575 NULL
107077 +get_max_inline_xattr_value_size_31578 get_max_inline_xattr_value_size 0 31578 NULL
107078 +osst_write_31581 osst_write 3 31581 NULL
107079 +snd_compr_get_avail_31584 snd_compr_get_avail 0 31584 NULL
107080 +iwl_dbgfs_ucode_tx_stats_read_31611 iwl_dbgfs_ucode_tx_stats_read 3 31611 NULL
107081 +mtd_get_user_prot_info_31616 mtd_get_user_prot_info 0 31616 NULL
107082 +arvo_sysfs_read_31617 arvo_sysfs_read 6 31617 NULL
107083 +videobuf_read_one_31637 videobuf_read_one 3 31637 NULL
107084 +pod_alloc_sysex_buffer_31651 pod_alloc_sysex_buffer 3 31651 NULL
107085 +xfer_secondary_pool_31661 xfer_secondary_pool 2 31661 NULL
107086 +emulator_set_cr_31665 emulator_set_cr 3 31665 NULL
107087 +__lgread_31668 __lgread 4 31668 NULL
107088 +forced_ps_read_31685 forced_ps_read 3 31685 NULL
107089 +fst_recover_rx_error_31687 fst_recover_rx_error 3 31687 NULL
107090 +reiserfs_in_journal_31689 reiserfs_in_journal 3 31689 NULL
107091 +gfn_to_hva_read_31728 gfn_to_hva_read 2 31728 NULL
107092 +utf16s_to_utf8s_31735 utf16s_to_utf8s 0 31735 NULL nohasharray
107093 +lu_buf_check_and_grow_31735 lu_buf_check_and_grow 2 31735 &utf16s_to_utf8s_31735
107094 +shmem_pwrite_slow_31741 shmem_pwrite_slow 3-2 31741 NULL
107095 +NCR_700_change_queue_depth_31742 NCR_700_change_queue_depth 2 31742 NULL nohasharray
107096 +input_abs_get_max_31742 input_abs_get_max 0 31742 &NCR_700_change_queue_depth_31742
107097 +muldiv64_31743 muldiv64 3-2-0 31743 NULL
107098 +stmpe_set_altfunc_31750 stmpe_set_altfunc 2 31750 NULL nohasharray
107099 +bcm_char_read_31750 bcm_char_read 3 31750 &stmpe_set_altfunc_31750
107100 +snd_seq_device_new_31753 snd_seq_device_new 4 31753 NULL
107101 +SyS_lsetxattr_31766 SyS_lsetxattr 4 31766 NULL
107102 +usblp_cache_device_id_string_31790 usblp_cache_device_id_string 0 31790 NULL
107103 +ecryptfs_send_message_locked_31801 ecryptfs_send_message_locked 2 31801 NULL
107104 +isr_rx_procs_read_31804 isr_rx_procs_read 3 31804 NULL
107105 +data_write_31805 data_write 3 31805 NULL
107106 +SyS_msgsnd_31814 SyS_msgsnd 3 31814 NULL
107107 +strnlen_user_31815 strnlen_user 0-2 31815 NULL
107108 +sta_last_signal_read_31818 sta_last_signal_read 3 31818 NULL
107109 +fsnotify_perm_31843 fsnotify_perm 0 31843 NULL
107110 +SyS_ppoll_31855 SyS_ppoll 2 31855 NULL
107111 +iwl_dbgfs_disable_ht40_write_31876 iwl_dbgfs_disable_ht40_write 3 31876 NULL
107112 +drm_mode_crtc_set_gamma_size_31881 drm_mode_crtc_set_gamma_size 2 31881 NULL
107113 +ddb_output_write_31902 ddb_output_write 3-0 31902 NULL
107114 +xattr_permission_31907 xattr_permission 0 31907 NULL
107115 +lu_buf_realloc_31915 lu_buf_realloc 2 31915 NULL
107116 +new_dir_31919 new_dir 3 31919 NULL
107117 +kmem_alloc_31920 kmem_alloc 1 31920 NULL
107118 +guestwidth_to_adjustwidth_31937 guestwidth_to_adjustwidth 0-1 31937 NULL
107119 +process_recorded_refs_if_needed_31938 process_recorded_refs_if_needed 0 31938 NULL
107120 +SYSC_sethostname_31940 SYSC_sethostname 2 31940 NULL
107121 +iov_iter_copy_from_user_31942 iov_iter_copy_from_user 4-0 31942 NULL nohasharray
107122 +read_mem_31942 read_mem 3 31942 &iov_iter_copy_from_user_31942
107123 +vb2_write_31948 vb2_write 3 31948 NULL
107124 +pvr2_ctrl_get_valname_31951 pvr2_ctrl_get_valname 4 31951 NULL
107125 +regcache_rbtree_sync_31964 regcache_rbtree_sync 2 31964 NULL
107126 +copy_from_user_toio_31966 copy_from_user_toio 3 31966 NULL
107127 +mtd_add_partition_31971 mtd_add_partition 3 31971 NULL
107128 +btrfs_insert_empty_inode_31975 btrfs_insert_empty_inode 0 31975 NULL
107129 +vx_read_status_31982 vx_read_status 0 31982 NULL nohasharray
107130 +iblock_execute_rw_31982 iblock_execute_rw 3 31982 &vx_read_status_31982
107131 +find_next_zero_bit_31990 find_next_zero_bit 3-2-0 31990 NULL
107132 +default_setup_hpet_msi_31991 default_setup_hpet_msi 1 31991 NULL
107133 +lustre_acl_xattr_merge2posix_31992 lustre_acl_xattr_merge2posix 2 31992 NULL
107134 +sysfs_create_file_31996 sysfs_create_file 0 31996 NULL
107135 +tps6586x_irq_map_32002 tps6586x_irq_map 2 32002 NULL
107136 +calc_hmac_32010 calc_hmac 3 32010 NULL
107137 +vmcs_read64_32012 vmcs_read64 0 32012 NULL
107138 +resource_alignment_32020 resource_alignment 0 32020 NULL
107139 +aead_len_32021 aead_len 0 32021 NULL
107140 +ocfs2_remove_extent_32032 ocfs2_remove_extent 4-3-0 32032 NULL
107141 +posix_acl_set_32037 posix_acl_set 4 32037 NULL
107142 +stk_read_32038 stk_read 3 32038 NULL
107143 +vmw_cursor_update_dmabuf_32045 vmw_cursor_update_dmabuf 3-4 32045 NULL
107144 +ocfs2_update_edge_lengths_32046 ocfs2_update_edge_lengths 0 32046 NULL
107145 +SYSC_llistxattr_32061 SYSC_llistxattr 3 32061 NULL
107146 +proc_scsi_devinfo_write_32064 proc_scsi_devinfo_write 3 32064 NULL
107147 +cow_file_range_inline_32091 cow_file_range_inline 3 32091 NULL
107148 +bio_alloc_32095 bio_alloc 2 32095 NULL
107149 +alloc_pwms_32100 alloc_pwms 1-2 32100 NULL
107150 +ath6kl_fwlog_read_32101 ath6kl_fwlog_read 3 32101 NULL
107151 +disk_status_32120 disk_status 4 32120 NULL
107152 +kobject_add_internal_32133 kobject_add_internal 0 32133 NULL
107153 +btrfs_split_item_32164 btrfs_split_item 0 32164 NULL
107154 +venus_link_32165 venus_link 5 32165 NULL
107155 +do_writepages_32173 do_writepages 0 32173 NULL nohasharray
107156 +ntfs_rl_realloc_nofail_32173 ntfs_rl_realloc_nofail 3 32173 &do_writepages_32173
107157 +load_header_32183 load_header 0 32183 NULL
107158 +ubi_wl_scrub_peb_32196 ubi_wl_scrub_peb 0 32196 NULL
107159 +wusb_ccm_mac_32199 wusb_ccm_mac 7 32199 NULL
107160 +__mem_cgroup_try_charge_swapin_32204 __mem_cgroup_try_charge_swapin 0 32204 NULL
107161 +riva_get_cmap_len_32218 riva_get_cmap_len 0 32218 NULL
107162 +caif_seqpkt_recvmsg_32241 caif_seqpkt_recvmsg 4 32241 NULL
107163 +lbs_lowrssi_read_32242 lbs_lowrssi_read 3 32242 NULL
107164 +ocfs2_xattr_find_entry_32260 ocfs2_xattr_find_entry 0 32260 NULL
107165 +vmalloc_user_32308 vmalloc_user 1 32308 NULL
107166 +kvm_set_spte_hva_32312 kvm_set_spte_hva 2 32312 NULL
107167 +cas_calc_tabort_32316 cas_calc_tabort 0 32316 NULL
107168 +SyS_select_32319 SyS_select 1 32319 NULL
107169 +nouveau_bar_create__32332 nouveau_bar_create_ 4 32332 NULL
107170 +nl80211_send_mlme_event_32337 nl80211_send_mlme_event 4 32337 NULL
107171 +apic_get_tmcct_32338 apic_get_tmcct 0 32338 NULL
107172 +t4_alloc_mem_32342 t4_alloc_mem 1 32342 NULL
107173 +dispatch_ioctl_32357 dispatch_ioctl 2 32357 NULL nohasharray
107174 +rx_streaming_always_write_32357 rx_streaming_always_write 3 32357 &dispatch_ioctl_32357
107175 +sel_read_initcon_32362 sel_read_initcon 3 32362 NULL nohasharray
107176 +ReadHDLCPCI_32362 ReadHDLCPCI 0 32362 &sel_read_initcon_32362
107177 +__wait_seqno_32370 __wait_seqno 0 32370 NULL
107178 +_drbd_bm_find_next_32372 _drbd_bm_find_next 2 32372 NULL
107179 +cpuset_slab_spread_node_32376 cpuset_slab_spread_node 0 32376 NULL
107180 +intel_iommu_map_32384 intel_iommu_map 4-3 32384 NULL
107181 +local_clock_32385 local_clock 0 32385 NULL
107182 +ocfs2_cancel_convert_32392 ocfs2_cancel_convert 0 32392 NULL
107183 +ll_setxattr_common_32398 ll_setxattr_common 4 32398 NULL
107184 +xfs_iext_add_indirect_multi_32400 xfs_iext_add_indirect_multi 3 32400 NULL
107185 +__add_missing_keys_32402 __add_missing_keys 0 32402 NULL
107186 +vmci_qp_alloc_32405 vmci_qp_alloc 5-3 32405 NULL
107187 +regmap_irq_map_32429 regmap_irq_map 2 32429 NULL
107188 +break_ksm_32439 break_ksm 0 32439 NULL
107189 +__ext4_handle_dirty_super_32458 __ext4_handle_dirty_super 0 32458 NULL
107190 +snd_pcm_sync_ptr_32461 snd_pcm_sync_ptr 0 32461 NULL
107191 +cache_status_32462 cache_status 5 32462 NULL
107192 +fill_readbuf_32464 fill_readbuf 3 32464 NULL
107193 +dgap_usertoboard_32490 dgap_usertoboard 4 32490 NULL
107194 +ide_driver_proc_write_32493 ide_driver_proc_write 3 32493 NULL
107195 +bypass_pwoff_write_32499 bypass_pwoff_write 3 32499 NULL
107196 +mdc_pinger_recov_seq_write_32510 mdc_pinger_recov_seq_write 3 32510 NULL
107197 +ctrl_std_val_to_sym_32516 ctrl_std_val_to_sym 5 32516 NULL
107198 +ocfs2_local_alloc_reserve_for_window_32518 ocfs2_local_alloc_reserve_for_window 0 32518 NULL
107199 +disconnect_32521 disconnect 4 32521 NULL
107200 +qsfp_read_32522 qsfp_read 0-2-4 32522 NULL
107201 +audio_get_intf_req_32524 audio_get_intf_req 0 32524 NULL nohasharray
107202 +ocfs2_refresh_qinfo_32524 ocfs2_refresh_qinfo 0 32524 &audio_get_intf_req_32524
107203 +ilo_read_32531 ilo_read 3 32531 NULL
107204 +ieee80211_if_read_estab_plinks_32533 ieee80211_if_read_estab_plinks 3 32533 NULL
107205 +format_devstat_counter_32550 format_devstat_counter 3 32550 NULL
107206 +__first_node_32558 __first_node 0 32558 NULL
107207 +aes_encrypt_fail_read_32562 aes_encrypt_fail_read 3 32562 NULL
107208 +osc_iocontrol_32565 osc_iocontrol 3 32565 NULL
107209 +mem_swapout_entry_32586 mem_swapout_entry 3 32586 NULL
107210 +pipeline_tcp_tx_stat_fifo_int_read_32589 pipeline_tcp_tx_stat_fifo_int_read 3 32589 NULL
107211 +read_file_beacon_32595 read_file_beacon 3 32595 NULL
107212 +ieee80211_if_read_dropped_frames_congestion_32603 ieee80211_if_read_dropped_frames_congestion 3 32603 NULL
107213 +irda_recvmsg_dgram_32631 irda_recvmsg_dgram 4 32631 NULL
107214 +cfg80211_roamed_32632 cfg80211_roamed 5-7 32632 NULL
107215 +ite_decode_bytes_32642 ite_decode_bytes 3 32642 NULL
107216 +kvmalloc_32646 kvmalloc 1 32646 NULL
107217 +ib_sg_dma_len_32649 ib_sg_dma_len 0 32649 NULL
107218 +generic_readlink_32654 generic_readlink 3 32654 NULL nohasharray
107219 +ftrace_startup_32654 ftrace_startup 0 32654 &generic_readlink_32654
107220 +get_unaligned_be24_32667 get_unaligned_be24 0 32667 NULL
107221 +move_addr_to_kernel_32673 move_addr_to_kernel 2 32673 NULL
107222 +apei_res_add_32674 apei_res_add 0 32674 NULL
107223 +jfs_readpages_32702 jfs_readpages 4 32702 NULL
107224 +rt2x00debug_read_queue_dump_32712 rt2x00debug_read_queue_dump 3 32712 NULL
107225 +i40e_pci_sriov_enable_32742 i40e_pci_sriov_enable 2 32742 NULL
107226 +get_arg_page_32746 get_arg_page 2 32746 NULL
107227 +megasas_change_queue_depth_32747 megasas_change_queue_depth 2 32747 NULL
107228 +stats_read_ul_32751 stats_read_ul 3 32751 NULL
107229 +begin_cmd_32766 begin_cmd 0 32766 NULL
107230 +vmci_transport_dgram_dequeue_32775 vmci_transport_dgram_dequeue 4 32775 NULL
107231 +sctp_tsnmap_grow_32784 sctp_tsnmap_grow 2 32784 NULL
107232 +ocfs2_read_inode_block_full_32790 ocfs2_read_inode_block_full 0 32790 NULL
107233 +rproc_name_read_32805 rproc_name_read 3 32805 NULL
107234 +new_tape_buffer_32866 new_tape_buffer 2 32866 NULL
107235 +io_apic_setup_irq_pin_32868 io_apic_setup_irq_pin 1-2 32868 NULL
107236 +ath6kl_usb_submit_ctrl_in_32880 ath6kl_usb_submit_ctrl_in 6 32880 NULL nohasharray
107237 +cifs_writedata_alloc_32880 cifs_writedata_alloc 1 32880 &ath6kl_usb_submit_ctrl_in_32880
107238 +vp702x_usb_inout_cmd_32884 vp702x_usb_inout_cmd 6-4 32884 NULL
107239 +ext4_get_group_number_32899 ext4_get_group_number 0-2 32899 NULL
107240 +il_dbgfs_tx_stats_read_32913 il_dbgfs_tx_stats_read 3 32913 NULL
107241 +zlib_inflate_workspacesize_32927 zlib_inflate_workspacesize 0 32927 NULL
107242 +rmap_recycle_32938 rmap_recycle 3 32938 NULL
107243 +irq_reserve_irqs_32946 irq_reserve_irqs 1-2 32946 NULL
107244 +ext4_valid_block_bitmap_32958 ext4_valid_block_bitmap 3 32958 NULL
107245 +xfs_log_reserve_32959 xfs_log_reserve 2 32959 NULL
107246 +ext4_group_overhead_blocks_32971 ext4_group_overhead_blocks 0 32971 NULL
107247 +arch_ptrace_32981 arch_ptrace 3 32981 NULL
107248 +compat_filldir_32999 compat_filldir 3 32999 NULL
107249 +btrfs_lookup_extent_info_33000 btrfs_lookup_extent_info 0 33000 NULL
107250 +ext3_alloc_blocks_33007 ext3_alloc_blocks 3-0 33007 NULL nohasharray
107251 +SyS_syslog_33007 SyS_syslog 3 33007 &ext3_alloc_blocks_33007
107252 +br_multicast_set_hash_max_33012 br_multicast_set_hash_max 2 33012 NULL
107253 +write_file_bt_ant_diversity_33019 write_file_bt_ant_diversity 3 33019 NULL
107254 +snd_pcm_prepare_33036 snd_pcm_prepare 0 33036 NULL
107255 +SYSC_lgetxattr_33049 SYSC_lgetxattr 4 33049 NULL
107256 +pipeline_dec_packet_in_fifo_full_read_33052 pipeline_dec_packet_in_fifo_full_read 3 33052 NULL
107257 +ebt_compat_match_offset_33053 ebt_compat_match_offset 0-2 33053 NULL
107258 +bitmap_resize_33054 bitmap_resize 2-3 33054 NULL
107259 +intel_ring_flush_all_caches_33059 intel_ring_flush_all_caches 0 33059 NULL
107260 +stats_dot11RTSSuccessCount_read_33065 stats_dot11RTSSuccessCount_read 3 33065 NULL
107261 +sel_read_checkreqprot_33068 sel_read_checkreqprot 3 33068 NULL
107262 +alloc_tio_33077 alloc_tio 3 33077 NULL
107263 +acl_permission_check_33083 acl_permission_check 0 33083 NULL
107264 +write_node_33121 write_node 4 33121 NULL
107265 +fb_sys_write_33130 fb_sys_write 3 33130 NULL
107266 +__len_within_target_33132 __len_within_target 0 33132 NULL
107267 +SyS_poll_33152 SyS_poll 2 33152 NULL
107268 +debug_debug6_read_33168 debug_debug6_read 3 33168 NULL
107269 +dataflash_read_fact_otp_33204 dataflash_read_fact_otp 3-2 33204 NULL
107270 +pp_read_33210 pp_read 3 33210 NULL
107271 +xfs_file_aio_write_33234 xfs_file_aio_write 4 33234 NULL nohasharray
107272 +i915_gem_object_wait_rendering__tail_33234 i915_gem_object_wait_rendering__tail 0 33234 &xfs_file_aio_write_33234
107273 +__vb2_wait_for_done_vb_33246 __vb2_wait_for_done_vb 0 33246 NULL
107274 +snd_pcm_plug_client_size_33267 snd_pcm_plug_client_size 0-2 33267 NULL
107275 +cachefiles_cook_key_33274 cachefiles_cook_key 2 33274 NULL
107276 +sync_pt_create_33282 sync_pt_create 2 33282 NULL
107277 +btrfs_delete_one_dir_name_33303 btrfs_delete_one_dir_name 0 33303 NULL
107278 +mcs7830_get_reg_33308 mcs7830_get_reg 3 33308 NULL
107279 +isku_sysfs_read_keys_easyzone_33318 isku_sysfs_read_keys_easyzone 6 33318 NULL
107280 +vx_send_irq_dsp_33329 vx_send_irq_dsp 0 33329 NULL
107281 +joydev_ioctl_33343 joydev_ioctl 2 33343 NULL
107282 +lov_stripesize_seq_write_33353 lov_stripesize_seq_write 3 33353 NULL
107283 +create_xattr_datum_33356 create_xattr_datum 5 33356 NULL nohasharray
107284 +irq_pkt_threshold_read_33356 irq_pkt_threshold_read 3 33356 &create_xattr_datum_33356
107285 +read_file_regidx_33370 read_file_regidx 3 33370 NULL
107286 +ocfs2_quota_read_33382 ocfs2_quota_read 5 33382 NULL
107287 +ieee80211_if_read_dropped_frames_no_route_33383 ieee80211_if_read_dropped_frames_no_route 3 33383 NULL
107288 +scsi_varlen_cdb_length_33385 scsi_varlen_cdb_length 0 33385 NULL
107289 +tg_get_cfs_period_33390 tg_get_cfs_period 0 33390 NULL
107290 +ocfs2_allocate_unwritten_extents_33394 ocfs2_allocate_unwritten_extents 3-2 33394 NULL
107291 +cfs_trace_copyin_string_33396 cfs_trace_copyin_string 4 33396 NULL
107292 +ext4_meta_bg_first_block_no_33408 ext4_meta_bg_first_block_no 2 33408 NULL nohasharray
107293 +snd_pcm_capture_ioctl1_33408 snd_pcm_capture_ioctl1 0 33408 &ext4_meta_bg_first_block_no_33408
107294 +ufs_getfrag_block_33409 ufs_getfrag_block 2 33409 NULL
107295 +filemap_fdatawrite_33415 filemap_fdatawrite 0 33415 NULL
107296 +dis_tap_write_33426 dis_tap_write 3 33426 NULL
107297 +ubh_scanc_33436 ubh_scanc 0-3-4 33436 NULL
107298 +message_stats_list_33440 message_stats_list 5 33440 NULL
107299 +ovs_vport_alloc_33475 ovs_vport_alloc 1 33475 NULL
107300 +create_entry_33479 create_entry 2 33479 NULL
107301 +ip_setsockopt_33487 ip_setsockopt 5 33487 NULL nohasharray
107302 +elf_map_33487 elf_map 0-2 33487 &ip_setsockopt_33487
107303 +ol_dqblk_chunk_off_33489 ol_dqblk_chunk_off 2 33489 NULL
107304 +res_counter_read_33499 res_counter_read 4 33499 NULL
107305 +fb_read_33506 fb_read 3 33506 NULL
107306 +musb_test_mode_write_33518 musb_test_mode_write 3 33518 NULL
107307 +ahash_setkey_unaligned_33521 ahash_setkey_unaligned 3 33521 NULL
107308 +nes_alloc_fast_reg_page_list_33523 nes_alloc_fast_reg_page_list 2 33523 NULL
107309 +aggr_size_rx_size_read_33526 aggr_size_rx_size_read 3 33526 NULL
107310 +acpi_gsi_to_irq_33533 acpi_gsi_to_irq 1 33533 NULL
107311 +osc_max_rpcs_in_flight_seq_write_33539 osc_max_rpcs_in_flight_seq_write 3 33539 NULL nohasharray
107312 +tomoyo_read_self_33539 tomoyo_read_self 3 33539 &osc_max_rpcs_in_flight_seq_write_33539
107313 +read_symlink_33572 read_symlink 0 33572 NULL
107314 +count_subheaders_33591 count_subheaders 0 33591 NULL
107315 +scsi_execute_33596 scsi_execute 5 33596 NULL
107316 +comedi_buf_write_n_allocated_33604 comedi_buf_write_n_allocated 0 33604 NULL
107317 +xt_compat_target_offset_33608 xt_compat_target_offset 0 33608 NULL
107318 +usb_gstrings_attach_33615 usb_gstrings_attach 3 33615 NULL nohasharray
107319 +il_dbgfs_qos_read_33615 il_dbgfs_qos_read 3 33615 &usb_gstrings_attach_33615
107320 +do_sync_write_33624 do_sync_write 0 33624 NULL
107321 +stride_page_count_33641 stride_page_count 2 33641 NULL
107322 +slab_alloc_node_33663 slab_alloc_node 3 33663 NULL
107323 +irq_blk_threshold_read_33666 irq_blk_threshold_read 3 33666 NULL
107324 +inw_p_33668 inw_p 0 33668 NULL
107325 +arp_hdr_len_33671 arp_hdr_len 0 33671 NULL
107326 +i2c_hid_alloc_buffers_33673 i2c_hid_alloc_buffers 2 33673 NULL
107327 +nv50_disp_dmac_create__33696 nv50_disp_dmac_create_ 6 33696 NULL
107328 +netlink_sendmsg_33708 netlink_sendmsg 4 33708 NULL
107329 +tipc_link_stats_33716 tipc_link_stats 3 33716 NULL
107330 +ext4_wb_update_i_disksize_33717 ext4_wb_update_i_disksize 2 33717 NULL
107331 +pvr2_stream_buffer_count_33719 pvr2_stream_buffer_count 2 33719 NULL
107332 +ocfs2_extent_map_get_blocks_33720 ocfs2_extent_map_get_blocks 2 33720 NULL
107333 +write_file_spectral_count_33723 write_file_spectral_count 3 33723 NULL nohasharray
107334 +ocfs2_lock_allocators_move_extents_33723 ocfs2_lock_allocators_move_extents 0 33723 &write_file_spectral_count_33723
107335 +__mutex_lock_interruptible_slowpath_33735 __mutex_lock_interruptible_slowpath 0 33735 NULL
107336 +do_munmap_33752 do_munmap 0 33752 NULL
107337 +vifs_state_read_33762 vifs_state_read 3 33762 NULL
107338 +hashtab_create_33769 hashtab_create 3 33769 NULL
107339 +btrfs_delayed_refs_qgroup_accounting_33775 btrfs_delayed_refs_qgroup_accounting 0 33775 NULL
107340 +irq_map_generic_chip_33793 irq_map_generic_chip 2 33793 NULL
107341 +if_sdio_read_rx_len_33800 if_sdio_read_rx_len 0 33800 NULL
107342 +find_next_offset_33804 find_next_offset 3-0 33804 NULL
107343 +filter_write_33819 filter_write 3 33819 NULL
107344 +sep_create_msgarea_context_33829 sep_create_msgarea_context 4 33829 NULL
107345 +scrub_setup_recheck_block_33831 scrub_setup_recheck_block 5-4 33831 NULL
107346 +ext4_journal_extend_33835 ext4_journal_extend 2-0 33835 NULL
107347 +snd_pcm_action_nonatomic_33844 snd_pcm_action_nonatomic 0 33844 NULL
107348 +calgary_alloc_coherent_33851 calgary_alloc_coherent 2 33851 NULL
107349 +oz_cdev_write_33852 oz_cdev_write 3 33852 NULL
107350 +bin_string_33884 bin_string 3-5 33884 NULL
107351 +get_user_pages_33908 get_user_pages 0-3-4 33908 NULL
107352 +ath6kl_roam_mode_write_33912 ath6kl_roam_mode_write 3 33912 NULL
107353 +queue_logical_block_size_33918 queue_logical_block_size 0 33918 NULL
107354 +sel_read_avc_cache_threshold_33942 sel_read_avc_cache_threshold 3 33942 NULL
107355 +lpfc_idiag_ctlacc_read_33943 lpfc_idiag_ctlacc_read 3 33943 NULL
107356 +read_file_tgt_rx_stats_33944 read_file_tgt_rx_stats 3 33944 NULL nohasharray
107357 +btrfs_uuid_tree_rem_33944 btrfs_uuid_tree_rem 0 33944 &read_file_tgt_rx_stats_33944
107358 +hfsplus_osx_setxattr_33952 hfsplus_osx_setxattr 4 33952 NULL
107359 +__proc_dump_kernel_33954 __proc_dump_kernel 5 33954 NULL
107360 +ocfs2_create_new_meta_bhs_33955 ocfs2_create_new_meta_bhs 0 33955 NULL
107361 +vga_switcheroo_debugfs_write_33984 vga_switcheroo_debugfs_write 3 33984 NULL
107362 +snd_interval_refine_33987 snd_interval_refine 0 33987 NULL
107363 +__ntfs_malloc_34022 __ntfs_malloc 1 34022 NULL
107364 +lbs_lowrssi_write_34025 lbs_lowrssi_write 3 34025 NULL
107365 +ppp_write_34034 ppp_write 3 34034 NULL
107366 +tty_insert_flip_string_34042 tty_insert_flip_string 3-0 34042 NULL
107367 +__domain_flush_pages_34045 __domain_flush_pages 2-3 34045 NULL
107368 +is_trap_at_addr_34047 is_trap_at_addr 2 34047 NULL
107369 +memcg_update_all_caches_34068 memcg_update_all_caches 1 34068 NULL
107370 +pipeline_pipeline_fifo_full_read_34095 pipeline_pipeline_fifo_full_read 3 34095 NULL
107371 +__irq_domain_add_34101 __irq_domain_add 2 34101 NULL
107372 +i915_gem_object_set_cache_level_34107 i915_gem_object_set_cache_level 0 34107 NULL nohasharray
107373 +proc_scsi_host_write_34107 proc_scsi_host_write 3 34107 &i915_gem_object_set_cache_level_34107
107374 +is_discarded_oblock_34120 is_discarded_oblock 2 34120 NULL
107375 +islpci_mgt_transmit_34133 islpci_mgt_transmit 5 34133 NULL
107376 +ttm_dma_page_pool_free_34135 ttm_dma_page_pool_free 2-0 34135 NULL
107377 +ixgbe_dbg_netdev_ops_write_34141 ixgbe_dbg_netdev_ops_write 3 34141 NULL
107378 +shmem_pread_fast_34147 shmem_pread_fast 3 34147 NULL
107379 +ext4_xattr_list_34162 ext4_xattr_list 3 34162 NULL
107380 +ocfs2_xattr_list_entry_34165 ocfs2_xattr_list_entry 0 34165 NULL
107381 +skb_to_sgvec_34171 skb_to_sgvec 0 34171 NULL
107382 +dtf_write_run_34196 dtf_write_run 3 34196 NULL
107383 +ext4_da_write_begin_34215 ext4_da_write_begin 3-4 34215 NULL
107384 +i915_gem_execbuffer_reserve_object_34224 i915_gem_execbuffer_reserve_object 0 34224 NULL
107385 +setup_nodes_for_search_34248 setup_nodes_for_search 0 34248 NULL
107386 +numa_migrate_prep_34256 numa_migrate_prep 0 34256 NULL
107387 +btrfs_bitmap_cluster_34257 btrfs_bitmap_cluster 4 34257 NULL
107388 +bl_pipe_downcall_34264 bl_pipe_downcall 3 34264 NULL
107389 +ocfs2_dlm_lock_34265 ocfs2_dlm_lock 0 34265 NULL
107390 +pcf857x_to_irq_34273 pcf857x_to_irq 2 34273 NULL
107391 +device_private_init_34279 device_private_init 0 34279 NULL
107392 +get_task_io_context_34316 get_task_io_context 3 34316 NULL
107393 +ext4_get_groups_count_34324 ext4_get_groups_count 0 34324 NULL
107394 +iov_iter_single_seg_count_34326 iov_iter_single_seg_count 0 34326 NULL nohasharray
107395 +pcpu_need_to_extend_34326 pcpu_need_to_extend 0 34326 &iov_iter_single_seg_count_34326
107396 +SYSC_brk_34331 SYSC_brk 1 34331 NULL
107397 +__insert_34349 __insert 2-3 34349 NULL
107398 +sync_page_io_34363 sync_page_io 3 34363 NULL nohasharray
107399 +crypto_ablkcipher_ivsize_34363 crypto_ablkcipher_ivsize 0 34363 &sync_page_io_34363
107400 +rngapi_reset_34366 rngapi_reset 3 34366 NULL
107401 +reiserfs_resize_34377 reiserfs_resize 2 34377 NULL
107402 +ea_read_34378 ea_read 0 34378 NULL
107403 +fuse_send_read_34379 fuse_send_read 4 34379 NULL
107404 +av7110_vbi_write_34384 av7110_vbi_write 3 34384 NULL
107405 +usbvision_v4l2_read_34386 usbvision_v4l2_read 3 34386 NULL
107406 +read_rbu_image_type_34387 read_rbu_image_type 6 34387 NULL
107407 +ivtv_read_pos_34400 ivtv_read_pos 3 34400 NULL nohasharray
107408 +iwl_calib_set_34400 iwl_calib_set 3 34400 &ivtv_read_pos_34400
107409 +wd_exp_mode_write_34407 wd_exp_mode_write 3 34407 NULL
107410 +nl80211_send_disassoc_34424 nl80211_send_disassoc 4 34424 NULL
107411 +security_socket_create_34439 security_socket_create 0 34439 NULL
107412 +usbtest_alloc_urb_34446 usbtest_alloc_urb 5-3 34446 NULL
107413 +mwifiex_regrdwr_read_34472 mwifiex_regrdwr_read 3 34472 NULL
107414 +skcipher_sndbuf_34476 skcipher_sndbuf 0 34476 NULL
107415 +i2o_parm_field_get_34477 i2o_parm_field_get 5 34477 NULL
107416 +ocfs2_block_group_clear_bits_34484 ocfs2_block_group_clear_bits 0 34484 NULL
107417 +security_inode_permission_34488 security_inode_permission 0 34488 NULL
107418 +__ffs64_34494 __ffs64 1-0 34494 NULL nohasharray
107419 +SyS_pwritev_34494 SyS_pwritev 3 34494 &__ffs64_34494
107420 +qp_alloc_res_34496 qp_alloc_res 5 34496 NULL
107421 +lu_buf_check_and_alloc_34505 lu_buf_check_and_alloc 2 34505 NULL
107422 +snd_pcm_hw_param_value_34525 snd_pcm_hw_param_value 0 34525 NULL
107423 +tracing_stats_read_34537 tracing_stats_read 3 34537 NULL nohasharray
107424 +ext4_fallocate_34537 ext4_fallocate 4-3 34537 &tracing_stats_read_34537
107425 +hugetlbfs_read_actor_34547 hugetlbfs_read_actor 4-5-2-0 34547 NULL
107426 +dbBackSplit_34561 dbBackSplit 0 34561 NULL
107427 +alloc_ieee80211_rsl_34564 alloc_ieee80211_rsl 1 34564 NULL nohasharray
107428 +self_check_peb_ec_hdr_34564 self_check_peb_ec_hdr 0 34564 &alloc_ieee80211_rsl_34564
107429 +i915_gem_execbuffer_relocate_object_34575 i915_gem_execbuffer_relocate_object 0 34575 NULL
107430 +lov_stripecount_seq_write_34582 lov_stripecount_seq_write 3 34582 NULL
107431 +init_send_hfcd_34586 init_send_hfcd 1 34586 NULL
107432 +inet6_ifla6_size_34591 inet6_ifla6_size 0 34591 NULL
107433 +ceph_msgpool_init_34599 ceph_msgpool_init 4 34599 NULL nohasharray
107434 +cw1200_queue_init_34599 cw1200_queue_init 4 34599 &ceph_msgpool_init_34599
107435 +__add_prelim_ref_34600 __add_prelim_ref 0 34600 NULL
107436 +brcmf_cfg80211_mgmt_tx_34608 brcmf_cfg80211_mgmt_tx 7 34608 NULL
107437 +mtd_write_34609 mtd_write 0 34609 NULL nohasharray
107438 +__jffs2_ref_totlen_34609 __jffs2_ref_totlen 0 34609 &mtd_write_34609
107439 +apei_get_nvs_resources_34616 apei_get_nvs_resources 0 34616 NULL
107440 +__cfg80211_disconnected_34622 __cfg80211_disconnected 3 34622 NULL
107441 +cnic_alloc_dma_34641 cnic_alloc_dma 3 34641 NULL
107442 +tomoyo_dump_page_34649 tomoyo_dump_page 2 34649 NULL
107443 +kvm_set_spte_hva_34671 kvm_set_spte_hva 2 34671 NULL
107444 +sleep_auth_write_34676 sleep_auth_write 3 34676 NULL
107445 +isr_fiqs_read_34687 isr_fiqs_read 3 34687 NULL
107446 +port_print_34704 port_print 3 34704 NULL
107447 +alloc_irq_and_cfg_at_34706 alloc_irq_and_cfg_at 1-2 34706 NULL
107448 +ext4_listxattr_34712 ext4_listxattr 3 34712 NULL
107449 +ieee80211_if_read_num_sta_ps_34722 ieee80211_if_read_num_sta_ps 3 34722 NULL
107450 +platform_list_read_file_34734 platform_list_read_file 3 34734 NULL
107451 +reg_w_ixbuf_34736 reg_w_ixbuf 4 34736 NULL
107452 +lsm_alloc_plain_34755 lsm_alloc_plain 1 34755 NULL
107453 +device_add_34766 device_add 0 34766 NULL
107454 +qib_cdev_init_34778 qib_cdev_init 1 34778 NULL
107455 +SYSC_keyctl_34800 SYSC_keyctl 4 34800 NULL
107456 +can_nocow_extent_34801 can_nocow_extent 2 34801 NULL
107457 +drbd_get_max_capacity_34804 drbd_get_max_capacity 0 34804 NULL
107458 +ll_setxattr_34806 ll_setxattr 4 34806 NULL
107459 +file_page_index_34820 file_page_index 0-2 34820 NULL
107460 +b43_debugfs_write_34838 b43_debugfs_write 3 34838 NULL
107461 +nl_portid_hash_zalloc_34843 nl_portid_hash_zalloc 1 34843 NULL
107462 +acpi_system_write_wakeup_device_34853 acpi_system_write_wakeup_device 3 34853 NULL
107463 +usb_serial_generic_prepare_write_buffer_34857 usb_serial_generic_prepare_write_buffer 3 34857 NULL
107464 +ieee80211_if_read_txpower_34871 ieee80211_if_read_txpower 3 34871 NULL
107465 +msg_print_text_34889 msg_print_text 0 34889 NULL
107466 +ieee80211_if_write_34894 ieee80211_if_write 3 34894 NULL
107467 +si476x_radio_read_rsq_primary_blob_34916 si476x_radio_read_rsq_primary_blob 3 34916 NULL
107468 +__inode_permission_34925 __inode_permission 0 34925 NULL nohasharray
107469 +btrfs_super_chunk_root_34925 btrfs_super_chunk_root 0 34925 &__inode_permission_34925
107470 +ODM_AllocateMemory_34929 ODM_AllocateMemory 3 34929 NULL
107471 +ceph_aio_write_34930 ceph_aio_write 4 34930 NULL
107472 +sec_flags2str_34933 sec_flags2str 3 34933 NULL
107473 +snd_info_entry_read_34938 snd_info_entry_read 3 34938 NULL
107474 +i2c_transfer_34958 i2c_transfer 0 34958 NULL
107475 +do_add_page_to_bio_34974 do_add_page_to_bio 2-10 34974 NULL
107476 +mq_lookup_34990 mq_lookup 2 34990 NULL
107477 +i915_gem_gtt_prepare_object_34991 i915_gem_gtt_prepare_object 0 34991 NULL
107478 +schedule_erase_34996 schedule_erase 0 34996 NULL
107479 +rx_rx_hdr_overflow_read_35002 rx_rx_hdr_overflow_read 3 35002 NULL
107480 +l2cap_skbuff_fromiovec_35003 l2cap_skbuff_fromiovec 4-3 35003 NULL
107481 +dm_cache_insert_mapping_35005 dm_cache_insert_mapping 2-3 35005 NULL
107482 +sisusb_copy_memory_35016 sisusb_copy_memory 4 35016 NULL
107483 +snd_pcm_hw_params_35020 snd_pcm_hw_params 0 35020 NULL
107484 +process_changed_xattr_35025 process_changed_xattr 0 35025 NULL
107485 +coda_psdev_read_35029 coda_psdev_read 3 35029 NULL
107486 +brcmf_sdio_chip_writenvram_35042 brcmf_sdio_chip_writenvram 4 35042 NULL
107487 +pwr_connection_out_of_sync_read_35061 pwr_connection_out_of_sync_read 3 35061 NULL
107488 +ext4_split_unwritten_extents_35063 ext4_split_unwritten_extents 0 35063 NULL
107489 +ntfs_attr_extend_initialized_35084 ntfs_attr_extend_initialized 2 35084 NULL
107490 +store_ifalias_35088 store_ifalias 4 35088 NULL
107491 +__kfifo_uint_must_check_helper_35097 __kfifo_uint_must_check_helper 0-1 35097 NULL
107492 +alloc_thread_info_node_35101 alloc_thread_info_node 2 35101 NULL
107493 +capi_write_35104 capi_write 3 35104 NULL nohasharray
107494 +tx_tx_done_template_read_35104 tx_tx_done_template_read 3 35104 &capi_write_35104
107495 +ide_settings_proc_write_35110 ide_settings_proc_write 3 35110 NULL
107496 +ceph_osdc_start_request_35122 ceph_osdc_start_request 0 35122 NULL
107497 +message_stats_print_35158 message_stats_print 6 35158 NULL
107498 +iscsi_conn_setup_35159 iscsi_conn_setup 2 35159 NULL
107499 +ieee80211_if_read_bssid_35161 ieee80211_if_read_bssid 3 35161 NULL
107500 +relocate_entry_cpu_35176 relocate_entry_cpu 0 35176 NULL
107501 +solo_v4l2_init_35179 solo_v4l2_init 2 35179 NULL
107502 +SyS_init_module_35180 SyS_init_module 2 35180 NULL
107503 +mlx4_ib_get_cq_umem_35184 mlx4_ib_get_cq_umem 5-6 35184 NULL
107504 +uprobe_get_swbp_addr_35201 uprobe_get_swbp_addr 0 35201 NULL
107505 +unix_stream_recvmsg_35210 unix_stream_recvmsg 4 35210 NULL
107506 +striped_read_35218 striped_read 0-3-2 35218 NULL nohasharray
107507 +security_key_getsecurity_35218 security_key_getsecurity 0 35218 &striped_read_35218
107508 +video_register_device_no_warn_35226 video_register_device_no_warn 3 35226 NULL nohasharray
107509 +rx_rx_cmplt_task_read_35226 rx_rx_cmplt_task_read 3 35226 &video_register_device_no_warn_35226
107510 +gfn_to_page_many_atomic_35234 gfn_to_page_many_atomic 2 35234 NULL nohasharray
107511 +may_commit_transaction_35234 may_commit_transaction 0 35234 &gfn_to_page_many_atomic_35234
107512 +SYSC_madvise_35241 SYSC_madvise 1-2 35241 NULL
107513 +set_fd_set_35249 set_fd_set 1 35249 NULL
107514 +ioapic_setup_resources_35255 ioapic_setup_resources 1 35255 NULL
107515 +alloc_thread_groups_35256 alloc_thread_groups 2 35256 NULL
107516 +jbd2_journal_get_write_access_35263 jbd2_journal_get_write_access 0 35263 NULL
107517 +dis_disc_write_35265 dis_disc_write 3 35265 NULL
107518 +dma_show_regs_35266 dma_show_regs 3 35266 NULL
107519 +irda_recvmsg_stream_35280 irda_recvmsg_stream 4 35280 NULL
107520 +i2o_block_end_request_35282 i2o_block_end_request 3 35282 NULL
107521 +isr_rx_rdys_read_35283 isr_rx_rdys_read 3 35283 NULL
107522 +brcmf_sdio_forensic_read_35311 brcmf_sdio_forensic_read 3 35311 NULL nohasharray
107523 +__btrfs_buffered_write_35311 __btrfs_buffered_write 3 35311 &brcmf_sdio_forensic_read_35311
107524 +tracing_read_pipe_35312 tracing_read_pipe 3 35312 NULL
107525 +fallback_on_nodma_alloc_35332 fallback_on_nodma_alloc 2 35332 NULL
107526 +ieee80211_if_fmt_ap_power_level_35347 ieee80211_if_fmt_ap_power_level 3 35347 NULL
107527 +nouveau_devinit_create__35348 nouveau_devinit_create_ 4 35348 NULL
107528 +ieee80211_rx_mgmt_deauth_35351 ieee80211_rx_mgmt_deauth 3 35351 NULL
107529 +compat_filldir64_35354 compat_filldir64 3 35354 NULL
107530 +amd_iommu_map_35355 amd_iommu_map 4 35355 NULL
107531 +read_kmem_35372 read_kmem 3 35372 NULL
107532 +ocfs2_journal_access_di_35393 ocfs2_journal_access_di 0 35393 NULL
107533 +create_pending_snapshots_35402 create_pending_snapshots 0 35402 NULL
107534 +btrfs_search_old_slot_35406 btrfs_search_old_slot 0 35406 NULL
107535 +SyS_getxattr_35408 SyS_getxattr 4 35408 NULL
107536 +rawv6_send_hdrinc_35425 rawv6_send_hdrinc 3 35425 NULL
107537 +C_SYSC_sendfile_35432 C_SYSC_sendfile 4 35432 NULL
107538 +__set_test_and_free_35436 __set_test_and_free 2 35436 NULL
107539 +buffer_to_user_35439 buffer_to_user 3 35439 NULL
107540 +memcg_memory_allocated_read_35469 memcg_memory_allocated_read 0 35469 NULL
107541 +fiemap_prepare_and_copy_exts_35494 fiemap_prepare_and_copy_exts 5 35494 NULL
107542 +btrfs_prealloc_file_range_trans_35500 btrfs_prealloc_file_range_trans 4-0 35500 NULL
107543 +async_setkey_35521 async_setkey 3 35521 NULL
107544 +inet_mask_len_35527 inet_mask_len 1 35527 NULL
107545 +__filemap_fdatawrite_range_35528 __filemap_fdatawrite_range 0 35528 NULL
107546 +iwl_dbgfs_bt_traffic_read_35534 iwl_dbgfs_bt_traffic_read 3 35534 NULL
107547 +pstore_mkfile_35536 pstore_mkfile 7 35536 NULL
107548 +rxpipe_tx_xfr_host_int_trig_rx_data_read_35538 rxpipe_tx_xfr_host_int_trig_rx_data_read 3 35538 NULL
107549 +ibnl_put_attr_35541 ibnl_put_attr 3 35541 NULL
107550 +ieee80211_if_write_smps_35550 ieee80211_if_write_smps 3 35550 NULL
107551 +send_update_extent_35556 send_update_extent 0 35556 NULL
107552 +vb2_dqbuf_35559 vb2_dqbuf 0 35559 NULL
107553 +sysfs_create_subdir_35567 sysfs_create_subdir 0 35567 NULL
107554 +ext4_blocks_for_truncate_35579 ext4_blocks_for_truncate 0 35579 NULL
107555 +ext2_acl_from_disk_35580 ext2_acl_from_disk 2 35580 NULL
107556 +spk_msg_set_35586 spk_msg_set 3 35586 NULL
107557 +kernel_readv_35617 kernel_readv 3 35617 NULL
107558 +reiserfs_readpages_35629 reiserfs_readpages 4 35629 NULL
107559 +ptlrpcd_steal_rqset_35637 ptlrpcd_steal_rqset 0 35637 NULL
107560 +nv50_vm_create_35643 nv50_vm_create 2-3 35643 NULL
107561 +spi_register_board_info_35651 spi_register_board_info 2 35651 NULL
107562 +rdmaltWithLock_35669 rdmaltWithLock 0 35669 NULL
107563 +cpu_to_sle64_35677 cpu_to_sle64 0-1 35677 NULL
107564 +ext3_mark_iloc_dirty_35686 ext3_mark_iloc_dirty 0 35686 NULL
107565 +dm_table_create_35687 dm_table_create 3 35687 NULL
107566 +SYSC_pwritev_35690 SYSC_pwritev 3 35690 NULL
107567 +rds_page_copy_user_35691 rds_page_copy_user 4 35691 NULL
107568 +md_super_write_35703 md_super_write 4 35703 NULL
107569 +btrfs_commit_transaction_35725 btrfs_commit_transaction 0 35725 NULL
107570 +rtw_IOL_cmd_tx_pkt_buf_dump_35732 rtw_IOL_cmd_tx_pkt_buf_dump 2 35732 NULL
107571 +ext4_truncate_restart_trans_35750 ext4_truncate_restart_trans 0 35750 NULL
107572 +iwl_dbgfs_disable_ht40_read_35761 iwl_dbgfs_disable_ht40_read 3 35761 NULL
107573 +udf_alloc_i_data_35786 udf_alloc_i_data 2 35786 NULL
107574 +pvr2_hdw_cpufw_get_35824 pvr2_hdw_cpufw_get 0-4-2 35824 NULL
107575 +tx_tx_cmplt_read_35854 tx_tx_cmplt_read 3 35854 NULL
107576 +vx_query_hbuffer_size_35859 vx_query_hbuffer_size 0 35859 NULL
107577 +changed_xattr_35860 changed_xattr 0 35860 NULL
107578 +mthca_buf_alloc_35861 mthca_buf_alloc 2 35861 NULL
107579 +fls64_35862 fls64 0 35862 NULL
107580 +kvm_dirty_bitmap_bytes_35886 kvm_dirty_bitmap_bytes 0 35886 NULL
107581 +ieee80211_if_fmt_dot11MeshRetryTimeout_35890 ieee80211_if_fmt_dot11MeshRetryTimeout 3 35890 NULL
107582 +uwb_rc_cmd_done_35892 uwb_rc_cmd_done 4 35892 NULL
107583 +SyS_set_mempolicy_35909 SyS_set_mempolicy 3 35909 NULL
107584 +kernel_setsockopt_35913 kernel_setsockopt 5 35913 NULL
107585 +rbio_nr_pages_35916 rbio_nr_pages 0-1-2 35916 NULL
107586 +balance_node_right_35920 balance_node_right 0 35920 NULL
107587 +sctp_tsnmap_mark_35929 sctp_tsnmap_mark 2 35929 NULL
107588 +rx_defrag_init_called_read_35935 rx_defrag_init_called_read 3 35935 NULL
107589 +put_cmsg_compat_35937 put_cmsg_compat 4 35937 NULL
107590 +ext_rts51x_sd_execute_write_data_35971 ext_rts51x_sd_execute_write_data 9 35971 NULL
107591 +ceph_buffer_new_35974 ceph_buffer_new 1 35974 NULL nohasharray
107592 +generic_ocp_read_35974 generic_ocp_read 3 35974 &ceph_buffer_new_35974
107593 +acl_alloc_35979 acl_alloc 1 35979 NULL
107594 +device_add_class_symlinks_35985 device_add_class_symlinks 0 35985 NULL
107595 +generic_file_aio_read_35987 generic_file_aio_read 0 35987 NULL
107596 +write_file_antenna_35998 write_file_antenna 3 35998 NULL nohasharray
107597 +kuc_alloc_35998 kuc_alloc 1 35998 &write_file_antenna_35998
107598 +locks_mandatory_area_35999 locks_mandatory_area 0 35999 NULL
107599 +il3945_ucode_tx_stats_read_36016 il3945_ucode_tx_stats_read 3 36016 NULL
107600 +ubi_eba_write_leb_36029 ubi_eba_write_leb 0-6-5 36029 NULL
107601 +__videobuf_alloc_36031 __videobuf_alloc 1 36031 NULL
107602 +account_shadowed_36048 account_shadowed 2 36048 NULL
107603 +gpio_power_read_36059 gpio_power_read 3 36059 NULL
107604 +snd_pcm_playback_hw_avail_36061 snd_pcm_playback_hw_avail 0 36061 NULL
107605 +did_create_dir_36062 did_create_dir 0 36062 NULL
107606 +write_emulate_36065 write_emulate 2-4 36065 NULL
107607 +stack_max_size_write_36068 stack_max_size_write 3 36068 NULL
107608 +radeon_vm_num_pdes_36070 radeon_vm_num_pdes 0 36070 NULL
107609 +ieee80211_if_fmt_peer_36071 ieee80211_if_fmt_peer 3 36071 NULL
107610 +ext3_new_blocks_36073 ext3_new_blocks 3-0 36073 NULL
107611 +ieee80211_if_write_tsf_36077 ieee80211_if_write_tsf 3 36077 NULL
107612 +vmemmap_pud_populate_36080 vmemmap_pud_populate 3 36080 NULL nohasharray
107613 +snd_pcm_plug_read_transfer_36080 snd_pcm_plug_read_transfer 0-3 36080 &vmemmap_pud_populate_36080
107614 +mtip_hw_read_device_status_36082 mtip_hw_read_device_status 3 36082 NULL
107615 +vga_arb_write_36112 vga_arb_write 3 36112 NULL
107616 +simple_xattr_alloc_36118 simple_xattr_alloc 2 36118 NULL
107617 +compat_ptrace_request_36131 compat_ptrace_request 3 36131 NULL
107618 +vmalloc_exec_36132 vmalloc_exec 1 36132 NULL
107619 +max8925_irq_domain_map_36133 max8925_irq_domain_map 2 36133 NULL
107620 +set_flexbg_block_bitmap_36136 set_flexbg_block_bitmap 0-4-5 36136 NULL
107621 +ext3_readpages_36144 ext3_readpages 4 36144 NULL
107622 +twl_set_36154 twl_set 2 36154 NULL
107623 +b1_alloc_card_36155 b1_alloc_card 1 36155 NULL
107624 +btrfs_file_extent_inline_len_36158 btrfs_file_extent_inline_len 0 36158 NULL
107625 +snd_korg1212_copy_from_36169 snd_korg1212_copy_from 6 36169 NULL
107626 +wm8994_edge_irq_map_36170 wm8994_edge_irq_map 2 36170 NULL
107627 +SyS_kexec_load_36176 SyS_kexec_load 2 36176 NULL
107628 +ramoops_init_przs_36199 ramoops_init_przs 4 36199 NULL
107629 +SYSC_sched_getaffinity_36208 SYSC_sched_getaffinity 2 36208 NULL
107630 +SYSC_process_vm_readv_36216 SYSC_process_vm_readv 5-3 36216 NULL
107631 +ubifs_read_nnode_36221 ubifs_read_nnode 0 36221 NULL
107632 +is_dirty_36223 is_dirty 2 36223 NULL
107633 +ept_walk_addr_36226 ept_walk_addr 3 36226 NULL
107634 +atomic_stats_read_36228 atomic_stats_read 3 36228 NULL
107635 +viafb_iga1_odev_proc_write_36241 viafb_iga1_odev_proc_write 3 36241 NULL
107636 +SYSC_getxattr_36242 SYSC_getxattr 4 36242 NULL
107637 +rproc_recovery_read_36245 rproc_recovery_read 3 36245 NULL
107638 +scrub_stripe_36248 scrub_stripe 5-4 36248 NULL
107639 +compat_sys_mbind_36256 compat_sys_mbind 5 36256 NULL
107640 +usb_buffer_alloc_36276 usb_buffer_alloc 2 36276 NULL nohasharray
107641 +cfs_hash_buckets_realloc_36276 cfs_hash_buckets_realloc 4 36276 &usb_buffer_alloc_36276
107642 +codec_reg_read_file_36280 codec_reg_read_file 3 36280 NULL
107643 +crypto_shash_digestsize_36284 crypto_shash_digestsize 0 36284 NULL
107644 +nouveau_cli_create_36293 nouveau_cli_create 3 36293 NULL
107645 +lpfc_debugfs_dif_err_read_36303 lpfc_debugfs_dif_err_read 3 36303 NULL
107646 +cfg80211_rx_mlme_mgmt_36306 cfg80211_rx_mlme_mgmt 3 36306 NULL
107647 +ad7879_spi_xfer_36311 ad7879_spi_xfer 3 36311 NULL
107648 +fuse_get_user_addr_36312 fuse_get_user_addr 0 36312 NULL
107649 +fat_compat_ioctl_filldir_36328 fat_compat_ioctl_filldir 3 36328 NULL
107650 +lc_create_36332 lc_create 4 36332 NULL
107651 +jbd2_journal_init_revoke_table_36336 jbd2_journal_init_revoke_table 1 36336 NULL
107652 +isku_sysfs_read_key_mask_36343 isku_sysfs_read_key_mask 6 36343 NULL
107653 +ath6kl_regwrite_write_36351 ath6kl_regwrite_write 3 36351 NULL
107654 +v9fs_file_readn_36353 v9fs_file_readn 4 36353 NULL nohasharray
107655 +xz_dec_lzma2_create_36353 xz_dec_lzma2_create 2 36353 &v9fs_file_readn_36353
107656 +to_sector_36361 to_sector 0-1 36361 NULL
107657 +irq_domain_disassociate_36367 irq_domain_disassociate 2 36367 NULL
107658 +posix_acl_create_36383 posix_acl_create 0 36383 NULL
107659 +tunables_read_36385 tunables_read 3 36385 NULL
107660 +afs_alloc_flat_call_36399 afs_alloc_flat_call 3-2 36399 NULL
107661 +sierra_write_36402 sierra_write 4 36402 NULL
107662 +msb_update_block_36412 msb_update_block 2 36412 NULL
107663 +SyS_sethostname_36417 SyS_sethostname 2 36417 NULL
107664 +ReadW6692B_36445 ReadW6692B 0 36445 NULL
107665 +sctp_tsnmap_init_36446 sctp_tsnmap_init 2 36446 NULL
107666 +alloc_etherdev_mqs_36450 alloc_etherdev_mqs 1 36450 NULL
107667 +check_extent_in_eb_36467 check_extent_in_eb 0 36467 NULL
107668 +SyS_process_vm_writev_36476 SyS_process_vm_writev 5-3 36476 NULL
107669 +b43_nphy_load_samples_36481 b43_nphy_load_samples 3 36481 NULL
107670 +set_var_mtrr_range_36483 set_var_mtrr_range 2 36483 NULL
107671 +ip6_append_data_36490 ip6_append_data 4 36490 NULL nohasharray
107672 +tx_tx_checksum_result_read_36490 tx_tx_checksum_result_read 3 36490 &ip6_append_data_36490
107673 +cmd_loop_36491 cmd_loop 0 36491 NULL
107674 +__hwahc_op_set_ptk_36510 __hwahc_op_set_ptk 5 36510 NULL
107675 +mcam_v4l_read_36513 mcam_v4l_read 3 36513 NULL
107676 +get_param_l_36518 get_param_l 0 36518 NULL
107677 +ieee80211_if_read_fwded_frames_36520 ieee80211_if_read_fwded_frames 3 36520 NULL
107678 +lguest_setup_irq_36531 lguest_setup_irq 1 36531 NULL
107679 +crypto_aead_authsize_36537 crypto_aead_authsize 0 36537 NULL
107680 +cpu_type_read_36540 cpu_type_read 3 36540 NULL
107681 +__kfifo_to_user_36555 __kfifo_to_user 3-0 36555 NULL nohasharray
107682 +macvtap_do_read_36555 macvtap_do_read 4 36555 &__kfifo_to_user_36555
107683 +btrfs_get_token_64_36572 btrfs_get_token_64 0 36572 NULL
107684 +__erst_read_36579 __erst_read 0 36579 NULL
107685 +put_cmsg_36589 put_cmsg 4 36589 NULL
107686 +do_sendfile_36610 do_sendfile 4-5 36610 NULL
107687 +fat_ioctl_filldir_36621 fat_ioctl_filldir 3 36621 NULL
107688 +i915_gem_execbuffer_relocate_slow_36634 i915_gem_execbuffer_relocate_slow 0 36634 NULL
107689 +vxge_config_vpaths_36636 vxge_config_vpaths 0 36636 NULL
107690 +convert_extent_item_v0_36645 convert_extent_item_v0 4-0 36645 NULL
107691 +ced_ioctl_36647 ced_ioctl 2 36647 NULL
107692 +lpfc_idiag_extacc_alloc_get_36648 lpfc_idiag_extacc_alloc_get 0-3 36648 NULL
107693 +osd_req_list_collection_objects_36664 osd_req_list_collection_objects 5 36664 NULL
107694 +iscsi_host_alloc_36671 iscsi_host_alloc 2 36671 NULL
107695 +xillybus_read_36678 xillybus_read 3 36678 NULL
107696 +tlv_put_btrfs_timespec_36685 tlv_put_btrfs_timespec 0 36685 NULL nohasharray
107697 +ext4_mb_discard_group_preallocations_36685 ext4_mb_discard_group_preallocations 2 36685 &tlv_put_btrfs_timespec_36685
107698 +gsmtty_write_36702 gsmtty_write 3 36702 NULL
107699 +sched_clock_36717 sched_clock 0 36717 NULL
107700 +ocfs2_rotate_tree_right_36723 ocfs2_rotate_tree_right 0 36723 NULL
107701 +snd_rawmidi_kernel_read1_36740 snd_rawmidi_kernel_read1 4-0 36740 NULL
107702 +cxgbi_device_register_36746 cxgbi_device_register 2-1 36746 NULL
107703 +fc_exch_mgr_alloc_36751 fc_exch_mgr_alloc 3-4 36751 NULL
107704 +ps_poll_upsd_timeouts_read_36755 ps_poll_upsd_timeouts_read 3 36755 NULL
107705 +ext4_ext_convert_to_initialized_36765 ext4_ext_convert_to_initialized 0 36765 NULL
107706 +ptp_filter_init_36780 ptp_filter_init 2 36780 NULL
107707 +i40e_init_lan_hmc_36796 i40e_init_lan_hmc 2-3-4-5 36796 NULL
107708 +proc_fault_inject_read_36802 proc_fault_inject_read 3 36802 NULL
107709 +hiddev_ioctl_36816 hiddev_ioctl 2 36816 NULL
107710 +ocfs2_journal_access_rb_36823 ocfs2_journal_access_rb 0 36823 NULL
107711 +int_hardware_entry_36833 int_hardware_entry 3 36833 NULL
107712 +fc_change_queue_depth_36841 fc_change_queue_depth 2 36841 NULL
107713 +keyctl_describe_key_36853 keyctl_describe_key 3 36853 NULL
107714 +cm_write_36858 cm_write 3 36858 NULL
107715 +range_to_mtrr_with_hole_36861 range_to_mtrr_with_hole 2 36861 NULL
107716 +tx_tx_data_programmed_read_36871 tx_tx_data_programmed_read 3 36871 NULL
107717 +svc_setsockopt_36876 svc_setsockopt 5 36876 NULL
107718 +raid56_parity_write_36877 raid56_parity_write 5 36877 NULL
107719 +__btrfs_map_block_36883 __btrfs_map_block 3 36883 NULL
107720 +ib_ucm_alloc_data_36885 ib_ucm_alloc_data 3 36885 NULL
107721 +selinux_inode_notifysecctx_36896 selinux_inode_notifysecctx 3 36896 NULL
107722 +OS_kmalloc_36909 OS_kmalloc 1 36909 NULL
107723 +audio_set_endpoint_req_36918 audio_set_endpoint_req 0 36918 NULL
107724 +build_key_36931 build_key 1 36931 NULL
107725 +crypto_blkcipher_ivsize_36944 crypto_blkcipher_ivsize 0 36944 NULL
107726 +div_u64_36951 div_u64 0 36951 NULL
107727 +write_leb_36957 write_leb 0-5 36957 NULL
107728 +ntfs_external_attr_find_36963 ntfs_external_attr_find 0 36963 NULL
107729 +sparse_early_mem_maps_alloc_node_36971 sparse_early_mem_maps_alloc_node 4 36971 NULL
107730 +il4965_rs_sta_dbgfs_scale_table_write_36979 il4965_rs_sta_dbgfs_scale_table_write 3 36979 NULL
107731 +drbd_new_dev_size_36998 drbd_new_dev_size 0-3 36998 NULL
107732 +auok190xfb_write_37001 auok190xfb_write 3 37001 NULL
107733 +setxattr_37006 setxattr 4 37006 NULL
107734 +btrfs_update_root_37035 btrfs_update_root 0 37035 NULL
107735 +ocfs2_dlm_unlock_37037 ocfs2_dlm_unlock 0 37037 NULL
107736 +command_file_read_37038 command_file_read 3 37038 NULL
107737 +__hfsplus_brec_find_37048 __hfsplus_brec_find 0 37048 NULL
107738 +figure_loop_size_37051 figure_loop_size 2-3 37051 NULL
107739 +qp_broker_create_37053 qp_broker_create 6-5 37053 NULL nohasharray
107740 +ieee80211_if_read_drop_unencrypted_37053 ieee80211_if_read_drop_unencrypted 3 37053 &qp_broker_create_37053
107741 +SYSC_setxattr_37078 SYSC_setxattr 4 37078 NULL
107742 +parse_command_37079 parse_command 2 37079 NULL
107743 +pipeline_cs_rx_packet_in_read_37089 pipeline_cs_rx_packet_in_read 3 37089 NULL
107744 +tun_get_user_37094 tun_get_user 5 37094 NULL
107745 +has_wrprotected_page_37123 has_wrprotected_page 3-2 37123 NULL
107746 +snd_hda_get_conn_list_37132 snd_hda_get_conn_list 0 37132 NULL
107747 +mtt_free_res_37144 mtt_free_res 5 37144 NULL
107748 +msg_word_37164 msg_word 0 37164 NULL
107749 +BeceemNVMRead_37166 BeceemNVMRead 0 37166 NULL
107750 +f2fs_direct_IO_37167 f2fs_direct_IO 4 37167 NULL
107751 +can_set_xattr_37182 can_set_xattr 4 37182 NULL
107752 +btrfs_insert_delayed_items_37191 btrfs_insert_delayed_items 0 37191 NULL
107753 +vcc_recvmsg_37198 vcc_recvmsg 4 37198 NULL
107754 +sysfs_add_file_37200 sysfs_add_file 0 37200 NULL
107755 +mpol_misplaced_37205 mpol_misplaced 0 37205 NULL
107756 +forced_ps_write_37209 forced_ps_write 3 37209 NULL
107757 +crypto_shash_descsize_37212 crypto_shash_descsize 0 37212 NULL nohasharray
107758 +ext4_ind_direct_IO_37212 ext4_ind_direct_IO 0-4 37212 &crypto_shash_descsize_37212
107759 +bchannel_get_rxbuf_37213 bchannel_get_rxbuf 2-0 37213 NULL
107760 +regmap_access_read_file_37223 regmap_access_read_file 3 37223 NULL
107761 +__do_replace_37227 __do_replace 5 37227 NULL
107762 +produce_free_peb_37232 produce_free_peb 0 37232 NULL
107763 +iwl_dbgfs_d3_sram_read_37237 iwl_dbgfs_d3_sram_read 3 37237 NULL
107764 +rx_filter_dup_filter_read_37238 rx_filter_dup_filter_read 3 37238 NULL
107765 +BeceemFlashBulkWrite_37255 BeceemFlashBulkWrite 0 37255 NULL
107766 +prot_queue_del_37258 prot_queue_del 0 37258 NULL
107767 +exofs_max_io_pages_37263 exofs_max_io_pages 0-2 37263 NULL
107768 +__add_keyed_refs_37264 __add_keyed_refs 0 37264 NULL
107769 +nested_svm_map_37268 nested_svm_map 2 37268 NULL
107770 +create_cq_user_37278 create_cq_user 5 37278 NULL
107771 +request_threaded_irq_37303 request_threaded_irq 0 37303 NULL
107772 +ieee80211_if_read_power_mode_37305 ieee80211_if_read_power_mode 3 37305 NULL
107773 +ext3_direct_IO_37308 ext3_direct_IO 4 37308 NULL
107774 +jffs2_write_dirent_37311 jffs2_write_dirent 5 37311 NULL
107775 +send_msg_37323 send_msg 4 37323 NULL
107776 +l2cap_create_connless_pdu_37327 l2cap_create_connless_pdu 3 37327 NULL nohasharray
107777 +bnx2x_vf_fill_fw_str_37327 bnx2x_vf_fill_fw_str 3 37327 &l2cap_create_connless_pdu_37327
107778 +scsi_mode_select_37330 scsi_mode_select 6 37330 NULL
107779 +rxrpc_server_sendmsg_37331 rxrpc_server_sendmsg 4 37331 NULL
107780 +lz4_compressbound_37337 lz4_compressbound 0-1 37337 NULL
107781 +move_vma_37341 move_vma 0-5 37341 NULL
107782 +security_inode_getsecurity_37354 security_inode_getsecurity 0 37354 NULL
107783 +cl_io_submit_rw_37374 cl_io_submit_rw 0 37374 NULL
107784 +iterate_leaf_refs_37385 iterate_leaf_refs 0 37385 NULL
107785 +iommu_num_pages_37391 iommu_num_pages 0-1-3-2 37391 NULL
107786 +btrfs_find_free_objectid_37412 btrfs_find_free_objectid 0 37412 NULL
107787 +hci_sock_sendmsg_37420 hci_sock_sendmsg 4 37420 NULL
107788 +acpi_os_allocate_zeroed_37422 acpi_os_allocate_zeroed 1 37422 NULL nohasharray
107789 +find_next_bit_37422 find_next_bit 0-3-2 37422 &acpi_os_allocate_zeroed_37422
107790 +ocfs2_insert_path_37425 ocfs2_insert_path 0 37425 NULL
107791 +tty_insert_flip_string_fixed_flag_37428 tty_insert_flip_string_fixed_flag 4-0 37428 NULL
107792 +iwl_print_last_event_logs_37433 iwl_print_last_event_logs 0-7-9 37433 NULL
107793 +fru_alloc_37442 fru_alloc 1 37442 NULL
107794 +tcp_established_options_37450 tcp_established_options 0 37450 NULL
107795 +brcmf_sdio_dump_console_37455 brcmf_sdio_dump_console 4 37455 NULL
107796 +__remove_37457 __remove 2 37457 NULL
107797 +ufs_data_ptr_to_cpu_37475 ufs_data_ptr_to_cpu 0 37475 NULL
107798 +get_est_timing_37484 get_est_timing 0 37484 NULL
107799 +kmem_realloc_37489 kmem_realloc 2 37489 NULL
107800 +__hfsplus_setxattr_37499 __hfsplus_setxattr 4 37499 NULL
107801 +bitmap_dirty_bits_37503 bitmap_dirty_bits 2 37503 NULL
107802 +osc_active_seq_write_37514 osc_active_seq_write 3 37514 NULL
107803 +bdev_writeseg_37519 bdev_writeseg 2-3 37519 NULL nohasharray
107804 +vmalloc_32_user_37519 vmalloc_32_user 1 37519 &bdev_writeseg_37519
107805 +xz_dec_test_write_37527 xz_dec_test_write 3 37527 NULL
107806 +fault_inject_read_37534 fault_inject_read 3 37534 NULL
107807 +hdr_size_37536 hdr_size 0 37536 NULL
107808 +extent_map_end_37550 extent_map_end 0 37550 NULL
107809 +sep_create_dcb_dmatables_context_37551 sep_create_dcb_dmatables_context 6 37551 NULL
107810 +ioat_chansts_37558 ioat_chansts 0 37558 NULL
107811 +xhci_alloc_streams_37586 xhci_alloc_streams 5 37586 NULL
107812 +ocfs2_add_branch_37588 ocfs2_add_branch 0 37588 NULL
107813 +alloc_descs_37593 alloc_descs 0-1-3 37593 NULL
107814 +qla2x00_debounce_register_37597 qla2x00_debounce_register 0 37597 NULL
107815 +find_extent_clone_37603 find_extent_clone 0 37603 NULL
107816 +btrfs_write_and_wait_marked_extents_37604 btrfs_write_and_wait_marked_extents 0 37604 NULL
107817 +kvm_read_guest_page_mmu_37611 kvm_read_guest_page_mmu 6-3 37611 NULL
107818 +SYSC_mbind_37622 SYSC_mbind 5 37622 NULL nohasharray
107819 +ocfs2_split_refcount_rec_37622 ocfs2_split_refcount_rec 0 37622 &SYSC_mbind_37622
107820 +btrfs_calc_trans_metadata_size_37629 btrfs_calc_trans_metadata_size 0-2 37629 NULL nohasharray
107821 +policy_residency_37629 policy_residency 0 37629 &btrfs_calc_trans_metadata_size_37629
107822 +alloc_fd_37637 alloc_fd 1 37637 NULL
107823 +SyS_mbind_37638 SyS_mbind 5 37638 NULL
107824 +bio_copy_user_iov_37660 bio_copy_user_iov 4 37660 NULL
107825 +rfcomm_sock_sendmsg_37661 rfcomm_sock_sendmsg 4 37661 NULL nohasharray
107826 +vmw_framebuffer_dmabuf_dirty_37661 vmw_framebuffer_dmabuf_dirty 6 37661 &rfcomm_sock_sendmsg_37661
107827 +SYSC_get_mempolicy_37664 SYSC_get_mempolicy 4-3 37664 NULL
107828 +lnw_gpio_to_irq_37665 lnw_gpio_to_irq 2 37665 NULL
107829 +ieee80211_if_read_rc_rateidx_mcs_mask_2ghz_37675 ieee80211_if_read_rc_rateidx_mcs_mask_2ghz 3 37675 NULL
107830 +regmap_map_read_file_37685 regmap_map_read_file 3 37685 NULL
107831 +page_chain_free_37697 page_chain_free 0 37697 NULL
107832 +nametbl_header_37698 nametbl_header 2-0 37698 NULL
107833 +__le32_to_cpup_37702 __le32_to_cpup 0 37702 NULL
107834 +dynamic_ps_timeout_write_37713 dynamic_ps_timeout_write 3 37713 NULL
107835 +dm_thin_remove_block_37724 dm_thin_remove_block 2 37724 NULL
107836 +find_active_uprobe_37733 find_active_uprobe 1 37733 NULL
107837 +read_enabled_file_bool_37744 read_enabled_file_bool 3 37744 NULL
107838 +ocfs2_duplicate_clusters_by_jbd_37749 ocfs2_duplicate_clusters_by_jbd 5-4-6 37749 NULL
107839 +ocfs2_control_cfu_37750 ocfs2_control_cfu 2 37750 NULL
107840 +ipath_cdev_init_37752 ipath_cdev_init 1 37752 NULL
107841 +dccp_setsockopt_cscov_37766 dccp_setsockopt_cscov 2 37766 NULL
107842 +il4965_rs_sta_dbgfs_rate_scale_data_read_37792 il4965_rs_sta_dbgfs_rate_scale_data_read 3 37792 NULL
107843 +smk_read_logging_37804 smk_read_logging 3 37804 NULL
107844 +deny_write_access_37813 deny_write_access 0 37813 NULL
107845 +ocrdma_alloc_frmr_page_list_37815 ocrdma_alloc_frmr_page_list 2 37815 NULL
107846 +rx_decrypt_key_not_found_read_37820 rx_decrypt_key_not_found_read 3 37820 NULL
107847 +bitmap_find_next_zero_area_37827 bitmap_find_next_zero_area 2-3-0-5-4 37827 NULL
107848 +android_get_p2p_addr_37832 android_get_p2p_addr 0 37832 NULL
107849 +jbd2_journal_get_undo_access_37837 jbd2_journal_get_undo_access 0 37837 NULL
107850 +o2hb_debug_read_37851 o2hb_debug_read 3 37851 NULL
107851 +SYSC_pwrite64_37862 SYSC_pwrite64 3 37862 NULL
107852 +xfs_dir2_block_to_sf_37868 xfs_dir2_block_to_sf 3 37868 NULL
107853 +set_registers_37883 set_registers 4 37883 NULL
107854 +btrfs_stack_file_extent_disk_bytenr_37888 btrfs_stack_file_extent_disk_bytenr 0 37888 NULL
107855 +max77686_irq_domain_map_37897 max77686_irq_domain_map 2 37897 NULL
107856 +tipc_link_send_sections_fast_37920 tipc_link_send_sections_fast 4 37920 NULL
107857 +_rtw_malloc_37928 _rtw_malloc 1 37928 NULL nohasharray
107858 +pkt_alloc_packet_data_37928 pkt_alloc_packet_data 1 37928 &_rtw_malloc_37928
107859 +read_rbu_packet_size_37939 read_rbu_packet_size 6 37939 NULL
107860 +write_file_bool_37957 write_file_bool 3 37957 NULL
107861 +fifo_alloc_37961 fifo_alloc 1 37961 NULL
107862 +ext3_free_blocks_sb_37967 ext3_free_blocks_sb 4-3 37967 NULL
107863 +rds_rdma_extra_size_37990 rds_rdma_extra_size 0 37990 NULL
107864 +persistent_ram_old_size_37997 persistent_ram_old_size 0 37997 NULL
107865 +vfs_readv_38011 vfs_readv 3 38011 NULL
107866 +aggr_recv_addba_req_evt_38037 aggr_recv_addba_req_evt 4 38037 NULL
107867 +SyS_pwrite64_38041 SyS_pwrite64 3 38041 NULL
107868 +klsi_105_prepare_write_buffer_38044 klsi_105_prepare_write_buffer 3 38044 NULL nohasharray
107869 +il_dbgfs_chain_noise_read_38044 il_dbgfs_chain_noise_read 3 38044 &klsi_105_prepare_write_buffer_38044
107870 +SyS_llistxattr_38048 SyS_llistxattr 3 38048 NULL
107871 +sysfs_do_create_link_38051 sysfs_do_create_link 0 38051 NULL
107872 +_xfs_buf_alloc_38058 _xfs_buf_alloc 3 38058 NULL nohasharray
107873 +is_discarded_38058 is_discarded 2 38058 &_xfs_buf_alloc_38058
107874 +nsm_create_handle_38060 nsm_create_handle 4 38060 NULL
107875 +alloc_ltalkdev_38071 alloc_ltalkdev 1 38071 NULL
107876 +xfs_buf_readahead_map_38081 xfs_buf_readahead_map 3 38081 NULL
107877 +uwb_mac_addr_print_38085 uwb_mac_addr_print 2 38085 NULL
107878 +request_key_auth_new_38092 request_key_auth_new 3 38092 NULL
107879 +proc_self_readlink_38094 proc_self_readlink 3 38094 NULL
107880 +ep0_read_38095 ep0_read 3 38095 NULL
107881 +sk_wmem_schedule_38096 sk_wmem_schedule 2 38096 NULL nohasharray
107882 +osc_checksum_seq_write_38096 osc_checksum_seq_write 3 38096 &sk_wmem_schedule_38096
107883 +o2hb_read_slots_38105 o2hb_read_slots 2 38105 NULL
107884 +snd_pcm_oss_write_38108 snd_pcm_oss_write 3 38108 NULL
107885 +_get_val_38115 _get_val 2 38115 NULL
107886 +vmw_kms_present_38130 vmw_kms_present 9 38130 NULL
107887 +__ntfs_copy_from_user_iovec_inatomic_38153 __ntfs_copy_from_user_iovec_inatomic 0-4-3 38153 NULL
107888 +btrfs_extent_same_38163 btrfs_extent_same 3-2 38163 NULL
107889 +kvm_clear_guest_38164 kvm_clear_guest 3-2 38164 NULL
107890 +cirrus_ttm_tt_create_38167 cirrus_ttm_tt_create 2 38167 NULL
107891 +send_rename_38170 send_rename 0 38170 NULL
107892 +cdev_add_38176 cdev_add 2-3 38176 NULL
107893 +create_srq_user_38191 create_srq_user 5 38191 NULL
107894 +rt2x00debug_write_rf_38195 rt2x00debug_write_rf 3 38195 NULL
107895 +do_chunk_alloc_38200 do_chunk_alloc 0 38200 NULL
107896 +get_ucode_user_38202 get_ucode_user 3 38202 NULL
107897 +ext3_new_block_38208 ext3_new_block 3-0 38208 NULL
107898 +stmpe_gpio_irq_map_38222 stmpe_gpio_irq_map 3 38222 NULL
107899 +osd_req_list_partition_collections_38223 osd_req_list_partition_collections 5 38223 NULL
107900 +palmas_gpio_to_irq_38235 palmas_gpio_to_irq 2 38235 NULL
107901 +ceph_decode_16_38239 ceph_decode_16 0 38239 NULL
107902 +_ipw_read_reg32_38245 _ipw_read_reg32 0 38245 NULL
107903 +snd_pcm_playback_rewind_38249 snd_pcm_playback_rewind 0-2 38249 NULL
107904 +from_dblock_38256 from_dblock 0-1 38256 NULL
107905 +vmci_qp_broker_set_page_store_38260 vmci_qp_broker_set_page_store 3-2 38260 NULL
107906 +ieee80211_if_read_auto_open_plinks_38268 ieee80211_if_read_auto_open_plinks 3 38268 NULL nohasharray
107907 +SYSC_msgrcv_38268 SYSC_msgrcv 3 38268 &ieee80211_if_read_auto_open_plinks_38268 nohasharray
107908 +mthca_alloc_icm_table_38268 mthca_alloc_icm_table 4-3 38268 &SYSC_msgrcv_38268
107909 +xfs_bmbt_to_bmdr_38275 xfs_bmbt_to_bmdr 3 38275 NULL nohasharray
107910 +xfs_bmdr_to_bmbt_38275 xfs_bmdr_to_bmbt 5 38275 &xfs_bmbt_to_bmdr_38275
107911 +ftdi_process_packet_38281 ftdi_process_packet 4 38281 NULL
107912 +gpa_to_gfn_38291 gpa_to_gfn 0-1 38291 NULL
107913 +ucma_query_path_38305 ucma_query_path 3 38305 NULL
107914 +isr_rx_headers_read_38325 isr_rx_headers_read 3 38325 NULL
107915 +ida_simple_get_38326 ida_simple_get 2-0 38326 NULL
107916 +ocfs2_rotate_rightmost_leaf_left_38330 ocfs2_rotate_rightmost_leaf_left 0 38330 NULL
107917 +__snd_gf1_look8_38333 __snd_gf1_look8 0 38333 NULL
107918 +ocfs2_replace_extent_rec_38357 ocfs2_replace_extent_rec 0 38357 NULL
107919 +btrfs_file_extent_disk_num_bytes_38363 btrfs_file_extent_disk_num_bytes 0 38363 NULL
107920 +dn_sendmsg_38390 dn_sendmsg 4 38390 NULL
107921 +get_valid_node_allowed_38412 get_valid_node_allowed 1-0 38412 NULL
107922 +ocfs2_which_cluster_group_38413 ocfs2_which_cluster_group 0-2 38413 NULL
107923 +ht_destroy_irq_38418 ht_destroy_irq 1 38418 NULL
107924 +ieee80211_if_read_dtim_count_38419 ieee80211_if_read_dtim_count 3 38419 NULL
107925 +pmcraid_copy_sglist_38431 pmcraid_copy_sglist 3 38431 NULL
107926 +kvm_write_guest_38454 kvm_write_guest 4-2 38454 NULL
107927 +btrfs_next_old_leaf_38465 btrfs_next_old_leaf 0 38465 NULL
107928 +kvm_arch_setup_async_pf_38481 kvm_arch_setup_async_pf 3 38481 NULL
107929 +blk_end_bidi_request_38482 blk_end_bidi_request 4-3 38482 NULL
107930 +cpu_to_mem_38501 cpu_to_mem 0 38501 NULL
107931 +dev_names_read_38509 dev_names_read 3 38509 NULL
107932 +iscsi_create_iface_38510 iscsi_create_iface 5 38510 NULL
107933 +event_rx_mismatch_read_38518 event_rx_mismatch_read 3 38518 NULL
107934 +mlx4_ib_db_map_user_38529 mlx4_ib_db_map_user 2 38529 NULL
107935 +ubifs_idx_node_sz_38546 ubifs_idx_node_sz 0-2 38546 NULL
107936 +btrfs_discard_extent_38547 btrfs_discard_extent 2 38547 NULL
107937 +kuc_len_38557 kuc_len 0-1 38557 NULL
107938 +cpu_to_node_38561 cpu_to_node 0 38561 NULL
107939 +irda_sendmsg_dgram_38563 irda_sendmsg_dgram 4 38563 NULL
107940 +il4965_rs_sta_dbgfs_scale_table_read_38564 il4965_rs_sta_dbgfs_scale_table_read 3 38564 NULL
107941 +_ipw_read32_38565 _ipw_read32 0 38565 NULL
107942 +snd_nm256_playback_copy_38567 snd_nm256_playback_copy 5-3 38567 NULL
107943 +copy_ctl_value_to_user_38587 copy_ctl_value_to_user 4 38587 NULL
107944 +compat_sys_ptrace_38595 compat_sys_ptrace 3 38595 NULL
107945 +blkg_stat_read_38612 blkg_stat_read 0 38612 NULL
107946 +icn_writecmd_38629 icn_writecmd 2 38629 NULL
107947 +write_enabled_file_bool_38630 write_enabled_file_bool 3 38630 NULL
107948 +ext2_readpages_38640 ext2_readpages 4 38640 NULL
107949 +cma_create_area_38642 cma_create_area 2 38642 NULL
107950 +audit_init_entry_38644 audit_init_entry 1 38644 NULL
107951 +qp_broker_alloc_38646 qp_broker_alloc 6-5 38646 NULL
107952 +mmc_send_cxd_data_38655 mmc_send_cxd_data 5 38655 NULL
107953 +nouveau_instmem_create__38664 nouveau_instmem_create_ 4 38664 NULL
107954 +snd_es1371_wait_src_ready_38673 snd_es1371_wait_src_ready 0 38673 NULL
107955 +iscsit_dump_data_payload_38683 iscsit_dump_data_payload 2 38683 NULL
107956 +ext4_wait_block_bitmap_38695 ext4_wait_block_bitmap 2 38695 NULL
107957 +validate_vid_hdr_38699 validate_vid_hdr 0 38699 NULL
107958 +rbio_add_io_page_38700 rbio_add_io_page 6 38700 NULL
107959 +find_next_usable_block_38716 find_next_usable_block 3-1-0 38716 NULL
107960 +alloc_trace_probe_38720 alloc_trace_probe 6 38720 NULL
107961 +w83977af_sir_interrupt_38738 w83977af_sir_interrupt 0 38738 NULL
107962 +udf_readpages_38761 udf_readpages 4 38761 NULL
107963 +iwl_dbgfs_thermal_throttling_read_38779 iwl_dbgfs_thermal_throttling_read 3 38779 NULL
107964 +bcache_device_init_38781 bcache_device_init 3 38781 NULL
107965 +snd_gus_dram_write_38784 snd_gus_dram_write 4 38784 NULL
107966 +slab_order_38794 slab_order 0 38794 NULL
107967 +do_pci_enable_device_38802 do_pci_enable_device 0 38802 NULL
107968 +err_decode_38804 err_decode 2 38804 NULL
107969 +btrfs_find_space_cluster_38812 btrfs_find_space_cluster 4-0 38812 NULL
107970 +ipv6_renew_option_38813 ipv6_renew_option 3 38813 NULL
107971 +direct_entry_38836 direct_entry 3 38836 NULL
107972 +compat_udp_setsockopt_38840 compat_udp_setsockopt 5 38840 NULL
107973 +read_nic_io_word_38853 read_nic_io_word 0 38853 NULL
107974 +interfaces_38859 interfaces 2 38859 NULL
107975 +pci_msix_table_size_38867 pci_msix_table_size 0 38867 NULL
107976 +dbgfs_state_38894 dbgfs_state 3 38894 NULL
107977 +f2fs_xattr_set_acl_38895 f2fs_xattr_set_acl 4 38895 NULL
107978 +traverse_38897 traverse 0 38897 NULL
107979 +__fswab16_38898 __fswab16 0 38898 NULL
107980 +ext3_trim_all_free_38929 ext3_trim_all_free 4-3-2 38929 NULL
107981 +il_dbgfs_sram_write_38942 il_dbgfs_sram_write 3 38942 NULL
107982 +__ath6kl_wmi_send_mgmt_cmd_38971 __ath6kl_wmi_send_mgmt_cmd 7 38971 NULL
107983 +usb_maxpacket_38977 usb_maxpacket 0 38977 NULL nohasharray
107984 +C_SYSC_preadv64_38977 C_SYSC_preadv64 3 38977 &usb_maxpacket_38977
107985 +OSDSetBlock_38986 OSDSetBlock 2-4 38986 NULL
107986 +lpfc_idiag_extacc_write_38998 lpfc_idiag_extacc_write 3 38998 NULL
107987 +udf_new_block_38999 udf_new_block 4 38999 NULL
107988 +get_nodes_39012 get_nodes 3 39012 NULL
107989 +twl6030_interrupt_unmask_39013 twl6030_interrupt_unmask 2 39013 NULL
107990 +__blkdev_issue_zeroout_39020 __blkdev_issue_zeroout 3-0 39020 NULL
107991 +qgroup_account_ref_step1_39024 qgroup_account_ref_step1 0 39024 NULL
107992 +acpi_install_gpe_block_39031 acpi_install_gpe_block 4 39031 NULL
107993 +_zd_iowrite32v_async_locked_39034 _zd_iowrite32v_async_locked 3 39034 NULL
107994 +do_write_kmem_39051 do_write_kmem 1-3-0 39051 NULL
107995 +gen_pool_create_39064 gen_pool_create 2 39064 NULL
107996 +ext4_init_block_bitmap_39071 ext4_init_block_bitmap 3 39071 NULL
107997 +ReadHFC_39104 ReadHFC 0 39104 NULL
107998 +tomoyo_truncate_39105 tomoyo_truncate 0 39105 NULL
107999 +leb_write_lock_39111 leb_write_lock 0 39111 NULL
108000 +__kfifo_to_user_r_39123 __kfifo_to_user_r 5-3 39123 NULL
108001 +ttm_mem_global_alloc_zone_39125 ttm_mem_global_alloc_zone 0 39125 NULL
108002 +ea_foreach_39133 ea_foreach 0 39133 NULL
108003 +generic_permission_39150 generic_permission 0 39150 NULL
108004 +proc_coredump_filter_read_39153 proc_coredump_filter_read 3 39153 NULL
108005 +echo_client_kbrw_39170 echo_client_kbrw 6 39170 NULL
108006 +btrfs_start_delalloc_flush_39173 btrfs_start_delalloc_flush 0 39173 NULL
108007 +ext3_xattr_check_names_39174 ext3_xattr_check_names 0 39174 NULL
108008 +ubi_more_update_data_39189 ubi_more_update_data 4-0 39189 NULL
108009 +qcam_read_bytes_39205 qcam_read_bytes 0 39205 NULL
108010 +ivtv_v4l2_write_39226 ivtv_v4l2_write 3 39226 NULL
108011 +posix_acl_to_xattr_39237 posix_acl_to_xattr 0 39237 NULL
108012 +drm_order_39244 drm_order 0 39244 NULL
108013 +snd_pcm_capture_forward_39248 snd_pcm_capture_forward 0-2 39248 NULL
108014 +r128_compat_ioctl_39250 r128_compat_ioctl 2 39250 NULL nohasharray
108015 +pwr_cont_miss_bcns_spread_read_39250 pwr_cont_miss_bcns_spread_read 3 39250 &r128_compat_ioctl_39250
108016 +i915_error_state_read_39254 i915_error_state_read 3 39254 NULL
108017 +bitmap_set_bits_39272 bitmap_set_bits 3 39272 NULL
108018 +rx_filter_protection_filter_read_39282 rx_filter_protection_filter_read 3 39282 NULL
108019 +__vmalloc_node_39308 __vmalloc_node 1-5 39308 NULL
108020 +__cfg80211_connect_result_39326 __cfg80211_connect_result 4-6 39326 NULL
108021 +insert_reserved_file_extent_39327 insert_reserved_file_extent 3-0 39327 NULL
108022 +wimax_msg_alloc_39343 wimax_msg_alloc 4 39343 NULL
108023 +__copy_from_user_nocache_39351 __copy_from_user_nocache 3-0 39351 NULL
108024 +ide_complete_rq_39354 ide_complete_rq 3 39354 NULL
108025 +do_write_log_from_user_39362 do_write_log_from_user 3-0 39362 NULL
108026 +vortex_wtdma_getlinearpos_39371 vortex_wtdma_getlinearpos 0 39371 NULL
108027 +regmap_name_read_file_39379 regmap_name_read_file 3 39379 NULL
108028 +fnic_trace_debugfs_read_39380 fnic_trace_debugfs_read 3 39380 NULL
108029 +ps_poll_ps_poll_utilization_read_39383 ps_poll_ps_poll_utilization_read 3 39383 NULL
108030 +__send_to_port_39386 __send_to_port 3 39386 NULL
108031 +perf_trace_buf_submit_39413 perf_trace_buf_submit 5 39413 NULL
108032 +user_power_read_39414 user_power_read 3 39414 NULL
108033 +alloc_agpphysmem_i8xx_39427 alloc_agpphysmem_i8xx 1 39427 NULL
108034 +__vb2_get_done_vb_39448 __vb2_get_done_vb 0 39448 NULL
108035 +apei_resources_add_39470 apei_resources_add 0 39470 NULL
108036 +setkey_unaligned_39474 setkey_unaligned 3 39474 NULL
108037 +do_get_mempolicy_39485 do_get_mempolicy 3 39485 NULL
108038 +ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries_39499 ieee80211_if_fmt_dot11MeshHWMPmaxPREQretries 3 39499 NULL
108039 +cl_req_alloc_39523 cl_req_alloc 4 39523 NULL
108040 +int_proc_write_39542 int_proc_write 3 39542 NULL
108041 +pp_write_39554 pp_write 3 39554 NULL
108042 +ol_dqblk_block_39558 ol_dqblk_block 2-0-3 39558 NULL
108043 +datablob_format_39571 datablob_format 2 39571 NULL nohasharray
108044 +ieee80211_if_read_fwded_mcast_39571 ieee80211_if_read_fwded_mcast 3 39571 &datablob_format_39571
108045 +ext_depth_39607 ext_depth 0 39607 NULL
108046 +nfs_idmap_get_key_39616 nfs_idmap_get_key 2 39616 NULL
108047 +sdio_readb_39618 sdio_readb 0 39618 NULL
108048 +dm_exception_table_init_39645 dm_exception_table_init 2 39645 NULL nohasharray
108049 +set_dev_class_39645 set_dev_class 4 39645 &dm_exception_table_init_39645
108050 +snd_rme32_capture_copy_39653 snd_rme32_capture_copy 5 39653 NULL
108051 +tcp_try_rmem_schedule_39657 tcp_try_rmem_schedule 3 39657 NULL
108052 +kvm_read_guest_cached_39666 kvm_read_guest_cached 4 39666 NULL
108053 +v4l_stk_read_39672 v4l_stk_read 3 39672 NULL
108054 +hsc_msg_len_get_39673 hsc_msg_len_get 0 39673 NULL
108055 +do_surface_dirty_sou_39678 do_surface_dirty_sou 7 39678 NULL
108056 +vmx_set_cr3_39688 vmx_set_cr3 2 39688 NULL
108057 +sd_completed_bytes_39705 sd_completed_bytes 0 39705 NULL
108058 +ftrace_pid_write_39710 ftrace_pid_write 3 39710 NULL
108059 +test_add_free_space_entry_39754 test_add_free_space_entry 2-3 39754 NULL
108060 +adt7316_spi_multi_read_39765 adt7316_spi_multi_read 3 39765 NULL
108061 +remap_to_origin_clear_discard_39767 remap_to_origin_clear_discard 3 39767 NULL
108062 +crypto_ablkcipher_blocksize_39811 crypto_ablkcipher_blocksize 0 39811 NULL
108063 +security_inode_listsecurity_39812 security_inode_listsecurity 0 39812 NULL
108064 +snd_pcm_oss_writev3_39818 snd_pcm_oss_writev3 3 39818 NULL
108065 +get_priv_size_39828 get_priv_size 0-1 39828 NULL
108066 +can_rmdir_39890 can_rmdir 0 39890 NULL
108067 +pkt_add_39897 pkt_add 3 39897 NULL
108068 +read_file_modal_eeprom_39909 read_file_modal_eeprom 3 39909 NULL
108069 +gen_pool_add_virt_39913 gen_pool_add_virt 4-5 39913 NULL
108070 +dw210x_op_rw_39915 dw210x_op_rw 6 39915 NULL
108071 +dma_to_mm_pfn_39916 dma_to_mm_pfn 0-1 39916 NULL
108072 +aes_encrypt_interrupt_read_39919 aes_encrypt_interrupt_read 3 39919 NULL
108073 +exofs_read_kern_39921 exofs_read_kern 6 39921 NULL nohasharray
108074 +oom_score_adj_read_39921 oom_score_adj_read 3 39921 &exofs_read_kern_39921
108075 +__spi_async_39932 __spi_async 0 39932 NULL
108076 +__get_order_39935 __get_order 0 39935 NULL
108077 +error_error_frame_read_39947 error_error_frame_read 3 39947 NULL
108078 +tty_prepare_flip_string_39955 tty_prepare_flip_string 3-0 39955 NULL
108079 +lstcon_group_list_39958 lstcon_group_list 2 39958 NULL
108080 +dma_push_rx_39973 dma_push_rx 2 39973 NULL
108081 +broadsheetfb_write_39976 broadsheetfb_write 3 39976 NULL
108082 +mthca_array_init_39987 mthca_array_init 2 39987 NULL
108083 +fw_device_op_read_39990 fw_device_op_read 3 39990 NULL
108084 +server_name2svname_39998 server_name2svname 4 39998 NULL
108085 +xen_hvm_config_40018 xen_hvm_config 2 40018 NULL
108086 +ivtvfb_write_40023 ivtvfb_write 3 40023 NULL
108087 +disc_pwup_write_40027 disc_pwup_write 3 40027 NULL
108088 +ea_foreach_i_40028 ea_foreach_i 0 40028 NULL
108089 +datablob_hmac_append_40038 datablob_hmac_append 3 40038 NULL
108090 +regmap_add_irq_chip_40042 regmap_add_irq_chip 4 40042 NULL
108091 +ocfs2_claim_clusters_40050 ocfs2_claim_clusters 0 40050 NULL
108092 +add_tty_40055 add_tty 1 40055 NULL nohasharray
108093 +l2cap_create_iframe_pdu_40055 l2cap_create_iframe_pdu 3 40055 &add_tty_40055
108094 +atomic_xchg_40070 atomic_xchg 0 40070 NULL
108095 +snd_pcm_sw_params_user_40095 snd_pcm_sw_params_user 0 40095 NULL
108096 +gen_pool_first_fit_40110 gen_pool_first_fit 2-3-4 40110 NULL
108097 +sctp_setsockopt_delayed_ack_40129 sctp_setsockopt_delayed_ack 3 40129 NULL
108098 +dwc2_max_desc_num_40132 dwc2_max_desc_num 0 40132 NULL
108099 +rx_rx_frame_checksum_read_40140 rx_rx_frame_checksum_read 3 40140 NULL
108100 +ath10k_write_simulate_fw_crash_40143 ath10k_write_simulate_fw_crash 3 40143 NULL
108101 +iwch_alloc_fastreg_pbl_40153 iwch_alloc_fastreg_pbl 2 40153 NULL
108102 +clone_backref_node_40154 clone_backref_node 0 40154 NULL
108103 +pt_write_40159 pt_write 3 40159 NULL
108104 +scsi_sg_count_40182 scsi_sg_count 0 40182 NULL
108105 +ipr_alloc_ucode_buffer_40199 ipr_alloc_ucode_buffer 1 40199 NULL nohasharray
108106 +devnode_find_40199 devnode_find 3-2 40199 &ipr_alloc_ucode_buffer_40199
108107 +allocate_probes_40204 allocate_probes 1 40204 NULL
108108 +acpi_system_write_alarm_40205 acpi_system_write_alarm 3 40205 NULL
108109 +au0828_v4l2_read_40220 au0828_v4l2_read 3 40220 NULL
108110 +compress_file_range_40225 compress_file_range 3-4 40225 NULL
108111 +osst_read_40237 osst_read 3 40237 NULL
108112 +lpage_info_slot_40243 lpage_info_slot 3-1 40243 NULL
108113 +ocfs2_zero_extend_get_range_40248 ocfs2_zero_extend_get_range 4-3 40248 NULL
108114 +rs_sta_dbgfs_scale_table_read_40262 rs_sta_dbgfs_scale_table_read 3 40262 NULL
108115 +ext2_fiemap_40271 ext2_fiemap 4 40271 NULL
108116 +usbnet_read_cmd_40275 usbnet_read_cmd 7 40275 NULL
108117 +rx_xfr_hint_trig_read_40283 rx_xfr_hint_trig_read 3 40283 NULL
108118 +vfio_unmap_unpin_40284 vfio_unmap_unpin 3 40284 NULL
108119 +_calc_trunk_info_40291 _calc_trunk_info 2 40291 NULL
108120 +SyS_bind_40303 SyS_bind 3 40303 NULL
108121 +ubi_io_write_data_40305 ubi_io_write_data 0-5-4 40305 NULL
108122 +batadv_tt_changes_fill_buff_40323 batadv_tt_changes_fill_buff 4 40323 NULL
108123 +ib_get_mad_data_offset_40336 ib_get_mad_data_offset 0 40336 NULL
108124 +mmio_read_40348 mmio_read 4 40348 NULL
108125 +ocfs2_release_clusters_40355 ocfs2_release_clusters 4-0 40355 NULL
108126 +event_rx_mem_empty_read_40363 event_rx_mem_empty_read 3 40363 NULL
108127 +ocfs2_check_range_for_refcount_40365 ocfs2_check_range_for_refcount 3-2 40365 NULL
108128 +get_chars_40373 get_chars 3 40373 NULL
108129 +submit_page_section_40408 submit_page_section 0 40408 NULL
108130 +ecryptfs_read_lower_40419 ecryptfs_read_lower 3 40419 NULL
108131 +slab_node_40421 slab_node 0 40421 NULL
108132 +fb_prepare_extra_logos_40429 fb_prepare_extra_logos 0-2 40429 NULL
108133 +tomoyo_update_policy_40458 tomoyo_update_policy 2 40458 NULL
108134 +zd_usb_scnprint_id_40459 zd_usb_scnprint_id 0-3 40459 NULL
108135 +SyS_writev_40467 SyS_writev 3 40467 NULL
108136 +__i915_add_request_40469 __i915_add_request 0 40469 NULL
108137 +SyS_select_40473 SyS_select 1 40473 NULL
108138 +afs_fs_store_data_40484 afs_fs_store_data 3-4-5-6 40484 NULL
108139 +batadv_hash_new_40491 batadv_hash_new 1 40491 NULL
108140 +devcgroup_inode_permission_40492 devcgroup_inode_permission 0 40492 NULL
108141 +drm_vma_node_start_40500 drm_vma_node_start 0 40500 NULL
108142 +sg_phys_40507 sg_phys 0 40507 NULL
108143 +__ethtool_get_sset_count_40511 __ethtool_get_sset_count 0 40511 NULL
108144 +TSS_checkhmac2_40520 TSS_checkhmac2 7-5 40520 NULL
108145 +ixgbe_dbg_reg_ops_read_40540 ixgbe_dbg_reg_ops_read 3 40540 NULL
108146 +i915_gem_execbuffer_relocate_object_slow_40546 i915_gem_execbuffer_relocate_object_slow 0 40546 NULL
108147 +ima_write_policy_40548 ima_write_policy 3 40548 NULL
108148 +btrfs_flush_all_pending_stuffs_40553 btrfs_flush_all_pending_stuffs 0 40553 NULL
108149 +esp_alloc_tmp_40558 esp_alloc_tmp 2-3 40558 NULL
108150 +ufs_inode_getfrag_40560 ufs_inode_getfrag 2-4 40560 NULL
108151 +bdev_sectors_40564 bdev_sectors 0 40564 NULL
108152 +lba_to_map_index_40580 lba_to_map_index 0-1 40580 NULL
108153 +b1_get_byte_40597 b1_get_byte 0 40597 NULL
108154 +get_priv_descr_and_size_40612 get_priv_descr_and_size 0 40612 NULL
108155 +qla8044_rd_reg_40652 qla8044_rd_reg 0 40652 NULL
108156 +pid_nr_ns_40654 pid_nr_ns 0 40654 NULL
108157 +twl4030_kpwrite_u8_40665 twl4030_kpwrite_u8 3 40665 NULL
108158 +__cfg80211_roamed_40668 __cfg80211_roamed 4-6 40668 NULL
108159 +pipeline_rx_complete_stat_fifo_int_read_40671 pipeline_rx_complete_stat_fifo_int_read 3 40671 NULL
108160 +fops_read_40672 fops_read 3 40672 NULL
108161 +ext4_mark_inode_dirty_40673 ext4_mark_inode_dirty 0 40673 NULL
108162 +idr_get_empty_slot_40674 idr_get_empty_slot 0 40674 NULL
108163 +alloc_rbio_40676 alloc_rbio 4 40676 NULL
108164 +videobuf_dma_init_user_locked_40678 videobuf_dma_init_user_locked 3-4 40678 NULL
108165 +pci_enable_resources_40680 pci_enable_resources 0 40680 NULL
108166 +nfc_hci_set_param_40697 nfc_hci_set_param 5 40697 NULL
108167 +__seq_open_private_40715 __seq_open_private 3 40715 NULL
108168 +btrfs_find_one_extref_40724 btrfs_find_one_extref 0 40724 NULL
108169 +fuse_readpages_40737 fuse_readpages 4 40737 NULL
108170 +xfs_iext_remove_direct_40744 xfs_iext_remove_direct 3 40744 NULL nohasharray
108171 +find_next_zero_bit_le_40744 find_next_zero_bit_le 2-3-0 40744 &xfs_iext_remove_direct_40744
108172 +i915_gem_execbuffer_relocate_entry_40750 i915_gem_execbuffer_relocate_entry 0 40750 NULL
108173 +security_inode_listxattr_40752 security_inode_listxattr 0 40752 NULL
108174 +card_send_command_40757 card_send_command 3 40757 NULL
108175 +ad1889_readl_40765 ad1889_readl 0 40765 NULL
108176 +pg_write_40766 pg_write 3 40766 NULL
108177 +show_list_40775 show_list 3-0 40775 NULL
108178 +calcu_metadata_size_40782 calcu_metadata_size 0 40782 NULL
108179 +kfifo_out_copy_r_40784 kfifo_out_copy_r 3-0 40784 NULL
108180 +bitmap_weight_40791 bitmap_weight 0-2 40791 NULL
108181 +pyra_sysfs_read_40795 pyra_sysfs_read 6 40795 NULL
108182 +add_action_40811 add_action 4 40811 NULL
108183 +nl80211_send_roamed_40825 nl80211_send_roamed 5-7 40825 NULL
108184 +SyS_mbind_40828 SyS_mbind 5 40828 NULL
108185 +__mlx4_qp_reserve_range_40847 __mlx4_qp_reserve_range 2-3 40847 NULL
108186 +nilfs_mdt_init_40849 nilfs_mdt_init 3 40849 NULL
108187 +ocfs2_zero_partial_clusters_40856 ocfs2_zero_partial_clusters 2-3 40856 NULL
108188 +v9fs_file_read_40858 v9fs_file_read 3 40858 NULL
108189 +read_file_queue_40895 read_file_queue 3 40895 NULL
108190 +btrfs_set_inode_index_count_40901 btrfs_set_inode_index_count 0 40901 NULL
108191 +waiters_read_40902 waiters_read 3 40902 NULL
108192 +isdn_add_channels_40905 isdn_add_channels 3 40905 NULL
108193 +gfs2_ea_find_40913 gfs2_ea_find 0 40913 NULL
108194 +vol_cdev_write_40915 vol_cdev_write 3 40915 NULL
108195 +snd_vx_create_40948 snd_vx_create 4 40948 NULL nohasharray
108196 +sg_alloc_table_40948 sg_alloc_table 0 40948 &snd_vx_create_40948
108197 +wm8994_free_irq_40951 wm8994_free_irq 2 40951 NULL
108198 +rds_sendmsg_40976 rds_sendmsg 4 40976 NULL
108199 +btrfs_find_orphan_item_40977 btrfs_find_orphan_item 0 40977 NULL
108200 +insert_old_idx_40987 insert_old_idx 0 40987 NULL
108201 +il_dbgfs_fh_reg_read_40993 il_dbgfs_fh_reg_read 3 40993 NULL
108202 +mac80211_format_buffer_41010 mac80211_format_buffer 2 41010 NULL
108203 +mtd_block_isbad_41015 mtd_block_isbad 0 41015 NULL
108204 +__proc_dobitmasks_41029 __proc_dobitmasks 5 41029 NULL
108205 +_req_append_segment_41031 _req_append_segment 2 41031 NULL
108206 +mISDN_sock_sendmsg_41035 mISDN_sock_sendmsg 4 41035 NULL
108207 +ocfs2_xattr_index_block_find_41040 ocfs2_xattr_index_block_find 0 41040 NULL
108208 +lprocfs_write_frac_helper_41050 lprocfs_write_frac_helper 2 41050 NULL
108209 +BcmFlash2xBulkWrite_41054 BcmFlash2xBulkWrite 0 41054 NULL
108210 +calculate_order_41061 calculate_order 0 41061 NULL
108211 +vfs_listxattr_41062 vfs_listxattr 0 41062 NULL nohasharray
108212 +beacon_filtering_write_41062 beacon_filtering_write 3 41062 &vfs_listxattr_41062
108213 +cfg80211_inform_bss_frame_41078 cfg80211_inform_bss_frame 4 41078 NULL
108214 +roccat_read_41093 roccat_read 3 41093 NULL nohasharray
108215 +nvme_map_user_pages_41093 nvme_map_user_pages 4-3 41093 &roccat_read_41093
108216 +dma_attach_41094 dma_attach 6-5 41094 NULL
108217 +provide_user_output_41105 provide_user_output 3 41105 NULL
108218 +f_audio_buffer_alloc_41110 f_audio_buffer_alloc 1 41110 NULL
108219 +ath10k_read_wmi_services_41112 ath10k_read_wmi_services 3 41112 NULL
108220 +ocfs2_extend_trans_41116 ocfs2_extend_trans 0 41116 NULL
108221 +btrfs_subvolume_reserve_metadata_41130 btrfs_subvolume_reserve_metadata 3 41130 NULL
108222 +v4l2_ctrl_new_int_menu_41151 v4l2_ctrl_new_int_menu 4 41151 NULL
108223 +tx_frag_mpdu_alloc_failed_read_41167 tx_frag_mpdu_alloc_failed_read 3 41167 NULL
108224 +dvb_ca_write_41171 dvb_ca_write 3 41171 NULL
108225 +ol_quota_chunk_block_41177 ol_quota_chunk_block 0-2 41177 NULL
108226 +dgap_driver_kzmalloc_41189 dgap_driver_kzmalloc 1 41189 NULL
108227 +compat_sys_process_vm_writev_41194 compat_sys_process_vm_writev 3-5 41194 NULL
108228 +dfs_file_write_41196 dfs_file_write 3 41196 NULL
108229 +ocfs2_read_quota_block_41207 ocfs2_read_quota_block 2 41207 NULL
108230 +nfs_page_array_len_41219 nfs_page_array_len 0-2-1 41219 NULL
108231 +cfg80211_process_disassoc_41231 cfg80211_process_disassoc 3 41231 NULL
108232 +hiddev_compat_ioctl_41255 hiddev_compat_ioctl 2 41255 NULL
108233 +create_dir_41256 create_dir 0 41256 NULL
108234 +erst_read_41260 erst_read 0 41260 NULL
108235 +setup_cluster_bitmap_41270 setup_cluster_bitmap 4-0 41270 NULL
108236 +alloc_context_41283 alloc_context 1 41283 NULL
108237 +objio_alloc_io_state_41316 objio_alloc_io_state 7-6 41316 NULL
108238 +o2hb_setup_one_bio_41341 o2hb_setup_one_bio 4 41341 NULL
108239 +twl_change_queue_depth_41342 twl_change_queue_depth 2 41342 NULL
108240 +rtw_android_set_block_41347 rtw_android_set_block 0 41347 NULL
108241 +irq_expand_nr_irqs_41351 irq_expand_nr_irqs 0 41351 NULL
108242 +cnic_init_id_tbl_41354 cnic_init_id_tbl 2 41354 NULL
108243 +jbd2_alloc_41359 jbd2_alloc 1 41359 NULL
108244 +kmp_init_41373 kmp_init 2 41373 NULL
108245 +netlink_alloc_large_skb_41375 netlink_alloc_large_skb 1 41375 NULL
108246 +isr_commands_read_41398 isr_commands_read 3 41398 NULL
108247 +is_writethrough_io_41406 is_writethrough_io 3 41406 NULL
108248 +rx_defrag_decrypt_failed_read_41411 rx_defrag_decrypt_failed_read 3 41411 NULL
108249 +xfs_iext_add_41422 xfs_iext_add 3 41422 NULL
108250 +isdn_ppp_fill_rq_41428 isdn_ppp_fill_rq 2 41428 NULL
108251 +lbs_rdrf_read_41431 lbs_rdrf_read 3 41431 NULL
108252 +vmemmap_populate_hugepages_41434 vmemmap_populate_hugepages 3 41434 NULL
108253 +iio_device_alloc_41440 iio_device_alloc 1 41440 NULL
108254 +ntfs_file_buffered_write_41442 ntfs_file_buffered_write 6-4 41442 NULL
108255 +pcpu_build_alloc_info_41443 pcpu_build_alloc_info 1-2-3 41443 NULL
108256 +layout_leb_in_gaps_41470 layout_leb_in_gaps 0 41470 NULL
108257 +snd_pcm_status_41472 snd_pcm_status 0 41472 NULL
108258 +rt2x00debug_write_rfcsr_41473 rt2x00debug_write_rfcsr 3 41473 NULL
108259 +bl_alloc_init_bio_41478 bl_alloc_init_bio 1 41478 NULL
108260 +split_item_41483 split_item 0 41483 NULL
108261 +kvm_unmap_hva_range_41484 kvm_unmap_hva_range 3-2 41484 NULL
108262 +ipath_user_sdma_page_length_41490 ipath_user_sdma_page_length 0-2-1 41490 NULL
108263 +wep_interrupt_read_41492 wep_interrupt_read 3 41492 NULL
108264 +SyS_get_mempolicy_41495 SyS_get_mempolicy 3-4 41495 NULL
108265 +hpfs_translate_name_41497 hpfs_translate_name 3 41497 NULL
108266 +xfrm_hash_new_size_41505 xfrm_hash_new_size 0-1 41505 NULL
108267 +perf_sw_event_41517 perf_sw_event 2 41517 NULL
108268 +SyS_preadv_41523 SyS_preadv 3 41523 NULL
108269 +dm_get_reserved_rq_based_ios_41529 dm_get_reserved_rq_based_ios 0 41529 NULL
108270 +add_excluded_extent_41547 add_excluded_extent 0 41547 NULL
108271 +tx_tx_frame_checksum_read_41553 tx_tx_frame_checksum_read 3 41553 NULL
108272 +ath6kl_endpoint_stats_read_41554 ath6kl_endpoint_stats_read 3 41554 NULL
108273 +si476x_radio_fops_read_41559 si476x_radio_fops_read 3 41559 NULL nohasharray
108274 +nr_status_frames_41559 nr_status_frames 0-1 41559 &si476x_radio_fops_read_41559
108275 +rng_dev_read_41581 rng_dev_read 3 41581 NULL
108276 +vga_io_r_41609 vga_io_r 0 41609 NULL
108277 +tcp_hdrlen_41610 tcp_hdrlen 0 41610 NULL
108278 +lbs_bcnmiss_write_41613 lbs_bcnmiss_write 3 41613 NULL nohasharray
108279 +usb_endpoint_maxp_41613 usb_endpoint_maxp 0 41613 &lbs_bcnmiss_write_41613
108280 +a2mp_send_41615 a2mp_send 4 41615 NULL
108281 +btrfs_calc_trunc_metadata_size_41626 btrfs_calc_trunc_metadata_size 0-2 41626 NULL
108282 +lstcon_batch_list_41627 lstcon_batch_list 2 41627 NULL
108283 +mempool_create_kmalloc_pool_41650 mempool_create_kmalloc_pool 1 41650 NULL
108284 +rx_rx_pre_complt_read_41653 rx_rx_pre_complt_read 3 41653 NULL
108285 +get_std_timing_41654 get_std_timing 0 41654 NULL
108286 +start_graph_tracing_41656 start_graph_tracing 0 41656 NULL
108287 +ieee80211_if_fmt_bssid_41677 ieee80211_if_fmt_bssid 3 41677 NULL
108288 +params_period_bytes_41683 params_period_bytes 0 41683 NULL
108289 +fill_pcm_stream_name_41685 fill_pcm_stream_name 2 41685 NULL
108290 +lov_unpackmd_41701 lov_unpackmd 4 41701 NULL
108291 +__ext3_journal_get_write_access_41705 __ext3_journal_get_write_access 0 41705 NULL
108292 +apei_exec_for_each_entry_41717 apei_exec_for_each_entry 0 41717 NULL
108293 +bdx_tx_db_init_41719 bdx_tx_db_init 2 41719 NULL
108294 +ocfs2_block_group_fill_41744 ocfs2_block_group_fill 0 41744 NULL
108295 +fillonedir_41746 fillonedir 3 41746 NULL
108296 +ocfs2_dx_dir_rebalance_41793 ocfs2_dx_dir_rebalance 7 41793 NULL
108297 +iwl_dbgfs_bt_notif_read_41794 iwl_dbgfs_bt_notif_read 3 41794 NULL
108298 +remap_pte_range_41800 remap_pte_range 5 41800 NULL
108299 +hsi_alloc_controller_41802 hsi_alloc_controller 1 41802 NULL
108300 +regcache_sync_block_raw_41803 regcache_sync_block_raw 4-3 41803 NULL
108301 +rtw_android_get_macaddr_41812 rtw_android_get_macaddr 0 41812 NULL
108302 +da9052_enable_irq_41814 da9052_enable_irq 2 41814 NULL
108303 +sco_send_frame_41815 sco_send_frame 3 41815 NULL
108304 +lp_gpio_to_irq_41822 lp_gpio_to_irq 2 41822 NULL
108305 +ixgbe_dbg_netdev_ops_read_41839 ixgbe_dbg_netdev_ops_read 3 41839 NULL
108306 +do_ip_setsockopt_41852 do_ip_setsockopt 5 41852 NULL
108307 +keyctl_instantiate_key_41855 keyctl_instantiate_key 3 41855 NULL
108308 +pci_map_single_41869 pci_map_single 0 41869 NULL
108309 +usb_gadget_get_string_41871 usb_gadget_get_string 0 41871 NULL
108310 +v_APCI3120_InterruptDmaMoveBlock16bit_41914 v_APCI3120_InterruptDmaMoveBlock16bit 4 41914 NULL
108311 +get_fdb_entries_41916 get_fdb_entries 3 41916 NULL
108312 +find_ge_pid_41918 find_ge_pid 1 41918 NULL
108313 +build_inv_iotlb_pages_41922 build_inv_iotlb_pages 4-5 41922 NULL
108314 +nfsd_getxattr_41934 nfsd_getxattr 0 41934 NULL
108315 +ext4_da_write_inline_data_begin_41935 ext4_da_write_inline_data_begin 3-4 41935 NULL
108316 +read_gssp_41947 read_gssp 3 41947 NULL
108317 +ocfs2_xattr_bucket_get_name_value_41949 ocfs2_xattr_bucket_get_name_value 0 41949 NULL
108318 +portnames_read_41958 portnames_read 3 41958 NULL
108319 +ubi_self_check_all_ff_41959 ubi_self_check_all_ff 0-4 41959 NULL
108320 +dst_mtu_41969 dst_mtu 0 41969 NULL
108321 +btrfs_check_trunc_cache_free_space_41973 btrfs_check_trunc_cache_free_space 0 41973 NULL
108322 +cx24116_writeregN_41975 cx24116_writeregN 4 41975 NULL
108323 +ubi_io_is_bad_41983 ubi_io_is_bad 0 41983 NULL
108324 +pool_allocate_42012 pool_allocate 3 42012 NULL
108325 +spidev_sync_read_42014 spidev_sync_read 0 42014 NULL
108326 +rs_sta_dbgfs_scale_table_write_42017 rs_sta_dbgfs_scale_table_write 3 42017 NULL
108327 +nouveau_ttm_tt_create_42026 nouveau_ttm_tt_create 2 42026 NULL
108328 +acpi_ut_create_buffer_object_42030 acpi_ut_create_buffer_object 1 42030 NULL
108329 +__btrfs_drop_extents_42032 __btrfs_drop_extents 5-0 42032 NULL
108330 +__hwahc_op_set_gtk_42038 __hwahc_op_set_gtk 4 42038 NULL
108331 +irda_sendmsg_ultra_42047 irda_sendmsg_ultra 4 42047 NULL
108332 +dma_generic_alloc_coherent_42048 dma_generic_alloc_coherent 2 42048 NULL nohasharray
108333 +jffs2_do_link_42048 jffs2_do_link 6 42048 &dma_generic_alloc_coherent_42048
108334 +ps_poll_upsd_max_ap_turn_read_42050 ps_poll_upsd_max_ap_turn_read 3 42050 NULL
108335 +InterfaceTransmitPacket_42058 InterfaceTransmitPacket 3 42058 NULL
108336 +alloc_bitset_42085 alloc_bitset 1 42085 NULL
108337 +scsi_execute_req_42088 scsi_execute_req 5 42088 NULL
108338 +sk_chk_filter_42095 sk_chk_filter 2 42095 NULL
108339 +send_truncate_42107 send_truncate 0 42107 NULL
108340 +submit_inquiry_42108 submit_inquiry 3 42108 NULL
108341 +sysfs_read_file_42113 sysfs_read_file 3 42113 NULL nohasharray
108342 +dw_dma_cyclic_prep_42113 dw_dma_cyclic_prep 3-4 42113 &sysfs_read_file_42113
108343 +__btrfs_unlink_inode_42114 __btrfs_unlink_inode 0 42114 NULL
108344 +ext4_do_update_inode_42127 ext4_do_update_inode 0 42127 NULL
108345 +blk_ioctl_zeroout_42160 blk_ioctl_zeroout 3 42160 NULL
108346 +mmc_align_data_size_42161 mmc_align_data_size 0-2 42161 NULL
108347 +kvm_lapic_get_cr8_42166 kvm_lapic_get_cr8 0 42166 NULL
108348 +read_file_base_eeprom_42168 read_file_base_eeprom 3 42168 NULL
108349 +oprofilefs_str_to_user_42182 oprofilefs_str_to_user 3 42182 NULL
108350 +write_file_beacon_42185 write_file_beacon 3 42185 NULL
108351 +get_znodes_to_commit_42201 get_znodes_to_commit 0 42201 NULL
108352 +ocfs2_resv_window_bits_42207 ocfs2_resv_window_bits 0 42207 NULL
108353 +pla_ocp_read_42235 pla_ocp_read 3 42235 NULL
108354 +rx_defrag_need_decrypt_read_42253 rx_defrag_need_decrypt_read 3 42253 NULL
108355 +vfio_remove_dma_overlap_42255 vfio_remove_dma_overlap 2 42255 NULL
108356 +__pcpu_size_to_slot_42271 __pcpu_size_to_slot 0 42271 NULL
108357 +snd_pcm_hw_param_value_max_42280 snd_pcm_hw_param_value_max 0 42280 NULL
108358 +__cpus_weight_42299 __cpus_weight 2-0 42299 NULL
108359 +sel_read_perm_42302 sel_read_perm 3 42302 NULL
108360 +sctp_setsockopt_del_key_42304 sctp_setsockopt_del_key 3 42304 NULL nohasharray
108361 +ulong_read_file_42304 ulong_read_file 3 42304 &sctp_setsockopt_del_key_42304
108362 +gfn_to_hva_42305 gfn_to_hva 2-0 42305 NULL
108363 +close_cur_inode_file_42308 close_cur_inode_file 0 42308 NULL nohasharray
108364 +xfs_vm_readpages_42308 xfs_vm_readpages 4 42308 &close_cur_inode_file_42308
108365 +free_cblock_42318 free_cblock 2 42318 NULL
108366 +hysdn_conf_read_42324 hysdn_conf_read 3 42324 NULL
108367 +tcp_sync_mss_42330 tcp_sync_mss 2-0 42330 NULL
108368 +snd_pcm_plug_alloc_42339 snd_pcm_plug_alloc 2 42339 NULL
108369 +ide_raw_taskfile_42355 ide_raw_taskfile 4 42355 NULL
108370 +drbd_md_last_sector_42378 drbd_md_last_sector 0 42378 NULL
108371 +il_dbgfs_disable_ht40_read_42386 il_dbgfs_disable_ht40_read 3 42386 NULL
108372 +hash_ipportnet4_expire_42391 hash_ipportnet4_expire 3 42391 NULL
108373 +msnd_fifo_read_42406 msnd_fifo_read 0-3 42406 NULL
108374 +krng_get_random_42420 krng_get_random 3 42420 NULL
108375 +gsm_data_alloc_42437 gsm_data_alloc 3 42437 NULL
108376 +key_conf_keyidx_read_42443 key_conf_keyidx_read 3 42443 NULL
108377 +alloc_request_42448 alloc_request 0 42448 NULL
108378 +snd_pcm_action_group_42452 snd_pcm_action_group 0 42452 NULL
108379 +tcm_loop_change_queue_depth_42454 tcm_loop_change_queue_depth 2 42454 NULL
108380 +kuc_free_42455 kuc_free 2 42455 NULL
108381 +tc3589x_gpio_irq_get_virq_42457 tc3589x_gpio_irq_get_virq 2 42457 NULL
108382 +ext3_valid_block_bitmap_42459 ext3_valid_block_bitmap 3 42459 NULL
108383 +__simple_xattr_set_42474 __simple_xattr_set 4 42474 NULL
108384 +follow_hugetlb_page_42486 follow_hugetlb_page 0-7 42486 NULL
108385 +omfs_readpages_42490 omfs_readpages 4 42490 NULL
108386 +bypass_write_42498 bypass_write 3 42498 NULL
108387 +SyS_mincore_42511 SyS_mincore 1-2 42511 NULL
108388 +jbd2_log_wait_commit_42519 jbd2_log_wait_commit 0 42519 NULL
108389 +kvm_write_wall_clock_42520 kvm_write_wall_clock 2 42520 NULL
108390 +dio_bio_complete_42524 dio_bio_complete 0 42524 NULL
108391 +smk_write_netlbladdr_42525 smk_write_netlbladdr 3 42525 NULL
108392 +self_check_ec_hdr_42528 self_check_ec_hdr 0 42528 NULL
108393 +__register_ftrace_function_42543 __register_ftrace_function 0 42543 NULL
108394 +dbAllocNear_42546 dbAllocNear 0 42546 NULL
108395 +inorder_next_42548 inorder_next 1-0 42548 NULL
108396 +ath6kl_wmi_proc_events_vif_42549 ath6kl_wmi_proc_events_vif 5 42549 NULL
108397 +udp_recvmsg_42558 udp_recvmsg 4 42558 NULL
108398 +iwl_print_event_log_42566 iwl_print_event_log 0-5-7 42566 NULL
108399 +ocfs2_reserve_suballoc_bits_42569 ocfs2_reserve_suballoc_bits 0 42569 NULL
108400 +xfrm_new_hash_mask_42579 xfrm_new_hash_mask 0-1 42579 NULL
108401 +oom_score_adj_write_42594 oom_score_adj_write 3 42594 NULL
108402 +map_state_42602 map_state 1 42602 NULL
108403 +resp_write_42628 resp_write 2 42628 NULL
108404 +ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout_42635 ieee80211_if_fmt_dot11MeshHWMPactivePathTimeout 3 42635 NULL
108405 +scsi_activate_tcq_42640 scsi_activate_tcq 2 42640 NULL
108406 +br_mdb_rehash_42643 br_mdb_rehash 2 42643 NULL
108407 +parport_pc_compat_write_block_pio_42644 parport_pc_compat_write_block_pio 3 42644 NULL
108408 +ocfs2_search_chain_42655 ocfs2_search_chain 0 42655 NULL
108409 +request_key_and_link_42693 request_key_and_link 4 42693 NULL
108410 +acpi_dev_get_irqresource_42694 acpi_dev_get_irqresource 2 42694 NULL
108411 +vb2_read_42703 vb2_read 3 42703 NULL
108412 +__ocfs2_decrease_refcount_42717 __ocfs2_decrease_refcount 5-4-0 42717 NULL
108413 +read_status_42722 read_status 0 42722 NULL
108414 +dvb_demux_ioctl_42733 dvb_demux_ioctl 2 42733 NULL
108415 +set_aoe_iflist_42737 set_aoe_iflist 2 42737 NULL
108416 +ax25_setsockopt_42740 ax25_setsockopt 5 42740 NULL
108417 +xen_bind_pirq_gsi_to_irq_42750 xen_bind_pirq_gsi_to_irq 1 42750 NULL
108418 +dpm_sysfs_add_42756 dpm_sysfs_add 0 42756 NULL
108419 +x25_recvmsg_42777 x25_recvmsg 4 42777 NULL
108420 +snd_midi_event_decode_42780 snd_midi_event_decode 0 42780 NULL
108421 +cryptd_hash_setkey_42781 cryptd_hash_setkey 3 42781 NULL nohasharray
108422 +isku_sysfs_read_info_42781 isku_sysfs_read_info 6 42781 &cryptd_hash_setkey_42781
108423 +elfcorehdr_read_notes_42786 elfcorehdr_read_notes 2 42786 NULL
108424 +koneplus_sysfs_read_42792 koneplus_sysfs_read 6 42792 NULL
108425 +ntfs_attr_extend_allocation_42796 ntfs_attr_extend_allocation 0-2-3 42796 NULL
108426 +fw_device_op_compat_ioctl_42804 fw_device_op_compat_ioctl 2 42804 NULL
108427 +drm_ioctl_42813 drm_ioctl 2 42813 NULL
108428 +iwl_dbgfs_ucode_bt_stats_read_42820 iwl_dbgfs_ucode_bt_stats_read 3 42820 NULL
108429 +xfs_iomap_eof_prealloc_initial_size_42822 xfs_iomap_eof_prealloc_initial_size 0-3 42822 NULL
108430 +set_arg_42824 set_arg 3 42824 NULL
108431 +si476x_radio_read_rsq_blob_42827 si476x_radio_read_rsq_blob 3 42827 NULL
108432 +ocfs2_desc_bitmap_to_cluster_off_42831 ocfs2_desc_bitmap_to_cluster_off 2 42831 NULL
108433 +prandom_u32_42853 prandom_u32 0 42853 NULL
108434 +ntfs_mapping_pairs_build_42859 ntfs_mapping_pairs_build 0 42859 NULL
108435 +nouveau_vm_create_42869 nouveau_vm_create 3-2 42869 NULL
108436 +ocfs2_clusters_for_bytes_42872 ocfs2_clusters_for_bytes 0-2 42872 NULL
108437 +nvme_trans_unit_serial_page_42879 nvme_trans_unit_serial_page 4 42879 NULL
108438 +xpc_kmalloc_cacheline_aligned_42895 xpc_kmalloc_cacheline_aligned 1 42895 NULL
108439 +hd_end_request_42904 hd_end_request 2 42904 NULL
108440 +sta_last_rx_rate_read_42909 sta_last_rx_rate_read 3 42909 NULL
108441 +sctp_getsockopt_maxburst_42941 sctp_getsockopt_maxburst 2 42941 NULL
108442 +get_unmapped_area_42944 get_unmapped_area 0 42944 NULL
108443 +vx_reset_chk_42946 vx_reset_chk 0 42946 NULL
108444 +send_link_42948 send_link 0 42948 NULL
108445 +blkdev_direct_IO_42962 blkdev_direct_IO 4 42962 NULL
108446 +read_file_node_stat_42964 read_file_node_stat 3 42964 NULL
108447 +compat_udpv6_setsockopt_42981 compat_udpv6_setsockopt 5 42981 NULL
108448 +nfs_idmap_get_desc_42990 nfs_idmap_get_desc 2-4 42990 NULL nohasharray
108449 +rtw_os_xmit_resource_alloc_42990 rtw_os_xmit_resource_alloc 3 42990 &nfs_idmap_get_desc_42990
108450 +mlx4_qp_reserve_range_43000 mlx4_qp_reserve_range 2-3 43000 NULL
108451 +isr_rx_mem_overflow_read_43025 isr_rx_mem_overflow_read 3 43025 NULL
108452 +add_bytes_to_bitmap_43026 add_bytes_to_bitmap 0-3-4 43026 NULL
108453 +init_phys_status_page_43028 init_phys_status_page 0 43028 NULL
108454 +wep_default_key_count_read_43035 wep_default_key_count_read 3 43035 NULL
108455 +send_to_group_43051 send_to_group 0 43051 NULL
108456 +nouveau_gpuobj_create__43072 nouveau_gpuobj_create_ 9 43072 NULL
108457 +nfs_map_group_to_gid_43082 nfs_map_group_to_gid 3 43082 NULL
108458 +ieee80211_if_fmt_drop_unencrypted_43107 ieee80211_if_fmt_drop_unencrypted 3 43107 NULL
108459 +calculate_node_totalpages_43118 calculate_node_totalpages 2-3 43118 NULL
108460 +cow_file_range_inline_43132 cow_file_range_inline 4 43132 NULL
108461 +read_file_dfs_43145 read_file_dfs 3 43145 NULL
108462 +cfs_cpt_table_alloc_43159 cfs_cpt_table_alloc 1 43159 NULL
108463 +usb_string_sub_43164 usb_string_sub 0 43164 NULL
108464 +il_dbgfs_power_save_status_read_43165 il_dbgfs_power_save_status_read 3 43165 NULL
108465 +send_cmd_43168 send_cmd 0 43168 NULL
108466 +ath6kl_set_assoc_req_ies_43185 ath6kl_set_assoc_req_ies 3 43185 NULL
108467 +ext4_xattr_ibody_get_43200 ext4_xattr_ibody_get 0 43200 NULL
108468 +uio_write_43202 uio_write 3 43202 NULL
108469 +iso_callback_43208 iso_callback 3 43208 NULL
108470 +ath10k_p2p_calc_noa_ie_len_43209 ath10k_p2p_calc_noa_ie_len 0 43209 NULL
108471 +f2fs_acl_from_disk_43210 f2fs_acl_from_disk 2 43210 NULL
108472 +atomic_long_add_return_43217 atomic_long_add_return 1-0 43217 NULL
108473 +vmemmap_alloc_block_43245 vmemmap_alloc_block 1-2 43245 NULL
108474 +fixup_leb_43256 fixup_leb 3 43256 NULL
108475 +ide_end_rq_43269 ide_end_rq 4 43269 NULL
108476 +nilfs_direct_IO_43271 nilfs_direct_IO 4 43271 NULL
108477 +mlx5_ib_reg_user_mr_43275 mlx5_ib_reg_user_mr 2-3 43275 NULL
108478 +parport_pc_ecp_write_block_pio_43278 parport_pc_ecp_write_block_pio 3 43278 NULL nohasharray
108479 +evtchn_write_43278 evtchn_write 3 43278 &parport_pc_ecp_write_block_pio_43278
108480 +filemap_write_and_wait_range_43279 filemap_write_and_wait_range 0 43279 NULL
108481 +mpage_alloc_43299 mpage_alloc 3 43299 NULL
108482 +get_nr_irqs_gsi_43315 get_nr_irqs_gsi 0 43315 NULL
108483 +mmu_set_spte_43327 mmu_set_spte 7-6 43327 NULL
108484 +__ext4_get_inode_loc_43332 __ext4_get_inode_loc 0 43332 NULL
108485 +kvm_host_page_size_43348 kvm_host_page_size 2-0 43348 NULL
108486 +activation_descriptor_init_43358 activation_descriptor_init 1 43358 NULL
108487 +gart_free_coherent_43362 gart_free_coherent 4-2 43362 NULL
108488 +hash_net4_expire_43378 hash_net4_expire 3 43378 NULL
108489 +xenfb_write_43412 xenfb_write 3 43412 NULL
108490 +__alloc_bootmem_low_43423 __alloc_bootmem_low 1 43423 NULL
108491 +usb_alloc_urb_43436 usb_alloc_urb 1 43436 NULL
108492 +ath6kl_wmi_roam_tbl_event_rx_43440 ath6kl_wmi_roam_tbl_event_rx 3 43440 NULL
108493 +ocfs2_rotate_tree_left_43442 ocfs2_rotate_tree_left 0 43442 NULL
108494 +usb_string_43443 usb_string 0 43443 NULL nohasharray
108495 +usemap_size_43443 usemap_size 0-2-1 43443 &usb_string_43443
108496 +get_vm_area_size_43444 get_vm_area_size 0 43444 NULL
108497 +nvme_trans_device_id_page_43466 nvme_trans_device_id_page 4 43466 NULL
108498 +calculate_discard_block_size_43480 calculate_discard_block_size 0 43480 NULL nohasharray
108499 +alloc_new_reservation_43480 alloc_new_reservation 4-0-2 43480 &calculate_discard_block_size_43480
108500 +tx_tx_data_prepared_read_43497 tx_tx_data_prepared_read 3 43497 NULL
108501 +ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime_43505 ieee80211_if_fmt_dot11MeshHWMPnetDiameterTraversalTime 3 43505 NULL
108502 +do_readlink_43518 do_readlink 2 43518 NULL
108503 +dvb_ca_en50221_io_write_43533 dvb_ca_en50221_io_write 3 43533 NULL
108504 +read_events_43534 read_events 3 43534 NULL
108505 +cachefiles_daemon_write_43535 cachefiles_daemon_write 3 43535 NULL
108506 +tx_frag_failed_read_43540 tx_frag_failed_read 3 43540 NULL nohasharray
108507 +ufs_alloccg_block_43540 ufs_alloccg_block 3-0 43540 &tx_frag_failed_read_43540
108508 +request_resource_43548 request_resource 0 43548 NULL
108509 +rpc_malloc_43573 rpc_malloc 2 43573 NULL
108510 +handle_frequent_errors_43599 handle_frequent_errors 4 43599 NULL
108511 +lpfc_idiag_drbacc_read_reg_43606 lpfc_idiag_drbacc_read_reg 0-3 43606 NULL
108512 +proc_read_43614 proc_read 3 43614 NULL
108513 +i915_gem_execbuffer_relocate_object_slow_43618 i915_gem_execbuffer_relocate_object_slow 0 43618 NULL nohasharray
108514 +disable_dma_on_even_43618 disable_dma_on_even 0 43618 &i915_gem_execbuffer_relocate_object_slow_43618
108515 +alloc_thread_groups_43625 alloc_thread_groups 2 43625 NULL
108516 +random_write_43656 random_write 3 43656 NULL
108517 +bio_integrity_tag_43658 bio_integrity_tag 3 43658 NULL
108518 +ext4_acl_count_43659 ext4_acl_count 0-1 43659 NULL
108519 +fs_path_copy_43673 fs_path_copy 0 43673 NULL
108520 +dmam_declare_coherent_memory_43679 dmam_declare_coherent_memory 4 43679 NULL
108521 +calgary_map_page_43686 calgary_map_page 4 43686 NULL
108522 +max77693_bulk_write_43698 max77693_bulk_write 2-3 43698 NULL
108523 +wait_for_completion_interruptible_43723 wait_for_completion_interruptible 0 43723 NULL
108524 +drbd_md_first_sector_43729 drbd_md_first_sector 0 43729 NULL
108525 +reset_card_proc_43731 reset_card_proc 0 43731 NULL
108526 +snd_rme32_playback_copy_43732 snd_rme32_playback_copy 5 43732 NULL
108527 +ocfs2_replace_clusters_43733 ocfs2_replace_clusters 5-0 43733 NULL
108528 +fuse_conn_congestion_threshold_write_43736 fuse_conn_congestion_threshold_write 3 43736 NULL
108529 +__bm_find_next_43748 __bm_find_next 2 43748 NULL
108530 +gigaset_initcs_43753 gigaset_initcs 2 43753 NULL
108531 +sctp_setsockopt_active_key_43755 sctp_setsockopt_active_key 3 43755 NULL
108532 +ocfs2_xattr_get_value_outside_43787 ocfs2_xattr_get_value_outside 0 43787 NULL nohasharray
108533 +byte_pos_43787 byte_pos 0-2 43787 &ocfs2_xattr_get_value_outside_43787
108534 +btrfs_copy_from_user_43806 btrfs_copy_from_user 0-3-1 43806 NULL
108535 +ext4_read_block_bitmap_43814 ext4_read_block_bitmap 2 43814 NULL
108536 +div64_u64_safe_43815 div64_u64_safe 2-1 43815 NULL
108537 +ext4_split_extent_43818 ext4_split_extent 0 43818 NULL
108538 +i915_gem_execbuffer_relocate_entry_43822 i915_gem_execbuffer_relocate_entry 0 43822 NULL
108539 +ieee80211_if_fmt_element_ttl_43825 ieee80211_if_fmt_element_ttl 3 43825 NULL
108540 +ieee80211_alloc_hw_43829 ieee80211_alloc_hw 1 43829 NULL
108541 +read_flush_43851 read_flush 3 43851 NULL
108542 +ocfs2_block_group_find_clear_bits_43874 ocfs2_block_group_find_clear_bits 4 43874 NULL
108543 +pm860x_bulk_write_43875 pm860x_bulk_write 2-3 43875 NULL
108544 +SendString_43928 SendString 3 43928 NULL
108545 +xen_register_gsi_43946 xen_register_gsi 2-1 43946 NULL
108546 +stats_dot11RTSFailureCount_read_43948 stats_dot11RTSFailureCount_read 3 43948 NULL
108547 +perf_tp_event_43971 perf_tp_event 2 43971 NULL
108548 +__get_required_blob_size_43980 __get_required_blob_size 0-3-2 43980 NULL
108549 +nla_reserve_43984 nla_reserve 3 43984 NULL
108550 +__clkdev_alloc_43990 __clkdev_alloc 1 43990 NULL
108551 +scsi_command_size_43992 scsi_command_size 0 43992 NULL nohasharray
108552 +kvm_read_guest_virt_43992 kvm_read_guest_virt 4-2 43992 &scsi_command_size_43992 nohasharray
108553 +bcm_recvmsg_43992 bcm_recvmsg 4 43992 &kvm_read_guest_virt_43992
108554 +ulist_add_43994 ulist_add 0 43994 NULL
108555 +emit_flags_44006 emit_flags 4-3 44006 NULL
108556 +write_flush_procfs_44011 write_flush_procfs 3 44011 NULL
108557 +fru_strlen_44046 fru_strlen 0 44046 NULL
108558 +tree_insert_offset_44069 tree_insert_offset 0 44069 NULL
108559 +SYSC_add_key_44079 SYSC_add_key 4 44079 NULL
108560 +btrfs_prev_leaf_44083 btrfs_prev_leaf 0 44083 NULL nohasharray
108561 +load_discard_44083 load_discard 3 44083 &btrfs_prev_leaf_44083
108562 +__vxge_hw_vpath_tim_configure_44093 __vxge_hw_vpath_tim_configure 2 44093 NULL
108563 +xlog_recover_add_to_cont_trans_44102 xlog_recover_add_to_cont_trans 4 44102 NULL
108564 +skb_frag_dma_map_44112 skb_frag_dma_map 0 44112 NULL
108565 +tracing_set_trace_read_44122 tracing_set_trace_read 3 44122 NULL
108566 +hwif_to_node_44127 hwif_to_node 0 44127 NULL
108567 +SyS_process_vm_writev_44129 SyS_process_vm_writev 3-5 44129 NULL
108568 +vmw_gmr_bind_44130 vmw_gmr_bind 3 44130 NULL
108569 +lookup_extent_data_ref_44136 lookup_extent_data_ref 0 44136 NULL
108570 +ttm_get_pages_44142 ttm_get_pages 2 44142 NULL
108571 +scsi_get_resid_44147 scsi_get_resid 0 44147 NULL
108572 +ubifs_find_dirty_idx_leb_44169 ubifs_find_dirty_idx_leb 0 44169 NULL
108573 +ocfs2_xattr_bucket_find_44174 ocfs2_xattr_bucket_find 0 44174 NULL
108574 +SYSC_set_mempolicy_44176 SYSC_set_mempolicy 3 44176 NULL
108575 +readreg_ipac_44186 readreg_ipac 0 44186 NULL
108576 +handle_eviocgbit_44193 handle_eviocgbit 3 44193 NULL
108577 +IO_APIC_get_PCI_irq_vector_44198 IO_APIC_get_PCI_irq_vector 0 44198 NULL
108578 +__set_free_44211 __set_free 2 44211 NULL
108579 +claim_ptd_buffers_44213 claim_ptd_buffers 3 44213 NULL
108580 +srp_alloc_iu_44227 srp_alloc_iu 2 44227 NULL
108581 +ioapic_register_intr_44238 ioapic_register_intr 1 44238 NULL
108582 +scsi_track_queue_full_44239 scsi_track_queue_full 2 44239 NULL
108583 +sigma_action_write_regmap_44240 sigma_action_write_regmap 3 44240 NULL
108584 +tc3589x_gpio_irq_map_44245 tc3589x_gpio_irq_map 2 44245 NULL
108585 +apei_resources_sub_44252 apei_resources_sub 0 44252 NULL
108586 +byt_gpio_irq_map_44275 byt_gpio_irq_map 2 44275 NULL
108587 +device_create_file_44285 device_create_file 0 44285 NULL
108588 +ufs_clusteracct_44293 ufs_clusteracct 3 44293 NULL
108589 +ocfs2_zero_range_for_truncate_44294 ocfs2_zero_range_for_truncate 3 44294 NULL
108590 +ath6kl_keepalive_read_44303 ath6kl_keepalive_read 3 44303 NULL
108591 +bitmap_scnprintf_44318 bitmap_scnprintf 0-2 44318 NULL
108592 +dispatch_proc_write_44320 dispatch_proc_write 3 44320 NULL
108593 +rs_init_44327 rs_init 1 44327 NULL
108594 +create_free_space_inode_44332 create_free_space_inode 0 44332 NULL
108595 +insert_into_bitmap_44340 insert_into_bitmap 0 44340 NULL
108596 +ubi_eba_write_leb_st_44343 ubi_eba_write_leb_st 0-5 44343 NULL
108597 +radix_tree_maybe_preload_44346 radix_tree_maybe_preload 0 44346 NULL
108598 +nfs_fscache_get_super_cookie_44355 nfs_fscache_get_super_cookie 3 44355 NULL nohasharray
108599 +blk_queue_init_tags_44355 blk_queue_init_tags 2 44355 &nfs_fscache_get_super_cookie_44355
108600 +__is_discarded_44359 __is_discarded 2 44359 NULL
108601 +ipx_recvmsg_44366 ipx_recvmsg 4 44366 NULL
108602 +alloc_requests_44372 alloc_requests 0 44372 NULL
108603 +rts_threshold_read_44384 rts_threshold_read 3 44384 NULL
108604 +iterate_dir_item_44386 iterate_dir_item 0 44386 NULL
108605 +mtip_hw_read_flags_44396 mtip_hw_read_flags 3 44396 NULL
108606 +aoedev_flush_44398 aoedev_flush 2 44398 NULL
108607 +strlcpy_44400 strlcpy 3 44400 NULL
108608 +drm_buffer_alloc_44405 drm_buffer_alloc 2 44405 NULL
108609 +osst_do_scsi_44410 osst_do_scsi 4 44410 NULL
108610 +check_user_page_hwpoison_44412 check_user_page_hwpoison 1 44412 NULL
108611 +ieee80211_if_read_rc_rateidx_mcs_mask_5ghz_44423 ieee80211_if_read_rc_rateidx_mcs_mask_5ghz 3 44423 NULL
108612 +iwl_dbgfs_bf_params_write_44450 iwl_dbgfs_bf_params_write 3 44450 NULL
108613 +write_file_debug_44476 write_file_debug 3 44476 NULL
108614 +btrfs_chunk_item_size_44478 btrfs_chunk_item_size 0-1 44478 NULL
108615 +sdio_align_size_44489 sdio_align_size 0-2 44489 NULL
108616 +bio_advance_44496 bio_advance 2 44496 NULL
108617 +ieee80211_if_read_dropped_frames_ttl_44500 ieee80211_if_read_dropped_frames_ttl 3 44500 NULL
108618 +ac_register_board_44504 ac_register_board 3 44504 NULL
108619 +security_getprocattr_44505 security_getprocattr 0 44505 NULL nohasharray
108620 +iwl_dbgfs_sram_read_44505 iwl_dbgfs_sram_read 3 44505 &security_getprocattr_44505
108621 +spidev_write_44510 spidev_write 3 44510 NULL
108622 +SyS_io_getevents_44519 SyS_io_getevents 3 44519 NULL
108623 +ieee80211_rx_mgmt_assoc_resp_44525 ieee80211_rx_mgmt_assoc_resp 3 44525 NULL
108624 +comm_write_44537 comm_write 3 44537 NULL
108625 +xfs_log_calc_unit_res_44540 xfs_log_calc_unit_res 0-2 44540 NULL
108626 +snd_pcm_drop_44542 snd_pcm_drop 0 44542 NULL
108627 +dbg_chk_pnode_44555 dbg_chk_pnode 0 44555 NULL
108628 +shmem_getpage_gfp_44556 shmem_getpage_gfp 0 44556 NULL
108629 +hash_ipport4_expire_44564 hash_ipport4_expire 3 44564 NULL
108630 +dgrp_config_proc_write_44571 dgrp_config_proc_write 3 44571 NULL
108631 +snd_pcm_alloc_vmalloc_buffer_44595 snd_pcm_alloc_vmalloc_buffer 2 44595 NULL
108632 +btrfs_qgroup_account_ref_44604 btrfs_qgroup_account_ref 0 44604 NULL
108633 +huge_page_shift_44618 huge_page_shift 0 44618 NULL
108634 +sysfs_add_one_44629 sysfs_add_one 0 44629 NULL
108635 +msb_get_free_block_44633 msb_get_free_block 2 44633 NULL
108636 +ext2_new_block_44645 ext2_new_block 2-0 44645 NULL
108637 +alloc_ctrl_packet_44667 alloc_ctrl_packet 1 44667 NULL
108638 +mpi_resize_44674 mpi_resize 2 44674 NULL
108639 +sysfs_create_link_44685 sysfs_create_link 0 44685 NULL nohasharray
108640 +__copy_user_intel_nocache_44685 __copy_user_intel_nocache 0-3 44685 &sysfs_create_link_44685
108641 +ts_read_44687 ts_read 3 44687 NULL
108642 +qib_get_user_pages_44689 qib_get_user_pages 1-2 44689 NULL
108643 +lov_emerg_alloc_44698 lov_emerg_alloc 1 44698 NULL
108644 +__ocfs2_rotate_tree_left_44705 __ocfs2_rotate_tree_left 0 44705 NULL
108645 +xfer_to_user_44713 xfer_to_user 3 44713 NULL nohasharray
108646 +__generic_block_fiemap_44713 __generic_block_fiemap 4 44713 &xfer_to_user_44713
108647 +_zd_iowrite32v_locked_44725 _zd_iowrite32v_locked 3 44725 NULL
108648 +clusterip_proc_write_44729 clusterip_proc_write 3 44729 NULL
108649 +fib_count_nexthops_44730 fib_count_nexthops 0 44730 NULL
108650 +SyS_read_44732 SyS_read 3 44732 NULL
108651 +vm_insert_mixed_44738 vm_insert_mixed 3 44738 NULL
108652 +key_tx_rx_count_read_44742 key_tx_rx_count_read 3 44742 NULL
108653 +set_brk_44749 set_brk 1-2 44749 NULL
108654 +tnode_new_44757 tnode_new 3 44757 NULL nohasharray
108655 +pty_write_44757 pty_write 3 44757 &tnode_new_44757
108656 +__videobuf_copy_stream_44769 __videobuf_copy_stream 4-0 44769 NULL
108657 +handsfree_ramp_44777 handsfree_ramp 2 44777 NULL
108658 +irq_domain_add_legacy_44781 irq_domain_add_legacy 4-2 44781 NULL
108659 +sctp_setsockopt_44788 sctp_setsockopt 5 44788 NULL
108660 +rx_dropped_read_44799 rx_dropped_read 3 44799 NULL
108661 +qla4xxx_alloc_work_44813 qla4xxx_alloc_work 2 44813 NULL
108662 +mei_cl_read_start_44824 mei_cl_read_start 2 44824 NULL
108663 +rmap_write_protect_44833 rmap_write_protect 2 44833 NULL
108664 +sisusb_write_44834 sisusb_write 3 44834 NULL
108665 +kvm_read_hva_44847 kvm_read_hva 3 44847 NULL
108666 +cubic_root_44848 cubic_root 1 44848 NULL
108667 +qib_verbs_send_dma_44850 qib_verbs_send_dma 6 44850 NULL
108668 +copydesc_user_44855 copydesc_user 3 44855 NULL
108669 +i915_gem_execbuffer_relocate_44868 i915_gem_execbuffer_relocate 0 44868 NULL
108670 +init_rs_44873 init_rs 1 44873 NULL
108671 +skb_availroom_44883 skb_availroom 0 44883 NULL
108672 +ocfs2_wait_for_mask_44893 ocfs2_wait_for_mask 0 44893 NULL
108673 +do_tty_write_44896 do_tty_write 5 44896 NULL
108674 +regmap_spi_read_44921 regmap_spi_read 3-5 44921 NULL
108675 +_snd_pcm_hw_param_last_44947 _snd_pcm_hw_param_last 0 44947 NULL
108676 +__add_delayed_refs_44977 __add_delayed_refs 0 44977 NULL
108677 +tx_queue_status_read_44978 tx_queue_status_read 3 44978 NULL
108678 +map_index_to_lba_44993 map_index_to_lba 0-1 44993 NULL
108679 +send_chmod_45011 send_chmod 0 45011 NULL
108680 +i915_gem_do_execbuffer_45012 i915_gem_do_execbuffer 0 45012 NULL
108681 +bytepos_delta_45017 bytepos_delta 0-2 45017 NULL
108682 +read_block_bitmap_45021 read_block_bitmap 2 45021 NULL nohasharray
108683 +ptrace_writedata_45021 ptrace_writedata 4-3 45021 &read_block_bitmap_45021
108684 +dm_kvzalloc_45025 dm_kvzalloc 1-2 45025 NULL
108685 +vhci_get_user_45039 vhci_get_user 3 45039 NULL
108686 +sysfs_do_create_link_sd_45057 sysfs_do_create_link_sd 0 45057 NULL
108687 +remap_oldmem_pfn_range_45060 remap_oldmem_pfn_range 2-3-4 45060 NULL nohasharray
108688 +sel_write_user_45060 sel_write_user 3 45060 &remap_oldmem_pfn_range_45060
108689 +vmscan_swappiness_45062 vmscan_swappiness 0 45062 NULL
108690 +snd_mixart_BA0_read_45069 snd_mixart_BA0_read 5 45069 NULL
108691 +kvm_mmu_page_get_gfn_45110 kvm_mmu_page_get_gfn 0-2 45110 NULL
108692 +pwr_missing_bcns_cnt_read_45113 pwr_missing_bcns_cnt_read 3 45113 NULL
108693 +usbdev_read_45114 usbdev_read 3 45114 NULL
108694 +send_to_tty_45141 send_to_tty 3 45141 NULL
108695 +stmpe_irq_map_45146 stmpe_irq_map 2 45146 NULL
108696 +cfs_trace_daemon_command_usrstr_45147 cfs_trace_daemon_command_usrstr 2 45147 NULL
108697 +gen_bitmask_string_45149 gen_bitmask_string 6 45149 NULL
108698 +ocfs2_remove_inode_range_45156 ocfs2_remove_inode_range 3-4 45156 NULL nohasharray
108699 +device_write_45156 device_write 3 45156 &ocfs2_remove_inode_range_45156
108700 +ocfs2_dq_frozen_trigger_45159 ocfs2_dq_frozen_trigger 4 45159 NULL
108701 +SYSC_write_45160 SYSC_write 3 45160 NULL
108702 +tomoyo_write_self_45161 tomoyo_write_self 3 45161 NULL
108703 +sta_agg_status_write_45164 sta_agg_status_write 3 45164 NULL
108704 +sctp_pack_cookie_45190 sctp_pack_cookie 6 45190 NULL nohasharray
108705 +snd_sb_csp_load_user_45190 snd_sb_csp_load_user 3 45190 &sctp_pack_cookie_45190
108706 +num_clusters_in_group_45194 num_clusters_in_group 2 45194 NULL
108707 +__radix_tree_preload_45197 __radix_tree_preload 0 45197 NULL
108708 +iso_alloc_urb_45206 iso_alloc_urb 4-5 45206 NULL
108709 +spi_alloc_master_45223 spi_alloc_master 2 45223 NULL
108710 +__dirty_45228 __dirty 2 45228 NULL
108711 +ieee80211_if_read_peer_45233 ieee80211_if_read_peer 3 45233 NULL
108712 +event_enable_write_45238 event_enable_write 3 45238 NULL
108713 +prism2_pda_proc_read_45246 prism2_pda_proc_read 3 45246 NULL
108714 +input_mt_init_slots_45279 input_mt_init_slots 2 45279 NULL
108715 +gfs2_fiemap_45282 gfs2_fiemap 4 45282 NULL
108716 +snd_pcm_oss_sync1_45298 snd_pcm_oss_sync1 2 45298 NULL
108717 +e1000_tx_map_45309 e1000_tx_map 5 45309 NULL
108718 +pte_val_45313 pte_val 0 45313 NULL
108719 +copy_vm86_regs_from_user_45340 copy_vm86_regs_from_user 3 45340 NULL
108720 +null_alloc_repbuf_45375 null_alloc_repbuf 3 45375 NULL
108721 +sock_recv_errqueue_45412 sock_recv_errqueue 3 45412 NULL
108722 +paging64_gva_to_gpa_45421 paging64_gva_to_gpa 2 45421 NULL nohasharray
108723 +ieee80211_if_fmt_dot11MeshHWMProotInterval_45421 ieee80211_if_fmt_dot11MeshHWMProotInterval 3 45421 &paging64_gva_to_gpa_45421
108724 +alloc_task_struct_node_45426 alloc_task_struct_node 1 45426 NULL
108725 +ll_iocontrol_register_45430 ll_iocontrol_register 2 45430 NULL
108726 +tty_buffer_alloc_45437 tty_buffer_alloc 2 45437 NULL
108727 +SYSC_mremap_45446 SYSC_mremap 5-1-2-3 45446 NULL
108728 +__node_remap_45458 __node_remap 4 45458 NULL
108729 +rds_ib_set_wr_signal_state_45463 rds_ib_set_wr_signal_state 0 45463 NULL
108730 +tracing_read_dyn_info_45468 tracing_read_dyn_info 3 45468 NULL
108731 +snd_pcm_hwsync_45479 snd_pcm_hwsync 0 45479 NULL
108732 +arizona_init_fll_45503 arizona_init_fll 5 45503 NULL
108733 +rds_message_copy_from_user_45510 rds_message_copy_from_user 3 45510 NULL
108734 +i40e_alloc_vfs_45511 i40e_alloc_vfs 2 45511 NULL
108735 +__split_vma_45522 __split_vma 0 45522 NULL
108736 +cgroup_read_u64_45532 cgroup_read_u64 5 45532 NULL
108737 +copy_macs_45534 copy_macs 4 45534 NULL
108738 +nla_attr_size_45545 nla_attr_size 0-1 45545 NULL
108739 +v9fs_direct_read_45546 v9fs_direct_read 3 45546 NULL
108740 +cx18_copy_mdl_to_user_45549 cx18_copy_mdl_to_user 4 45549 NULL
108741 +ext3_group_first_block_no_45555 ext3_group_first_block_no 0-2 45555 NULL
108742 +stats_dot11ACKFailureCount_read_45558 stats_dot11ACKFailureCount_read 3 45558 NULL
108743 +_regmap_bus_raw_write_45559 _regmap_bus_raw_write 2 45559 NULL
108744 +posix_acl_xattr_size_45561 posix_acl_xattr_size 0-1 45561 NULL
108745 +venus_rmdir_45564 venus_rmdir 4 45564 NULL
108746 +btrfs_find_free_ino_45585 btrfs_find_free_ino 0 45585 NULL
108747 +ipath_create_cq_45586 ipath_create_cq 2 45586 NULL
108748 +ath6kl_keepalive_write_45600 ath6kl_keepalive_write 3 45600 NULL
108749 +hidraw_get_report_45609 hidraw_get_report 3 45609 NULL
108750 +commit_cowonly_roots_45640 commit_cowonly_roots 0 45640 NULL
108751 +ebitmap_next_positive_45651 ebitmap_next_positive 3-0 45651 NULL
108752 +ext4_reserve_inode_write_45654 ext4_reserve_inode_write 0 45654 NULL
108753 +dma_map_cont_45668 dma_map_cont 5 45668 NULL
108754 +compat_mpctl_ioctl_45671 compat_mpctl_ioctl 2 45671 NULL
108755 +dgram_sendmsg_45679 dgram_sendmsg 4 45679 NULL
108756 +smk_write_ambient_45691 smk_write_ambient 3 45691 NULL
108757 +unix_dgram_sendmsg_45699 unix_dgram_sendmsg 4 45699 NULL nohasharray
108758 +bscnl_emit_45699 bscnl_emit 0-2-5 45699 &unix_dgram_sendmsg_45699
108759 +sg_proc_write_adio_45704 sg_proc_write_adio 3 45704 NULL
108760 +snd_cs46xx_io_read_45734 snd_cs46xx_io_read 5 45734 NULL nohasharray
108761 +task_cgroup_path_45734 task_cgroup_path 3 45734 &snd_cs46xx_io_read_45734
108762 +rw_copy_check_uvector_45748 rw_copy_check_uvector 3-0 45748 NULL nohasharray
108763 +v4l2_ctrl_new_std_45748 v4l2_ctrl_new_std 5 45748 &rw_copy_check_uvector_45748
108764 +lkdtm_debugfs_read_45752 lkdtm_debugfs_read 3 45752 NULL
108765 +btrfs_delete_delayed_dir_index_45757 btrfs_delete_delayed_dir_index 0 45757 NULL
108766 +alloc_ts_config_45775 alloc_ts_config 1 45775 NULL
108767 +osc_checksum_type_seq_write_45785 osc_checksum_type_seq_write 3 45785 NULL
108768 +raw_setsockopt_45800 raw_setsockopt 5 45800 NULL
108769 +rds_tcp_inc_copy_to_user_45804 rds_tcp_inc_copy_to_user 3 45804 NULL
108770 +lbs_rdbbp_read_45805 lbs_rdbbp_read 3 45805 NULL
108771 +pcpu_alloc_alloc_info_45813 pcpu_alloc_alloc_info 1-2 45813 NULL
108772 +ll_max_readahead_mb_seq_write_45815 ll_max_readahead_mb_seq_write 3 45815 NULL
108773 +fm_v4l2_init_video_device_45821 fm_v4l2_init_video_device 2 45821 NULL
108774 +memcg_update_cache_size_45828 memcg_update_cache_size 2 45828 NULL
108775 +ipv6_recv_rxpmtu_45830 ipv6_recv_rxpmtu 3 45830 NULL
108776 +task_state_char_45839 task_state_char 1 45839 NULL
108777 +__ip_select_ident_45851 __ip_select_ident 3 45851 NULL
108778 +x509_process_extension_45854 x509_process_extension 5 45854 NULL
108779 +efx_tx_queue_insert_45859 efx_tx_queue_insert 2 45859 NULL
108780 +isdn_write_45863 isdn_write 3 45863 NULL
108781 +unpack_orig_pfns_45867 unpack_orig_pfns 0 45867 NULL
108782 +tpm_config_in_45880 tpm_config_in 0 45880 NULL
108783 +get_rdac_req_45882 get_rdac_req 3 45882 NULL
108784 +ocfs2_xattr_block_find_45891 ocfs2_xattr_block_find 0 45891 NULL
108785 +online_page_cgroup_45894 online_page_cgroup 3 45894 NULL
108786 +cfs_cpt_weight_45903 cfs_cpt_weight 0 45903 NULL
108787 +wm_adsp_region_to_reg_45915 wm_adsp_region_to_reg 0-2 45915 NULL
108788 +dbgfs_frame_45917 dbgfs_frame 3 45917 NULL
108789 +alloc_mr_45935 alloc_mr 1 45935 NULL
108790 +kmem_cache_alloc_node_trace_45968 kmem_cache_alloc_node_trace 3 45968 NULL
108791 +copy_to_45969 copy_to 3 45969 NULL
108792 +rb_simple_read_45972 rb_simple_read 3 45972 NULL
108793 +ioat2_dca_count_dca_slots_45984 ioat2_dca_count_dca_slots 0 45984 NULL
108794 +ore_calc_stripe_info_46023 ore_calc_stripe_info 2 46023 NULL
108795 +sierra_setup_urb_46029 sierra_setup_urb 5 46029 NULL
108796 +get_free_entries_46030 get_free_entries 1 46030 NULL
108797 +__access_remote_vm_46031 __access_remote_vm 0-3-5 46031 NULL
108798 +snd_emu10k1x_ptr_read_46049 snd_emu10k1x_ptr_read 0 46049 NULL
108799 +acpi_register_gsi_xen_hvm_46052 acpi_register_gsi_xen_hvm 2 46052 NULL
108800 +__ocfs2_move_extent_46060 __ocfs2_move_extent 5-6-4-0-3 46060 NULL nohasharray
108801 +dma_tx_errors_read_46060 dma_tx_errors_read 3 46060 &__ocfs2_move_extent_46060
108802 +sel_commit_bools_write_46077 sel_commit_bools_write 3 46077 NULL
108803 +arizona_set_irq_wake_46101 arizona_set_irq_wake 2 46101 NULL
108804 +il3945_ucode_general_stats_read_46111 il3945_ucode_general_stats_read 3 46111 NULL nohasharray
108805 +memcg_update_array_size_46111 memcg_update_array_size 1 46111 &il3945_ucode_general_stats_read_46111
108806 +C_SYSC_writev_46113 C_SYSC_writev 3 46113 NULL
108807 +mlx4_ib_alloc_fast_reg_page_list_46119 mlx4_ib_alloc_fast_reg_page_list 2 46119 NULL
108808 +paging32_walk_addr_nested_46121 paging32_walk_addr_nested 3 46121 NULL
108809 +replay_dir_deletes_46136 replay_dir_deletes 0 46136 NULL
108810 +rtw_buf_update_46138 rtw_buf_update 4 46138 NULL
108811 +vb2_dma_sg_get_userptr_46146 vb2_dma_sg_get_userptr 2-3 46146 NULL
108812 +__netlink_change_ngroups_46156 __netlink_change_ngroups 2 46156 NULL
108813 +alloc_iova_46160 alloc_iova 2 46160 NULL
108814 +kmalloc_section_memmap_46168 kmalloc_section_memmap 2 46168 NULL
108815 +twl_direction_out_46182 twl_direction_out 2 46182 NULL
108816 +vxge_os_dma_malloc_46184 vxge_os_dma_malloc 2 46184 NULL
108817 +fq_resize_46195 fq_resize 2 46195 NULL
108818 +add_conn_list_46197 add_conn_list 3-0 46197 NULL
108819 +i2400m_op_msg_from_user_46213 i2400m_op_msg_from_user 4 46213 NULL
108820 +tm6000_i2c_recv_regs_46215 tm6000_i2c_recv_regs 5 46215 NULL
108821 +dsp_write_46218 dsp_write 2 46218 NULL
108822 +xen_setup_msi_irqs_46245 xen_setup_msi_irqs 2 46245 NULL
108823 +mpi_read_raw_data_46248 mpi_read_raw_data 2 46248 NULL
108824 +ReadReg_46277 ReadReg 0 46277 NULL
108825 +sg_proc_write_dressz_46316 sg_proc_write_dressz 3 46316 NULL
108826 +compat_SyS_readv_46328 compat_SyS_readv 3 46328 NULL nohasharray
108827 +__hwahc_dev_set_key_46328 __hwahc_dev_set_key 5 46328 &compat_SyS_readv_46328
108828 +iwl_dbgfs_chain_noise_read_46355 iwl_dbgfs_chain_noise_read 3 46355 NULL
108829 +smk_write_direct_46363 smk_write_direct 3 46363 NULL
108830 +__iommu_calculate_agaw_46366 __iommu_calculate_agaw 2 46366 NULL
108831 +ubi_dump_flash_46381 ubi_dump_flash 4 46381 NULL
108832 +mmap_ureg_46388 mmap_ureg 3 46388 NULL
108833 +vma_adjust_46390 vma_adjust 0 46390 NULL
108834 +fuse_file_aio_write_46399 fuse_file_aio_write 4 46399 NULL
108835 +crypto_ablkcipher_reqsize_46411 crypto_ablkcipher_reqsize 0 46411 NULL
108836 +ttm_page_pool_get_pages_46431 ttm_page_pool_get_pages 0-5 46431 NULL
108837 +cfs_power2_roundup_46433 cfs_power2_roundup 0-1 46433 NULL
108838 +hash_ipportip6_expire_46443 hash_ipportip6_expire 3 46443 NULL
108839 +cp210x_set_config_46447 cp210x_set_config 4 46447 NULL
108840 +parport_pc_fifo_write_block_46455 parport_pc_fifo_write_block 3 46455 NULL
108841 +il_dbgfs_clear_traffic_stats_write_46458 il_dbgfs_clear_traffic_stats_write 3 46458 NULL
108842 +filldir64_46469 filldir64 3 46469 NULL
108843 +ocfs2_reserve_clusters_with_limit_46479 ocfs2_reserve_clusters_with_limit 0 46479 NULL
108844 +fill_in_write_vector_46498 fill_in_write_vector 0 46498 NULL
108845 +p9pdu_vreadf_46500 p9pdu_vreadf 0 46500 NULL
108846 +pin_code_reply_46510 pin_code_reply 4 46510 NULL
108847 +mthca_alloc_cq_buf_46512 mthca_alloc_cq_buf 3 46512 NULL
108848 +nouveau_drm_ioctl_46514 nouveau_drm_ioctl 2 46514 NULL nohasharray
108849 +kmsg_read_46514 kmsg_read 3 46514 &nouveau_drm_ioctl_46514
108850 +bdx_rxdb_create_46525 bdx_rxdb_create 1 46525 NULL
108851 +nl80211_send_rx_assoc_46538 nl80211_send_rx_assoc 4 46538 NULL
108852 +pm860x_irq_domain_map_46553 pm860x_irq_domain_map 2 46553 NULL
108853 +link_send_sections_long_46556 link_send_sections_long 4 46556 NULL
108854 +dn_current_mss_46574 dn_current_mss 0 46574 NULL nohasharray
108855 +blk_flush_complete_seq_46574 blk_flush_complete_seq 2 46574 &dn_current_mss_46574
108856 +serverworks_create_gatt_pages_46582 serverworks_create_gatt_pages 1 46582 NULL
108857 +snd_compr_write_data_46592 snd_compr_write_data 3 46592 NULL
108858 +il3945_stats_flag_46606 il3945_stats_flag 0-3 46606 NULL
108859 +vscnprintf_46617 vscnprintf 0-2 46617 NULL
108860 +__kfifo_out_r_46623 __kfifo_out_r 3-0 46623 NULL
108861 +request_key_async_with_auxdata_46624 request_key_async_with_auxdata 4 46624 NULL
108862 +pci_enable_device_46642 pci_enable_device 0 46642 NULL
108863 +vfs_getxattr_alloc_46649 vfs_getxattr_alloc 0 46649 NULL
108864 +av7110_ipack_init_46655 av7110_ipack_init 2 46655 NULL
108865 +e1000_tx_map_46672 e1000_tx_map 4 46672 NULL
108866 +alloc_data_packet_46698 alloc_data_packet 1 46698 NULL
108867 +__ilog2_u32_46706 __ilog2_u32 0 46706 NULL
108868 +erst_dbg_write_46715 erst_dbg_write 3 46715 NULL
108869 +ide_read_status_46719 ide_read_status 0 46719 NULL
108870 +wl1271_rx_filter_alloc_field_46721 wl1271_rx_filter_alloc_field 5 46721 NULL
108871 +irq_domain_add_simple_46734 irq_domain_add_simple 2-3 46734 NULL
108872 +ext4_count_free_46754 ext4_count_free 2 46754 NULL nohasharray
108873 +pte_pfn_46754 pte_pfn 0 46754 &ext4_count_free_46754
108874 +ntfs2utc_46762 ntfs2utc 1 46762 NULL
108875 +hest_ghes_dev_register_46766 hest_ghes_dev_register 1 46766 NULL
108876 +int_hw_irq_en_46776 int_hw_irq_en 3 46776 NULL
108877 +regcache_lzo_sync_46777 regcache_lzo_sync 2 46777 NULL
108878 +_xfs_buf_get_pages_46811 _xfs_buf_get_pages 2 46811 NULL
108879 +btrfs_insert_empty_items_46822 btrfs_insert_empty_items 0 46822 NULL
108880 +xfs_iroot_realloc_46826 xfs_iroot_realloc 2 46826 NULL
108881 +shmem_pwrite_fast_46842 shmem_pwrite_fast 3 46842 NULL
108882 +readreg_46845 readreg 0 46845 NULL
108883 +spi_async_46857 spi_async 0 46857 NULL
108884 +vsnprintf_46863 vsnprintf 0 46863 NULL nohasharray
108885 +SyS_move_pages_46863 SyS_move_pages 2 46863 &vsnprintf_46863
108886 +nvme_alloc_queue_46865 nvme_alloc_queue 3 46865 NULL
108887 +rvmalloc_46873 rvmalloc 1 46873 NULL
108888 +qp_memcpy_from_queue_iov_46874 qp_memcpy_from_queue_iov 5-4 46874 NULL
108889 +lov_iocontrol_46876 lov_iocontrol 3 46876 NULL
108890 +stmpe_gpio_irq_unmap_46884 stmpe_gpio_irq_unmap 2 46884 NULL
108891 +ixgbe_dbg_reg_ops_write_46895 ixgbe_dbg_reg_ops_write 3 46895 NULL
108892 +sk_mem_pages_46896 sk_mem_pages 0-1 46896 NULL
108893 +ol_dqblk_off_46904 ol_dqblk_off 2-3 46904 NULL
108894 +ieee80211_if_fmt_power_mode_46906 ieee80211_if_fmt_power_mode 3 46906 NULL
108895 +wlcore_alloc_hw_46917 wlcore_alloc_hw 1-3 46917 NULL
108896 +fb_write_46924 fb_write 3 46924 NULL
108897 +i915_gem_check_olr_46925 i915_gem_check_olr 0 46925 NULL
108898 +kvm_register_read_46948 kvm_register_read 0 46948 NULL
108899 +__sctp_setsockopt_connectx_46949 __sctp_setsockopt_connectx 3 46949 NULL
108900 +qla4xxx_post_aen_work_46953 qla4xxx_post_aen_work 3 46953 NULL
108901 +SYSC_poll_46965 SYSC_poll 2 46965 NULL
108902 +crypto_tfm_alg_alignmask_46971 crypto_tfm_alg_alignmask 0 46971 NULL
108903 +mgmt_pending_add_46976 mgmt_pending_add 5 46976 NULL
108904 +strlcat_46985 strlcat 3 46985 NULL
108905 +bitmap_file_clear_bit_46990 bitmap_file_clear_bit 2 46990 NULL
108906 +gfs2_xattr_system_set_46996 gfs2_xattr_system_set 4 46996 NULL nohasharray
108907 +sel_write_bool_46996 sel_write_bool 3 46996 &gfs2_xattr_system_set_46996
108908 +ttm_bo_io_47000 ttm_bo_io 5 47000 NULL
108909 +blk_rq_map_kern_47004 blk_rq_map_kern 4 47004 NULL
108910 +__map_single_47020 __map_single 3-4-7-0 47020 NULL
108911 +cx231xx_init_bulk_47024 cx231xx_init_bulk 3-2-4 47024 NULL
108912 +fs_path_len_47060 fs_path_len 0 47060 NULL
108913 +ufs_new_fragments_47070 ufs_new_fragments 4-3-5 47070 NULL nohasharray
108914 +ext4_xattr_list_entries_47070 ext4_xattr_list_entries 0-4 47070 &ufs_new_fragments_47070
108915 +pipeline_dec_packet_in_read_47076 pipeline_dec_packet_in_read 3 47076 NULL
108916 +scsi_deactivate_tcq_47086 scsi_deactivate_tcq 2 47086 NULL
108917 +iwl_dump_nic_event_log_47089 iwl_dump_nic_event_log 0 47089 NULL
108918 +ptlrpc_lprocfs_threads_max_seq_write_47104 ptlrpc_lprocfs_threads_max_seq_write 3 47104 NULL
108919 +tboot_log_read_47110 tboot_log_read 3 47110 NULL
108920 +mousedev_read_47123 mousedev_read 3 47123 NULL
108921 +ubi_compare_lebs_47141 ubi_compare_lebs 0 47141 NULL
108922 +ses_recv_diag_47143 ses_recv_diag 4 47143 NULL nohasharray
108923 +acpi_ut_initialize_buffer_47143 acpi_ut_initialize_buffer 2 47143 &ses_recv_diag_47143
108924 +mxms_headerlen_47161 mxms_headerlen 0 47161 NULL
108925 +rs_sta_dbgfs_rate_scale_data_read_47165 rs_sta_dbgfs_rate_scale_data_read 3 47165 NULL
108926 +alloc_cpumask_var_node_47167 alloc_cpumask_var_node 3 47167 NULL
108927 +bpf_alloc_binary_47170 bpf_alloc_binary 1 47170 NULL
108928 +rts51x_ms_rw_47171 rts51x_ms_rw 3-4 47171 NULL
108929 +btrfs_del_inode_ref_47181 btrfs_del_inode_ref 0 47181 NULL
108930 +can_set_system_xattr_47182 can_set_system_xattr 4 47182 NULL
108931 +options_write_47243 options_write 3 47243 NULL
108932 +portcntrs_1_read_47253 portcntrs_1_read 3 47253 NULL
108933 +da9052_disable_irq_nosync_47260 da9052_disable_irq_nosync 2 47260 NULL
108934 +p9pdu_readf_47269 p9pdu_readf 0 47269 NULL
108935 +ablkcipher_next_slow_47274 ablkcipher_next_slow 3-4 47274 NULL
108936 +gfs2_readpages_47285 gfs2_readpages 4 47285 NULL
108937 +vsnprintf_47291 vsnprintf 0 47291 NULL
108938 +tx_internal_desc_overflow_read_47300 tx_internal_desc_overflow_read 3 47300 NULL
108939 +iterate_inode_ref_47322 iterate_inode_ref 0 47322 NULL
108940 +SyS_madvise_47354 SyS_madvise 1-2 47354 NULL
108941 +ieee80211_if_read_dot11MeshHoldingTimeout_47356 ieee80211_if_read_dot11MeshHoldingTimeout 3 47356 NULL
108942 +avc_get_hash_stats_47359 avc_get_hash_stats 0 47359 NULL
108943 +find_first_zero_bit_le_47369 find_first_zero_bit_le 2 47369 NULL
108944 +__bio_map_kern_47379 __bio_map_kern 3 47379 NULL
108945 +nv_rd32_47390 nv_rd32 0 47390 NULL nohasharray
108946 +trace_options_core_read_47390 trace_options_core_read 3 47390 &nv_rd32_47390
108947 +nametbl_list_47391 nametbl_list 2 47391 NULL
108948 +dgrp_net_write_47392 dgrp_net_write 3 47392 NULL
108949 +pfkey_sendmsg_47394 pfkey_sendmsg 4 47394 NULL
108950 +gfn_to_pfn_prot_47398 gfn_to_pfn_prot 2 47398 NULL
108951 +lbs_wrmac_write_47400 lbs_wrmac_write 3 47400 NULL
108952 +ocfs2_resv_end_47408 ocfs2_resv_end 0 47408 NULL
108953 +sta_vht_capa_read_47409 sta_vht_capa_read 3 47409 NULL
108954 +crypto_ablkcipher_alignmask_47410 crypto_ablkcipher_alignmask 0 47410 NULL
108955 +lbs_wrrf_write_47418 lbs_wrrf_write 3 47418 NULL
108956 +vzalloc_47421 vzalloc 1 47421 NULL
108957 +hash_ipportip4_expire_47426 hash_ipportip4_expire 3 47426 NULL
108958 +posix_acl_from_disk_47445 posix_acl_from_disk 2 47445 NULL
108959 +numaq_apicid_to_cpu_present_47449 numaq_apicid_to_cpu_present 1 47449 NULL
108960 +environ_read_47451 environ_read 3 47451 NULL
108961 +__load_mapping_47460 __load_mapping 2 47460 NULL
108962 +try_lock_extent_47465 try_lock_extent 0 47465 NULL
108963 +nvme_trans_send_fw_cmd_47479 nvme_trans_send_fw_cmd 4 47479 NULL
108964 +wb_force_mapping_47485 wb_force_mapping 2 47485 NULL nohasharray
108965 +newpart_47485 newpart 6-4 47485 &wb_force_mapping_47485
108966 +mcp23s17_read_regs_47491 mcp23s17_read_regs 4 47491 NULL
108967 +core_sys_select_47494 core_sys_select 1 47494 NULL
108968 +read_block_for_search_47502 read_block_for_search 0 47502 NULL
108969 +alloc_arraycache_47505 alloc_arraycache 2-1 47505 NULL nohasharray
108970 +btrfs_init_inode_security_47505 btrfs_init_inode_security 0 47505 &alloc_arraycache_47505
108971 +unlink_simple_47506 unlink_simple 3 47506 NULL
108972 +pstore_decompress_47510 pstore_decompress 0 47510 NULL
108973 +ufs_inode_getblock_47512 ufs_inode_getblock 4 47512 NULL
108974 +__proc_lnet_portal_rotor_47529 __proc_lnet_portal_rotor 5 47529 NULL
108975 +snd_pcm_resume_47530 snd_pcm_resume 0 47530 NULL
108976 +vscnprintf_47533 vscnprintf 0-2 47533 NULL nohasharray
108977 +process_vm_rw_47533 process_vm_rw 3-5 47533 &vscnprintf_47533
108978 +einj_check_trigger_header_47534 einj_check_trigger_header 0 47534 NULL
108979 +ieee80211_if_fmt_min_discovery_timeout_47539 ieee80211_if_fmt_min_discovery_timeout 3 47539 NULL
108980 +ocfs2_resv_find_window_47557 ocfs2_resv_find_window 3 47557 NULL
108981 +read_ldt_47570 read_ldt 2 47570 NULL
108982 +isku_sysfs_read_last_set_47572 isku_sysfs_read_last_set 6 47572 NULL
108983 +rpipe_get_idx_47579 rpipe_get_idx 2-0 47579 NULL
108984 +SYSC_fcntl64_47581 SYSC_fcntl64 3 47581 NULL
108985 +vendorextnReadSection_47583 vendorextnReadSection 0 47583 NULL
108986 +btrfs_stack_header_bytenr_47589 btrfs_stack_header_bytenr 0 47589 NULL
108987 +ext4_kvzalloc_47605 ext4_kvzalloc 1 47605 NULL
108988 +sctp_ssnmap_new_47608 sctp_ssnmap_new 2-1 47608 NULL
108989 +cache_read_pipefs_47615 cache_read_pipefs 3 47615 NULL
108990 +twl4030_clear_set_47624 twl4030_clear_set 4 47624 NULL
108991 +irq_set_chip_47638 irq_set_chip 1 47638 NULL
108992 +get_size_47644 get_size 1-2 47644 NULL
108993 +snd_pcm_info_47699 snd_pcm_info 0 47699 NULL
108994 +packet_recvmsg_47700 packet_recvmsg 4 47700 NULL nohasharray
108995 +ipath_format_hwmsg_47700 ipath_format_hwmsg 2 47700 &packet_recvmsg_47700
108996 +global_rt_runtime_47712 global_rt_runtime 0 47712 NULL
108997 +save_microcode_47717 save_microcode 3 47717 NULL
108998 +bits_to_user_47733 bits_to_user 3-2 47733 NULL
108999 +carl9170_debugfs_read_47738 carl9170_debugfs_read 3 47738 NULL
109000 +ir_prepare_write_buffer_47747 ir_prepare_write_buffer 3 47747 NULL
109001 +mvumi_alloc_mem_resource_47750 mvumi_alloc_mem_resource 3 47750 NULL
109002 +ext3_find_near_47752 ext3_find_near 0 47752 NULL
109003 +alloc_sched_domains_47756 alloc_sched_domains 1 47756 NULL
109004 +uwb_ie_dump_hex_47774 uwb_ie_dump_hex 4 47774 NULL
109005 +SyS_setgroups16_47780 SyS_setgroups16 1 47780 NULL
109006 +error_error_numll_frame_cts_start_read_47781 error_error_numll_frame_cts_start_read 3 47781 NULL
109007 +posix_acl_fix_xattr_from_user_47793 posix_acl_fix_xattr_from_user 2 47793 NULL
109008 +W6692_empty_Bfifo_47804 W6692_empty_Bfifo 2 47804 NULL
109009 +lov_packmd_47810 lov_packmd 0 47810 NULL
109010 +pinconf_dbg_config_write_47835 pinconf_dbg_config_write 3 47835 NULL
109011 +KEY_SIZE_47855 KEY_SIZE 0 47855 NULL
109012 +ubifs_unpack_nnode_47866 ubifs_unpack_nnode 0 47866 NULL
109013 +vhci_read_47878 vhci_read 3 47878 NULL
109014 +ubi_wl_put_peb_47886 ubi_wl_put_peb 0 47886 NULL
109015 +keyctl_instantiate_key_common_47889 keyctl_instantiate_key_common 4 47889 NULL
109016 +load_mapping_47904 load_mapping 3 47904 NULL
109017 +btrfs_duplicate_item_47910 btrfs_duplicate_item 0 47910 NULL
109018 +cfs_percpt_alloc_47918 cfs_percpt_alloc 2 47918 NULL
109019 +comedi_write_47926 comedi_write 3 47926 NULL
109020 +nvme_trans_get_blk_desc_len_47946 nvme_trans_get_blk_desc_len 0-2 47946 NULL
109021 +lp8788_irq_map_47964 lp8788_irq_map 2 47964 NULL
109022 +gether_get_ifname_47972 gether_get_ifname 3 47972 NULL
109023 +iwl_dbgfs_ucode_tracing_read_47983 iwl_dbgfs_ucode_tracing_read 3 47983 NULL nohasharray
109024 +mempool_resize_47983 mempool_resize 2 47983 &iwl_dbgfs_ucode_tracing_read_47983
109025 +dbg_port_buf_47990 dbg_port_buf 2 47990 NULL
109026 +ib_umad_write_47993 ib_umad_write 3 47993 NULL
109027 +ocfs2_find_refcount_split_pos_48001 ocfs2_find_refcount_split_pos 0 48001 NULL
109028 +lustre_cfg_len_48002 lustre_cfg_len 0 48002 NULL
109029 +gdm_tty_recv_complete_48011 gdm_tty_recv_complete 2 48011 NULL
109030 +ffs_epfile_write_48014 ffs_epfile_write 3 48014 NULL
109031 +bio_integrity_set_tag_48035 bio_integrity_set_tag 3 48035 NULL
109032 +pppoe_sendmsg_48039 pppoe_sendmsg 4 48039 NULL
109033 +SYSC_writev_48040 SYSC_writev 3 48040 NULL
109034 +btrfs_reserve_extent_48044 btrfs_reserve_extent 6 48044 NULL
109035 +wpan_phy_alloc_48056 wpan_phy_alloc 1 48056 NULL
109036 +ocfs2_change_refcount_rec_48059 ocfs2_change_refcount_rec 0 48059 NULL
109037 +posix_acl_alloc_48063 posix_acl_alloc 1 48063 NULL
109038 +palmas_bulk_write_48068 palmas_bulk_write 2-3-5 48068 NULL
109039 +disc_write_48070 disc_write 3 48070 NULL
109040 +mmc_alloc_host_48097 mmc_alloc_host 1 48097 NULL
109041 +skb_copy_datagram_const_iovec_48102 skb_copy_datagram_const_iovec 4-2-5-0 48102 NULL
109042 +radio_isa_common_probe_48107 radio_isa_common_probe 3 48107 NULL
109043 +vmw_framebuffer_surface_dirty_48132 vmw_framebuffer_surface_dirty 6 48132 NULL
109044 +set_discoverable_48141 set_discoverable 4 48141 NULL
109045 +dn_fib_count_nhs_48145 dn_fib_count_nhs 0 48145 NULL
109046 +get_cur_inode_state_48149 get_cur_inode_state 0 48149 NULL
109047 +bitmap_onto_48152 bitmap_onto 4 48152 NULL nohasharray
109048 +_add_to_r4w_48152 _add_to_r4w 4 48152 &bitmap_onto_48152
109049 +isr_dma1_done_read_48159 isr_dma1_done_read 3 48159 NULL
109050 +c4iw_id_table_alloc_48163 c4iw_id_table_alloc 3 48163 NULL
109051 +ocfs2_find_next_zero_bit_unaligned_48170 ocfs2_find_next_zero_bit_unaligned 2-3 48170 NULL nohasharray
109052 +rbd_obj_method_sync_48170 rbd_obj_method_sync 8 48170 &ocfs2_find_next_zero_bit_unaligned_48170
109053 +alloc_cc770dev_48186 alloc_cc770dev 1 48186 NULL
109054 +init_ipath_48187 init_ipath 1 48187 NULL
109055 +brcmf_sdio_chip_cm3_exitdl_48192 brcmf_sdio_chip_cm3_exitdl 4 48192 NULL
109056 +cfg80211_process_deauth_48200 cfg80211_process_deauth 3 48200 NULL
109057 +ext4_index_trans_blocks_48205 ext4_index_trans_blocks 0-2 48205 NULL
109058 +snd_seq_dump_var_event_48209 snd_seq_dump_var_event 0 48209 NULL
109059 +ll_direct_IO_26_48216 ll_direct_IO_26 4 48216 NULL
109060 +is_block_in_journal_48223 is_block_in_journal 3 48223 NULL
109061 +uv_blade_nr_possible_cpus_48226 uv_blade_nr_possible_cpus 0 48226 NULL
109062 +nilfs_readpages_48229 nilfs_readpages 4 48229 NULL
109063 +read_file_recv_48232 read_file_recv 3 48232 NULL
109064 +unaccount_shadowed_48233 unaccount_shadowed 2 48233 NULL nohasharray
109065 +blk_rq_pos_48233 blk_rq_pos 0 48233 &unaccount_shadowed_48233
109066 +nouveau_i2c_port_create__48240 nouveau_i2c_port_create_ 7 48240 NULL
109067 +nfsctl_transaction_read_48250 nfsctl_transaction_read 3 48250 NULL
109068 +batadv_socket_read_48257 batadv_socket_read 3 48257 NULL
109069 +cache_write_pipefs_48270 cache_write_pipefs 3 48270 NULL
109070 +trace_options_write_48275 trace_options_write 3 48275 NULL
109071 +send_set_info_48288 send_set_info 7 48288 NULL
109072 +lpfc_idiag_extacc_read_48301 lpfc_idiag_extacc_read 3 48301 NULL
109073 +timblogiw_read_48305 timblogiw_read 3 48305 NULL
109074 +hash_setkey_48310 hash_setkey 3 48310 NULL
109075 +audio_set_intf_req_48319 audio_set_intf_req 0 48319 NULL
109076 +kvm_mmu_pte_write_48340 kvm_mmu_pte_write 2 48340 NULL
109077 +__alloc_fd_48356 __alloc_fd 2 48356 NULL
109078 +skb_add_data_48363 skb_add_data 3 48363 NULL
109079 +tx_frag_init_called_read_48377 tx_frag_init_called_read 3 48377 NULL
109080 +lbs_debugfs_write_48413 lbs_debugfs_write 3 48413 NULL
109081 +uhid_event_from_user_48417 uhid_event_from_user 2 48417 NULL
109082 +div64_u64_rem_48418 div64_u64_rem 0-1-2 48418 NULL
109083 +snd_power_wait_48422 snd_power_wait 0 48422 NULL
109084 +pwr_tx_without_ps_read_48423 pwr_tx_without_ps_read 3 48423 NULL
109085 +hugepage_madvise_48435 hugepage_madvise 0 48435 NULL
109086 +print_filtered_48442 print_filtered 2-0 48442 NULL
109087 +tun_recvmsg_48463 tun_recvmsg 4 48463 NULL
109088 +compat_SyS_preadv64_48469 compat_SyS_preadv64 3 48469 NULL
109089 +ipath_format_hwerrors_48487 ipath_format_hwerrors 5 48487 NULL
109090 +init_section_page_cgroup_48489 init_section_page_cgroup 2 48489 NULL nohasharray
109091 +r8712_usbctrl_vendorreq_48489 r8712_usbctrl_vendorreq 6 48489 &init_section_page_cgroup_48489
109092 +ocfs2_refcount_cow_48495 ocfs2_refcount_cow 3 48495 NULL
109093 +send_control_msg_48498 send_control_msg 6 48498 NULL
109094 +mlx4_en_create_tx_ring_48501 mlx4_en_create_tx_ring 4 48501 NULL
109095 +count_masked_bytes_48507 count_masked_bytes 0-1 48507 NULL
109096 +diva_os_copy_to_user_48508 diva_os_copy_to_user 4 48508 NULL
109097 +brcmf_sdio_trap_info_48510 brcmf_sdio_trap_info 4 48510 NULL
109098 +phantom_get_free_48514 phantom_get_free 0 48514 NULL
109099 +drbd_bm_capacity_48530 drbd_bm_capacity 0 48530 NULL
109100 +ext3_splice_branch_48531 ext3_splice_branch 6 48531 NULL
109101 +raid10_size_48571 raid10_size 0-2-3 48571 NULL
109102 +llog_data_len_48607 llog_data_len 1 48607 NULL
109103 +ufs_dtogd_48616 ufs_dtogd 0-2 48616 NULL
109104 +do_ip_vs_set_ctl_48641 do_ip_vs_set_ctl 4 48641 NULL
109105 +ll_rw_extents_stats_pp_seq_write_48651 ll_rw_extents_stats_pp_seq_write 3 48651 NULL
109106 +mtd_read_48655 mtd_read 0 48655 NULL
109107 +aes_encrypt_packets_read_48666 aes_encrypt_packets_read 3 48666 NULL
109108 +ore_get_rw_state_48667 ore_get_rw_state 5-4 48667 NULL
109109 +sm501_create_subdev_48668 sm501_create_subdev 4-3 48668 NULL
109110 +ubi_eba_unmap_leb_48671 ubi_eba_unmap_leb 0 48671 NULL
109111 +hysdn_log_write_48694 hysdn_log_write 3 48694 NULL
109112 +altera_drscan_48698 altera_drscan 2 48698 NULL
109113 +kvm_set_irq_routing_48704 kvm_set_irq_routing 3 48704 NULL
109114 +recv_msg_48709 recv_msg 4 48709 NULL
109115 +lpfc_idiag_drbacc_write_48712 lpfc_idiag_drbacc_write 3 48712 NULL
109116 +SyS_lgetxattr_48719 SyS_lgetxattr 4 48719 NULL
109117 +ath6kl_usb_bmi_read_48745 ath6kl_usb_bmi_read 3 48745 NULL
109118 +ath6kl_regwrite_read_48747 ath6kl_regwrite_read 3 48747 NULL
109119 +event_buffer_read_48772 event_buffer_read 3 48772 NULL nohasharray
109120 +l2cap_segment_sdu_48772 l2cap_segment_sdu 4 48772 &event_buffer_read_48772
109121 +gfs2_direct_IO_48774 gfs2_direct_IO 4 48774 NULL
109122 +il3945_sta_dbgfs_stats_table_read_48802 il3945_sta_dbgfs_stats_table_read 3 48802 NULL
109123 +twa_change_queue_depth_48808 twa_change_queue_depth 2 48808 NULL
109124 +register_ftrace_profiler_48816 register_ftrace_profiler 0 48816 NULL
109125 +atomic_counters_read_48827 atomic_counters_read 3 48827 NULL
109126 +azx_get_position_48841 azx_get_position 0 48841 NULL
109127 +vc_do_resize_48842 vc_do_resize 4-3 48842 NULL
109128 +comedi_buf_write_alloc_48846 comedi_buf_write_alloc 0-2 48846 NULL
109129 +suspend_dtim_interval_write_48854 suspend_dtim_interval_write 3 48854 NULL
109130 +viafb_dvp1_proc_write_48864 viafb_dvp1_proc_write 3 48864 NULL nohasharray
109131 +C_SYSC_pwritev64_48864 C_SYSC_pwritev64 3 48864 &viafb_dvp1_proc_write_48864
109132 +ide_port_alloc_devices_48866 ide_port_alloc_devices 2 48866 NULL
109133 +__ffs_ep0_read_events_48868 __ffs_ep0_read_events 3 48868 NULL
109134 +ext2_alloc_branch_48889 ext2_alloc_branch 4 48889 NULL
109135 +crypto_cipher_ctxsize_48890 crypto_cipher_ctxsize 0 48890 NULL
109136 +joydev_handle_JSIOCSAXMAP_48898 joydev_handle_JSIOCSAXMAP 3 48898 NULL
109137 +xdi_copy_to_user_48900 xdi_copy_to_user 4 48900 NULL
109138 +msg_hdr_sz_48908 msg_hdr_sz 0 48908 NULL
109139 +snd_pcm_update_hw_ptr_48925 snd_pcm_update_hw_ptr 0 48925 NULL
109140 +sep_crypto_dma_48937 sep_crypto_dma 0 48937 NULL
109141 +si5351_write_parameters_48940 si5351_write_parameters 2 48940 NULL
109142 +event_heart_beat_read_48961 event_heart_beat_read 3 48961 NULL
109143 +nand_ecc_test_run_48966 nand_ecc_test_run 1 48966 NULL
109144 +vmci_handle_arr_create_48971 vmci_handle_arr_create 1 48971 NULL
109145 +batadv_orig_hash_del_if_48972 batadv_orig_hash_del_if 2 48972 NULL
109146 +btrfs_delete_delayed_insertion_item_48981 btrfs_delete_delayed_insertion_item 0 48981 NULL
109147 +rds_rm_size_48996 rds_rm_size 0-2 48996 NULL
109148 +sel_write_enforce_48998 sel_write_enforce 3 48998 NULL
109149 +null_alloc_rs_49019 null_alloc_rs 2 49019 NULL
109150 +filemap_check_errors_49022 filemap_check_errors 0 49022 NULL
109151 +aic_inb_49023 aic_inb 0 49023 NULL
109152 +transient_status_49027 transient_status 4 49027 NULL
109153 +iwl_mvm_power_legacy_dbgfs_read_49038 iwl_mvm_power_legacy_dbgfs_read 4 49038 NULL nohasharray
109154 +ipath_reg_user_mr_49038 ipath_reg_user_mr 2-3 49038 &iwl_mvm_power_legacy_dbgfs_read_49038
109155 +aic7xxx_rem_scb_from_disc_list_49041 aic7xxx_rem_scb_from_disc_list 0 49041 NULL
109156 +setup_msi_irq_49052 setup_msi_irq 3-4 49052 NULL
109157 +ubi_read_49061 ubi_read 0 49061 NULL
109158 +sparse_early_nid_49094 sparse_early_nid 0 49094 NULL nohasharray
109159 +scsi_register_49094 scsi_register 2 49094 &sparse_early_nid_49094
109160 +paging64_walk_addr_nested_49100 paging64_walk_addr_nested 3 49100 NULL
109161 +compat_do_readv_writev_49102 compat_do_readv_writev 4 49102 NULL
109162 +xfrm_replay_state_esn_len_49119 xfrm_replay_state_esn_len 0 49119 NULL
109163 +ll_max_cached_mb_seq_write_49122 ll_max_cached_mb_seq_write 3 49122 NULL
109164 +qib_user_sdma_pin_pages_49136 qib_user_sdma_pin_pages 4-5-6 49136 NULL nohasharray
109165 +pt_read_49136 pt_read 3 49136 &qib_user_sdma_pin_pages_49136
109166 +read_file_49137 read_file 4 49137 NULL
109167 +ipwireless_tty_received_49154 ipwireless_tty_received 3 49154 NULL
109168 +f2fs_acl_count_49155 f2fs_acl_count 0-1 49155 NULL
109169 +ipw_queue_tx_init_49161 ipw_queue_tx_init 3 49161 NULL
109170 +ext4_free_clusters_after_init_49174 ext4_free_clusters_after_init 2 49174 NULL
109171 +__jfs_setxattr_49175 __jfs_setxattr 5 49175 NULL
109172 +ath6kl_bgscan_int_write_49178 ath6kl_bgscan_int_write 3 49178 NULL
109173 +dvb_dvr_ioctl_49182 dvb_dvr_ioctl 2 49182 NULL
109174 +print_queue_49191 print_queue 0 49191 NULL
109175 +root_nfs_cat_49192 root_nfs_cat 3 49192 NULL
109176 +iwl_dbgfs_ucode_general_stats_read_49199 iwl_dbgfs_ucode_general_stats_read 3 49199 NULL
109177 +il4965_rs_sta_dbgfs_stats_table_read_49206 il4965_rs_sta_dbgfs_stats_table_read 3 49206 NULL
109178 +do_jffs2_getxattr_49210 do_jffs2_getxattr 0 49210 NULL
109179 +resp_write_same_49217 resp_write_same 2 49217 NULL
109180 +nouveau_therm_create__49228 nouveau_therm_create_ 4 49228 NULL
109181 +hugetlb_cgroup_read_49259 hugetlb_cgroup_read 5 49259 NULL
109182 +ieee80211_if_read_rssi_threshold_49260 ieee80211_if_read_rssi_threshold 3 49260 NULL
109183 +isku_sysfs_read_keys_media_49268 isku_sysfs_read_keys_media 6 49268 NULL
109184 +ptlrpc_check_set_49277 ptlrpc_check_set 0 49277 NULL
109185 +rx_filter_beacon_filter_read_49279 rx_filter_beacon_filter_read 3 49279 NULL
109186 +__ext4_ext_dirty_49284 __ext4_ext_dirty 0 49284 NULL
109187 +ext4_xattr_ibody_list_49287 ext4_xattr_ibody_list 3-0 49287 NULL
109188 +viafb_dfph_proc_write_49288 viafb_dfph_proc_write 3 49288 NULL
109189 +uio_read_49300 uio_read 3 49300 NULL
109190 +ocfs2_resmap_find_free_bits_49301 ocfs2_resmap_find_free_bits 3 49301 NULL
109191 +isku_sysfs_read_keys_macro_49312 isku_sysfs_read_keys_macro 6 49312 NULL
109192 +update_ref_for_cow_49313 update_ref_for_cow 0 49313 NULL
109193 +SYSC_mincore_49319 SYSC_mincore 2-1 49319 NULL
109194 +fwtty_port_handler_49327 fwtty_port_handler 9 49327 NULL
109195 +srpt_alloc_ioctx_ring_49330 srpt_alloc_ioctx_ring 2-4-3 49330 NULL
109196 +__intel_map_single_49338 __intel_map_single 3-2 49338 NULL
109197 +intel_ring_invalidate_all_caches_49346 intel_ring_invalidate_all_caches 0 49346 NULL
109198 +joydev_ioctl_common_49359 joydev_ioctl_common 2 49359 NULL
109199 +ocfs2_remove_btree_range_49370 ocfs2_remove_btree_range 4-3-5 49370 NULL
109200 +iscsi_alloc_session_49390 iscsi_alloc_session 3 49390 NULL
109201 +ext4_ext_index_trans_blocks_49396 ext4_ext_index_trans_blocks 0 49396 NULL
109202 +rx_streaming_always_read_49401 rx_streaming_always_read 3 49401 NULL
109203 +tnode_alloc_49407 tnode_alloc 1 49407 NULL
109204 +samples_to_bytes_49426 samples_to_bytes 0-2 49426 NULL
109205 +ubi_add_to_av_49432 ubi_add_to_av 0 49432 NULL nohasharray
109206 +md_domain_init_49432 md_domain_init 2 49432 &ubi_add_to_av_49432
109207 +compat_do_msg_fill_49440 compat_do_msg_fill 3 49440 NULL
109208 +get_lru_size_49441 get_lru_size 0 49441 NULL
109209 +i915_gem_object_set_to_gtt_domain_49450 i915_gem_object_set_to_gtt_domain 0 49450 NULL
109210 +ocfs2_merge_rec_left_49455 ocfs2_merge_rec_left 0 49455 NULL
109211 +__hfsplus_getxattr_49460 __hfsplus_getxattr 0 49460 NULL
109212 +agp_3_5_isochronous_node_enable_49465 agp_3_5_isochronous_node_enable 3 49465 NULL
109213 +xfs_iformat_local_49472 xfs_iformat_local 4 49472 NULL
109214 +savu_sysfs_read_49473 savu_sysfs_read 6 49473 NULL
109215 +isr_decrypt_done_read_49490 isr_decrypt_done_read 3 49490 NULL
109216 +SyS_listxattr_49519 SyS_listxattr 3 49519 NULL
109217 +emulator_write_phys_49520 emulator_write_phys 2-4 49520 NULL
109218 +btrfs_add_free_space_49524 btrfs_add_free_space 0 49524 NULL
109219 +smk_write_access_49561 smk_write_access 3 49561 NULL
109220 +ntfs_malloc_nofs_49572 ntfs_malloc_nofs 1 49572 NULL
109221 +alloc_chunk_49575 alloc_chunk 1 49575 NULL
109222 +sctp_setsockopt_default_send_param_49578 sctp_setsockopt_default_send_param 3 49578 NULL
109223 +readfifo_49583 readfifo 1 49583 NULL
109224 +tap_write_49595 tap_write 3 49595 NULL
109225 +create_task_io_context_49601 create_task_io_context 3 49601 NULL
109226 +isr_wakeups_read_49607 isr_wakeups_read 3 49607 NULL
109227 +btrfs_mksubvol_49616 btrfs_mksubvol 3 49616 NULL
109228 +heap_init_49617 heap_init 2 49617 NULL
109229 +smk_write_doi_49621 smk_write_doi 3 49621 NULL
109230 +port_fops_read_49626 port_fops_read 3 49626 NULL
109231 +btrfsic_cmp_log_and_dev_bytenr_49628 btrfsic_cmp_log_and_dev_bytenr 2 49628 NULL
109232 +__swab32p_49657 __swab32p 0 49657 NULL
109233 +ubi_wl_flush_49682 ubi_wl_flush 0 49682 NULL
109234 +aa_simple_write_to_buffer_49683 aa_simple_write_to_buffer 3-4 49683 NULL
109235 +SyS_pwritev_49688 SyS_pwritev 3 49688 NULL
109236 +__setup_irq_49696 __setup_irq 0 49696 NULL
109237 +cx2341x_ctrl_new_menu_49700 cx2341x_ctrl_new_menu 3 49700 NULL
109238 +do_splice_to_49714 do_splice_to 4 49714 NULL
109239 +write_pool_49718 write_pool 3 49718 NULL
109240 +dm_thin_insert_block_49720 dm_thin_insert_block 2-3 49720 NULL
109241 +kvm_mmu_notifier_invalidate_page_49723 kvm_mmu_notifier_invalidate_page 3 49723 NULL
109242 +sep_create_dcb_dmatables_context_kernel_49728 sep_create_dcb_dmatables_context_kernel 6 49728 NULL
109243 +zd_usb_iowrite16v_49744 zd_usb_iowrite16v 3 49744 NULL
109244 +btrfs_chunk_num_stripes_49751 btrfs_chunk_num_stripes 0 49751 NULL
109245 +fuse_wr_pages_49753 fuse_wr_pages 0-1-2 49753 NULL
109246 +key_conf_keylen_read_49758 key_conf_keylen_read 3 49758 NULL
109247 +fuse_conn_waiting_read_49762 fuse_conn_waiting_read 3 49762 NULL
109248 +w83977af_fir_interrupt_49775 w83977af_fir_interrupt 0 49775 NULL
109249 +ceph_osdc_readpages_49789 ceph_osdc_readpages 0 49789 NULL
109250 +nfs4_acl_new_49806 nfs4_acl_new 1 49806 NULL
109251 +ntfs_copy_from_user_iovec_49829 ntfs_copy_from_user_iovec 3-6-0 49829 NULL
109252 +add_uuid_49831 add_uuid 4 49831 NULL
109253 +ath6kl_fwlog_block_read_49836 ath6kl_fwlog_block_read 3 49836 NULL
109254 +iraw_loop_49842 iraw_loop 0-1 49842 NULL
109255 +twl4030_write_49846 twl4030_write 2 49846 NULL
109256 +scsi_dispatch_cmd_entry_49848 scsi_dispatch_cmd_entry 3 49848 NULL
109257 +timeradd_entry_49850 timeradd_entry 3 49850 NULL
109258 +ubifs_destroy_tnc_subtree_49853 ubifs_destroy_tnc_subtree 0 49853 NULL
109259 +btrfs_subvolume_reserve_metadata_49859 btrfs_subvolume_reserve_metadata 3 49859 NULL
109260 +fiemap_count_to_size_49869 fiemap_count_to_size 0-1 49869 NULL
109261 +sctp_setsockopt_bindx_49870 sctp_setsockopt_bindx 3 49870 NULL
109262 +snd_mask_eq_49889 snd_mask_eq 0 49889 NULL
109263 +ceph_get_caps_49890 ceph_get_caps 0 49890 NULL
109264 +osc_brw_49896 osc_brw 4 49896 NULL
109265 +__cow_file_range_49901 __cow_file_range 5 49901 NULL
109266 +__copy_from_user_inatomic_nocache_49921 __copy_from_user_inatomic_nocache 3 49921 NULL
109267 +config_ep_by_speed_49939 config_ep_by_speed 0 49939 NULL
109268 +batadv_tt_realloc_packet_buff_49960 batadv_tt_realloc_packet_buff 4 49960 NULL
109269 +ieee80211_if_fmt_dtim_count_49987 ieee80211_if_fmt_dtim_count 3 49987 NULL
109270 +drm_buffer_copy_from_user_49990 drm_buffer_copy_from_user 3 49990 NULL
109271 +sta2x11_swiotlb_alloc_coherent_49994 sta2x11_swiotlb_alloc_coherent 2 49994 NULL
109272 +l2cap_chan_send_49995 l2cap_chan_send 3 49995 NULL
109273 +__module_alloc_50004 __module_alloc 1 50004 NULL
109274 +dn_mss_from_pmtu_50011 dn_mss_from_pmtu 0-2 50011 NULL
109275 +ptrace_readdata_50020 ptrace_readdata 2-4 50020 NULL
109276 +isdn_read_50021 isdn_read 3 50021 NULL
109277 +mdc_rename_pack_50023 mdc_rename_pack 4-6 50023 NULL
109278 +qp_alloc_queue_50028 qp_alloc_queue 1 50028 NULL
109279 +ioread8_50049 ioread8 0 50049 NULL
109280 +fuse_conn_max_background_write_50061 fuse_conn_max_background_write 3 50061 NULL
109281 +vmw_surface_destroy_size_50072 vmw_surface_destroy_size 0 50072 NULL
109282 +arch_setup_ht_irq_50073 arch_setup_ht_irq 1 50073 NULL
109283 +__kfifo_dma_in_prepare_50081 __kfifo_dma_in_prepare 4 50081 NULL
109284 +dev_set_alias_50084 dev_set_alias 3 50084 NULL
109285 +libcfs_ioctl_popdata_50087 libcfs_ioctl_popdata 3 50087 NULL
109286 +sock_setsockopt_50088 sock_setsockopt 5 50088 NULL
109287 +altera_swap_dr_50090 altera_swap_dr 2 50090 NULL
109288 +android_set_cntry_50100 android_set_cntry 0 50100 NULL
109289 +process_recorded_refs_50110 process_recorded_refs 0 50110 NULL
109290 +read_file_slot_50111 read_file_slot 3 50111 NULL
109291 +xfs_dir3_sf_entsize_50112 xfs_dir3_sf_entsize 0-3 50112 NULL
109292 +rx_streaming_interval_write_50120 rx_streaming_interval_write 3 50120 NULL
109293 +ocfs2_search_one_group_50125 ocfs2_search_one_group 0 50125 NULL nohasharray
109294 +jfs_direct_IO_50125 jfs_direct_IO 4 50125 &ocfs2_search_one_group_50125
109295 +SYSC_preadv_50134 SYSC_preadv 3 50134 NULL
109296 +copy_items_50140 copy_items 6 50140 NULL
109297 +tx_frag_need_fragmentation_read_50153 tx_frag_need_fragmentation_read 3 50153 NULL
109298 +reiserfs_bmap_count_50160 reiserfs_bmap_count 0 50160 NULL
109299 +kmalloc_node_50163 kmalloc_node 1-3 50163 NULL
109300 +rx_filter_ibss_filter_read_50167 rx_filter_ibss_filter_read 3 50167 NULL
109301 +ahd_probe_stack_size_50168 ahd_probe_stack_size 0 50168 NULL
109302 +odev_update_50169 odev_update 2 50169 NULL
109303 +ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 ieee80211_if_fmt_dot11MeshHWMPRannInterval 3 50172 NULL nohasharray
109304 +xfs_get_blocks_direct_50172 xfs_get_blocks_direct 2 50172 &ieee80211_if_fmt_dot11MeshHWMPRannInterval_50172 nohasharray
109305 +ubi_resize_volume_50172 ubi_resize_volume 2 50172 &xfs_get_blocks_direct_50172
109306 +ext3_do_update_inode_50178 ext3_do_update_inode 0 50178 NULL
109307 +cfg80211_roamed_bss_50198 cfg80211_roamed_bss 6-4 50198 NULL
109308 +cyttsp4_probe_50201 cyttsp4_probe 4 50201 NULL
109309 +rx_rx_timeout_wa_read_50204 rx_rx_timeout_wa_read 3 50204 NULL
109310 +compat_SyS_sendfile_50206 compat_SyS_sendfile 4 50206 NULL nohasharray
109311 +mthca_buddy_init_50206 mthca_buddy_init 2 50206 &compat_SyS_sendfile_50206
109312 +l2cap_sock_setsockopt_50207 l2cap_sock_setsockopt 5 50207 NULL
109313 +mon_bin_compat_ioctl_50234 mon_bin_compat_ioctl 3 50234 NULL
109314 +sg_kmalloc_50240 sg_kmalloc 1 50240 NULL
109315 +vma_dup_policy_50269 vma_dup_policy 0 50269 NULL
109316 +rxrpc_setsockopt_50286 rxrpc_setsockopt 5 50286 NULL
109317 +soc_codec_reg_show_50302 soc_codec_reg_show 0-3 50302 NULL
109318 +SYSC_flistxattr_50307 SYSC_flistxattr 3 50307 NULL
109319 +SYSC_sched_setaffinity_50310 SYSC_sched_setaffinity 2 50310 NULL
109320 +iterate_irefs_50313 iterate_irefs 0 50313 NULL
109321 +soc_camera_read_50319 soc_camera_read 3 50319 NULL
109322 +do_launder_page_50329 do_launder_page 0 50329 NULL
109323 +nouveau_engine_create__50331 nouveau_engine_create_ 7 50331 NULL
109324 +lpfc_idiag_pcicfg_read_50334 lpfc_idiag_pcicfg_read 3 50334 NULL
109325 +ocfs2_block_to_cluster_group_50337 ocfs2_block_to_cluster_group 2 50337 NULL nohasharray
109326 +snd_pcm_lib_writev_50337 snd_pcm_lib_writev 0-3 50337 &ocfs2_block_to_cluster_group_50337
109327 +tpm_read_50344 tpm_read 3 50344 NULL
109328 +sched_clock_remote_50347 sched_clock_remote 0 50347 NULL
109329 +efx_nic_update_stats_50352 efx_nic_update_stats 2 50352 NULL
109330 +kvm_arch_create_memslot_50354 kvm_arch_create_memslot 2 50354 NULL
109331 +isdn_ppp_read_50356 isdn_ppp_read 4 50356 NULL
109332 +ocfs2_figure_insert_type_50362 ocfs2_figure_insert_type 0 50362 NULL nohasharray
109333 +iwl_dbgfs_echo_test_write_50362 iwl_dbgfs_echo_test_write 3 50362 &ocfs2_figure_insert_type_50362
109334 +xfrm_send_migrate_50365 xfrm_send_migrate 5 50365 NULL
109335 +roccat_common2_receive_50369 roccat_common2_receive 4 50369 NULL
109336 +sl_alloc_bufs_50380 sl_alloc_bufs 2 50380 NULL
109337 +hash_ip6_expire_50390 hash_ip6_expire 3 50390 NULL
109338 +snd_mask_refine_last_50406 snd_mask_refine_last 0 50406 NULL
109339 +l2tp_ip_sendmsg_50411 l2tp_ip_sendmsg 4 50411 NULL
109340 +iscsi_create_conn_50425 iscsi_create_conn 2 50425 NULL
109341 +validate_acl_mac_addrs_50429 validate_acl_mac_addrs 0 50429 NULL
109342 +btrfs_error_discard_extent_50444 btrfs_error_discard_extent 2 50444 NULL nohasharray
109343 +ecryptfs_write_lower_page_segment_50444 ecryptfs_write_lower_page_segment 4 50444 &btrfs_error_discard_extent_50444
109344 +calc_csum_metadata_size_50448 calc_csum_metadata_size 0 50448 NULL
109345 +pgctrl_write_50453 pgctrl_write 3 50453 NULL
109346 +device_create_sys_dev_entry_50458 device_create_sys_dev_entry 0 50458 NULL
109347 +force_mapping_50464 force_mapping 2 50464 NULL
109348 +cfs_size_round_50472 cfs_size_round 0-1 50472 NULL
109349 +cdrom_read_cdda_50478 cdrom_read_cdda 4 50478 NULL
109350 +mei_io_cb_alloc_req_buf_50493 mei_io_cb_alloc_req_buf 2 50493 NULL
109351 +pwr_rcvd_awake_beacons_read_50505 pwr_rcvd_awake_beacons_read 3 50505 NULL
109352 +__ctzdi2_50536 __ctzdi2 1 50536 NULL
109353 +ath6kl_set_ap_probe_resp_ies_50539 ath6kl_set_ap_probe_resp_ies 3 50539 NULL
109354 +usbat_flash_write_data_50553 usbat_flash_write_data 4 50553 NULL
109355 +self_check_peb_vid_hdr_50563 self_check_peb_vid_hdr 0 50563 NULL nohasharray
109356 +ttm_agp_tt_create_50563 ttm_agp_tt_create 3 50563 &self_check_peb_vid_hdr_50563
109357 +fat_readpages_50582 fat_readpages 4 50582 NULL
109358 +iwl_dbgfs_missed_beacon_read_50584 iwl_dbgfs_missed_beacon_read 3 50584 NULL
109359 +build_inv_iommu_pages_50589 build_inv_iommu_pages 2-3 50589 NULL
109360 +xillybus_write_50605 xillybus_write 3 50605 NULL
109361 +rx_rx_checksum_result_read_50617 rx_rx_checksum_result_read 3 50617 NULL
109362 +ocfs2_split_extent_50618 ocfs2_split_extent 0 50618 NULL
109363 +sparse_early_usemaps_alloc_node_50623 sparse_early_usemaps_alloc_node 4 50623 NULL
109364 +__ffs_50625 __ffs 0-1 50625 NULL
109365 +regcache_rbtree_write_50629 regcache_rbtree_write 2 50629 NULL
109366 +simple_transaction_get_50633 simple_transaction_get 3 50633 NULL
109367 +ocfs2_do_insert_extent_50658 ocfs2_do_insert_extent 0 50658 NULL
109368 +ath6kl_tm_rx_event_50664 ath6kl_tm_rx_event 3 50664 NULL
109369 +bnad_debugfs_read_50665 bnad_debugfs_read 3 50665 NULL
109370 +ext2_try_to_allocate_with_rsv_50669 ext2_try_to_allocate_with_rsv 4-2-0 50669 NULL
109371 +prism2_read_fid_reg_50689 prism2_read_fid_reg 0 50689 NULL nohasharray
109372 +i2c_smbus_read_byte_data_50689 i2c_smbus_read_byte_data 0 50689 &prism2_read_fid_reg_50689
109373 +paging32_gva_to_gpa_50696 paging32_gva_to_gpa 2 50696 NULL
109374 +xfs_growfs_get_hdr_buf_50697 xfs_growfs_get_hdr_buf 3 50697 NULL
109375 +dev_mem_read_50706 dev_mem_read 3 50706 NULL
109376 +blk_check_plugged_50736 blk_check_plugged 3 50736 NULL
109377 +__ext3_get_inode_loc_50744 __ext3_get_inode_loc 0 50744 NULL
109378 +btrfs_truncate_free_space_cache_50769 btrfs_truncate_free_space_cache 0 50769 NULL
109379 +ocfs2_xattr_block_get_50773 ocfs2_xattr_block_get 0 50773 NULL
109380 +tm6000_read_write_usb_50774 tm6000_read_write_usb 7 50774 NULL
109381 +bio_alloc_map_data_50782 bio_alloc_map_data 2-1 50782 NULL
109382 +tpm_write_50798 tpm_write 3 50798 NULL
109383 +write_flush_50803 write_flush 3 50803 NULL
109384 +dvb_play_50814 dvb_play 3 50814 NULL
109385 +dpcm_show_state_50827 dpcm_show_state 0 50827 NULL
109386 +acpi_ev_install_gpe_block_50829 acpi_ev_install_gpe_block 2 50829 NULL
109387 +SetArea_50835 SetArea 4 50835 NULL nohasharray
109388 +mask_from_50835 mask_from 0-1-2 50835 &SetArea_50835 nohasharray
109389 +create_mem_extents_50835 create_mem_extents 0 50835 &mask_from_50835
109390 +videobuf_dma_init_user_50839 videobuf_dma_init_user 3-4 50839 NULL
109391 +btrfs_search_slot_for_read_50843 btrfs_search_slot_for_read 0 50843 NULL
109392 +self_check_write_50856 self_check_write 0-5 50856 NULL
109393 +carl9170_debugfs_write_50857 carl9170_debugfs_write 3 50857 NULL
109394 +alloc_masks_50861 alloc_masks 3 50861 NULL
109395 +__percpu_counter_init_50878 __percpu_counter_init 0 50878 NULL
109396 +btrfs_insert_inode_ref_50884 btrfs_insert_inode_ref 0 50884 NULL
109397 +SyS_lgetxattr_50889 SyS_lgetxattr 4 50889 NULL
109398 +netlbl_secattr_catmap_walk_rng_50894 netlbl_secattr_catmap_walk_rng 0-2 50894 NULL
109399 +__bdev_writeseg_50903 __bdev_writeseg 4 50903 NULL
109400 +xfs_iext_remove_50909 xfs_iext_remove 3 50909 NULL
109401 +blk_rq_cur_sectors_50910 blk_rq_cur_sectors 0 50910 NULL
109402 +hash_recvmsg_50924 hash_recvmsg 4 50924 NULL
109403 +chd_dec_fetch_cdata_50926 chd_dec_fetch_cdata 3 50926 NULL
109404 +show_device_status_50947 show_device_status 0 50947 NULL
109405 +irq_timeout_write_50950 irq_timeout_write 3 50950 NULL
109406 +ocfs2_add_refcount_flag_50952 ocfs2_add_refcount_flag 6 50952 NULL
109407 +sdio_uart_write_50954 sdio_uart_write 3 50954 NULL
109408 +SyS_setxattr_50957 SyS_setxattr 4 50957 NULL
109409 +btrfs_del_csums_50969 btrfs_del_csums 0 50969 NULL
109410 +__btrfs_mod_ref_50973 __btrfs_mod_ref 0 50973 NULL
109411 +iwl_statistics_flag_50981 iwl_statistics_flag 0-3 50981 NULL
109412 +timeout_write_50991 timeout_write 3 50991 NULL
109413 +wm831x_irq_map_50995 wm831x_irq_map 2 50995 NULL
109414 +proc_write_51003 proc_write 3 51003 NULL
109415 +jbd2_journal_extend_51012 jbd2_journal_extend 2-0 51012 NULL
109416 +lbs_dev_info_51023 lbs_dev_info 3 51023 NULL
109417 +ntfs_attr_find_51028 ntfs_attr_find 0 51028 NULL nohasharray
109418 +fuse_conn_congestion_threshold_read_51028 fuse_conn_congestion_threshold_read 3 51028 &ntfs_attr_find_51028
109419 +BcmGetSectionValEndOffset_51039 BcmGetSectionValEndOffset 0 51039 NULL
109420 +dump_midi_51040 dump_midi 3 51040 NULL
109421 +usb_get_descriptor_51041 usb_get_descriptor 0 51041 NULL
109422 +srpt_alloc_ioctx_51042 srpt_alloc_ioctx 2-3 51042 NULL
109423 +do_arpt_set_ctl_51053 do_arpt_set_ctl 4 51053 NULL
109424 +wusb_prf_64_51065 wusb_prf_64 7 51065 NULL
109425 +jbd2_journal_init_revoke_51088 jbd2_journal_init_revoke 2 51088 NULL
109426 +solo_enc_v4l2_init_51094 solo_enc_v4l2_init 2 51094 NULL
109427 +__ocfs2_find_path_51096 __ocfs2_find_path 0 51096 NULL
109428 +btrfs_del_item_51110 btrfs_del_item 0 51110 NULL nohasharray
109429 +ti_recv_51110 ti_recv 3 51110 &btrfs_del_item_51110
109430 +uasp_prepare_r_request_51124 uasp_prepare_r_request 0 51124 NULL
109431 +nfs_map_name_to_uid_51132 nfs_map_name_to_uid 3 51132 NULL
109432 +alloc_rtllib_51136 alloc_rtllib 1 51136 NULL
109433 +simple_xattr_set_51140 simple_xattr_set 4 51140 NULL
109434 +set_dirty_51144 set_dirty 3 51144 NULL
109435 +xfs_trans_get_efd_51148 xfs_trans_get_efd 3 51148 NULL
109436 +walk_page_buffers_51170 walk_page_buffers 0 51170 NULL
109437 +snd_pcm_unlink_51210 snd_pcm_unlink 0 51210 NULL
109438 +uhci_frame_skel_link_51213 uhci_frame_skel_link 2 51213 NULL
109439 +nf_ct_ext_create_51232 nf_ct_ext_create 3 51232 NULL
109440 +snd_pcm_write_51235 snd_pcm_write 3 51235 NULL
109441 +tipc_send_51238 tipc_send 4 51238 NULL
109442 +drm_property_create_51239 drm_property_create 4 51239 NULL
109443 +__mxt_read_reg_51249 __mxt_read_reg 0 51249 NULL
109444 +st_read_51251 st_read 3 51251 NULL
109445 +compat_dccp_setsockopt_51263 compat_dccp_setsockopt 5 51263 NULL
109446 +target_alloc_sgl_51264 target_alloc_sgl 3 51264 NULL
109447 +dvb_audio_write_51275 dvb_audio_write 3 51275 NULL
109448 +ipwireless_network_packet_received_51277 ipwireless_network_packet_received 4 51277 NULL
109449 +zone_reclaimable_pages_51283 zone_reclaimable_pages 0 51283 NULL nohasharray
109450 +__get_cur_name_and_parent_51283 __get_cur_name_and_parent 0 51283 &zone_reclaimable_pages_51283
109451 +pvr2_std_id_to_str_51288 pvr2_std_id_to_str 2 51288 NULL
109452 +bnad_debugfs_read_regrd_51308 bnad_debugfs_read_regrd 3 51308 NULL
109453 +get_cell_51316 get_cell 2 51316 NULL
109454 +init_map_ipmac_51317 init_map_ipmac 4-3-5 51317 NULL
109455 +ocfs2_read_inode_block_51319 ocfs2_read_inode_block 0 51319 NULL
109456 +alloc_hippi_dev_51320 alloc_hippi_dev 1 51320 NULL
109457 +ext2_xattr_get_51327 ext2_xattr_get 0 51327 NULL
109458 +alloc_smp_req_51337 alloc_smp_req 1 51337 NULL nohasharray
109459 +compat_arch_ptrace_51337 compat_arch_ptrace 3 51337 &alloc_smp_req_51337
109460 +ipw_get_event_log_len_51341 ipw_get_event_log_len 0 51341 NULL
109461 +ieee80211_if_fmt_estab_plinks_51370 ieee80211_if_fmt_estab_plinks 3 51370 NULL
109462 +radeon_kms_compat_ioctl_51371 radeon_kms_compat_ioctl 2 51371 NULL
109463 +pci_sriov_resource_alignment_51406 pci_sriov_resource_alignment 0 51406 NULL
109464 +ceph_sync_read_51410 ceph_sync_read 3-0 51410 NULL
109465 +get_first_ref_51413 get_first_ref 0 51413 NULL
109466 +__btrfs_end_transaction_51420 __btrfs_end_transaction 0 51420 NULL
109467 +blk_register_region_51424 blk_register_region 1-2 51424 NULL
109468 +mwifiex_rdeeprom_read_51429 mwifiex_rdeeprom_read 3 51429 NULL
109469 +hfsplus_brec_read_51436 hfsplus_brec_read 0 51436 NULL
109470 +ieee80211_if_read_dot11MeshHWMPRootMode_51441 ieee80211_if_read_dot11MeshHWMPRootMode 3 51441 NULL
109471 +print_devstats_dot11ACKFailureCount_51443 print_devstats_dot11ACKFailureCount 3 51443 NULL
109472 +____alloc_ei_netdev_51475 ____alloc_ei_netdev 1 51475 NULL
109473 +xfs_buf_get_uncached_51477 xfs_buf_get_uncached 2 51477 NULL
109474 +btrfs_find_space_cluster_51482 btrfs_find_space_cluster 5 51482 NULL
109475 +kvm_fetch_guest_virt_51493 kvm_fetch_guest_virt 4-2 51493 NULL
109476 +ieee80211_if_write_uapsd_queues_51526 ieee80211_if_write_uapsd_queues 3 51526 NULL
109477 +key_search_51533 key_search 0 51533 NULL
109478 +load_pdptrs_51541 load_pdptrs 3 51541 NULL
109479 +__alloc_eip_netdev_51549 __alloc_eip_netdev 1 51549 NULL
109480 +ixgb_get_eeprom_len_51586 ixgb_get_eeprom_len 0 51586 NULL
109481 +snd_interval_refine_first_51589 snd_interval_refine_first 0 51589 NULL nohasharray
109482 +get_cur_path_51589 get_cur_path 0 51589 &snd_interval_refine_first_51589
109483 +aac_convert_sgraw2_51598 aac_convert_sgraw2 4 51598 NULL
109484 +table_size_to_number_of_entries_51613 table_size_to_number_of_entries 0-1 51613 NULL
109485 +extent_fiemap_51621 extent_fiemap 3 51621 NULL
109486 +sctp_auth_create_key_51641 sctp_auth_create_key 1 51641 NULL
109487 +iscsi_create_session_51647 iscsi_create_session 3 51647 NULL
109488 +get_new_cssid_51665 get_new_cssid 2 51665 NULL
109489 +ps_upsd_utilization_read_51669 ps_upsd_utilization_read 3 51669 NULL
109490 +sctp_setsockopt_associnfo_51684 sctp_setsockopt_associnfo 3 51684 NULL
109491 +host_mapping_level_51696 host_mapping_level 2-0 51696 NULL
109492 +sel_write_access_51704 sel_write_access 3 51704 NULL
109493 +tty_cdev_add_51714 tty_cdev_add 2-4 51714 NULL
109494 +v9fs_alloc_rdir_buf_51716 v9fs_alloc_rdir_buf 2 51716 NULL
109495 +drm_compat_ioctl_51717 drm_compat_ioctl 2 51717 NULL
109496 +sg_read_oxfer_51724 sg_read_oxfer 3 51724 NULL
109497 +dbg_check_lpt_nodes_51727 dbg_check_lpt_nodes 0 51727 NULL
109498 +cm4040_read_51732 cm4040_read 3 51732 NULL
109499 +get_user_pages_fast_51751 get_user_pages_fast 1-2-0 51751 NULL
109500 +ifx_spi_insert_flip_string_51752 ifx_spi_insert_flip_string 3 51752 NULL
109501 +if_write_51756 if_write 3 51756 NULL
109502 +ext4_ext_create_new_leaf_51763 ext4_ext_create_new_leaf 0 51763 NULL
109503 +__fswab32_51781 __fswab32 0 51781 NULL
109504 +to_ratio_51809 to_ratio 1-2 51809 NULL
109505 +qib_alloc_devdata_51819 qib_alloc_devdata 2 51819 NULL
109506 +buffer_from_user_51826 buffer_from_user 3 51826 NULL
109507 +max732x_irq_pending_51840 max732x_irq_pending 0 51840 NULL
109508 +ioread32_51847 ioread32 0 51847 NULL nohasharray
109509 +read_file_tgt_tx_stats_51847 read_file_tgt_tx_stats 3 51847 &ioread32_51847
109510 +do_readv_writev_51849 do_readv_writev 4 51849 NULL
109511 +SYSC_sendto_51852 SYSC_sendto 6 51852 NULL
109512 +bm_page_io_async_51858 bm_page_io_async 2 51858 NULL
109513 +pointer_size_read_51863 pointer_size_read 3 51863 NULL
109514 +mlx4_alloc_db_from_pgdir_51865 mlx4_alloc_db_from_pgdir 3 51865 NULL
109515 +get_indirect_ea_51869 get_indirect_ea 4 51869 NULL
109516 +user_read_51881 user_read 3 51881 NULL
109517 +dbAdjCtl_51888 dbAdjCtl 0 51888 NULL
109518 +virt_to_phys_51896 virt_to_phys 0 51896 NULL nohasharray
109519 +SyS_mq_timedsend_51896 SyS_mq_timedsend 3 51896 &virt_to_phys_51896
109520 +commit_fs_roots_51898 commit_fs_roots 0 51898 NULL
109521 +uvhub_to_first_node_51916 uvhub_to_first_node 0 51916 NULL
109522 +wmi_set_ie_51919 wmi_set_ie 3 51919 NULL
109523 +dbg_status_buf_51930 dbg_status_buf 2 51930 NULL
109524 +__tcp_mtu_to_mss_51938 __tcp_mtu_to_mss 0-2 51938 NULL
109525 +xfrm_alg_len_51940 xfrm_alg_len 0 51940 NULL
109526 +irq_dispose_mapping_51941 irq_dispose_mapping 1 51941 NULL
109527 +scsi_get_vpd_page_51951 scsi_get_vpd_page 4 51951 NULL
109528 +arizona_free_irq_51969 arizona_free_irq 2 51969 NULL nohasharray
109529 +snd_mask_min_51969 snd_mask_min 0 51969 &arizona_free_irq_51969
109530 +__blkdev_get_51972 __blkdev_get 0 51972 NULL nohasharray
109531 +read_page_51972 read_page 2 51972 &__blkdev_get_51972
109532 +get_zone_51981 get_zone 0-1 51981 NULL
109533 +ath6kl_sdio_alloc_prep_scat_req_51986 ath6kl_sdio_alloc_prep_scat_req 2 51986 NULL
109534 +_c4iw_write_mem_dma_51991 _c4iw_write_mem_dma 3 51991 NULL
109535 +ntfs_attr_size_51994 ntfs_attr_size 0 51994 NULL
109536 +dwc3_mode_write_51997 dwc3_mode_write 3 51997 NULL
109537 +skb_copy_datagram_from_iovec_52014 skb_copy_datagram_from_iovec 4-2-5 52014 NULL
109538 +rdmalt_52022 rdmalt 0 52022 NULL
109539 +override_release_52032 override_release 2 52032 NULL
109540 +end_port_52042 end_port 0 52042 NULL
109541 +dma_rx_errors_read_52045 dma_rx_errors_read 3 52045 NULL
109542 +msnd_fifo_write_52052 msnd_fifo_write 0-3 52052 NULL
109543 +dvb_ringbuffer_avail_52057 dvb_ringbuffer_avail 0 52057 NULL
109544 +__fuse_request_alloc_52060 __fuse_request_alloc 1 52060 NULL
109545 +isofs_readpages_52067 isofs_readpages 4 52067 NULL
109546 +nsm_get_handle_52089 nsm_get_handle 4 52089 NULL
109547 +ulist_add_merge_52096 ulist_add_merge 0 52096 NULL
109548 +o2net_debug_read_52105 o2net_debug_read 3 52105 NULL
109549 +split_scan_timeout_write_52128 split_scan_timeout_write 3 52128 NULL
109550 +retry_count_read_52129 retry_count_read 3 52129 NULL
109551 +snd_pcm_channel_info_user_52135 snd_pcm_channel_info_user 0 52135 NULL
109552 +gdm_usb_hci_send_52138 gdm_usb_hci_send 3 52138 NULL
109553 +sub_alloc_52140 sub_alloc 0 52140 NULL nohasharray
109554 +zram_meta_alloc_52140 zram_meta_alloc 1 52140 &sub_alloc_52140
109555 +hysdn_conf_write_52145 hysdn_conf_write 3 52145 NULL nohasharray
109556 +ext2_alloc_blocks_52145 ext2_alloc_blocks 2-0 52145 &hysdn_conf_write_52145
109557 +htable_size_52148 htable_size 0-1 52148 NULL
109558 +smk_write_load2_52155 smk_write_load2 3 52155 NULL
109559 +ieee80211_if_read_dot11MeshRetryTimeout_52168 ieee80211_if_read_dot11MeshRetryTimeout 3 52168 NULL
109560 +mga_compat_ioctl_52170 mga_compat_ioctl 2 52170 NULL
109561 +print_prefix_52176 print_prefix 0 52176 NULL
109562 +proc_pid_readlink_52186 proc_pid_readlink 3 52186 NULL
109563 +vmci_qp_broker_alloc_52216 vmci_qp_broker_alloc 6-5 52216 NULL
109564 +do_dmabuf_dirty_ldu_52241 do_dmabuf_dirty_ldu 6 52241 NULL
109565 +fuse_request_alloc_52243 fuse_request_alloc 1 52243 NULL nohasharray
109566 +xfs_iomap_eof_align_last_fsb_52243 xfs_iomap_eof_align_last_fsb 3 52243 &fuse_request_alloc_52243
109567 +ocfs2_try_to_merge_extent_52244 ocfs2_try_to_merge_extent 0 52244 NULL
109568 +pm80x_request_irq_52250 pm80x_request_irq 2 52250 NULL
109569 +mdiobus_alloc_size_52259 mdiobus_alloc_size 1 52259 NULL
109570 +shrink_slab_52261 shrink_slab 2-3 52261 NULL
109571 +hva_to_pfn_slow_52262 hva_to_pfn_slow 1 52262 NULL
109572 +sisusbcon_do_font_op_52271 sisusbcon_do_font_op 9 52271 NULL
109573 +handle_supp_msgs_52284 handle_supp_msgs 4 52284 NULL
109574 +kobject_set_name_vargs_52309 kobject_set_name_vargs 0 52309 NULL
109575 +read_file_reset_52310 read_file_reset 3 52310 NULL
109576 +request_asymmetric_key_52317 request_asymmetric_key 4-2 52317 NULL
109577 +hwflags_read_52318 hwflags_read 3 52318 NULL
109578 +snd_pcm_hw_free_52327 snd_pcm_hw_free 0 52327 NULL
109579 +ntfs_rl_split_52328 ntfs_rl_split 4-2 52328 NULL
109580 +test_unaligned_bulk_52333 test_unaligned_bulk 3 52333 NULL
109581 +hur_len_52339 hur_len 0 52339 NULL
109582 +bytes_to_frames_52362 bytes_to_frames 0-2 52362 NULL
109583 +copy_entries_to_user_52367 copy_entries_to_user 1 52367 NULL
109584 +iwl_dump_fh_52371 iwl_dump_fh 0 52371 NULL
109585 +hfsplus_find_attr_52374 hfsplus_find_attr 0 52374 NULL
109586 +ocfs2_journal_access_eb_52377 ocfs2_journal_access_eb 0 52377 NULL
109587 +mq_emit_config_values_52378 mq_emit_config_values 3 52378 NULL
109588 +isdn_writebuf_stub_52383 isdn_writebuf_stub 4 52383 NULL
109589 +jfs_setxattr_52389 jfs_setxattr 4 52389 NULL
109590 +aer_inject_write_52399 aer_inject_write 3 52399 NULL nohasharray
109591 +cl_page_own_52399 cl_page_own 0 52399 &aer_inject_write_52399
109592 +cgroup_file_write_52417 cgroup_file_write 3 52417 NULL
109593 +line6_midibuf_init_52425 line6_midibuf_init 2 52425 NULL
109594 +hso_serial_common_create_52428 hso_serial_common_create 4 52428 NULL
109595 +delay_status_52431 delay_status 5 52431 NULL
109596 +ath6kl_delete_qos_write_52435 ath6kl_delete_qos_write 3 52435 NULL
109597 +ieee80211_if_fmt_num_sta_ps_52438 ieee80211_if_fmt_num_sta_ps 3 52438 NULL
109598 +acpi_nvs_for_each_region_52448 acpi_nvs_for_each_region 0 52448 NULL
109599 +alauda_read_data_52452 alauda_read_data 3 52452 NULL
109600 +ieee80211_alloc_txb_52477 ieee80211_alloc_txb 1 52477 NULL
109601 +usb_tranzport_write_52479 usb_tranzport_write 3 52479 NULL
109602 +ocfs2_extend_no_holes_52483 ocfs2_extend_no_holes 3-4 52483 NULL
109603 +fd_do_rw_52495 fd_do_rw 3 52495 NULL
109604 +qib_user_sdma_pin_pages_52498 qib_user_sdma_pin_pages 3-5-4 52498 NULL
109605 +int_tasklet_entry_52500 int_tasklet_entry 3 52500 NULL
109606 +lmv_get_easize_52504 lmv_get_easize 0 52504 NULL
109607 +pm_qos_power_write_52513 pm_qos_power_write 3 52513 NULL
109608 +bt_sock_stream_recvmsg_52518 bt_sock_stream_recvmsg 4 52518 NULL
109609 +dup_variable_bug_52525 dup_variable_bug 3 52525 NULL
109610 +raw_recvmsg_52529 raw_recvmsg 4 52529 NULL
109611 +from_oblock_52546 from_oblock 0-1 52546 NULL
109612 +dccpprobe_read_52549 dccpprobe_read 3 52549 NULL
109613 +ocfs2_make_right_split_rec_52562 ocfs2_make_right_split_rec 3 52562 NULL
109614 +debug_level_proc_write_52572 debug_level_proc_write 3 52572 NULL
109615 +isku_sysfs_read_macro_52587 isku_sysfs_read_macro 6 52587 NULL
109616 +snd_pcm_sw_params_52594 snd_pcm_sw_params 0 52594 NULL
109617 +SyS_setsockopt_52610 SyS_setsockopt 5 52610 NULL
109618 +ll_sa_entry_alloc_52611 ll_sa_entry_alloc 4 52611 NULL
109619 +affs_set_blocksize_52625 affs_set_blocksize 2 52625 NULL
109620 +tps80031_writes_52638 tps80031_writes 3-4 52638 NULL
109621 +brcmf_sdio_assert_info_52653 brcmf_sdio_assert_info 4 52653 NULL
109622 +perf_trace_sched_stat_template_52656 perf_trace_sched_stat_template 3 52656 NULL
109623 +nvme_queue_extra_52661 nvme_queue_extra 0-1 52661 NULL
109624 +htb_add_class_to_row_52663 htb_add_class_to_row 3 52663 NULL
109625 +posix_acl_equiv_mode_52666 posix_acl_equiv_mode 0 52666 NULL
109626 +SYSC_gethostname_52677 SYSC_gethostname 2 52677 NULL
109627 +ntfs_get_nr_significant_bytes_52688 ntfs_get_nr_significant_bytes 0 52688 NULL
109628 +nvd0_disp_pioc_create__52693 nvd0_disp_pioc_create_ 5 52693 NULL
109629 +vendorextnWriteSection_52698 vendorextnWriteSection 0 52698 NULL
109630 +nouveau_client_create__52715 nouveau_client_create_ 5 52715 NULL
109631 +__dm_stat_bio_52722 __dm_stat_bio 3 52722 NULL
109632 +cx25840_ir_rx_read_52724 cx25840_ir_rx_read 3 52724 NULL
109633 +blkcipher_next_slow_52733 blkcipher_next_slow 4-3 52733 NULL
109634 +relay_alloc_page_array_52735 relay_alloc_page_array 1 52735 NULL
109635 +hfcsusb_rx_frame_52745 hfcsusb_rx_frame 3 52745 NULL
109636 +carl9170_debugfs_vif_dump_read_52755 carl9170_debugfs_vif_dump_read 3 52755 NULL
109637 +ieee80211_if_read_beacon_timeout_52756 ieee80211_if_read_beacon_timeout 3 52756 NULL
109638 +radeon_get_ib_value_52757 radeon_get_ib_value 0 52757 NULL
109639 +nvme_trans_ext_inq_page_52776 nvme_trans_ext_inq_page 3 52776 NULL
109640 +pwr_rcvd_beacons_read_52836 pwr_rcvd_beacons_read 3 52836 NULL
109641 +map_try_harder_52846 map_try_harder 2-3 52846 NULL
109642 +ext2_xattr_set_acl_52857 ext2_xattr_set_acl 4 52857 NULL
109643 +process_deleted_xattr_52861 process_deleted_xattr 0 52861 NULL
109644 +mon_bin_get_event_52863 mon_bin_get_event 6-4 52863 NULL
109645 +twl6030_gpadc_write_52867 twl6030_gpadc_write 1 52867 NULL
109646 +qib_decode_6120_err_52876 qib_decode_6120_err 3 52876 NULL
109647 +twlreg_write_52880 twlreg_write 3 52880 NULL
109648 +pvr2_ctrl_value_to_sym_internal_52881 pvr2_ctrl_value_to_sym_internal 5 52881 NULL
109649 +cache_read_procfs_52882 cache_read_procfs 3 52882 NULL
109650 +kvm_kvzalloc_52894 kvm_kvzalloc 1 52894 NULL
109651 +arizona_request_irq_52908 arizona_request_irq 2 52908 NULL
109652 +create_vtbl_52909 create_vtbl 0 52909 NULL
109653 +dio_bio_reap_52913 dio_bio_reap 0 52913 NULL
109654 +__kfifo_out_peek_r_52919 __kfifo_out_peek_r 3 52919 NULL
109655 +iblock_get_bio_52936 iblock_get_bio 3 52936 NULL
109656 +__nodes_remap_52951 __nodes_remap 5 52951 NULL
109657 +send_packet_52960 send_packet 4 52960 NULL
109658 +ieee80211_if_fmt_fwded_mcast_52961 ieee80211_if_fmt_fwded_mcast 3 52961 NULL
109659 +tx_tx_exch_read_52986 tx_tx_exch_read 3 52986 NULL
109660 +num_node_state_52989 num_node_state 0 52989 NULL
109661 +efivarfs_file_write_53000 efivarfs_file_write 3 53000 NULL
109662 +uasp_alloc_stream_res_53015 uasp_alloc_stream_res 0 53015 NULL
109663 +btrfs_free_and_pin_reserved_extent_53016 btrfs_free_and_pin_reserved_extent 2 53016 NULL
109664 +tx_tx_exch_pending_read_53018 tx_tx_exch_pending_read 3 53018 NULL
109665 +ext4_meta_bg_first_group_53031 ext4_meta_bg_first_group 0-2 53031 NULL
109666 +ocfs2_new_leaf_refcount_block_53036 ocfs2_new_leaf_refcount_block 0 53036 NULL
109667 +bio_cur_bytes_53037 bio_cur_bytes 0 53037 NULL
109668 +regcache_lzo_block_count_53056 regcache_lzo_block_count 0 53056 NULL
109669 +cfi_read_query_53066 cfi_read_query 0 53066 NULL
109670 +iwl_dbgfs_interrupt_write_53069 iwl_dbgfs_interrupt_write 3 53069 NULL
109671 +mwifiex_debug_read_53074 mwifiex_debug_read 3 53074 NULL
109672 +page_to_nid_53085 page_to_nid 0 53085 NULL
109673 +qib_resize_cq_53090 qib_resize_cq 2 53090 NULL
109674 +insert_new_root_53097 insert_new_root 0 53097 NULL
109675 +verity_status_53120 verity_status 5 53120 NULL
109676 +__copy_from_user_ll_nocache_nozero_53123 __copy_from_user_ll_nocache_nozero 0-3 53123 NULL
109677 +brcmf_usb_dl_cmd_53130 brcmf_usb_dl_cmd 4 53130 NULL
109678 +btrfs_search_forward_53137 btrfs_search_forward 0 53137 NULL
109679 +ps_poll_ps_poll_max_ap_turn_read_53140 ps_poll_ps_poll_max_ap_turn_read 3 53140 NULL
109680 +ieee80211_bss_info_update_53170 ieee80211_bss_info_update 4 53170 NULL
109681 +btrfs_io_bio_alloc_53179 btrfs_io_bio_alloc 2 53179 NULL
109682 +clear_capture_buf_53192 clear_capture_buf 2 53192 NULL
109683 +SyS_init_module_53202 SyS_init_module 2 53202 NULL
109684 +mtdoops_erase_block_53206 mtdoops_erase_block 2 53206 NULL
109685 +fixup_user_fault_53210 fixup_user_fault 3 53210 NULL
109686 +tx_tx_start_data_read_53219 tx_tx_start_data_read 3 53219 NULL
109687 +ptlrpc_lprocfs_req_history_max_seq_write_53243 ptlrpc_lprocfs_req_history_max_seq_write 3 53243 NULL
109688 +hfsplus_xattr_set_posix_acl_53249 hfsplus_xattr_set_posix_acl 4 53249 NULL
109689 +xfs_trans_read_buf_map_53258 xfs_trans_read_buf_map 5 53258 NULL
109690 +wil_write_file_ssid_53266 wil_write_file_ssid 3 53266 NULL
109691 +btrfs_file_extent_num_bytes_53269 btrfs_file_extent_num_bytes 0 53269 NULL
109692 +tsk_fork_get_node_53271 tsk_fork_get_node 0 53271 NULL
109693 +btrfs_find_highest_objectid_53284 btrfs_find_highest_objectid 0 53284 NULL
109694 +setup_leaf_for_split_53312 setup_leaf_for_split 0 53312 NULL
109695 +ftrace_profile_write_53327 ftrace_profile_write 3 53327 NULL
109696 +setup_cluster_no_bitmap_53328 setup_cluster_no_bitmap 0 53328 NULL
109697 +gsm_control_reply_53333 gsm_control_reply 4 53333 NULL
109698 +vm_mmap_53339 vm_mmap 0 53339 NULL
109699 +vendorextnIoctl_53350 vendorextnIoctl 0 53350 NULL nohasharray
109700 +btrfs_find_all_roots_53350 btrfs_find_all_roots 0 53350 &vendorextnIoctl_53350
109701 +read_6120_creg32_53363 read_6120_creg32 0 53363 NULL
109702 +sock_setbindtodevice_53369 sock_setbindtodevice 3 53369 NULL
109703 +get_random_bytes_arch_53370 get_random_bytes_arch 2 53370 NULL
109704 +isolate_lru_page_53417 isolate_lru_page 0 53417 NULL
109705 +i915_gem_execbuffer_relocate_object_53435 i915_gem_execbuffer_relocate_object 0 53435 NULL
109706 +isr_cmd_cmplt_read_53439 isr_cmd_cmplt_read 3 53439 NULL
109707 +mwifiex_info_read_53447 mwifiex_info_read 3 53447 NULL
109708 +apei_exec_run_optional_53452 apei_exec_run_optional 0 53452 NULL
109709 +paging64_prefetch_gpte_53468 paging64_prefetch_gpte 4 53468 NULL
109710 +iowarrior_read_53483 iowarrior_read 3 53483 NULL
109711 +osd_req_write_kern_53486 osd_req_write_kern 5 53486 NULL
109712 +do_verify_xattr_datum_53499 do_verify_xattr_datum 0 53499 NULL
109713 +ext4_ext_grow_indepth_53503 ext4_ext_grow_indepth 0 53503 NULL
109714 +snd_pcm_format_physical_width_53505 snd_pcm_format_physical_width 0 53505 NULL
109715 +dbAllocNext_53506 dbAllocNext 0 53506 NULL
109716 +ocfs2_xattr_set_acl_53508 ocfs2_xattr_set_acl 4 53508 NULL
109717 +check_acl_53512 check_acl 0 53512 NULL
109718 +alloc_pages_exact_nid_53515 alloc_pages_exact_nid 1 53515 NULL
109719 +send_utimes_53516 send_utimes 0 53516 NULL
109720 +SYSC_bind_53582 SYSC_bind 3 53582 NULL
109721 +cifs_utf16_bytes_53593 cifs_utf16_bytes 0 53593 NULL
109722 +proc_uid_map_write_53596 proc_uid_map_write 3 53596 NULL
109723 +gfn_to_pfn_async_53597 gfn_to_pfn_async 2 53597 NULL
109724 +pfkey_recvmsg_53604 pfkey_recvmsg 4 53604 NULL
109725 +___alloc_bootmem_nopanic_53626 ___alloc_bootmem_nopanic 1 53626 NULL
109726 +xd_write_multiple_pages_53633 xd_write_multiple_pages 6-5 53633 NULL
109727 +stmpe_gpio_request_53634 stmpe_gpio_request 2 53634 NULL nohasharray
109728 +ccid_getsockopt_builtin_ccids_53634 ccid_getsockopt_builtin_ccids 2 53634 &stmpe_gpio_request_53634
109729 +nr_sendmsg_53656 nr_sendmsg 4 53656 NULL
109730 +fuse_fill_write_pages_53682 fuse_fill_write_pages 0-4 53682 NULL
109731 +v4l2_event_subscribe_53687 v4l2_event_subscribe 3 53687 NULL
109732 +igb_alloc_q_vector_53690 igb_alloc_q_vector 6-4 53690 NULL nohasharray
109733 +bdev_logical_block_size_53690 bdev_logical_block_size 0 53690 &igb_alloc_q_vector_53690
109734 +find_overflow_devnum_53711 find_overflow_devnum 0 53711 NULL
109735 +bio_integrity_split_53714 bio_integrity_split 3 53714 NULL
109736 +__ocfs2_resv_find_window_53721 __ocfs2_resv_find_window 3 53721 NULL
109737 +__proc_debug_mb_53732 __proc_debug_mb 5 53732 NULL
109738 +wdm_write_53735 wdm_write 3 53735 NULL
109739 +ext3_try_to_allocate_with_rsv_53737 ext3_try_to_allocate_with_rsv 5-3-0 53737 NULL
109740 +da9052_disable_irq_53745 da9052_disable_irq 2 53745 NULL
109741 +lpfc_idiag_queacc_read_qe_53755 lpfc_idiag_queacc_read_qe 0-2 53755 NULL nohasharray
109742 +amdtp_out_stream_get_max_payload_53755 amdtp_out_stream_get_max_payload 0 53755 &lpfc_idiag_queacc_read_qe_53755
109743 +ext2_acl_count_53773 ext2_acl_count 0-1 53773 NULL
109744 +__kfifo_dma_in_prepare_r_53792 __kfifo_dma_in_prepare_r 4-5 53792 NULL
109745 +qp_alloc_host_work_53798 qp_alloc_host_work 5-3 53798 NULL
109746 +regmap_raw_write_53803 regmap_raw_write 2-4 53803 NULL
109747 +lpfc_idiag_ctlacc_read_reg_53809 lpfc_idiag_ctlacc_read_reg 0-3 53809 NULL
109748 +nls_nullsize_53815 nls_nullsize 0 53815 NULL
109749 +insert_pfn_53816 insert_pfn 3-0 53816 NULL
109750 +setup_data_read_53822 setup_data_read 3 53822 NULL
109751 +pms_read_53873 pms_read 3 53873 NULL
109752 +ieee80211_if_fmt_dropped_frames_congestion_53883 ieee80211_if_fmt_dropped_frames_congestion 3 53883 NULL
109753 +ocfs2_rm_xattr_cluster_53900 ocfs2_rm_xattr_cluster 4-5-3 53900 NULL nohasharray
109754 +SyS_setgroups_53900 SyS_setgroups 1 53900 &ocfs2_rm_xattr_cluster_53900
109755 +azx_via_get_position_53916 azx_via_get_position 0 53916 NULL
109756 +usb_serial_generic_write_53927 usb_serial_generic_write 4 53927 NULL
109757 +ocfs2_make_clusters_writable_53938 ocfs2_make_clusters_writable 5-4-0 53938 NULL
109758 +idetape_chrdev_write_53976 idetape_chrdev_write 3 53976 NULL
109759 +mthca_reg_user_mr_53980 mthca_reg_user_mr 2-3 53980 NULL
109760 +__ocfs2_xattr_set_value_outside_53981 __ocfs2_xattr_set_value_outside 5 53981 NULL
109761 +ieee80211_if_fmt_dot11MeshHWMPperrMinInterval_53998 ieee80211_if_fmt_dot11MeshHWMPperrMinInterval 3 53998 NULL
109762 +send_clone_54011 send_clone 0 54011 NULL
109763 +hfsplus_attr_build_key_54013 hfsplus_attr_build_key 0 54013 NULL
109764 +snd_pcm_lib_write_transfer_54018 snd_pcm_lib_write_transfer 5-2-4 54018 NULL
109765 +mdc_kuc_write_54019 mdc_kuc_write 3 54019 NULL
109766 +ipxrtr_route_packet_54036 ipxrtr_route_packet 4 54036 NULL
109767 +pipeline_dec_packet_out_read_54052 pipeline_dec_packet_out_read 3 54052 NULL
109768 +nl80211_send_disconnected_54056 nl80211_send_disconnected 5 54056 NULL
109769 +rproc_state_read_54057 rproc_state_read 3 54057 NULL
109770 +btrfs_start_transaction_54066 btrfs_start_transaction 2 54066 NULL
109771 +_malloc_54077 _malloc 1 54077 NULL
109772 +bitmap_bitremap_54096 bitmap_bitremap 4 54096 NULL
109773 +altera_set_ir_pre_54103 altera_set_ir_pre 2 54103 NULL nohasharray
109774 +lustre_posix_acl_xattr_filter_54103 lustre_posix_acl_xattr_filter 2 54103 &altera_set_ir_pre_54103
109775 +__comedi_buf_write_alloc_54112 __comedi_buf_write_alloc 0-2 54112 NULL
109776 +strn_len_54122 strn_len 0 54122 NULL
109777 +isku_receive_54130 isku_receive 4 54130 NULL
109778 +isr_host_acknowledges_read_54136 isr_host_acknowledges_read 3 54136 NULL
109779 +irq_blk_threshold_write_54138 irq_blk_threshold_write 3 54138 NULL
109780 +memcpy_toiovec_54166 memcpy_toiovec 3 54166 NULL
109781 +nouveau_falcon_create__54169 nouveau_falcon_create_ 8 54169 NULL
109782 +p9_client_prepare_req_54175 p9_client_prepare_req 3 54175 NULL
109783 +devm_request_threaded_irq_54215 devm_request_threaded_irq 0 54215 NULL
109784 +do_sys_poll_54221 do_sys_poll 2 54221 NULL
109785 +__register_chrdev_54223 __register_chrdev 2-3 54223 NULL
109786 +pi_read_regr_54231 pi_read_regr 0 54231 NULL
109787 +mcp23s08_read_regs_54246 mcp23s08_read_regs 4 54246 NULL
109788 +reada_add_block_54247 reada_add_block 2 54247 NULL
109789 +write_file_spec_scan_ctl_54248 write_file_spec_scan_ctl 3 54248 NULL
109790 +jbd2__journal_restart_54249 jbd2__journal_restart 0 54249 NULL
109791 +barrier_all_devices_54254 barrier_all_devices 0 54254 NULL nohasharray
109792 +xfs_dir2_sf_addname_hard_54254 xfs_dir2_sf_addname_hard 3 54254 &barrier_all_devices_54254
109793 +ceph_msgpool_get_54258 ceph_msgpool_get 2 54258 NULL
109794 +wusb_prf_54261 wusb_prf 7 54261 NULL nohasharray
109795 +audio_write_54261 audio_write 4 54261 &wusb_prf_54261
109796 +mwifiex_getlog_read_54269 mwifiex_getlog_read 3 54269 NULL
109797 +kstrtou16_from_user_54274 kstrtou16_from_user 2 54274 NULL
109798 +ubi_calc_data_len_54279 ubi_calc_data_len 0-3 54279 NULL
109799 +altera_set_dr_post_54291 altera_set_dr_post 2 54291 NULL
109800 +dlm_alloc_pagevec_54296 dlm_alloc_pagevec 1 54296 NULL
109801 +get_iovec_page_array_54298 get_iovec_page_array 6 54298 NULL
109802 +ttm_mem_global_alloc_54299 ttm_mem_global_alloc 0 54299 NULL
109803 +reclaim_pages_54301 reclaim_pages 3 54301 NULL
109804 +sprintf_54306 sprintf 0 54306 NULL
109805 +bio_add_pc_page_54319 bio_add_pc_page 4 54319 NULL
109806 +br_fdb_fillbuf_54339 br_fdb_fillbuf 0 54339 NULL
109807 +__alloc_dev_table_54343 __alloc_dev_table 2 54343 NULL
109808 +__get_free_pages_54352 __get_free_pages 0 54352 NULL
109809 +tcf_hash_create_54360 tcf_hash_create 4 54360 NULL
109810 +read_file_credit_dist_stats_54367 read_file_credit_dist_stats 3 54367 NULL
109811 +vfs_readlink_54368 vfs_readlink 3 54368 NULL
109812 +do_dccp_setsockopt_54377 do_dccp_setsockopt 5 54377 NULL nohasharray
109813 +intel_sdvo_write_cmd_54377 intel_sdvo_write_cmd 4 54377 &do_dccp_setsockopt_54377
109814 +ah_alloc_tmp_54378 ah_alloc_tmp 2-3 54378 NULL
109815 +gart_unmap_page_54379 gart_unmap_page 3-2 54379 NULL
109816 +snd_pcm_oss_read2_54387 snd_pcm_oss_read2 3-0 54387 NULL
109817 +iwl_dbgfs_power_save_status_read_54392 iwl_dbgfs_power_save_status_read 3 54392 NULL
109818 +efx_nic_describe_stats_54407 efx_nic_describe_stats 2 54407 NULL
109819 +ll_ra_count_get_54410 ll_ra_count_get 3 54410 NULL
109820 +copy_gadget_strings_54417 copy_gadget_strings 3-2 54417 NULL
109821 +btrfs_inc_extent_ref_54442 btrfs_inc_extent_ref 0 54442 NULL
109822 +sparse_early_mem_maps_alloc_node_54485 sparse_early_mem_maps_alloc_node 4-5 54485 NULL
109823 +simple_strtoull_54493 simple_strtoull 0 54493 NULL
109824 +swiotlb_tbl_map_single_54495 swiotlb_tbl_map_single 0 54495 NULL
109825 +btrfs_ordered_sum_size_54509 btrfs_ordered_sum_size 0-2 54509 NULL
109826 +cgroup_write_X64_54514 cgroup_write_X64 5 54514 NULL
109827 +rfc4106_set_key_54519 rfc4106_set_key 3 54519 NULL
109828 +vmci_transport_dgram_enqueue_54525 vmci_transport_dgram_enqueue 4 54525 NULL
109829 +viacam_read_54526 viacam_read 3 54526 NULL
109830 +unix_dgram_connect_54535 unix_dgram_connect 3 54535 NULL
109831 +setsockopt_54539 setsockopt 5 54539 NULL
109832 +i915_reset_gen7_sol_offsets_54547 i915_reset_gen7_sol_offsets 0 54547 NULL
109833 +lbs_lowsnr_write_54549 lbs_lowsnr_write 3 54549 NULL
109834 +ntfs_commit_pages_after_non_resident_write_54555 ntfs_commit_pages_after_non_resident_write 4-3 54555 NULL nohasharray
109835 +i915_gem_get_seqno_54555 i915_gem_get_seqno 0 54555 &ntfs_commit_pages_after_non_resident_write_54555
109836 +btrfs_update_inode_item_54561 btrfs_update_inode_item 0 54561 NULL nohasharray
109837 +SYSC_setsockopt_54561 SYSC_setsockopt 5 54561 &btrfs_update_inode_item_54561
109838 +nfsd_vfs_write_54577 nfsd_vfs_write 6 54577 NULL
109839 +fw_iso_buffer_init_54582 fw_iso_buffer_init 3 54582 NULL
109840 +nvme_npages_54601 nvme_npages 0-1 54601 NULL
109841 +irq_pkt_threshold_write_54605 irq_pkt_threshold_write 3 54605 NULL
109842 +devm_gen_pool_create_54607 devm_gen_pool_create 3 54607 NULL
109843 +port_fops_write_54627 port_fops_write 3 54627 NULL
109844 +irq_timeout_read_54653 irq_timeout_read 3 54653 NULL
109845 +dns_resolver_read_54658 dns_resolver_read 3 54658 NULL
109846 +twl6030_interrupt_mask_54659 twl6030_interrupt_mask 2 54659 NULL
109847 +kvm_read_cr3_54662 kvm_read_cr3 0 54662 NULL
109848 +tdp_page_fault_54663 tdp_page_fault 2 54663 NULL
109849 +bus_add_device_54665 bus_add_device 0 54665 NULL
109850 +cw1200_queue_stats_init_54670 cw1200_queue_stats_init 2 54670 NULL
109851 +bio_kmalloc_54672 bio_kmalloc 2 54672 NULL
109852 +vring_new_virtqueue_54673 vring_new_virtqueue 2 54673 NULL
109853 +evm_read_key_54674 evm_read_key 3 54674 NULL
109854 +fs_path_add_path_54680 fs_path_add_path 0 54680 NULL
109855 +platform_get_irq_byname_54700 platform_get_irq_byname 0 54700 NULL
109856 +__btrfs_inc_extent_ref_54706 __btrfs_inc_extent_ref 7-0 54706 NULL
109857 +rfkill_fop_read_54711 rfkill_fop_read 3 54711 NULL
109858 +clk_divider_set_rate_54726 clk_divider_set_rate 3-2 54726 NULL
109859 +ocfs2_control_write_54737 ocfs2_control_write 3 54737 NULL
109860 +kzalloc_54740 kzalloc 1 54740 NULL
109861 +wep_iv_read_54744 wep_iv_read 3 54744 NULL
109862 +lpfc_idiag_pcicfg_write_54749 lpfc_idiag_pcicfg_write 3 54749 NULL
109863 +iio_event_chrdev_read_54757 iio_event_chrdev_read 3 54757 NULL
109864 +adis16480_show_firmware_date_54762 adis16480_show_firmware_date 3 54762 NULL
109865 +ldsem_atomic_update_54774 ldsem_atomic_update 1-0 54774 NULL
109866 +gpiochip_add_54781 gpiochip_add 0 54781 NULL
109867 +flexcop_device_kmalloc_54793 flexcop_device_kmalloc 1 54793 NULL
109868 +domain_init_54797 domain_init 2 54797 NULL
109869 +ext3_find_goal_54801 ext3_find_goal 0 54801 NULL
109870 +get_dev_size_54807 get_dev_size 0 54807 NULL
109871 +nfsd_write_54809 nfsd_write 6 54809 NULL
109872 +aes_decrypt_fail_read_54815 aes_decrypt_fail_read 3 54815 NULL nohasharray
109873 +kvzalloc_54815 kvzalloc 1 54815 &aes_decrypt_fail_read_54815 nohasharray
109874 +crypto_tfm_ctx_alignment_54815 crypto_tfm_ctx_alignment 0 54815 &kvzalloc_54815
109875 +generic_perform_write_54832 generic_perform_write 3 54832 NULL
109876 +write_rio_54837 write_rio 3 54837 NULL
109877 +nouveau_engctx_create__54839 nouveau_engctx_create_ 8 54839 NULL nohasharray
109878 +ext3_acl_from_disk_54839 ext3_acl_from_disk 2 54839 &nouveau_engctx_create__54839
109879 +ufx_ops_write_54848 ufx_ops_write 3 54848 NULL
109880 +printer_read_54851 printer_read 3 54851 NULL
109881 +qib_reg_user_mr_54858 qib_reg_user_mr 2-3 54858 NULL
109882 +alloc_ep_req_54860 alloc_ep_req 2 54860 NULL
109883 +broadsheet_spiflash_rewrite_sector_54864 broadsheet_spiflash_rewrite_sector 2 54864 NULL
109884 +prism_build_supp_rates_54865 prism_build_supp_rates 0 54865 NULL
109885 +iscsi_pool_init_54913 iscsi_pool_init 4-2 54913 NULL nohasharray
109886 +kobject_set_name_vargs_54913 kobject_set_name_vargs 0 54913 &iscsi_pool_init_54913
109887 +btrfs_stack_chunk_num_stripes_54923 btrfs_stack_chunk_num_stripes 0 54923 NULL
109888 +bio_add_page_54933 bio_add_page 0-3 54933 NULL
109889 +mxms_structlen_54939 mxms_structlen 0 54939 NULL
109890 +add_port_54941 add_port 2 54941 NULL
109891 +ath9k_dump_btcoex_54949 ath9k_dump_btcoex 0 54949 NULL
109892 +alauda_write_data_54967 alauda_write_data 3 54967 NULL
109893 +c4_add_card_54968 c4_add_card 3 54968 NULL
109894 +iwl_pcie_dump_fh_54975 iwl_pcie_dump_fh 0 54975 NULL
109895 +ubi_change_vtbl_record_54979 ubi_change_vtbl_record 0 54979 NULL
109896 +ext3_xattr_get_54989 ext3_xattr_get 0 54989 NULL
109897 +rds_ib_inc_copy_to_user_55007 rds_ib_inc_copy_to_user 3 55007 NULL
109898 +mem_cgroup_get_lru_size_55008 mem_cgroup_get_lru_size 0 55008 NULL
109899 +cx231xx_v4l2_read_55014 cx231xx_v4l2_read 3 55014 NULL
109900 +paging32_get_level1_sp_gpa_55022 paging32_get_level1_sp_gpa 0 55022 NULL
109901 +error_error_null_Frame_tx_start_read_55024 error_error_null_Frame_tx_start_read 3 55024 NULL
109902 +dgap_do_bios_load_55025 dgap_do_bios_load 3 55025 NULL
109903 +btrfs_init_acl_55028 btrfs_init_acl 0 55028 NULL
109904 +write_ctree_super_55039 write_ctree_super 0 55039 NULL
109905 +ext4_ext_handle_uninitialized_extents_55059 ext4_ext_handle_uninitialized_extents 0-6 55059 NULL
109906 +apei_exec_run_55075 apei_exec_run 0 55075 NULL
109907 +bitmap_storage_alloc_55077 bitmap_storage_alloc 2 55077 NULL
109908 +snd_pcm_capture_hw_avail_55086 snd_pcm_capture_hw_avail 0 55086 NULL nohasharray
109909 +read_dma_55086 read_dma 3 55086 &snd_pcm_capture_hw_avail_55086
109910 +rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read_55106 rxpipe_beacon_buffer_thres_host_int_trig_rx_data_read 3 55106 NULL
109911 +corrupt_data_55120 corrupt_data 0-3 55120 NULL
109912 +crypto_ahash_setkey_55134 crypto_ahash_setkey 3 55134 NULL
109913 +ocfs2_prepare_refcount_change_for_del_55137 ocfs2_prepare_refcount_change_for_del 3-0 55137 NULL nohasharray
109914 +filldir_55137 filldir 3 55137 &ocfs2_prepare_refcount_change_for_del_55137
109915 +validate_vid_hdr_55145 validate_vid_hdr 0 55145 NULL
109916 +ocfs2_truncate_file_55148 ocfs2_truncate_file 3 55148 NULL
109917 +npages_to_npools_55149 npages_to_npools 0-1 55149 NULL
109918 +ieee80211_if_read_uapsd_queues_55150 ieee80211_if_read_uapsd_queues 3 55150 NULL
109919 +mtd_get_fact_prot_info_55186 mtd_get_fact_prot_info 0 55186 NULL
109920 +sel_write_relabel_55195 sel_write_relabel 3 55195 NULL
109921 +sched_feat_write_55202 sched_feat_write 3 55202 NULL
109922 +ht40allow_map_read_55209 ht40allow_map_read 3 55209 NULL
109923 +__kfifo_dma_out_prepare_r_55211 __kfifo_dma_out_prepare_r 4-5 55211 NULL
109924 +do_raw_setsockopt_55215 do_raw_setsockopt 5 55215 NULL
109925 +qxl_alloc_client_monitors_config_55216 qxl_alloc_client_monitors_config 2 55216 NULL
109926 +dbAllocDmap_55227 dbAllocDmap 0 55227 NULL
109927 +hash_netport6_expire_55232 hash_netport6_expire 3 55232 NULL
109928 +memcpy_fromiovec_55247 memcpy_fromiovec 3 55247 NULL
109929 +lbs_failcount_write_55276 lbs_failcount_write 3 55276 NULL
109930 +persistent_ram_new_55286 persistent_ram_new 2-1 55286 NULL
109931 +ptrace_request_55288 ptrace_request 3 55288 NULL
109932 +rx_streaming_interval_read_55291 rx_streaming_interval_read 3 55291 NULL
109933 +lov_get_stripecnt_55297 lov_get_stripecnt 0-3 55297 NULL
109934 +gsm_control_modem_55303 gsm_control_modem 3 55303 NULL
109935 +wimax_msg_len_55304 wimax_msg_len 0 55304 NULL
109936 +qp_alloc_guest_work_55305 qp_alloc_guest_work 5-3 55305 NULL nohasharray
109937 +__get_vm_area_node_55305 __get_vm_area_node 6 55305 &qp_alloc_guest_work_55305
109938 +__vxge_hw_vpath_initialize_55328 __vxge_hw_vpath_initialize 2 55328 NULL
109939 +do_shmat_55336 do_shmat 5 55336 NULL
109940 +vme_user_read_55338 vme_user_read 3 55338 NULL
109941 +sctp_datamsg_from_user_55342 sctp_datamsg_from_user 4 55342 NULL nohasharray
109942 +__wa_xfer_setup_sizes_55342 __wa_xfer_setup_sizes 0 55342 &sctp_datamsg_from_user_55342
109943 +iterate_inode_extrefs_55362 iterate_inode_extrefs 0 55362 NULL nohasharray
109944 +acpi_system_read_event_55362 acpi_system_read_event 3 55362 &iterate_inode_extrefs_55362
109945 +cw1200_sdio_align_size_55391 cw1200_sdio_align_size 2 55391 NULL
109946 +__domain_mapping_55393 __domain_mapping 5 55393 NULL
109947 +iwl_dbgfs_plcp_delta_read_55407 iwl_dbgfs_plcp_delta_read 3 55407 NULL
109948 +si476x_radio_read_rds_blckcnt_blob_55427 si476x_radio_read_rds_blckcnt_blob 3 55427 NULL
109949 +SyS_read_55449 SyS_read 3 55449 NULL
109950 +add_relation_rb_55451 add_relation_rb 0 55451 NULL
109951 +__vxge_hw_channel_allocate_55462 __vxge_hw_channel_allocate 3 55462 NULL
109952 +cx23888_ir_rx_read_55473 cx23888_ir_rx_read 3 55473 NULL
109953 +snd_pcm_lib_write_55483 snd_pcm_lib_write 0-3 55483 NULL
109954 +i2o_pool_alloc_55485 i2o_pool_alloc 4 55485 NULL
109955 +ocfs2_rec_clusters_55501 ocfs2_rec_clusters 0 55501 NULL nohasharray
109956 +ras_stride_increase_window_55501 ras_stride_increase_window 3 55501 &ocfs2_rec_clusters_55501
109957 +ext4_flex_bg_size_55502 ext4_flex_bg_size 0 55502 NULL
109958 +tx_tx_done_int_template_read_55511 tx_tx_done_int_template_read 3 55511 NULL
109959 +ea_get_55522 ea_get 3-0 55522 NULL
109960 +buffer_size_55534 buffer_size 0 55534 NULL
109961 +set_msr_interception_55538 set_msr_interception 2 55538 NULL
109962 +tty_port_register_device_55543 tty_port_register_device 3 55543 NULL
109963 +dgap_do_config_load_55548 dgap_do_config_load 2 55548 NULL
109964 +dm_stats_list_55551 dm_stats_list 4 55551 NULL
109965 +gfs2_bitfit_55566 gfs2_bitfit 2-3-0 55566 NULL
109966 +hash_netport4_expire_55584 hash_netport4_expire 3 55584 NULL
109967 +add_partition_55588 add_partition 2 55588 NULL
109968 +kstrtou8_from_user_55599 kstrtou8_from_user 2 55599 NULL
109969 +SyS_keyctl_55602 SyS_keyctl 4 55602 NULL
109970 +allocate_without_wrapping_disk_55607 allocate_without_wrapping_disk 4 55607 NULL
109971 +macvtap_put_user_55609 macvtap_put_user 4 55609 NULL
109972 +selinux_setprocattr_55611 selinux_setprocattr 4 55611 NULL
109973 +edge_tty_recv_55622 edge_tty_recv 3 55622 NULL
109974 +snd_pcm_hw_param_last_55624 snd_pcm_hw_param_last 0 55624 NULL
109975 +reiserfs_xattr_get_55628 reiserfs_xattr_get 0 55628 NULL nohasharray
109976 +pktgen_if_write_55628 pktgen_if_write 3 55628 &reiserfs_xattr_get_55628
109977 +osc_obd_max_pages_per_rpc_seq_write_55636 osc_obd_max_pages_per_rpc_seq_write 3 55636 NULL
109978 +dvb_dmxdev_set_buffer_size_55643 dvb_dmxdev_set_buffer_size 2 55643 NULL
109979 +mlx4_buddy_alloc_55647 mlx4_buddy_alloc 2 55647 NULL
109980 +xfs_bmbt_maxrecs_55649 xfs_bmbt_maxrecs 0-2 55649 NULL
109981 +lpfc_idiag_queinfo_read_55662 lpfc_idiag_queinfo_read 3 55662 NULL
109982 +il_dbgfs_tx_queue_read_55668 il_dbgfs_tx_queue_read 3 55668 NULL
109983 +btrfs_reloc_cow_block_55672 btrfs_reloc_cow_block 0 55672 NULL
109984 +get_info_55681 get_info 3 55681 NULL
109985 +iwl_dbgfs_plcp_delta_write_55682 iwl_dbgfs_plcp_delta_write 3 55682 NULL
109986 +pm8001_store_update_fw_55716 pm8001_store_update_fw 4 55716 NULL
109987 +ocfs2_lock_refcount_tree_55719 ocfs2_lock_refcount_tree 0 55719 NULL nohasharray
109988 +mtdswap_init_55719 mtdswap_init 2 55719 &ocfs2_lock_refcount_tree_55719
109989 +tap_pwup_write_55723 tap_pwup_write 3 55723 NULL
109990 +__iio_allocate_kfifo_55738 __iio_allocate_kfifo 2 55738 NULL
109991 +set_local_name_55757 set_local_name 4 55757 NULL
109992 +strlen_55778 strlen 0 55778 NULL nohasharray
109993 +is_idx_node_in_tnc_55778 is_idx_node_in_tnc 0 55778 &strlen_55778
109994 +set_spte_55783 set_spte 4-5 55783 NULL
109995 +req_bio_endio_55786 req_bio_endio 3 55786 NULL nohasharray
109996 +conf_read_55786 conf_read 3 55786 &req_bio_endio_55786
109997 +uwb_rc_neh_grok_event_55799 uwb_rc_neh_grok_event 3 55799 NULL
109998 +sb16_copy_from_user_55836 sb16_copy_from_user 7-6-10 55836 NULL
109999 +ept_gva_to_gpa_55848 ept_gva_to_gpa 2 55848 NULL
110000 +ip_hdrlen_55849 ip_hdrlen 0 55849 NULL
110001 +hcd_alloc_coherent_55862 hcd_alloc_coherent 5 55862 NULL
110002 +shmem_setxattr_55867 shmem_setxattr 4 55867 NULL
110003 +__check_block_validity_55869 __check_block_validity 0 55869 NULL
110004 +hsc_write_55875 hsc_write 3 55875 NULL
110005 +pm_qos_power_read_55891 pm_qos_power_read 3 55891 NULL
110006 +snd_pcm_hw_param_value_min_55917 snd_pcm_hw_param_value_min 0 55917 NULL
110007 +ext2_direct_IO_55932 ext2_direct_IO 4 55932 NULL
110008 +paging64_page_fault_55942 paging64_page_fault 2 55942 NULL
110009 +kvm_write_guest_virt_system_55944 kvm_write_guest_virt_system 4-2 55944 NULL
110010 +sel_read_policy_55947 sel_read_policy 3 55947 NULL
110011 +ceph_get_direct_page_vector_55956 ceph_get_direct_page_vector 2 55956 NULL
110012 +simple_read_from_buffer_55957 simple_read_from_buffer 5-2 55957 NULL
110013 +tx_tx_imm_resp_read_55964 tx_tx_imm_resp_read 3 55964 NULL
110014 +btrfs_clone_55977 btrfs_clone 5-3 55977 NULL
110015 +wa_xfer_create_subset_sg_55992 wa_xfer_create_subset_sg 2-3 55992 NULL
110016 +nvme_alloc_iod_56027 nvme_alloc_iod 1-2 56027 NULL
110017 +dccp_sendmsg_56058 dccp_sendmsg 4 56058 NULL
110018 +__set_discard_56081 __set_discard 2 56081 NULL
110019 +pscsi_get_bio_56103 pscsi_get_bio 1 56103 NULL
110020 +usb_alloc_stream_buffers_56123 usb_alloc_stream_buffers 3 56123 NULL
110021 +sel_read_handle_status_56139 sel_read_handle_status 3 56139 NULL
110022 +write_file_frameerrors_56145 write_file_frameerrors 3 56145 NULL
110023 +add_extent_mapping_56157 add_extent_mapping 0 56157 NULL
110024 +__i2c_transfer_56162 __i2c_transfer 0 56162 NULL
110025 +rawv6_setsockopt_56165 rawv6_setsockopt 5 56165 NULL
110026 +create_irq_nr_56180 create_irq_nr 1-0-2 56180 NULL
110027 +ath9k_dump_legacy_btcoex_56194 ath9k_dump_legacy_btcoex 0 56194 NULL
110028 +ocfs2_journal_access_gd_56209 ocfs2_journal_access_gd 0 56209 NULL
110029 +update_space_info_56213 update_space_info 0 56213 NULL
110030 +ncp_read_bounce_size_56221 ncp_read_bounce_size 0-1 56221 NULL
110031 +vring_add_indirect_56222 vring_add_indirect 4 56222 NULL
110032 +ocfs2_find_xe_in_bucket_56224 ocfs2_find_xe_in_bucket 0 56224 NULL
110033 +do_ipt_set_ctl_56238 do_ipt_set_ctl 4 56238 NULL
110034 +fd_copyin_56247 fd_copyin 3 56247 NULL
110035 +svc_init_buffer_56249 svc_init_buffer 3 56249 NULL
110036 +sk_rmem_schedule_56255 sk_rmem_schedule 3 56255 NULL
110037 +p9pdu_vreadf_56271 p9pdu_vreadf 0 56271 NULL
110038 +il4965_ucode_general_stats_read_56277 il4965_ucode_general_stats_read 3 56277 NULL
110039 +ieee80211_if_fmt_user_power_level_56283 ieee80211_if_fmt_user_power_level 3 56283 NULL
110040 +RESIZE_IF_NEEDED_56286 RESIZE_IF_NEEDED 2 56286 NULL
110041 +dvb_aplay_56296 dvb_aplay 3 56296 NULL
110042 +btmrvl_hscfgcmd_read_56303 btmrvl_hscfgcmd_read 3 56303 NULL
110043 +speakup_file_write_56310 speakup_file_write 3 56310 NULL
110044 +pipeline_pre_to_defrag_swi_read_56321 pipeline_pre_to_defrag_swi_read 3 56321 NULL
110045 +journal_init_revoke_table_56331 journal_init_revoke_table 1 56331 NULL
110046 +snd_rawmidi_read_56337 snd_rawmidi_read 3 56337 NULL
110047 +ipv6_recv_error_56347 ipv6_recv_error 3 56347 NULL
110048 +vxge_os_dma_malloc_async_56348 vxge_os_dma_malloc_async 3 56348 NULL
110049 +mite_device_bytes_transferred_56355 mite_device_bytes_transferred 0 56355 NULL
110050 +iov_iter_copy_from_user_atomic_56368 iov_iter_copy_from_user_atomic 0-4 56368 NULL
110051 +dev_read_56369 dev_read 3 56369 NULL
110052 +ath10k_read_simulate_fw_crash_56371 ath10k_read_simulate_fw_crash 3 56371 NULL
110053 +ata_qc_complete_multiple_56376 ata_qc_complete_multiple 2 56376 NULL
110054 +snd_pcm_common_ioctl1_56382 snd_pcm_common_ioctl1 0 56382 NULL
110055 +write_gssp_56404 write_gssp 3 56404 NULL
110056 +ocfs2_control_read_56405 ocfs2_control_read 3 56405 NULL
110057 +do_get_write_access_56410 do_get_write_access 0 56410 NULL
110058 +i915_gem_object_sync_56417 i915_gem_object_sync 0 56417 NULL nohasharray
110059 +store_msg_56417 store_msg 3 56417 &i915_gem_object_sync_56417
110060 +pppol2tp_sendmsg_56420 pppol2tp_sendmsg 4 56420 NULL
110061 +fl_create_56435 fl_create 5 56435 NULL
110062 +gnttab_map_56439 gnttab_map 2 56439 NULL
110063 +cx231xx_init_isoc_56453 cx231xx_init_isoc 3-2-4 56453 NULL
110064 +set_connectable_56458 set_connectable 4 56458 NULL
110065 +osd_req_list_partition_objects_56464 osd_req_list_partition_objects 5 56464 NULL
110066 +putused_user_56467 putused_user 3 56467 NULL
110067 +lbs_rdmac_write_56471 lbs_rdmac_write 3 56471 NULL
110068 +calc_linear_pos_56472 calc_linear_pos 0-3 56472 NULL
110069 +global_rt_period_56476 global_rt_period 0 56476 NULL
110070 +crypto_shash_alignmask_56486 crypto_shash_alignmask 0 56486 NULL
110071 +ieee80211_rx_mgmt_probe_beacon_56491 ieee80211_rx_mgmt_probe_beacon 3 56491 NULL
110072 +cfs_access_process_vm_56503 cfs_access_process_vm 2-4-0 56503 NULL
110073 +init_map_ip_56508 init_map_ip 5 56508 NULL
110074 +lustre_posix_acl_xattr_reduce_space_56512 lustre_posix_acl_xattr_reduce_space 3 56512 NULL
110075 +ext4_zeroout_es_56514 ext4_zeroout_es 0 56514 NULL
110076 +cfg80211_connect_result_56515 cfg80211_connect_result 6-4 56515 NULL
110077 +ip_options_get_56538 ip_options_get 4 56538 NULL
110078 +ll_wr_track_id_56544 ll_wr_track_id 2 56544 NULL
110079 +vb2_queue_or_prepare_buf_56547 vb2_queue_or_prepare_buf 0 56547 NULL
110080 +ocfs2_change_extent_flag_56549 ocfs2_change_extent_flag 5 56549 NULL
110081 +alloc_apertures_56561 alloc_apertures 1 56561 NULL
110082 +rs_sta_dbgfs_stats_table_read_56573 rs_sta_dbgfs_stats_table_read 3 56573 NULL
110083 +portcntrs_2_read_56586 portcntrs_2_read 3 56586 NULL
110084 +event_filter_write_56609 event_filter_write 3 56609 NULL
110085 +nvme_trans_log_temperature_56613 nvme_trans_log_temperature 3 56613 NULL
110086 +gather_array_56641 gather_array 3 56641 NULL
110087 +lookup_extent_backref_56644 lookup_extent_backref 9-0 56644 NULL
110088 +uvc_debugfs_stats_read_56651 uvc_debugfs_stats_read 3 56651 NULL
110089 +tg3_nvram_write_block_56666 tg3_nvram_write_block 3 56666 NULL
110090 +btrfs_cow_block_56678 btrfs_cow_block 0 56678 NULL
110091 +snd_gus_dram_read_56686 snd_gus_dram_read 4 56686 NULL nohasharray
110092 +da9055_gpio_to_irq_56686 da9055_gpio_to_irq 2 56686 &snd_gus_dram_read_56686
110093 +build_map_info_56696 build_map_info 2 56696 NULL
110094 +dvb_ringbuffer_read_user_56702 dvb_ringbuffer_read_user 3-0 56702 NULL
110095 +sta_flags_read_56710 sta_flags_read 3 56710 NULL
110096 +ipv6_getsockopt_sticky_56711 ipv6_getsockopt_sticky 5 56711 NULL
110097 +__wa_xfer_setup_segs_56725 __wa_xfer_setup_segs 2 56725 NULL
110098 +__copy_from_user_ll_56738 __copy_from_user_ll 0-3 56738 NULL
110099 +pcpu_populate_chunk_56741 pcpu_populate_chunk 3-2 56741 NULL
110100 +drm_agp_bind_pages_56748 drm_agp_bind_pages 3 56748 NULL
110101 +btrfsic_map_block_56751 btrfsic_map_block 2 56751 NULL
110102 +alloc_iommu_56778 alloc_iommu 2-3-0 56778 NULL
110103 +hash_lookup_56792 hash_lookup 2 56792 NULL nohasharray
110104 +ttm_alloc_new_pages_56792 ttm_alloc_new_pages 5 56792 &hash_lookup_56792
110105 +do_syslog_56807 do_syslog 3 56807 NULL
110106 +ext4_ext_rm_idx_56827 ext4_ext_rm_idx 0 56827 NULL
110107 +mtdchar_write_56831 mtdchar_write 3 56831 NULL nohasharray
110108 +ntfs_rl_realloc_56831 ntfs_rl_realloc 3 56831 &mtdchar_write_56831
110109 +sysctl_sync_threshold_56835 sysctl_sync_threshold 0 56835 NULL
110110 +snd_rawmidi_kernel_write1_56847 snd_rawmidi_kernel_write1 4-0 56847 NULL
110111 +si476x_radio_read_agc_blob_56849 si476x_radio_read_agc_blob 3 56849 NULL
110112 +wb_lookup_56858 wb_lookup 2 56858 NULL
110113 +ext3_xattr_ibody_get_56880 ext3_xattr_ibody_get 0 56880 NULL
110114 +pvr2_debugifc_print_status_56890 pvr2_debugifc_print_status 3 56890 NULL
110115 +debug_debug3_read_56894 debug_debug3_read 3 56894 NULL
110116 +batadv_tt_update_changes_56895 batadv_tt_update_changes 3 56895 NULL
110117 +hfsplus_find_cat_56899 hfsplus_find_cat 0 56899 NULL
110118 +hfsplus_setxattr_56902 hfsplus_setxattr 4 56902 NULL
110119 +__bitmap_clear_bits_56912 __bitmap_clear_bits 3 56912 NULL
110120 +strcspn_56913 strcspn 0 56913 NULL
110121 +__kfifo_out_56927 __kfifo_out 0-3 56927 NULL
110122 +journal_init_revoke_56933 journal_init_revoke 2 56933 NULL nohasharray
110123 +CopyBufferToControlPacket_56933 CopyBufferToControlPacket 0 56933 &journal_init_revoke_56933
110124 +nouveau_xtensa_create__56952 nouveau_xtensa_create_ 8 56952 NULL
110125 +diva_get_driver_info_56967 diva_get_driver_info 0 56967 NULL
110126 +nouveau_device_create__56984 nouveau_device_create_ 6 56984 NULL
110127 +sptlrpc_secflags2str_56995 sptlrpc_secflags2str 3 56995 NULL
110128 +vlsi_alloc_ring_57003 vlsi_alloc_ring 3-4 57003 NULL
110129 +btrfs_super_csum_size_57004 btrfs_super_csum_size 0 57004 NULL
110130 +aircable_process_packet_57027 aircable_process_packet 4 57027 NULL
110131 +i915_gem_evict_everything_57038 i915_gem_evict_everything 0 57038 NULL
110132 +skb_network_offset_57043 skb_network_offset 0 57043 NULL nohasharray
110133 +ieee80211_if_fmt_state_57043 ieee80211_if_fmt_state 3 57043 &skb_network_offset_57043
110134 +bytes_to_samples_57049 bytes_to_samples 0-2 57049 NULL
110135 +xfs_buf_read_map_57053 xfs_buf_read_map 3 57053 NULL
110136 +__wl_get_peb_57058 __wl_get_peb 0 57058 NULL
110137 +cx2341x_ctrl_new_std_57061 cx2341x_ctrl_new_std 4 57061 NULL
110138 +sca3000_read_data_57064 sca3000_read_data 4 57064 NULL
110139 +pcmcia_replace_cis_57066 pcmcia_replace_cis 3 57066 NULL
110140 +tracing_set_trace_write_57096 tracing_set_trace_write 3 57096 NULL
110141 +altera_get_note_57099 altera_get_note 6 57099 NULL
110142 +hpfs_readpages_57106 hpfs_readpages 4 57106 NULL
110143 +snd_pcm_hw_params_old_user_57108 snd_pcm_hw_params_old_user 0 57108 NULL
110144 +crypto_compress_ctxsize_57109 crypto_compress_ctxsize 0 57109 NULL
110145 +sysfs_write_file_57116 sysfs_write_file 3 57116 NULL
110146 +cipso_v4_gentag_loc_57119 cipso_v4_gentag_loc 0 57119 NULL
110147 +nl80211_send_deauth_57136 nl80211_send_deauth 4 57136 NULL nohasharray
110148 +rds_ib_sub_signaled_57136 rds_ib_sub_signaled 2 57136 &nl80211_send_deauth_57136 nohasharray
110149 +ima_show_htable_value_57136 ima_show_htable_value 2 57136 &rds_ib_sub_signaled_57136
110150 +snd_sonicvibes_getdmac_57140 snd_sonicvibes_getdmac 0 57140 NULL
110151 +changed_inode_57156 changed_inode 0 57156 NULL
110152 +udl_prime_create_57159 udl_prime_create 2 57159 NULL
110153 +__ipath_get_user_pages_57166 __ipath_get_user_pages 1-2 57166 NULL
110154 +stk_prepare_sio_buffers_57168 stk_prepare_sio_buffers 2 57168 NULL
110155 +rx_hw_stuck_read_57179 rx_hw_stuck_read 3 57179 NULL
110156 +ocfs2_claim_metadata_57192 ocfs2_claim_metadata 0 57192 NULL
110157 +tt3650_ci_msg_57219 tt3650_ci_msg 4 57219 NULL
110158 +dma_fifo_alloc_57236 dma_fifo_alloc 5-3-2 57236 NULL
110159 +flush_space_57241 flush_space 3-0 57241 NULL
110160 +rsxx_cram_write_57244 rsxx_cram_write 3 57244 NULL
110161 +ieee80211_if_fmt_tsf_57249 ieee80211_if_fmt_tsf 3 57249 NULL
110162 +oprofilefs_ulong_from_user_57251 oprofilefs_ulong_from_user 3 57251 NULL
110163 +alloc_flex_gd_57259 alloc_flex_gd 1 57259 NULL
110164 +lbs_sleepparams_write_57283 lbs_sleepparams_write 3 57283 NULL
110165 +pstore_file_read_57288 pstore_file_read 3 57288 NULL
110166 +snd_pcm_read_57289 snd_pcm_read 3 57289 NULL
110167 +fw_file_size_57307 fw_file_size 0 57307 NULL
110168 +ftdi_elan_write_57309 ftdi_elan_write 3 57309 NULL
110169 +write_file_regval_57313 write_file_regval 3 57313 NULL
110170 +__mxt_write_reg_57326 __mxt_write_reg 3 57326 NULL
110171 +ocfs2_xattr_shrink_size_57328 ocfs2_xattr_shrink_size 3 57328 NULL
110172 +usblp_read_57342 usblp_read 3 57342 NULL
110173 +print_devstats_dot11RTSFailureCount_57347 print_devstats_dot11RTSFailureCount 3 57347 NULL
110174 +dio_send_cur_page_57348 dio_send_cur_page 0 57348 NULL
110175 +tipc_bclink_stats_57372 tipc_bclink_stats 2 57372 NULL
110176 +max8997_irq_domain_map_57375 max8997_irq_domain_map 2 57375 NULL
110177 +tty_register_device_attr_57381 tty_register_device_attr 2 57381 NULL
110178 +read_file_blob_57406 read_file_blob 3 57406 NULL
110179 +enclosure_register_57412 enclosure_register 3 57412 NULL
110180 +compat_keyctl_instantiate_key_iov_57431 compat_keyctl_instantiate_key_iov 3 57431 NULL
110181 +copy_to_user_fromio_57432 copy_to_user_fromio 3 57432 NULL
110182 +__roundup_pow_of_two_57461 __roundup_pow_of_two 0 57461 NULL
110183 +crypto_tfm_alg_blocksize_57463 crypto_tfm_alg_blocksize 0 57463 NULL
110184 +sisusb_clear_vram_57466 sisusb_clear_vram 2-3 57466 NULL
110185 +blk_flush_cur_seq_57467 blk_flush_cur_seq 0 57467 NULL
110186 +ieee80211_if_read_flags_57470 ieee80211_if_read_flags 3 57470 NULL nohasharray
110187 +sep_lock_user_pages_57470 sep_lock_user_pages 2-3 57470 &ieee80211_if_read_flags_57470
110188 +ocfs2_write_cluster_57483 ocfs2_write_cluster 9-8-2 57483 NULL
110189 +bnad_debugfs_write_regwr_57500 bnad_debugfs_write_regwr 3 57500 NULL
110190 +skb_headlen_57501 skb_headlen 0 57501 NULL
110191 +copy_in_user_57502 copy_in_user 3 57502 NULL
110192 +ckhdid_printf_57505 ckhdid_printf 2 57505 NULL
110193 +init_tag_map_57515 init_tag_map 3 57515 NULL
110194 +wil_read_file_ssid_57517 wil_read_file_ssid 3 57517 NULL nohasharray
110195 +il_dbgfs_force_reset_read_57517 il_dbgfs_force_reset_read 3 57517 &wil_read_file_ssid_57517 nohasharray
110196 +btrfs_insert_inode_extref_57517 btrfs_insert_inode_extref 0 57517 &il_dbgfs_force_reset_read_57517
110197 +cmm_read_57520 cmm_read 3 57520 NULL
110198 +inode_permission_57531 inode_permission 0 57531 NULL
110199 +acpi_dev_get_resources_57534 acpi_dev_get_resources 0 57534 NULL
110200 +ptlrpc_lprocfs_hp_ratio_seq_write_57537 ptlrpc_lprocfs_hp_ratio_seq_write 3 57537 NULL
110201 +ReadHDLCPnP_57559 ReadHDLCPnP 0 57559 NULL nohasharray
110202 +ext4_group_first_block_no_57559 ext4_group_first_block_no 0-2 57559 &ReadHDLCPnP_57559
110203 +obd_unpackmd_57563 obd_unpackmd 0 57563 NULL
110204 +snd_pcm_playback_ioctl1_57569 snd_pcm_playback_ioctl1 0 57569 NULL
110205 +get_bridge_ifindices_57579 get_bridge_ifindices 0 57579 NULL
110206 +ldlm_cli_enqueue_local_57582 ldlm_cli_enqueue_local 11 57582 NULL
110207 +il_dbgfs_interrupt_write_57591 il_dbgfs_interrupt_write 3 57591 NULL
110208 +read_file_spectral_fft_period_57593 read_file_spectral_fft_period 3 57593 NULL
110209 +wm831x_gpio_to_irq_57614 wm831x_gpio_to_irq 2 57614 NULL
110210 +vma_kernel_pagesize_57616 vma_kernel_pagesize 0 57616 NULL
110211 +tx_tx_retry_template_read_57623 tx_tx_retry_template_read 3 57623 NULL
110212 +sisusbcon_putcs_57630 sisusbcon_putcs 3 57630 NULL
110213 +mem_read_57631 mem_read 3 57631 NULL
110214 +tc3589x_irq_map_57639 tc3589x_irq_map 2 57639 NULL
110215 +r3964_write_57662 r3964_write 4 57662 NULL
110216 +proc_ns_readlink_57664 proc_ns_readlink 3 57664 NULL
110217 +__lgwrite_57669 __lgwrite 4 57669 NULL
110218 +f1x_match_to_this_node_57695 f1x_match_to_this_node 3 57695 NULL
110219 +i2400m_rx_stats_read_57706 i2400m_rx_stats_read 3 57706 NULL
110220 +snd_interval_value_57713 snd_interval_value 0 57713 NULL
110221 +ieee80211_if_read_dot11MeshHWMPconfirmationInterval_57722 ieee80211_if_read_dot11MeshHWMPconfirmationInterval 3 57722 NULL
110222 +i915_gem_object_get_pages_57734 i915_gem_object_get_pages 0 57734 NULL
110223 +nouveau_gpio_create__57735 nouveau_gpio_create_ 4-5 57735 NULL
110224 +compat_sys_set_mempolicy_57742 compat_sys_set_mempolicy 3 57742 NULL nohasharray
110225 +pppol2tp_recvmsg_57742 pppol2tp_recvmsg 4 57742 &compat_sys_set_mempolicy_57742
110226 +ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval_57762 ieee80211_if_fmt_dot11MeshHWMPpreqMinInterval 3 57762 NULL
110227 +SYSC_process_vm_writev_57776 SYSC_process_vm_writev 5-3 57776 NULL
110228 +apei_exec_collect_resources_57788 apei_exec_collect_resources 0 57788 NULL
110229 +ld2_57794 ld2 0 57794 NULL
110230 +ivtv_read_57796 ivtv_read 3 57796 NULL
110231 +generic_ptrace_peekdata_57806 generic_ptrace_peekdata 2 57806 NULL
110232 +ipath_user_sdma_num_pages_57813 ipath_user_sdma_num_pages 0 57813 NULL
110233 +bfad_debugfs_read_regrd_57830 bfad_debugfs_read_regrd 3 57830 NULL
110234 +copy_to_user_57835 copy_to_user 3-0 57835 NULL
110235 +flash_read_57843 flash_read 3 57843 NULL
110236 +kiblnd_create_tx_pool_57846 kiblnd_create_tx_pool 2 57846 NULL
110237 +process_all_new_xattrs_57881 process_all_new_xattrs 0 57881 NULL
110238 +xt_alloc_table_info_57903 xt_alloc_table_info 1 57903 NULL
110239 +atomic_add_return_unchecked_57910 atomic_add_return_unchecked 0-1 57910 NULL nohasharray
110240 +iio_read_first_n_kfifo_57910 iio_read_first_n_kfifo 2 57910 &atomic_add_return_unchecked_57910
110241 +memcg_caches_array_size_57918 memcg_caches_array_size 0-1 57918 NULL
110242 +twl_i2c_write_57923 twl_i2c_write 3-4 57923 NULL
110243 +__snd_gf1_look16_57925 __snd_gf1_look16 0 57925 NULL
110244 +sel_read_handle_unknown_57933 sel_read_handle_unknown 3 57933 NULL
110245 +nvc0_vm_create_57942 nvc0_vm_create 2-3 57942 NULL
110246 +xfs_mru_cache_create_57943 xfs_mru_cache_create 3 57943 NULL
110247 +key_algorithm_read_57946 key_algorithm_read 3 57946 NULL
110248 +ip_set_alloc_57953 ip_set_alloc 1 57953 NULL nohasharray
110249 +ioat3_dca_count_dca_slots_57953 ioat3_dca_count_dca_slots 0 57953 &ip_set_alloc_57953
110250 +c2_reg_user_mr_57982 c2_reg_user_mr 2-3 57982 NULL
110251 +interleave_nodes_57992 interleave_nodes 0 57992 NULL
110252 +do_rx_dma_57996 do_rx_dma 5 57996 NULL
110253 +rx_reset_counter_read_58001 rx_reset_counter_read 3 58001 NULL
110254 +iwl_dbgfs_ucode_rx_stats_read_58023 iwl_dbgfs_ucode_rx_stats_read 3 58023 NULL
110255 +io_playback_transfer_58030 io_playback_transfer 4 58030 NULL
110256 +ext4_block_bitmap_58033 ext4_block_bitmap 0 58033 NULL
110257 +mce_async_out_58056 mce_async_out 3 58056 NULL
110258 +ocfs2_find_leaf_58065 ocfs2_find_leaf 0 58065 NULL
110259 +dt3155_alloc_coherent_58073 dt3155_alloc_coherent 2 58073 NULL
110260 +cm4040_write_58079 cm4040_write 3 58079 NULL
110261 +ipv6_flowlabel_opt_58135 ipv6_flowlabel_opt 3 58135 NULL nohasharray
110262 +slhc_init_58135 slhc_init 2-1 58135 &ipv6_flowlabel_opt_58135
110263 +ocfs2_reserve_clusters_58164 ocfs2_reserve_clusters 0 58164 NULL
110264 +ext4_bg_num_gdb_58171 ext4_bg_num_gdb 0 58171 NULL
110265 +garmin_write_bulk_58191 garmin_write_bulk 3 58191 NULL
110266 +ieee80211_if_fmt_flags_58205 ieee80211_if_fmt_flags 3 58205 NULL
110267 +sysfs_add_file_mode_58222 sysfs_add_file_mode 0 58222 NULL
110268 +hva_to_pfn_58241 hva_to_pfn 1-0 58241 NULL
110269 +btrfsic_create_link_to_next_block_58246 btrfsic_create_link_to_next_block 4 58246 NULL
110270 +read_file_debug_58256 read_file_debug 3 58256 NULL
110271 +osc_max_dirty_mb_seq_write_58263 osc_max_dirty_mb_seq_write 3 58263 NULL
110272 +cfg80211_mgmt_tx_status_58266 cfg80211_mgmt_tx_status 4 58266 NULL
110273 +profile_load_58267 profile_load 3 58267 NULL
110274 +kstrtos8_from_user_58268 kstrtos8_from_user 2 58268 NULL
110275 +acpi_ds_build_internal_package_obj_58271 acpi_ds_build_internal_package_obj 3 58271 NULL
110276 +iscsi_decode_text_input_58292 iscsi_decode_text_input 4 58292 NULL
110277 +intel_alloc_coherent_58302 intel_alloc_coherent 2 58302 NULL
110278 +ieee80211_if_read_dot11MeshTTL_58307 ieee80211_if_read_dot11MeshTTL 3 58307 NULL
110279 +i915_wait_seqno_58309 i915_wait_seqno 0 58309 NULL
110280 +tx_tx_start_int_templates_read_58324 tx_tx_start_int_templates_read 3 58324 NULL
110281 +ext4_ext_truncate_extend_restart_58331 ext4_ext_truncate_extend_restart 3-0 58331 NULL
110282 +diva_init_dma_map_58336 diva_init_dma_map 3 58336 NULL
110283 +__copy_from_user_swizzled_58337 __copy_from_user_swizzled 2-4 58337 NULL
110284 +next_pidmap_58347 next_pidmap 2-0 58347 NULL
110285 +SyS_migrate_pages_58348 SyS_migrate_pages 2 58348 NULL
110286 +save_hint_58359 save_hint 2 58359 NULL
110287 +vmw_ttm_tt_create_58369 vmw_ttm_tt_create 2 58369 NULL nohasharray
110288 +brcmf_debugfs_sdio_counter_read_58369 brcmf_debugfs_sdio_counter_read 3 58369 &vmw_ttm_tt_create_58369
110289 +hash_ipportnet6_expire_58379 hash_ipportnet6_expire 3 58379 NULL
110290 +il_dbgfs_status_read_58388 il_dbgfs_status_read 3 58388 NULL
110291 +_drbd_md_sync_page_io_58403 _drbd_md_sync_page_io 6 58403 NULL
110292 +kvm_mmu_write_protect_pt_masked_58406 kvm_mmu_write_protect_pt_masked 3-4 58406 NULL nohasharray
110293 +idetape_pad_zeros_58406 idetape_pad_zeros 2 58406 &kvm_mmu_write_protect_pt_masked_58406
110294 +i2400m_pld_size_58415 i2400m_pld_size 0 58415 NULL
110295 +__mlx4_alloc_mtt_range_58418 __mlx4_alloc_mtt_range 2 58418 NULL
110296 +capabilities_read_58457 capabilities_read 3 58457 NULL
110297 +batadv_iv_ogm_aggr_packet_58462 batadv_iv_ogm_aggr_packet 3 58462 NULL
110298 +lpfc_idiag_baracc_read_58466 lpfc_idiag_baracc_read 3 58466 NULL nohasharray
110299 +compat_do_ipt_set_ctl_58466 compat_do_ipt_set_ctl 4 58466 &lpfc_idiag_baracc_read_58466
110300 +nv_rd08_58472 nv_rd08 0 58472 NULL
110301 +snd_gf1_read_addr_58483 snd_gf1_read_addr 0 58483 NULL
110302 +snd_rme96_capture_copy_58484 snd_rme96_capture_copy 5 58484 NULL
110303 +btrfs_cont_expand_58498 btrfs_cont_expand 2-3 58498 NULL
110304 +rndis_add_response_58544 rndis_add_response 2 58544 NULL
110305 +__clear_discard_58546 __clear_discard 2 58546 NULL
110306 +wrap_max_58548 wrap_max 0-1-2 58548 NULL
110307 +wep_decrypt_fail_read_58567 wep_decrypt_fail_read 3 58567 NULL
110308 +scnprint_mac_oui_58578 scnprint_mac_oui 3-0 58578 NULL
110309 +get_rhf_errstring_58582 get_rhf_errstring 3 58582 NULL
110310 +ea_read_inline_58589 ea_read_inline 0 58589 NULL
110311 +isku_sysfs_read_keys_thumbster_58590 isku_sysfs_read_keys_thumbster 6 58590 NULL
110312 +xip_file_read_58592 xip_file_read 3 58592 NULL
110313 +ecryptfs_write_end_58594 ecryptfs_write_end 5-3 58594 NULL
110314 +radeon_bo_size_58606 radeon_bo_size 0 58606 NULL
110315 +ebt_buf_count_58607 ebt_buf_count 0 58607 NULL
110316 +xfs_iomap_write_delay_58616 xfs_iomap_write_delay 2 58616 NULL
110317 +skb_copy_to_page_nocache_58624 skb_copy_to_page_nocache 6 58624 NULL
110318 +filemap_fdatawrite_range_58630 filemap_fdatawrite_range 0 58630 NULL
110319 +vb2_qbuf_58631 vb2_qbuf 0 58631 NULL
110320 +module_alloc_update_bounds_rx_58634 module_alloc_update_bounds_rx 1 58634 NULL
110321 +tx_tx_start_fw_gen_read_58648 tx_tx_start_fw_gen_read 3 58648 NULL
110322 +ocfs2_block_to_cluster_start_58653 ocfs2_block_to_cluster_start 2 58653 NULL
110323 +iwl_dbgfs_rx_handlers_write_58655 iwl_dbgfs_rx_handlers_write 3 58655 NULL
110324 +__gfn_to_pfn_58671 __gfn_to_pfn 2 58671 NULL
110325 +find_zero_58685 find_zero 0-1 58685 NULL
110326 +uwb_bce_print_IEs_58686 uwb_bce_print_IEs 4 58686 NULL
110327 +tps6586x_writes_58689 tps6586x_writes 2-3 58689 NULL
110328 +vmalloc_node_58700 vmalloc_node 1-2 58700 NULL
110329 +vx_send_msg_58711 vx_send_msg 0 58711 NULL
110330 +i915_gem_execbuffer_reserve_58722 i915_gem_execbuffer_reserve 0 58722 NULL
110331 +da9052_gpio_to_irq_58729 da9052_gpio_to_irq 2 58729 NULL
110332 +csum_exist_in_range_58730 csum_exist_in_range 2-3 58730 NULL
110333 +frames_to_bytes_58741 frames_to_bytes 0-2 58741 NULL
110334 +ieee80211_if_write_tkip_mic_test_58748 ieee80211_if_write_tkip_mic_test 3 58748 NULL
110335 +agp_allocate_memory_58761 agp_allocate_memory 2 58761 NULL
110336 +oblock_to_dblock_58762 oblock_to_dblock 0-2 58762 NULL
110337 +regmap_calc_reg_len_58795 regmap_calc_reg_len 0 58795 NULL
110338 +raw_send_hdrinc_58803 raw_send_hdrinc 4 58803 NULL
110339 +isku_sysfs_read_58806 isku_sysfs_read 5 58806 NULL
110340 +write_file_58812 write_file 4 58812 NULL
110341 +ep_read_58813 ep_read 3 58813 NULL
110342 +command_write_58841 command_write 3 58841 NULL
110343 +ocfs2_truncate_log_append_58850 ocfs2_truncate_log_append 3-0 58850 NULL
110344 +ath6kl_wmi_send_action_cmd_58860 ath6kl_wmi_send_action_cmd 7 58860 NULL
110345 +gs_alloc_req_58883 gs_alloc_req 2 58883 NULL
110346 +esas2r_change_queue_depth_58886 esas2r_change_queue_depth 2 58886 NULL
110347 +lprocfs_wr_pinger_recov_58914 lprocfs_wr_pinger_recov 3 58914 NULL
110348 +print_devstats_dot11FCSErrorCount_58919 print_devstats_dot11FCSErrorCount 3 58919 NULL
110349 +pipeline_cs_rx_packet_out_read_58926 pipeline_cs_rx_packet_out_read 3 58926 NULL
110350 +SyS_pread64_58935 SyS_pread64 3 58935 NULL
110351 +wait_table_hash_nr_entries_58962 wait_table_hash_nr_entries 0 58962 NULL
110352 +ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout_58965 ieee80211_if_fmt_dot11MeshHWMPactivePathToRootTimeout 3 58965 NULL
110353 +crypto_aead_ivsize_58970 crypto_aead_ivsize 0 58970 NULL
110354 +__mem_cgroup_try_charge_58976 __mem_cgroup_try_charge 0 58976 NULL
110355 +init_list_58990 init_list 3 58990 NULL
110356 +remap_to_cache_dirty_58991 remap_to_cache_dirty 4-3 58991 NULL
110357 +ep_write_59008 ep_write 3 59008 NULL
110358 +lpfc_idiag_baracc_write_59014 lpfc_idiag_baracc_write 3 59014 NULL
110359 +SyS_preadv_59029 SyS_preadv 3 59029 NULL
110360 +init_pci_cap_msi_perm_59033 init_pci_cap_msi_perm 2 59033 NULL
110361 +selinux_transaction_write_59038 selinux_transaction_write 3 59038 NULL
110362 +crypto_aead_reqsize_59039 crypto_aead_reqsize 0 59039 NULL
110363 +regmap_bulk_write_59049 regmap_bulk_write 2-4 59049 NULL
110364 +sysfs_link_sibling_59078 sysfs_link_sibling 0 59078 NULL
110365 +do_perf_sw_event_59099 do_perf_sw_event 3 59099 NULL
110366 +mmc_sd_num_wr_blocks_59112 mmc_sd_num_wr_blocks 0 59112 NULL
110367 +scsi_io_completion_59122 scsi_io_completion 2 59122 NULL
110368 +init_status_page_59124 init_status_page 0 59124 NULL
110369 +nfc_llcp_send_i_frame_59130 nfc_llcp_send_i_frame 3 59130 NULL
110370 +print_devstats_dot11RTSSuccessCount_59145 print_devstats_dot11RTSSuccessCount 3 59145 NULL nohasharray
110371 +framebuffer_alloc_59145 framebuffer_alloc 1 59145 &print_devstats_dot11RTSSuccessCount_59145
110372 +ocfs2_claim_local_alloc_bits_59147 ocfs2_claim_local_alloc_bits 0 59147 NULL
110373 +radeon_compat_ioctl_59150 radeon_compat_ioctl 2 59150 NULL
110374 +pvr2_hdw_report_clients_59152 pvr2_hdw_report_clients 3 59152 NULL
110375 +ksize_59176 ksize 0 59176 NULL
110376 +setup_window_59178 setup_window 4-2-5-7 59178 NULL
110377 +ocfs2_move_extent_59187 ocfs2_move_extent 3-5-2 59187 NULL
110378 +validate_exec_list_59204 validate_exec_list 0 59204 NULL
110379 +xfs_iext_realloc_indirect_59211 xfs_iext_realloc_indirect 2 59211 NULL
110380 +check_mapped_selector_name_59216 check_mapped_selector_name 5 59216 NULL
110381 +dt3155_read_59226 dt3155_read 3 59226 NULL
110382 +paging64_gpte_to_gfn_lvl_59229 paging64_gpte_to_gfn_lvl 0-1-2 59229 NULL
110383 +tty_prepare_flip_string_flags_59240 tty_prepare_flip_string_flags 4 59240 NULL
110384 +nla_len_59258 nla_len 0 59258 NULL
110385 +drbd_bm_write_page_59290 drbd_bm_write_page 2 59290 NULL
110386 +__push_leaf_right_59302 __push_leaf_right 0 59302 NULL
110387 +btrfs_insert_dir_item_59304 btrfs_insert_dir_item 4-0 59304 NULL
110388 +fd_copyout_59323 fd_copyout 3 59323 NULL
110389 +read_9287_modal_eeprom_59327 read_9287_modal_eeprom 3 59327 NULL
110390 +rx_defrag_in_process_called_read_59338 rx_defrag_in_process_called_read 3 59338 NULL
110391 +paging64_get_level1_sp_gpa_59346 paging64_get_level1_sp_gpa 0 59346 NULL nohasharray
110392 +xfs_attrmulti_attr_set_59346 xfs_attrmulti_attr_set 4 59346 &paging64_get_level1_sp_gpa_59346
110393 +__map_request_59350 __map_request 0 59350 NULL
110394 +xfs_dir2_sf_entsize_59366 xfs_dir2_sf_entsize 0-2 59366 NULL
110395 +blk_flush_policy_59368 blk_flush_policy 0 59368 NULL
110396 +f2fs_fallocate_59377 f2fs_fallocate 3-4 59377 NULL
110397 +pvr2_debugifc_print_info_59380 pvr2_debugifc_print_info 3 59380 NULL
110398 +ocfs2_replay_truncate_records_59382 ocfs2_replay_truncate_records 0 59382 NULL
110399 +journal_init_dev_59384 journal_init_dev 5 59384 NULL
110400 +isku_sysfs_read_keys_function_59412 isku_sysfs_read_keys_function 6 59412 NULL
110401 +pci_ctrl_read_59424 pci_ctrl_read 0 59424 NULL
110402 +vxge_hw_ring_rxds_per_block_get_59425 vxge_hw_ring_rxds_per_block_get 0 59425 NULL
110403 +snd_pcm_tstamp_59431 snd_pcm_tstamp 0 59431 NULL
110404 +SyS_sched_setaffinity_59442 SyS_sched_setaffinity 2 59442 NULL
110405 +fs_path_ensure_buf_59445 fs_path_ensure_buf 2-0 59445 NULL
110406 +descriptor_loc_59446 descriptor_loc 3 59446 NULL
110407 +block_rsv_use_bytes_59464 block_rsv_use_bytes 0 59464 NULL
110408 +shrink_tnc_trees_59481 shrink_tnc_trees 0 59481 NULL
110409 +btrfs_del_dir_entries_in_log_59490 btrfs_del_dir_entries_in_log 0 59490 NULL
110410 +ib_copy_from_udata_59502 ib_copy_from_udata 3 59502 NULL
110411 +rds_pin_pages_59507 rds_pin_pages 1-2 59507 NULL
110412 +kmalloc_large_node_59542 kmalloc_large_node 3 59542 NULL
110413 +ext4_resize_fs_59543 ext4_resize_fs 2 59543 NULL
110414 +mpi_get_nbits_59551 mpi_get_nbits 0 59551 NULL
110415 +tunables_write_59563 tunables_write 3 59563 NULL
110416 +__copy_from_user_ll_nozero_59571 __copy_from_user_ll_nozero 0-3 59571 NULL
110417 +write_pbl_59583 write_pbl 4 59583 NULL
110418 +memdup_user_59590 memdup_user 2 59590 NULL
110419 +tps6586x_irq_get_virq_59601 tps6586x_irq_get_virq 2 59601 NULL
110420 +mem_fwlog_free_mem_blks_read_59616 mem_fwlog_free_mem_blks_read 3 59616 NULL nohasharray
110421 +xrcdn_free_res_59616 xrcdn_free_res 5 59616 &mem_fwlog_free_mem_blks_read_59616
110422 +ath6kl_endpoint_stats_write_59621 ath6kl_endpoint_stats_write 3 59621 NULL
110423 +mtrr_write_59622 mtrr_write 3 59622 NULL
110424 +ocfs2_adjust_rightmost_branch_59623 ocfs2_adjust_rightmost_branch 0 59623 NULL
110425 +find_first_zero_bit_59636 find_first_zero_bit 0-2 59636 NULL
110426 +SyS_setdomainname_59646 SyS_setdomainname 2 59646 NULL
110427 +hidraw_read_59650 hidraw_read 3 59650 NULL
110428 +v9fs_xattr_set_acl_59651 v9fs_xattr_set_acl 4 59651 NULL
110429 +paravirt_sched_clock_59660 paravirt_sched_clock 0 59660 NULL
110430 +__devcgroup_check_permission_59665 __devcgroup_check_permission 0 59665 NULL
110431 +iwl_dbgfs_mac_params_read_59666 iwl_dbgfs_mac_params_read 3 59666 NULL
110432 +alloc_dca_provider_59670 alloc_dca_provider 2 59670 NULL
110433 +mic_calc_failure_read_59700 mic_calc_failure_read 3 59700 NULL
110434 +ioperm_get_59701 ioperm_get 4-3 59701 NULL
110435 +snd_pcm_info_user_59711 snd_pcm_info_user 0 59711 NULL
110436 +prism2_info_scanresults_59729 prism2_info_scanresults 3 59729 NULL
110437 +ieee80211_if_read_fwded_unicast_59740 ieee80211_if_read_fwded_unicast 3 59740 NULL
110438 +fat_direct_IO_59741 fat_direct_IO 4 59741 NULL
110439 +qib_decode_7220_sdma_errs_59745 qib_decode_7220_sdma_errs 4 59745 NULL
110440 +strnlen_59746 strnlen 0 59746 NULL
110441 +process_all_refs_59754 process_all_refs 0 59754 NULL nohasharray
110442 +ext3_acl_count_59754 ext3_acl_count 0-1 59754 &process_all_refs_59754
110443 +process_new_xattr_59755 process_new_xattr 0 59755 NULL
110444 +long_retry_limit_read_59766 long_retry_limit_read 3 59766 NULL
110445 +venus_remove_59781 venus_remove 4 59781 NULL
110446 +mei_nfc_recv_59784 mei_nfc_recv 3 59784 NULL
110447 +xlog_do_recover_59789 xlog_do_recover 3 59789 NULL
110448 +msb_get_zone_from_lba_59800 msb_get_zone_from_lba 0-1 59800 NULL
110449 +ipw_write_59807 ipw_write 3 59807 NULL
110450 +scsi_init_shared_tag_map_59812 scsi_init_shared_tag_map 2 59812 NULL
110451 +ieee80211_if_read_dot11MeshHWMPmaxPREQretries_59829 ieee80211_if_read_dot11MeshHWMPmaxPREQretries 3 59829 NULL
110452 +gspca_dev_probe2_59833 gspca_dev_probe2 4 59833 NULL
110453 +fs64_to_cpu_59845 fs64_to_cpu 0 59845 NULL
110454 +regmap_raw_write_async_59849 regmap_raw_write_async 2-4 59849 NULL
110455 +intel_ring_wait_request_59865 intel_ring_wait_request 0 59865 NULL
110456 +pvr2_ioread_set_sync_key_59882 pvr2_ioread_set_sync_key 3 59882 NULL
110457 +shmem_zero_setup_59885 shmem_zero_setup 0 59885 NULL nohasharray
110458 +start_transaction_59885 start_transaction 2 59885 &shmem_zero_setup_59885
110459 +l2cap_sock_recvmsg_59886 l2cap_sock_recvmsg 4 59886 NULL
110460 +ffs_prepare_buffer_59892 ffs_prepare_buffer 2 59892 NULL
110461 +ocfs2_extend_rotate_transaction_59894 ocfs2_extend_rotate_transaction 0 59894 NULL
110462 +swiotlb_map_page_59909 swiotlb_map_page 3 59909 NULL
110463 +aic7xxx_abort_waiting_scb_59932 aic7xxx_abort_waiting_scb 0 59932 NULL
110464 +kvm_mmu_notifier_invalidate_range_start_59944 kvm_mmu_notifier_invalidate_range_start 3-4 59944 NULL
110465 +ocfs2_expand_inline_ref_root_59945 ocfs2_expand_inline_ref_root 0 59945 NULL
110466 +il_dbgfs_rxon_flags_read_59950 il_dbgfs_rxon_flags_read 3 59950 NULL nohasharray
110467 +dapm_widget_power_read_file_59950 dapm_widget_power_read_file 3 59950 &il_dbgfs_rxon_flags_read_59950
110468 +lookup_node_59953 lookup_node 2 59953 NULL
110469 +il_dbgfs_missed_beacon_read_59956 il_dbgfs_missed_beacon_read 3 59956 NULL
110470 +kvm_set_cr3_59965 kvm_set_cr3 2 59965 NULL
110471 +__arch_hweight16_59975 __arch_hweight16 0 59975 NULL
110472 +osd_req_read_kern_59990 osd_req_read_kern 5 59990 NULL
110473 +ghash_async_setkey_60001 ghash_async_setkey 3 60001 NULL
110474 +ieee80211_if_fmt_dot11MeshAwakeWindowDuration_60006 ieee80211_if_fmt_dot11MeshAwakeWindowDuration 3 60006 NULL
110475 +rawsock_sendmsg_60010 rawsock_sendmsg 4 60010 NULL
110476 +mthca_init_cq_60011 mthca_init_cq 2 60011 NULL
110477 +osd_req_list_dev_partitions_60027 osd_req_list_dev_partitions 4 60027 NULL
110478 +xlog_bread_offset_60030 xlog_bread_offset 3 60030 NULL
110479 +bio_integrity_hw_sectors_60039 bio_integrity_hw_sectors 0-2 60039 NULL
110480 +do_ip6t_set_ctl_60040 do_ip6t_set_ctl 4 60040 NULL
110481 +pin_2_irq_60050 pin_2_irq 0-3 60050 NULL nohasharray
110482 +vcs_size_60050 vcs_size 0 60050 &pin_2_irq_60050
110483 +gru_alloc_gts_60056 gru_alloc_gts 3-2 60056 NULL
110484 +open_cur_inode_file_60057 open_cur_inode_file 0 60057 NULL
110485 +compat_writev_60063 compat_writev 3 60063 NULL
110486 +ath6kl_listen_int_write_60066 ath6kl_listen_int_write 3 60066 NULL
110487 +c4iw_num_stags_60073 c4iw_num_stags 0 60073 NULL
110488 +mp_register_gsi_60079 mp_register_gsi 2 60079 NULL
110489 +rxrpc_kernel_send_data_60083 rxrpc_kernel_send_data 3 60083 NULL
110490 +ieee80211_if_fmt_fwded_frames_60103 ieee80211_if_fmt_fwded_frames 3 60103 NULL
110491 +SYSC_msgsnd_60113 SYSC_msgsnd 3 60113 NULL
110492 +nfs_idmap_request_key_60124 nfs_idmap_request_key 2 60124 NULL
110493 +__mutex_lock_common_60134 __mutex_lock_common 0 60134 NULL
110494 +ld_usb_read_60156 ld_usb_read 3 60156 NULL
110495 +jmb38x_ms_count_slots_60164 jmb38x_ms_count_slots 0 60164 NULL
110496 +init_state_60165 init_state 2 60165 NULL
110497 +sg_build_sgat_60179 sg_build_sgat 3 60179 NULL nohasharray
110498 +jffs2_alloc_full_dirent_60179 jffs2_alloc_full_dirent 1 60179 &sg_build_sgat_60179
110499 +fuse_async_req_send_60183 fuse_async_req_send 0-3 60183 NULL
110500 +rx_rx_tkip_replays_read_60193 rx_rx_tkip_replays_read 3 60193 NULL
110501 +qib_reg_phys_mr_60202 qib_reg_phys_mr 3 60202 NULL
110502 +btrfs_get_token_16_60220 btrfs_get_token_16 0 60220 NULL
110503 +arizona_map_irq_60230 arizona_map_irq 2 60230 NULL nohasharray
110504 +__phys_addr_nodebug_60230 __phys_addr_nodebug 0 60230 &arizona_map_irq_60230
110505 +wm831x_irq_60254 wm831x_irq 2 60254 NULL
110506 +irq_alloc_domain_generic_chips_60264 irq_alloc_domain_generic_chips 3-2 60264 NULL
110507 +printer_write_60276 printer_write 3 60276 NULL
110508 +alloc_irq_pin_list_60277 alloc_irq_pin_list 1 60277 NULL
110509 +do_xip_mapping_read_60297 do_xip_mapping_read 5 60297 NULL
110510 +getDataLength_60301 getDataLength 0 60301 NULL
110511 +xfs_next_bit_60322 xfs_next_bit 0-3 60322 NULL
110512 +inorder_to_tree_60331 inorder_to_tree 1-0 60331 NULL
110513 +usb_alphatrack_write_60341 usb_alphatrack_write 3 60341 NULL
110514 +__kfifo_from_user_r_60345 __kfifo_from_user_r 5-3 60345 NULL
110515 +max_unfragmented_pages_60362 max_unfragmented_pages 0 60362 NULL
110516 +dccp_setsockopt_60367 dccp_setsockopt 5 60367 NULL
110517 +ubi_eba_atomic_leb_change_60379 ubi_eba_atomic_leb_change 0-5 60379 NULL
110518 +instruction_pointer_60384 instruction_pointer 0 60384 NULL
110519 +drop_outstanding_extent_60390 drop_outstanding_extent 0 60390 NULL
110520 +mthca_alloc_resize_buf_60394 mthca_alloc_resize_buf 3 60394 NULL
110521 +ocfs2_zero_extend_60396 ocfs2_zero_extend 3 60396 NULL
110522 +driver_names_read_60399 driver_names_read 3 60399 NULL
110523 +paging32_walk_addr_generic_60415 paging32_walk_addr_generic 4 60415 NULL
110524 +simple_alloc_urb_60420 simple_alloc_urb 3 60420 NULL
110525 +excessive_retries_read_60425 excessive_retries_read 3 60425 NULL
110526 +tstats_write_60432 tstats_write 3 60432 NULL nohasharray
110527 +kmalloc_60432 kmalloc 1 60432 &tstats_write_60432
110528 +scaled_div32_60442 scaled_div32 2-1-0 60442 NULL
110529 +snd_hda_get_num_raw_conns_60462 snd_hda_get_num_raw_conns 0 60462 NULL
110530 +crypto_shash_setkey_60483 crypto_shash_setkey 3 60483 NULL
110531 +lustre_msg_early_size_60496 lustre_msg_early_size 0 60496 NULL
110532 +v9fs_fid_readn_60544 v9fs_fid_readn 4 60544 NULL
110533 +nonpaging_map_60551 nonpaging_map 4 60551 NULL
110534 +osc_lockless_truncate_seq_write_60553 osc_lockless_truncate_seq_write 3 60553 NULL
110535 +tracing_entries_write_60563 tracing_entries_write 3 60563 NULL
110536 +hash_net6_expire_60598 hash_net6_expire 3 60598 NULL
110537 +btrfs_add_delayed_tree_ref_60602 btrfs_add_delayed_tree_ref 0 60602 NULL
110538 +skb_transport_offset_60619 skb_transport_offset 0 60619 NULL
110539 +wl1273_fm_fops_write_60621 wl1273_fm_fops_write 3 60621 NULL
110540 +usb_control_msg_60624 usb_control_msg 0 60624 NULL
110541 +acl_alloc_stack_init_60630 acl_alloc_stack_init 1 60630 NULL
110542 +free_dind_blocks_60635 free_dind_blocks 0 60635 NULL
110543 +ubifs_recover_leb_60639 ubifs_recover_leb 3 60639 NULL
110544 +__proc_lnet_stats_60647 __proc_lnet_stats 5 60647 NULL
110545 +mv_ffc64_60648 mv_ffc64 1 60648 NULL
110546 +if_sdio_host_to_card_60666 if_sdio_host_to_card 4 60666 NULL
110547 +run_clustered_refs_60668 run_clustered_refs 0 60668 NULL
110548 +ieee80211_if_read_dot11MeshConfirmTimeout_60670 ieee80211_if_read_dot11MeshConfirmTimeout 3 60670 NULL
110549 +btrfs_reserve_extent_60674 btrfs_reserve_extent 5-0 60674 NULL
110550 +init_data_container_60709 init_data_container 1 60709 NULL
110551 +vga_rcrt_60731 vga_rcrt 0 60731 NULL
110552 +snd_ice1712_ds_read_60754 snd_ice1712_ds_read 0 60754 NULL
110553 +raid_status_60755 raid_status 5 60755 NULL
110554 +sel_write_checkreqprot_60774 sel_write_checkreqprot 3 60774 NULL
110555 +opticon_write_60775 opticon_write 4 60775 NULL
110556 +acl_alloc_num_60778 acl_alloc_num 1-2 60778 NULL
110557 +snd_pcm_oss_readv3_60792 snd_pcm_oss_readv3 3 60792 NULL
110558 +block_rsv_migrate_bytes_60843 block_rsv_migrate_bytes 0 60843 NULL
110559 +pwr_tx_with_ps_read_60851 pwr_tx_with_ps_read 3 60851 NULL
110560 +alloc_buf_60864 alloc_buf 2-3 60864 NULL
110561 +generic_writepages_60871 generic_writepages 0 60871 NULL
110562 +tipc_createport_60875 tipc_createport 4 60875 NULL
110563 +ubifs_read_one_lp_60882 ubifs_read_one_lp 0 60882 NULL
110564 +ext4_update_inline_data_60888 ext4_update_inline_data 3 60888 NULL
110565 +iio_debugfs_read_reg_60908 iio_debugfs_read_reg 3 60908 NULL
110566 +libcfs_sock_ioctl_60915 libcfs_sock_ioctl 0 60915 NULL
110567 +mgt_set_varlen_60916 mgt_set_varlen 4 60916 NULL
110568 +scrub_chunk_60926 scrub_chunk 5 60926 NULL
110569 +submit_extent_page_60928 submit_extent_page 5 60928 NULL
110570 +pti_char_write_60960 pti_char_write 3 60960 NULL
110571 +mwifiex_alloc_sdio_mpa_buffers_60961 mwifiex_alloc_sdio_mpa_buffers 3-2 60961 NULL
110572 +__a2mp_build_60987 __a2mp_build 3 60987 NULL
110573 +hsc_msg_alloc_60990 hsc_msg_alloc 1 60990 NULL
110574 +ath6kl_lrssi_roam_read_61022 ath6kl_lrssi_roam_read 3 61022 NULL
110575 +graph_depth_write_61024 graph_depth_write 3 61024 NULL
110576 +sdhci_pltfm_register_61031 sdhci_pltfm_register 3 61031 NULL
110577 +lpfc_idiag_queacc_write_61043 lpfc_idiag_queacc_write 3 61043 NULL
110578 +symtab_init_61050 symtab_init 2 61050 NULL
110579 +fuse_send_write_61053 fuse_send_write 0-4 61053 NULL
110580 +snd_pcm_pause_61054 snd_pcm_pause 0 61054 NULL
110581 +bitmap_scnlistprintf_61062 bitmap_scnlistprintf 0-4-2 61062 NULL
110582 +ahash_align_buffer_size_61070 ahash_align_buffer_size 0-1-2 61070 NULL
110583 +journal_stop_61080 journal_stop 0 61080 NULL
110584 +snd_pcm_update_hw_ptr0_61084 snd_pcm_update_hw_ptr0 0 61084 NULL
110585 +get_derived_key_61100 get_derived_key 4 61100 NULL
110586 +mem_cgroup_cache_charge_61101 mem_cgroup_cache_charge 0 61101 NULL
110587 +i40e_calculate_l2fpm_size_61104 i40e_calculate_l2fpm_size 0-1-2-3-4 61104 NULL
110588 +alloc_chrdev_region_61112 alloc_chrdev_region 0 61112 NULL
110589 +__probe_kernel_read_61119 __probe_kernel_read 3 61119 NULL
110590 +vmemmap_alloc_block_buf_61126 vmemmap_alloc_block_buf 1-2 61126 NULL
110591 +afs_proc_cells_write_61139 afs_proc_cells_write 3 61139 NULL
110592 +brcmf_sdio_chip_cr4_exitdl_61143 brcmf_sdio_chip_cr4_exitdl 4 61143 NULL
110593 +__vmalloc_61168 __vmalloc 1 61168 NULL
110594 +event_oom_late_read_61175 event_oom_late_read 3 61175 NULL nohasharray
110595 +pair_device_61175 pair_device 4 61175 &event_oom_late_read_61175
110596 +dio_bio_add_page_61178 dio_bio_add_page 0 61178 NULL
110597 +btrfs_reloc_post_snapshot_61189 btrfs_reloc_post_snapshot 0 61189 NULL
110598 +SyS_prctl_61202 SyS_prctl 4 61202 NULL
110599 +arch_hibernation_header_save_61212 arch_hibernation_header_save 0 61212 NULL
110600 +smk_read_ambient_61220 smk_read_ambient 3 61220 NULL
110601 +__verify_planes_array_61249 __verify_planes_array 0 61249 NULL
110602 +find_get_pages_tag_61270 find_get_pages_tag 0 61270 NULL nohasharray
110603 +ifalias_store_61270 ifalias_store 4 61270 &find_get_pages_tag_61270 nohasharray
110604 +btrfs_bio_alloc_61270 btrfs_bio_alloc 3 61270 &ifalias_store_61270
110605 +kick_a_thread_61273 kick_a_thread 0 61273 NULL
110606 +hfsplus_getxattr_finder_info_61283 hfsplus_getxattr_finder_info 0 61283 NULL nohasharray
110607 +vortex_adbdma_getlinearpos_61283 vortex_adbdma_getlinearpos 0 61283 &hfsplus_getxattr_finder_info_61283
110608 +nvme_trans_copy_to_user_61288 nvme_trans_copy_to_user 3 61288 NULL
110609 +ext4_issue_discard_61305 ext4_issue_discard 2 61305 NULL
110610 +xfer_from_user_61307 xfer_from_user 3 61307 NULL
110611 +ocfs2_get_sector_61309 ocfs2_get_sector 4 61309 NULL
110612 +timespec_to_ns_61317 timespec_to_ns 0 61317 NULL
110613 +xfrm_user_sec_ctx_size_61320 xfrm_user_sec_ctx_size 0 61320 NULL
110614 +C_SYSC_msgsnd_61330 C_SYSC_msgsnd 3 61330 NULL
110615 +write_file_spectral_short_repeat_61335 write_file_spectral_short_repeat 3 61335 NULL
110616 +__fls_61340 __fls 0 61340 NULL nohasharray
110617 +st5481_setup_isocpipes_61340 st5481_setup_isocpipes 6-4 61340 &__fls_61340
110618 +do_splice_direct_61341 do_splice_direct 5 61341 NULL nohasharray
110619 +rx_rx_wa_ba_not_expected_read_61341 rx_rx_wa_ba_not_expected_read 3 61341 &do_splice_direct_61341
110620 +__dm_get_reserved_ios_61342 __dm_get_reserved_ios 0-2-3 61342 NULL
110621 +f1x_map_sysaddr_to_csrow_61344 f1x_map_sysaddr_to_csrow 2 61344 NULL
110622 +kvm_apic_id_61363 kvm_apic_id 0 61363 NULL
110623 +debug_debug4_read_61367 debug_debug4_read 3 61367 NULL
110624 +get_inode_info_61387 get_inode_info 0 61387 NULL
110625 +system_enable_write_61396 system_enable_write 3 61396 NULL
110626 +size_entry_mwt_61400 size_entry_mwt 0 61400 NULL
110627 +xfs_zero_remaining_bytes_61423 xfs_zero_remaining_bytes 3 61423 NULL
110628 +i915_emit_box_61436 i915_emit_box 0 61436 NULL
110629 +dma_ops_area_alloc_61440 dma_ops_area_alloc 3-4-5-0 61440 NULL
110630 +tc3589x_irq_unmap_61447 tc3589x_irq_unmap 2 61447 NULL
110631 +unix_stream_sendmsg_61455 unix_stream_sendmsg 4 61455 NULL
110632 +snd_pcm_lib_writev_transfer_61483 snd_pcm_lib_writev_transfer 5-4-2 61483 NULL
110633 +btrfs_item_size_61485 btrfs_item_size 0 61485 NULL
110634 +ocfs2_get_refcount_rec_61514 ocfs2_get_refcount_rec 0 61514 NULL
110635 +__vmalloc_area_node_61525 __vmalloc_area_node 4 61525 NULL
110636 +erst_errno_61526 erst_errno 0 61526 NULL
110637 +ntfs_attr_lookup_61539 ntfs_attr_lookup 0 61539 NULL
110638 +get_ohm_of_thermistor_61545 get_ohm_of_thermistor 2 61545 NULL
110639 +trace_options_core_write_61551 trace_options_core_write 3 61551 NULL
110640 +o2hb_pop_count_61553 o2hb_pop_count 2 61553 NULL
110641 +dvb_net_ioctl_61559 dvb_net_ioctl 2 61559 NULL
110642 +alloc_pgtable_page_61562 alloc_pgtable_page 1 61562 NULL
110643 +parport_pc_fifo_write_block_dma_61568 parport_pc_fifo_write_block_dma 3 61568 NULL
110644 +fan_proc_write_61569 fan_proc_write 3 61569 NULL
110645 +ieee80211_if_read_rc_rateidx_mask_2ghz_61570 ieee80211_if_read_rc_rateidx_mask_2ghz 3 61570 NULL
110646 +ldlm_pool_rw_atomic_seq_write_61572 ldlm_pool_rw_atomic_seq_write 3 61572 NULL
110647 +seq_open_private_61589 seq_open_private 3 61589 NULL
110648 +ept_gpte_to_gfn_lvl_61591 ept_gpte_to_gfn_lvl 0-2-1 61591 NULL
110649 +netlink_recvmsg_61600 netlink_recvmsg 4 61600 NULL
110650 +nfs4_init_uniform_client_string_61601 nfs4_init_uniform_client_string 3 61601 NULL
110651 +configfs_write_file_61621 configfs_write_file 3 61621 NULL
110652 +ieee80211_if_fmt_hw_queues_61629 ieee80211_if_fmt_hw_queues 3 61629 NULL
110653 +i2o_parm_table_get_61635 i2o_parm_table_get 6 61635 NULL
110654 +snd_pcm_oss_read3_61643 snd_pcm_oss_read3 0-3 61643 NULL
110655 +resize_stripes_61650 resize_stripes 2 61650 NULL
110656 +ttm_page_pool_free_61661 ttm_page_pool_free 2-0 61661 NULL
110657 +insert_one_name_61668 insert_one_name 7 61668 NULL
110658 +snd_pcm_playback_avail_61671 snd_pcm_playback_avail 0 61671 NULL
110659 +qib_format_hwmsg_61679 qib_format_hwmsg 2 61679 NULL
110660 +lock_loop_61681 lock_loop 1 61681 NULL
110661 +__do_tune_cpucache_61684 __do_tune_cpucache 2 61684 NULL
110662 +filter_read_61692 filter_read 3 61692 NULL
110663 +prog_page_61711 prog_page 2 61711 NULL
110664 +iov_length_61716 iov_length 0 61716 NULL
110665 +fragmentation_threshold_read_61718 fragmentation_threshold_read 3 61718 NULL
110666 +null_alloc_reqbuf_61719 null_alloc_reqbuf 3 61719 NULL
110667 +read_file_interrupt_61742 read_file_interrupt 3 61742 NULL nohasharray
110668 +read_file_regval_61742 read_file_regval 3 61742 &read_file_interrupt_61742
110669 +SyS_sendto_61763 SyS_sendto 6 61763 NULL
110670 +gfs2_meta_wait_61773 gfs2_meta_wait 0 61773 NULL
110671 +num_counter_active_61789 num_counter_active 0 61789 NULL
110672 +mls_compute_context_len_61812 mls_compute_context_len 0 61812 NULL
110673 +tps80031_irq_init_61830 tps80031_irq_init 3 61830 NULL
110674 +bfad_debugfs_write_regwr_61841 bfad_debugfs_write_regwr 3 61841 NULL
110675 +regcache_sync_block_61846 regcache_sync_block 4-5 61846 NULL
110676 +fs_path_prepare_for_add_61854 fs_path_prepare_for_add 2-0 61854 NULL
110677 +evdev_compute_buffer_size_61863 evdev_compute_buffer_size 0 61863 NULL
110678 +SYSC_lsetxattr_61869 SYSC_lsetxattr 4 61869 NULL
110679 +get_fw_name_61874 get_fw_name 3 61874 NULL
110680 +twl4030_sih_setup_61878 twl4030_sih_setup 3-0 61878 NULL
110681 +btrfs_ioctl_clone_61886 btrfs_ioctl_clone 4-3-5 61886 NULL
110682 +lprocfs_write_frac_u64_helper_61897 lprocfs_write_frac_u64_helper 2 61897 NULL
110683 +lov_mds_md_stripecnt_61899 lov_mds_md_stripecnt 0-1 61899 NULL
110684 +clear_refs_write_61904 clear_refs_write 3 61904 NULL
110685 +rx_filter_arp_filter_read_61914 rx_filter_arp_filter_read 3 61914 NULL
110686 +au0828_init_isoc_61917 au0828_init_isoc 3-2-4 61917 NULL
110687 +sctp_sendmsg_61919 sctp_sendmsg 4 61919 NULL
110688 +ocfs2_reserve_new_metadata_blocks_61926 ocfs2_reserve_new_metadata_blocks 0 61926 NULL
110689 +SyS_kexec_load_61946 SyS_kexec_load 2 61946 NULL
110690 +gfn_to_pfn_memslot_atomic_61947 gfn_to_pfn_memslot_atomic 2 61947 NULL
110691 +il4965_ucode_rx_stats_read_61948 il4965_ucode_rx_stats_read 3 61948 NULL
110692 +squashfs_read_id_index_table_61961 squashfs_read_id_index_table 4 61961 NULL
110693 +fix_read_error_61965 fix_read_error 4 61965 NULL
110694 +mlx4_alloc_mtt_range_61966 mlx4_alloc_mtt_range 2 61966 NULL
110695 +ocfs2_quota_write_61972 ocfs2_quota_write 5-4 61972 NULL
110696 +fd_locked_ioctl_61978 fd_locked_ioctl 3 61978 NULL
110697 +cow_file_range_61979 cow_file_range 3 61979 NULL
110698 +module_alloc_exec_61991 module_alloc_exec 1 61991 NULL
110699 +dequeue_event_62000 dequeue_event 3 62000 NULL
110700 +xt_compat_match_offset_62011 xt_compat_match_offset 0 62011 NULL
110701 +SyS_setxattr_62019 SyS_setxattr 4 62019 NULL
110702 +jffs2_do_unlink_62020 jffs2_do_unlink 4 62020 NULL
110703 +SYSC_select_62024 SYSC_select 1 62024 NULL
110704 +pmcraid_build_passthrough_ioadls_62034 pmcraid_build_passthrough_ioadls 2 62034 NULL
110705 +sctp_user_addto_chunk_62047 sctp_user_addto_chunk 2-3 62047 NULL
110706 +do_pselect_62061 do_pselect 1 62061 NULL
110707 +pcpu_alloc_bootmem_62074 pcpu_alloc_bootmem 2 62074 NULL
110708 +get_domain_for_dev_62099 get_domain_for_dev 2 62099 NULL
110709 +ipath_user_sdma_pin_pages_62100 ipath_user_sdma_pin_pages 3-5-4 62100 NULL
110710 +jffs2_security_setxattr_62107 jffs2_security_setxattr 4 62107 NULL
110711 +btrfs_direct_IO_62114 btrfs_direct_IO 4 62114 NULL
110712 +ip_recv_error_62117 ip_recv_error 3 62117 NULL
110713 +generic_block_fiemap_62122 generic_block_fiemap 4 62122 NULL
110714 +llc_ui_header_len_62131 llc_ui_header_len 0 62131 NULL
110715 +qib_diag_write_62133 qib_diag_write 3 62133 NULL nohasharray
110716 +kobject_add_varg_62133 kobject_add_varg 0 62133 &qib_diag_write_62133
110717 +ql_status_62135 ql_status 5 62135 NULL nohasharray
110718 +device_add_attrs_62135 device_add_attrs 0 62135 &ql_status_62135
110719 +video_usercopy_62151 video_usercopy 2 62151 NULL
110720 +wrmWithLock_62164 wrmWithLock 0 62164 NULL
110721 +SyS_getxattr_62166 SyS_getxattr 4 62166 NULL
110722 +prism54_wpa_bss_ie_get_62173 prism54_wpa_bss_ie_get 0 62173 NULL
110723 +write_file_dfs_62180 write_file_dfs 3 62180 NULL
110724 +alloc_upcall_62186 alloc_upcall 2 62186 NULL
110725 +btrfs_xattr_acl_set_62203 btrfs_xattr_acl_set 4 62203 NULL
110726 +sock_kmalloc_62205 sock_kmalloc 2 62205 NULL
110727 +SYSC_setgroups16_62232 SYSC_setgroups16 1 62232 NULL
110728 +nfsd_read_file_62241 nfsd_read_file 6 62241 NULL
110729 +allocate_partition_62245 allocate_partition 4 62245 NULL
110730 +security_file_permission_62278 security_file_permission 0 62278 NULL
110731 +get_random_int_62279 get_random_int 0 62279 NULL
110732 +__qib_get_user_pages_62287 __qib_get_user_pages 1-2 62287 NULL
110733 +il_dbgfs_sram_read_62296 il_dbgfs_sram_read 3 62296 NULL
110734 +sparse_early_usemaps_alloc_pgdat_section_62304 sparse_early_usemaps_alloc_pgdat_section 2 62304 NULL
110735 +ocfs2_find_victim_alloc_group_62306 ocfs2_find_victim_alloc_group 0 62306 NULL
110736 +subsystem_filter_read_62310 subsystem_filter_read 3 62310 NULL
110737 +vmemmap_pgd_populate_62315 vmemmap_pgd_populate 2 62315 NULL
110738 +timespec_to_jiffies_62321 timespec_to_jiffies 0 62321 NULL
110739 +Wb35Reg_BurstWrite_62327 Wb35Reg_BurstWrite 4 62327 NULL
110740 +subseq_list_62332 subseq_list 3-0 62332 NULL
110741 +ll_statahead_max_seq_write_62333 ll_statahead_max_seq_write 3 62333 NULL
110742 +flash_write_62354 flash_write 3 62354 NULL
110743 +xfpregs_set_62363 xfpregs_set 4 62363 NULL
110744 +rx_rx_timeout_read_62389 rx_rx_timeout_read 3 62389 NULL
110745 +altera_irscan_62396 altera_irscan 2 62396 NULL
110746 +set_ssp_62411 set_ssp 4 62411 NULL
110747 +mlx4_en_create_rx_ring_62498 mlx4_en_create_rx_ring 3 62498 NULL
110748 +ext_rts51x_sd_execute_read_data_62501 ext_rts51x_sd_execute_read_data 9 62501 NULL
110749 +mtip_get_next_rr_node_62502 mtip_get_next_rr_node 0 62502 NULL
110750 +ocfs2_path_bh_journal_access_62504 ocfs2_path_bh_journal_access 0 62504 NULL
110751 +pep_sendmsg_62524 pep_sendmsg 4 62524 NULL
110752 +test_iso_queue_62534 test_iso_queue 5 62534 NULL nohasharray
110753 +__kmalloc_node_track_caller_62534 __kmalloc_node_track_caller 3 62534 &test_iso_queue_62534
110754 +debugfs_read_62535 debugfs_read 3 62535 NULL
110755 +sco_sock_sendmsg_62542 sco_sock_sendmsg 4 62542 NULL
110756 +qib_refresh_qsfp_cache_62547 qib_refresh_qsfp_cache 0 62547 NULL
110757 +xfrm_user_policy_62573 xfrm_user_policy 4 62573 NULL
110758 +get_subdir_62581 get_subdir 3 62581 NULL
110759 +nfsd_vfs_read_62605 nfsd_vfs_read 6 62605 NULL
110760 +get_desc_base_62617 get_desc_base 0 62617 NULL
110761 +iommu_area_alloc_62619 iommu_area_alloc 2-3-4-7-0 62619 NULL
110762 +vfs_fsync_range_62635 vfs_fsync_range 0 62635 NULL
110763 +lpfc_sli4_queue_alloc_62646 lpfc_sli4_queue_alloc 3 62646 NULL
110764 +write_62671 write 3 62671 NULL
110765 +ocfs2_wait_for_mask_interruptible_62675 ocfs2_wait_for_mask_interruptible 0 62675 NULL
110766 +printer_req_alloc_62687 printer_req_alloc 2 62687 NULL
110767 +ext4_ind_map_blocks_62690 ext4_ind_map_blocks 0 62690 NULL
110768 +htb_remove_class_from_row_62692 htb_remove_class_from_row 3 62692 NULL
110769 +qla4_83xx_rd_reg_62693 qla4_83xx_rd_reg 0 62693 NULL
110770 +bioset_integrity_create_62708 bioset_integrity_create 2 62708 NULL
110771 +gfs2_log_write_62717 gfs2_log_write 3 62717 NULL
110772 +rdm_62719 rdm 0 62719 NULL
110773 +obd_ioctl_popdata_62741 obd_ioctl_popdata 3 62741 NULL
110774 +key_replays_read_62746 key_replays_read 3 62746 NULL
110775 +lov_verify_lmm_62747 lov_verify_lmm 2 62747 NULL
110776 +mwifiex_rdeeprom_write_62754 mwifiex_rdeeprom_write 3 62754 NULL
110777 +ax25_sendmsg_62770 ax25_sendmsg 4 62770 NULL
110778 +page_key_alloc_62771 page_key_alloc 0 62771 NULL
110779 +C_SYSC_ipc_62776 C_SYSC_ipc 3 62776 NULL
110780 +SyS_sched_getaffinity_62786 SyS_sched_getaffinity 2 62786 NULL
110781 +dm_stats_account_io_62787 dm_stats_account_io 3 62787 NULL
110782 +posix_acl_valid_62788 posix_acl_valid 0 62788 NULL
110783 +is_first_ref_62805 is_first_ref 0 62805 NULL
110784 +tracing_total_entries_read_62817 tracing_total_entries_read 3 62817 NULL
110785 +name_cache_insert_62822 name_cache_insert 0 62822 NULL
110786 +BeceemEEPROMBulkRead_62835 BeceemEEPROMBulkRead 0 62835 NULL
110787 +__rounddown_pow_of_two_62836 __rounddown_pow_of_two 0 62836 NULL
110788 +bio_get_nr_vecs_62838 bio_get_nr_vecs 0 62838 NULL
110789 +xlog_recover_add_to_trans_62839 xlog_recover_add_to_trans 4 62839 NULL
110790 +rx_fcs_err_read_62844 rx_fcs_err_read 3 62844 NULL
110791 +set_swbp_62853 set_swbp 3 62853 NULL
110792 +read_nic_io_dword_62859 read_nic_io_dword 0 62859 NULL
110793 +l2tp_ip6_recvmsg_62874 l2tp_ip6_recvmsg 4 62874 NULL
110794 +aoechr_write_62883 aoechr_write 3 62883 NULL
110795 +if_spi_host_to_card_62890 if_spi_host_to_card 4 62890 NULL
110796 +ocfs2_validate_gd_parent_62905 ocfs2_validate_gd_parent 0 62905 NULL
110797 +mempool_create_slab_pool_62907 mempool_create_slab_pool 1 62907 NULL
110798 +getdqbuf_62908 getdqbuf 1 62908 NULL
110799 +try_async_pf_62914 try_async_pf 3 62914 NULL nohasharray
110800 +SyS_remap_file_pages_62914 SyS_remap_file_pages 1-2 62914 &try_async_pf_62914
110801 +ll_statahead_agl_seq_write_62928 ll_statahead_agl_seq_write 3 62928 NULL
110802 +atomic64_sub_return_62941 atomic64_sub_return 1 62941 NULL
110803 +agp_create_user_memory_62955 agp_create_user_memory 1 62955 NULL
110804 +send_write_62969 send_write 0-3 62969 NULL
110805 +__ext3_journal_stop_63017 __ext3_journal_stop 0 63017 NULL
110806 +alloc_mem_cgroup_per_zone_info_63024 alloc_mem_cgroup_per_zone_info 2 63024 NULL
110807 +kstrtoull_from_user_63026 kstrtoull_from_user 2 63026 NULL
110808 +PTR_ERR_63033 PTR_ERR 0 63033 NULL nohasharray
110809 +__vb2_perform_fileio_63033 __vb2_perform_fileio 3 63033 &PTR_ERR_63033
110810 +pipeline_defrag_to_csum_swi_read_63037 pipeline_defrag_to_csum_swi_read 3 63037 NULL
110811 +scsi_host_alloc_63041 scsi_host_alloc 2 63041 NULL
110812 +run_delayed_tree_ref_63042 run_delayed_tree_ref 0 63042 NULL
110813 +unlink1_63059 unlink1 3 63059 NULL
110814 +__do_munmap_63063 __do_munmap 0 63063 NULL
110815 +xen_set_nslabs_63066 xen_set_nslabs 0 63066 NULL
110816 +iwl_dbgfs_fw_rx_stats_read_63070 iwl_dbgfs_fw_rx_stats_read 3 63070 NULL
110817 +ocfs2_decrease_refcount_63078 ocfs2_decrease_refcount 4-3-0 63078 NULL
110818 +find_extent_in_eb_63082 find_extent_in_eb 0 63082 NULL
110819 +sep_prepare_input_output_dma_table_in_dcb_63087 sep_prepare_input_output_dma_table_in_dcb 4-5-3-2 63087 NULL
110820 +__ocfs2_flush_truncate_log_63097 __ocfs2_flush_truncate_log 0 63097 NULL
110821 +iwl_dbgfs_sensitivity_read_63116 iwl_dbgfs_sensitivity_read 3 63116 NULL
110822 +ext4_chunk_trans_blocks_63123 ext4_chunk_trans_blocks 0-2 63123 NULL
110823 +alloc_cblock_63133 alloc_cblock 2 63133 NULL
110824 +snd_pcm_status_user_63140 snd_pcm_status_user 0 63140 NULL
110825 +ubifs_change_one_lp_63157 ubifs_change_one_lp 0 63157 NULL
110826 +smk_write_revoke_subj_63173 smk_write_revoke_subj 3 63173 NULL
110827 +SyS_syslog_63178 SyS_syslog 3 63178 NULL
110828 +security_policydb_len_63198 security_policydb_len 0 63198 NULL
110829 +vme_master_read_63221 vme_master_read 0 63221 NULL
110830 +SyS_gethostname_63227 SyS_gethostname 2 63227 NULL
110831 +module_alloc_update_bounds_rw_63233 module_alloc_update_bounds_rw 1 63233 NULL
110832 +ptp_read_63251 ptp_read 4 63251 NULL
110833 +xfs_dir2_leaf_getdents_63262 xfs_dir2_leaf_getdents 3 63262 NULL
110834 +ntfs_attr_can_be_non_resident_63267 ntfs_attr_can_be_non_resident 0 63267 NULL
110835 +raid5_resize_63306 raid5_resize 2 63306 NULL
110836 +proc_info_read_63344 proc_info_read 3 63344 NULL
110837 +ps_upsd_max_sptime_read_63362 ps_upsd_max_sptime_read 3 63362 NULL
110838 +idmouse_read_63374 idmouse_read 3 63374 NULL
110839 +edac_pci_alloc_ctl_info_63388 edac_pci_alloc_ctl_info 1 63388 NULL nohasharray
110840 +usbnet_read_cmd_nopm_63388 usbnet_read_cmd_nopm 7 63388 &edac_pci_alloc_ctl_info_63388
110841 +rxpipe_missed_beacon_host_int_trig_rx_data_read_63405 rxpipe_missed_beacon_host_int_trig_rx_data_read 3 63405 NULL
110842 +nouveau_event_create_63411 nouveau_event_create 1 63411 NULL
110843 +l2cap_sock_sendmsg_63427 l2cap_sock_sendmsg 4 63427 NULL
110844 +sep_prepare_input_output_dma_table_63429 sep_prepare_input_output_dma_table 3-4-2 63429 NULL
110845 +gfn_to_hva_many_63437 gfn_to_hva_many 2-0 63437 NULL
110846 +nfsd_symlink_63442 nfsd_symlink 6 63442 NULL
110847 +lookup_dir_item_inode_63447 lookup_dir_item_inode 0 63447 NULL
110848 +i915_gem_object_get_fence_63455 i915_gem_object_get_fence 0 63455 NULL
110849 +__do_kmalloc_node_63461 __do_kmalloc_node 3 63461 NULL
110850 +si5351_bulk_write_63468 si5351_bulk_write 2-3 63468 NULL
110851 +snd_info_entry_write_63474 snd_info_entry_write 3 63474 NULL
110852 +do_work_63483 do_work 0 63483 NULL
110853 +reada_find_extent_63486 reada_find_extent 2 63486 NULL
110854 +__copy_from_user_ll_nocache_63487 __copy_from_user_ll_nocache 0-3 63487 NULL
110855 +read_kcore_63488 read_kcore 3 63488 NULL nohasharray
110856 +alloc_reserved_tree_block_63488 alloc_reserved_tree_block 0 63488 &read_kcore_63488
110857 +save_hint_63497 save_hint 2 63497 NULL
110858 +wl1271_tx_min_rate_get_63498 wl1271_tx_min_rate_get 2 63498 NULL
110859 +sis_voice_irq_63501 sis_voice_irq 1 63501 NULL
110860 +snd_pcm_plug_write_transfer_63503 snd_pcm_plug_write_transfer 0-3 63503 NULL
110861 +efx_mcdi_rpc_async_63529 efx_mcdi_rpc_async 5-4 63529 NULL
110862 +ubi_more_leb_change_data_63534 ubi_more_leb_change_data 4-0 63534 NULL
110863 +write_file_spectral_period_63536 write_file_spectral_period 3 63536 NULL
110864 +if_sdio_read_scratch_63540 if_sdio_read_scratch 0 63540 NULL
110865 +append_to_buffer_63550 append_to_buffer 3 63550 NULL
110866 +dbg_leb_write_63555 dbg_leb_write 4-5 63555 NULL nohasharray
110867 +kvm_write_guest_page_63555 kvm_write_guest_page 2-5 63555 &dbg_leb_write_63555
110868 +ubifs_lpt_scan_nolock_63572 ubifs_lpt_scan_nolock 0 63572 NULL
110869 +iwch_reg_user_mr_63575 iwch_reg_user_mr 2-3 63575 NULL
110870 +ocfs2_calc_trunc_pos_63576 ocfs2_calc_trunc_pos 4 63576 NULL
110871 +rproc_alloc_63577 rproc_alloc 5 63577 NULL
110872 +ext3_clear_blocks_63597 ext3_clear_blocks 4-5 63597 NULL
110873 +write_debug_level_63613 write_debug_level 3 63613 NULL
110874 +module_alloc_63630 module_alloc 1 63630 NULL
110875 +ntfs_malloc_nofs_nofail_63631 ntfs_malloc_nofs_nofail 1 63631 NULL
110876 +symbol_build_supp_rates_63634 symbol_build_supp_rates 0 63634 NULL
110877 +_ubh_find_next_zero_bit__63640 _ubh_find_next_zero_bit_ 3-5-4 63640 NULL
110878 +ext4_ext_get_access_63642 ext4_ext_get_access 0 63642 NULL
110879 +proc_loginuid_write_63648 proc_loginuid_write 3 63648 NULL
110880 +ValidateDSDParamsChecksum_63654 ValidateDSDParamsChecksum 3 63654 NULL
110881 +ldlm_cli_enqueue_63657 ldlm_cli_enqueue 8 63657 NULL
110882 +hidraw_ioctl_63658 hidraw_ioctl 2 63658 NULL
110883 +vbi_read_63673 vbi_read 3 63673 NULL nohasharray
110884 +xen_register_pirq_63673 xen_register_pirq 1-2 63673 &vbi_read_63673
110885 +write_file_spectral_fft_period_63696 write_file_spectral_fft_period 3 63696 NULL
110886 +bin_search_63697 bin_search 0 63697 NULL
110887 +arizona_irq_map_63709 arizona_irq_map 2 63709 NULL
110888 +ocfs2_et_root_journal_access_63713 ocfs2_et_root_journal_access 0 63713 NULL
110889 +nouveau_object_create__63715 nouveau_object_create_ 5 63715 NULL
110890 +btrfs_insert_delayed_dir_index_63720 btrfs_insert_delayed_dir_index 4-0 63720 NULL
110891 +selinux_secctx_to_secid_63744 selinux_secctx_to_secid 2 63744 NULL
110892 +snd_pcm_oss_read1_63771 snd_pcm_oss_read1 3 63771 NULL
110893 +snd_pcm_link_63772 snd_pcm_link 0 63772 NULL
110894 +snd_opl4_mem_proc_read_63774 snd_opl4_mem_proc_read 5 63774 NULL
110895 +spidev_compat_ioctl_63778 spidev_compat_ioctl 2 63778 NULL
110896 +mwifiex_11n_create_rx_reorder_tbl_63806 mwifiex_11n_create_rx_reorder_tbl 4 63806 NULL
110897 +copy_nodes_to_user_63807 copy_nodes_to_user 2 63807 NULL
110898 +prepare_copy_63826 prepare_copy 2 63826 NULL
110899 +sel_write_load_63830 sel_write_load 3 63830 NULL
110900 +ll_readlink_63836 ll_readlink 3 63836 NULL
110901 +IsSectionWritable_63842 IsSectionWritable 0 63842 NULL
110902 +proc_pid_attr_write_63845 proc_pid_attr_write 3 63845 NULL
110903 +divas_write_63901 divas_write 3 63901 NULL
110904 +IsOffsetWritable_63902 IsOffsetWritable 0 63902 NULL nohasharray
110905 +xhci_alloc_stream_info_63902 xhci_alloc_stream_info 3 63902 &IsOffsetWritable_63902
110906 +uvc_alloc_urb_buffers_63922 uvc_alloc_urb_buffers 0-2-3 63922 NULL
110907 +snd_compr_write_63923 snd_compr_write 3 63923 NULL
110908 +acpi_ev_get_gpe_xrupt_block_63924 acpi_ev_get_gpe_xrupt_block 1 63924 NULL
110909 +tipc_send2port_63935 tipc_send2port 5 63935 NULL
110910 +afs_send_simple_reply_63940 afs_send_simple_reply 3 63940 NULL
110911 +__team_options_register_63941 __team_options_register 3 63941 NULL
110912 +macvtap_recvmsg_63949 macvtap_recvmsg 4 63949 NULL
110913 +generic_acl_init_63955 generic_acl_init 0 63955 NULL
110914 +domain_pfn_mapping_63957 domain_pfn_mapping 4 63957 NULL
110915 +diva_xdi_write_63975 diva_xdi_write 4 63975 NULL
110916 +rs_extent_to_bm_page_63996 rs_extent_to_bm_page 0-1 63996 NULL
110917 +read_file_frameerrors_64001 read_file_frameerrors 3 64001 NULL
110918 +hfsplus_security_setxattr_64009 hfsplus_security_setxattr 4 64009 NULL
110919 +C_SYSC_sendfile64_64017 C_SYSC_sendfile64 4 64017 NULL
110920 +SyS_rt_sigpending_64018 SyS_rt_sigpending 2 64018 NULL
110921 +offset_to_vaddr_64025 offset_to_vaddr 0-2 64025 NULL
110922 +dbAllocDmapLev_64030 dbAllocDmapLev 0 64030 NULL
110923 +resize_async_buffer_64031 resize_async_buffer 4 64031 NULL
110924 +SyS_fsetxattr_64039 SyS_fsetxattr 4 64039 NULL
110925 +tfrc_calc_x_reverse_lookup_64057 tfrc_calc_x_reverse_lookup 0 64057 NULL
110926 +__sock_create_64069 __sock_create 0 64069 NULL
110927 +get_u8_64076 get_u8 0 64076 NULL
110928 +xilly_malloc_64077 xilly_malloc 2 64077 NULL
110929 +btrfs_copy_root_64079 btrfs_copy_root 0 64079 NULL
110930 +sl_realloc_bufs_64086 sl_realloc_bufs 2 64086 NULL
110931 +clear_update_marker_64088 clear_update_marker 0 64088 NULL nohasharray
110932 +vmci_handle_arr_get_size_64088 vmci_handle_arr_get_size 0 64088 &clear_update_marker_64088
110933 +lbs_highrssi_read_64089 lbs_highrssi_read 3 64089 NULL
110934 +SyS_set_mempolicy_64096 SyS_set_mempolicy 3 64096 NULL
110935 +SyS_mq_timedsend_64107 SyS_mq_timedsend 3 64107 NULL
110936 +rdma_addr_size_64116 rdma_addr_size 0 64116 NULL
110937 +do_load_xattr_datum_64118 do_load_xattr_datum 0 64118 NULL
110938 +bypass_wd_write_64120 bypass_wd_write 3 64120 NULL
110939 +ol_quota_entries_per_block_64122 ol_quota_entries_per_block 0 64122 NULL
110940 +ext4_prepare_inline_data_64124 ext4_prepare_inline_data 3 64124 NULL
110941 +init_bch_64130 init_bch 2-1 64130 NULL
110942 +SYSC_ptrace_64136 SYSC_ptrace 3 64136 NULL
110943 +ablkcipher_copy_iv_64140 ablkcipher_copy_iv 3 64140 NULL
110944 +dlfb_ops_write_64150 dlfb_ops_write 3 64150 NULL
110945 +__comedi_buf_alloc_64155 __comedi_buf_alloc 3 64155 NULL
110946 +cpumask_scnprintf_64170 cpumask_scnprintf 0-2 64170 NULL
110947 +ocfs2_reserve_blocks_for_rec_trunc_64206 ocfs2_reserve_blocks_for_rec_trunc 0 64206 NULL
110948 +xfs_vm_direct_IO_64223 xfs_vm_direct_IO 4 64223 NULL
110949 +read_pulse_64227 read_pulse 0-3 64227 NULL
110950 +ea_len_64229 ea_len 0 64229 NULL
110951 +btrfs_make_block_group_64241 btrfs_make_block_group 0 64241 NULL
110952 +__btrfs_update_delayed_inode_64248 __btrfs_update_delayed_inode 0 64248 NULL
110953 +io_capture_transfer_64276 io_capture_transfer 4 64276 NULL
110954 +btrfs_file_extent_offset_64278 btrfs_file_extent_offset 0 64278 NULL
110955 +btrfs_next_item_64285 btrfs_next_item 0 64285 NULL
110956 +sta_current_tx_rate_read_64286 sta_current_tx_rate_read 3 64286 NULL
110957 +event_id_read_64288 event_id_read 3 64288 NULL nohasharray
110958 +xfs_dir_cilookup_result_64288 xfs_dir_cilookup_result 3 64288 &event_id_read_64288
110959 +ocfs2_block_check_validate_bhs_64302 ocfs2_block_check_validate_bhs 0 64302 NULL
110960 +snd_hda_get_sub_nodes_64304 snd_hda_get_sub_nodes 0 64304 NULL
110961 +error_error_bar_retry_read_64305 error_error_bar_retry_read 3 64305 NULL
110962 +ffz_64324 ffz 0-1 64324 NULL
110963 +map_region_64328 map_region 1 64328 NULL
110964 +sisusbcon_clear_64329 sisusbcon_clear 4-3-5 64329 NULL
110965 +ts_write_64336 ts_write 3 64336 NULL
110966 +usbtmc_write_64340 usbtmc_write 3 64340 NULL
110967 +do_write_orph_node_64343 do_write_orph_node 2 64343 NULL
110968 +ft1000_read_reg_64352 ft1000_read_reg 0 64352 NULL
110969 +bnx2x_vfop_mcast_cmd_64354 bnx2x_vfop_mcast_cmd 5 64354 NULL
110970 +user_regset_copyin_64360 user_regset_copyin 7 64360 NULL
110971 +wlc_phy_loadsampletable_nphy_64367 wlc_phy_loadsampletable_nphy 3 64367 NULL
110972 +reg_create_64372 reg_create 5 64372 NULL
110973 +ilo_write_64378 ilo_write 3 64378 NULL
110974 +btrfs_map_block_64379 btrfs_map_block 3 64379 NULL
110975 +vmcs_readl_64381 vmcs_readl 0 64381 NULL
110976 +nilfs_alloc_seg_bio_64383 nilfs_alloc_seg_bio 3 64383 NULL
110977 +ir_lirc_transmit_ir_64403 ir_lirc_transmit_ir 3 64403 NULL
110978 +pidlist_allocate_64404 pidlist_allocate 1 64404 NULL
110979 +rx_hdr_overflow_read_64407 rx_hdr_overflow_read 3 64407 NULL
110980 +snd_card_create_64418 snd_card_create 4 64418 NULL nohasharray
110981 +keyctl_get_security_64418 keyctl_get_security 3 64418 &snd_card_create_64418
110982 +nl80211_send_mgmt_64419 nl80211_send_mgmt 7 64419 NULL
110983 +oom_adj_write_64428 oom_adj_write 3 64428 NULL
110984 +ext4_trim_extent_64431 ext4_trim_extent 4 64431 NULL nohasharray
110985 +read_file_spectral_short_repeat_64431 read_file_spectral_short_repeat 3 64431 &ext4_trim_extent_64431
110986 +ax25_recvmsg_64441 ax25_recvmsg 4 64441 NULL
110987 +single_open_size_64483 single_open_size 4 64483 NULL
110988 +p54_parse_rssical_64493 p54_parse_rssical 3 64493 NULL
110989 +msg_data_sz_64503 msg_data_sz 0 64503 NULL
110990 +remove_uuid_64505 remove_uuid 4 64505 NULL nohasharray
110991 +handle_abnormal_pfn_64505 handle_abnormal_pfn 3 64505 &remove_uuid_64505
110992 +crypto_blkcipher_alignmask_64520 crypto_blkcipher_alignmask 0 64520 NULL
110993 +opera1_usb_i2c_msgxfer_64521 opera1_usb_i2c_msgxfer 4 64521 NULL
110994 +iwl_dbgfs_ucode_tracing_write_64524 iwl_dbgfs_ucode_tracing_write 3 64524 NULL
110995 +ses_send_diag_64527 ses_send_diag 4 64527 NULL
110996 +prctl_set_mm_64538 prctl_set_mm 3 64538 NULL
110997 +SyS_bind_64544 SyS_bind 3 64544 NULL
110998 +rbd_obj_read_sync_64554 rbd_obj_read_sync 4-3 64554 NULL
110999 +__btrfs_prealloc_file_range_64557 __btrfs_prealloc_file_range 3-0 64557 NULL
111000 +__spi_sync_64561 __spi_sync 0 64561 NULL nohasharray
111001 +ll_max_rw_chunk_seq_write_64561 ll_max_rw_chunk_seq_write 3 64561 &__spi_sync_64561
111002 +__apei_exec_run_64563 __apei_exec_run 0 64563 NULL
111003 +kstrtoul_from_user_64569 kstrtoul_from_user 2 64569 NULL
111004 +do_erase_64574 do_erase 4 64574 NULL
111005 +fanotify_write_64623 fanotify_write 3 64623 NULL
111006 +ocfs2_remove_refcount_extent_64631 ocfs2_remove_refcount_extent 0 64631 NULL
111007 +to_dblock_64655 to_dblock 0-1 64655 NULL
111008 +regmap_read_debugfs_64658 regmap_read_debugfs 5 64658 NULL
111009 +ocfs2_read_xattr_block_64661 ocfs2_read_xattr_block 0 64661 NULL nohasharray
111010 +tlbflush_read_file_64661 tlbflush_read_file 3 64661 &ocfs2_read_xattr_block_64661 nohasharray
111011 +pool_create_64661 pool_create 3 64661 &tlbflush_read_file_64661
111012 +efx_tsoh_get_buffer_64664 efx_tsoh_get_buffer 3 64664 NULL
111013 +rx_rx_out_of_mpdu_nodes_read_64668 rx_rx_out_of_mpdu_nodes_read 3 64668 NULL
111014 +nr_free_zone_pages_64680 nr_free_zone_pages 0 64680 NULL
111015 +sec_bulk_write_64691 sec_bulk_write 2-3 64691 NULL nohasharray
111016 +mremap_to_64691 mremap_to 0-3 64691 &sec_bulk_write_64691
111017 +pfn_to_hpa_64703 pfn_to_hpa 0-1 64703 NULL
111018 +ip_select_ident_more_64707 ip_select_ident_more 4 64707 NULL
111019 +snd_pcm_oss_capture_position_fixup_64713 snd_pcm_oss_capture_position_fixup 0 64713 NULL
111020 +dapm_bias_read_file_64715 dapm_bias_read_file 3 64715 NULL
111021 +atomic_add_return_64720 atomic_add_return 0-1 64720 NULL
111022 +i2400m_msg_to_dev_64722 i2400m_msg_to_dev 3 64722 NULL
111023 +AscGetChipVersion_64737 AscGetChipVersion 0 64737 NULL
111024 +squashfs_read_inode_lookup_table_64739 squashfs_read_inode_lookup_table 4 64739 NULL
111025 +perf_swevent_event_64745 perf_swevent_event 2 64745 NULL
111026 +bio_map_kern_64751 bio_map_kern 3 64751 NULL
111027 +rt2x00debug_write_csr_64753 rt2x00debug_write_csr 3 64753 NULL
111028 +message_for_md_64777 message_for_md 5 64777 NULL
111029 +isr_low_rssi_read_64789 isr_low_rssi_read 3 64789 NULL
111030 +regmap_reg_ranges_read_file_64798 regmap_reg_ranges_read_file 3 64798 NULL
111031 +nfsctl_transaction_write_64800 nfsctl_transaction_write 3 64800 NULL
111032 +rfkill_fop_write_64808 rfkill_fop_write 3 64808 NULL
111033 +proc_projid_map_write_64810 proc_projid_map_write 3 64810 NULL
111034 +megaraid_change_queue_depth_64815 megaraid_change_queue_depth 2 64815 NULL
111035 +ecryptfs_send_miscdev_64816 ecryptfs_send_miscdev 2 64816 NULL
111036 +vaddr_get_pfn_64818 vaddr_get_pfn 1 64818 NULL
111037 +gfn_to_page_64826 gfn_to_page 2 64826 NULL
111038 +do_kimage_alloc_64827 do_kimage_alloc 3 64827 NULL
111039 +altera_set_dr_pre_64862 altera_set_dr_pre 2 64862 NULL
111040 +gfn_to_pfn_64870 gfn_to_pfn 2 64870 NULL
111041 +lprocfs_write_u64_helper_64880 lprocfs_write_u64_helper 2 64880 NULL
111042 +ffs_epfile_io_64886 ffs_epfile_io 3 64886 NULL
111043 +mk_pid_64894 mk_pid 0-3 64894 NULL
111044 +ieee80211_if_read_ave_beacon_64924 ieee80211_if_read_ave_beacon 3 64924 NULL
111045 +usb_reset_and_verify_device_64933 usb_reset_and_verify_device 0 64933 NULL
111046 +ubifs_wbuf_write_nolock_64946 ubifs_wbuf_write_nolock 3 64946 NULL
111047 +ip_options_get_from_user_64958 ip_options_get_from_user 4 64958 NULL
111048 +acpi_os_install_interrupt_handler_64968 acpi_os_install_interrupt_handler 1 64968 NULL
111049 +traceprobe_probes_write_64969 traceprobe_probes_write 3 64969 NULL
111050 +suspend_dtim_interval_read_64971 suspend_dtim_interval_read 3 64971 NULL
111051 +ext2_group_first_block_no_64972 ext2_group_first_block_no 0-2 64972 NULL
111052 +crypto_ahash_digestsize_65014 crypto_ahash_digestsize 0 65014 NULL
111053 +insert_dent_65034 insert_dent 7 65034 NULL
111054 +snd_hda_get_pin_label_65035 snd_hda_get_pin_label 5 65035 NULL
111055 +ext4_ind_trans_blocks_65053 ext4_ind_trans_blocks 0-2 65053 NULL
111056 +pcibios_enable_device_65059 pcibios_enable_device 0 65059 NULL
111057 +make_idx_node_65068 make_idx_node 0 65068 NULL
111058 +count_run_65072 count_run 0-2-4-5 65072 NULL
111059 +__alloc_bootmem_node_high_65076 __alloc_bootmem_node_high 2 65076 NULL
111060 +ocfs2_truncate_cluster_pages_65086 ocfs2_truncate_cluster_pages 2 65086 NULL
111061 +send_create_inode_65090 send_create_inode 0 65090 NULL nohasharray
111062 +ath9k_dump_mci_btcoex_65090 ath9k_dump_mci_btcoex 0 65090 &send_create_inode_65090
111063 +uasp_alloc_cmd_65097 uasp_alloc_cmd 0 65097 NULL
111064 +__ext3_journal_dirty_metadata_65103 __ext3_journal_dirty_metadata 0 65103 NULL
111065 +generic_ocp_write_65107 generic_ocp_write 4 65107 NULL
111066 +kswapd_shrink_zone_65174 kswapd_shrink_zone 4 65174 NULL
111067 +i2c_smbus_xfer_emulated_65183 i2c_smbus_xfer_emulated 0 65183 NULL
111068 +btrfs_run_delayed_items_nr_65204 btrfs_run_delayed_items_nr 0 65204 NULL
111069 +rx_rx_done_read_65217 rx_rx_done_read 3 65217 NULL
111070 +print_endpoint_stat_65232 print_endpoint_stat 3-4-0 65232 NULL
111071 +journal_get_write_access_65243 journal_get_write_access 0 65243 NULL
111072 +whci_n_caps_65247 whci_n_caps 0 65247 NULL
111073 +kmem_zalloc_greedy_65268 kmem_zalloc_greedy 3-2 65268 NULL
111074 +kmalloc_parameter_65279 kmalloc_parameter 1 65279 NULL
111075 +compat_core_sys_select_65285 compat_core_sys_select 1 65285 NULL
111076 +get_unaligned_le16_65293 get_unaligned_le16 0 65293 NULL
111077 +mpi_set_buffer_65294 mpi_set_buffer 3 65294 NULL
111078 +redirected_tty_write_65297 redirected_tty_write 3 65297 NULL
111079 +get_var_len_65304 get_var_len 0 65304 NULL
111080 +unpack_array_65318 unpack_array 0 65318 NULL
111081 +pci_vpd_find_tag_65325 pci_vpd_find_tag 0-2 65325 NULL
111082 +dccp_setsockopt_service_65336 dccp_setsockopt_service 4 65336 NULL
111083 +init_list_set_65351 init_list_set 3-2 65351 NULL
111084 +dma_rx_requested_read_65354 dma_rx_requested_read 3 65354 NULL
111085 +batadv_tt_save_orig_buffer_65361 batadv_tt_save_orig_buffer 4 65361 NULL
111086 +alloc_cpu_rmap_65363 alloc_cpu_rmap 1 65363 NULL
111087 +__ext4_new_inode_65370 __ext4_new_inode 5 65370 NULL
111088 +SyS_writev_65372 SyS_writev 3 65372 NULL
111089 +mi_set_context_65395 mi_set_context 0 65395 NULL
111090 +__alloc_bootmem_nopanic_65397 __alloc_bootmem_nopanic 1 65397 NULL
111091 +trace_seq_to_user_65398 trace_seq_to_user 3 65398 NULL
111092 +mtd_get_device_size_65400 mtd_get_device_size 0 65400 NULL
111093 +__read_vmcore_65402 __read_vmcore 2 65402 NULL
111094 +usb_ep_enable_65405 usb_ep_enable 0 65405 NULL
111095 +ocfs2_write_begin_nolock_65410 ocfs2_write_begin_nolock 4-3 65410 NULL
111096 +drm_calloc_large_65421 drm_calloc_large 2-1 65421 NULL
111097 +device_add_groups_65423 device_add_groups 0 65423 NULL
111098 +xpc_kzalloc_cacheline_aligned_65433 xpc_kzalloc_cacheline_aligned 1 65433 NULL
111099 +vmalloc_to_pfn_65437 vmalloc_to_pfn 0 65437 NULL
111100 +usb_alloc_coherent_65444 usb_alloc_coherent 2 65444 NULL
111101 +il_dbgfs_wd_timeout_write_65464 il_dbgfs_wd_timeout_write 3 65464 NULL
111102 +ext4_es_zeroout_65465 ext4_es_zeroout 0 65465 NULL
111103 +clear_user_65470 clear_user 2 65470 NULL
111104 +__pcibus_to_node_65489 __pcibus_to_node 0 65489 NULL nohasharray
111105 +dpcm_state_read_file_65489 dpcm_state_read_file 3 65489 &__pcibus_to_node_65489
111106 +lookup_inline_extent_backref_65493 lookup_inline_extent_backref 9-0 65493 NULL
111107 +qib_create_ctxtdata_65497 qib_create_ctxtdata 3 65497 NULL
111108 +nvme_trans_standard_inquiry_page_65526 nvme_trans_standard_inquiry_page 4 65526 NULL
111109 diff --git a/tools/gcc/size_overflow_plugin.c b/tools/gcc/size_overflow_plugin.c
111110 new file mode 100644
111111 index 0000000..50f8464
111112 --- /dev/null
111113 +++ b/tools/gcc/size_overflow_plugin.c
111114 @@ -0,0 +1,4072 @@
111115 +/*
111116 + * Copyright 2011, 2012, 2013, 2014 by Emese Revfy <re.emese@gmail.com>
111117 + * Licensed under the GPL v2, or (at your option) v3
111118 + *
111119 + * Homepage:
111120 + * http://www.grsecurity.net/~ephox/overflow_plugin/
111121 + *
111122 + * Documentation:
111123 + * http://forums.grsecurity.net/viewtopic.php?f=7&t=3043
111124 + *
111125 + * This plugin recomputes expressions of function arguments marked by a size_overflow attribute
111126 + * with double integer precision (DImode/TImode for 32/64 bit integer types).
111127 + * The recomputed argument is checked against TYPE_MAX and an event is logged on overflow and the triggering process is killed.
111128 + *
111129 + * Usage:
111130 + * $ 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
111131 + * $ gcc -fplugin=size_overflow_plugin.so test.c -O2
111132 + */
111133 +
111134 +#include "gcc-plugin.h"
111135 +#include "config.h"
111136 +#include "system.h"
111137 +#include "coretypes.h"
111138 +#include "tree.h"
111139 +#include "tree-pass.h"
111140 +#include "intl.h"
111141 +#include "plugin-version.h"
111142 +#include "tm.h"
111143 +#include "toplev.h"
111144 +#include "function.h"
111145 +#include "tree-flow.h"
111146 +#include "plugin.h"
111147 +#include "gimple.h"
111148 +#include "diagnostic.h"
111149 +#include "cfgloop.h"
111150 +
111151 +#if BUILDING_GCC_VERSION >= 4008
111152 +#define TODO_dump_func 0
111153 +#define TODO_dump_cgraph 0
111154 +#endif
111155 +
111156 +#define __unused __attribute__((__unused__))
111157 +#define ASM_NAME(node) IDENTIFIER_POINTER(DECL_ASSEMBLER_NAME(node))
111158 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
111159 +#define NAME_LEN(node) IDENTIFIER_LENGTH(DECL_NAME(node))
111160 +#define BEFORE_STMT true
111161 +#define AFTER_STMT false
111162 +#define CREATE_NEW_VAR NULL_TREE
111163 +#define CODES_LIMIT 32
111164 +#define MAX_PARAM 31
111165 +#define VEC_LEN 128
111166 +#define MY_STMT GF_PLF_1
111167 +#define NO_CAST_CHECK GF_PLF_2
111168 +#define RET_CHECK NULL_TREE
111169 +#define CANNOT_FIND_ARG 32
111170 +#define WRONG_NODE 32
111171 +#define NOT_INTENTIONAL_ASM NULL
111172 +#define MIN_CHECK true
111173 +#define MAX_CHECK false
111174 +
111175 +#define TURN_OFF_ASM_STR "# size_overflow MARK_TURN_OFF "
111176 +#define YES_ASM_STR "# size_overflow MARK_YES "
111177 +#define OK_ASM_STR "# size_overflow "
111178 +
111179 +#if BUILDING_GCC_VERSION == 4005
111180 +#define DECL_CHAIN(NODE) (TREE_CHAIN(DECL_MINIMAL_CHECK(NODE)))
111181 +#endif
111182 +
111183 +struct size_overflow_hash {
111184 + const struct size_overflow_hash * const next;
111185 + const char * const name;
111186 + const unsigned int param;
111187 +};
111188 +
111189 +#include "size_overflow_hash.h"
111190 +
111191 +enum mark {
111192 + MARK_NO, MARK_YES, MARK_NOT_INTENTIONAL, MARK_TURN_OFF
111193 +};
111194 +
111195 +static unsigned int call_count;
111196 +
111197 +struct visited {
111198 + struct visited *next;
111199 + const_tree fndecl;
111200 + unsigned int num;
111201 + const_gimple first_stmt;
111202 +};
111203 +
111204 +struct next_cgraph_node {
111205 + struct next_cgraph_node *next;
111206 + struct cgraph_node *current_function;
111207 + tree callee_fndecl;
111208 + unsigned int num;
111209 +};
111210 +
111211 +struct interesting_node {
111212 + struct interesting_node *next;
111213 + gimple first_stmt;
111214 + const_tree fndecl;
111215 + tree node;
111216 +#if BUILDING_GCC_VERSION <= 4007
111217 + VEC(tree, gc) *last_nodes;
111218 +#else
111219 + vec<tree, va_gc> *last_nodes;
111220 +#endif
111221 + unsigned int num;
111222 + enum mark intentional_attr_decl;
111223 + enum mark intentional_attr_cur_fndecl;
111224 + gimple intentional_mark_from_gimple;
111225 +};
111226 +
111227 +int plugin_is_GPL_compatible;
111228 +void debug_gimple_stmt(gimple gs);
111229 +
111230 +static tree report_size_overflow_decl;
111231 +static const_tree const_char_ptr_type_node;
111232 +
111233 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs);
111234 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs);
111235 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs);
111236 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs);
111237 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs);
111238 +
111239 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before);
111240 +static tree get_size_overflow_type(gimple stmt, const_tree node);
111241 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3);
111242 +
111243 +static struct plugin_info size_overflow_plugin_info = {
111244 + .version = "20140111beta",
111245 + .help = "no-size-overflow\tturn off size overflow checking\n",
111246 +};
111247 +
111248 +static tree handle_size_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
111249 +{
111250 + unsigned int arg_count;
111251 + enum tree_code code = TREE_CODE(*node);
111252 +
111253 + switch (code) {
111254 + case FUNCTION_DECL:
111255 + arg_count = type_num_arguments(TREE_TYPE(*node));
111256 + break;
111257 + case FUNCTION_TYPE:
111258 + case METHOD_TYPE:
111259 + arg_count = type_num_arguments(*node);
111260 + break;
111261 + default:
111262 + *no_add_attrs = true;
111263 + error("%s: %qE attribute only applies to functions", __func__, name);
111264 + return NULL_TREE;
111265 + }
111266 +
111267 + for (; args; args = TREE_CHAIN(args)) {
111268 + tree position = TREE_VALUE(args);
111269 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
111270 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
111271 + *no_add_attrs = true;
111272 + }
111273 + }
111274 + return NULL_TREE;
111275 +}
111276 +
111277 +static tree handle_intentional_overflow_attribute(tree *node, tree __unused name, tree args, int __unused flags, bool *no_add_attrs)
111278 +{
111279 + unsigned int arg_count;
111280 + enum tree_code code = TREE_CODE(*node);
111281 +
111282 + switch (code) {
111283 + case FUNCTION_DECL:
111284 + arg_count = type_num_arguments(TREE_TYPE(*node));
111285 + break;
111286 + case FUNCTION_TYPE:
111287 + case METHOD_TYPE:
111288 + arg_count = type_num_arguments(*node);
111289 + break;
111290 + case FIELD_DECL:
111291 + return NULL_TREE;
111292 + default:
111293 + *no_add_attrs = true;
111294 + error("%qE attribute only applies to functions", name);
111295 + return NULL_TREE;
111296 + }
111297 +
111298 + if (TREE_INT_CST_HIGH(TREE_VALUE(args)) != 0)
111299 + return NULL_TREE;
111300 +
111301 + for (; args; args = TREE_CHAIN(args)) {
111302 + tree position = TREE_VALUE(args);
111303 + if (TREE_CODE(position) != INTEGER_CST || TREE_INT_CST_LOW(position) > arg_count ) {
111304 + error("%s: parameter %u is outside range.", __func__, (unsigned int)TREE_INT_CST_LOW(position));
111305 + *no_add_attrs = true;
111306 + }
111307 + }
111308 + return NULL_TREE;
111309 +}
111310 +
111311 +static struct attribute_spec size_overflow_attr = {
111312 + .name = "size_overflow",
111313 + .min_length = 1,
111314 + .max_length = -1,
111315 + .decl_required = true,
111316 + .type_required = false,
111317 + .function_type_required = false,
111318 + .handler = handle_size_overflow_attribute,
111319 +#if BUILDING_GCC_VERSION >= 4007
111320 + .affects_type_identity = false
111321 +#endif
111322 +};
111323 +
111324 +static struct attribute_spec intentional_overflow_attr = {
111325 + .name = "intentional_overflow",
111326 + .min_length = 1,
111327 + .max_length = -1,
111328 + .decl_required = true,
111329 + .type_required = false,
111330 + .function_type_required = false,
111331 + .handler = handle_intentional_overflow_attribute,
111332 +#if BUILDING_GCC_VERSION >= 4007
111333 + .affects_type_identity = false
111334 +#endif
111335 +};
111336 +
111337 +static void register_attributes(void __unused *event_data, void __unused *data)
111338 +{
111339 + register_attribute(&size_overflow_attr);
111340 + register_attribute(&intentional_overflow_attr);
111341 +}
111342 +
111343 +static bool is_bool(const_tree node)
111344 +{
111345 + const_tree type;
111346 +
111347 + if (node == NULL_TREE)
111348 + return false;
111349 +
111350 + type = TREE_TYPE(node);
111351 + if (!INTEGRAL_TYPE_P(type))
111352 + return false;
111353 + if (TREE_CODE(type) == BOOLEAN_TYPE)
111354 + return true;
111355 + if (TYPE_PRECISION(type) == 1)
111356 + return true;
111357 + return false;
111358 +}
111359 +
111360 +static bool skip_types(const_tree var)
111361 +{
111362 + tree type;
111363 + enum tree_code code;
111364 +
111365 + if (is_gimple_constant(var))
111366 + return true;
111367 +
111368 + switch (TREE_CODE(var)) {
111369 + case ADDR_EXPR:
111370 +#if BUILDING_GCC_VERSION >= 4006
111371 + case MEM_REF:
111372 +#endif
111373 + case ARRAY_REF:
111374 + case BIT_FIELD_REF:
111375 + case INDIRECT_REF:
111376 + case TARGET_MEM_REF:
111377 + case COMPONENT_REF:
111378 + case VAR_DECL:
111379 + case VIEW_CONVERT_EXPR:
111380 + return true;
111381 + default:
111382 + break;
111383 + }
111384 +
111385 + code = TREE_CODE(var);
111386 + gcc_assert(code == SSA_NAME || code == PARM_DECL);
111387 +
111388 + type = TREE_TYPE(var);
111389 + switch (TREE_CODE(type)) {
111390 + case INTEGER_TYPE:
111391 + case ENUMERAL_TYPE:
111392 + return false;
111393 + case BOOLEAN_TYPE:
111394 + return is_bool(var);
111395 + default:
111396 + return true;
111397 + }
111398 +}
111399 +
111400 +static inline gimple get_def_stmt(const_tree node)
111401 +{
111402 + gcc_assert(node != NULL_TREE);
111403 +
111404 + if (skip_types(node))
111405 + return NULL;
111406 +
111407 + if (TREE_CODE(node) != SSA_NAME)
111408 + return NULL;
111409 + return SSA_NAME_DEF_STMT(node);
111410 +}
111411 +
111412 +static unsigned char get_tree_code(const_tree type)
111413 +{
111414 + switch (TREE_CODE(type)) {
111415 + case ARRAY_TYPE:
111416 + return 0;
111417 + case BOOLEAN_TYPE:
111418 + return 1;
111419 + case ENUMERAL_TYPE:
111420 + return 2;
111421 + case FUNCTION_TYPE:
111422 + return 3;
111423 + case INTEGER_TYPE:
111424 + return 4;
111425 + case POINTER_TYPE:
111426 + return 5;
111427 + case RECORD_TYPE:
111428 + return 6;
111429 + case UNION_TYPE:
111430 + return 7;
111431 + case VOID_TYPE:
111432 + return 8;
111433 + case REAL_TYPE:
111434 + return 9;
111435 + case VECTOR_TYPE:
111436 + return 10;
111437 + case REFERENCE_TYPE:
111438 + return 11;
111439 + case OFFSET_TYPE:
111440 + return 12;
111441 + case COMPLEX_TYPE:
111442 + return 13;
111443 + default:
111444 + debug_tree((tree)type);
111445 + gcc_unreachable();
111446 + }
111447 +}
111448 +
111449 +struct function_hash {
111450 + size_t tree_codes_len;
111451 + unsigned char tree_codes[CODES_LIMIT];
111452 + tree fndecl;
111453 + unsigned int hash;
111454 +};
111455 +
111456 +// http://www.team5150.com/~andrew/noncryptohashzoo2~/CrapWow.html
111457 +static unsigned int CrapWow(const char *key, unsigned int len, unsigned int seed)
111458 +{
111459 +#define cwfold( a, b, lo, hi ) { p = (unsigned int)(a) * (unsigned long long)(b); lo ^= (unsigned int)p; hi ^= (unsigned int)(p >> 32); }
111460 +#define cwmixa( in ) { cwfold( in, m, k, h ); }
111461 +#define cwmixb( in ) { cwfold( in, n, h, k ); }
111462 +
111463 + unsigned int m = 0x57559429;
111464 + unsigned int n = 0x5052acdb;
111465 + const unsigned int *key4 = (const unsigned int *)key;
111466 + unsigned int h = len;
111467 + unsigned int k = len + seed + n;
111468 + unsigned long long p;
111469 +
111470 + while (len >= 8) {
111471 + cwmixb(key4[0]) cwmixa(key4[1]) key4 += 2;
111472 + len -= 8;
111473 + }
111474 + if (len >= 4) {
111475 + cwmixb(key4[0]) key4 += 1;
111476 + len -= 4;
111477 + }
111478 + if (len)
111479 + cwmixa(key4[0] & ((1 << (len * 8)) - 1 ));
111480 + cwmixb(h ^ (k + n));
111481 + return k ^ h;
111482 +
111483 +#undef cwfold
111484 +#undef cwmixa
111485 +#undef cwmixb
111486 +}
111487 +
111488 +static void set_hash(const char *fn_name, struct function_hash *fn_hash_data)
111489 +{
111490 + unsigned int fn, codes, seed = 0;
111491 +
111492 + fn = CrapWow(fn_name, strlen(fn_name), seed) & 0xffff;
111493 + codes = CrapWow((const char*)fn_hash_data->tree_codes, fn_hash_data->tree_codes_len, seed) & 0xffff;
111494 +
111495 + fn_hash_data->hash = fn ^ codes;
111496 +}
111497 +
111498 +static void set_node_codes(const_tree type, struct function_hash *fn_hash_data)
111499 +{
111500 + gcc_assert(type != NULL_TREE);
111501 + gcc_assert(TREE_CODE_CLASS(TREE_CODE(type)) == tcc_type);
111502 +
111503 + while (type && fn_hash_data->tree_codes_len < CODES_LIMIT) {
111504 + fn_hash_data->tree_codes[fn_hash_data->tree_codes_len] = get_tree_code(type);
111505 + fn_hash_data->tree_codes_len++;
111506 + type = TREE_TYPE(type);
111507 + }
111508 +}
111509 +
111510 +static void set_result_codes(const_tree node, struct function_hash *fn_hash_data)
111511 +{
111512 + const_tree result;
111513 +
111514 + gcc_assert(node != NULL_TREE);
111515 +
111516 + if (DECL_P(node)) {
111517 + result = DECL_RESULT(node);
111518 + if (result != NULL_TREE)
111519 + return set_node_codes(TREE_TYPE(result), fn_hash_data);
111520 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
111521 + }
111522 +
111523 + gcc_assert(TYPE_P(node));
111524 +
111525 + if (TREE_CODE(node) == FUNCTION_TYPE)
111526 + return set_result_codes(TREE_TYPE(node), fn_hash_data);
111527 +
111528 + return set_node_codes(node, fn_hash_data);
111529 +}
111530 +
111531 +static void set_function_codes(struct function_hash *fn_hash_data)
111532 +{
111533 + const_tree arg, type = TREE_TYPE(fn_hash_data->fndecl);
111534 + enum tree_code code = TREE_CODE(type);
111535 +
111536 + gcc_assert(code == FUNCTION_TYPE || code == METHOD_TYPE);
111537 +
111538 + set_result_codes(fn_hash_data->fndecl, fn_hash_data);
111539 +
111540 + for (arg = TYPE_ARG_TYPES(type); arg != NULL_TREE && fn_hash_data->tree_codes_len < CODES_LIMIT; arg = TREE_CHAIN(arg))
111541 + set_node_codes(TREE_VALUE(arg), fn_hash_data);
111542 +}
111543 +
111544 +static const struct size_overflow_hash *get_function_hash(tree fndecl)
111545 +{
111546 + const struct size_overflow_hash *entry;
111547 + struct function_hash fn_hash_data;
111548 + const char *func_name;
111549 +
111550 + // skip builtins __builtin_constant_p
111551 + if (DECL_BUILT_IN(fndecl))
111552 + return NULL;
111553 +
111554 + fn_hash_data.fndecl = fndecl;
111555 + fn_hash_data.tree_codes_len = 0;
111556 +
111557 + set_function_codes(&fn_hash_data);
111558 + gcc_assert(fn_hash_data.tree_codes_len != 0);
111559 +
111560 + func_name = ASM_NAME(fn_hash_data.fndecl);
111561 + set_hash(func_name, &fn_hash_data);
111562 +
111563 + entry = size_overflow_hash[fn_hash_data.hash];
111564 +
111565 + while (entry) {
111566 + if (!strcmp(entry->name, func_name))
111567 + return entry;
111568 + entry = entry->next;
111569 + }
111570 + return NULL;
111571 +}
111572 +
111573 +static void print_missing_msg(tree func, unsigned int argnum)
111574 +{
111575 + location_t loc;
111576 + const char *curfunc;
111577 + struct function_hash fn_hash_data;
111578 +
111579 + fn_hash_data.fndecl = DECL_ORIGIN(func);
111580 + fn_hash_data.tree_codes_len = 0;
111581 +
111582 + loc = DECL_SOURCE_LOCATION(fn_hash_data.fndecl);
111583 + curfunc = ASM_NAME(fn_hash_data.fndecl);
111584 +
111585 + set_function_codes(&fn_hash_data);
111586 + set_hash(curfunc, &fn_hash_data);
111587 +
111588 + inform(loc, "Function %s is missing from the size_overflow hash table +%s+%u+%u+", curfunc, curfunc, argnum, fn_hash_data.hash);
111589 +}
111590 +
111591 +static unsigned int find_arg_number_tree(const_tree arg, const_tree func)
111592 +{
111593 + tree var;
111594 + unsigned int argnum = 1;
111595 +
111596 + if (TREE_CODE(arg) == SSA_NAME)
111597 + arg = SSA_NAME_VAR(arg);
111598 +
111599 + for (var = DECL_ARGUMENTS(func); var; var = TREE_CHAIN(var), argnum++) {
111600 + if (!operand_equal_p(arg, var, 0) && strcmp(NAME(var), NAME(arg)))
111601 + continue;
111602 + if (!skip_types(var))
111603 + return argnum;
111604 + }
111605 +
111606 + return CANNOT_FIND_ARG;
111607 +}
111608 +
111609 +static tree create_new_var(tree type)
111610 +{
111611 + tree new_var = create_tmp_var(type, "cicus");
111612 +
111613 +#if BUILDING_GCC_VERSION <= 4007
111614 + add_referenced_var(new_var);
111615 +#endif
111616 + return new_var;
111617 +}
111618 +
111619 +static gimple create_binary_assign(enum tree_code code, gimple stmt, tree rhs1, tree rhs2)
111620 +{
111621 + gimple assign;
111622 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
111623 + tree type = TREE_TYPE(rhs1);
111624 + tree lhs = create_new_var(type);
111625 +
111626 + gcc_assert(types_compatible_p(type, TREE_TYPE(rhs2)));
111627 + assign = gimple_build_assign_with_ops(code, lhs, rhs1, rhs2);
111628 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
111629 +
111630 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
111631 + update_stmt(assign);
111632 + gimple_set_plf(assign, MY_STMT, true);
111633 + return assign;
111634 +}
111635 +
111636 +static tree cast_a_tree(tree type, tree var)
111637 +{
111638 + gcc_assert(type != NULL_TREE);
111639 + gcc_assert(var != NULL_TREE);
111640 + gcc_assert(fold_convertible_p(type, var));
111641 +
111642 + return fold_convert(type, var);
111643 +}
111644 +
111645 +static tree get_lhs(const_gimple stmt)
111646 +{
111647 + switch (gimple_code(stmt)) {
111648 + case GIMPLE_ASSIGN:
111649 + case GIMPLE_CALL:
111650 + return gimple_get_lhs(stmt);
111651 + case GIMPLE_PHI:
111652 + return gimple_phi_result(stmt);
111653 + default:
111654 + return NULL_TREE;
111655 + }
111656 +}
111657 +
111658 +static bool skip_cast(tree dst_type, const_tree rhs, bool force)
111659 +{
111660 + const_gimple def_stmt = get_def_stmt(rhs);
111661 +
111662 + if (force)
111663 + return false;
111664 +
111665 + if (is_gimple_constant(rhs))
111666 + return false;
111667 +
111668 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
111669 + return false;
111670 +
111671 + if (!types_compatible_p(dst_type, TREE_TYPE(rhs)))
111672 + return false;
111673 +
111674 + // DI type can be on 32 bit (from create_assign) but overflow type stays DI
111675 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
111676 + return false;
111677 +
111678 + return true;
111679 +}
111680 +
111681 +static gimple build_cast_stmt(tree dst_type, tree rhs, tree lhs, gimple_stmt_iterator *gsi, bool before, bool force)
111682 +{
111683 + gimple assign, def_stmt;
111684 +
111685 + gcc_assert(dst_type != NULL_TREE && rhs != NULL_TREE);
111686 + if (gsi_end_p(*gsi) && before == AFTER_STMT)
111687 + gcc_unreachable();
111688 +
111689 + def_stmt = get_def_stmt(rhs);
111690 + if (def_stmt && gimple_code(def_stmt) != GIMPLE_NOP && skip_cast(dst_type, rhs, force) && gimple_plf(def_stmt, MY_STMT))
111691 + return def_stmt;
111692 +
111693 + if (lhs == CREATE_NEW_VAR)
111694 + lhs = create_new_var(dst_type);
111695 +
111696 + assign = gimple_build_assign(lhs, cast_a_tree(dst_type, rhs));
111697 +
111698 + if (!gsi_end_p(*gsi)) {
111699 + location_t loc = gimple_location(gsi_stmt(*gsi));
111700 + gimple_set_location(assign, loc);
111701 + }
111702 +
111703 + gimple_assign_set_lhs(assign, make_ssa_name(lhs, assign));
111704 +
111705 + if (before)
111706 + gsi_insert_before(gsi, assign, GSI_NEW_STMT);
111707 + else
111708 + gsi_insert_after(gsi, assign, GSI_NEW_STMT);
111709 + update_stmt(assign);
111710 + return assign;
111711 +}
111712 +
111713 +static tree cast_to_new_size_overflow_type(gimple stmt, tree rhs, tree size_overflow_type, bool before)
111714 +{
111715 + gimple_stmt_iterator gsi;
111716 + tree lhs;
111717 + gimple new_stmt;
111718 +
111719 + if (rhs == NULL_TREE)
111720 + return NULL_TREE;
111721 +
111722 + gsi = gsi_for_stmt(stmt);
111723 + new_stmt = build_cast_stmt(size_overflow_type, rhs, CREATE_NEW_VAR, &gsi, before, false);
111724 + gimple_set_plf(new_stmt, MY_STMT, true);
111725 +
111726 + lhs = get_lhs(new_stmt);
111727 + gcc_assert(lhs != NULL_TREE);
111728 + return lhs;
111729 +}
111730 +
111731 +static tree cast_to_TI_type(gimple stmt, tree node)
111732 +{
111733 + gimple_stmt_iterator gsi;
111734 + gimple cast_stmt;
111735 + tree type = TREE_TYPE(node);
111736 +
111737 + if (types_compatible_p(type, intTI_type_node))
111738 + return node;
111739 +
111740 + gsi = gsi_for_stmt(stmt);
111741 + cast_stmt = build_cast_stmt(intTI_type_node, node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
111742 + gimple_set_plf(cast_stmt, MY_STMT, true);
111743 + return gimple_assign_lhs(cast_stmt);
111744 +}
111745 +
111746 +static tree create_assign(struct pointer_set_t *visited, gimple oldstmt, tree rhs1, bool before)
111747 +{
111748 + tree lhs, new_lhs;
111749 + gimple_stmt_iterator gsi;
111750 +
111751 + if (rhs1 == NULL_TREE) {
111752 + debug_gimple_stmt(oldstmt);
111753 + error("%s: rhs1 is NULL_TREE", __func__);
111754 + gcc_unreachable();
111755 + }
111756 +
111757 + switch (gimple_code(oldstmt)) {
111758 + case GIMPLE_ASM:
111759 + lhs = rhs1;
111760 + break;
111761 + case GIMPLE_CALL:
111762 + case GIMPLE_ASSIGN:
111763 + lhs = gimple_get_lhs(oldstmt);
111764 + break;
111765 + default:
111766 + debug_gimple_stmt(oldstmt);
111767 + gcc_unreachable();
111768 + }
111769 +
111770 + gsi = gsi_for_stmt(oldstmt);
111771 + pointer_set_insert(visited, oldstmt);
111772 + if (lookup_stmt_eh_lp(oldstmt) != 0) {
111773 + basic_block next_bb, cur_bb;
111774 + const_edge e;
111775 +
111776 + gcc_assert(before == false);
111777 + gcc_assert(stmt_can_throw_internal(oldstmt));
111778 + gcc_assert(gimple_code(oldstmt) == GIMPLE_CALL);
111779 + gcc_assert(!gsi_end_p(gsi));
111780 +
111781 + cur_bb = gimple_bb(oldstmt);
111782 + next_bb = cur_bb->next_bb;
111783 + e = find_edge(cur_bb, next_bb);
111784 + gcc_assert(e != NULL);
111785 + gcc_assert(e->flags & EDGE_FALLTHRU);
111786 +
111787 + gsi = gsi_after_labels(next_bb);
111788 + gcc_assert(!gsi_end_p(gsi));
111789 +
111790 + before = true;
111791 + oldstmt = gsi_stmt(gsi);
111792 + }
111793 +
111794 + new_lhs = cast_to_new_size_overflow_type(oldstmt, rhs1, get_size_overflow_type(oldstmt, lhs), before);
111795 + return new_lhs;
111796 +}
111797 +
111798 +static tree dup_assign(struct pointer_set_t *visited, gimple oldstmt, const_tree node, tree rhs1, tree rhs2, tree __unused rhs3)
111799 +{
111800 + gimple stmt;
111801 + gimple_stmt_iterator gsi;
111802 + tree size_overflow_type, new_var, lhs = gimple_assign_lhs(oldstmt);
111803 +
111804 + if (gimple_plf(oldstmt, MY_STMT))
111805 + return lhs;
111806 +
111807 + if (gimple_num_ops(oldstmt) != 4 && rhs1 == NULL_TREE) {
111808 + rhs1 = gimple_assign_rhs1(oldstmt);
111809 + rhs1 = create_assign(visited, oldstmt, rhs1, BEFORE_STMT);
111810 + }
111811 + if (gimple_num_ops(oldstmt) == 3 && rhs2 == NULL_TREE) {
111812 + rhs2 = gimple_assign_rhs2(oldstmt);
111813 + rhs2 = create_assign(visited, oldstmt, rhs2, BEFORE_STMT);
111814 + }
111815 +
111816 + stmt = gimple_copy(oldstmt);
111817 + gimple_set_location(stmt, gimple_location(oldstmt));
111818 + gimple_set_plf(stmt, MY_STMT, true);
111819 +
111820 + if (gimple_assign_rhs_code(oldstmt) == WIDEN_MULT_EXPR)
111821 + gimple_assign_set_rhs_code(stmt, MULT_EXPR);
111822 +
111823 + size_overflow_type = get_size_overflow_type(oldstmt, node);
111824 +
111825 + new_var = create_new_var(size_overflow_type);
111826 + new_var = make_ssa_name(new_var, stmt);
111827 + gimple_assign_set_lhs(stmt, new_var);
111828 +
111829 + if (rhs1 != NULL_TREE)
111830 + gimple_assign_set_rhs1(stmt, rhs1);
111831 +
111832 + if (rhs2 != NULL_TREE)
111833 + gimple_assign_set_rhs2(stmt, rhs2);
111834 +#if BUILDING_GCC_VERSION >= 4007
111835 + if (rhs3 != NULL_TREE)
111836 + gimple_assign_set_rhs3(stmt, rhs3);
111837 +#endif
111838 + gimple_set_vuse(stmt, gimple_vuse(oldstmt));
111839 + gimple_set_vdef(stmt, gimple_vdef(oldstmt));
111840 +
111841 + gsi = gsi_for_stmt(oldstmt);
111842 + gsi_insert_after(&gsi, stmt, GSI_SAME_STMT);
111843 + update_stmt(stmt);
111844 + pointer_set_insert(visited, oldstmt);
111845 + return gimple_assign_lhs(stmt);
111846 +}
111847 +
111848 +static tree cast_parm_decl(tree phi_ssa_name, tree arg, tree size_overflow_type, basic_block bb)
111849 +{
111850 + gimple assign;
111851 + gimple_stmt_iterator gsi;
111852 + basic_block first_bb;
111853 +
111854 + gcc_assert(SSA_NAME_IS_DEFAULT_DEF(arg));
111855 +
111856 + if (bb->index == 0) {
111857 + first_bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
111858 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
111859 + set_immediate_dominator(CDI_DOMINATORS, first_bb, ENTRY_BLOCK_PTR);
111860 + bb = first_bb;
111861 + }
111862 +
111863 + gsi = gsi_after_labels(bb);
111864 + assign = build_cast_stmt(size_overflow_type, arg, phi_ssa_name, &gsi, BEFORE_STMT, false);
111865 + gimple_set_plf(assign, MY_STMT, true);
111866 +
111867 + return gimple_assign_lhs(assign);
111868 +}
111869 +
111870 +static tree use_phi_ssa_name(tree ssa_name_var, tree new_arg)
111871 +{
111872 + gimple_stmt_iterator gsi;
111873 + gimple assign, def_stmt = get_def_stmt(new_arg);
111874 +
111875 + if (gimple_code(def_stmt) == GIMPLE_PHI) {
111876 + gsi = gsi_after_labels(gimple_bb(def_stmt));
111877 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, BEFORE_STMT, true);
111878 + } else {
111879 + gsi = gsi_for_stmt(def_stmt);
111880 + assign = build_cast_stmt(TREE_TYPE(new_arg), new_arg, ssa_name_var, &gsi, AFTER_STMT, true);
111881 + }
111882 +
111883 + gimple_set_plf(assign, MY_STMT, true);
111884 + return gimple_assign_lhs(assign);
111885 +}
111886 +
111887 +static tree cast_visited_phi_arg(tree ssa_name_var, tree arg, tree size_overflow_type)
111888 +{
111889 + basic_block bb;
111890 + gimple_stmt_iterator gsi;
111891 + const_gimple def_stmt;
111892 + gimple assign;
111893 +
111894 + def_stmt = get_def_stmt(arg);
111895 + bb = gimple_bb(def_stmt);
111896 + gcc_assert(bb->index != 0);
111897 + gsi = gsi_after_labels(bb);
111898 +
111899 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, BEFORE_STMT, false);
111900 + gimple_set_plf(assign, MY_STMT, true);
111901 + return gimple_assign_lhs(assign);
111902 +}
111903 +
111904 +static tree create_new_phi_arg(tree ssa_name_var, tree new_arg, gimple oldstmt, unsigned int i)
111905 +{
111906 + tree size_overflow_type;
111907 + tree arg;
111908 + const_gimple def_stmt;
111909 +
111910 + if (new_arg != NULL_TREE && is_gimple_constant(new_arg))
111911 + return new_arg;
111912 +
111913 + arg = gimple_phi_arg_def(oldstmt, i);
111914 + def_stmt = get_def_stmt(arg);
111915 + gcc_assert(def_stmt != NULL);
111916 + size_overflow_type = get_size_overflow_type(oldstmt, arg);
111917 +
111918 + switch (gimple_code(def_stmt)) {
111919 + case GIMPLE_PHI:
111920 + return cast_visited_phi_arg(ssa_name_var, arg, size_overflow_type);
111921 + case GIMPLE_NOP: {
111922 + basic_block bb;
111923 +
111924 + bb = gimple_phi_arg_edge(oldstmt, i)->src;
111925 + return cast_parm_decl(ssa_name_var, arg, size_overflow_type, bb);
111926 + }
111927 + case GIMPLE_ASM: {
111928 + gimple_stmt_iterator gsi;
111929 + gimple assign, stmt = get_def_stmt(arg);
111930 +
111931 + gsi = gsi_for_stmt(stmt);
111932 + assign = build_cast_stmt(size_overflow_type, arg, ssa_name_var, &gsi, AFTER_STMT, false);
111933 + gimple_set_plf(assign, MY_STMT, true);
111934 + return gimple_assign_lhs(assign);
111935 + }
111936 + default:
111937 + gcc_assert(new_arg != NULL_TREE);
111938 + gcc_assert(types_compatible_p(TREE_TYPE(new_arg), size_overflow_type));
111939 + return use_phi_ssa_name(ssa_name_var, new_arg);
111940 + }
111941 +}
111942 +
111943 +static gimple overflow_create_phi_node(gimple oldstmt, tree result)
111944 +{
111945 + basic_block bb;
111946 + gimple phi;
111947 + gimple_seq seq;
111948 + gimple_stmt_iterator gsi = gsi_for_stmt(oldstmt);
111949 +
111950 + bb = gsi_bb(gsi);
111951 +
111952 + if (result == NULL_TREE) {
111953 + tree old_result = gimple_phi_result(oldstmt);
111954 + tree size_overflow_type = get_size_overflow_type(oldstmt, old_result);
111955 +
111956 + result = create_new_var(size_overflow_type);
111957 + }
111958 +
111959 + phi = create_phi_node(result, bb);
111960 + gimple_phi_set_result(phi, make_ssa_name(result, phi));
111961 + seq = phi_nodes(bb);
111962 + gsi = gsi_last(seq);
111963 + gsi_remove(&gsi, false);
111964 +
111965 + gsi = gsi_for_stmt(oldstmt);
111966 + gsi_insert_after(&gsi, phi, GSI_NEW_STMT);
111967 + gimple_set_bb(phi, bb);
111968 + gimple_set_plf(phi, MY_STMT, true);
111969 + return phi;
111970 +}
111971 +
111972 +#if BUILDING_GCC_VERSION <= 4007
111973 +static tree create_new_phi_node(VEC(tree, gc) *args, tree ssa_name_var, gimple oldstmt)
111974 +#else
111975 +static tree create_new_phi_node(vec<tree, va_gc> *args, tree ssa_name_var, gimple oldstmt)
111976 +#endif
111977 +{
111978 + gimple new_phi;
111979 + unsigned int i;
111980 + tree arg, result;
111981 + location_t loc = gimple_location(oldstmt);
111982 +
111983 +#if BUILDING_GCC_VERSION <= 4007
111984 + gcc_assert(!VEC_empty(tree, args));
111985 +#else
111986 + gcc_assert(!args->is_empty());
111987 +#endif
111988 +
111989 + new_phi = overflow_create_phi_node(oldstmt, ssa_name_var);
111990 + result = gimple_phi_result(new_phi);
111991 + ssa_name_var = SSA_NAME_VAR(result);
111992 +
111993 +
111994 +#if BUILDING_GCC_VERSION == 4005
111995 + for (i = 0; i < VEC_length(tree, args); i++) {
111996 + arg = VEC_index(tree, args, i);
111997 +#elif BUILDING_GCC_VERSION <= 4007
111998 + FOR_EACH_VEC_ELT(tree, args, i, arg) {
111999 +#else
112000 + FOR_EACH_VEC_ELT(*args, i, arg) {
112001 +#endif
112002 + arg = create_new_phi_arg(ssa_name_var, arg, oldstmt, i);
112003 + add_phi_arg(new_phi, arg, gimple_phi_arg_edge(oldstmt, i), loc);
112004 + }
112005 +
112006 +#if BUILDING_GCC_VERSION <= 4007
112007 + VEC_free(tree, gc, args);
112008 +#else
112009 + vec_free(args);
112010 +#endif
112011 + update_stmt(new_phi);
112012 + return result;
112013 +}
112014 +
112015 +static tree handle_phi(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree orig_result)
112016 +{
112017 + tree ssa_name_var = NULL_TREE;
112018 +#if BUILDING_GCC_VERSION <= 4007
112019 + VEC(tree, gc) *args;
112020 +#else
112021 + vec<tree, va_gc> *args;
112022 +#endif
112023 + gimple oldstmt = get_def_stmt(orig_result);
112024 + unsigned int i, len = gimple_phi_num_args(oldstmt);
112025 +
112026 + pointer_set_insert(visited, oldstmt);
112027 +#if BUILDING_GCC_VERSION <= 4007
112028 + args = VEC_alloc(tree, gc, len);
112029 +#else
112030 + vec_alloc(args, len);
112031 +#endif
112032 + for (i = 0; i < len; i++) {
112033 + tree arg, new_arg;
112034 +
112035 + arg = gimple_phi_arg_def(oldstmt, i);
112036 + new_arg = expand(visited, caller_node, arg);
112037 +
112038 + if (ssa_name_var == NULL_TREE && new_arg != NULL_TREE)
112039 + ssa_name_var = SSA_NAME_VAR(new_arg);
112040 +
112041 + if (is_gimple_constant(arg)) {
112042 + tree size_overflow_type = get_size_overflow_type(oldstmt, arg);
112043 +
112044 + new_arg = cast_a_tree(size_overflow_type, arg);
112045 + }
112046 +
112047 +#if BUILDING_GCC_VERSION <= 4007
112048 + VEC_safe_push(tree, gc, args, new_arg);
112049 +#else
112050 + vec_safe_push(args, new_arg);
112051 +#endif
112052 + }
112053 +
112054 + return create_new_phi_node(args, ssa_name_var, oldstmt);
112055 +}
112056 +
112057 +static tree change_assign_rhs(gimple stmt, const_tree orig_rhs, tree new_rhs)
112058 +{
112059 + gimple assign;
112060 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112061 + tree origtype = TREE_TYPE(orig_rhs);
112062 +
112063 + gcc_assert(is_gimple_assign(stmt));
112064 +
112065 + assign = build_cast_stmt(origtype, new_rhs, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
112066 + gimple_set_plf(assign, MY_STMT, true);
112067 + return gimple_assign_lhs(assign);
112068 +}
112069 +
112070 +static bool is_a_cast_and_const_overflow(const_tree no_const_rhs)
112071 +{
112072 + const_tree rhs1, lhs, rhs1_type, lhs_type;
112073 + enum machine_mode lhs_mode, rhs_mode;
112074 + gimple def_stmt = get_def_stmt(no_const_rhs);
112075 +
112076 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112077 + return false;
112078 +
112079 + rhs1 = gimple_assign_rhs1(def_stmt);
112080 + lhs = gimple_assign_lhs(def_stmt);
112081 + rhs1_type = TREE_TYPE(rhs1);
112082 + lhs_type = TREE_TYPE(lhs);
112083 + rhs_mode = TYPE_MODE(rhs1_type);
112084 + lhs_mode = TYPE_MODE(lhs_type);
112085 + if (TYPE_UNSIGNED(lhs_type) == TYPE_UNSIGNED(rhs1_type) || lhs_mode != rhs_mode)
112086 + return false;
112087 +
112088 + return true;
112089 +}
112090 +
112091 +static tree create_cast_assign(struct pointer_set_t *visited, gimple stmt)
112092 +{
112093 + tree rhs1 = gimple_assign_rhs1(stmt);
112094 + tree lhs = gimple_assign_lhs(stmt);
112095 + const_tree rhs1_type = TREE_TYPE(rhs1);
112096 + const_tree lhs_type = TREE_TYPE(lhs);
112097 +
112098 + if (TYPE_UNSIGNED(rhs1_type) == TYPE_UNSIGNED(lhs_type))
112099 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112100 +
112101 + return create_assign(visited, stmt, rhs1, AFTER_STMT);
112102 +}
112103 +
112104 +static bool no_uses(tree node)
112105 +{
112106 + imm_use_iterator imm_iter;
112107 + use_operand_p use_p;
112108 +
112109 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
112110 + const_gimple use_stmt = USE_STMT(use_p);
112111 +
112112 + if (use_stmt == NULL)
112113 + return true;
112114 + if (is_gimple_debug(use_stmt))
112115 + continue;
112116 + return false;
112117 + }
112118 + return true;
112119 +}
112120 +
112121 +// 3.8.5 mm/page-writeback.c __ilog2_u64(): ret, uint + uintmax; uint -> int; int max
112122 +static bool is_const_plus_unsigned_signed_truncation(const_tree lhs)
112123 +{
112124 + tree rhs1, lhs_type, rhs_type, rhs2, not_const_rhs;
112125 + gimple def_stmt = get_def_stmt(lhs);
112126 +
112127 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
112128 + return false;
112129 +
112130 + rhs1 = gimple_assign_rhs1(def_stmt);
112131 + rhs_type = TREE_TYPE(rhs1);
112132 + lhs_type = TREE_TYPE(lhs);
112133 + if (TYPE_UNSIGNED(lhs_type) || !TYPE_UNSIGNED(rhs_type))
112134 + return false;
112135 + if (TYPE_MODE(lhs_type) != TYPE_MODE(rhs_type))
112136 + return false;
112137 +
112138 + def_stmt = get_def_stmt(rhs1);
112139 + if (!def_stmt || !is_gimple_assign(def_stmt) || gimple_num_ops(def_stmt) != 3)
112140 + return false;
112141 +
112142 + if (gimple_assign_rhs_code(def_stmt) != PLUS_EXPR)
112143 + return false;
112144 +
112145 + rhs1 = gimple_assign_rhs1(def_stmt);
112146 + rhs2 = gimple_assign_rhs2(def_stmt);
112147 + if (!is_gimple_constant(rhs1) && !is_gimple_constant(rhs2))
112148 + return false;
112149 +
112150 + if (is_gimple_constant(rhs2))
112151 + not_const_rhs = rhs1;
112152 + else
112153 + not_const_rhs = rhs2;
112154 +
112155 + return no_uses(not_const_rhs);
112156 +}
112157 +
112158 +static bool skip_lhs_cast_check(const_gimple stmt)
112159 +{
112160 + const_tree rhs = gimple_assign_rhs1(stmt);
112161 + const_gimple def_stmt = get_def_stmt(rhs);
112162 +
112163 + // 3.8.2 kernel/futex_compat.c compat_exit_robust_list(): get_user() 64 ulong -> int (compat_long_t), int max
112164 + if (gimple_code(def_stmt) == GIMPLE_ASM)
112165 + return true;
112166 +
112167 + if (is_const_plus_unsigned_signed_truncation(rhs))
112168 + return true;
112169 +
112170 + return false;
112171 +}
112172 +
112173 +static tree create_cast_overflow_check(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree new_rhs1, gimple stmt)
112174 +{
112175 + bool cast_lhs, cast_rhs;
112176 + tree lhs = gimple_assign_lhs(stmt);
112177 + tree rhs = gimple_assign_rhs1(stmt);
112178 + const_tree lhs_type = TREE_TYPE(lhs);
112179 + const_tree rhs_type = TREE_TYPE(rhs);
112180 + enum machine_mode lhs_mode = TYPE_MODE(lhs_type);
112181 + enum machine_mode rhs_mode = TYPE_MODE(rhs_type);
112182 + unsigned int lhs_size = GET_MODE_BITSIZE(lhs_mode);
112183 + unsigned int rhs_size = GET_MODE_BITSIZE(rhs_mode);
112184 +
112185 + static bool check_lhs[3][4] = {
112186 + // ss su us uu
112187 + { false, true, true, false }, // lhs > rhs
112188 + { false, false, false, false }, // lhs = rhs
112189 + { true, true, true, true }, // lhs < rhs
112190 + };
112191 +
112192 + static bool check_rhs[3][4] = {
112193 + // ss su us uu
112194 + { true, false, true, true }, // lhs > rhs
112195 + { true, false, true, true }, // lhs = rhs
112196 + { true, false, true, true }, // lhs < rhs
112197 + };
112198 +
112199 + // skip lhs check on signed SI -> HI cast or signed SI -> QI cast !!!!
112200 + if (rhs_mode == SImode && !TYPE_UNSIGNED(rhs_type) && (lhs_mode == HImode || lhs_mode == QImode))
112201 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112202 +
112203 + if (lhs_size > rhs_size) {
112204 + cast_lhs = check_lhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112205 + cast_rhs = check_rhs[0][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112206 + } else if (lhs_size == rhs_size) {
112207 + cast_lhs = check_lhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112208 + cast_rhs = check_rhs[1][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112209 + } else {
112210 + cast_lhs = check_lhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112211 + cast_rhs = check_rhs[2][TYPE_UNSIGNED(rhs_type) + 2 * TYPE_UNSIGNED(lhs_type)];
112212 + }
112213 +
112214 + if (!cast_lhs && !cast_rhs)
112215 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112216 +
112217 + if (cast_lhs && !skip_lhs_cast_check(stmt))
112218 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, lhs, BEFORE_STMT);
112219 +
112220 + if (cast_rhs)
112221 + check_size_overflow(caller_node, stmt, TREE_TYPE(new_rhs1), new_rhs1, rhs, BEFORE_STMT);
112222 +
112223 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112224 +}
112225 +
112226 +static tree handle_unary_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
112227 +{
112228 + tree rhs1, new_rhs1, lhs = gimple_assign_lhs(stmt);
112229 +
112230 + if (gimple_plf(stmt, MY_STMT))
112231 + return lhs;
112232 +
112233 + rhs1 = gimple_assign_rhs1(stmt);
112234 + if (TREE_CODE(TREE_TYPE(rhs1)) == POINTER_TYPE)
112235 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112236 +
112237 + new_rhs1 = expand(visited, caller_node, rhs1);
112238 +
112239 + if (new_rhs1 == NULL_TREE)
112240 + return create_cast_assign(visited, stmt);
112241 +
112242 + if (gimple_plf(stmt, NO_CAST_CHECK))
112243 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112244 +
112245 + if (gimple_assign_rhs_code(stmt) == BIT_NOT_EXPR) {
112246 + tree size_overflow_type = get_size_overflow_type(stmt, rhs1);
112247 +
112248 + new_rhs1 = cast_to_new_size_overflow_type(stmt, new_rhs1, size_overflow_type, BEFORE_STMT);
112249 + check_size_overflow(caller_node, stmt, size_overflow_type, new_rhs1, rhs1, BEFORE_STMT);
112250 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112251 + }
112252 +
112253 + if (!gimple_assign_cast_p(stmt))
112254 + return dup_assign(visited, stmt, lhs, new_rhs1, NULL_TREE, NULL_TREE);
112255 +
112256 + return create_cast_overflow_check(visited, caller_node, new_rhs1, stmt);
112257 +}
112258 +
112259 +static tree handle_unary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, gimple stmt)
112260 +{
112261 + tree rhs1, lhs = gimple_assign_lhs(stmt);
112262 + gimple def_stmt = get_def_stmt(lhs);
112263 +
112264 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP);
112265 + rhs1 = gimple_assign_rhs1(def_stmt);
112266 +
112267 + if (is_gimple_constant(rhs1))
112268 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112269 +
112270 + switch (TREE_CODE(rhs1)) {
112271 + case SSA_NAME:
112272 + return handle_unary_rhs(visited, caller_node, def_stmt);
112273 + case ARRAY_REF:
112274 + case BIT_FIELD_REF:
112275 + case ADDR_EXPR:
112276 + case COMPONENT_REF:
112277 + case INDIRECT_REF:
112278 +#if BUILDING_GCC_VERSION >= 4006
112279 + case MEM_REF:
112280 +#endif
112281 + case TARGET_MEM_REF:
112282 + case VIEW_CONVERT_EXPR:
112283 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112284 + case PARM_DECL:
112285 + case VAR_DECL:
112286 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112287 +
112288 + default:
112289 + debug_gimple_stmt(def_stmt);
112290 + debug_tree(rhs1);
112291 + gcc_unreachable();
112292 + }
112293 +}
112294 +
112295 +static void insert_cond(basic_block cond_bb, tree arg, enum tree_code cond_code, tree type_value)
112296 +{
112297 + gimple cond_stmt;
112298 + gimple_stmt_iterator gsi = gsi_last_bb(cond_bb);
112299 +
112300 + cond_stmt = gimple_build_cond(cond_code, arg, type_value, NULL_TREE, NULL_TREE);
112301 + gsi_insert_after(&gsi, cond_stmt, GSI_CONTINUE_LINKING);
112302 + update_stmt(cond_stmt);
112303 +}
112304 +
112305 +static tree create_string_param(tree string)
112306 +{
112307 + tree i_type, a_type;
112308 + const int length = TREE_STRING_LENGTH(string);
112309 +
112310 + gcc_assert(length > 0);
112311 +
112312 + i_type = build_index_type(build_int_cst(NULL_TREE, length - 1));
112313 + a_type = build_array_type(char_type_node, i_type);
112314 +
112315 + TREE_TYPE(string) = a_type;
112316 + TREE_CONSTANT(string) = 1;
112317 + TREE_READONLY(string) = 1;
112318 +
112319 + return build1(ADDR_EXPR, ptr_type_node, string);
112320 +}
112321 +
112322 +#if BUILDING_GCC_VERSION <= 4006
112323 +struct cgraph_node *cgraph_get_create_node(tree decl);
112324 +
112325 +struct cgraph_node *cgraph_get_create_node(tree decl)
112326 +{
112327 + struct cgraph_node *node;
112328 +
112329 + node = cgraph_get_node(decl);
112330 + if (node)
112331 + return node;
112332 + return cgraph_node(decl);
112333 +}
112334 +#endif
112335 +
112336 +static void insert_cond_result(struct cgraph_node *caller_node, basic_block bb_true, const_gimple stmt, const_tree arg, bool min)
112337 +{
112338 + gimple func_stmt;
112339 + const_gimple def_stmt;
112340 + const_tree loc_line;
112341 + tree loc_file, ssa_name, current_func;
112342 + expanded_location xloc;
112343 + char *ssa_name_buf;
112344 + int len;
112345 + struct cgraph_edge *edge;
112346 + struct cgraph_node *callee_node;
112347 + int frequency;
112348 + gimple_stmt_iterator gsi = gsi_start_bb(bb_true);
112349 +
112350 + def_stmt = get_def_stmt(arg);
112351 + xloc = expand_location(gimple_location(def_stmt));
112352 +
112353 + if (!gimple_has_location(def_stmt)) {
112354 + xloc = expand_location(gimple_location(stmt));
112355 + if (!gimple_has_location(stmt))
112356 + xloc = expand_location(DECL_SOURCE_LOCATION(current_function_decl));
112357 + }
112358 +
112359 + loc_line = build_int_cstu(unsigned_type_node, xloc.line);
112360 +
112361 + loc_file = build_string(strlen(xloc.file) + 1, xloc.file);
112362 + loc_file = create_string_param(loc_file);
112363 +
112364 + current_func = build_string(NAME_LEN(current_function_decl) + 1, NAME(current_function_decl));
112365 + current_func = create_string_param(current_func);
112366 +
112367 + gcc_assert(DECL_NAME(SSA_NAME_VAR(arg)) != NULL);
112368 + call_count++;
112369 + 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);
112370 + gcc_assert(len > 0);
112371 + ssa_name = build_string(len + 1, ssa_name_buf);
112372 + free(ssa_name_buf);
112373 + ssa_name = create_string_param(ssa_name);
112374 +
112375 + // void report_size_overflow(const char *file, unsigned int line, const char *func, const char *ssa_name)
112376 + func_stmt = gimple_build_call(report_size_overflow_decl, 4, loc_file, loc_line, current_func, ssa_name);
112377 + gsi_insert_after(&gsi, func_stmt, GSI_CONTINUE_LINKING);
112378 +
112379 + callee_node = cgraph_get_create_node(report_size_overflow_decl);
112380 + frequency = compute_call_stmt_bb_frequency(current_function_decl, bb_true);
112381 +
112382 +#if BUILDING_GCC_VERSION <= 4006
112383 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency, bb_true->loop_depth);
112384 +#else
112385 + edge = cgraph_create_edge(caller_node, callee_node, func_stmt, bb_true->count, frequency);
112386 +#endif
112387 + gcc_assert(edge != NULL);
112388 +}
112389 +
112390 +static void __unused print_the_code_insertions(const_gimple stmt)
112391 +{
112392 + location_t loc = gimple_location(stmt);
112393 +
112394 + inform(loc, "Integer size_overflow check applied here.");
112395 +}
112396 +
112397 +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)
112398 +{
112399 + basic_block cond_bb, join_bb, bb_true;
112400 + edge e;
112401 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112402 +
112403 + cond_bb = gimple_bb(stmt);
112404 + if (before)
112405 + gsi_prev(&gsi);
112406 + if (gsi_end_p(gsi))
112407 + e = split_block_after_labels(cond_bb);
112408 + else
112409 + e = split_block(cond_bb, gsi_stmt(gsi));
112410 + cond_bb = e->src;
112411 + join_bb = e->dest;
112412 + e->flags = EDGE_FALSE_VALUE;
112413 + e->probability = REG_BR_PROB_BASE;
112414 +
112415 + bb_true = create_empty_bb(cond_bb);
112416 + make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);
112417 + make_edge(cond_bb, join_bb, EDGE_FALSE_VALUE);
112418 + make_edge(bb_true, join_bb, EDGE_FALLTHRU);
112419 +
112420 + gcc_assert(dom_info_available_p(CDI_DOMINATORS));
112421 + set_immediate_dominator(CDI_DOMINATORS, bb_true, cond_bb);
112422 + set_immediate_dominator(CDI_DOMINATORS, join_bb, cond_bb);
112423 +
112424 + if (current_loops != NULL) {
112425 + gcc_assert(cond_bb->loop_father == join_bb->loop_father);
112426 + add_bb_to_loop(bb_true, cond_bb->loop_father);
112427 + }
112428 +
112429 + insert_cond(cond_bb, arg, cond_code, type_value);
112430 + insert_cond_result(caller_node, bb_true, stmt, arg, min);
112431 +
112432 +// print_the_code_insertions(stmt);
112433 +}
112434 +
112435 +static void check_size_overflow(struct cgraph_node *caller_node, gimple stmt, tree size_overflow_type, tree cast_rhs, tree rhs, bool before)
112436 +{
112437 + const_tree rhs_type = TREE_TYPE(rhs);
112438 + tree cast_rhs_type, type_max_type, type_min_type, type_max, type_min;
112439 +
112440 + gcc_assert(rhs_type != NULL_TREE);
112441 + if (TREE_CODE(rhs_type) == POINTER_TYPE)
112442 + return;
112443 +
112444 + gcc_assert(TREE_CODE(rhs_type) == INTEGER_TYPE || TREE_CODE(rhs_type) == ENUMERAL_TYPE);
112445 +
112446 + if (is_const_plus_unsigned_signed_truncation(rhs))
112447 + return;
112448 +
112449 + type_max = cast_a_tree(size_overflow_type, TYPE_MAX_VALUE(rhs_type));
112450 + // typemax (-1) < typemin (0)
112451 + if (TREE_OVERFLOW(type_max))
112452 + return;
112453 +
112454 + type_min = cast_a_tree(size_overflow_type, TYPE_MIN_VALUE(rhs_type));
112455 +
112456 + cast_rhs_type = TREE_TYPE(cast_rhs);
112457 + type_max_type = TREE_TYPE(type_max);
112458 + gcc_assert(types_compatible_p(cast_rhs_type, type_max_type));
112459 +
112460 + insert_check_size_overflow(caller_node, stmt, GT_EXPR, cast_rhs, type_max, before, MAX_CHECK);
112461 +
112462 + // special case: get_size_overflow_type(), 32, u64->s
112463 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode) && TYPE_UNSIGNED(size_overflow_type) && !TYPE_UNSIGNED(rhs_type))
112464 + return;
112465 +
112466 + type_min_type = TREE_TYPE(type_min);
112467 + gcc_assert(types_compatible_p(type_max_type, type_min_type));
112468 + insert_check_size_overflow(caller_node, stmt, LT_EXPR, cast_rhs, type_min, before, MIN_CHECK);
112469 +}
112470 +
112471 +static bool is_a_constant_overflow(const_gimple stmt, const_tree rhs)
112472 +{
112473 + if (gimple_assign_rhs_code(stmt) == MIN_EXPR)
112474 + return false;
112475 + if (!is_gimple_constant(rhs))
112476 + return false;
112477 + return true;
112478 +}
112479 +
112480 +static tree get_def_stmt_rhs(const_tree var)
112481 +{
112482 + tree rhs1, def_stmt_rhs1;
112483 + gimple rhs1_def_stmt, def_stmt_rhs1_def_stmt, def_stmt;
112484 +
112485 + def_stmt = get_def_stmt(var);
112486 + if (!gimple_assign_cast_p(def_stmt))
112487 + return NULL_TREE;
112488 + gcc_assert(gimple_code(def_stmt) != GIMPLE_NOP && gimple_plf(def_stmt, MY_STMT) && gimple_assign_cast_p(def_stmt));
112489 +
112490 + rhs1 = gimple_assign_rhs1(def_stmt);
112491 + rhs1_def_stmt = get_def_stmt(rhs1);
112492 + if (!gimple_assign_cast_p(rhs1_def_stmt))
112493 + return rhs1;
112494 +
112495 + def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
112496 + def_stmt_rhs1_def_stmt = get_def_stmt(def_stmt_rhs1);
112497 +
112498 + switch (gimple_code(def_stmt_rhs1_def_stmt)) {
112499 + case GIMPLE_CALL:
112500 + case GIMPLE_NOP:
112501 + case GIMPLE_ASM:
112502 + case GIMPLE_PHI:
112503 + return def_stmt_rhs1;
112504 + case GIMPLE_ASSIGN:
112505 + return rhs1;
112506 + default:
112507 + debug_gimple_stmt(def_stmt_rhs1_def_stmt);
112508 + gcc_unreachable();
112509 + }
112510 +}
112511 +
112512 +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)
112513 +{
112514 + tree new_rhs, orig_rhs;
112515 + void (*gimple_assign_set_rhs)(gimple, tree);
112516 + tree rhs1 = gimple_assign_rhs1(stmt);
112517 + tree rhs2 = gimple_assign_rhs2(stmt);
112518 + tree lhs = gimple_assign_lhs(stmt);
112519 +
112520 + if (!check_overflow)
112521 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112522 +
112523 + if (change_rhs == NULL_TREE)
112524 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112525 +
112526 + if (new_rhs2 == NULL_TREE) {
112527 + orig_rhs = rhs1;
112528 + gimple_assign_set_rhs = &gimple_assign_set_rhs1;
112529 + } else {
112530 + orig_rhs = rhs2;
112531 + gimple_assign_set_rhs = &gimple_assign_set_rhs2;
112532 + }
112533 +
112534 + check_size_overflow(caller_node, stmt, TREE_TYPE(change_rhs), change_rhs, orig_rhs, BEFORE_STMT);
112535 +
112536 + new_rhs = change_assign_rhs(stmt, orig_rhs, change_rhs);
112537 + gimple_assign_set_rhs(stmt, new_rhs);
112538 + update_stmt(stmt);
112539 +
112540 + return create_assign(visited, stmt, lhs, AFTER_STMT);
112541 +}
112542 +
112543 +static bool is_subtraction_special(const_gimple stmt)
112544 +{
112545 + gimple rhs1_def_stmt, rhs2_def_stmt;
112546 + const_tree rhs1_def_stmt_rhs1, rhs2_def_stmt_rhs1, rhs1_def_stmt_lhs, rhs2_def_stmt_lhs;
112547 + enum machine_mode rhs1_def_stmt_rhs1_mode, rhs2_def_stmt_rhs1_mode, rhs1_def_stmt_lhs_mode, rhs2_def_stmt_lhs_mode;
112548 + const_tree rhs1 = gimple_assign_rhs1(stmt);
112549 + const_tree rhs2 = gimple_assign_rhs2(stmt);
112550 +
112551 + if (is_gimple_constant(rhs1) || is_gimple_constant(rhs2))
112552 + return false;
112553 +
112554 + gcc_assert(TREE_CODE(rhs1) == SSA_NAME && TREE_CODE(rhs2) == SSA_NAME);
112555 +
112556 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
112557 + return false;
112558 +
112559 + rhs1_def_stmt = get_def_stmt(rhs1);
112560 + rhs2_def_stmt = get_def_stmt(rhs2);
112561 + if (!gimple_assign_cast_p(rhs1_def_stmt) || !gimple_assign_cast_p(rhs2_def_stmt))
112562 + return false;
112563 +
112564 + rhs1_def_stmt_rhs1 = gimple_assign_rhs1(rhs1_def_stmt);
112565 + rhs2_def_stmt_rhs1 = gimple_assign_rhs1(rhs2_def_stmt);
112566 + rhs1_def_stmt_lhs = gimple_assign_lhs(rhs1_def_stmt);
112567 + rhs2_def_stmt_lhs = gimple_assign_lhs(rhs2_def_stmt);
112568 + rhs1_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_rhs1));
112569 + rhs2_def_stmt_rhs1_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_rhs1));
112570 + rhs1_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs1_def_stmt_lhs));
112571 + rhs2_def_stmt_lhs_mode = TYPE_MODE(TREE_TYPE(rhs2_def_stmt_lhs));
112572 + if (GET_MODE_BITSIZE(rhs1_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs1_def_stmt_lhs_mode))
112573 + return false;
112574 + if (GET_MODE_BITSIZE(rhs2_def_stmt_rhs1_mode) <= GET_MODE_BITSIZE(rhs2_def_stmt_lhs_mode))
112575 + return false;
112576 +
112577 + gimple_set_plf(rhs1_def_stmt, NO_CAST_CHECK, true);
112578 + gimple_set_plf(rhs2_def_stmt, NO_CAST_CHECK, true);
112579 + return true;
112580 +}
112581 +
112582 +static tree handle_integer_truncation(struct pointer_set_t *visited, struct cgraph_node *caller_node, const_tree lhs)
112583 +{
112584 + tree new_rhs1, new_rhs2;
112585 + tree new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1, new_lhs;
112586 + gimple assign, stmt = get_def_stmt(lhs);
112587 + tree rhs1 = gimple_assign_rhs1(stmt);
112588 + tree rhs2 = gimple_assign_rhs2(stmt);
112589 +
112590 + if (!is_subtraction_special(stmt))
112591 + return NULL_TREE;
112592 +
112593 + new_rhs1 = expand(visited, caller_node, rhs1);
112594 + new_rhs2 = expand(visited, caller_node, rhs2);
112595 +
112596 + new_rhs1_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs1);
112597 + new_rhs2_def_stmt_rhs1 = get_def_stmt_rhs(new_rhs2);
112598 +
112599 + if (new_rhs1_def_stmt_rhs1 == NULL_TREE || new_rhs2_def_stmt_rhs1 == NULL_TREE)
112600 + return NULL_TREE;
112601 +
112602 + if (!types_compatible_p(TREE_TYPE(new_rhs1_def_stmt_rhs1), TREE_TYPE(new_rhs2_def_stmt_rhs1))) {
112603 + new_rhs1_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs1_def_stmt_rhs1);
112604 + new_rhs2_def_stmt_rhs1 = cast_to_TI_type(stmt, new_rhs2_def_stmt_rhs1);
112605 + }
112606 +
112607 + assign = create_binary_assign(MINUS_EXPR, stmt, new_rhs1_def_stmt_rhs1, new_rhs2_def_stmt_rhs1);
112608 + new_lhs = gimple_assign_lhs(assign);
112609 + check_size_overflow(caller_node, assign, TREE_TYPE(new_lhs), new_lhs, rhs1, AFTER_STMT);
112610 +
112611 + return dup_assign(visited, stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
112612 +}
112613 +
112614 +static bool is_a_neg_overflow(const_gimple stmt, const_tree rhs)
112615 +{
112616 + const_gimple def_stmt;
112617 +
112618 + if (TREE_CODE(rhs) != SSA_NAME)
112619 + return false;
112620 +
112621 + if (gimple_assign_rhs_code(stmt) != PLUS_EXPR)
112622 + return false;
112623 +
112624 + def_stmt = get_def_stmt(rhs);
112625 + if (!is_gimple_assign(def_stmt) || gimple_assign_rhs_code(def_stmt) != BIT_NOT_EXPR)
112626 + return false;
112627 +
112628 + return true;
112629 +}
112630 +
112631 +static tree handle_binary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112632 +{
112633 + tree rhs1, rhs2, new_lhs;
112634 + gimple def_stmt = get_def_stmt(lhs);
112635 + tree new_rhs1 = NULL_TREE;
112636 + tree new_rhs2 = NULL_TREE;
112637 +
112638 + rhs1 = gimple_assign_rhs1(def_stmt);
112639 + rhs2 = gimple_assign_rhs2(def_stmt);
112640 +
112641 + /* no DImode/TImode division in the 32/64 bit kernel */
112642 + switch (gimple_assign_rhs_code(def_stmt)) {
112643 + case RDIV_EXPR:
112644 + case TRUNC_DIV_EXPR:
112645 + case CEIL_DIV_EXPR:
112646 + case FLOOR_DIV_EXPR:
112647 + case ROUND_DIV_EXPR:
112648 + case TRUNC_MOD_EXPR:
112649 + case CEIL_MOD_EXPR:
112650 + case FLOOR_MOD_EXPR:
112651 + case ROUND_MOD_EXPR:
112652 + case EXACT_DIV_EXPR:
112653 + case POINTER_PLUS_EXPR:
112654 + case BIT_AND_EXPR:
112655 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112656 + default:
112657 + break;
112658 + }
112659 +
112660 + new_lhs = handle_integer_truncation(visited, caller_node, lhs);
112661 + if (new_lhs != NULL_TREE)
112662 + return new_lhs;
112663 +
112664 + if (TREE_CODE(rhs1) == SSA_NAME)
112665 + new_rhs1 = expand(visited, caller_node, rhs1);
112666 + if (TREE_CODE(rhs2) == SSA_NAME)
112667 + new_rhs2 = expand(visited, caller_node, rhs2);
112668 +
112669 + if (is_a_neg_overflow(def_stmt, rhs2))
112670 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs1, NULL_TREE);
112671 + if (is_a_neg_overflow(def_stmt, rhs1))
112672 + return handle_intentional_overflow(visited, caller_node, true, def_stmt, new_rhs2, new_rhs2);
112673 +
112674 +
112675 + if (is_a_constant_overflow(def_stmt, rhs2))
112676 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs1), def_stmt, new_rhs1, NULL_TREE);
112677 + if (is_a_constant_overflow(def_stmt, rhs1))
112678 + return handle_intentional_overflow(visited, caller_node, !is_a_cast_and_const_overflow(rhs2), def_stmt, new_rhs2, new_rhs2);
112679 +
112680 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, NULL_TREE);
112681 +}
112682 +
112683 +#if BUILDING_GCC_VERSION >= 4007
112684 +static tree get_new_rhs(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree size_overflow_type, tree rhs)
112685 +{
112686 + if (is_gimple_constant(rhs))
112687 + return cast_a_tree(size_overflow_type, rhs);
112688 + if (TREE_CODE(rhs) != SSA_NAME)
112689 + return NULL_TREE;
112690 + return expand(visited, caller_node, rhs);
112691 +}
112692 +
112693 +static tree handle_ternary_ops(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112694 +{
112695 + tree rhs1, rhs2, rhs3, new_rhs1, new_rhs2, new_rhs3, size_overflow_type;
112696 + gimple def_stmt = get_def_stmt(lhs);
112697 +
112698 + size_overflow_type = get_size_overflow_type(def_stmt, lhs);
112699 +
112700 + rhs1 = gimple_assign_rhs1(def_stmt);
112701 + rhs2 = gimple_assign_rhs2(def_stmt);
112702 + rhs3 = gimple_assign_rhs3(def_stmt);
112703 + new_rhs1 = get_new_rhs(visited, caller_node, size_overflow_type, rhs1);
112704 + new_rhs2 = get_new_rhs(visited, caller_node, size_overflow_type, rhs2);
112705 + new_rhs3 = get_new_rhs(visited, caller_node, size_overflow_type, rhs3);
112706 +
112707 + return dup_assign(visited, def_stmt, lhs, new_rhs1, new_rhs2, new_rhs3);
112708 +}
112709 +#endif
112710 +
112711 +static tree get_size_overflow_type(gimple stmt, const_tree node)
112712 +{
112713 + const_tree type;
112714 + tree new_type;
112715 +
112716 + gcc_assert(node != NULL_TREE);
112717 +
112718 + type = TREE_TYPE(node);
112719 +
112720 + if (gimple_plf(stmt, MY_STMT))
112721 + return TREE_TYPE(node);
112722 +
112723 + switch (TYPE_MODE(type)) {
112724 + case QImode:
112725 + new_type = intHI_type_node;
112726 + break;
112727 + case HImode:
112728 + new_type = intSI_type_node;
112729 + break;
112730 + case SImode:
112731 + new_type = intDI_type_node;
112732 + break;
112733 + case DImode:
112734 + if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
112735 + new_type = TYPE_UNSIGNED(type) ? unsigned_intDI_type_node : intDI_type_node;
112736 + else
112737 + new_type = intTI_type_node;
112738 + break;
112739 + case TImode:
112740 + gcc_assert(!TYPE_UNSIGNED(type));
112741 + new_type = intTI_type_node;
112742 + break;
112743 + default:
112744 + debug_tree((tree)node);
112745 + error("%s: unsupported gcc configuration (%qE).", __func__, current_function_decl);
112746 + gcc_unreachable();
112747 + }
112748 +
112749 + if (TYPE_QUALS(type) != 0)
112750 + return build_qualified_type(new_type, TYPE_QUALS(type));
112751 + return new_type;
112752 +}
112753 +
112754 +static tree expand_visited(gimple def_stmt)
112755 +{
112756 + const_gimple next_stmt;
112757 + gimple_stmt_iterator gsi;
112758 + enum gimple_code code = gimple_code(def_stmt);
112759 +
112760 + if (code == GIMPLE_ASM)
112761 + return NULL_TREE;
112762 +
112763 + gsi = gsi_for_stmt(def_stmt);
112764 + gsi_next(&gsi);
112765 +
112766 + if (gimple_code(def_stmt) == GIMPLE_PHI && gsi_end_p(gsi))
112767 + return NULL_TREE;
112768 + gcc_assert(!gsi_end_p(gsi));
112769 + next_stmt = gsi_stmt(gsi);
112770 +
112771 + if (gimple_code(def_stmt) == GIMPLE_PHI && !gimple_plf((gimple)next_stmt, MY_STMT))
112772 + return NULL_TREE;
112773 + gcc_assert(gimple_plf((gimple)next_stmt, MY_STMT));
112774 +
112775 + return get_lhs(next_stmt);
112776 +}
112777 +
112778 +static tree expand(struct pointer_set_t *visited, struct cgraph_node *caller_node, tree lhs)
112779 +{
112780 + gimple def_stmt;
112781 +
112782 + def_stmt = get_def_stmt(lhs);
112783 +
112784 + if (!def_stmt || gimple_code(def_stmt) == GIMPLE_NOP)
112785 + return NULL_TREE;
112786 +
112787 + if (gimple_plf(def_stmt, MY_STMT))
112788 + return lhs;
112789 +
112790 + if (pointer_set_contains(visited, def_stmt))
112791 + return expand_visited(def_stmt);
112792 +
112793 + switch (gimple_code(def_stmt)) {
112794 + case GIMPLE_PHI:
112795 + return handle_phi(visited, caller_node, lhs);
112796 + case GIMPLE_CALL:
112797 + case GIMPLE_ASM:
112798 + return create_assign(visited, def_stmt, lhs, AFTER_STMT);
112799 + case GIMPLE_ASSIGN:
112800 + switch (gimple_num_ops(def_stmt)) {
112801 + case 2:
112802 + return handle_unary_ops(visited, caller_node, def_stmt);
112803 + case 3:
112804 + return handle_binary_ops(visited, caller_node, lhs);
112805 +#if BUILDING_GCC_VERSION >= 4007
112806 + case 4:
112807 + return handle_ternary_ops(visited, caller_node, lhs);
112808 +#endif
112809 + }
112810 + default:
112811 + debug_gimple_stmt(def_stmt);
112812 + error("%s: unknown gimple code", __func__);
112813 + gcc_unreachable();
112814 + }
112815 +}
112816 +
112817 +static tree cast_to_orig_type(gimple stmt, const_tree orig_node, tree new_node)
112818 +{
112819 + const_gimple assign;
112820 + tree orig_type = TREE_TYPE(orig_node);
112821 + gimple_stmt_iterator gsi = gsi_for_stmt(stmt);
112822 +
112823 + assign = build_cast_stmt(orig_type, new_node, CREATE_NEW_VAR, &gsi, BEFORE_STMT, false);
112824 + return gimple_assign_lhs(assign);
112825 +}
112826 +
112827 +static void change_orig_node(struct interesting_node *cur_node, tree new_node)
112828 +{
112829 + void (*set_rhs)(gimple, tree);
112830 + gimple stmt = cur_node->first_stmt;
112831 + const_tree orig_node = cur_node->node;
112832 +
112833 + switch (gimple_code(stmt)) {
112834 + case GIMPLE_RETURN:
112835 + gimple_return_set_retval(stmt, cast_to_orig_type(stmt, orig_node, new_node));
112836 + break;
112837 + case GIMPLE_CALL:
112838 + gimple_call_set_arg(stmt, cur_node->num - 1, cast_to_orig_type(stmt, orig_node, new_node));
112839 + break;
112840 + case GIMPLE_ASSIGN:
112841 + switch (cur_node->num) {
112842 + case 1:
112843 + set_rhs = &gimple_assign_set_rhs1;
112844 + break;
112845 + case 2:
112846 + set_rhs = &gimple_assign_set_rhs2;
112847 + break;
112848 +#if BUILDING_GCC_VERSION > 4005
112849 + case 3:
112850 + set_rhs = &gimple_assign_set_rhs3;
112851 + break;
112852 +#endif
112853 + default:
112854 + gcc_unreachable();
112855 + }
112856 +
112857 + set_rhs(stmt, cast_to_orig_type(stmt, orig_node, new_node));
112858 + break;
112859 + default:
112860 + debug_gimple_stmt(stmt);
112861 + gcc_unreachable();
112862 + }
112863 +
112864 + update_stmt(stmt);
112865 +}
112866 +
112867 +static unsigned int get_correct_arg_count(unsigned int argnum, tree fndecl)
112868 +{
112869 + const struct size_overflow_hash *hash;
112870 + unsigned int new_argnum;
112871 + tree arg;
112872 + const_tree origarg;
112873 +
112874 + if (argnum == 0)
112875 + return argnum;
112876 +
112877 + hash = get_function_hash(fndecl);
112878 + if (hash && hash->param & (1U << argnum))
112879 + return argnum;
112880 +
112881 + if (DECL_EXTERNAL(fndecl))
112882 + return argnum;
112883 +
112884 + origarg = DECL_ARGUMENTS(DECL_ORIGIN(fndecl));
112885 + argnum--;
112886 + while (origarg && argnum) {
112887 + origarg = TREE_CHAIN(origarg);
112888 + argnum--;
112889 + }
112890 + gcc_assert(argnum == 0);
112891 + gcc_assert(origarg != NULL_TREE);
112892 +
112893 + for (arg = DECL_ARGUMENTS(fndecl), new_argnum = 1; arg; arg = TREE_CHAIN(arg), new_argnum++)
112894 + if (operand_equal_p(origarg, arg, 0) || !strcmp(NAME(origarg), NAME(arg)))
112895 + return new_argnum;
112896 +
112897 + return CANNOT_FIND_ARG;
112898 +}
112899 +
112900 +// Don't want to duplicate entries in next_cgraph_node
112901 +static bool is_in_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, const_tree fndecl, unsigned int num)
112902 +{
112903 + const_tree new_callee_fndecl;
112904 + struct next_cgraph_node *cur_node;
112905 +
112906 + if (fndecl == RET_CHECK)
112907 +#if BUILDING_GCC_VERSION <= 4007
112908 + new_callee_fndecl = node->decl;
112909 +#else
112910 + new_callee_fndecl = node->symbol.decl;
112911 +#endif
112912 + else
112913 + new_callee_fndecl = fndecl;
112914 +
112915 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
112916 +#if BUILDING_GCC_VERSION <= 4007
112917 + if (!operand_equal_p(cur_node->current_function->decl, node->decl, 0))
112918 +#else
112919 + if (!operand_equal_p(cur_node->current_function->symbol.decl, node->symbol.decl, 0))
112920 +#endif
112921 + continue;
112922 + if (!operand_equal_p(cur_node->callee_fndecl, new_callee_fndecl, 0))
112923 + continue;
112924 + if (num == cur_node->num)
112925 + return true;
112926 + }
112927 + return false;
112928 +}
112929 +
112930 +/* Add a next_cgraph_node into the list for handle_function().
112931 + * handle_function() iterates over all the next cgraph nodes and
112932 + * starts the overflow check insertion process.
112933 + */
112934 +static struct next_cgraph_node *create_new_next_cgraph_node(struct next_cgraph_node *head, struct cgraph_node *node, tree fndecl, unsigned int num)
112935 +{
112936 + struct next_cgraph_node *new_node;
112937 +
112938 + if (is_in_next_cgraph_node(head, node, fndecl, num))
112939 + return head;
112940 +
112941 + new_node = (struct next_cgraph_node *)xmalloc(sizeof(*new_node));
112942 + new_node->current_function = node;
112943 + new_node->next = NULL;
112944 + new_node->num = num;
112945 + if (fndecl == RET_CHECK)
112946 +#if BUILDING_GCC_VERSION <= 4007
112947 + new_node->callee_fndecl = node->decl;
112948 +#else
112949 + new_node->callee_fndecl = node->symbol.decl;
112950 +#endif
112951 + else
112952 + new_node->callee_fndecl = fndecl;
112953 +
112954 + if (!head)
112955 + return new_node;
112956 +
112957 + new_node->next = head;
112958 + return new_node;
112959 +}
112960 +
112961 +static struct next_cgraph_node *create_new_next_cgraph_nodes(struct next_cgraph_node *head, struct cgraph_node *node, unsigned int num)
112962 +{
112963 + struct cgraph_edge *e;
112964 +
112965 + if (num == 0)
112966 + return create_new_next_cgraph_node(head, node, RET_CHECK, num);
112967 +
112968 + for (e = node->callers; e; e = e->next_caller) {
112969 + tree fndecl = gimple_call_fndecl(e->call_stmt);
112970 +
112971 + gcc_assert(fndecl != NULL_TREE);
112972 + head = create_new_next_cgraph_node(head, e->caller, fndecl, num);
112973 + }
112974 +
112975 + return head;
112976 +}
112977 +
112978 +static bool is_a_return_check(const_tree node)
112979 +{
112980 + if (TREE_CODE(node) == FUNCTION_DECL)
112981 + return true;
112982 +
112983 + gcc_assert(TREE_CODE(node) == PARM_DECL);
112984 + return false;
112985 +}
112986 +
112987 +static bool is_in_hash_table(tree fndecl, unsigned int num)
112988 +{
112989 + const struct size_overflow_hash *hash;
112990 +
112991 + hash = get_function_hash(fndecl);
112992 + if (hash && (hash->param & (1U << num)))
112993 + return true;
112994 + return false;
112995 +}
112996 +
112997 +struct missing_functions {
112998 + struct missing_functions *next;
112999 + const_tree node;
113000 + tree fndecl;
113001 +};
113002 +
113003 +static struct missing_functions *create_new_missing_function(struct missing_functions *missing_fn_head, tree node)
113004 +{
113005 + struct missing_functions *new_function;
113006 +
113007 + new_function = (struct missing_functions *)xmalloc(sizeof(*new_function));
113008 + new_function->node = node;
113009 + new_function->next = NULL;
113010 +
113011 + if (TREE_CODE(node) == FUNCTION_DECL)
113012 + new_function->fndecl = node;
113013 + else
113014 + new_function->fndecl = current_function_decl;
113015 + gcc_assert(new_function->fndecl);
113016 +
113017 + if (!missing_fn_head)
113018 + return new_function;
113019 +
113020 + new_function->next = missing_fn_head;
113021 + return new_function;
113022 +}
113023 +
113024 +/* Check if the function has a size_overflow attribute or it is in the size_overflow hash table.
113025 + * If the function is missing everywhere then print the missing message into stderr.
113026 + */
113027 +static bool is_missing_function(tree orig_fndecl, unsigned int num)
113028 +{
113029 + switch (DECL_FUNCTION_CODE(orig_fndecl)) {
113030 +#if BUILDING_GCC_VERSION >= 4008
113031 + case BUILT_IN_BSWAP16:
113032 +#endif
113033 + case BUILT_IN_BSWAP32:
113034 + case BUILT_IN_BSWAP64:
113035 + case BUILT_IN_EXPECT:
113036 + case BUILT_IN_MEMCMP:
113037 + return false;
113038 + default:
113039 + break;
113040 + }
113041 +
113042 + // skip test.c
113043 + if (strcmp(NAME(current_function_decl), "coolmalloc")) {
113044 + if (lookup_attribute("size_overflow", DECL_ATTRIBUTES(orig_fndecl)))
113045 + warning(0, "unnecessary size_overflow attribute on: %s\n", NAME(orig_fndecl));
113046 + }
113047 +
113048 + if (is_in_hash_table(orig_fndecl, num))
113049 + return false;
113050 +
113051 + print_missing_msg(orig_fndecl, num);
113052 + return true;
113053 +}
113054 +
113055 +// Get the argnum of a function decl, if node is a return then the argnum is 0
113056 +static unsigned int get_function_num(const_tree node, const_tree orig_fndecl)
113057 +{
113058 + if (is_a_return_check(node))
113059 + return 0;
113060 + else
113061 + return find_arg_number_tree(node, orig_fndecl);
113062 +}
113063 +
113064 +/* If the function is missing from the hash table and it is a static function
113065 + * then create a next_cgraph_node from it for handle_function()
113066 + */
113067 +static struct next_cgraph_node *check_missing_overflow_attribute_and_create_next_node(struct next_cgraph_node *cnodes, struct missing_functions *missing_fn_head)
113068 +{
113069 + unsigned int num;
113070 + tree orig_fndecl;
113071 + struct cgraph_node *next_node = NULL;
113072 +
113073 + orig_fndecl = DECL_ORIGIN(missing_fn_head->fndecl);
113074 +
113075 + num = get_function_num(missing_fn_head->node, orig_fndecl);
113076 + if (num == CANNOT_FIND_ARG)
113077 + return cnodes;
113078 +
113079 + if (!is_missing_function(orig_fndecl, num))
113080 + return cnodes;
113081 +
113082 + next_node = cgraph_get_node(missing_fn_head->fndecl);
113083 + if (next_node && next_node->local.local)
113084 + cnodes = create_new_next_cgraph_nodes(cnodes, next_node, num);
113085 + return cnodes;
113086 +}
113087 +
113088 +/* Search for missing size_overflow attributes on the last nodes in ipa and collect them
113089 + * into the next_cgraph_node list. They will be the next interesting returns or callees.
113090 + */
113091 +static struct next_cgraph_node *search_overflow_attribute(struct next_cgraph_node *cnodes, struct interesting_node *cur_node)
113092 +{
113093 + unsigned int i;
113094 + tree node;
113095 + struct missing_functions *cur, *missing_fn_head = NULL;
113096 +
113097 +#if BUILDING_GCC_VERSION == 4005
113098 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113099 + node = VEC_index(tree, cur_node->last_nodes, i);
113100 +#elif BUILDING_GCC_VERSION <= 4007
113101 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, node) {
113102 +#else
113103 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, node) {
113104 +#endif
113105 + switch (TREE_CODE(node)) {
113106 + case PARM_DECL:
113107 + if (TREE_CODE(TREE_TYPE(node)) != INTEGER_TYPE)
113108 + break;
113109 + case FUNCTION_DECL:
113110 + missing_fn_head = create_new_missing_function(missing_fn_head, node);
113111 + break;
113112 + default:
113113 + break;
113114 + }
113115 + }
113116 +
113117 + while (missing_fn_head) {
113118 + cnodes = check_missing_overflow_attribute_and_create_next_node(cnodes, missing_fn_head);
113119 +
113120 + cur = missing_fn_head->next;
113121 + free(missing_fn_head);
113122 + missing_fn_head = cur;
113123 + }
113124 +
113125 + return cnodes;
113126 +}
113127 +
113128 +static void walk_phi_set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree result)
113129 +{
113130 + gimple phi = get_def_stmt(result);
113131 + unsigned int i, n = gimple_phi_num_args(phi);
113132 +
113133 + pointer_set_insert(visited, phi);
113134 + for (i = 0; i < n; i++) {
113135 + const_tree arg = gimple_phi_arg_def(phi, i);
113136 +
113137 + set_conditions(visited, interesting_conditions, arg);
113138 + }
113139 +}
113140 +
113141 +enum conditions {
113142 + FROM_CONST, NOT_UNARY, CAST
113143 +};
113144 +
113145 +// Search for constants, cast assignments and binary/ternary assignments
113146 +static void set_conditions(struct pointer_set_t *visited, bool *interesting_conditions, const_tree lhs)
113147 +{
113148 + gimple def_stmt = get_def_stmt(lhs);
113149 +
113150 + if (is_gimple_constant(lhs)) {
113151 + interesting_conditions[FROM_CONST] = true;
113152 + return;
113153 + }
113154 +
113155 + if (!def_stmt)
113156 + return;
113157 +
113158 + if (pointer_set_contains(visited, def_stmt))
113159 + return;
113160 +
113161 + switch (gimple_code(def_stmt)) {
113162 + case GIMPLE_NOP:
113163 + case GIMPLE_CALL:
113164 + case GIMPLE_ASM:
113165 + return;
113166 + case GIMPLE_PHI:
113167 + return walk_phi_set_conditions(visited, interesting_conditions, lhs);
113168 + case GIMPLE_ASSIGN:
113169 + if (gimple_num_ops(def_stmt) == 2) {
113170 + const_tree rhs = gimple_assign_rhs1(def_stmt);
113171 +
113172 + if (gimple_assign_cast_p(def_stmt))
113173 + interesting_conditions[CAST] = true;
113174 +
113175 + return set_conditions(visited, interesting_conditions, rhs);
113176 + } else {
113177 + interesting_conditions[NOT_UNARY] = true;
113178 + return;
113179 + }
113180 + default:
113181 + debug_gimple_stmt(def_stmt);
113182 + gcc_unreachable();
113183 + }
113184 +}
113185 +
113186 +// determine whether duplication will be necessary or not.
113187 +static void search_interesting_conditions(struct interesting_node *cur_node, bool *interesting_conditions)
113188 +{
113189 + struct pointer_set_t *visited;
113190 +
113191 + if (gimple_assign_cast_p(cur_node->first_stmt))
113192 + interesting_conditions[CAST] = true;
113193 + else if (is_gimple_assign(cur_node->first_stmt) && gimple_num_ops(cur_node->first_stmt) > 2)
113194 + interesting_conditions[NOT_UNARY] = true;
113195 +
113196 + visited = pointer_set_create();
113197 + set_conditions(visited, interesting_conditions, cur_node->node);
113198 + pointer_set_destroy(visited);
113199 +}
113200 +
113201 +// Remove the size_overflow asm stmt and create an assignment from the input and output of the asm
113202 +static void replace_size_overflow_asm_with_assign(gimple asm_stmt, tree lhs, tree rhs)
113203 +{
113204 + gimple assign;
113205 + gimple_stmt_iterator gsi;
113206 +
113207 + // already removed
113208 + if (gimple_bb(asm_stmt) == NULL)
113209 + return;
113210 + gsi = gsi_for_stmt(asm_stmt);
113211 +
113212 + assign = gimple_build_assign(lhs, rhs);
113213 + gsi_insert_before(&gsi, assign, GSI_SAME_STMT);
113214 + SSA_NAME_DEF_STMT(lhs) = assign;
113215 +
113216 + gsi_remove(&gsi, true);
113217 +}
113218 +
113219 +// Get the field decl of a component ref for intentional_overflow checking
113220 +static const_tree search_field_decl(const_tree comp_ref)
113221 +{
113222 + const_tree field = NULL_TREE;
113223 + unsigned int i, len = TREE_OPERAND_LENGTH(comp_ref);
113224 +
113225 + for (i = 0; i < len; i++) {
113226 + field = TREE_OPERAND(comp_ref, i);
113227 + if (TREE_CODE(field) == FIELD_DECL)
113228 + break;
113229 + }
113230 + gcc_assert(TREE_CODE(field) == FIELD_DECL);
113231 + return field;
113232 +}
113233 +
113234 +/* Get the fndecl of an interesting stmt, the fndecl is the caller function if the interesting
113235 + * stmt is a return otherwise it is the callee function.
113236 + */
113237 +static const_tree get_interesting_orig_fndecl(const_gimple stmt, unsigned int argnum)
113238 +{
113239 + const_tree fndecl;
113240 +
113241 + if (argnum == 0)
113242 + fndecl = current_function_decl;
113243 + else
113244 + fndecl = gimple_call_fndecl(stmt);
113245 +
113246 + if (fndecl == NULL_TREE)
113247 + return NULL_TREE;
113248 +
113249 + return DECL_ORIGIN(fndecl);
113250 +}
113251 +
113252 +/* Get the param of the intentional_overflow attribute.
113253 + * * 0: MARK_NOT_INTENTIONAL
113254 + * * 1..MAX_PARAM: MARK_YES
113255 + * * -1: MARK_TURN_OFF
113256 + */
113257 +static tree get_attribute_param(const_tree decl)
113258 +{
113259 + const_tree attr;
113260 +
113261 + if (decl == NULL_TREE)
113262 + return NULL_TREE;
113263 +
113264 + attr = lookup_attribute("intentional_overflow", DECL_ATTRIBUTES(decl));
113265 + if (!attr || !TREE_VALUE(attr))
113266 + return NULL_TREE;
113267 +
113268 + return TREE_VALUE(attr);
113269 +}
113270 +
113271 +// MARK_TURN_OFF
113272 +static bool is_turn_off_intentional_attr(const_tree decl)
113273 +{
113274 + const_tree param_head;
113275 +
113276 + param_head = get_attribute_param(decl);
113277 + if (param_head == NULL_TREE)
113278 + return false;
113279 +
113280 + if (TREE_INT_CST_HIGH(TREE_VALUE(param_head)) == -1)
113281 + return true;
113282 + return false;
113283 +}
113284 +
113285 +// MARK_NOT_INTENTIONAL
113286 +static bool is_end_intentional_intentional_attr(const_tree decl, unsigned int argnum)
113287 +{
113288 + const_tree param_head;
113289 +
113290 + if (argnum == 0)
113291 + return false;
113292 +
113293 + param_head = get_attribute_param(decl);
113294 + if (param_head == NULL_TREE)
113295 + return false;
113296 +
113297 + if (!TREE_INT_CST_LOW(TREE_VALUE(param_head)))
113298 + return true;
113299 + return false;
113300 +}
113301 +
113302 +// MARK_YES
113303 +static bool is_yes_intentional_attr(const_tree decl, unsigned int argnum)
113304 +{
113305 + tree param, param_head;
113306 +
113307 + if (argnum == 0)
113308 + return false;
113309 +
113310 + param_head = get_attribute_param(decl);
113311 + for (param = param_head; param; param = TREE_CHAIN(param))
113312 + if (argnum == TREE_INT_CST_LOW(TREE_VALUE(param)))
113313 + return true;
113314 + return false;
113315 +}
113316 +
113317 +static const char *get_asm_string(const_gimple stmt)
113318 +{
113319 + if (!stmt)
113320 + return NULL;
113321 + if (gimple_code(stmt) != GIMPLE_ASM)
113322 + return NULL;
113323 +
113324 + return gimple_asm_string(stmt);
113325 +}
113326 +
113327 +static bool is_size_overflow_intentional_asm_turn_off(const_gimple stmt)
113328 +{
113329 + const char *str;
113330 +
113331 + str = get_asm_string(stmt);
113332 + if (!str)
113333 + return false;
113334 + return !strncmp(str, TURN_OFF_ASM_STR, sizeof(TURN_OFF_ASM_STR) - 1);
113335 +}
113336 +
113337 +static bool is_size_overflow_intentional_asm_yes(const_gimple stmt)
113338 +{
113339 + const char *str;
113340 +
113341 + str = get_asm_string(stmt);
113342 + if (!str)
113343 + return false;
113344 + return !strncmp(str, YES_ASM_STR, sizeof(YES_ASM_STR) - 1);
113345 +}
113346 +
113347 +static bool is_size_overflow_asm(const_gimple stmt)
113348 +{
113349 + const char *str;
113350 +
113351 + str = get_asm_string(stmt);
113352 + if (!str)
113353 + return false;
113354 + return !strncmp(str, OK_ASM_STR, sizeof(OK_ASM_STR) - 1);
113355 +}
113356 +
113357 +static void print_missing_intentional(enum mark callee_attr, enum mark caller_attr, const_tree decl, unsigned int argnum)
113358 +{
113359 + location_t loc;
113360 +
113361 + if (caller_attr == MARK_NO || caller_attr == MARK_NOT_INTENTIONAL || caller_attr == MARK_TURN_OFF)
113362 + return;
113363 +
113364 + if (callee_attr == MARK_NOT_INTENTIONAL || callee_attr == MARK_YES)
113365 + return;
113366 +
113367 + loc = DECL_SOURCE_LOCATION(decl);
113368 + inform(loc, "The intentional_overflow attribute is missing from +%s+%u+", NAME(decl), argnum);
113369 +}
113370 +
113371 +/* Get the type of the intentional_overflow attribute of a node
113372 + * * MARK_TURN_OFF
113373 + * * MARK_YES
113374 + * * MARK_NO
113375 + * * MARK_NOT_INTENTIONAL
113376 + */
113377 +static enum mark get_intentional_attr_type(const_tree node)
113378 +{
113379 + const_tree cur_decl;
113380 +
113381 + if (node == NULL_TREE)
113382 + return MARK_NO;
113383 +
113384 + switch (TREE_CODE(node)) {
113385 + case COMPONENT_REF:
113386 + cur_decl = search_field_decl(node);
113387 + if (is_turn_off_intentional_attr(cur_decl))
113388 + return MARK_TURN_OFF;
113389 + if (is_end_intentional_intentional_attr(cur_decl, 1))
113390 + return MARK_YES;
113391 + break;
113392 + case PARM_DECL: {
113393 + unsigned int argnum;
113394 +
113395 + cur_decl = DECL_ORIGIN(current_function_decl);
113396 + argnum = find_arg_number_tree(node, cur_decl);
113397 + if (argnum == CANNOT_FIND_ARG)
113398 + return MARK_NO;
113399 + if (is_yes_intentional_attr(cur_decl, argnum))
113400 + return MARK_YES;
113401 + if (is_end_intentional_intentional_attr(cur_decl, argnum))
113402 + return MARK_NOT_INTENTIONAL;
113403 + break;
113404 + }
113405 + case FUNCTION_DECL:
113406 + if (is_turn_off_intentional_attr(DECL_ORIGIN(node)))
113407 + return MARK_TURN_OFF;
113408 + break;
113409 + default:
113410 + break;
113411 + }
113412 + return MARK_NO;
113413 +}
113414 +
113415 +// Search for the intentional_overflow attribute on the last nodes
113416 +static enum mark search_last_nodes_intentional(struct interesting_node *cur_node)
113417 +{
113418 + unsigned int i;
113419 + tree last_node;
113420 + enum mark mark = MARK_NO;
113421 +
113422 +#if BUILDING_GCC_VERSION == 4005
113423 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113424 + last_node = VEC_index(tree, cur_node->last_nodes, i);
113425 +#elif BUILDING_GCC_VERSION <= 4007
113426 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, last_node) {
113427 +#else
113428 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, last_node) {
113429 +#endif
113430 + mark = get_intentional_attr_type(last_node);
113431 + if (mark != MARK_NO)
113432 + break;
113433 + }
113434 + return mark;
113435 +}
113436 +
113437 +/* Check the intentional kind of size_overflow asm stmt (created by the gimple pass) and
113438 + * set the appropriate intentional_overflow type. Delete the asm stmt in the end.
113439 + */
113440 +static bool is_intentional_attribute_from_gimple(struct interesting_node *cur_node)
113441 +{
113442 + if (!cur_node->intentional_mark_from_gimple)
113443 + return false;
113444 +
113445 + if (is_size_overflow_intentional_asm_yes(cur_node->intentional_mark_from_gimple))
113446 + cur_node->intentional_attr_cur_fndecl = MARK_YES;
113447 + else
113448 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
113449 +
113450 + // skip param decls
113451 + if (gimple_asm_noutputs(cur_node->intentional_mark_from_gimple) == 0)
113452 + return true;
113453 + return true;
113454 +}
113455 +
113456 +/* Search intentional_overflow attribute on caller and on callee too.
113457 + * 0</MARK_YES: no dup, search size_overflow and intentional_overflow attributes
113458 + * 0/MARK_NOT_INTENTIONAL: no dup, search size_overflow attribute (int)
113459 + * -1/MARK_TURN_OFF: no dup, no search, current_function_decl -> no dup
113460 +*/
113461 +static void check_intentional_attribute_ipa(struct interesting_node *cur_node)
113462 +{
113463 + const_tree fndecl;
113464 +
113465 + if (is_intentional_attribute_from_gimple(cur_node))
113466 + return;
113467 +
113468 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
113469 + cur_node->intentional_attr_cur_fndecl = MARK_TURN_OFF;
113470 + return;
113471 + }
113472 +
113473 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASM) {
113474 + cur_node->intentional_attr_cur_fndecl = MARK_NOT_INTENTIONAL;
113475 + return;
113476 + }
113477 +
113478 + if (gimple_code(cur_node->first_stmt) == GIMPLE_ASSIGN)
113479 + return;
113480 +
113481 + fndecl = get_interesting_orig_fndecl(cur_node->first_stmt, cur_node->num);
113482 + if (is_turn_off_intentional_attr(fndecl)) {
113483 + cur_node->intentional_attr_decl = MARK_TURN_OFF;
113484 + return;
113485 + }
113486 +
113487 + if (is_end_intentional_intentional_attr(fndecl, cur_node->num))
113488 + cur_node->intentional_attr_decl = MARK_NOT_INTENTIONAL;
113489 + else if (is_yes_intentional_attr(fndecl, cur_node->num))
113490 + cur_node->intentional_attr_decl = MARK_YES;
113491 +
113492 + cur_node->intentional_attr_cur_fndecl = search_last_nodes_intentional(cur_node);
113493 + print_missing_intentional(cur_node->intentional_attr_decl, cur_node->intentional_attr_cur_fndecl, cur_node->fndecl, cur_node->num);
113494 +}
113495 +
113496 +// e.g., 3.8.2, 64, arch/x86/ia32/ia32_signal.c copy_siginfo_from_user32(): compat_ptr() u32 max
113497 +static bool skip_asm(const_tree arg)
113498 +{
113499 + gimple def_stmt = get_def_stmt(arg);
113500 +
113501 + if (!def_stmt || !gimple_assign_cast_p(def_stmt))
113502 + return false;
113503 +
113504 + def_stmt = get_def_stmt(gimple_assign_rhs1(def_stmt));
113505 + return def_stmt && gimple_code(def_stmt) == GIMPLE_ASM;
113506 +}
113507 +
113508 +static void walk_use_def_phi(struct pointer_set_t *visited, struct interesting_node *cur_node, tree result)
113509 +{
113510 + gimple phi = get_def_stmt(result);
113511 + unsigned int i, n = gimple_phi_num_args(phi);
113512 +
113513 + pointer_set_insert(visited, phi);
113514 + for (i = 0; i < n; i++) {
113515 + tree arg = gimple_phi_arg_def(phi, i);
113516 +
113517 + walk_use_def(visited, cur_node, arg);
113518 + }
113519 +}
113520 +
113521 +static void walk_use_def_binary(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
113522 +{
113523 + gimple def_stmt = get_def_stmt(lhs);
113524 + tree rhs1, rhs2;
113525 +
113526 + rhs1 = gimple_assign_rhs1(def_stmt);
113527 + rhs2 = gimple_assign_rhs2(def_stmt);
113528 +
113529 + walk_use_def(visited, cur_node, rhs1);
113530 + walk_use_def(visited, cur_node, rhs2);
113531 +}
113532 +
113533 +static void insert_last_node(struct interesting_node *cur_node, tree node)
113534 +{
113535 + unsigned int i;
113536 + tree element;
113537 + enum tree_code code;
113538 +
113539 + gcc_assert(node != NULL_TREE);
113540 +
113541 + if (is_gimple_constant(node))
113542 + return;
113543 +
113544 + code = TREE_CODE(node);
113545 + if (code == VAR_DECL) {
113546 + node = DECL_ORIGIN(node);
113547 + code = TREE_CODE(node);
113548 + }
113549 +
113550 + if (code != PARM_DECL && code != FUNCTION_DECL && code != COMPONENT_REF)
113551 + return;
113552 +
113553 +#if BUILDING_GCC_VERSION == 4005
113554 + for (i = 0; i < VEC_length(tree, cur_node->last_nodes); i++) {
113555 + element = VEC_index(tree, cur_node->last_nodes, i);
113556 +#elif BUILDING_GCC_VERSION <= 4007
113557 + FOR_EACH_VEC_ELT(tree, cur_node->last_nodes, i, element) {
113558 +#else
113559 + FOR_EACH_VEC_ELT(*cur_node->last_nodes, i, element) {
113560 +#endif
113561 + if (operand_equal_p(node, element, 0))
113562 + return;
113563 + }
113564 +
113565 +#if BUILDING_GCC_VERSION <= 4007
113566 + gcc_assert(VEC_length(tree, cur_node->last_nodes) < VEC_LEN);
113567 + VEC_safe_push(tree, gc, cur_node->last_nodes, node);
113568 +#else
113569 + gcc_assert(cur_node->last_nodes->length() < VEC_LEN);
113570 + vec_safe_push(cur_node->last_nodes, node);
113571 +#endif
113572 +}
113573 +
113574 +// a size_overflow asm stmt in the control flow doesn't stop the recursion
113575 +static void handle_asm_stmt(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs, const_gimple stmt)
113576 +{
113577 + if (!is_size_overflow_asm(stmt))
113578 + walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
113579 +}
113580 +
113581 +/* collect the parm_decls and fndecls (for checking a missing size_overflow attribute (ret or arg) or intentional_overflow)
113582 + * and component refs (for checking the intentional_overflow attribute).
113583 + */
113584 +static void walk_use_def(struct pointer_set_t *visited, struct interesting_node *cur_node, tree lhs)
113585 +{
113586 + const_gimple def_stmt;
113587 +
113588 + if (TREE_CODE(lhs) != SSA_NAME) {
113589 + insert_last_node(cur_node, lhs);
113590 + return;
113591 + }
113592 +
113593 + def_stmt = get_def_stmt(lhs);
113594 + if (!def_stmt)
113595 + return;
113596 +
113597 + if (pointer_set_insert(visited, def_stmt))
113598 + return;
113599 +
113600 + switch (gimple_code(def_stmt)) {
113601 + case GIMPLE_NOP:
113602 + return walk_use_def(visited, cur_node, SSA_NAME_VAR(lhs));
113603 + case GIMPLE_ASM:
113604 + return handle_asm_stmt(visited, cur_node, lhs, def_stmt);
113605 + case GIMPLE_CALL: {
113606 + tree fndecl = gimple_call_fndecl(def_stmt);
113607 +
113608 + if (fndecl == NULL_TREE)
113609 + return;
113610 + insert_last_node(cur_node, fndecl);
113611 + return;
113612 + }
113613 + case GIMPLE_PHI:
113614 + return walk_use_def_phi(visited, cur_node, lhs);
113615 + case GIMPLE_ASSIGN:
113616 + switch (gimple_num_ops(def_stmt)) {
113617 + case 2:
113618 + return walk_use_def(visited, cur_node, gimple_assign_rhs1(def_stmt));
113619 + case 3:
113620 + return walk_use_def_binary(visited, cur_node, lhs);
113621 + }
113622 + default:
113623 + debug_gimple_stmt((gimple)def_stmt);
113624 + error("%s: unknown gimple code", __func__);
113625 + gcc_unreachable();
113626 + }
113627 +}
113628 +
113629 +// Collect all the last nodes for checking the intentional_overflow and size_overflow attributes
113630 +static void set_last_nodes(struct interesting_node *cur_node)
113631 +{
113632 + struct pointer_set_t *visited;
113633 +
113634 + visited = pointer_set_create();
113635 + walk_use_def(visited, cur_node, cur_node->node);
113636 + pointer_set_destroy(visited);
113637 +}
113638 +
113639 +enum precond {
113640 + NO_ATTRIBUTE_SEARCH, NO_CHECK_INSERT, NONE
113641 +};
113642 +
113643 +/* 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.
113644 + * There is only missing size_overflow attribute checking if the intentional_overflow attribute is the mark_no type.
113645 + * Stmt duplication is unnecessary if there are no binary/ternary assignements or if the unary assignment isn't a cast.
113646 + * 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.
113647 + */
113648 +static enum precond check_preconditions(struct interesting_node *cur_node)
113649 +{
113650 + bool interesting_conditions[3] = {false, false, false};
113651 +
113652 + set_last_nodes(cur_node);
113653 +
113654 + check_intentional_attribute_ipa(cur_node);
113655 + if (cur_node->intentional_attr_decl == MARK_TURN_OFF || cur_node->intentional_attr_cur_fndecl == MARK_TURN_OFF)
113656 + return NO_ATTRIBUTE_SEARCH;
113657 +
113658 + search_interesting_conditions(cur_node, interesting_conditions);
113659 +
113660 + // error code
113661 + if (interesting_conditions[CAST] && interesting_conditions[FROM_CONST] && !interesting_conditions[NOT_UNARY])
113662 + return NO_ATTRIBUTE_SEARCH;
113663 +
113664 + // unnecessary overflow check
113665 + if (!interesting_conditions[CAST] && !interesting_conditions[NOT_UNARY])
113666 + return NO_CHECK_INSERT;
113667 +
113668 + if (cur_node->intentional_attr_cur_fndecl != MARK_NO)
113669 + return NO_CHECK_INSERT;
113670 +
113671 + return NONE;
113672 +}
113673 +
113674 +/* This function calls the main recursion function (expand) that duplicates the stmts. Before that it checks the intentional_overflow attribute and asm stmts,
113675 + * 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
113676 + * in the original stmt (first stmt) and it inserts the overflow check for the arg of the callee or for the return value.
113677 + */
113678 +static struct next_cgraph_node *handle_interesting_stmt(struct next_cgraph_node *cnodes, struct interesting_node *cur_node, struct cgraph_node *caller_node)
113679 +{
113680 + enum precond ret;
113681 + struct pointer_set_t *visited;
113682 + tree new_node, orig_node = cur_node->node;
113683 +
113684 + ret = check_preconditions(cur_node);
113685 + if (ret == NO_ATTRIBUTE_SEARCH)
113686 + return cnodes;
113687 +
113688 + cnodes = search_overflow_attribute(cnodes, cur_node);
113689 +
113690 + if (ret == NO_CHECK_INSERT)
113691 + return cnodes;
113692 +
113693 + visited = pointer_set_create();
113694 + new_node = expand(visited, caller_node, orig_node);
113695 + pointer_set_destroy(visited);
113696 +
113697 + if (new_node == NULL_TREE)
113698 + return cnodes;
113699 +
113700 + change_orig_node(cur_node, new_node);
113701 + check_size_overflow(caller_node, cur_node->first_stmt, TREE_TYPE(new_node), new_node, orig_node, BEFORE_STMT);
113702 +
113703 + return cnodes;
113704 +}
113705 +
113706 +// Check visited interesting nodes.
113707 +static bool is_in_interesting_node(struct interesting_node *head, const_gimple first_stmt, const_tree node, unsigned int num)
113708 +{
113709 + struct interesting_node *cur;
113710 +
113711 + for (cur = head; cur; cur = cur->next) {
113712 + if (!operand_equal_p(node, cur->node, 0))
113713 + continue;
113714 + if (num != cur->num)
113715 + continue;
113716 + if (first_stmt == cur->first_stmt)
113717 + return true;
113718 + }
113719 + return false;
113720 +}
113721 +
113722 +/* Create an interesting node. The ipa pass starts to duplicate from these stmts.
113723 + 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
113724 + 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
113725 + the intentional_overflow attribute check. They are collected by set_last_nodes().
113726 + num: arg count of a call stmt or 0 when it is a ret
113727 + node: the recursion starts from here, it is a call arg or a return value
113728 + 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.
113729 + intentional_attr_decl: intentional_overflow attribute of the callee function
113730 + intentional_attr_cur_fndecl: intentional_overflow attribute of the caller function
113731 + intentional_mark_from_gimple: the intentional overflow type of size_overflow asm stmt from gimple if it exists
113732 + */
113733 +static struct interesting_node *create_new_interesting_node(struct interesting_node *head, gimple first_stmt, tree node, unsigned int num, gimple asm_stmt)
113734 +{
113735 + struct interesting_node *new_node;
113736 + tree fndecl;
113737 + enum gimple_code code;
113738 +
113739 + gcc_assert(node != NULL_TREE);
113740 + code = gimple_code(first_stmt);
113741 + gcc_assert(code == GIMPLE_CALL || code == GIMPLE_ASM || code == GIMPLE_ASSIGN || code == GIMPLE_RETURN);
113742 +
113743 + if (num == CANNOT_FIND_ARG)
113744 + return head;
113745 +
113746 + if (skip_types(node))
113747 + return head;
113748 +
113749 + if (skip_asm(node))
113750 + return head;
113751 +
113752 + if (is_gimple_call(first_stmt))
113753 + fndecl = gimple_call_fndecl(first_stmt);
113754 + else
113755 + fndecl = current_function_decl;
113756 +
113757 + if (fndecl == NULL_TREE)
113758 + return head;
113759 +
113760 + if (is_in_interesting_node(head, first_stmt, node, num))
113761 + return head;
113762 +
113763 + new_node = (struct interesting_node *)xmalloc(sizeof(*new_node));
113764 +
113765 + new_node->next = NULL;
113766 + new_node->first_stmt = first_stmt;
113767 +#if BUILDING_GCC_VERSION <= 4007
113768 + new_node->last_nodes = VEC_alloc(tree, gc, VEC_LEN);
113769 +#else
113770 + vec_alloc(new_node->last_nodes, VEC_LEN);
113771 +#endif
113772 + new_node->num = num;
113773 + new_node->node = node;
113774 + new_node->fndecl = fndecl;
113775 + new_node->intentional_attr_decl = MARK_NO;
113776 + new_node->intentional_attr_cur_fndecl = MARK_NO;
113777 + new_node->intentional_mark_from_gimple = asm_stmt;
113778 +
113779 + if (!head)
113780 + return new_node;
113781 +
113782 + new_node->next = head;
113783 + return new_node;
113784 +}
113785 +
113786 +/* 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).
113787 + * If the ret stmt is in the next cgraph node list then it's an interesting ret.
113788 + */
113789 +static struct interesting_node *handle_stmt_by_cgraph_nodes_ret(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
113790 +{
113791 + struct next_cgraph_node *cur_node;
113792 + tree ret = gimple_return_retval(stmt);
113793 +
113794 + if (ret == NULL_TREE)
113795 + return head;
113796 +
113797 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
113798 + if (!operand_equal_p(cur_node->callee_fndecl, DECL_ORIGIN(current_function_decl), 0))
113799 + continue;
113800 + if (cur_node->num == 0)
113801 + head = create_new_interesting_node(head, stmt, ret, 0, NOT_INTENTIONAL_ASM);
113802 + }
113803 +
113804 + return head;
113805 +}
113806 +
113807 +/* 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).
113808 + * If the call stmt is in the next cgraph node list then it's an interesting call.
113809 + */
113810 +static struct interesting_node *handle_stmt_by_cgraph_nodes_call(struct interesting_node *head, gimple stmt, struct next_cgraph_node *next_node)
113811 +{
113812 + unsigned int argnum;
113813 + tree fndecl, arg;
113814 + struct next_cgraph_node *cur_node;
113815 +
113816 + fndecl = gimple_call_fndecl(stmt);
113817 + if (fndecl == NULL_TREE)
113818 + return head;
113819 +
113820 + for (cur_node = next_node; cur_node; cur_node = cur_node->next) {
113821 + if (!operand_equal_p(cur_node->callee_fndecl, fndecl, 0))
113822 + continue;
113823 + argnum = get_correct_arg_count(cur_node->num, fndecl);
113824 + gcc_assert(argnum != CANNOT_FIND_ARG);
113825 + if (argnum == 0)
113826 + continue;
113827 +
113828 + arg = gimple_call_arg(stmt, argnum - 1);
113829 + head = create_new_interesting_node(head, stmt, arg, argnum, NOT_INTENTIONAL_ASM);
113830 + }
113831 +
113832 + return head;
113833 +}
113834 +
113835 +static unsigned int check_ops(const_tree orig_node, const_tree node, unsigned int ret_count)
113836 +{
113837 + if (!operand_equal_p(orig_node, node, 0))
113838 + return WRONG_NODE;
113839 + if (skip_types(node))
113840 + return WRONG_NODE;
113841 + return ret_count;
113842 +}
113843 +
113844 +// Get the index of the rhs node in an assignment
113845 +static unsigned int get_assign_ops_count(const_gimple stmt, tree node)
113846 +{
113847 + const_tree rhs1, rhs2;
113848 + unsigned int ret;
113849 +
113850 + gcc_assert(stmt);
113851 + gcc_assert(is_gimple_assign(stmt));
113852 +
113853 + rhs1 = gimple_assign_rhs1(stmt);
113854 + gcc_assert(rhs1 != NULL_TREE);
113855 +
113856 + switch (gimple_num_ops(stmt)) {
113857 + case 2:
113858 + return check_ops(node, rhs1, 1);
113859 + case 3:
113860 + ret = check_ops(node, rhs1, 1);
113861 + if (ret != WRONG_NODE)
113862 + return ret;
113863 +
113864 + rhs2 = gimple_assign_rhs2(stmt);
113865 + gcc_assert(rhs2 != NULL_TREE);
113866 + return check_ops(node, rhs2, 2);
113867 + default:
113868 + gcc_unreachable();
113869 + }
113870 +}
113871 +
113872 +// Find the correct arg number of a call stmt. It is needed when the interesting function is a cloned function.
113873 +static unsigned int find_arg_number_gimple(const_tree arg, const_gimple stmt)
113874 +{
113875 + unsigned int i;
113876 +
113877 + if (gimple_call_fndecl(stmt) == NULL_TREE)
113878 + return CANNOT_FIND_ARG;
113879 +
113880 + for (i = 0; i < gimple_call_num_args(stmt); i++) {
113881 + tree node;
113882 +
113883 + node = gimple_call_arg(stmt, i);
113884 + if (!operand_equal_p(arg, node, 0))
113885 + continue;
113886 + if (!skip_types(node))
113887 + return i + 1;
113888 + }
113889 +
113890 + return CANNOT_FIND_ARG;
113891 +}
113892 +
113893 +/* starting from the size_overflow asm stmt collect interesting stmts. They can be
113894 + * any of return, call or assignment stmts (because of inlining).
113895 + */
113896 +static struct interesting_node *get_interesting_ret_or_call(struct pointer_set_t *visited, struct interesting_node *head, tree node, gimple intentional_asm)
113897 +{
113898 + use_operand_p use_p;
113899 + imm_use_iterator imm_iter;
113900 + unsigned int argnum;
113901 +
113902 + gcc_assert(TREE_CODE(node) == SSA_NAME);
113903 +
113904 + if (pointer_set_insert(visited, node))
113905 + return head;
113906 +
113907 + FOR_EACH_IMM_USE_FAST(use_p, imm_iter, node) {
113908 + gimple stmt = USE_STMT(use_p);
113909 +
113910 + if (stmt == NULL)
113911 + return head;
113912 + if (is_gimple_debug(stmt))
113913 + continue;
113914 +
113915 + switch (gimple_code(stmt)) {
113916 + case GIMPLE_CALL:
113917 + argnum = find_arg_number_gimple(node, stmt);
113918 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
113919 + break;
113920 + case GIMPLE_RETURN:
113921 + head = create_new_interesting_node(head, stmt, node, 0, intentional_asm);
113922 + break;
113923 + case GIMPLE_ASSIGN:
113924 + argnum = get_assign_ops_count(stmt, node);
113925 + head = create_new_interesting_node(head, stmt, node, argnum, intentional_asm);
113926 + break;
113927 + case GIMPLE_PHI: {
113928 + tree result = gimple_phi_result(stmt);
113929 + head = get_interesting_ret_or_call(visited, head, result, intentional_asm);
113930 + break;
113931 + }
113932 + case GIMPLE_ASM:
113933 + if (gimple_asm_noutputs(stmt) != 0)
113934 + break;
113935 + if (!is_size_overflow_asm(stmt))
113936 + break;
113937 + head = create_new_interesting_node(head, stmt, node, 1, intentional_asm);
113938 + break;
113939 + case GIMPLE_COND:
113940 + case GIMPLE_SWITCH:
113941 + break;
113942 + default:
113943 + debug_gimple_stmt(stmt);
113944 + gcc_unreachable();
113945 + break;
113946 + }
113947 + }
113948 + return head;
113949 +}
113950 +
113951 +static void remove_size_overflow_asm(gimple stmt)
113952 +{
113953 + gimple_stmt_iterator gsi;
113954 + tree input, output;
113955 +
113956 + if (!is_size_overflow_asm(stmt))
113957 + return;
113958 +
113959 + if (gimple_asm_noutputs(stmt) == 0) {
113960 + gsi = gsi_for_stmt(stmt);
113961 + gsi_remove(&gsi, true);
113962 + return;
113963 + }
113964 +
113965 + input = gimple_asm_input_op(stmt, 0);
113966 + output = gimple_asm_output_op(stmt, 0);
113967 + replace_size_overflow_asm_with_assign(stmt, TREE_VALUE(output), TREE_VALUE(input));
113968 +}
113969 +
113970 +/* handle the size_overflow asm stmts from the gimple pass and collect the interesting stmts.
113971 + * If the asm stmt is a parm_decl kind (noutputs == 0) then remove it.
113972 + * If it is a simple asm stmt then replace it with an assignment from the asm input to the asm output.
113973 + */
113974 +static struct interesting_node *handle_stmt_by_size_overflow_asm(gimple stmt, struct interesting_node *head)
113975 +{
113976 + const_tree output;
113977 + struct pointer_set_t *visited;
113978 + gimple intentional_asm = NOT_INTENTIONAL_ASM;
113979 +
113980 + if (!is_size_overflow_asm(stmt))
113981 + return head;
113982 +
113983 + if (is_size_overflow_intentional_asm_yes(stmt) || is_size_overflow_intentional_asm_turn_off(stmt))
113984 + intentional_asm = stmt;
113985 +
113986 + gcc_assert(gimple_asm_ninputs(stmt) == 1);
113987 +
113988 + if (gimple_asm_noutputs(stmt) == 0 && is_size_overflow_intentional_asm_turn_off(stmt))
113989 + return head;
113990 +
113991 + if (gimple_asm_noutputs(stmt) == 0) {
113992 + const_tree input;
113993 +
113994 + if (!is_size_overflow_intentional_asm_turn_off(stmt))
113995 + return head;
113996 +
113997 + input = gimple_asm_input_op(stmt, 0);
113998 + remove_size_overflow_asm(stmt);
113999 + if (is_gimple_constant(TREE_VALUE(input)))
114000 + return head;
114001 + visited = pointer_set_create();
114002 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(input), intentional_asm);
114003 + pointer_set_destroy(visited);
114004 + return head;
114005 + }
114006 +
114007 + if (!is_size_overflow_intentional_asm_yes(stmt) && !is_size_overflow_intentional_asm_turn_off(stmt))
114008 + remove_size_overflow_asm(stmt);
114009 +
114010 + visited = pointer_set_create();
114011 + output = gimple_asm_output_op(stmt, 0);
114012 + head = get_interesting_ret_or_call(visited, head, TREE_VALUE(output), intentional_asm);
114013 + pointer_set_destroy(visited);
114014 + return head;
114015 +}
114016 +
114017 +/* Iterate over all the stmts of a function and look for the size_overflow asm stmts (they were created in the gimple pass)
114018 + * or a call stmt or a return stmt and store them in the interesting_node list
114019 + */
114020 +static struct interesting_node *collect_interesting_stmts(struct next_cgraph_node *next_node)
114021 +{
114022 + basic_block bb;
114023 + struct interesting_node *head = NULL;
114024 +
114025 + FOR_ALL_BB(bb) {
114026 + gimple_stmt_iterator gsi;
114027 +
114028 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114029 + enum gimple_code code;
114030 + gimple stmt = gsi_stmt(gsi);
114031 +
114032 + code = gimple_code(stmt);
114033 +
114034 + if (code == GIMPLE_ASM)
114035 + head = handle_stmt_by_size_overflow_asm(stmt, head);
114036 +
114037 + if (!next_node)
114038 + continue;
114039 + if (code == GIMPLE_CALL)
114040 + head = handle_stmt_by_cgraph_nodes_call(head, stmt, next_node);
114041 + if (code == GIMPLE_RETURN)
114042 + head = handle_stmt_by_cgraph_nodes_ret(head, stmt, next_node);
114043 + }
114044 + }
114045 + return head;
114046 +}
114047 +
114048 +static void set_current_function_decl(tree fndecl)
114049 +{
114050 + gcc_assert(fndecl != NULL_TREE);
114051 +
114052 + push_cfun(DECL_STRUCT_FUNCTION(fndecl));
114053 + calculate_dominance_info(CDI_DOMINATORS);
114054 + current_function_decl = fndecl;
114055 +}
114056 +
114057 +static void unset_current_function_decl(void)
114058 +{
114059 + free_dominance_info(CDI_DOMINATORS);
114060 + pop_cfun();
114061 + current_function_decl = NULL_TREE;
114062 +}
114063 +
114064 +static void free_interesting_node(struct interesting_node *head)
114065 +{
114066 + struct interesting_node *cur;
114067 +
114068 + while (head) {
114069 + cur = head->next;
114070 +#if BUILDING_GCC_VERSION <= 4007
114071 + VEC_free(tree, gc, head->last_nodes);
114072 +#else
114073 + vec_free(head->last_nodes);
114074 +#endif
114075 + free(head);
114076 + head = cur;
114077 + }
114078 +}
114079 +
114080 +static struct visited *insert_visited_function(struct visited *head, struct interesting_node *cur_node)
114081 +{
114082 + struct visited *new_visited;
114083 +
114084 + new_visited = (struct visited *)xmalloc(sizeof(*new_visited));
114085 + new_visited->fndecl = cur_node->fndecl;
114086 + new_visited->num = cur_node->num;
114087 + new_visited->first_stmt = cur_node->first_stmt;
114088 + new_visited->next = NULL;
114089 +
114090 + if (!head)
114091 + return new_visited;
114092 +
114093 + new_visited->next = head;
114094 + return new_visited;
114095 +}
114096 +
114097 +/* 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
114098 + * it is a visited function.
114099 + */
114100 +static bool is_visited_function(struct visited *head, struct interesting_node *cur_node)
114101 +{
114102 + struct visited *cur;
114103 +
114104 + if (!head)
114105 + return false;
114106 +
114107 + for (cur = head; cur; cur = cur->next) {
114108 + if (!operand_equal_p(cur_node->fndecl, cur->fndecl, 0))
114109 + continue;
114110 + if (cur_node->num != cur->num)
114111 + continue;
114112 + if (cur_node->first_stmt == cur->first_stmt)
114113 + return true;
114114 + }
114115 + return false;
114116 +}
114117 +
114118 +static void free_next_cgraph_node(struct next_cgraph_node *head)
114119 +{
114120 + struct next_cgraph_node *cur;
114121 +
114122 + while (head) {
114123 + cur = head->next;
114124 + free(head);
114125 + head = cur;
114126 + }
114127 +}
114128 +
114129 +static void remove_all_size_overflow_asm(void)
114130 +{
114131 + basic_block bb;
114132 +
114133 + FOR_ALL_BB(bb) {
114134 + gimple_stmt_iterator si;
114135 +
114136 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
114137 + remove_size_overflow_asm(gsi_stmt(si));
114138 + }
114139 +}
114140 +
114141 +/* Main recursive walk of the ipa pass: iterate over the collected interesting stmts in a function
114142 + * (they are interesting if they have an associated size_overflow asm stmt) and recursively walk
114143 + * the newly collected interesting functions (they are interesting if there is control flow between
114144 + * the interesting stmts and them).
114145 + */
114146 +static struct visited *handle_function(struct cgraph_node *node, struct next_cgraph_node *next_node, struct visited *visited)
114147 +{
114148 + struct interesting_node *head, *cur_node;
114149 + struct next_cgraph_node *cur_cnodes, *cnodes_head = NULL;
114150 +
114151 +#if BUILDING_GCC_VERSION <= 4007
114152 + set_current_function_decl(node->decl);
114153 +#else
114154 + set_current_function_decl(node->symbol.decl);
114155 +#endif
114156 + call_count = 0;
114157 +
114158 + head = collect_interesting_stmts(next_node);
114159 + for (cur_node = head; cur_node; cur_node = cur_node->next) {
114160 + if (is_visited_function(visited, cur_node))
114161 + continue;
114162 + cnodes_head = handle_interesting_stmt(cnodes_head, cur_node, node);
114163 + visited = insert_visited_function(visited, cur_node);
114164 + }
114165 +
114166 + free_interesting_node(head);
114167 + remove_all_size_overflow_asm();
114168 + unset_current_function_decl();
114169 +
114170 + for (cur_cnodes = cnodes_head; cur_cnodes; cur_cnodes = cur_cnodes->next)
114171 + visited = handle_function(cur_cnodes->current_function, cur_cnodes, visited);
114172 +
114173 + free_next_cgraph_node(cnodes_head);
114174 + return visited;
114175 +}
114176 +
114177 +static void free_visited(struct visited *head)
114178 +{
114179 + struct visited *cur;
114180 +
114181 + while (head) {
114182 + cur = head->next;
114183 + free(head);
114184 + head = cur;
114185 + }
114186 +}
114187 +
114188 +// erase the local flag
114189 +static void set_plf_false(void)
114190 +{
114191 + basic_block bb;
114192 +
114193 + FOR_ALL_BB(bb) {
114194 + gimple_stmt_iterator si;
114195 +
114196 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
114197 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
114198 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
114199 + gimple_set_plf(gsi_stmt(si), MY_STMT, false);
114200 + }
114201 +}
114202 +
114203 +#if BUILDING_GCC_VERSION <= 4006
114204 +static bool cgraph_function_with_gimple_body_p(struct cgraph_node *node)
114205 +{
114206 + return node->analyzed && !node->thunk.thunk_p && !node->alias;
114207 +}
114208 +
114209 +static struct cgraph_node *cgraph_first_function_with_gimple_body(void)
114210 +{
114211 + struct cgraph_node *node;
114212 +
114213 + for (node = cgraph_nodes; node; node = node->next) {
114214 + if (cgraph_function_with_gimple_body_p(node))
114215 + return node;
114216 + }
114217 + return NULL;
114218 +}
114219 +
114220 +static inline struct cgraph_node *cgraph_next_function_with_gimple_body(struct cgraph_node *node)
114221 +{
114222 + for (node = node->next; node; node = node->next) {
114223 + if (cgraph_function_with_gimple_body_p(node))
114224 + return node;
114225 + }
114226 + return NULL;
114227 +}
114228 +
114229 +#define FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) \
114230 + for ((node) = cgraph_first_function_with_gimple_body (); (node); \
114231 + (node) = cgraph_next_function_with_gimple_body (node))
114232 +
114233 +#endif
114234 +
114235 +// Main entry point of the ipa pass: erases the plf flag of all stmts and iterates over all the functions
114236 +static unsigned int search_function(void)
114237 +{
114238 + struct cgraph_node *node;
114239 + struct visited *visited = NULL;
114240 +
114241 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
114242 +#if BUILDING_GCC_VERSION <= 4007
114243 + set_current_function_decl(node->decl);
114244 +#else
114245 + set_current_function_decl(node->symbol.decl);
114246 +#endif
114247 + set_plf_false();
114248 + unset_current_function_decl();
114249 + }
114250 +
114251 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
114252 + gcc_assert(cgraph_function_flags_ready);
114253 +#if BUILDING_GCC_VERSION <= 4007
114254 + gcc_assert(node->reachable);
114255 +#endif
114256 +
114257 + visited = handle_function(node, NULL, visited);
114258 + }
114259 +
114260 + free_visited(visited);
114261 + return 0;
114262 +}
114263 +
114264 +static struct ipa_opt_pass_d pass_ipa = {
114265 + .pass = {
114266 + .type = SIMPLE_IPA_PASS,
114267 + .name = "size_overflow",
114268 +#if BUILDING_GCC_VERSION >= 4008
114269 + .optinfo_flags = OPTGROUP_NONE,
114270 +#endif
114271 + .gate = NULL,
114272 + .execute = search_function,
114273 + .sub = NULL,
114274 + .next = NULL,
114275 + .static_pass_number = 0,
114276 + .tv_id = TV_NONE,
114277 + .properties_required = 0,
114278 + .properties_provided = 0,
114279 + .properties_destroyed = 0,
114280 + .todo_flags_start = 0,
114281 + .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,
114282 + },
114283 + .generate_summary = NULL,
114284 + .write_summary = NULL,
114285 + .read_summary = NULL,
114286 +#if BUILDING_GCC_VERSION >= 4006
114287 + .write_optimization_summary = NULL,
114288 + .read_optimization_summary = NULL,
114289 +#endif
114290 + .stmt_fixup = NULL,
114291 + .function_transform_todo_flags_start = 0,
114292 + .function_transform = NULL,
114293 + .variable_transform = NULL,
114294 +};
114295 +
114296 +// data for the size_overflow asm stmt
114297 +struct asm_data {
114298 + gimple def_stmt;
114299 + tree input;
114300 + tree output;
114301 +};
114302 +
114303 +#if BUILDING_GCC_VERSION <= 4007
114304 +static VEC(tree, gc) *create_asm_io_list(tree string, tree io)
114305 +#else
114306 +static vec<tree, va_gc> *create_asm_io_list(tree string, tree io)
114307 +#endif
114308 +{
114309 + tree list;
114310 +#if BUILDING_GCC_VERSION <= 4007
114311 + VEC(tree, gc) *vec_list = NULL;
114312 +#else
114313 + vec<tree, va_gc> *vec_list = NULL;
114314 +#endif
114315 +
114316 + list = build_tree_list(NULL_TREE, string);
114317 + list = chainon(NULL_TREE, build_tree_list(list, io));
114318 +#if BUILDING_GCC_VERSION <= 4007
114319 + VEC_safe_push(tree, gc, vec_list, list);
114320 +#else
114321 + vec_safe_push(vec_list, list);
114322 +#endif
114323 + return vec_list;
114324 +}
114325 +
114326 +static void create_asm_stmt(const char *str, tree str_input, tree str_output, struct asm_data *asm_data)
114327 +{
114328 + gimple asm_stmt;
114329 + gimple_stmt_iterator gsi;
114330 +#if BUILDING_GCC_VERSION <= 4007
114331 + VEC(tree, gc) *input, *output = NULL;
114332 +#else
114333 + vec<tree, va_gc> *input, *output = NULL;
114334 +#endif
114335 +
114336 + input = create_asm_io_list(str_input, asm_data->input);
114337 +
114338 + if (asm_data->output)
114339 + output = create_asm_io_list(str_output, asm_data->output);
114340 +
114341 + asm_stmt = gimple_build_asm_vec(str, input, output, NULL, NULL);
114342 + gsi = gsi_for_stmt(asm_data->def_stmt);
114343 + gsi_insert_after(&gsi, asm_stmt, GSI_NEW_STMT);
114344 +
114345 + if (asm_data->output)
114346 + SSA_NAME_DEF_STMT(asm_data->output) = asm_stmt;
114347 +}
114348 +
114349 +static void replace_call_lhs(const struct asm_data *asm_data)
114350 +{
114351 + gimple_set_lhs(asm_data->def_stmt, asm_data->input);
114352 + update_stmt(asm_data->def_stmt);
114353 + SSA_NAME_DEF_STMT(asm_data->input) = asm_data->def_stmt;
114354 +}
114355 +
114356 +static enum mark search_intentional_phi(struct pointer_set_t *visited, const_tree result)
114357 +{
114358 + enum mark cur_fndecl_attr;
114359 + gimple phi = get_def_stmt(result);
114360 + unsigned int i, n = gimple_phi_num_args(phi);
114361 +
114362 + pointer_set_insert(visited, phi);
114363 + for (i = 0; i < n; i++) {
114364 + tree arg = gimple_phi_arg_def(phi, i);
114365 +
114366 + cur_fndecl_attr = search_intentional(visited, arg);
114367 + if (cur_fndecl_attr != MARK_NO)
114368 + return cur_fndecl_attr;
114369 + }
114370 + return MARK_NO;
114371 +}
114372 +
114373 +static enum mark search_intentional_binary(struct pointer_set_t *visited, const_tree lhs)
114374 +{
114375 + enum mark cur_fndecl_attr;
114376 + const_tree rhs1, rhs2;
114377 + gimple def_stmt = get_def_stmt(lhs);
114378 +
114379 + rhs1 = gimple_assign_rhs1(def_stmt);
114380 + rhs2 = gimple_assign_rhs2(def_stmt);
114381 +
114382 + cur_fndecl_attr = search_intentional(visited, rhs1);
114383 + if (cur_fndecl_attr != MARK_NO)
114384 + return cur_fndecl_attr;
114385 + return search_intentional(visited, rhs2);
114386 +}
114387 +
114388 +// Look up the intentional_overflow attribute on the caller and the callee functions.
114389 +static enum mark search_intentional(struct pointer_set_t *visited, const_tree lhs)
114390 +{
114391 + const_gimple def_stmt;
114392 +
114393 + if (TREE_CODE(lhs) != SSA_NAME)
114394 + return get_intentional_attr_type(lhs);
114395 +
114396 + def_stmt = get_def_stmt(lhs);
114397 + if (!def_stmt)
114398 + return MARK_NO;
114399 +
114400 + if (pointer_set_contains(visited, def_stmt))
114401 + return MARK_NO;
114402 +
114403 + switch (gimple_code(def_stmt)) {
114404 + case GIMPLE_NOP:
114405 + return search_intentional(visited, SSA_NAME_VAR(lhs));
114406 + case GIMPLE_ASM:
114407 + if (is_size_overflow_intentional_asm_turn_off(def_stmt))
114408 + return MARK_TURN_OFF;
114409 + return MARK_NO;
114410 + case GIMPLE_CALL:
114411 + return MARK_NO;
114412 + case GIMPLE_PHI:
114413 + return search_intentional_phi(visited, lhs);
114414 + case GIMPLE_ASSIGN:
114415 + switch (gimple_num_ops(def_stmt)) {
114416 + case 2:
114417 + return search_intentional(visited, gimple_assign_rhs1(def_stmt));
114418 + case 3:
114419 + return search_intentional_binary(visited, lhs);
114420 + }
114421 + case GIMPLE_RETURN:
114422 + return MARK_NO;
114423 + default:
114424 + debug_gimple_stmt((gimple)def_stmt);
114425 + error("%s: unknown gimple code", __func__);
114426 + gcc_unreachable();
114427 + }
114428 +}
114429 +
114430 +// Check the intentional_overflow attribute and create the asm comment string for the size_overflow asm stmt.
114431 +static enum mark check_intentional_attribute_gimple(const_tree arg, const_gimple stmt, unsigned int argnum)
114432 +{
114433 + const_tree fndecl;
114434 + struct pointer_set_t *visited;
114435 + enum mark cur_fndecl_attr, decl_attr = MARK_NO;
114436 +
114437 + fndecl = get_interesting_orig_fndecl(stmt, argnum);
114438 + if (is_end_intentional_intentional_attr(fndecl, argnum))
114439 + decl_attr = MARK_NOT_INTENTIONAL;
114440 + else if (is_yes_intentional_attr(fndecl, argnum))
114441 + decl_attr = MARK_YES;
114442 + else if (is_turn_off_intentional_attr(fndecl) || is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl))) {
114443 + return MARK_TURN_OFF;
114444 + }
114445 +
114446 + visited = pointer_set_create();
114447 + cur_fndecl_attr = search_intentional(visited, arg);
114448 + pointer_set_destroy(visited);
114449 +
114450 + switch (cur_fndecl_attr) {
114451 + case MARK_NO:
114452 + case MARK_TURN_OFF:
114453 + return cur_fndecl_attr;
114454 + default:
114455 + print_missing_intentional(decl_attr, cur_fndecl_attr, fndecl, argnum);
114456 + return MARK_YES;
114457 + }
114458 +}
114459 +
114460 +static void check_missing_size_overflow_attribute(tree var)
114461 +{
114462 + tree orig_fndecl;
114463 + unsigned int num;
114464 +
114465 + if (is_a_return_check(var))
114466 + orig_fndecl = DECL_ORIGIN(var);
114467 + else
114468 + orig_fndecl = DECL_ORIGIN(current_function_decl);
114469 +
114470 + num = get_function_num(var, orig_fndecl);
114471 + if (num == CANNOT_FIND_ARG)
114472 + return;
114473 +
114474 + is_missing_function(orig_fndecl, num);
114475 +}
114476 +
114477 +static void search_size_overflow_attribute_phi(struct pointer_set_t *visited, const_tree result)
114478 +{
114479 + gimple phi = get_def_stmt(result);
114480 + unsigned int i, n = gimple_phi_num_args(phi);
114481 +
114482 + pointer_set_insert(visited, phi);
114483 + for (i = 0; i < n; i++) {
114484 + tree arg = gimple_phi_arg_def(phi, i);
114485 +
114486 + search_size_overflow_attribute(visited, arg);
114487 + }
114488 +}
114489 +
114490 +static void search_size_overflow_attribute_binary(struct pointer_set_t *visited, const_tree lhs)
114491 +{
114492 + const_gimple def_stmt = get_def_stmt(lhs);
114493 + tree rhs1, rhs2;
114494 +
114495 + rhs1 = gimple_assign_rhs1(def_stmt);
114496 + rhs2 = gimple_assign_rhs2(def_stmt);
114497 +
114498 + search_size_overflow_attribute(visited, rhs1);
114499 + search_size_overflow_attribute(visited, rhs2);
114500 +}
114501 +
114502 +static void search_size_overflow_attribute(struct pointer_set_t *visited, tree lhs)
114503 +{
114504 + const_gimple def_stmt;
114505 +
114506 + if (TREE_CODE(lhs) == PARM_DECL) {
114507 + check_missing_size_overflow_attribute(lhs);
114508 + return;
114509 + }
114510 +
114511 + def_stmt = get_def_stmt(lhs);
114512 + if (!def_stmt)
114513 + return;
114514 +
114515 + if (pointer_set_insert(visited, def_stmt))
114516 + return;
114517 +
114518 + switch (gimple_code(def_stmt)) {
114519 + case GIMPLE_NOP:
114520 + return search_size_overflow_attribute(visited, SSA_NAME_VAR(lhs));
114521 + case GIMPLE_ASM:
114522 + return;
114523 + case GIMPLE_CALL: {
114524 + tree fndecl = gimple_call_fndecl(def_stmt);
114525 +
114526 + if (fndecl == NULL_TREE)
114527 + return;
114528 + check_missing_size_overflow_attribute(fndecl);
114529 + return;
114530 + }
114531 + case GIMPLE_PHI:
114532 + return search_size_overflow_attribute_phi(visited, lhs);
114533 + case GIMPLE_ASSIGN:
114534 + switch (gimple_num_ops(def_stmt)) {
114535 + case 2:
114536 + return search_size_overflow_attribute(visited, gimple_assign_rhs1(def_stmt));
114537 + case 3:
114538 + return search_size_overflow_attribute_binary(visited, lhs);
114539 + }
114540 + default:
114541 + debug_gimple_stmt((gimple)def_stmt);
114542 + error("%s: unknown gimple code", __func__);
114543 + gcc_unreachable();
114544 + }
114545 +}
114546 +
114547 +// Search missing entries in the hash table (invoked from the gimple pass)
114548 +static void search_missing_size_overflow_attribute_gimple(const_gimple stmt, unsigned int num)
114549 +{
114550 + tree fndecl = NULL_TREE;
114551 + tree lhs;
114552 + struct pointer_set_t *visited;
114553 +
114554 + if (is_turn_off_intentional_attr(DECL_ORIGIN(current_function_decl)))
114555 + return;
114556 +
114557 + if (num == 0) {
114558 + gcc_assert(gimple_code(stmt) == GIMPLE_RETURN);
114559 + lhs = gimple_return_retval(stmt);
114560 + } else {
114561 + gcc_assert(is_gimple_call(stmt));
114562 + lhs = gimple_call_arg(stmt, num - 1);
114563 + fndecl = gimple_call_fndecl(stmt);
114564 + }
114565 +
114566 + if (fndecl != NULL_TREE && is_turn_off_intentional_attr(DECL_ORIGIN(fndecl)))
114567 + return;
114568 +
114569 + visited = pointer_set_create();
114570 + search_size_overflow_attribute(visited, lhs);
114571 + pointer_set_destroy(visited);
114572 +}
114573 +
114574 +static void create_output_from_phi(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
114575 +{
114576 + gimple_stmt_iterator gsi;
114577 + gimple assign;
114578 +
114579 + assign = gimple_build_assign(asm_data->input, asm_data->output);
114580 + gsi = gsi_for_stmt(stmt);
114581 + gsi_insert_before(&gsi, assign, GSI_NEW_STMT);
114582 + asm_data->def_stmt = assign;
114583 +
114584 + asm_data->output = create_new_var(TREE_TYPE(asm_data->output));
114585 + asm_data->output = make_ssa_name(asm_data->output, stmt);
114586 + if (gimple_code(stmt) == GIMPLE_RETURN)
114587 + gimple_return_set_retval(stmt, asm_data->output);
114588 + else
114589 + gimple_call_set_arg(stmt, argnum - 1, asm_data->output);
114590 + update_stmt(stmt);
114591 +}
114592 +
114593 +static char *create_asm_comment(unsigned int argnum, const_gimple stmt , const char *mark_str)
114594 +{
114595 + const char *fn_name;
114596 + char *asm_comment;
114597 + unsigned int len;
114598 +
114599 + if (argnum == 0)
114600 + fn_name = NAME(current_function_decl);
114601 + else
114602 + fn_name = NAME(gimple_call_fndecl(stmt));
114603 +
114604 + len = asprintf(&asm_comment, "%s %s %u", mark_str, fn_name, argnum);
114605 + gcc_assert(len > 0);
114606 +
114607 + return asm_comment;
114608 +}
114609 +
114610 +static const char *convert_mark_to_str(enum mark mark)
114611 +{
114612 + switch (mark) {
114613 + case MARK_NO:
114614 + return OK_ASM_STR;
114615 + case MARK_YES:
114616 + case MARK_NOT_INTENTIONAL:
114617 + return YES_ASM_STR;
114618 + case MARK_TURN_OFF:
114619 + return TURN_OFF_ASM_STR;
114620 + }
114621 +
114622 + gcc_unreachable();
114623 +}
114624 +
114625 +/* Create the input of the size_overflow asm stmt.
114626 + * When the arg of the callee function is a parm_decl it creates this kind of size_overflow asm stmt:
114627 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
114628 + * The input field in asm_data will be empty if there is no need for further size_overflow asm stmt insertion.
114629 + * otherwise create the input (for a phi stmt the output too) of the asm stmt.
114630 + */
114631 +static void create_asm_input(gimple stmt, unsigned int argnum, struct asm_data *asm_data)
114632 +{
114633 + if (!asm_data->def_stmt) {
114634 + asm_data->input = NULL_TREE;
114635 + return;
114636 + }
114637 +
114638 + asm_data->input = create_new_var(TREE_TYPE(asm_data->output));
114639 + asm_data->input = make_ssa_name(asm_data->input, asm_data->def_stmt);
114640 +
114641 + switch (gimple_code(asm_data->def_stmt)) {
114642 + case GIMPLE_ASSIGN:
114643 + case GIMPLE_CALL:
114644 + replace_call_lhs(asm_data);
114645 + break;
114646 + case GIMPLE_PHI:
114647 + create_output_from_phi(stmt, argnum, asm_data);
114648 + break;
114649 + case GIMPLE_NOP: {
114650 + enum mark mark;
114651 + const char *mark_str;
114652 + char *asm_comment;
114653 +
114654 + mark = check_intentional_attribute_gimple(asm_data->output, stmt, argnum);
114655 +
114656 + asm_data->input = asm_data->output;
114657 + asm_data->output = NULL;
114658 + asm_data->def_stmt = stmt;
114659 +
114660 + mark_str = convert_mark_to_str(mark);
114661 + asm_comment = create_asm_comment(argnum, stmt, mark_str);
114662 +
114663 + create_asm_stmt(asm_comment, build_string(2, "rm"), NULL, asm_data);
114664 + free(asm_comment);
114665 + asm_data->input = NULL_TREE;
114666 + break;
114667 + }
114668 + case GIMPLE_ASM:
114669 + if (is_size_overflow_asm(asm_data->def_stmt)) {
114670 + asm_data->input = NULL_TREE;
114671 + break;
114672 + }
114673 + default:
114674 + debug_gimple_stmt(asm_data->def_stmt);
114675 + gcc_unreachable();
114676 + }
114677 +}
114678 +
114679 +/* This is the gimple part of searching for a missing size_overflow attribute. If the intentional_overflow attribute type
114680 + * is of the right kind create the appropriate size_overflow asm stmts:
114681 + * __asm__("# size_overflow" : =rm" D.3344_8 : "0" cicus.4_16);
114682 + * __asm__("# size_overflow MARK_YES" : : "rm" size_1(D));
114683 + */
114684 +static void create_size_overflow_asm(gimple stmt, tree output_node, unsigned int argnum)
114685 +{
114686 + struct asm_data asm_data;
114687 + const char *mark_str;
114688 + char *asm_comment;
114689 + enum mark mark;
114690 +
114691 + if (is_gimple_constant(output_node))
114692 + return;
114693 +
114694 + asm_data.output = output_node;
114695 + mark = check_intentional_attribute_gimple(asm_data.output, stmt, argnum);
114696 + if (mark != MARK_TURN_OFF)
114697 + search_missing_size_overflow_attribute_gimple(stmt, argnum);
114698 +
114699 + asm_data.def_stmt = get_def_stmt(asm_data.output);
114700 + if (is_size_overflow_intentional_asm_turn_off(asm_data.def_stmt))
114701 + return;
114702 +
114703 + create_asm_input(stmt, argnum, &asm_data);
114704 + if (asm_data.input == NULL_TREE)
114705 + return;
114706 +
114707 + mark_str = convert_mark_to_str(mark);
114708 + asm_comment = create_asm_comment(argnum, stmt, mark_str);
114709 + create_asm_stmt(asm_comment, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
114710 + free(asm_comment);
114711 +}
114712 +
114713 +// Insert an asm stmt with "MARK_TURN_OFF", "MARK_YES" or "MARK_NOT_INTENTIONAL".
114714 +static bool create_mark_asm(gimple stmt, enum mark mark)
114715 +{
114716 + struct asm_data asm_data;
114717 + const char *asm_str;
114718 +
114719 + switch (mark) {
114720 + case MARK_TURN_OFF:
114721 + asm_str = TURN_OFF_ASM_STR;
114722 + break;
114723 + case MARK_NOT_INTENTIONAL:
114724 + case MARK_YES:
114725 + asm_str = YES_ASM_STR;
114726 + break;
114727 + default:
114728 + gcc_unreachable();
114729 + }
114730 +
114731 + asm_data.def_stmt = stmt;
114732 + asm_data.output = gimple_call_lhs(stmt);
114733 +
114734 + if (asm_data.output == NULL_TREE) {
114735 + asm_data.input = gimple_call_arg(stmt, 0);
114736 + if (is_gimple_constant(asm_data.input))
114737 + return false;
114738 + asm_data.output = NULL;
114739 + create_asm_stmt(asm_str, build_string(2, "rm"), NULL, &asm_data);
114740 + return true;
114741 + }
114742 +
114743 + create_asm_input(stmt, 0, &asm_data);
114744 + gcc_assert(asm_data.input != NULL_TREE);
114745 +
114746 + create_asm_stmt(asm_str, build_string(1, "0"), build_string(3, "=rm"), &asm_data);
114747 + return true;
114748 +}
114749 +
114750 +static bool is_from_cast(const_tree node)
114751 +{
114752 + gimple def_stmt = get_def_stmt(node);
114753 +
114754 + if (!def_stmt)
114755 + return false;
114756 +
114757 + if (gimple_assign_cast_p(def_stmt))
114758 + return true;
114759 +
114760 + return false;
114761 +}
114762 +
114763 +// Skip duplication when there is a minus expr and the type of rhs1 or rhs2 is a pointer_type.
114764 +static bool skip_ptr_minus(gimple stmt)
114765 +{
114766 + const_tree rhs1, rhs2, ptr1_rhs, ptr2_rhs;
114767 +
114768 + if (gimple_assign_rhs_code(stmt) != MINUS_EXPR)
114769 + return false;
114770 +
114771 + rhs1 = gimple_assign_rhs1(stmt);
114772 + if (!is_from_cast(rhs1))
114773 + return false;
114774 +
114775 + rhs2 = gimple_assign_rhs2(stmt);
114776 + if (!is_from_cast(rhs2))
114777 + return false;
114778 +
114779 + ptr1_rhs = gimple_assign_rhs1(get_def_stmt(rhs1));
114780 + ptr2_rhs = gimple_assign_rhs1(get_def_stmt(rhs2));
114781 +
114782 + if (TREE_CODE(TREE_TYPE(ptr1_rhs)) != POINTER_TYPE && TREE_CODE(TREE_TYPE(ptr2_rhs)) != POINTER_TYPE)
114783 + return false;
114784 +
114785 + create_mark_asm(stmt, MARK_YES);
114786 + return true;
114787 +}
114788 +
114789 +static void walk_use_def_ptr(struct pointer_set_t *visited, const_tree lhs)
114790 +{
114791 + gimple def_stmt;
114792 +
114793 + def_stmt = get_def_stmt(lhs);
114794 + if (!def_stmt)
114795 + return;
114796 +
114797 + if (pointer_set_insert(visited, def_stmt))
114798 + return;
114799 +
114800 + switch (gimple_code(def_stmt)) {
114801 + case GIMPLE_NOP:
114802 + case GIMPLE_ASM:
114803 + case GIMPLE_CALL:
114804 + break;
114805 + case GIMPLE_PHI: {
114806 + unsigned int i, n = gimple_phi_num_args(def_stmt);
114807 +
114808 + pointer_set_insert(visited, def_stmt);
114809 +
114810 + for (i = 0; i < n; i++) {
114811 + tree arg = gimple_phi_arg_def(def_stmt, i);
114812 +
114813 + walk_use_def_ptr(visited, arg);
114814 + }
114815 + }
114816 + case GIMPLE_ASSIGN:
114817 + switch (gimple_num_ops(def_stmt)) {
114818 + case 2:
114819 + walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt));
114820 + return;
114821 + case 3:
114822 + if (skip_ptr_minus(def_stmt))
114823 + return;
114824 +
114825 + walk_use_def_ptr(visited, gimple_assign_rhs1(def_stmt));
114826 + walk_use_def_ptr(visited, gimple_assign_rhs2(def_stmt));
114827 + return;
114828 + default:
114829 + return;
114830 + }
114831 + default:
114832 + debug_gimple_stmt((gimple)def_stmt);
114833 + error("%s: unknown gimple code", __func__);
114834 + gcc_unreachable();
114835 + }
114836 +}
114837 +
114838 +// Look for a ptr - ptr expression (e.g., cpuset_common_file_read() s - page)
114839 +static void insert_mark_not_intentional_asm_at_ptr(const_tree arg)
114840 +{
114841 + struct pointer_set_t *visited;
114842 +
114843 + visited = pointer_set_create();
114844 + walk_use_def_ptr(visited, arg);
114845 + pointer_set_destroy(visited);
114846 +}
114847 +
114848 +// Determine the return value and insert the asm stmt to mark the return stmt.
114849 +static void insert_asm_ret(gimple stmt)
114850 +{
114851 + tree ret;
114852 +
114853 + ret = gimple_return_retval(stmt);
114854 + create_size_overflow_asm(stmt, ret, 0);
114855 +}
114856 +
114857 +// Determine the correct arg index and arg and insert the asm stmt to mark the stmt.
114858 +static void insert_asm_arg(gimple stmt, unsigned int orig_argnum)
114859 +{
114860 + tree arg;
114861 + unsigned int argnum;
114862 +
114863 + argnum = get_correct_arg_count(orig_argnum, gimple_call_fndecl(stmt));
114864 + gcc_assert(argnum != 0);
114865 + if (argnum == CANNOT_FIND_ARG)
114866 + return;
114867 +
114868 + arg = gimple_call_arg(stmt, argnum - 1);
114869 + gcc_assert(arg != NULL_TREE);
114870 +
114871 + // skip all ptr - ptr expressions
114872 + insert_mark_not_intentional_asm_at_ptr(arg);
114873 +
114874 + create_size_overflow_asm(stmt, arg, argnum);
114875 +}
114876 +
114877 +// If a function arg or the return value is marked by the size_overflow attribute then set its index in the array.
114878 +static void set_argnum_attribute(const_tree attr, bool *argnums)
114879 +{
114880 + unsigned int argnum;
114881 + tree attr_value;
114882 +
114883 + for (attr_value = TREE_VALUE(attr); attr_value; attr_value = TREE_CHAIN(attr_value)) {
114884 + argnum = TREE_INT_CST_LOW(TREE_VALUE(attr_value));
114885 + argnums[argnum] = true;
114886 + }
114887 +}
114888 +
114889 +// If a function arg or the return value is in the hash table then set its index in the array.
114890 +static void set_argnum_hash(tree fndecl, bool *argnums)
114891 +{
114892 + unsigned int num;
114893 + const struct size_overflow_hash *hash;
114894 +
114895 + hash = get_function_hash(DECL_ORIGIN(fndecl));
114896 + if (!hash)
114897 + return;
114898 +
114899 + for (num = 0; num <= MAX_PARAM; num++) {
114900 + if (!(hash->param & (1U << num)))
114901 + continue;
114902 +
114903 + argnums[num] = true;
114904 + }
114905 +}
114906 +
114907 +static bool is_all_the_argnums_empty(bool *argnums)
114908 +{
114909 + unsigned int i;
114910 +
114911 + for (i = 0; i <= MAX_PARAM; i++)
114912 + if (argnums[i])
114913 + return false;
114914 + return true;
114915 +}
114916 +
114917 +// Check whether the arguments or the return value of the function are in the hash table or are marked by the size_overflow attribute.
114918 +static void search_interesting_args(tree fndecl, bool *argnums)
114919 +{
114920 + const_tree attr;
114921 +
114922 + set_argnum_hash(fndecl, argnums);
114923 + if (!is_all_the_argnums_empty(argnums))
114924 + return;
114925 +
114926 + attr = lookup_attribute("size_overflow", DECL_ATTRIBUTES(fndecl));
114927 + if (attr && TREE_VALUE(attr))
114928 + set_argnum_attribute(attr, argnums);
114929 +}
114930 +
114931 +/*
114932 + * Look up the intentional_overflow attribute that turns off ipa based duplication
114933 + * on the callee function.
114934 + */
114935 +static bool is_mark_turn_off_attribute(gimple stmt)
114936 +{
114937 + enum mark mark;
114938 + const_tree fndecl = gimple_call_fndecl(stmt);
114939 +
114940 + mark = get_intentional_attr_type(DECL_ORIGIN(fndecl));
114941 + if (mark == MARK_TURN_OFF)
114942 + return true;
114943 + return false;
114944 +}
114945 +
114946 +// 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
114947 +static void handle_interesting_function(gimple stmt)
114948 +{
114949 + unsigned int argnum;
114950 + tree fndecl;
114951 + bool orig_argnums[MAX_PARAM + 1] = {false};
114952 +
114953 + if (gimple_call_num_args(stmt) == 0)
114954 + return;
114955 + fndecl = gimple_call_fndecl(stmt);
114956 + if (fndecl == NULL_TREE)
114957 + return;
114958 + fndecl = DECL_ORIGIN(fndecl);
114959 +
114960 + if (is_mark_turn_off_attribute(stmt)) {
114961 + create_mark_asm(stmt, MARK_TURN_OFF);
114962 + return;
114963 + }
114964 +
114965 + search_interesting_args(fndecl, orig_argnums);
114966 +
114967 + for (argnum = 1; argnum < MAX_PARAM; argnum++)
114968 + if (orig_argnums[argnum])
114969 + insert_asm_arg(stmt, argnum);
114970 +}
114971 +
114972 +// 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
114973 +static void handle_interesting_ret(gimple stmt)
114974 +{
114975 + bool orig_argnums[MAX_PARAM + 1] = {false};
114976 +
114977 + search_interesting_args(current_function_decl, orig_argnums);
114978 +
114979 + if (orig_argnums[0])
114980 + insert_asm_ret(stmt);
114981 +}
114982 +
114983 +// Iterate over all the stmts and search for call and return stmts and mark them if they're in the hash table
114984 +static unsigned int search_interesting_functions(void)
114985 +{
114986 + basic_block bb;
114987 +
114988 + FOR_ALL_BB(bb) {
114989 + gimple_stmt_iterator gsi;
114990 +
114991 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
114992 + gimple stmt = gsi_stmt(gsi);
114993 +
114994 + if (is_size_overflow_asm(stmt))
114995 + continue;
114996 +
114997 + if (is_gimple_call(stmt))
114998 + handle_interesting_function(stmt);
114999 + else if (gimple_code(stmt) == GIMPLE_RETURN)
115000 + handle_interesting_ret(stmt);
115001 + }
115002 + }
115003 + return 0;
115004 +}
115005 +
115006 +/*
115007 + * A lot of functions get inlined before the ipa passes so after the build_ssa gimple pass
115008 + * this pass inserts asm stmts to mark the interesting args
115009 + * that the ipa pass will detect and insert the size overflow checks for.
115010 + */
115011 +static struct gimple_opt_pass insert_size_overflow_asm_pass = {
115012 + .pass = {
115013 + .type = GIMPLE_PASS,
115014 + .name = "insert_size_overflow_asm",
115015 +#if BUILDING_GCC_VERSION >= 4008
115016 + .optinfo_flags = OPTGROUP_NONE,
115017 +#endif
115018 + .gate = NULL,
115019 + .execute = search_interesting_functions,
115020 + .sub = NULL,
115021 + .next = NULL,
115022 + .static_pass_number = 0,
115023 + .tv_id = TV_NONE,
115024 + .properties_required = PROP_cfg,
115025 + .properties_provided = 0,
115026 + .properties_destroyed = 0,
115027 + .todo_flags_start = 0,
115028 + .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
115029 + }
115030 +};
115031 +
115032 +// Create the noreturn report_size_overflow() function decl.
115033 +static void start_unit_callback(void __unused *gcc_data, void __unused *user_data)
115034 +{
115035 + tree fntype;
115036 +
115037 + const_char_ptr_type_node = build_pointer_type(build_type_variant(char_type_node, 1, 0));
115038 +
115039 + // void report_size_overflow(const char *loc_file, unsigned int loc_line, const char *current_func, const char *ssa_var)
115040 + fntype = build_function_type_list(void_type_node,
115041 + const_char_ptr_type_node,
115042 + unsigned_type_node,
115043 + const_char_ptr_type_node,
115044 + const_char_ptr_type_node,
115045 + NULL_TREE);
115046 + report_size_overflow_decl = build_fn_decl("report_size_overflow", fntype);
115047 +
115048 + DECL_ASSEMBLER_NAME(report_size_overflow_decl);
115049 + TREE_PUBLIC(report_size_overflow_decl) = 1;
115050 + DECL_EXTERNAL(report_size_overflow_decl) = 1;
115051 + DECL_ARTIFICIAL(report_size_overflow_decl) = 1;
115052 + TREE_THIS_VOLATILE(report_size_overflow_decl) = 1;
115053 +}
115054 +
115055 +static unsigned int dump_functions(void)
115056 +{
115057 + struct cgraph_node *node;
115058 +
115059 + FOR_EACH_FUNCTION_WITH_GIMPLE_BODY(node) {
115060 + basic_block bb;
115061 +
115062 +#if BUILDING_GCC_VERSION <= 4007
115063 + push_cfun(DECL_STRUCT_FUNCTION(node->decl));
115064 + current_function_decl = node->decl;
115065 +#else
115066 + push_cfun(DECL_STRUCT_FUNCTION(node->symbol.decl));
115067 + current_function_decl = node->symbol.decl;
115068 +#endif
115069 +
115070 + fprintf(stderr, "-----------------------------------------\n%s\n-----------------------------------------\n", NAME(current_function_decl));
115071 +
115072 + FOR_ALL_BB(bb) {
115073 + gimple_stmt_iterator si;
115074 +
115075 + fprintf(stderr, "<bb %u>:\n", bb->index);
115076 + for (si = gsi_start_phis(bb); !gsi_end_p(si); gsi_next(&si))
115077 + debug_gimple_stmt(gsi_stmt(si));
115078 + for (si = gsi_start_bb(bb); !gsi_end_p(si); gsi_next(&si))
115079 + debug_gimple_stmt(gsi_stmt(si));
115080 + fprintf(stderr, "\n");
115081 + }
115082 +
115083 + fprintf(stderr, "-------------------------------------------------------------------------\n");
115084 +
115085 + pop_cfun();
115086 + current_function_decl = NULL_TREE;
115087 + }
115088 +
115089 + fprintf(stderr, "###############################################################################\n");
115090 +
115091 + return 0;
115092 +}
115093 +
115094 +static struct ipa_opt_pass_d pass_dump = {
115095 + .pass = {
115096 + .type = SIMPLE_IPA_PASS,
115097 + .name = "dump",
115098 +#if BUILDING_GCC_VERSION >= 4008
115099 + .optinfo_flags = OPTGROUP_NONE,
115100 +#endif
115101 + .gate = NULL,
115102 + .execute = dump_functions,
115103 + .sub = NULL,
115104 + .next = NULL,
115105 + .static_pass_number = 0,
115106 + .tv_id = TV_NONE,
115107 + .properties_required = 0,
115108 + .properties_provided = 0,
115109 + .properties_destroyed = 0,
115110 + .todo_flags_start = 0,
115111 + .todo_flags_finish = 0,
115112 + },
115113 + .generate_summary = NULL,
115114 + .write_summary = NULL,
115115 + .read_summary = NULL,
115116 +#if BUILDING_GCC_VERSION >= 4006
115117 + .write_optimization_summary = NULL,
115118 + .read_optimization_summary = NULL,
115119 +#endif
115120 + .stmt_fixup = NULL,
115121 + .function_transform_todo_flags_start = 0,
115122 + .function_transform = NULL,
115123 + .variable_transform = NULL,
115124 +};
115125 +
115126 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
115127 +{
115128 + int i;
115129 + const char * const plugin_name = plugin_info->base_name;
115130 + const int argc = plugin_info->argc;
115131 + const struct plugin_argument * const argv = plugin_info->argv;
115132 + bool enable = true;
115133 +
115134 + struct register_pass_info insert_size_overflow_asm_pass_info = {
115135 + .pass = &insert_size_overflow_asm_pass.pass,
115136 + .reference_pass_name = "ssa",
115137 + .ref_pass_instance_number = 1,
115138 + .pos_op = PASS_POS_INSERT_AFTER
115139 + };
115140 +
115141 + struct register_pass_info __unused dump_before_pass_info = {
115142 + .pass = &pass_dump.pass,
115143 + .reference_pass_name = "increase_alignment",
115144 + .ref_pass_instance_number = 1,
115145 + .pos_op = PASS_POS_INSERT_BEFORE
115146 + };
115147 +
115148 + struct register_pass_info ipa_pass_info = {
115149 + .pass = &pass_ipa.pass,
115150 + .reference_pass_name = "increase_alignment",
115151 + .ref_pass_instance_number = 1,
115152 + .pos_op = PASS_POS_INSERT_BEFORE
115153 + };
115154 +
115155 + struct register_pass_info __unused dump_after_pass_info = {
115156 + .pass = &pass_dump.pass,
115157 + .reference_pass_name = "increase_alignment",
115158 + .ref_pass_instance_number = 1,
115159 + .pos_op = PASS_POS_INSERT_BEFORE
115160 + };
115161 +
115162 + if (!plugin_default_version_check(version, &gcc_version)) {
115163 + error(G_("incompatible gcc/plugin versions"));
115164 + return 1;
115165 + }
115166 +
115167 + for (i = 0; i < argc; ++i) {
115168 + if (!strcmp(argv[i].key, "no-size-overflow")) {
115169 + enable = false;
115170 + continue;
115171 + }
115172 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115173 + }
115174 +
115175 + register_callback(plugin_name, PLUGIN_INFO, NULL, &size_overflow_plugin_info);
115176 + if (enable) {
115177 + register_callback("start_unit", PLUGIN_START_UNIT, &start_unit_callback, NULL);
115178 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &insert_size_overflow_asm_pass_info);
115179 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_before_pass_info);
115180 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &ipa_pass_info);
115181 +// register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &dump_after_pass_info);
115182 + }
115183 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
115184 +
115185 + return 0;
115186 +}
115187 diff --git a/tools/gcc/stackleak_plugin.c b/tools/gcc/stackleak_plugin.c
115188 new file mode 100644
115189 index 0000000..ac2901e
115190 --- /dev/null
115191 +++ b/tools/gcc/stackleak_plugin.c
115192 @@ -0,0 +1,327 @@
115193 +/*
115194 + * Copyright 2011-2013 by the PaX Team <pageexec@freemail.hu>
115195 + * Licensed under the GPL v2
115196 + *
115197 + * Note: the choice of the license means that the compilation process is
115198 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
115199 + * but for the kernel it doesn't matter since it doesn't link against
115200 + * any of the gcc libraries
115201 + *
115202 + * gcc plugin to help implement various PaX features
115203 + *
115204 + * - track lowest stack pointer
115205 + *
115206 + * TODO:
115207 + * - initialize all local variables
115208 + *
115209 + * BUGS:
115210 + * - none known
115211 + */
115212 +#include "gcc-plugin.h"
115213 +#include "config.h"
115214 +#include "system.h"
115215 +#include "coretypes.h"
115216 +#include "tree.h"
115217 +#include "tree-pass.h"
115218 +#include "flags.h"
115219 +#include "intl.h"
115220 +#include "toplev.h"
115221 +#include "plugin.h"
115222 +//#include "expr.h" where are you...
115223 +#include "diagnostic.h"
115224 +#include "plugin-version.h"
115225 +#include "tm.h"
115226 +#include "function.h"
115227 +#include "basic-block.h"
115228 +#include "gimple.h"
115229 +#include "rtl.h"
115230 +#include "emit-rtl.h"
115231 +
115232 +#if BUILDING_GCC_VERSION >= 4008
115233 +#define TODO_dump_func 0
115234 +#endif
115235 +
115236 +extern void print_gimple_stmt(FILE *, gimple, int, int);
115237 +
115238 +int plugin_is_GPL_compatible;
115239 +
115240 +static int track_frame_size = -1;
115241 +static const char track_function[] = "pax_track_stack";
115242 +static const char check_function[] = "pax_check_alloca";
115243 +static bool init_locals;
115244 +
115245 +static struct plugin_info stackleak_plugin_info = {
115246 + .version = "201302112000",
115247 + .help = "track-lowest-sp=nn\ttrack sp in functions whose frame size is at least nn bytes\n"
115248 +// "initialize-locals\t\tforcibly initialize all stack frames\n"
115249 +};
115250 +
115251 +static bool gate_stackleak_track_stack(void);
115252 +static unsigned int execute_stackleak_tree_instrument(void);
115253 +static unsigned int execute_stackleak_final(void);
115254 +
115255 +static struct gimple_opt_pass stackleak_tree_instrument_pass = {
115256 + .pass = {
115257 + .type = GIMPLE_PASS,
115258 + .name = "stackleak_tree_instrument",
115259 +#if BUILDING_GCC_VERSION >= 4008
115260 + .optinfo_flags = OPTGROUP_NONE,
115261 +#endif
115262 + .gate = gate_stackleak_track_stack,
115263 + .execute = execute_stackleak_tree_instrument,
115264 + .sub = NULL,
115265 + .next = NULL,
115266 + .static_pass_number = 0,
115267 + .tv_id = TV_NONE,
115268 + .properties_required = PROP_gimple_leh | PROP_cfg,
115269 + .properties_provided = 0,
115270 + .properties_destroyed = 0,
115271 + .todo_flags_start = 0, //TODO_verify_ssa | TODO_verify_flow | TODO_verify_stmts,
115272 + .todo_flags_finish = TODO_verify_ssa | TODO_verify_stmts | TODO_dump_func | TODO_update_ssa
115273 + }
115274 +};
115275 +
115276 +static struct rtl_opt_pass stackleak_final_rtl_opt_pass = {
115277 + .pass = {
115278 + .type = RTL_PASS,
115279 + .name = "stackleak_final",
115280 +#if BUILDING_GCC_VERSION >= 4008
115281 + .optinfo_flags = OPTGROUP_NONE,
115282 +#endif
115283 + .gate = gate_stackleak_track_stack,
115284 + .execute = execute_stackleak_final,
115285 + .sub = NULL,
115286 + .next = NULL,
115287 + .static_pass_number = 0,
115288 + .tv_id = TV_NONE,
115289 + .properties_required = 0,
115290 + .properties_provided = 0,
115291 + .properties_destroyed = 0,
115292 + .todo_flags_start = 0,
115293 + .todo_flags_finish = TODO_dump_func
115294 + }
115295 +};
115296 +
115297 +static bool gate_stackleak_track_stack(void)
115298 +{
115299 + return track_frame_size >= 0;
115300 +}
115301 +
115302 +static void stackleak_check_alloca(gimple_stmt_iterator *gsi)
115303 +{
115304 + gimple check_alloca;
115305 + tree fntype, fndecl, alloca_size;
115306 +
115307 + fntype = build_function_type_list(void_type_node, long_unsigned_type_node, NULL_TREE);
115308 + fndecl = build_fn_decl(check_function, fntype);
115309 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
115310 +
115311 + // insert call to void pax_check_alloca(unsigned long size)
115312 + alloca_size = gimple_call_arg(gsi_stmt(*gsi), 0);
115313 + check_alloca = gimple_build_call(fndecl, 1, alloca_size);
115314 + gsi_insert_before(gsi, check_alloca, GSI_SAME_STMT);
115315 +}
115316 +
115317 +static void stackleak_add_instrumentation(gimple_stmt_iterator *gsi)
115318 +{
115319 + gimple track_stack;
115320 + tree fntype, fndecl;
115321 +
115322 + fntype = build_function_type_list(void_type_node, NULL_TREE);
115323 + fndecl = build_fn_decl(track_function, fntype);
115324 + DECL_ASSEMBLER_NAME(fndecl); // for LTO
115325 +
115326 + // insert call to void pax_track_stack(void)
115327 + track_stack = gimple_build_call(fndecl, 0);
115328 + gsi_insert_after(gsi, track_stack, GSI_CONTINUE_LINKING);
115329 +}
115330 +
115331 +#if BUILDING_GCC_VERSION == 4005
115332 +static bool gimple_call_builtin_p(gimple stmt, enum built_in_function code)
115333 +{
115334 + tree fndecl;
115335 +
115336 + if (!is_gimple_call(stmt))
115337 + return false;
115338 + fndecl = gimple_call_fndecl(stmt);
115339 + if (!fndecl)
115340 + return false;
115341 + if (DECL_BUILT_IN_CLASS(fndecl) != BUILT_IN_NORMAL)
115342 + return false;
115343 +// print_node(stderr, "pax", fndecl, 4);
115344 + return DECL_FUNCTION_CODE(fndecl) == code;
115345 +}
115346 +#endif
115347 +
115348 +static bool is_alloca(gimple stmt)
115349 +{
115350 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA))
115351 + return true;
115352 +
115353 +#if BUILDING_GCC_VERSION >= 4007
115354 + if (gimple_call_builtin_p(stmt, BUILT_IN_ALLOCA_WITH_ALIGN))
115355 + return true;
115356 +#endif
115357 +
115358 + return false;
115359 +}
115360 +
115361 +static unsigned int execute_stackleak_tree_instrument(void)
115362 +{
115363 + basic_block bb, entry_bb;
115364 + bool prologue_instrumented = false, is_leaf = true;
115365 +
115366 + entry_bb = ENTRY_BLOCK_PTR_FOR_FUNCTION(cfun)->next_bb;
115367 +
115368 + // 1. loop through BBs and GIMPLE statements
115369 + FOR_EACH_BB(bb) {
115370 + gimple_stmt_iterator gsi;
115371 +
115372 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
115373 + gimple stmt;
115374 +
115375 + stmt = gsi_stmt(gsi);
115376 +
115377 + if (is_gimple_call(stmt))
115378 + is_leaf = false;
115379 +
115380 + // gimple match: align 8 built-in BUILT_IN_NORMAL:BUILT_IN_ALLOCA attributes <tree_list 0xb7576450>
115381 + if (!is_alloca(stmt))
115382 + continue;
115383 +
115384 + // 2. insert stack overflow check before each __builtin_alloca call
115385 + stackleak_check_alloca(&gsi);
115386 +
115387 + // 3. insert track call after each __builtin_alloca call
115388 + stackleak_add_instrumentation(&gsi);
115389 + if (bb == entry_bb)
115390 + prologue_instrumented = true;
115391 + }
115392 + }
115393 +
115394 + // special cases for some bad linux code: taking the address of static inline functions will materialize them
115395 + // but we mustn't instrument some of them as the resulting stack alignment required by the function call ABI
115396 + // will break other assumptions regarding the expected (but not otherwise enforced) register clobbering ABI.
115397 + // case in point: native_save_fl on amd64 when optimized for size clobbers rdx if it were instrumented here.
115398 + if (is_leaf && !TREE_PUBLIC(current_function_decl) && DECL_DECLARED_INLINE_P(current_function_decl))
115399 + return 0;
115400 + if (is_leaf && !strncmp(IDENTIFIER_POINTER(DECL_NAME(current_function_decl)), "_paravirt_", 10))
115401 + return 0;
115402 +
115403 + // 4. insert track call at the beginning
115404 + if (!prologue_instrumented) {
115405 + gimple_stmt_iterator gsi;
115406 +
115407 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
115408 + if (dom_info_available_p(CDI_DOMINATORS))
115409 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
115410 + gsi = gsi_start_bb(bb);
115411 + stackleak_add_instrumentation(&gsi);
115412 + }
115413 +
115414 + return 0;
115415 +}
115416 +
115417 +static unsigned int execute_stackleak_final(void)
115418 +{
115419 + rtx insn, next;
115420 +
115421 + if (cfun->calls_alloca)
115422 + return 0;
115423 +
115424 + // keep calls only if function frame is big enough
115425 + if (get_frame_size() >= track_frame_size)
115426 + return 0;
115427 +
115428 + // 1. find pax_track_stack calls
115429 + for (insn = get_insns(); insn; insn = next) {
115430 + // 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))
115431 + rtx body;
115432 +
115433 + next = NEXT_INSN(insn);
115434 + if (!CALL_P(insn))
115435 + continue;
115436 + body = PATTERN(insn);
115437 + if (GET_CODE(body) != CALL)
115438 + continue;
115439 + body = XEXP(body, 0);
115440 + if (GET_CODE(body) != MEM)
115441 + continue;
115442 + body = XEXP(body, 0);
115443 + if (GET_CODE(body) != SYMBOL_REF)
115444 + continue;
115445 + if (strcmp(XSTR(body, 0), track_function))
115446 + continue;
115447 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
115448 + // 2. delete call
115449 + delete_insn_and_edges(insn);
115450 +#if BUILDING_GCC_VERSION >= 4007
115451 + if (GET_CODE(next) == NOTE && NOTE_KIND(next) == NOTE_INSN_CALL_ARG_LOCATION) {
115452 + insn = next;
115453 + next = NEXT_INSN(insn);
115454 + delete_insn_and_edges(insn);
115455 + }
115456 +#endif
115457 + }
115458 +
115459 +// print_simple_rtl(stderr, get_insns());
115460 +// print_rtl(stderr, get_insns());
115461 +// warning(0, "track_frame_size: %d %ld %d", cfun->calls_alloca, get_frame_size(), track_frame_size);
115462 +
115463 + return 0;
115464 +}
115465 +
115466 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
115467 +{
115468 + const char * const plugin_name = plugin_info->base_name;
115469 + const int argc = plugin_info->argc;
115470 + const struct plugin_argument * const argv = plugin_info->argv;
115471 + int i;
115472 + struct register_pass_info stackleak_tree_instrument_pass_info = {
115473 + .pass = &stackleak_tree_instrument_pass.pass,
115474 +// .reference_pass_name = "tree_profile",
115475 + .reference_pass_name = "optimized",
115476 + .ref_pass_instance_number = 1,
115477 + .pos_op = PASS_POS_INSERT_BEFORE
115478 + };
115479 + struct register_pass_info stackleak_final_pass_info = {
115480 + .pass = &stackleak_final_rtl_opt_pass.pass,
115481 + .reference_pass_name = "final",
115482 + .ref_pass_instance_number = 1,
115483 + .pos_op = PASS_POS_INSERT_BEFORE
115484 + };
115485 +
115486 + if (!plugin_default_version_check(version, &gcc_version)) {
115487 + error(G_("incompatible gcc/plugin versions"));
115488 + return 1;
115489 + }
115490 +
115491 + register_callback(plugin_name, PLUGIN_INFO, NULL, &stackleak_plugin_info);
115492 +
115493 + for (i = 0; i < argc; ++i) {
115494 + if (!strcmp(argv[i].key, "track-lowest-sp")) {
115495 + if (!argv[i].value) {
115496 + error(G_("no value supplied for option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115497 + continue;
115498 + }
115499 + track_frame_size = atoi(argv[i].value);
115500 + if (argv[i].value[0] < '0' || argv[i].value[0] > '9' || track_frame_size < 0)
115501 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
115502 + continue;
115503 + }
115504 + if (!strcmp(argv[i].key, "initialize-locals")) {
115505 + if (argv[i].value) {
115506 + error(G_("invalid option argument '-fplugin-arg-%s-%s=%s'"), plugin_name, argv[i].key, argv[i].value);
115507 + continue;
115508 + }
115509 + init_locals = true;
115510 + continue;
115511 + }
115512 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115513 + }
115514 +
115515 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_tree_instrument_pass_info);
115516 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &stackleak_final_pass_info);
115517 +
115518 + return 0;
115519 +}
115520 diff --git a/tools/gcc/structleak_plugin.c b/tools/gcc/structleak_plugin.c
115521 new file mode 100644
115522 index 0000000..4fae911
115523 --- /dev/null
115524 +++ b/tools/gcc/structleak_plugin.c
115525 @@ -0,0 +1,277 @@
115526 +/*
115527 + * Copyright 2013 by PaX Team <pageexec@freemail.hu>
115528 + * Licensed under the GPL v2
115529 + *
115530 + * Note: the choice of the license means that the compilation process is
115531 + * NOT 'eligible' as defined by gcc's library exception to the GPL v3,
115532 + * but for the kernel it doesn't matter since it doesn't link against
115533 + * any of the gcc libraries
115534 + *
115535 + * gcc plugin to forcibly initialize certain local variables that could
115536 + * otherwise leak kernel stack to userland if they aren't properly initialized
115537 + * by later code
115538 + *
115539 + * Homepage: http://pax.grsecurity.net/
115540 + *
115541 + * Usage:
115542 + * $ # for 4.5/4.6/C based 4.7
115543 + * $ 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
115544 + * $ # for C++ based 4.7/4.8+
115545 + * $ 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
115546 + * $ gcc -fplugin=./structleak_plugin.so test.c -O2
115547 + *
115548 + * TODO: eliminate redundant initializers
115549 + * increase type coverage
115550 + */
115551 +
115552 +#include "gcc-plugin.h"
115553 +#include "config.h"
115554 +#include "system.h"
115555 +#include "coretypes.h"
115556 +#include "tree.h"
115557 +#include "tree-pass.h"
115558 +#include "intl.h"
115559 +#include "plugin-version.h"
115560 +#include "tm.h"
115561 +#include "toplev.h"
115562 +#include "function.h"
115563 +#include "tree-flow.h"
115564 +#include "plugin.h"
115565 +#include "gimple.h"
115566 +#include "diagnostic.h"
115567 +#include "cfgloop.h"
115568 +#include "langhooks.h"
115569 +
115570 +#if BUILDING_GCC_VERSION >= 4008
115571 +#define TODO_dump_func 0
115572 +#endif
115573 +
115574 +#define NAME(node) IDENTIFIER_POINTER(DECL_NAME(node))
115575 +
115576 +// unused type flag in all versions 4.5-4.8
115577 +#define TYPE_USERSPACE(TYPE) TYPE_LANG_FLAG_3(TYPE)
115578 +
115579 +int plugin_is_GPL_compatible;
115580 +void debug_gimple_stmt(gimple gs);
115581 +
115582 +static struct plugin_info structleak_plugin_info = {
115583 + .version = "201304082245",
115584 + .help = "disable\tdo not activate plugin\n",
115585 +};
115586 +
115587 +static tree handle_user_attribute(tree *node, tree name, tree args, int flags, bool *no_add_attrs)
115588 +{
115589 + *no_add_attrs = true;
115590 +
115591 + // check for types? for now accept everything linux has to offer
115592 + if (TREE_CODE(*node) != FIELD_DECL)
115593 + return NULL_TREE;
115594 +
115595 + *no_add_attrs = false;
115596 + return NULL_TREE;
115597 +}
115598 +
115599 +static struct attribute_spec user_attr = {
115600 + .name = "user",
115601 + .min_length = 0,
115602 + .max_length = 0,
115603 + .decl_required = false,
115604 + .type_required = false,
115605 + .function_type_required = false,
115606 + .handler = handle_user_attribute,
115607 +#if BUILDING_GCC_VERSION >= 4007
115608 + .affects_type_identity = true
115609 +#endif
115610 +};
115611 +
115612 +static void register_attributes(void *event_data, void *data)
115613 +{
115614 + register_attribute(&user_attr);
115615 +// register_attribute(&force_attr);
115616 +}
115617 +
115618 +static tree get_field_type(tree field)
115619 +{
115620 + return strip_array_types(TREE_TYPE(field));
115621 +}
115622 +
115623 +static bool is_userspace_type(tree type)
115624 +{
115625 + tree field;
115626 +
115627 + for (field = TYPE_FIELDS(type); field; field = TREE_CHAIN(field)) {
115628 + tree fieldtype = get_field_type(field);
115629 + enum tree_code code = TREE_CODE(fieldtype);
115630 +
115631 + if (code == RECORD_TYPE || code == UNION_TYPE)
115632 + if (is_userspace_type(fieldtype))
115633 + return true;
115634 +
115635 + if (lookup_attribute("user", DECL_ATTRIBUTES(field)))
115636 + return true;
115637 + }
115638 + return false;
115639 +}
115640 +
115641 +static void finish_type(void *event_data, void *data)
115642 +{
115643 + tree type = (tree)event_data;
115644 +
115645 + if (TYPE_USERSPACE(type))
115646 + return;
115647 +
115648 + if (is_userspace_type(type))
115649 + TYPE_USERSPACE(type) = 1;
115650 +}
115651 +
115652 +static void initialize(tree var)
115653 +{
115654 + basic_block bb;
115655 + gimple_stmt_iterator gsi;
115656 + tree initializer;
115657 + gimple init_stmt;
115658 +
115659 + // this is the original entry bb before the forced split
115660 + // TODO: check further BBs in case more splits occured before us
115661 + bb = ENTRY_BLOCK_PTR->next_bb->next_bb;
115662 +
115663 + // first check if the variable is already initialized, warn otherwise
115664 + for (gsi = gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi)) {
115665 + gimple stmt = gsi_stmt(gsi);
115666 + tree rhs1;
115667 +
115668 + // we're looking for an assignment of a single rhs...
115669 + if (!gimple_assign_single_p(stmt))
115670 + continue;
115671 + rhs1 = gimple_assign_rhs1(stmt);
115672 +#if BUILDING_GCC_VERSION >= 4007
115673 + // ... of a non-clobbering expression...
115674 + if (TREE_CLOBBER_P(rhs1))
115675 + continue;
115676 +#endif
115677 + // ... to our variable...
115678 + if (gimple_get_lhs(stmt) != var)
115679 + continue;
115680 + // if it's an initializer then we're good
115681 + if (TREE_CODE(rhs1) == CONSTRUCTOR)
115682 + return;
115683 + }
115684 +
115685 + // these aren't the 0days you're looking for
115686 +// inform(DECL_SOURCE_LOCATION(var), "userspace variable will be forcibly initialized");
115687 +
115688 + // build the initializer expression
115689 + initializer = build_constructor(TREE_TYPE(var), NULL);
115690 +
115691 + // build the initializer stmt
115692 + init_stmt = gimple_build_assign(var, initializer);
115693 + gsi = gsi_start_bb(ENTRY_BLOCK_PTR->next_bb);
115694 + gsi_insert_before(&gsi, init_stmt, GSI_NEW_STMT);
115695 + update_stmt(init_stmt);
115696 +}
115697 +
115698 +static unsigned int handle_function(void)
115699 +{
115700 + basic_block bb;
115701 + unsigned int ret = 0;
115702 + tree var;
115703 +
115704 +#if BUILDING_GCC_VERSION == 4005
115705 + tree vars;
115706 +#else
115707 + unsigned int i;
115708 +#endif
115709 +
115710 + // split the first bb where we can put the forced initializers
115711 + bb = split_block_after_labels(ENTRY_BLOCK_PTR)->dest;
115712 + if (dom_info_available_p(CDI_DOMINATORS))
115713 + set_immediate_dominator(CDI_DOMINATORS, bb, ENTRY_BLOCK_PTR);
115714 +
115715 + // enumarate all local variables and forcibly initialize our targets
115716 +#if BUILDING_GCC_VERSION == 4005
115717 + for (vars = cfun->local_decls; vars; vars = TREE_CHAIN(vars)) {
115718 + var = TREE_VALUE(vars);
115719 +#else
115720 + FOR_EACH_LOCAL_DECL(cfun, i, var) {
115721 +#endif
115722 + tree type = TREE_TYPE(var);
115723 +
115724 + gcc_assert(DECL_P(var));
115725 + if (!auto_var_in_fn_p(var, current_function_decl))
115726 + continue;
115727 +
115728 + // only care about structure types
115729 + if (TREE_CODE(type) != RECORD_TYPE && TREE_CODE(type) != UNION_TYPE)
115730 + continue;
115731 +
115732 + // if the type is of interest, examine the variable
115733 + if (TYPE_USERSPACE(type))
115734 + initialize(var);
115735 + }
115736 +
115737 + return ret;
115738 +}
115739 +
115740 +static struct gimple_opt_pass structleak_pass = {
115741 + .pass = {
115742 + .type = GIMPLE_PASS,
115743 + .name = "structleak",
115744 +#if BUILDING_GCC_VERSION >= 4008
115745 + .optinfo_flags = OPTGROUP_NONE,
115746 +#endif
115747 + .gate = NULL,
115748 + .execute = handle_function,
115749 + .sub = NULL,
115750 + .next = NULL,
115751 + .static_pass_number = 0,
115752 + .tv_id = TV_NONE,
115753 + .properties_required = PROP_cfg,
115754 + .properties_provided = 0,
115755 + .properties_destroyed = 0,
115756 + .todo_flags_start = 0,
115757 + .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
115758 + }
115759 +};
115760 +
115761 +int plugin_init(struct plugin_name_args *plugin_info, struct plugin_gcc_version *version)
115762 +{
115763 + int i;
115764 + const char * const plugin_name = plugin_info->base_name;
115765 + const int argc = plugin_info->argc;
115766 + const struct plugin_argument * const argv = plugin_info->argv;
115767 + bool enable = true;
115768 +
115769 + struct register_pass_info structleak_pass_info = {
115770 + .pass = &structleak_pass.pass,
115771 + .reference_pass_name = "ssa",
115772 + .ref_pass_instance_number = 1,
115773 + .pos_op = PASS_POS_INSERT_AFTER
115774 + };
115775 +
115776 + if (!plugin_default_version_check(version, &gcc_version)) {
115777 + error(G_("incompatible gcc/plugin versions"));
115778 + return 1;
115779 + }
115780 +
115781 + if (strcmp(lang_hooks.name, "GNU C")) {
115782 + inform(UNKNOWN_LOCATION, G_("%s supports C only"), plugin_name);
115783 + enable = false;
115784 + }
115785 +
115786 + for (i = 0; i < argc; ++i) {
115787 + if (!strcmp(argv[i].key, "disable")) {
115788 + enable = false;
115789 + continue;
115790 + }
115791 + error(G_("unkown option '-fplugin-arg-%s-%s'"), plugin_name, argv[i].key);
115792 + }
115793 +
115794 + register_callback(plugin_name, PLUGIN_INFO, NULL, &structleak_plugin_info);
115795 + if (enable) {
115796 + register_callback(plugin_name, PLUGIN_PASS_MANAGER_SETUP, NULL, &structleak_pass_info);
115797 + register_callback(plugin_name, PLUGIN_FINISH_TYPE, finish_type, NULL);
115798 + }
115799 + register_callback(plugin_name, PLUGIN_ATTRIBUTES, register_attributes, NULL);
115800 +
115801 + return 0;
115802 +}
115803 diff --git a/tools/lib/lk/Makefile b/tools/lib/lk/Makefile
115804 index 3dba0a4..97175dc 100644
115805 --- a/tools/lib/lk/Makefile
115806 +++ b/tools/lib/lk/Makefile
115807 @@ -13,7 +13,7 @@ LIB_OBJS += $(OUTPUT)debugfs.o
115808
115809 LIBFILE = liblk.a
115810
115811 -CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
115812 +CFLAGS = -ggdb3 -Wall -Wextra -std=gnu99 -Werror -O6 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 $(EXTRA_WARNINGS) $(EXTRA_CFLAGS) -fPIC
115813 EXTLIBS = -lelf -lpthread -lrt -lm
115814 ALL_CFLAGS = $(CFLAGS) $(BASIC_CFLAGS) -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
115815 ALL_LDFLAGS = $(LDFLAGS)
115816 diff --git a/tools/perf/util/include/asm/alternative-asm.h b/tools/perf/util/include/asm/alternative-asm.h
115817 index 6789d78..4afd019e 100644
115818 --- a/tools/perf/util/include/asm/alternative-asm.h
115819 +++ b/tools/perf/util/include/asm/alternative-asm.h
115820 @@ -5,4 +5,7 @@
115821
115822 #define altinstruction_entry #
115823
115824 + .macro pax_force_retaddr rip=0, reload=0
115825 + .endm
115826 +
115827 #endif
115828 diff --git a/tools/perf/util/include/linux/compiler.h b/tools/perf/util/include/linux/compiler.h
115829 index 96b919d..c49bb74 100644
115830 --- a/tools/perf/util/include/linux/compiler.h
115831 +++ b/tools/perf/util/include/linux/compiler.h
115832 @@ -18,4 +18,12 @@
115833 #define __force
115834 #endif
115835
115836 +#ifndef __size_overflow
115837 +# define __size_overflow(...)
115838 +#endif
115839 +
115840 +#ifndef __intentional_overflow
115841 +# define __intentional_overflow(...)
115842 +#endif
115843 +
115844 #endif
115845 diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
115846 index aac732d..bc87a5d 100644
115847 --- a/virt/kvm/kvm_main.c
115848 +++ b/virt/kvm/kvm_main.c
115849 @@ -75,12 +75,17 @@ LIST_HEAD(vm_list);
115850
115851 static cpumask_var_t cpus_hardware_enabled;
115852 static int kvm_usage_count = 0;
115853 -static atomic_t hardware_enable_failed;
115854 +static atomic_unchecked_t hardware_enable_failed;
115855
115856 struct kmem_cache *kvm_vcpu_cache;
115857 EXPORT_SYMBOL_GPL(kvm_vcpu_cache);
115858
115859 -static __read_mostly struct preempt_ops kvm_preempt_ops;
115860 +static void kvm_sched_in(struct preempt_notifier *pn, int cpu);
115861 +static void kvm_sched_out(struct preempt_notifier *pn, struct task_struct *next);
115862 +static struct preempt_ops kvm_preempt_ops = {
115863 + .sched_in = kvm_sched_in,
115864 + .sched_out = kvm_sched_out,
115865 +};
115866
115867 struct dentry *kvm_debugfs_dir;
115868
115869 @@ -749,7 +754,7 @@ int __kvm_set_memory_region(struct kvm *kvm,
115870 /* We can read the guest memory with __xxx_user() later on. */
115871 if ((mem->slot < KVM_USER_MEM_SLOTS) &&
115872 ((mem->userspace_addr & (PAGE_SIZE - 1)) ||
115873 - !access_ok(VERIFY_WRITE,
115874 + !__access_ok(VERIFY_WRITE,
115875 (void __user *)(unsigned long)mem->userspace_addr,
115876 mem->memory_size)))
115877 goto out;
115878 @@ -1613,8 +1618,17 @@ EXPORT_SYMBOL_GPL(kvm_read_guest_cached);
115879
115880 int kvm_clear_guest_page(struct kvm *kvm, gfn_t gfn, int offset, int len)
115881 {
115882 - return kvm_write_guest_page(kvm, gfn, (const void *) empty_zero_page,
115883 - offset, len);
115884 + int r;
115885 + unsigned long addr;
115886 +
115887 + addr = gfn_to_hva(kvm, gfn);
115888 + if (kvm_is_error_hva(addr))
115889 + return -EFAULT;
115890 + r = __clear_user((void __user *)addr + offset, len);
115891 + if (r)
115892 + return -EFAULT;
115893 + mark_page_dirty(kvm, gfn);
115894 + return 0;
115895 }
115896 EXPORT_SYMBOL_GPL(kvm_clear_guest_page);
115897
115898 @@ -1867,7 +1881,7 @@ static int kvm_vcpu_release(struct inode *inode, struct file *filp)
115899 return 0;
115900 }
115901
115902 -static struct file_operations kvm_vcpu_fops = {
115903 +static file_operations_no_const kvm_vcpu_fops __read_only = {
115904 .release = kvm_vcpu_release,
115905 .unlocked_ioctl = kvm_vcpu_ioctl,
115906 #ifdef CONFIG_COMPAT
115907 @@ -2553,7 +2567,7 @@ static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
115908 return 0;
115909 }
115910
115911 -static struct file_operations kvm_vm_fops = {
115912 +static file_operations_no_const kvm_vm_fops __read_only = {
115913 .release = kvm_vm_release,
115914 .unlocked_ioctl = kvm_vm_ioctl,
115915 #ifdef CONFIG_COMPAT
115916 @@ -2654,7 +2668,7 @@ out:
115917 return r;
115918 }
115919
115920 -static struct file_operations kvm_chardev_ops = {
115921 +static file_operations_no_const kvm_chardev_ops __read_only = {
115922 .unlocked_ioctl = kvm_dev_ioctl,
115923 .compat_ioctl = kvm_dev_ioctl,
115924 .llseek = noop_llseek,
115925 @@ -2680,7 +2694,7 @@ static void hardware_enable_nolock(void *junk)
115926
115927 if (r) {
115928 cpumask_clear_cpu(cpu, cpus_hardware_enabled);
115929 - atomic_inc(&hardware_enable_failed);
115930 + atomic_inc_unchecked(&hardware_enable_failed);
115931 printk(KERN_INFO "kvm: enabling virtualization on "
115932 "CPU%d failed\n", cpu);
115933 }
115934 @@ -2734,10 +2748,10 @@ static int hardware_enable_all(void)
115935
115936 kvm_usage_count++;
115937 if (kvm_usage_count == 1) {
115938 - atomic_set(&hardware_enable_failed, 0);
115939 + atomic_set_unchecked(&hardware_enable_failed, 0);
115940 on_each_cpu(hardware_enable_nolock, NULL, 1);
115941
115942 - if (atomic_read(&hardware_enable_failed)) {
115943 + if (atomic_read_unchecked(&hardware_enable_failed)) {
115944 hardware_disable_all_nolock();
115945 r = -EBUSY;
115946 }
115947 @@ -3171,7 +3185,7 @@ static void kvm_sched_out(struct preempt_notifier *pn,
115948 kvm_arch_vcpu_put(vcpu);
115949 }
115950
115951 -int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115952 +int kvm_init(const void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115953 struct module *module)
115954 {
115955 int r;
115956 @@ -3218,7 +3232,7 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115957 if (!vcpu_align)
115958 vcpu_align = __alignof__(struct kvm_vcpu);
115959 kvm_vcpu_cache = kmem_cache_create("kvm_vcpu", vcpu_size, vcpu_align,
115960 - 0, NULL);
115961 + SLAB_USERCOPY, NULL);
115962 if (!kvm_vcpu_cache) {
115963 r = -ENOMEM;
115964 goto out_free_3;
115965 @@ -3228,9 +3242,11 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115966 if (r)
115967 goto out_free;
115968
115969 + pax_open_kernel();
115970 kvm_chardev_ops.owner = module;
115971 kvm_vm_fops.owner = module;
115972 kvm_vcpu_fops.owner = module;
115973 + pax_close_kernel();
115974
115975 r = misc_register(&kvm_dev);
115976 if (r) {
115977 @@ -3240,9 +3256,6 @@ int kvm_init(void *opaque, unsigned vcpu_size, unsigned vcpu_align,
115978
115979 register_syscore_ops(&kvm_syscore_ops);
115980
115981 - kvm_preempt_ops.sched_in = kvm_sched_in;
115982 - kvm_preempt_ops.sched_out = kvm_sched_out;
115983 -
115984 r = kvm_init_debug();
115985 if (r) {
115986 printk(KERN_ERR "kvm: create debugfs files failed\n");